https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
ExplicitMixedOrder Class Reference

Implements a form of the central difference time integrator that calculates acceleration directly from the residual forces. More...

#include <ExplicitMixedOrder.h>

Inheritance diagram for ExplicitMixedOrder:
[legend]

Public Types

enum  TimeOrder { FIRST , SECOND }
 
typedef DataFileName DataFileParameterType
 

Public Member Functions

 ExplicitMixedOrder (const InputParameters &parameters)
 
virtual int order () override
 
virtual void computeTimeDerivatives () override
 
virtual void solve () override
 
virtual void postResidual (NumericVector< Number > &residual) override
 
virtual bool overridesSolve () const override
 
virtual void postSolve () override
 
virtual bool advancesProblemState () const override
 
virtual bool performExplicitSolve (SparseMatrix< Number > &mass_matrix) override
 
void computeADTimeDerivatives (ADReal &, const dof_id_type &, ADReal &) const override
 
virtual void init () override
 
virtual void meshChanged () override
 
TimeOrder findVariableTimeOrder (unsigned int var_num) const
 Retrieve the order of the highest time derivative of a variable.
 
virtual void initialSetup () override
 
virtual void preSolve () override
 
virtual bool isExplicit () const override
 
virtual void preStep ()
 
virtual void postStep ()
 
virtual unsigned int getNumNonlinearIterations () const
 
virtual unsigned int getNumLinearIterations () const
 
const Real & dt () const
 
virtual unsigned int numStatesRequired () const
 
virtual const bool & isLumped () const
 
bool integratesVar (const unsigned int var_num) const
 
void setNumIterationsLastSolve ()
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
bool isKokkosObject () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const TgetParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const TqueryParam (const std::string &name) const
 
const TgetRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
TagID uDotFactorTag () const
 
TagID uDotDotFactorTag () const
 
virtual Real timeDerivativeRHSContribution (dof_id_type dof_id, const std::vector< Real > &factors={}) const
 
virtual Real timeDerivativeMatrixContribution (const Real factor) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 

Protected Types

enum  SolveType
 

Protected Member Functions

void updateDOFIndices ()
 compile the dof indices for first and second order in time variables
 
virtual TagID massMatrixTagID () const override
 
virtual void evaluateRHSResidual ()
 Evaluate the RHS residual.
 
template<typename T , typename T2 , typename T3 , typename T4 >
void computeTimeDerivativeHelper (T &u_dot, T2 &u_dotdot, const T3 &u_old, const T4 &u_older) const
 Helper function that actually does the math for computing the time derivative.
 
void computeICs ()
 
void setupSolver ()
 
bool solveLinearSystem (SparseMatrix< Number > &mass_matrix)
 
bool checkLinearConvergence ()
 
unsigned int getNumNonlinearIterationsLastSolve () const
 
unsigned int getNumLinearIterationsLastSolve () const
 
void copyVector (const NumericVector< Number > &from, NumericVector< Number > &to)
 
virtual Real duDotDuCoeff () const
 
void computeDuDotDu ()
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 
TdeclareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< TdeclareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const TgetRestartableData (const std::string &data_name) const
 
TdeclareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
TdeclareRecoverableData (const std::string &data_name, Args &&... args)
 
TdeclareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
TdeclareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
NumericVector< Number > * addVector (const std::string &name, const bool project, const libMesh::ParallelType type)
 

Protected Attributes

const bool & _constant_mass
 Whether we are reusing the mass matrix.
 
const bool & _recompute_mass_matrix_on_mesh_change
 Must be set to true to use adaptivity with a constant mass matrix.
 
bool _mesh_changed
 Whether the mesh changed just before the current solve.
 
const TagName & _mass_matrix_name
 Mass matrix name.
 
NumericVector< Real > * _mass_matrix_lumped
 Lumped mass matrix.
 
const NumericVector< Number > & _solution_older
 The older solution.
 
std::unordered_set< unsigned int > & _vars_first
 
std::vector< dof_id_type > & _local_first_order_indices
 
std::unordered_set< unsigned int > & _vars_second
 
std::vector< dof_id_type > & _local_second_order_indices
 
 CONSISTENT
 
 LUMPED
 
 LUMP_PRECONDITIONED
 
MooseEnum _solve_type
 
