www.mooseframework.org
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
Adaptivity Class Reference

Takes care of everything related to mesh adaptivity. More...

#include <Adaptivity.h>

Inheritance diagram for Adaptivity:
[legend]

Public Member Functions

 Adaptivity (FEProblemBase &subproblem)
 
virtual ~Adaptivity ()
 
void init (unsigned int steps, unsigned int initial_steps)
 Initialize the initial adaptivity ;-) More...
 
template<typename T >
void setParam (const std::string &param_name, const T &param_value)
 Set adaptivity parameter. More...
 
void setErrorEstimator (const MooseEnum &error_estimator_name)
 Set the error estimator. More...
 
void setErrorNorm (SystemNorm &sys_norm)
 Set the error norm (FIXME: improve description) More...
 
void setPrintMeshChanged (bool state=true)
 
unsigned int getInitialSteps () const
 Pull out the number of initial steps previously set by calling init() More...
 
unsigned int getSteps () const
 Pull out the number of steps previously set by calling init() More...
 
unsigned int getCyclesPerStep () const
 Pull out the number of cycles_per_step previously set through the AdaptivityAction. More...
 
void setCyclesPerStep (const unsigned int &num)
 Set the number of cycles_per_step. More...
 
bool getRecomputeMarkersFlag () const
 Pull out the _recompute_markers_during_cycles flag previously set through the AdaptivityAction. More...
 
void setRecomputeMarkersFlag (const bool flag)
 Set the flag to recompute markers during adaptivity cycles. More...
 
bool adaptMesh (std::string marker_name=std::string())
 Adapts the mesh based on the error estimator used. More...
 
bool initialAdaptMesh ()
 Used during initial adaptivity. More...
 
void uniformRefineWithProjection ()
 Performs uniform refinement on the meshes in the current object. More...
 
void setAdaptivityOn (bool state)
 Allow adaptivity to be toggled programatically. More...
 
bool isOn ()
 Is adaptivity on? More...
 
bool isInitialized ()
 Returns whether or not Adaptivity::init() has ran. More...
 
void setTimeActive (Real start_time, Real stop_time)
 Sets the time when the adaptivity is active. More...
 
void setUseNewSystem ()
 Tells this object we're using the "new" adaptivity system. More...
 
void setMarkerVariableName (std::string marker_field)
 Sets the name of the field variable to actually use to flag elements for refinement / coarsening. More...
 
void setInitialMarkerVariableName (std::string marker_field)
 Sets the name of the field variable to actually use to flag elements for initial refinement / coarsening. More...
 
void setMaxHLevel (unsigned int level)
 Set the maximum refinement level (for the new Adaptivity system). More...
 
unsigned int getMaxHLevel ()
 Return the maximum h-level. More...
 
void setInterval (unsigned int interval)
 Set the interval (number of timesteps) between refinement steps. More...
 
ErrorVector & getErrorVector (const std::string &indicator_field)
 Get an ErrorVector that will be filled up with values corresponding to the indicator field name passed in. More...
 
void updateErrorVectors ()
 Update the ErrorVectors that have been requested through calls to getErrorVector(). More...
 
bool isAdaptivityDue ()
 Query if an adaptivity step should be performed at the current time / time step. More...
 

Static Public Member Functions

static void uniformRefine (MooseMesh *mesh)
 Performs uniform refinement of the passed Mesh object. More...
 

Public Attributes

const ConsoleStream _console
 An instance of helper class to write streams to the Console objects. More...
 

Protected Attributes

FEProblemBase_subproblem
 
MooseMesh_mesh
 
bool _mesh_refinement_on
 on/off flag reporting if the adaptivity is being used More...
 
bool _initialized
 on/off flag reporting if the adaptivity system has been initialized More...
 
std::unique_ptr< MeshRefinement > _mesh_refinement
 A mesh refinement object to be used either with initial refinement or with Adaptivity. More...
 
std::unique_ptr< ErrorEstimator > _error_estimator
 Error estimator to be used by the apps. More...
 
std::unique_ptr< ErrorVector > _error
 Error vector for use with the error estimator. More...
 
std::shared_ptr< DisplacedProblem_displaced_problem
 
std::unique_ptr< MeshRefinement > _displaced_mesh_refinement
 A mesh refinement object for displaced mesh. More...
 
unsigned int _initial_steps
 the number of adaptivity steps to do at the beginning of simulation More...
 
unsigned int _steps
 steps of adaptivity to perform More...
 
bool _print_mesh_changed
 True if we want to print out info when mesh has changed. More...
 
Real & _t
 Time. More...
 
int & _step
 Time Step. More...
 
unsigned int _interval
 intreval between adaptivity runs More...
 
Real _start_time
 When adaptivity start. More...
 
Real _stop_time
 When adaptivity stops. More...
 
unsigned int _cycles_per_step
 The number of adaptivity cycles per step. More...
 
bool _use_new_system
 Whether or not to use the "new" adaptivity system. More...
 
std::string _marker_variable_name
 Name of the marker variable if using the new adaptivity system. More...
 
std::string _initial_marker_variable_name
 Name of the initial marker variable if using the new adaptivity system. More...
 
unsigned int _max_h_level
 The maximum number of refinement levels. More...
 
