本文整理汇总了C++中MooseSharedPointer类的典型用法代码示例。如果您正苦于以下问题:C++ MooseSharedPointer类的具体用法?C++ MooseSharedPointer怎么用?C++ MooseSharedPointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MooseSharedPointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
PartitionerAction::act()
{
_mesh->setIsCustomPartitionerRequested(true);
MooseSharedPointer<MoosePartitioner> mp = MooseSharedNamespace::static_pointer_cast<MoosePartitioner>(_factory.create(_type, _name, _moose_object_pars));
_mesh->setCustomPartitioner(mp->getPartitioner());
}
示例2: addOutputFilename
void
OutputWarehouse::addOutput(MooseSharedPointer<Output> & output)
{
_all_ptrs.push_back(output);
// Add the object to the warehouse storage, Checkpoint placed at end so they are called last
Checkpoint * cp = dynamic_cast<Checkpoint *>(output.get());
if (cp != NULL)
_all_objects.push_back(output.get());
else
_all_objects.insert(_all_objects.begin(), output.get());
// Store the name and pointer
_object_map[output->name()] = output.get();
_object_names.insert(output->name());
// If the output object is a FileOutput then store the output filename
FileOutput * ptr = dynamic_cast<FileOutput *>(output.get());
if (ptr != NULL)
addOutputFilename(ptr->filename());
// Insert object sync times to the global set
if (output->parameters().isParamValid("sync_times"))
{
std::vector<Real> sync_times = output->parameters().get<std::vector<Real> >("sync_times");
_sync_times.insert(sync_times.begin(), sync_times.end());
}
}
示例3:
void
ComputeFullJacobianThread::computeJacobian()
{
std::vector<std::pair<MooseVariable *, MooseVariable *> > & ce = _fe_problem.couplingEntries(_tid);
for (std::vector<std::pair<MooseVariable *, MooseVariable *> >::iterator it = ce.begin(); it != ce.end(); ++it)
{
MooseVariable & ivariable = *(*it).first;
MooseVariable & jvariable = *(*it).second;
unsigned int ivar = ivariable.number();
unsigned int jvar = jvariable.number();
if (ivariable.activeOnSubdomain(_subdomain) && jvariable.activeOnSubdomain(_subdomain) && _kernels.hasActiveVariableBlockObjects(ivar, _subdomain, _tid))
{
// only if there are dofs for j-variable (if it is subdomain restricted var, there may not be any)
const std::vector<MooseSharedPointer<KernelBase> > & kernels = _kernels.getActiveVariableBlockObjects(ivar, _subdomain, _tid);
for (std::vector<MooseSharedPointer<KernelBase> >::const_iterator kt = kernels.begin(); kt != kernels.end(); ++kt)
{
MooseSharedPointer<KernelBase> kernel = *kt;
if ((kernel->variable().number() == ivar) && kernel->isImplicit())
{
kernel->subProblem().prepareShapes(jvar, _tid);
kernel->computeOffDiagJacobian(jvar);
}
}
}
}
const std::vector<MooseVariableScalar *> & scalar_vars = _sys.getScalarVariables(_tid);
if (scalar_vars.size() > 0)
{
// go over nl-variables (non-scalar)
const std::vector<MooseVariable *> & vars = _sys.getVariables(_tid);
for (std::vector<MooseVariable *>::const_iterator it = vars.begin(); it != vars.end(); it++)
{
MooseVariable & ivariable = *(*it);
if (ivariable.activeOnSubdomain(_subdomain) > 0 && _kernels.hasActiveVariableBlockObjects(ivariable.number(), _subdomain, _tid))
{
// for each variable get the list of active kernels
const std::vector<MooseSharedPointer<KernelBase> > & kernels = _kernels.getActiveVariableBlockObjects(ivariable.number(), _subdomain, _tid);
for (std::vector<MooseSharedPointer<KernelBase> >::const_iterator kt = kernels.begin(); kt != kernels.end(); ++kt)
{
MooseSharedPointer<KernelBase> kernel = *kt;
if (kernel->isImplicit())
{
// now, get the list of coupled scalar vars and compute their off-diag jacobians
const std::vector<MooseVariableScalar *> coupled_scalar_vars = kernel->getCoupledMooseScalarVars();
for (std::vector<MooseVariableScalar *>::const_iterator jt = coupled_scalar_vars.begin(); jt != coupled_scalar_vars.end(); jt++)
{
MooseVariableScalar & jvariable = *(*jt);
// Do: dvar / dscalar_var
if (_sys.hasScalarVariable(jvariable.name())) // want to process only nl-variables (not aux ones)
kernel->computeOffDiagJacobianScalar(jvariable.number());
}
}
}
}
}
}
}
示例4: addBoundaryMaterial
void MaterialWarehouse::addBoundaryMaterial(std::vector<BoundaryID> boundaries, MooseSharedPointer<Material> & material)
{
_all_ptrs.push_back(material);
_all_objects.push_back(material.get());
for (std::vector<BoundaryID>::const_iterator it = boundaries.begin(); it != boundaries.end(); ++it)
{
_boundaries.insert(*it);
_active_boundary_materials[*it].push_back(material.get());
_mat_by_name[material->name()].push_back(material.get());
}
}
示例5:
void
ControlOutput::outputControls()
{
// Extract InputParameter objects from warehouse
InputParameterWarehouse & wh = _app.getInputParameterWarehouse();
const std::multimap<MooseObjectName, MooseSharedPointer<InputParameters> > & params = wh.getInputParameters();
// The stream to build
std::stringstream oss;
oss << std::left;
// Populate a map based on unique InputParameter objects
std::map<MooseSharedPointer<InputParameters>, std::set<MooseObjectName> > objects;
for (std::multimap<MooseObjectName, MooseSharedPointer<InputParameters> >::const_iterator iter = params.begin(); iter != params.end(); ++iter)
objects[iter->second].insert(iter->first);
// Produce the control information
oss << "Controls:\n";
for (std::map<MooseSharedPointer<InputParameters>, std::set<MooseObjectName> >::const_iterator iter = objects.begin(); iter != objects.end(); ++iter)
{
MooseSharedPointer<InputParameters> ptr = iter->first;
const std::set<std::string> & names = ptr->getControllableParameters();
if (!names.empty())
{
oss << ConsoleUtils::indent(2) << COLOR_YELLOW << ptr->get<std::string>("_object_name") << COLOR_DEFAULT << '\n';
// Full names(s)
oss << ConsoleUtils::indent(4) << "Name(s): ";
for (std::set<MooseObjectName>::const_iterator it = iter->second.begin(); it != iter->second.end(); ++it)
oss << (*it) << " ";
oss << '\n';
// Tag(s)
const std::vector<std::string> & tags = ptr->get<std::vector<std::string> >("control_tags");
if (!tags.empty())
{
oss << ConsoleUtils::indent(4) << "Tag(s): ";
for (std::vector<std::string>::const_iterator it = tags.begin(); it != tags.end(); ++it)
oss << *it << " ";
oss << '\n';
}
oss << ConsoleUtils::indent(4) << "Parameter(s):\n";
for (std::set<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)
oss << ConsoleUtils::indent(6) << std::setw(ConsoleUtils::console_field_width) << *it << ptr->type(*it) << '\n';
}
}
_console << oss.str() << std::endl;
}
示例6: addNeighborMaterial
void MaterialWarehouse::addNeighborMaterial(std::vector<SubdomainID> blocks, MooseSharedPointer<Material> & material)
{
_all_ptrs.push_back(material);
_all_objects.push_back(material.get());
for (unsigned int i=0; i<blocks.size(); ++i)
{
SubdomainID blk_id = blocks[i];
_blocks.insert(blk_id);
_active_neighbor_materials[blk_id].push_back(material.get());
_mat_by_name[material->name()].push_back(material.get());
}
}
示例7:
void
AuxiliarySystem::addKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters)
{
parameters.set<AuxiliarySystem *>("_aux_sys") = this;
for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
{
MooseSharedPointer<AuxKernel> kernel = _factory.create<AuxKernel>(kernel_name, name, parameters, tid);
if (kernel->isNodal())
_nodal_aux_storage.addObject(kernel, tid);
else
_elemental_aux_storage.addObject(kernel, tid);
}
}
示例8:
void
MaterialOutputAction::materialOutputHelper<RealTensorValue>(const std::string & property_name, Material * material)
{
for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
for (unsigned int j = 0; j < LIBMESH_DIM; ++j)
{
std::ostringstream oss;
oss << property_name << "_" << i << j;
MooseSharedPointer<MooseObjectAction> action = MooseSharedNamespace::static_pointer_cast<MooseObjectAction>(createAction("MaterialRealTensorValueAux", property_name, oss.str(), material));
action->getObjectParams().set<unsigned int>("row") = i;
action->getObjectParams().set<unsigned int>("column") = j;
_awh.addActionBlock(action);
}
}
示例9:
void
ComputeJacobianThread::computeJacobian()
{
if (_kernels.hasActiveBlockObjects(_subdomain, _tid))
{
const std::vector<MooseSharedPointer<KernelBase> > & kernels = _kernels.getActiveBlockObjects(_subdomain, _tid);
for (std::vector<MooseSharedPointer<KernelBase> >::const_iterator it = kernels.begin(); it != kernels.end(); ++it)
{
MooseSharedPointer<KernelBase> kernel = *it;
if (kernel->isImplicit())
{
kernel->subProblem().prepareShapes(kernel->variable().number(), _tid);
kernel->computeJacobian();
}
}
}
}
示例10:
void
AuxiliarySystem::addScalarKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters)
{
for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
{
parameters.set<THREAD_ID>("_tid") = tid;
MooseSharedPointer<AuxScalarKernel> kernel = MooseSharedNamespace::static_pointer_cast<AuxScalarKernel>(_factory.create(kernel_name, name, parameters));
// Add this AuxKernel to multiple ExecStores
const std::vector<ExecFlagType> & exec_flags = kernel->execFlags();
for (unsigned int i=0; i<exec_flags.size(); ++i)
_auxs(exec_flags[i])[tid].addScalarKernel(kernel);
_mproblem._objects_by_name[tid][name].push_back(kernel.get());
}
}
示例11: if
void
ConstraintWarehouse::addObject(MooseSharedPointer<Constraint> object, THREAD_ID /*tid = 0*/)
{
// Adds to the storage of _all_objects
MooseObjectWarehouse<Constraint>::addObject(object);
// Cast the the possible Contraint types
MooseSharedPointer<NodeFaceConstraint> nfc = MooseSharedNamespace::dynamic_pointer_cast<NodeFaceConstraint>(object);
MooseSharedPointer<FaceFaceConstraint> ffc = MooseSharedNamespace::dynamic_pointer_cast<FaceFaceConstraint>(object);
MooseSharedPointer<NodalConstraint> nc = MooseSharedNamespace::dynamic_pointer_cast<NodalConstraint>(object);
MooseSharedPointer<ElemElemConstraint> ec = MooseSharedNamespace::dynamic_pointer_cast<ElemElemConstraint>(object);
// NodeFaceConstraint
if (nfc)
{
MooseMesh & mesh = nfc->getParam<FEProblem *>("_fe_problem")->mesh();
unsigned int slave = mesh.getBoundaryID(nfc->getParam<BoundaryName>("slave"));
bool displaced = nfc->parameters().have_parameter<bool>("use_displaced_mesh") && nfc->getParam<bool>("use_displaced_mesh");
if (displaced)
_displaced_node_face_constraints[slave].addObject(nfc);
else
_node_face_constraints[slave].addObject(nfc);
}
// FaceFaceConstraint
else if (ffc)
{
const std::string & interface = ffc->getParam<std::string>("interface");
_face_face_constraints[interface].addObject(ffc);
}
// ElemElemConstraint
else if (ec)
{
const InterfaceID interface_id = ec->getParam<InterfaceID>("interface_id");
_element_constraints[interface_id].addObject(ec);
}
// NodalConstraint
else if (nc)
_nodal_constraints.addObject(nc);
else
mooseError("Unknown type of Constraint object");
}
示例12:
MooseObjectAction *
SetupDebugAction::createOutputAction(const std::string & type, const std::string & name)
{
// Set the 'type =' parameters for the desired object
_action_params.set<std::string>("type") = type;
// Create the action
MooseSharedPointer<MooseObjectAction> action = MooseSharedNamespace::static_pointer_cast<MooseObjectAction>(_action_factory.create("AddOutputAction", name, _action_params));
// Set the object parameters
InputParameters & object_params = action->getObjectParams();
object_params.set<bool>("_built_by_moose") = true;
// Add the action to the warehouse
_awh.addActionBlock(action);
// Return the pointer to the action
return action.get();
}
示例13:
void
MultiAppWarehouse::addMultiApp(MooseSharedPointer<MultiApp> multi_app)
{
_all_ptrs.push_back(multi_app);
_all_objects.push_back(multi_app.get());
MooseSharedPointer<TransientMultiApp> trans_multi_app = MooseSharedNamespace::dynamic_pointer_cast<TransientMultiApp>(multi_app);
if (trans_multi_app.get())
_transient_multi_apps.push_back(trans_multi_app.get());
}
示例14: mooseError
void
SetupPreconditionerAction::act()
{
if (_problem.get() != NULL)
{
// build the preconditioner
_moose_object_pars.set<FEProblem *>("_fe_problem") = _problem.get();
MooseSharedPointer<MoosePreconditioner> pc = MooseSharedNamespace::static_pointer_cast<MoosePreconditioner>(_factory.create(_type, _name, _moose_object_pars));
if (!pc.get())
mooseError("Failed to build the preconditioner.");
_problem->getNonlinearSystem().setPreconditioner(pc);
/**
* Go ahead and set common precondition options here. The child classes will still be called
* through the action warehouse
*/
Moose::PetscSupport::storePetscOptions(*_problem, _pars);
}
}
示例15: long_name
void
CommonOutputAction::create(std::string object_type)
{
// Set the 'type =' parameters for the desired object
_action_params.set<std::string>("type") = object_type;
// Create the complete object name (uses lower case of type)
std::transform(object_type.begin(), object_type.end(), object_type.begin(), ::tolower);
std::string long_name("Outputs/");
long_name += object_type;
// Create the action
MooseSharedPointer<MooseObjectAction> action = MooseSharedNamespace::static_pointer_cast<MooseObjectAction>(_action_factory.create("AddOutputAction", long_name, _action_params));
// Set flag indicating that the object to be created was created with short-cut syntax
action->getObjectParams().set<bool>("_built_by_moose") = true;
// Add the action to the warehouse
_awh.addActionBlock(action);
}