NumericVector< Real > * _explicit_residual
 
NumericVector< Real > * _solution_update
 
NumericVector< Real > * _mass_matrix_diag_inverted
 
NumericVector< Real > * _ones
 
TagID _Ke_time_tag
 
std::unique_ptr< libMesh::LinearSolver< Number > > _linear_solver
 
std::unique_ptr< LumpedPreconditioner_preconditioner
 
Real _current_time
 
FEProblemBase_fe_problem
 
SystemBase_sys
 
std::vector< Real > & _du_dot_du
 
int_t_step
 
Real & _dt
 
Real & _dt_old
 
unsigned int _n_nonlinear_iterations
 
unsigned int _n_linear_iterations
 
bool _is_lumped
 
bool & _var_restriction
 
std::vector< dof_id_type > & _local_indices
 
std::unordered_set< unsigned int > & _vars
 
std::unique_ptr< NumericVector< Number > > _from_subvector
 
const bool & _enabled
 
MooseApp_app
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
MooseApp_restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
NonlinearSystemBase_nl
 
libMesh::NonlinearImplicitSystem_nonlinear_implicit_system
 
NumericVector< Number > * _Re_time
 
NumericVector< Number > * _Re_non_time
 
const TagID _u_dot_factor_tag
 
const TagID _u_dotdot_factor_tag
 
LinearSystem_linear_system
 
libMesh::LinearImplicitSystem_linear_implicit_system
 
FEProblemBase_mci_feproblem
 
const NumericVector< Number > *const & _solution
 
const NumericVector< Number > & _solution_old
 
std::unique_ptr< NumericVector< Number > > & _solution_sub
 
std::unique_ptr< NumericVector< Number > > & _solution_old_sub
 
const Parallel::Communicator & _communicator
 

Private Member Functions

RestartableDataValueregisterRestartableDataOnApp (std::unique_ptr< RestartableDataValue > data, THREAD_ID tid) const
 
void registerRestartableNameWithFilterOnApp (const std::string &name, Moose::RESTARTABLE_FILTER filter)
 
RestartableData< T > & declareRestartableDataHelper (const std::string &data_name, void *context, Args &&... args) const
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

const ParallelParamObject_parent
 
const MooseBase_si_moose_base
 
const FEProblemBase_si_problem
 
const RestartableDataMapName _metaname
 
std::string _restartable_name
 

Detailed Description

Implements a form of the central difference time integrator that calculates acceleration directly from the residual forces.

Definition at line 25 of file ExplicitMixedOrder.h.

Member Enumeration Documentation

◆ TimeOrder

Enumerator
FIRST 
SECOND 

Definition at line 56 of file ExplicitMixedOrder.h.

Constructor & Destructor Documentation

◆ ExplicitMixedOrder()

ExplicitMixedOrder::ExplicitMixedOrder ( const InputParameters parameters)

Definition at line 83 of file ExplicitMixedOrder.C.

85 _constant_mass(getParam<bool>("use_constant_mass")),
87 getParam<bool>("recompute_mass_matrix_after_mesh_change")),
88 _mesh_changed(true),
89 _mass_matrix_name(getParam<TagName>("mass_matrix_tag")),
90 _mass_matrix_lumped(addVector("mass_matrix_lumped", true, GHOSTED)),
92 _vars_first(declareRestartableData<std::unordered_set<unsigned int>>("first_order_vars")),
94 declareRestartableData<std::vector<dof_id_type>>("first_local_indices")),
95 _vars_second(declareRestartableData<std::unordered_set<unsigned int>>("second_order_vars")),
97 declareRestartableData<std::vector<dof_id_type>>("second_local_indices"))
98{
102}
std::unordered_set< unsigned int > & _vars_second
const NumericVector< Number > & _solution_older
The older solution.
const bool & _recompute_mass_matrix_on_mesh_change
Must be set to true to use adaptivity with a constant mass matrix.
NumericVector< Real > * _mass_matrix_lumped
Lumped mass matrix.
const TagName & _mass_matrix_name
Mass matrix name.
std::unordered_set< unsigned int > & _vars_first
const bool & _constant_mass
Whether we are reusing the mass matrix.
bool _mesh_changed
Whether the mesh changed just before the current solve.
std::vector< dof_id_type > & _local_second_order_indices
std::vector< dof_id_type > & _local_first_order_indices
virtual void setUDotOldRequested(const bool u_dot_old_requested)
virtual void setUDotDotRequested(const bool u_dotdot_requested)
virtual void setUDotRequested(const bool u_dot_requested)
const InputParameters & parameters() const
NumericVector< Number > * addVector(const std::string &name, const bool project, const libMesh::ParallelType type)
T & declareRestartableData(const std::string &data_name, Args &&... args)
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
FEProblemBase & _fe_problem