bool _recompute_markers_during_cycles
 Whether or not to recompute markers during adaptivity cycles. More...
 
std::map< std::string, std::unique_ptr< ErrorVector > > _indicator_field_to_error_vector
 Stores pointers to ErrorVectors associated with indicator field names. More...
 

Detailed Description

Takes care of everything related to mesh adaptivity.

Definition at line 48 of file Adaptivity.h.

Constructor & Destructor Documentation

Adaptivity::Adaptivity ( FEProblemBase subproblem)

Definition at line 35 of file Adaptivity.C.

36  : ConsoleStreamInterface(subproblem.getMooseApp()),
37  _subproblem(subproblem),
39  _mesh_refinement_on(false),
40  _initialized(false),
41  _initial_steps(0),
42  _steps(0),
43  _print_mesh_changed(false),
44  _t(_subproblem.time()),
46  _interval(1),
47  _start_time(-std::numeric_limits<Real>::max()),
48  _stop_time(std::numeric_limits<Real>::max()),
50  _use_new_system(false),
51  _max_h_level(0),
53 {
54 }
Real _stop_time
When adaptivity stops.
Definition: Adaptivity.h:282
bool _initialized
on/off flag reporting if the adaptivity system has been initialized
Definition: Adaptivity.h:252
bool _recompute_markers_during_cycles
Whether or not to recompute markers during adaptivity cycles.
Definition: Adaptivity.h:299
virtual Real & time() const
MooseMesh & _mesh
Definition: Adaptivity.h:247
Real & _t
Time.
Definition: Adaptivity.h:274
FEProblemBase & _subproblem
Definition: Adaptivity.h:246
bool _print_mesh_changed
True if we want to print out info when mesh has changed.
Definition: Adaptivity.h:271
bool _mesh_refinement_on
on/off flag reporting if the adaptivity is being used
Definition: Adaptivity.h:250
virtual int & timeStep() const
ConsoleStreamInterface(MooseApp &app)
A class for providing a helper stream object for writting message to all the Output objects...
unsigned int _steps
steps of adaptivity to perform
Definition: Adaptivity.h:268
MooseApp & getMooseApp()
Get the MooseApp this object is associated with.
Definition: MooseObject.h:72
unsigned int _initial_steps
the number of adaptivity steps to do at the beginning of simulation
Definition: Adaptivity.h:266
bool _use_new_system
Whether or not to use the "new" adaptivity system.
Definition: Adaptivity.h:287
unsigned int _interval
intreval between adaptivity runs
Definition: Adaptivity.h:278
virtual MooseMesh & mesh() override
unsigned int _cycles_per_step
The number of adaptivity cycles per step.
Definition: Adaptivity.h:284
Real _start_time
When adaptivity start.
Definition: Adaptivity.h:280
int & _step
Time Step.
Definition: Adaptivity.h:276
unsigned int _max_h_level
The maximum number of refinement levels.
Definition: Adaptivity.h:296
Adaptivity::~Adaptivity ( )
virtual

Definition at line 56 of file Adaptivity.C.

56 {}

Member Function Documentation

bool Adaptivity::adaptMesh ( std::string  marker_name = std::string())

Adapts the mesh based on the error estimator used.

Returns
a boolean that indicates whether the mesh was changed

Definition at line 125 of file Adaptivity.C.

Referenced by FEProblemBase::adaptMesh(), and initialAdaptMesh().

