12 #ifdef LIBMESH_ENABLE_AMR 24 #include "libmesh/transient_system.h" 25 #include "libmesh/system_norm.h" 26 #include "libmesh/enum_norm_type.h" 39 "Add libMesh based adaptation schemes via the Executioner/Adaptivity input syntax.");
40 MooseEnum estimators(
"KellyErrorEstimator LaplacianErrorEstimator PatchRecoveryErrorEstimator",
41 "KellyErrorEstimator");
46 "The number of adaptivity steps to perform using the initial conditions");
49 "The fraction of elements or error to refine. Should be between 0 and 1.");
52 "The fraction of elements or error to coarsen. Should be between 0 and 1.");
54 "error_estimator", estimators,
"The class name of the error estimator you want to use.");
58 "Determines whether information about the mesh is printed when adaptivity occurs",
59 "Use the Console output parameter 'print_mesh_changed_info'");
60 params.
addParam<std::vector<std::string>>(
61 "weight_names", {},
"List of names of variables that will be associated with weight_values");
65 "List of values between 0 and 1 to weight the associated weight_names error by");
67 "show_initial_progress",
true,
"Show the progress of the initial adaptivity");
89 auto rm_params =
_factory.getValidParams(
"ElementSideNeighborLayers");
91 rm_params.set<std::string>(
"for_whom") =
"Adaptivity";
96 if (rm_params.areAllRequiredParamsValid())
99 "ElementSideNeighborLayers",
"adaptivity_algebraic_ghosting", rm_params);
104 _factory.releaseSharedObjects(*rm_obj);
107 mooseError(
"Invalid initialization of ElementSideNeighborLayers");
112 auto rm_params =
_factory.getValidParams(
"ElementPointNeighborLayers");
114 rm_params.set<std::string>(
"for_whom") =
"Adaptivity";
119 if (rm_params.areAllRequiredParamsValid())
122 "ElementPointNeighborLayers",
"adaptivity_geometric_ghosting", rm_params);
127 _factory.releaseSharedObjects(*rm_obj);
130 mooseError(
"Invalid initialization of ElementPointNeighborLayers");
142 if (
_mesh->isSplit())
145 adapt.
init(getParam<unsigned int>(
"steps"),
146 getParam<unsigned int>(
"initial_adaptivity"),
147 getParam<MooseEnum>(
"adaptivity_type").getEnum<AdaptivityType>());
151 adapt.
setParam(
"cycles_per_step", getParam<unsigned int>(
"cycles_per_step"));
152 adapt.
setParam(
"refine fraction", getParam<Real>(
"refine_fraction"));
153 adapt.
setParam(
"coarsen fraction", getParam<Real>(
"coarsen_fraction"));
154 adapt.
setParam(
"max h-level", getParam<unsigned int>(
"max_h_level"));
155 adapt.
setParam(
"recompute_markers_during_cycles",
156 getParam<bool>(
"recompute_markers_during_cycles"));
160 const std::vector<std::string> & weight_names =
161 getParam<std::vector<std::string>>(
"weight_names");
162 const std::vector<Real> & weight_values = getParam<std::vector<Real>>(
"weight_values");
164 auto num_weight_names = weight_names.size();
165 auto num_weight_values = weight_values.size();
167 if (num_weight_names)
169 if (num_weight_names != num_weight_values)
170 mooseError(
"Number of weight_names must be equal to number of weight_values in " 171 "Execution/Adaptivity");
174 std::vector<Real> weights(system.
nVariables(), 0);
176 for (MooseIndex(num_weight_names) i = 0; i < num_weight_names; i++)
178 std::string
name = weight_names[i];
179 auto value = weight_values[i];
191 adapt.
setTimeActive(getParam<Real>(
"start_time"), getParam<Real>(
"stop_time"));
192 adapt.
setInterval(getParam<unsigned int>(
"interval"));
196 #endif // LIBMESH_ENABLE_AMR
void setPrintMeshChanged(bool state=true)
void setInterval(unsigned int interval)
Set the interval (number of timesteps) between refinement steps.
RelationshipManagerType
Main types of Relationship Managers.
AdaptivityType
Defines types of mesh adaptivity options available.
unsigned int number() const
Get variable number coming from libMesh.
Factory & _factory
The Factory associated with the MooseApp.
void setTimeActive(Real start_time, Real stop_time)
Sets the time when the adaptivity is active.
AdaptivityAction(const InputParameters ¶ms)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
virtual unsigned int nVariables() const
Get the number of variables in this system.
Nonlinear system to be solved.
const std::string & name() const
Get the name of the class.
bool addRelationshipManager(std::shared_ptr< RelationshipManager > relationship_manager)
Transfers ownership of a RelationshipManager to the application for lifetime management.
virtual std::unique_ptr< Base > create()=0
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
static InputParameters validParams()
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
const std::string & _current_task
The current action (even though we have separate instances for each action)
MooseApp & _app
The MOOSE application this is associated with.
void setErrorEstimator(const MooseEnum &error_estimator_name)
Set the error estimator.
void init(const unsigned int steps, const unsigned int initial_steps, const AdaptivityType adaptivity_type)
Initialize and turn on adaptivity for the simulation.
std::shared_ptr< MooseMesh > & _mesh
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Takes care of everything related to mesh adaptivity.
RelationshipManagers are used for describing what kinds of non-local resources are needed for an obje...
registerMooseAction("MooseApp", AdaptivityAction, "setup_adaptivity")
InputParameters commonAdaptivityParams()
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...
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
void setParam(const std::string ¶m_name, const T ¶m_value)
Set adaptivity parameter.
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
void setErrorNorm(libMesh::SystemNorm &sys_norm)
Set the error norm (FIXME: improve description)