Member Function Documentation

◆ advancesProblemState()

virtual bool ExplicitMixedOrder::advancesProblemState ( ) const
inlineoverridevirtual

Reimplemented from ExplicitTimeIntegrator.

Definition at line 44 of file ExplicitMixedOrder.h.

44{ return true; }

◆ computeADTimeDerivatives()

void ExplicitMixedOrder::computeADTimeDerivatives ( ADReal ,
const dof_id_type &  ,
ADReal  
) const
inlineoverridevirtual

Implements ExplicitTimeIntegrator.

Definition at line 48 of file ExplicitMixedOrder.h.

49 {
50 mooseError("NOT SUPPORTED");
51 }
void mooseError(Args &&... args) const

◆ computeICs()

void ExplicitMixedOrder::computeICs ( )
protected

Definition at line 363 of file ExplicitMixedOrder.C.

364{
365 // Compute the first-order approximation of the velocity at the current time step
366 // using the Euler scheme, where the velocity is estimated as the difference
367 // between the current solution and the previous time step, divided by the time
368 auto vel = _sys.solutionUDot();
369 *vel = *_solution;
370 *vel -= _solution_old;
371 *vel /= _dt;
372 vel->close();
373}
virtual NumericVector< Number > * solutionUDot()
const NumericVector< Number > *const & _solution
const NumericVector< Number > & _solution_old
virtual void close()=0

Referenced by init().

◆ computeTimeDerivativeHelper()

template<typename T , typename T2 , typename T3 , typename T4 >
void ExplicitMixedOrder::computeTimeDerivativeHelper ( T u_dot,
T2 &  u_dotdot,
const T3 &  u_old,
const T4 &  u_older 
) const
protected

Helper function that actually does the math for computing the time derivative.

Definition at line 124 of file ExplicitMixedOrder.h.

128{
129 // computing first derivative
130 // using the Central Difference method
131 // u_dot_old = (first_term - second_term) / 2 / dt
132 // first_term = u
133 // second_term = u_older
134 u_dot -= u_older; // 'older than older' solution
135 u_dot *= 1.0 / (2.0 * _dt);
136
137 // computing second derivative
138 // using the Central Difference method
139 // u_dotdot_old = (first_term - second_term + third_term) / dt / dt
140 // first_term = u
141 // second_term = 2 * u_old
142 // third_term = u_older
143 u_dotdot -= u_old;
144 u_dotdot -= u_old;
145 u_dotdot += u_older;
146 u_dotdot *= 1.0 / (_dt * _dt);
147}

◆ computeTimeDerivatives()

void ExplicitMixedOrder::computeTimeDerivatives ( )
overridevirtual

Implements ExplicitTimeIntegrator.

Definition at line 105 of file ExplicitMixedOrder.C.

106{
107 /*
108 Because this is called in NonLinearSystemBase
109 this should not actually compute the time derivatives.
110 Calculating time derivatives here will cause issues for the
111 solution update.
112 */
113 return;
114}

◆ evaluateRHSResidual()

void ExplicitMixedOrder::evaluateRHSResidual ( )
protectedvirtual

Evaluate the RHS residual.

Reimplemented in NEML2CentralDifference.

Definition at line 195 of file ExplicitMixedOrder.C.

196{
197 // Compute the residual
200
201 // Move the residual to the RHS
202 *_explicit_residual *= -1.0;
203}
NumericVector< Real > * _explicit_residual
void computeResidual(libMesh::NonlinearImplicitSystem &sys, const NumericVector< libMesh::Number > &soln, NumericVector< libMesh::Number > &residual)
NonlinearSystemBase * _nl
libMesh::NonlinearImplicitSystem * _nonlinear_implicit_system
unsigned int number() const
std::unique_ptr< NumericVector< Number > > current_local_solution