126 {
127  // If the marker name is supplied, use it. Otherwise, use the one in _marker_variable_name
128  if (marker_name.empty())
129  marker_name = _marker_variable_name;
130 
131  bool mesh_changed = false;
132 
133  if (_use_new_system)
134  {
135  if (!marker_name.empty()) // Only flag if a marker variable name has been set
136  {
137  _mesh_refinement->clean_refinement_flags();
138 
139  std::vector<Number> serialized_solution;
141  _subproblem.getAuxiliarySystem().solution().localize(serialized_solution);
142 
143  FlagElementsThread fet(_subproblem, serialized_solution, _max_h_level, marker_name);
144  ConstElemRange all_elems(_subproblem.mesh().getMesh().active_elements_begin(),
145  _subproblem.mesh().getMesh().active_elements_end(),
146  1);
147  Threads::parallel_reduce(all_elems, fet);
149  }
150  }
151  else
152  {
153  // Compute the error for each active element
155 
156  // Flag elements to be refined and coarsened
157  _mesh_refinement->flag_elements_by_error_fraction(*_error);
158 
159  if (_displaced_problem)
160  // Reuse the error vector and refine the displaced mesh
161  _displaced_mesh_refinement->flag_elements_by_error_fraction(*_error);
162  }
163 
164  // If the DisplacedProblem is active, undisplace the DisplacedMesh
165  // in preparation for refinement. We can't safely refine the
166  // DisplacedMesh directly, since the Hilbert keys computed on the
167  // inconsistenly-displaced Mesh are different on different
168  // processors, leading to inconsistent Hilbert keys. We must do
169  // this before the undisplaced Mesh is refined, so that the
170  // element and node numbering is still consistent.
171  if (_displaced_problem)
172  _displaced_problem->undisplaceMesh();
173 
174  // Perform refinement and coarsening
175  mesh_changed = _mesh_refinement->refine_and_coarsen_elements();
176 
177  if (_displaced_problem && mesh_changed)
178  {
179 // Now do refinement/coarsening
180 #ifndef NDEBUG
181  bool displaced_mesh_changed =
182 #endif
183  _displaced_mesh_refinement->refine_and_coarsen_elements();
184 
185  // Since the undisplaced mesh changed, the displaced mesh better have changed!
186  mooseAssert(displaced_mesh_changed, "Undisplaced mesh changed, but displaced mesh did not!");
187  }
188 
189  if (mesh_changed && _print_mesh_changed)
190  {
191  _console << "\nMesh Changed:\n";
192  _mesh.printInfo();
193  }
194 
195  return mesh_changed;
196 }
std::shared_ptr< DisplacedProblem > _displaced_problem
Definition: Adaptivity.h:260
std::string _marker_variable_name
Name of the marker variable if using the new adaptivity system.
Definition: Adaptivity.h:290
std::unique_ptr< MeshRefinement > _displaced_mesh_refinement
A mesh refinement object for displaced mesh.
Definition: Adaptivity.h:263
std::unique_ptr< ErrorEstimator > _error_estimator
Error estimator to be used by the apps.
Definition: Adaptivity.h:256
NonlinearSystemBase & getNonlinearSystemBase()
void printInfo(std::ostream &os=libMesh::out) const
Calls print_info() on the underlying Mesh.
Definition: MooseMesh.C:2429
std::unique_ptr< ErrorVector > _error
Error vector for use with the error estimator.
Definition: Adaptivity.h:258
MooseMesh & _mesh
Definition: Adaptivity.h:247
FEProblemBase & _subproblem
Definition: Adaptivity.h:246
bool _print_mesh_changed
True if we want to print out info when mesh has changed.
Definition: Adaptivity.h:271
std::unique_ptr< MeshRefinement > _mesh_refinement
A mesh refinement object to be used either with initial refinement or with Adaptivity.
Definition: Adaptivity.h:254
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2408
AuxiliarySystem & getAuxiliarySystem()
virtual NumericVector< Number > & solution() override
bool _use_new_system
Whether or not to use the "new" adaptivity system.
Definition: Adaptivity.h:287
virtual System & system() override
Get the reference to the libMesh system.
virtual MooseMesh & mesh() override
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
unsigned int _max_h_level
The maximum number of refinement levels.
Definition: Adaptivity.h:296
unsigned int Adaptivity::getCyclesPerStep ( ) const
inline

Pull out the number of cycles_per_step previously set through the AdaptivityAction.

Returns
the number of cycles per step

Definition at line 108 of file Adaptivity.h.

Referenced by FEProblemBase::adaptMesh().

108 { return _cycles_per_step; }
unsigned int _cycles_per_step
The number of adaptivity cycles per step.
Definition: Adaptivity.h:284
ErrorVector & Adaptivity::getErrorVector ( const std::string &  indicator_field)

Get an ErrorVector that will be filled up with values corresponding to the indicator field name passed in.

Note that this returns a reference... and the return value should be stored as a reference!

Parameters
indicator_fieldThe name of the field to get an ErrorVector for.

Definition at line 276 of file Adaptivity.C.

Referenced by Marker::getErrorVector().

277 {
278  // Insert or retrieve error vector
279  auto insert_pair = moose_try_emplace(
280  _indicator_field_to_error_vector, indicator_field, libmesh_make_unique<ErrorVector>());
281  return *insert_pair.first->second;
282 }
std::pair< typename M::iterator, bool > moose_try_emplace(M &m, const typename M::key_type &k, Args &&...args)
Function to mirror the behavior of the C++17 std::map::try_emplace() method (no hint).
Definition: Moose.h:66
std::map< std::string, std::unique_ptr< ErrorVector > > _indicator_field_to_error_vector
Stores pointers to ErrorVectors associated with indicator field names.
Definition: Adaptivity.h:302
unsigned int Adaptivity::getInitialSteps ( ) const
inline

Pull out the number of initial steps previously set by calling init()

Returns
the number of initial steps

Definition at line 94 of file Adaptivity.h.

Referenced by FEProblemBase::initialAdaptMesh(), and FEProblemBase::initialSetup().

94 { return _initial_steps; }
unsigned int _initial_steps
the number of adaptivity steps to do at the beginning of simulation
Definition: Adaptivity.h:266
unsigned int Adaptivity::getMaxHLevel ( )
inline

Return the maximum h-level.

Definition at line 218 of file Adaptivity.h.

218 { return _max_h_level; }
unsigned int _max_h_level
The maximum number of refinement levels.
Definition: Adaptivity.h:296
bool Adaptivity::getRecomputeMarkersFlag ( ) const
inline

Pull out the _recompute_markers_during_cycles flag previously set through the AdaptivityAction.

Returns
the flag to recompute markers during adaptivity cycles

Definition at line 121 of file Adaptivity.h.

Referenced by FEProblemBase::adaptMesh().

bool _recompute_markers_during_cycles
Whether or not to recompute markers during adaptivity cycles.
Definition: Adaptivity.h:299
unsigned int Adaptivity::getSteps ( ) const
inline

Pull out the number of steps previously set by calling init()

Returns
the number of steps

Definition at line 101 of file Adaptivity.h.

Referenced by Steady::execute().

