12#ifdef LIBMESH_ENABLE_AMR
24#include "libmesh/transient_system.h"
25#include "libmesh/system_norm.h"
26#include "libmesh/enum_norm_type.h"
37 "Add libMesh based adaptation schemes via the Executioner/Adaptivity input syntax.");
38 MooseEnum estimators(
"KellyErrorEstimator LaplacianErrorEstimator PatchRecoveryErrorEstimator",
39 "KellyErrorEstimator");
44 "The number of adaptivity steps to perform using the initial conditions");
45 params.
addParam<Real>(
"refine_fraction",
47 "The fraction of elements or error to refine. Should be between 0 and 1.");
48 params.
addParam<Real>(
"coarsen_fraction",
50 "The fraction of elements or error to coarsen. Should be between 0 and 1.");
52 "error_estimator", estimators,
"The class name of the error estimator you want to use.");
56 "Determines whether information about the mesh is printed when adaptivity occurs",
57 "Use the Console output parameter 'print_mesh_changed_info'");
58 params.
addParam<std::vector<std::string>>(
59 "weight_names", {},
"List of names of variables that will be associated with weight_values");
63 "List of values between 0 and 1 to weight the associated weight_names error by");
65 "show_initial_progress",
true,
"Show the progress of the initial adaptivity");
89 rm_params.
set<std::string>(
"for_whom") =
"Adaptivity";
94 if (rm_params.areAllRequiredParamsValid())
97 "ElementSideNeighborLayers",
"adaptivity_algebraic_ghosting", rm_params);
105 mooseError(
"Invalid initialization of ElementSideNeighborLayers");
112 rm_params.
set<std::string>(
"for_whom") =
"Adaptivity";
117 if (rm_params.areAllRequiredParamsValid())
120 "ElementPointNeighborLayers",
"adaptivity_geometric_ghosting", rm_params);
128 mooseError(
"Invalid initialization of ElementPointNeighborLayers");
140 if (
_mesh->isSplit())
141 adapt.
init(0, 0, getParam<MooseEnum>(
"adaptivity_type").getEnum<AdaptivityType>());
143 adapt.
init(getParam<unsigned int>(
"steps"),
144 getParam<unsigned int>(
"initial_adaptivity"),
145 getParam<MooseEnum>(
"adaptivity_type").getEnum<AdaptivityType>());
149 adapt.
setParam(
"cycles_per_step", getParam<unsigned int>(
"cycles_per_step"));
150 adapt.
setParam(
"refine fraction", getParam<Real>(
"refine_fraction"));
151 adapt.
setParam(
"coarsen fraction", getParam<Real>(
"coarsen_fraction"));
152 adapt.
setParam(
"max h-level", getParam<unsigned int>(
"max_h_level"));
153 adapt.
setParam(
"recompute_markers_during_cycles",
154 getParam<bool>(
"recompute_markers_during_cycles"));
158 const std::vector<std::string> & weight_names =
159 getParam<std::vector<std::string>>(
"weight_names");
160 const std::vector<Real> & weight_values = getParam<std::vector<Real>>(
"weight_values");
162 auto num_weight_names = weight_names.size();
163 auto num_weight_values = weight_values.size();
165 if (num_weight_names)
167 if (num_weight_names != num_weight_values)
168 mooseError(
"Number of weight_names must be equal to number of weight_values in "
169 "Execution/Adaptivity");
172 std::vector<Real> weights(system.
nVariables(), 0);
174 for (MooseIndex(num_weight_names) i = 0; i < num_weight_names; i++)
176 std::string
name = weight_names[i];
177 auto value = weight_values[i];
189 adapt.
setTimeActive(getParam<Real>(
"start_time"), getParam<Real>(
"stop_time"));
191 adapt.
setInterval(getParam<unsigned int>(
"interval"));
registerMooseAction("MooseApp", AdaptivityAction, "setup_adaptivity")
std::shared_ptr< MooseMesh > & _mesh
MooseApp & _app
The MOOSE application this is associated with.
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
const std::string & _current_task
The current action (even though we have separate instances for each action)
static InputParameters validParams()
AdaptivityAction(const InputParameters ¶ms)
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
Takes care of everything related to mesh adaptivity.
void init(const unsigned int steps, const unsigned int initial_steps, const AdaptivityType adaptivity_type)
Initialize and turn on adaptivity for the simulation.
void setTimeActive(Real start_time, Real stop_time)
Sets the time when the adaptivity is active.
void setParam(const std::string ¶m_name, const T ¶m_value)
Set adaptivity parameter.
void setInterval(unsigned int interval)
Set the interval (number of timesteps) between refinement steps.
void setErrorNorm(libMesh::SystemNorm &sys_norm)
Set the error norm (FIXME: improve description)
void setAdaptivityControlFlag(const bool *adapt_control_flag)
Sets the boolean control flag to enable / disable adaptivity.
void setPrintMeshChanged(bool state=true)
void setErrorEstimator(const MooseEnum &error_estimator_name)
Set the error estimator.
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters ¶meters, THREAD_ID tid=0, bool print_deprecated=true)
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
void releaseSharedObjects(const MooseObject &moose_object, THREAD_ID tid=0)
Releases any shared resources created as a side effect of creating an object through the Factory::cre...
bool addRelationshipManager(std::shared_ptr< RelationshipManager > relationship_manager)
Transfers ownership of a RelationshipManager to the application for lifetime management.
const std::string & name() const
Get the name of the class.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
unsigned int number() const
Get variable number coming from libMesh.
Nonlinear system to be solved.
Factory & _factory
The Factory associated with the MooseApp.
RelationshipManagers are used for describing what kinds of non-local resources are needed for an obje...
virtual unsigned int nVariables() const
Get the number of variables in this system.
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
RelationshipManagerType
Main types of Relationship Managers.
InputParameters commonAdaptivityParams()