Referenced by NEML2CentralDifference::evaluateRHSResidual(), and solve().

◆ findVariableTimeOrder()

ExplicitMixedOrder::TimeOrder ExplicitMixedOrder::findVariableTimeOrder ( unsigned int  var_num) const

Retrieve the order of the highest time derivative of a variable.

Returns
Returns the time order enum of this variable.

Definition at line 376 of file ExplicitMixedOrder.C.

377{
378 if (_vars_first.empty() && _vars_second.empty())
379 mooseError("Time order sets are both empty.");
380 if (_vars_first.count(var_num))
381 return FIRST;
382 else if (_vars_second.count(var_num))
383 return SECOND;
384 else
385 mooseError("Variable " + _sys.system().variable_name(var_num) +
386 " does not exist in time order sets.");
387}
virtual libMesh::System & system()=0
const std::string & variable_name(const unsigned int i) const

Referenced by ExplicitDirichletBCBase::timestepSetup().

◆ init()

void ExplicitMixedOrder::init ( )
overridevirtual

Reimplemented from ExplicitTimeIntegrator.

Definition at line 290 of file ExplicitMixedOrder.C.

291{
293
294 // Compute ICs for velocity
295 computeICs();
296
297 // Seperate variables into first and second time integration order and find
298 // the local indices for each
299 const auto & var_names_first = getParam<std::vector<VariableName>>("first_order_vars");
300 const auto & var_names_second = getParam<std::vector<VariableName>>("second_order_vars");
301 std::vector<unsigned int> var_num_vec;
302
303 auto & lm_sys = _sys.system();
304 lm_sys.get_all_variable_numbers(var_num_vec);
305 std::unordered_set<unsigned int> var_nums(var_num_vec.begin(), var_num_vec.end());
306
307 for (const auto & var_name : var_names_first)
308 if (lm_sys.has_variable(var_name))
309 {
310 const auto var_num = lm_sys.variable_number(var_name);
311 _vars_first.insert(var_num);
312 var_nums.erase(var_num);
313 }
314
315 for (const auto & var_name : var_names_second)
316 if (lm_sys.has_variable(var_name))
317 {
318 const auto var_num = lm_sys.variable_number(var_name);
319 _vars_second.insert(var_num);
320 var_nums.erase(var_num);
321 }
322
323 // If var_nums is empty then that means the user has specified all the variables in this system
324 if (!var_nums.empty())
325 mooseError("Not all nonlinear variables have their order specified.");
326}
virtual void init() override
void get_all_variable_numbers(std::vector< unsigned int > &all_variable_numbers) const
if(subdm)

◆ massMatrixTagID()

TagID ExplicitMixedOrder::massMatrixTagID ( ) const
overrideprotectedvirtual

Reimplemented from ExplicitTimeIntegrator.

Definition at line 132 of file ExplicitMixedOrder.C.

133{
135}
virtual TagID getMatrixTagID(const TagName &tag_name) const
SubProblem & subproblem()

Referenced by solve().

◆ meshChanged()

void ExplicitMixedOrder::meshChanged ( )
overridevirtual

Reimplemented from ExplicitTimeIntegrator.

Reimplemented in NEML2CentralDifference.

Definition at line 117 of file ExplicitMixedOrder.C.

118{
120 paramError("recompute_mass_matrix_after_mesh_change",
121 "Must be set to true explicitly by the user to support adaptivity with "
122 "`use_constant_mass`.");
123
124 // after mesh changes we need to recompute the mass matrix, it is not interpolable as it contains
125 // a volume integrated quantity!
126 _mesh_changed = true;
127
129}
virtual void meshChanged() override
void paramError(const std::string &param, Args... args) const

Referenced by NEML2CentralDifference::meshChanged().

◆ order()

virtual int ExplicitMixedOrder::order ( )
inlineoverridevirtual

Implements ExplicitTimeIntegrator.

Definition at line 32 of file ExplicitMixedOrder.h.

32{ return 1; }

◆ overridesSolve()

virtual bool ExplicitMixedOrder::overridesSolve ( ) const
inlineoverridevirtual

Implements ExplicitTimeIntegrator.

Definition at line 37 of file ExplicitMixedOrder.h.

37{ return true; }