101 { return _steps; }
unsigned int _steps
steps of adaptivity to perform
Definition: Adaptivity.h:268
void Adaptivity::init ( unsigned int  steps,
unsigned int  initial_steps 
)

Initialize the initial adaptivity ;-)

Parameters
stepsTODO: describe me
initial_stepsnumber of steps to do in the initial adaptivity

Definition at line 59 of file Adaptivity.C.

Referenced by SetAdaptivityOptionsAction::act(), and AdaptivityAction::act().

60 {
61  // Get the pointer to the DisplacedProblem, this cannot be done at construction because
62  // DisplacedProblem
63  // does not exist at that point.
65 
66  _mesh_refinement = libmesh_make_unique<MeshRefinement>(_mesh);
67  _error = libmesh_make_unique<ErrorVector>();
68 
69  EquationSystems & es = _subproblem.es();
70  es.parameters.set<bool>("adaptivity") = true;
71 
72  _initial_steps = initial_steps;
73  _steps = steps;
74  _mesh_refinement_on = true;
75 
76  _mesh_refinement->set_periodic_boundaries_ptr(
77  _subproblem.getNonlinearSystemBase().dofMap().get_periodic_boundaries());
78 
79  // displaced problem
80  if (_displaced_problem != nullptr)
81  {
82  EquationSystems & displaced_es = _displaced_problem->es();
83  displaced_es.parameters.set<bool>("adaptivity") = true;
84 
86  _displaced_mesh_refinement = libmesh_make_unique<MeshRefinement>(_displaced_problem->mesh());
87 
88  // The periodic boundaries pointer allows the MeshRefinement
89  // object to determine elements which are "topological" neighbors,
90  // i.e. neighbors across periodic boundaries, for the purposes of
91  // refinement.
92  _displaced_mesh_refinement->set_periodic_boundaries_ptr(
93  _subproblem.getNonlinearSystemBase().dofMap().get_periodic_boundaries());
94 
95  // TODO: This is currently an empty function on the DisplacedProblem... could it be removed?
96  _displaced_problem->initAdaptivity();
97  }
98 
99  // indicate the Adaptivity system has been initialized
100  _initialized = true;
101 }
std::shared_ptr< DisplacedProblem > _displaced_problem
Definition: Adaptivity.h:260
std::unique_ptr< MeshRefinement > _displaced_mesh_refinement
A mesh refinement object for displaced mesh.
Definition: Adaptivity.h:263
NonlinearSystemBase & getNonlinearSystemBase()
bool _initialized
on/off flag reporting if the adaptivity system has been initialized
Definition: Adaptivity.h:252
std::unique_ptr< ErrorVector > _error
Error vector for use with the error estimator.
Definition: Adaptivity.h:258
MooseMesh & _mesh
Definition: Adaptivity.h:247
virtual EquationSystems & es() override
FEProblemBase & _subproblem
Definition: Adaptivity.h:246
virtual DofMap & dofMap()
Gets the dof map.
Definition: SystemBase.C:610
std::unique_ptr< MeshRefinement > _mesh_refinement
A mesh refinement object to be used either with initial refinement or with Adaptivity.
Definition: Adaptivity.h:254
virtual std::shared_ptr< DisplacedProblem > getDisplacedProblem()
bool _mesh_refinement_on
on/off flag reporting if the adaptivity is being used
Definition: Adaptivity.h:250
unsigned int _steps
steps of adaptivity to perform
Definition: Adaptivity.h:268
unsigned int _initial_steps
the number of adaptivity steps to do at the beginning of simulation
Definition: Adaptivity.h:266
bool Adaptivity::initialAdaptMesh ( )

Used during initial adaptivity.

Returns
a boolean that indicates whether the mesh was changed

Definition at line 199 of file Adaptivity.C.

Referenced by FEProblemBase::initialAdaptMesh().

200 {
202 }
bool adaptMesh(std::string marker_name=std::string())
Adapts the mesh based on the error estimator used.
Definition: Adaptivity.C:125
std::string _initial_marker_variable_name
Name of the initial marker variable if using the new adaptivity system.
Definition: Adaptivity.h:293
bool Adaptivity::isAdaptivityDue ( )

Query if an adaptivity step should be performed at the current time / time step.

Definition at line 304 of file Adaptivity.C.

Referenced by FEProblemBase::adaptMesh().

305 {
306  return _mesh_refinement_on && (_start_time <= _t && _t < _stop_time) && _step % _interval == 0;
307 }
Real _stop_time
When adaptivity stops.
Definition: Adaptivity.h:282
Real & _t
Time.
Definition: Adaptivity.h:274
bool _mesh_refinement_on
on/off flag reporting if the adaptivity is being used
Definition: Adaptivity.h:250
unsigned int _interval
intreval between adaptivity runs
Definition: Adaptivity.h:278
Real _start_time
When adaptivity start.
Definition: Adaptivity.h:280
int & _step
Time Step.
Definition: Adaptivity.h:276
bool Adaptivity::isInitialized ( )
inline

Returns whether or not Adaptivity::init() has ran.

Can be used to indicate if mesh adaptivity is available.

Returns
true if the Adaptivity system is ready to be used, otherwise false

Definition at line 176 of file Adaptivity.h.

