本文整理汇总了C++中FEProblem类的典型用法代码示例。如果您正苦于以下问题:C++ FEProblem类的具体用法?C++ FEProblem怎么用?C++ FEProblem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FEProblem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mooseError
void
TransientMultiApp::setupApp(unsigned int i, Real /*time*/) // FIXME: Should we be passing time?
{
MooseApp * app = _apps[i];
Transient * ex = dynamic_cast<Transient *>(app->getExecutioner());
if (!ex)
mooseError("MultiApp " << _name << " is not using a Transient Executioner!");
// Get the FEProblem and OutputWarehouse for the current MultiApp
FEProblem * problem = appProblem(_first_local_app + i);
OutputWarehouse & output_warehouse = app->getOutputWarehouse();
// Update the file numbers for the outputs from the parent application
output_warehouse.setFileNumbers(_app.getOutputFileNumbers());
// Call initialization method of Executioner (Note, this preforms the output of the initial time step, if desired)
ex->init();
if (_interpolate_transfers)
{
AuxiliarySystem & aux_system = problem->getAuxiliarySystem();
System & libmesh_aux_system = aux_system.system();
// We'll store a copy of the auxiliary system's solution at the old time in here
libmesh_aux_system.add_vector("transfer_old", false);
// This will be where we'll transfer the value to for the "target" time
libmesh_aux_system.add_vector("transfer", false);
}
ex->preExecute();
problem->advanceState();
_transient_executioners[i] = ex;
}
示例2:
void
MultiAppProjectionTransfer::projectSolution(FEProblem & to_problem, unsigned int app)
{
EquationSystems & proj_es = to_problem.es();
LinearImplicitSystem & ls = *_proj_sys[app];
// activate the current transfer
proj_es.parameters.set<MultiAppProjectionTransfer *>("transfer") = this;
proj_es.parameters.set<unsigned int>("app") = app;
// TODO: specify solver params in an input file
// solver tolerance
Real tol = proj_es.parameters.get<Real>("linear solver tolerance");
proj_es.parameters.set<Real>("linear solver tolerance") = 1e-10; // set our tolerance
// solve it
ls.solve();
proj_es.parameters.set<Real>("linear solver tolerance") = tol; // restore the original tolerance
// copy projected solution into target es
MeshBase & to_mesh = proj_es.get_mesh();
MooseVariable & to_var = to_problem.getVariable(0, _to_var_name);
System & to_sys = to_var.sys().system();
NumericVector<Number> * to_solution = to_sys.solution.get();
{
MeshBase::const_node_iterator it = to_mesh.local_nodes_begin();
const MeshBase::const_node_iterator end_it = to_mesh.local_nodes_end();
for ( ; it != end_it; ++it)
{
const Node * node = *it;
if (node->n_comp(to_sys.number(), to_var.number()) > 0)
{
const dof_id_type proj_index = node->dof_number(ls.number(), _proj_var_num, 0);
const dof_id_type to_index = node->dof_number(to_sys.number(), to_var.number(), 0);
to_solution->set(to_index, (*ls.solution)(proj_index));
}
}
}
{
MeshBase::const_element_iterator it = to_mesh.active_local_elements_begin();
const MeshBase::const_element_iterator end_it = to_mesh.active_local_elements_end();
for ( ; it != end_it; ++it)
{
const Elem * elem = *it;
if (elem->n_comp(to_sys.number(), to_var.number()) > 0)
{
const dof_id_type proj_index = elem->dof_number(ls.number(), _proj_var_num, 0);
const dof_id_type to_index = elem->dof_number(to_sys.number(), to_var.number(), 0);
to_solution->set(to_index, (*ls.solution)(proj_index));
}
}
}
to_solution->close();
to_sys.update();
}
示例3: parameters
void
Executioner::addAttributeReporter(const std::string & name, Real & attribute, const std::string execute_on)
{
FEProblem * problem = parameters().getCheckedPointerParam<FEProblem *>("_fe_problem", "Failed to retrieve FEProblem when adding a attribute reporter in Executioner");
InputParameters params = _app.getFactory().getValidParams("ExecutionerAttributeReporter");
params.set<Real *>("value") = &attribute;
if (!execute_on.empty())
params.set<MultiMooseEnum>("execute_on") = execute_on;
problem->addPostprocessor("ExecutionerAttributeReporter", name, params);
}
示例4:
RandomInterface::RandomInterface(const std::string & name, InputParameters & parameters,
FEProblem & problem, THREAD_ID tid, bool is_nodal) :
_random_data(NULL),
_generator(NULL),
_ri_problem(problem),
_ri_name(name),
_master_seed(parameters.get<unsigned int>("seed")),
_is_nodal(is_nodal),
_reset_on(EXEC_RESIDUAL),
_curr_node(problem.assembly(tid).node()),
_curr_element(problem.assembly(tid).elem())
{
}
示例5: mooseError
FunctionPeriodicBoundary::FunctionPeriodicBoundary(FEProblem & feproblem, std::vector<std::string> fn_names) :
_dim(fn_names.size()),
_tr_x(&feproblem.getFunction(fn_names[0])),
_tr_y(fn_names.size() > 1 ? &feproblem.getFunction(fn_names[1]) : NULL),
_tr_z(fn_names.size() > 2 ? &feproblem.getFunction(fn_names[2]) : NULL)
{
// Make certain the the dimensions agree
if (_dim != feproblem.mesh().dimension())
mooseError("Transform function has to have the same dimension as the problem being solved.");
// Initialize the functions (i.e., call thier initialSetup methods)
init();
}
示例6: mooseError
void
TransientMultiApp::setupApp(unsigned int i, Real /*time*/, bool output_initial) // FIXME: Should we be passing time?
{
MooseApp * app = _apps[i];
Transient * ex = dynamic_cast<Transient *>(app->getExecutioner());
if (!ex)
mooseError("MultiApp " << _name << " is not using a Transient Executioner!");
// Get the FEProblem and OutputWarehouse for the current MultiApp
FEProblem * problem = appProblem(_first_local_app + i);
OutputWarehouse & output_warehouse = _apps[i]->getOutputWarehouse();
if (!output_initial)
{
ex->outputInitial(false);//\todo{Remove; handled within ex->init()}
output_warehouse.allowOutput(false);
}
// Set the file numbers of the i-th app to that of the parent app
output_warehouse.setFileNumbers(app->getOutputFileNumbers());
// Call initialization method of Executioner (Note, this preforms the output of the initial time step, if desired)
ex->init();
// Enable output after setup
output_warehouse.allowOutput(true);
if (_interpolate_transfers)
{
AuxiliarySystem & aux_system = problem->getAuxiliarySystem();
System & libmesh_aux_system = aux_system.system();
// We'll store a copy of the auxiliary system's solution at the old time in here
libmesh_aux_system.add_vector("transfer_old", false);
// This will be where we'll transfer the value to for the "target" time
libmesh_aux_system.add_vector("transfer", false);
}
ex->preExecute();
problem->copyOldSolutions();
_transient_executioners[i] = ex;
if (_detect_steady_state || _tolerate_failure)
{
_apps[i]->getOutputWarehouse().allowOutput(false);
ex->allowOutput(false);
}
}
示例7: mooseError
MeshTools::BoundingBox
MultiApp::getBoundingBox(unsigned int app)
{
if (!_has_an_app)
mooseError("No app for " << name() << " on processor " << _orig_rank);
FEProblem * problem = appProblem(app);
MPI_Comm swapped = Moose::swapLibMeshComm(_my_comm);
MooseMesh & mesh = problem->mesh();
MeshTools::BoundingBox bbox = MeshTools::bounding_box(mesh);
Moose::swapLibMeshComm(swapped);
Point min = bbox.min();
Point max = bbox.max();
Point inflation_amount = (max-min)*_inflation;
Point inflated_min = min - inflation_amount;
Point inflated_max = max + inflation_amount;
// This is where the app is located. We need to shift by this amount.
Point p = position(app);
Point shifted_min = inflated_min;
Point shifted_max = inflated_max;
// If the problem is RZ then we're going to invent a box that would cover the whole "3D" app
// FIXME: Assuming all subdomains are the same coordinate system type!
if (problem->getCoordSystem(*(problem->mesh().meshSubdomains().begin())) == Moose::COORD_RZ)
{
shifted_min(0) = -inflated_max(0);
shifted_min(1) = inflated_min(1);
shifted_min(2) = -inflated_max(0);
shifted_max(0) = inflated_max(0);
shifted_max(1) = inflated_max(1);
shifted_max(2) = inflated_max(0);
}
// Shift them to the position they're supposed to be
shifted_min += p;
shifted_max += p;
return MeshTools::BoundingBox(shifted_min, shifted_max);
}
示例8:
ComputeElemDampingThread::ComputeElemDampingThread(FEProblem & feproblem) :
ThreadedElementLoop<ConstElemRange>(feproblem),
_damping(1.0),
_nl(feproblem.getNonlinearSystem()),
_element_dampers(_nl.getElementDamperWarehouse())
{
}
示例9:
ComputeNodalDampingThread::ComputeNodalDampingThread(FEProblem & feproblem) :
ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(feproblem),
_damping(1.0),
_nl(feproblem.getNonlinearSystem()),
_nodal_dampers(_nl.getNodalDamperWarehouse())
{
}
示例10: outputExecutionInformation
std::string
outputExecutionInformation(MooseApp & app, FEProblem & problem)
{
std::stringstream oss;
oss << std::left;
Executioner * exec = app.getExecutioner();
oss << "Execution Information:\n"
<< std::setw(console_field_width) << " Executioner: " << demangle(typeid(*exec).name()) << '\n';
std::string time_stepper = exec->getTimeStepperName();
if (time_stepper != "")
oss << std::setw(console_field_width) << " TimeStepper: " << time_stepper << '\n';
oss << std::setw(console_field_width) << " Solver Mode: " << Moose::stringify<Moose::SolveType>(problem.solverParams()._type) << '\n';
const std::string & pc_desc = problem.getPetscOptions().pc_description;
if (!pc_desc.empty())
oss << std::setw(console_field_width) << " Preconditioner: " << pc_desc << '\n';
oss << '\n';
return oss.str();
}
示例11: outputLegacyInformation
std::string outputLegacyInformation(MooseApp & /*app*/, FEProblem & problem)
{
std::stringstream oss;
oss << std::left;
if (problem.legacyUoAuxComputation() || problem.legacyUoInitialization())
{
oss << COLOR_RED << "LEGACY MODES ENABLED:" << COLOR_DEFAULT << '\n';
if (problem.legacyUoAuxComputation())
oss << COLOR_RED << " Computing EXEC_LINEAR AuxKernel types when any UserObject type is executed." << COLOR_DEFAULT << '\n';
if (problem.legacyUoInitialization())
oss << COLOR_RED << " Computing all UserObjects during initial setup." << COLOR_DEFAULT << '\n';
}
return oss.str();
}
示例12:
ComputeNodalKernelBcsThread::ComputeNodalKernelBcsThread(FEProblem & fe_problem,
const MooseObjectWarehouse<NodalKernel> & nodal_kernels) :
ThreadedNodeLoop<ConstBndNodeRange, ConstBndNodeRange::const_iterator>(fe_problem),
_aux_sys(fe_problem.getAuxiliarySystem()),
_nodal_kernels(nodal_kernels),
_num_cached(0)
{
}
示例13:
ComputeNodalKernelJacobiansThread::ComputeNodalKernelJacobiansThread(FEProblem & fe_problem,
const MooseObjectWarehouse<NodalKernel> & nodal_kernels,
SparseMatrix<Number> & jacobian) :
ThreadedNodeLoop<ConstNodeRange, ConstNodeRange::const_iterator>(fe_problem),
_aux_sys(fe_problem.getAuxiliarySystem()),
_nodal_kernels(nodal_kernels),
_jacobian(jacobian),
_num_cached(0)
{
}
示例14:
ComputeJacobianBlockThread::ComputeJacobianBlockThread(FEProblem & fe_problem, libMesh::System & precond_system, SparseMatrix<Number> & jacobian, unsigned int ivar, unsigned int jvar) :
_fe_problem(fe_problem),
_precond_system(precond_system),
_nl(_fe_problem.getNonlinearSystem()),
_mesh(fe_problem.mesh()),
_jacobian(jacobian),
_ivar(ivar),
_jvar(jvar)
{
}
示例15: petscSetOptions
void
petscSetOptions(FEProblem & problem)
{
// Reference to the options stored in FEPRoblem
PetscOptions & petsc = problem.getPetscOptions();
if (petsc.inames.size() != petsc.values.size())
mooseError("PETSc names and options are not the same length");
#if PETSC_VERSION_LESS_THAN(3,7,0)
PetscOptionsClear();
#else
PetscOptionsClear(PETSC_NULL);
#endif
setSolverOptions(problem.solverParams());
// Add any additional options specified in the input file
for (const auto & flag : petsc.flags)
setSinglePetscOption(flag.c_str());
for (unsigned int i=0; i<petsc.inames.size(); ++i)
setSinglePetscOption(petsc.inames[i], petsc.values[i]);
// set up DM which is required if use a field split preconditioner
if (problem.getNonlinearSystem().haveFieldSplitPreconditioner())
petscSetupDM(problem.getNonlinearSystem());
// commandline options always win
// the options from a user commandline will overwrite the existing ones if any conflicts
{ // Get any options specified on the command-line
int argc;
char ** args;
PetscGetArgs(&argc, &args);
#if PETSC_VERSION_LESS_THAN(3,7,0)
PetscOptionsInsert(&argc, &args, NULL);
#else
PetscOptionsInsert(PETSC_NULL, &argc, &args, NULL);
#endif
}
}