◆ performExplicitSolve()

bool ExplicitMixedOrder::performExplicitSolve ( SparseMatrix< Number > &  mass_matrix)
overridevirtual

Reimplemented from ExplicitTimeIntegrator.

Definition at line 217 of file ExplicitMixedOrder.C.

218{
219 bool converged = false;
220
221 // Grab all the vectors that we will need
222 auto accel = _sys.solutionUDotDot();
223 auto vel = _sys.solutionUDot();
224
225 // Compute Forward Euler
226 // Split diag mass and residual vectors into correct subvectors
227 const std::unique_ptr<NumericVector<Number>> mass_inv_first(
228 NumericVector<Number>::build(_communicator, libMesh::default_solver_package(), PARALLEL));
229 const std::unique_ptr<NumericVector<Real>> exp_res_first(
230 NumericVector<Number>::build(_communicator, libMesh::default_solver_package(), PARALLEL));
231 _mass_matrix_diag_inverted->create_subvector(*mass_inv_first, _local_first_order_indices, false);
232 _explicit_residual->create_subvector(*exp_res_first, _local_first_order_indices, false);
233
234 // Need velocity vector split into subvectors
235 auto vel_first = vel->get_subvector(_local_first_order_indices);
236
237 // Velocity update for foward euler
238 vel_first->pointwise_mult(*mass_inv_first, *exp_res_first);
239
240 // Restore the velocities
241 vel->restore_subvector(std::move(vel_first), _local_first_order_indices);
242
243 // Compute Central Difference
244 // Split diag mass and residual vectors into correct subvectors
245 const std::unique_ptr<NumericVector<Real>> mass_inv_second(
246 NumericVector<Number>::build(_communicator, libMesh::default_solver_package(), PARALLEL));
247 const std::unique_ptr<NumericVector<Real>> exp_res_second(
248 NumericVector<Number>::build(_communicator, libMesh::default_solver_package(), PARALLEL));
249 _mass_matrix_diag_inverted->create_subvector(
250 *mass_inv_second, _local_second_order_indices, false);
251 _explicit_residual->create_subvector(*exp_res_second, _local_second_order_indices, false);
252
253 // Only need acceleration and old velocity vector for central difference
254 auto accel_second = accel->get_subvector(_local_second_order_indices);
255
256 auto vel_second = vel->get_subvector(_local_second_order_indices);
257
258 // Compute acceleration for central difference
259 accel_second->pointwise_mult(*mass_inv_second, *exp_res_second);
260
261 // Scaling the acceleration
262 auto accel_scaled = accel_second->clone();
263 accel_scaled->scale((_dt + _dt_old) / 2);
264
265 // Velocity update for central difference
266 *vel_second += *accel_scaled;
267
268 // Restore acceleration
269 accel->restore_subvector(std::move(accel_second), _local_second_order_indices);
270
271 vel->restore_subvector(std::move(vel_second), _local_second_order_indices);
272
273 // Same solution update for both methods
274 *_solution_update = *vel;
275 _solution_update->scale(_dt);
276
277 // Check for convergence by seeing if there is a nan or inf
278 auto sum = _solution_update->sum();
279 converged = std::isfinite(sum);
280
281 // The linear iteration count remains zero
283 vel->close();
284 accel->close();
285
286 return converged;
287}
NumericVector< Real > * _mass_matrix_diag_inverted
NumericVector< Real > * _solution_update
virtual NumericVector< Number > * solutionUDotDot()
unsigned int _n_linear_iterations
const Parallel::Communicator & _communicator
bool converged(const std::vector< std::pair< unsigned int, Real > > &residuals, const std::vector< Real > &abs_tolerances)
Based on the residuals, determine if the iterative process converged or not.
SolverPackage default_solver_package()

Referenced by solve().

◆ postResidual()

void ExplicitMixedOrder::postResidual ( NumericVector< Number > &  residual)
overridevirtual

Reimplemented from ExplicitTimeIntegrator.

Definition at line 206 of file ExplicitMixedOrder.C.

207{
208 residual += *_Re_time;
209 residual += *_Re_non_time;
210 residual.close();
211
212 // Reset time to the time at which to evaluate nodal BCs, which comes next
214}
virtual Real & time() const
NumericVector< Number > * _Re_non_time
NumericVector< Number > * _Re_time