176 { return _initialized; }
bool _initialized
on/off flag reporting if the adaptivity system has been initialized
Definition: Adaptivity.h:252
bool Adaptivity::isOn ( )
inline

Is adaptivity on?

Returns
true if mesh adaptivity is on, otherwise false

Definition at line 168 of file Adaptivity.h.

Referenced by FEProblemBase::checkProblemIntegrity(), and FEProblemBase::initialSetup().

168 { return _mesh_refinement_on; }
bool _mesh_refinement_on
on/off flag reporting if the adaptivity is being used
Definition: Adaptivity.h:250
void Adaptivity::setAdaptivityOn ( bool  state)

Allow adaptivity to be toggled programatically.

Parameters
stateThe adaptivity state (on/off).

Definition at line 241 of file Adaptivity.C.

242 {
243  // check if Adaptivity has been initialized before turning on
244  if (state == true && !_initialized)
245  mooseError("Mesh adaptivity system not available");
246 
247  _mesh_refinement_on = state;
248 }
bool _initialized
on/off flag reporting if the adaptivity system has been initialized
Definition: Adaptivity.h:252
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
bool _mesh_refinement_on
on/off flag reporting if the adaptivity is being used
Definition: Adaptivity.h:250
void Adaptivity::setCyclesPerStep ( const unsigned int &  num)
inline

Set the number of cycles_per_step.

Parameters
numThe number of cycles per step to execute

Definition at line 114 of file Adaptivity.h.

Referenced by SetAdaptivityOptionsAction::act().

114 { _cycles_per_step = num; }
unsigned int _cycles_per_step
The number of adaptivity cycles per step.
Definition: Adaptivity.h:284
void Adaptivity::setErrorEstimator ( const MooseEnum error_estimator_name)

Set the error estimator.

Parameters
error_estimator_namethe name of the error estimator (currently: Laplacian, Kelly, and PatchRecovery)

Definition at line 104 of file Adaptivity.C.

Referenced by AdaptivityAction::act().

105 {
106  if (error_estimator_name == "KellyErrorEstimator")
107  _error_estimator = libmesh_make_unique<KellyErrorEstimator>();
108  else if (error_estimator_name == "LaplacianErrorEstimator")
109  _error_estimator = libmesh_make_unique<LaplacianErrorEstimator>();
110  else if (error_estimator_name == "PatchRecoveryErrorEstimator")
111  _error_estimator = libmesh_make_unique<PatchRecoveryErrorEstimator>();
112  else
113  mooseError(std::string("Unknown error_estimator selection: ") +
114  std::string(error_estimator_name));
115 }
std::unique_ptr< ErrorEstimator > _error_estimator
Error estimator to be used by the apps.
Definition: Adaptivity.h:256
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void Adaptivity::setErrorNorm ( SystemNorm &  sys_norm)

Set the error norm (FIXME: improve description)

Definition at line 118 of file Adaptivity.C.

Referenced by AdaptivityAction::act().

119 {
120  mooseAssert(_error_estimator, "error_estimator not initialized. Did you call init_adaptivity()?");
121  _error_estimator->error_norm = sys_norm;
122 }
std::unique_ptr< ErrorEstimator > _error_estimator
Error estimator to be used by the apps.
Definition: Adaptivity.h:256
void Adaptivity::setInitialMarkerVariableName ( std::string  marker_field)

Sets the name of the field variable to actually use to flag elements for initial refinement / coarsening.

This must be a CONSTANT, MONOMIAL Auxiliary Variable Name that contains values corresponding to libMesh::Elem::RefinementState.

Parameters
marker_fieldThe name of the field to use for refinement / coarsening.

Definition at line 270 of file Adaptivity.C.

Referenced by SetAdaptivityOptionsAction::act().

271 {
272  _initial_marker_variable_name = marker_field;
273 }
std::string _initial_marker_variable_name
Name of the initial marker variable if using the new adaptivity system.
Definition: Adaptivity.h:293
void Adaptivity::setInterval ( unsigned int  interval)
inline

Set the interval (number of timesteps) between refinement steps.

Definition at line 223 of file Adaptivity.h.

Referenced by AdaptivityAction::act().

223 { _interval = interval; }
unsigned int _interval
intreval between adaptivity runs
Definition: Adaptivity.h:278
void Adaptivity::setMarkerVariableName ( std::string  marker_field)

Sets the name of the field variable to actually use to flag elements for refinement / coarsening.

This must be a CONSTANT, MONOMIAL Auxiliary Variable Name that contains values corresponding to libMesh::Elem::RefinementState.

Parameters
marker_fieldThe name of the field to use for refinement / coarsening.

Definition at line 264 of file Adaptivity.C.

Referenced by SetAdaptivityOptionsAction::act().

265 {
266  _marker_variable_name = marker_field;
267 }
std::string _marker_variable_name
Name of the marker variable if using the new adaptivity system.
Definition: Adaptivity.h:290
void Adaptivity::setMaxHLevel ( unsigned int  level)
inline

Set the maximum refinement level (for the new Adaptivity system).

Definition at line 213 of file Adaptivity.h.

Referenced by SetAdaptivityOptionsAction::act().

213 { _max_h_level = level; }
unsigned int _max_h_level
The maximum number of refinement levels.
Definition: Adaptivity.h:296
template<typename T >
void Adaptivity::setParam ( const std::string &  param_name,
const T &  param_value 
)

