https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ExplicitMixedOrder.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
13
14// Forward declarations
15namespace libMesh
16{
17template <typename T>
18class SparseMatrix;
19}
20
26{
27public:
29
31
32 virtual int order() override { return 1; }
33 virtual void computeTimeDerivatives() override;
34
35 virtual void solve() override;
36 virtual void postResidual(NumericVector<Number> & residual) override;
37 virtual bool overridesSolve() const override { return true; }
38
39 virtual void postSolve() override
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 }
44 virtual bool advancesProblemState() const override { return true; }
45
46 virtual bool performExplicitSolve(SparseMatrix<Number> & mass_matrix) override;
47
48 void computeADTimeDerivatives(ADReal &, const dof_id_type &, ADReal &) const override
49 {
50 mooseError("NOT SUPPORTED");
51 }
52 virtual void init() override;
53
54 virtual void meshChanged() override;
55
57 {
59 SECOND
60 };
61
66 TimeOrder findVariableTimeOrder(unsigned int var_num) const;
67
68protected:
70 void updateDOFIndices();
71
72 virtual TagID massMatrixTagID() const override;
73
75 virtual void evaluateRHSResidual();
76
78 const bool & _constant_mass;
79
87
90
92 const TagName & _mass_matrix_name;
93
95 NumericVector<Real> * _mass_matrix_lumped;
96
98 const NumericVector<Number> & _solution_older;
99
100 // Variables that forward Euler time integration will be used for
101 std::unordered_set<unsigned int> & _vars_first;
102
103 // local dofs that will have forward euler time integration
104 std::vector<dof_id_type> & _local_first_order_indices;
105
106 // Variables that central difference time integration will be used for
107 std::unordered_set<unsigned int> & _vars_second;
108
109 // local dofs that will have central difference time integration
110 std::vector<dof_id_type> & _local_second_order_indices;
111
115 template <typename T, typename T2, typename T3, typename T4>
116 void
117 computeTimeDerivativeHelper(T & u_dot, T2 & u_dotdot, const T3 & u_old, const T4 & u_older) const;
118
119 void computeICs();
120};
121
122template <typename T, typename T2, typename T3, typename T4>
123void
125 T2 & u_dotdot,
126 const T3 & u_old,
127 const T4 & u_older) const
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}
DualNumber< Real, DNDerivativeType, true > ADReal
const double T
unsigned int TagID
Implements a form of the central difference time integrator that calculates acceleration directly fro...
std::unordered_set< unsigned int > & _vars_second
TimeOrder findVariableTimeOrder(unsigned int var_num) const
Retrieve the order of the highest time derivative of a variable.
virtual void postSolve() override
const NumericVector< Number > & _solution_older
The older solution.
virtual void meshChanged() override
const bool & _recompute_mass_matrix_on_mesh_change
Must be set to true to use adaptivity with a constant mass matrix.
virtual void evaluateRHSResidual()
Evaluate the RHS residual.
void computeADTimeDerivatives(ADReal &, const dof_id_type &, ADReal &) const override
NumericVector< Real > * _mass_matrix_lumped
Lumped mass matrix.
virtual void postResidual(NumericVector< Number > &residual) override
const TagName & _mass_matrix_name
Mass matrix name.
virtual void solve() override
virtual TagID massMatrixTagID() const override
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.
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.
virtual bool advancesProblemState() const override
void updateDOFIndices()
compile the dof indices for first and second order in time variables
std::vector< dof_id_type > & _local_second_order_indices
virtual bool overridesSolve() const override
virtual void init() override
static InputParameters validParams()
std::vector< dof_id_type > & _local_first_order_indices
virtual bool performExplicitSolve(SparseMatrix< Number > &mass_matrix) override
virtual void computeTimeDerivatives() override
virtual int order() override
virtual void advanceState()
const InputParameters & parameters() const
void mooseError(Args &&... args) const
FEProblemBase & _fe_problem
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...