◆ postSolve()

virtual void ExplicitMixedOrder::postSolve ( )
inlineoverridevirtual

Reimplemented from ExplicitTimeIntegrator.

Reimplemented in NEML2CentralDifference.

Definition at line 39 of file ExplicitMixedOrder.h.

40 { // Once we have the new solution, we want to adanceState to make sure the
41 // coupling between the solution and the computed material properties is kept correctly.
43 }
virtual void advanceState()

Referenced by NEML2CentralDifference::postSolve().

◆ solve()

void ExplicitMixedOrder::solve ( )
overridevirtual

Reimplemented from ExplicitTimeIntegrator.

Definition at line 138 of file ExplicitMixedOrder.C.

139{
140 // Getting the tagID for the mass matrix
141 auto mass_tag = massMatrixTagID();
142
143 // Reset iteration counts
146
148
149 auto & mass_matrix = _nonlinear_implicit_system->get_system_matrix();
150
151 if (_mesh_changed)
153
154 // Compute the mass matrix
156 {
157 // We only want to compute "inverted" lumped mass matrix once.
159 *_nonlinear_implicit_system->current_local_solution, mass_matrix, mass_tag);
160
161 // Calculate and record the lumped mass matrix for use in residual calculation
162 mass_matrix.vector_mult(*_mass_matrix_lumped, *_ones);
163 _mass_matrix_lumped->close();
164
165 // "Invert" the diagonal mass matrix
167 _mass_matrix_diag_inverted->reciprocal();
169 }
170
171 _mesh_changed = false;
172
173 // Set time to the time at which to evaluate the residual
176
177 // Evaluate residual and move it to the RHS
179
180 // Perform the linear solve
181 bool converged = performExplicitSolve(mass_matrix);
183
184 // Update the solution
187
189
192}
virtual void evaluateRHSResidual()
Evaluate the RHS residual.
virtual TagID massMatrixTagID() const override
void updateDOFIndices()
compile the dof indices for first and second order in time variables
virtual bool performExplicitSolve(SparseMatrix< Number > &mass_matrix) override
NumericVector< Real > * _ones
virtual Real & timeOld() const
virtual void computeJacobianTag(const NumericVector< libMesh::Number > &soln, libMesh::SparseMatrix< libMesh::Number > &jacobian, TagID tag)
void overwriteNodeFace(NumericVector< Number > &soln)
void setSolution(const NumericVector< Number > &soln)
NumericVector< Number > & solutionOld()
unsigned int _n_nonlinear_iterations
const SparseMatrix< Number > & get_system_matrix() const
std::unique_ptr< NonlinearSolver< Number > > nonlinear_solver
std::unique_ptr< NumericVector< Number > > solution

◆ updateDOFIndices()

void ExplicitMixedOrder::updateDOFIndices ( )
protected

compile the dof indices for first and second order in time variables

Definition at line 329 of file ExplicitMixedOrder.C.

330{
331 auto & lm_sys = _sys.system();
332
333 std::vector<dof_id_type> var_dof_indices, work_vec;
334 for (const auto var_num : _vars_first)
335 {
338 lm_sys.get_dof_map().local_variable_indices(var_dof_indices, lm_sys.get_mesh(), var_num);
339 std::merge(work_vec.begin(),
340 work_vec.end(),
341 var_dof_indices.begin(),
342 var_dof_indices.end(),
343 std::back_inserter(_local_first_order_indices));
344 }
345
346 work_vec.clear();
347 var_dof_indices.clear();
348
349 for (const auto var_num : _vars_second)
350 {
353 lm_sys.get_dof_map().local_variable_indices(var_dof_indices, lm_sys.get_mesh(), var_num);
354 std::merge(work_vec.begin(),
355 work_vec.end(),
356 var_dof_indices.begin(),
357 var_dof_indices.end(),
358 std::back_inserter(_local_second_order_indices));
359 }
360}
virtual void clear()

Referenced by solve().

◆ validParams()

InputParameters ExplicitMixedOrder::validParams ( )
static

Definition at line 41 of file ExplicitMixedOrder.C.