Set adaptivity parameter.

Parameters
param_namethe name of the parameter
param_valuethe value of parameter

Definition at line 307 of file Adaptivity.h.

Referenced by AdaptivityAction::act().

308 {
309  if (param_name == "refine fraction")
310  {
311  _mesh_refinement->refine_fraction() = param_value;
313  _displaced_mesh_refinement->refine_fraction() = param_value;
314  }
315  else if (param_name == "coarsen fraction")
316  {
317  _mesh_refinement->coarsen_fraction() = param_value;
319  _displaced_mesh_refinement->coarsen_fraction() = param_value;
320  }
321  else if (param_name == "max h-level")
322  {
323  _mesh_refinement->max_h_level() = param_value;
325  _displaced_mesh_refinement->max_h_level() = param_value;
326  }
327  else if (param_name == "cycles_per_step")
328  _cycles_per_step = param_value;
329  else if (param_name == "recompute_markers_during_cycles")
330  _recompute_markers_during_cycles = param_value;
331  else
332  mooseError("Invalid Param in adaptivity object");
333 }
std::unique_ptr< MeshRefinement > _displaced_mesh_refinement
A mesh refinement object for displaced mesh.
Definition: Adaptivity.h:263
bool _recompute_markers_during_cycles
Whether or not to recompute markers during adaptivity cycles.
Definition: Adaptivity.h:299
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::unique_ptr< MeshRefinement > _mesh_refinement
A mesh refinement object to be used either with initial refinement or with Adaptivity.
Definition: Adaptivity.h:254
unsigned int _cycles_per_step
The number of adaptivity cycles per step.
Definition: Adaptivity.h:284
void Adaptivity::setPrintMeshChanged ( bool  state = true)
inline

Definition at line 87 of file Adaptivity.h.

Referenced by AdaptivityAction::act().

87 { _print_mesh_changed = state; }
bool _print_mesh_changed
True if we want to print out info when mesh has changed.
Definition: Adaptivity.h:271
void Adaptivity::setRecomputeMarkersFlag ( const bool  flag)
inline

Set the flag to recompute markers during adaptivity cycles.

Parameters
flagThe flag to recompute markers

Definition at line 127 of file Adaptivity.h.

Referenced by SetAdaptivityOptionsAction::act().

bool _recompute_markers_during_cycles
Whether or not to recompute markers during adaptivity cycles.
Definition: Adaptivity.h:299
void Adaptivity::setTimeActive ( Real  start_time,
Real  stop_time 
)

Sets the time when the adaptivity is active.

Parameters
start_timeThe time when adaptivity starts
stop_timeThe time when adaptivity stops

Definition at line 251 of file Adaptivity.C.

Referenced by SetAdaptivityOptionsAction::act(), and AdaptivityAction::act().

252 {
253  _start_time = start_time;
254  _stop_time = stop_time;
255 }
Real _stop_time
When adaptivity stops.
Definition: Adaptivity.h:282
Real _start_time
When adaptivity start.
Definition: Adaptivity.h:280
void Adaptivity::setUseNewSystem ( )

Tells this object we're using the "new" adaptivity system.

Definition at line 258 of file Adaptivity.C.

Referenced by SetAdaptivityOptionsAction::act().

259 {
260  _use_new_system = true;
261 }
bool _use_new_system
Whether or not to use the "new" adaptivity system.
Definition: Adaptivity.h:287
void Adaptivity::uniformRefine ( MooseMesh mesh)
static

Performs uniform refinement of the passed Mesh object.

The number of levels of refinement performed is stored in the MooseMesh object. No solution projection is performed in this version.

Definition at line 205 of file Adaptivity.C.

Referenced by SetupMeshCompleteAction::act().

206 {
207  mooseAssert(mesh, "Mesh pointer must not be NULL");
208 
209  // NOTE: we are using a separate object here, since adaptivity may not be on, but we need to be
210  // able to do refinements
211  MeshRefinement mesh_refinement(*mesh);
212  unsigned int level = mesh->uniformRefineLevel();
213  mesh_refinement.uniformly_refine(level);
214 }
unsigned int uniformRefineLevel() const
Returns the level of uniform refinement requested (zero if AMR is disabled).
Definition: MooseMesh.C:2202
void Adaptivity::uniformRefineWithProjection ( )

Performs uniform refinement on the meshes in the current object.

Projections are performed of the solution vectors.

Definition at line 217 of file Adaptivity.C.

Referenced by FEProblemBase::initialSetup().

218 {
219  // NOTE: we are using a separate object here, since adaptivity may not be on, but we need to be
220  // able to do refinements
221  MeshRefinement mesh_refinement(_mesh);
222  unsigned int level = _mesh.uniformRefineLevel();
223  MeshRefinement displaced_mesh_refinement(_displaced_problem ? _displaced_problem->mesh() : _mesh);
224 
225  // we have to go step by step so EquationSystems::reinit() won't freak out
226  for (unsigned int i = 0; i < level; i++)
227  {
228  // See comment above about why refining the displaced mesh is potentially unsafe.
229  if (_displaced_problem)
230  _displaced_problem->undisplaceMesh();
231 
232  mesh_refinement.uniformly_refine(1);
233 
234  if (_displaced_problem)
235  displaced_mesh_refinement.uniformly_refine(1);
237  }
238 }
std::shared_ptr< DisplacedProblem > _displaced_problem
Definition: Adaptivity.h:260
MooseMesh & _mesh
Definition: Adaptivity.h:247
FEProblemBase & _subproblem
Definition: Adaptivity.h:246
virtual void meshChanged() override
unsigned int uniformRefineLevel() const
Returns the level of uniform refinement requested (zero if AMR is disabled).
Definition: MooseMesh.C:2202
void Adaptivity::updateErrorVectors ( )

