Nektar++
Loading...
Searching...
No Matches
edesign/EquationSystems/EulerCFE.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: EulerCFE.cpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Euler equations in consÆ’ervative variables without artificial
32// diffusion
33//
34///////////////////////////////////////////////////////////////////////////////
35
37
53#include <SolverCore/Advection/AdvectionWeakDG/AdvectionWeakDGOp.hpp>
54#include <SolverCore/TimeOps/TimeOp.hpp>
55
56#include <iomanip>
57
58namespace Nektar
59{
60using namespace MultiRegions;
61
62std::string EulerCFE::className =
64 "EulerCFE", EulerCFE::create,
65 "Euler equations in conservative variables.");
66
69 : UnsteadySystem(pSession, pGraph)
70{
71 ASSERTL0(m_projectionType == MultiRegions::eDiscontinuous,
72 "The NavierStokesCFE is only implemented for projectionType "
73 "Discontinuous");
74}
75
76/**
77 * @brief Initialisation object for the Euler equations in conservative
78 * variables.
79 */
80void EulerCFE::v_InitObject(bool declareExpansionLists)
81{
82 // Call to the initialisation object of EquationSystem
83 UnsteadySystem::v_InitObject(declareExpansionLists);
84
85 ASSERTL0(m_session->DefinesSolverInfo("UPWINDTYPE"),
86 "No UPWINDTYPE defined in session.");
87
88 /// Create Fields for solution m_phys, m_coeff and others
89 v_InitialiseFields();
90
91 // Create and initialise all operators
92 v_InitialiseOperators();
93}
94
95void EulerCFE::v_GenerateSummary(SummaryList &s)
96{
97 UnsteadySystem::v_GenerateSummary(s);
98
99 AddSummaryItem(s, "Equations", "Compressible Euler");
100 AddSummaryItem(s, "Formulation", "Explicit");
101
102 std::stringstream ss;
103 ss << R"(
104 _ _ _ _
105| \ | | | | | | _ _
106| \| | ___| | _| |_ __ _ _ __ _| |_ _| |_
107| . ` |/ _ \ |/ / __/ _` | '__|_ _|_ _|
108| |\ | __/ <| || (_| | | |_| |_|
109\_| \_/\___|_|\_\\__\__,_|_|
110 _ _ _
111 | | (_) | |
112 _ __ ___ __| | ___ ___ _ __ _ _ __ ___ __| |
113| '__/ _ \/ _` |/ _ \/ __| |/ _` | '_ \ / _ \/ _` |
114| | | __/ (_| | __/\__ \ | (_| | | | | __/ (_| |
115|_| \___|\__,_|\___||___/_|\__, |_| |_|\___|\__,_|
116 __/ |
117 |___/
118)";
119 AddSummaryItem(s, "Redesign disclaimer", ss.str());
121
122/*
123 * Setup rhs advection term.
124 *
125 * Upon input
126 * param in: = u^{n}
127 * param out: = param in
128 * param time: = t^{n+1}
129 * param dt: = \Delta t
130 *
131 * Upon output
132 * param in: = u^{n+1}
133 * param out: = param in
134 */
135void EulerCFE::DoAdvection(LibUtilities::Field<double, FieldState::Phys> &in,
137 const double &time, const double &dt)
138{
139 // Solve advection problem
140 m_advectionWeakDGOp->UpdateBndPhys(time);
141 m_advectionWeakDGOp->SetScale(-dt);
142 m_advectionWeakDGOp->Apply(in, out);
143}
144
145/**
146 * @brief Project onto the solution space, which for DG is a copy.
147 */
148void EulerCFE::DoProjection(LibUtilities::Field<double, FieldState::Phys> &in,
150 [[maybe_unused]] const double &time)
151{
152 if (&in != &out)
153 {
154 m_math.copy(in, out);
155 }
156}
157
158/*
159 * Create and initialise all operators for this solver
160 */
161void EulerCFE::v_InitialiseOperators()
162{
163 // Element-local projection of the solution to coefficients for output.
164 m_iProductWRTBaseOp =
165 IProductWRTBaseOp<double>::Create(m_expansionLists[0], m_variables[0]);
166 m_multiplyByElmtInvMassOp = MultiplyByElmtInvMassOp<double>::Create(
167 m_expansionLists[0], m_variables[0]);
168
169 // Create operators
170 m_advectionWeakDGOp =
171 AdvectionWeakDGOp<double>::Create(m_expansionLists[0], m_variables[0]);
172
173 std::string execName =
175 std::string riemannMethod = m_session->GetSolverInfo("UpwindType");
176 auto volumeFluxOp =
177 EulerVolumeFluxOp<double>::Create(m_expansionLists[0], m_variables[0]);
178
179 // Set volume flux and for advection operator
180 m_advectionWeakDGOp->SetVolumeFluxOp(volumeFluxOp);
181
182 std::string EqnOfState =
183 StringUtils::ToUpperCopy(m_session->GetEquationOfState().type);
184 riemannMethod = "AdvTraceFluxCFE" + riemannMethod + EqnOfState;
186 m_expansionLists[0], m_variables[0], riemannMethod, execName);
187
188 // Set trace flux and Riemann solver for advection operator
189 m_advectionWeakDGOp->SetTraceFlux(traceFluxOp);
191 // The trace and the volume term in one pass, as SOLVERINFO
192 // FusedElmt selects.
193 m_advectionWeakDGOp->SetFusedElmtOp(
194 CreateAdvDiffFusedElmtCFEOp<SolverCore::AdvectionFusedElmtOp>(
195 m_expansionLists[0], m_variables[0], true, ""));
196
197 // Configure Time-integration
198 m_timeOp = TimeOp<double>::Create(m_expansionLists[0], m_variables[0]);
199 m_timeOp->DefineProjection(&EulerCFE::DoProjection, this);
200 m_timeOp->DefineExplicitRhs(&EulerCFE::DoAdvection, this);
201
202 SetUpBoundaryConditions();
203}
204
205CoefficientFieldViews EulerCFE::v_GetOutputFieldViews()
206{
207 // The solution is advanced in physical space, so project back to
208 // coefficients before exposing it to output filters, through the
209 // element-local L2 projection required by the restart path.
210 m_iProductWRTBaseOp->Apply(m_phys[0], m_wsp_coeff[0]);
211 m_multiplyByElmtInvMassOp->Apply(m_wsp_coeff[0], m_coeff[0]);
212
213 return UnsteadySystem::v_GetOutputFieldViews();
214}
215
216/**
217 * @brief Attach the boundary conditions this system supports.
218 *
219 * Each operator claims only the regions carrying its tag and costs nothing
220 * when there are none, so all of them are attached unconditionally.
221 */
222void EulerCFE::SetUpBoundaryConditions()
223{
224 // A pressure outflow extrapolates the interior state and imposes only the
225 // static pressure, so it is a condition on the inviscid state and belongs
226 // here as much as on the viscous path. Attached unconditionally: the
227 // operator claims only the regions tagged PressureOutflow and costs nothing
228 // when there are none.
229 auto bndCondPressureOutflowOp = BndCondPressureOutflowCFEOp<double>::Create(
230 m_expansionLists[0], m_variables[0]);
231 m_advectionWeakDGOp->AddBndCondUpdateOp(bndCondPressureOutflowOp);
232
233 // A subsonic entropy inflow is likewise a condition on the inviscid state.
234 auto bndCondEntropyVelocityOp =
236 m_variables[0]);
237 m_advectionWeakDGOp->AddBndCondUpdateOp(bndCondEntropyVelocityOp);
238
239 // Its two siblings, which fill the same degree of freedom with the
240 // pressure or the total enthalpy instead.
241 auto bndCondEntropyPressureOp =
243 m_variables[0]);
244 m_advectionWeakDGOp->AddBndCondUpdateOp(bndCondEntropyPressureOp);
245
246 auto bndCondEntropyTotalEnthalpyOp =
248 m_expansionLists[0], m_variables[0]);
249 m_advectionWeakDGOp->AddBndCondUpdateOp(bndCondEntropyTotalEnthalpyOp);
250
251 // An inviscid wall and a symmetry plane, which mirror the momentum, and a
252 // zeroth order extrapolation, which claims its regions so they are seeded
253 // with the interior state and then leaves them alone.
254 auto bndCondSlipWallOp = BndCondSlipWallCFEOp<double>::Create(
255 m_expansionLists[0], m_variables[0]);
256 m_advectionWeakDGOp->AddBndCondUpdateOp(bndCondSlipWallOp);
257
258 auto bndCondExtrapOrder0Op = BndCondExtrapOrder0CFEOp<double>::Create(
259 m_expansionLists[0], m_variables[0]);
260 m_advectionWeakDGOp->AddBndCondUpdateOp(bndCondExtrapOrder0Op);
261
262 // The characteristic farfield, which takes its freestream from the session
263 // parameters rather than from the region's boundary values.
264 auto bndCondRiemannInvariantOp =
266 m_variables[0]);
267 m_advectionWeakDGOp->AddBndCondUpdateOp(bndCondRiemannInvariantOp);
268
269 // And the reservoir inflow, whose session values are a stagnation state
270 // and a flow direction rather than a conserved state.
271 auto bndCondStagnationInflowOp =
273 m_variables[0]);
274 m_advectionWeakDGOp->AddBndCondUpdateOp(bndCondStagnationInflowOp);
275}
276
277/**
278 * @brief Supply the Courant estimate with the compressible wave speed.
279 *
280 * The conserved state is converted to velocity and sound speed on demand,
281 * so a run that asks for no Courant estimate builds neither the operator
282 * nor the field it writes into.
283 */
284UnsteadySystem::CFLVelocity EulerCFE::v_GetCFLVelocity()
285{
286 std::vector<std::string> components;
287 for (unsigned int i = 0; i < m_coordim; ++i)
288 {
289 components.push_back("u" + std::to_string(i));
290 }
291 components.push_back("c");
292
293 if (!m_cflVelocityOp)
294 {
295 // The kernel works in the shape dimension while the reduction reads
296 // the coordinate dimension; they part company only on a manifold,
297 // which the compressible solver does not support.
298 ASSERTL0(m_expansionLists[0]->GetExp(0)->GetShapeDimension() ==
299 m_coordim,
300 "The Courant estimate expects the shape and coordinate "
301 "dimensions to agree.");
302
303 m_cflVelocityOp =
304 CFLVelocityCFEOp<double>::Create(m_expansionLists[0], components);
305
306 auto bAtr_phys =
307 MultiRegions::GetBlockAttributes<double, FieldState::Phys>(
308 m_expansionLists[0]);
309
310 m_cflVelocity = LibUtilities::Field<double, FieldState::Phys>(
311 "cflVelocity", bAtr_phys, m_coordim + 1, m_npointsZ);
312 }
313
314 m_cflVelocityOp->Apply(m_phys[0], m_cflVelocity);
315
316 // The last component is a sound speed, so it counts in full.
317 return {&m_cflVelocity, 0, components, 1.0};
318}
319
320} // namespace Nektar
#define ASSERTL0(condition, msg)
Whole-field interface of the IProductWRTBase element operator, which takes a physical-space field to ...
Whole-field interface of the MultiplyByElmtInvMass element operator, which multiplies a coefficient-s...
Subsonic Riemann boundary holding the entropy and the pressure.
Subsonic Riemann boundary holding the entropy and the total enthalpy.
Subsonic Riemann inflow holding the entropy and the velocity.
Zeroth order extrapolation: the exterior state is the interior one.
Subsonic pressure outflow, as a boundary state.
Characteristic farfield boundary from the Riemann invariants.
Inviscid slip wall and symmetry plane.
Subsonic inflow from a stagnation state and a flow direction.
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
static std::string className
Name of class.
EulerCFE(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
A Field represents expansion data to be operated on.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Whole-field interface of the inner product with the basis: integrates a physical-space field against ...
Whole-field interface of the element-wise inverse mass operator: replaces every element's coefficient...
Common base class of the operator family interfaces: holds the expansion list, component names and da...
Definition Operator.hpp:100
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::vector< std::pair< std::string, std::string > > SummaryList
Definition Misc.h:46
EquationSystemFactory & GetEquationSystemFactory()
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
Definition Misc.cpp:46
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition MeshGraph.h:287