42{
44
46 "Implementation of explicit time integration without invoking any of the nonlinear solver.");
47
48 params.addParam<bool>("use_constant_mass",
49 false,
50 "If set to true, will only compute the mass matrix in the first time step, "
51 "and keep using it throughout the simulation.");
52
53 params.addParam<bool>(
54 "recompute_mass_matrix_after_mesh_change",
55 false,
56 "If set to true, the mass matrix will be recomputed when the mesh changes (e.g. through "
57 "adaptivity). If use_constant_mass is set to true, adadaptivity is used, and this parameter "
58 "is not set to true, the simulation will error out when the mesh changes.");
59
60 params.addParam<TagName>("mass_matrix_tag", "mass", "The tag for the mass matrix");
61
62 params.addParam<std::vector<VariableName>>(
63 "second_order_vars",
64 {},
65 "A subset of variables that require second-order integration (velocity and acceleration) to "
66 "be applied by this time integrator.");
67
68 params.addParam<std::vector<VariableName>>(
69 "first_order_vars",
70 {},
71 "A subset of variables that require first-order integration (velocity only) to be applied by "
72 "this time integrator.");
73
74 // Prevent users from using variables option by accident.
75 params.suppressParameter<std::vector<VariableName>>("variables");
76
77 MooseEnum solve_type("consistent lumped lump_preconditioned", "lumped");
78 params.setParameters("solve_type", solve_type);
79 params.ignoreParameter<MooseEnum>("solve_type");
80 return params;
81}
static InputParameters validParams()
void suppressParameter(const std::string &name)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void ignoreParameter(const std::string &name)
void addClassDescription(const std::string &doc_string)
void setParameters(const std::string &name, const T &value, Ts... extra_input_parameters)

Referenced by NEML2CentralDifference::validParams().

Member Data Documentation

◆ _constant_mass

const bool& ExplicitMixedOrder::_constant_mass
protected

Whether we are reusing the mass matrix.

Definition at line 78 of file ExplicitMixedOrder.h.

Referenced by meshChanged(), and solve().

◆ _local_first_order_indices

std::vector<dof_id_type>& ExplicitMixedOrder::_local_first_order_indices
protected

Definition at line 104 of file ExplicitMixedOrder.h.

Referenced by performExplicitSolve(), and updateDOFIndices().

◆ _local_second_order_indices

std::vector<dof_id_type>& ExplicitMixedOrder::_local_second_order_indices
protected

Definition at line 110 of file ExplicitMixedOrder.h.

Referenced by performExplicitSolve(), and updateDOFIndices().

◆ _mass_matrix_lumped

NumericVector<Real>* ExplicitMixedOrder::_mass_matrix_lumped
protected

Lumped mass matrix.

Definition at line 95 of file ExplicitMixedOrder.h.

Referenced by solve().

◆ _mass_matrix_name

const TagName& ExplicitMixedOrder::_mass_matrix_name
protected

Mass matrix name.

Definition at line 92 of file ExplicitMixedOrder.h.

Referenced by massMatrixTagID().

◆ _mesh_changed

bool ExplicitMixedOrder::_mesh_changed
protected

Whether the mesh changed just before the current solve.

Definition at line 89 of file ExplicitMixedOrder.h.

Referenced by meshChanged(), and solve().

◆ _recompute_mass_matrix_on_mesh_change

const bool& ExplicitMixedOrder::_recompute_mass_matrix_on_mesh_change
protected

Must be set to true to use adaptivity with a constant mass matrix.

This will recompute the mass matrix when the mesh changes. The user must make sure that the underlying material density stays constant, otherwise simulation results will depend on adaptivity.

Definition at line 86 of file ExplicitMixedOrder.h.

Referenced by meshChanged().

◆ _solution_older

const NumericVector<Number>& ExplicitMixedOrder::_solution_older
protected

The older solution.

Definition at line 98 of file ExplicitMixedOrder.h.

◆ _vars_first

std::unordered_set<unsigned int>& ExplicitMixedOrder::_vars_first
protected

Definition at line 101 of file ExplicitMixedOrder.h.

Referenced by findVariableTimeOrder(), init(), and updateDOFIndices().

◆ _vars_second

std::unordered_set<unsigned int>& ExplicitMixedOrder::_vars_second
protected

Definition at line 107 of file ExplicitMixedOrder.h.

Referenced by findVariableTimeOrder(), init(), and updateDOFIndices().


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