Update the ErrorVectors that have been requested through calls to getErrorVector().

Definition at line 285 of file Adaptivity.C.

Referenced by FEProblemBase::computeMarkers().

286 {
287  // Resize all of the ErrorVectors in case the mesh has changed
288  for (const auto & it : _indicator_field_to_error_vector)
289  {
290  ErrorVector & vec = *(it.second);
291  vec.assign(_mesh.getMesh().max_elem_id(), 0);
292  }
293 
294  // Fill the vectors with the local contributions
295  UpdateErrorVectorsThread uevt(_subproblem, _indicator_field_to_error_vector);
296  Threads::parallel_reduce(*_mesh.getActiveLocalElementRange(), uevt);
297 
298  // Now sum across all processors
299  for (const auto & it : _indicator_field_to_error_vector)
300  _subproblem.comm().sum((std::vector<float> &)*(it.second));
301 }
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:724
MooseMesh & _mesh
Definition: Adaptivity.h:247
std::map< std::string, std::unique_ptr< ErrorVector > > _indicator_field_to_error_vector
Stores pointers to ErrorVectors associated with indicator field names.
Definition: Adaptivity.h:302
FEProblemBase & _subproblem
Definition: Adaptivity.h:246
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2408

Member Data Documentation

const ConsoleStream ConsoleStreamInterface::_console
inherited

An instance of helper class to write streams to the Console objects.

Definition at line 37 of file ConsoleStreamInterface.h.

Referenced by IterationAdaptiveDT::acceptStep(), CreateProblemAction::act(), SetupRecoverFileBaseAction::act(), adaptMesh(), FEProblemBase::adaptMesh(), FEProblemBase::advanceMultiApps(), SimplePredictor::apply(), FEProblemBase::backupMultiApps(), FEProblemBase::checkProblemIntegrity(), IterationAdaptiveDT::computeAdaptiveDT(), Transient::computeConstrainedDT(), NonlinearSystemBase::computeDamping(), IterationAdaptiveDT::computeDT(), IterationAdaptiveDT::computeFailedDT(), IterationAdaptiveDT::computeInterpolationDT(), FEProblemBase::computeResidualType(), IterationAdaptiveDT::constrainStep(), TimeStepper::constrainStep(), AB2PredictorCorrector::converged(), FEProblemBase::execMultiApps(), FEProblemBase::execMultiAppTransfers(), MultiAppPostprocessorTransfer::execute(), MultiAppPostprocessorInterpolationTransfer::execute(), MultiAppVariableValueSamplePostprocessorTransfer::execute(), MultiAppNearestNodeTransfer::execute(), MultiAppPostprocessorToAuxScalarTransfer::execute(), MultiAppScalarToAuxScalarTransfer::execute(), MultiAppVariableValueSampleTransfer::execute(), MultiAppUserObjectTransfer::execute(), MultiAppInterpolationTransfer::execute(), MultiAppMeshFunctionTransfer::execute(), MultiAppProjectionTransfer::execute(), MultiAppCopyTransfer::execute(), Steady::execute(), MultiAppDTKUserObjectTransfer::execute(), ActionWarehouse::executeActionsWithAction(), ActionWarehouse::executeAllActions(), MultiApp::globalAppToLocal(), InversePowerMethod::init(), NonlinearEigen::init(), Steady::init(), FEProblemBase::initialAdaptMesh(), FEProblemBase::initialSetup(), EigenExecutionerBase::inversePowerIteration(), Transient::keepGoing(), IterationAdaptiveDT::limitDTByFunction(), IterationAdaptiveDT::limitDTToPostprocessorValue(), EigenExecutionerBase::makeBXConsistent(), Console::meshChanged(), MooseObject::mooseDeprecated(), MooseObject::mooseInfo(), MooseObject::mooseWarning(), DOFMapOutput::output(), VariableResidualNormsDebugOutput::output(), Console::output(), ControlOutput::outputActiveObjects(), ControlOutput::outputChangedControls(), ControlOutput::outputControls(), Console::outputInput(), Console::outputPostprocessors(), Console::outputScalarVariables(), Console::outputSystemInformation(), FEProblemBase::possiblyRebuildGeomSearchPatches(), EigenExecutionerBase::postExecute(), ActionWarehouse::printActionDependencySets(), EigenExecutionerBase::printEigenvalue(), MaterialPropertyDebugOutput::printMaterialMap(), SolutionTimeAdaptiveDT::rejectStep(), DT2::rejectStep(), FEProblemBase::restoreMultiApps(), SimplePredictor::shouldApply(), NonlinearSystem::solve(), LStableDirk2::solve(), LStableDirk3::solve(), ImplicitMidpoint::solve(), ExplicitTVDRK2::solve(), AStableDirk4::solve(), LStableDirk4::solve(), ExplicitRK2::solve(), TransientMultiApp::solveStep(), Transient::solveStep(), DT2::step(), AB2PredictorCorrector::step(), NonlinearEigen::takeStep(), FEProblemBase::useFECache(), Console::writeTimestepInformation(), Console::writeVariableNorms(), and FEProblemBase::~FEProblemBase().

