-
Notifications
You must be signed in to change notification settings - Fork 304
Expand file tree
/
Copy patheuler2_solver.h
More file actions
147 lines (120 loc) · 4.77 KB
/
euler2_solver.h
File metadata and controls
147 lines (120 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// The libMesh Finite Element Library.
// Copyright (C) 2002-2022 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef LIBMESH_EULER2_SOLVER_H
#define LIBMESH_EULER2_SOLVER_H
// Local includes
#include "libmesh/first_order_unsteady_solver.h"
// C++ includes
namespace libMesh
{
/**
* This class defines a theta-method (defaulting to Backward
* Euler with theta = 1.0) solver to handle
* time integration of DifferentiableSystems.
* The "Euler2" solver differs from Euler in how it evaluates
* residuals at intermediate theta values:
* Euler solves m(u,u') = f(theta*u_new + (1-theta)*u_old),
* Euler2 solves m(u') = theta*f(u_new) + (1-theta)*f(u_old)
* i.e. the trapezoidal rule for theta = 0.5
*
* This class is part of the new DifferentiableSystem framework,
* which is still experimental. Users of this framework should
* beware of bugs and future API changes.
*
* \author Roy H. Stogner
* \date 2006
*/
class Euler2Solver : public FirstOrderUnsteadySolver
{
public:
/**
* The parent class
*/
typedef FirstOrderUnsteadySolver Parent;
/**
* Constructor. Requires a reference to the system
* to be solved.
*/
explicit
Euler2Solver (sys_type & s);
/**
* Destructor.
*/
virtual ~Euler2Solver ();
/**
* Error convergence order: 2 for Crank-Nicolson, 1 otherwise
*/
virtual Real error_order() const override;
/**
* A method to integrate the system::QoI functionals.
*/
virtual void integrate_qoi_timestep() override;
#ifdef LIBMESH_ENABLE_AMR
/**
* A method to compute the adjoint refinement error estimate at the current timestep.
* int_{tstep_start}^{tstep_end} R(u^h,z) dt.
* The user provides an initialized ARefEE object.
* Fills in an ErrorVector that contains the weighted sum of errors from all the QoIs and can be used to guide AMR.
* The integration scheme used is consistent with the theta used for the unsteady solution.
* CURRENTLY ONLY SUPPORTED for Backward Euler.
*/
virtual void integrate_adjoint_refinement_error_estimate(AdjointRefinementEstimator & adjoint_refinement_error_estimator, ErrorVector & QoI_elementwise_error) override;
#endif // LIBMESH_ENABLE_AMR
virtual void advance_postprocessing_timestep(std::vector<std::function<void(Real, System &)>> integration_operations) override;
/**
* This method uses the DifferentiablePhysics'
* element_time_derivative() and element_constraint()
* to build a full residual on an element. What combination
* it uses will depend on theta.
*/
virtual bool element_residual (bool request_jacobian,
DiffContext &) override;
/**
* This method uses the DifferentiablePhysics'
* side_time_derivative() and side_constraint()
* to build a full residual on an element's side.
* What combination it uses will depend on theta.
*/
virtual bool side_residual (bool request_jacobian,
DiffContext &) override;
/**
* This method uses the DifferentiablePhysics'
* nonlocal_time_derivative() and nonlocal_constraint()
* to build a full residual for non-local terms.
* What combination it uses will depend on theta.
*/
virtual bool nonlocal_residual (bool request_jacobian,
DiffContext &) override;
/**
* The value for the theta method to employ: 1.0 corresponds
* to backwards Euler, 0.0 corresponds to forwards Euler,
* 0.5 corresponds to a Crank-Nicolson-like scheme.
*/
Real theta;
protected:
/**
* This method is the underlying implementation of the public
* residual methods.
*/
virtual bool _general_residual (bool request_jacobian,
DiffContext &,
ResFuncType mass,
ResFuncType damping,
ResFuncType time_deriv,
ResFuncType constraint,
ReinitFuncType reinit,
bool compute_second_order_eqns);
};
} // namespace libMesh
#endif // LIBMESH_EULER2_SOLVER_H