unsigned int Adaptivity::_cycles_per_step
protected

The number of adaptivity cycles per step.

Definition at line 284 of file Adaptivity.h.

std::unique_ptr<MeshRefinement> Adaptivity::_displaced_mesh_refinement
protected

A mesh refinement object for displaced mesh.

Definition at line 263 of file Adaptivity.h.

Referenced by adaptMesh(), and init().

std::shared_ptr<DisplacedProblem> Adaptivity::_displaced_problem
protected

Definition at line 260 of file Adaptivity.h.

Referenced by adaptMesh(), init(), and uniformRefineWithProjection().

std::unique_ptr<ErrorVector> Adaptivity::_error
protected

Error vector for use with the error estimator.

Definition at line 258 of file Adaptivity.h.

Referenced by adaptMesh(), and init().

std::unique_ptr<ErrorEstimator> Adaptivity::_error_estimator
protected

Error estimator to be used by the apps.

Definition at line 256 of file Adaptivity.h.

Referenced by adaptMesh(), setErrorEstimator(), and setErrorNorm().

std::map<std::string, std::unique_ptr<ErrorVector> > Adaptivity::_indicator_field_to_error_vector
protected

Stores pointers to ErrorVectors associated with indicator field names.

Definition at line 302 of file Adaptivity.h.

Referenced by getErrorVector(), and updateErrorVectors().

std::string Adaptivity::_initial_marker_variable_name
protected

Name of the initial marker variable if using the new adaptivity system.

Definition at line 293 of file Adaptivity.h.

Referenced by initialAdaptMesh(), and setInitialMarkerVariableName().

unsigned int Adaptivity::_initial_steps
protected

the number of adaptivity steps to do at the beginning of simulation

Definition at line 266 of file Adaptivity.h.

Referenced by init().

bool Adaptivity::_initialized
protected

on/off flag reporting if the adaptivity system has been initialized

Definition at line 252 of file Adaptivity.h.

Referenced by init(), and setAdaptivityOn().

unsigned int Adaptivity::_interval
protected

intreval between adaptivity runs

Definition at line 278 of file Adaptivity.h.

Referenced by isAdaptivityDue().

std::string Adaptivity::_marker_variable_name
protected

Name of the marker variable if using the new adaptivity system.

Definition at line 290 of file Adaptivity.h.

Referenced by adaptMesh(), and setMarkerVariableName().

unsigned int Adaptivity::_max_h_level
protected

The maximum number of refinement levels.

Definition at line 296 of file Adaptivity.h.

Referenced by adaptMesh().

MooseMesh& Adaptivity::_mesh
protected

Definition at line 247 of file Adaptivity.h.

Referenced by adaptMesh(), init(), uniformRefineWithProjection(), and updateErrorVectors().

std::unique_ptr<MeshRefinement> Adaptivity::_mesh_refinement
protected

A mesh refinement object to be used either with initial refinement or with Adaptivity.

Definition at line 254 of file Adaptivity.h.

Referenced by adaptMesh(), and init().

bool Adaptivity::_mesh_refinement_on
protected

on/off flag reporting if the adaptivity is being used

Definition at line 250 of file Adaptivity.h.

Referenced by init(), isAdaptivityDue(), and setAdaptivityOn().

bool Adaptivity::_print_mesh_changed
protected

True if we want to print out info when mesh has changed.

Definition at line 271 of file Adaptivity.h.

Referenced by adaptMesh().

bool Adaptivity::_recompute_markers_during_cycles
protected

Whether or not to recompute markers during adaptivity cycles.

Definition at line 299 of file Adaptivity.h.

Real Adaptivity::_start_time
protected

When adaptivity start.

Definition at line 280 of file Adaptivity.h.

Referenced by isAdaptivityDue(), and setTimeActive().

int& Adaptivity::_step
protected

Time Step.

Definition at line 276 of file Adaptivity.h.

Referenced by isAdaptivityDue().

unsigned int Adaptivity::_steps
protected

steps of adaptivity to perform

Definition at line 268 of file Adaptivity.h.

Referenced by init().

Real Adaptivity::_stop_time
protected

When adaptivity stops.

Definition at line 282 of file Adaptivity.h.

Referenced by isAdaptivityDue(), and setTimeActive().

FEProblemBase& Adaptivity::_subproblem
protected

Definition at line 246 of file Adaptivity.h.

Referenced by adaptMesh(), init(), uniformRefineWithProjection(), and updateErrorVectors().

Real& Adaptivity::_t
protected

Time.

Definition at line 274 of file Adaptivity.h.

Referenced by isAdaptivityDue().

bool Adaptivity::_use_new_system
protected

Whether or not to use the "new" adaptivity system.

Definition at line 287 of file Adaptivity.h.

Referenced by adaptMesh(), and setUseNewSystem().


The documentation for this class was generated from the following files: