MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
dgcartesianbcacousticperturbstraightductexit.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef DGBOUNDARYCONDITIONSTRAIGHTDUCTEXIT_H_
8#define DGBOUNDARYCONDITIONSTRAIGHTDUCTEXIT_H_
9
12
13/* \brief Outlet of a straight duct in a solid wall (2D).
14 *
15 * The extend of the duct is determined by the property ductPosition.
16 * It gives the interval on the boundary where the boundary condition is
17 * applied, the remaining part of this boundary is treated as a solid wall.
18 */
19template <MInt nDim, class SysEqn>
20class DgBcAcousticPerturbStraightDuctExit final : public DgBoundaryCondition<nDim, SysEqn> {
21 // Typedefs
22 public:
24 using Base::begin;
25 using Base::end;
26 using Base::flux;
27 using Base::solver;
28 using Base::surfaces;
29 using Base::sysEqn;
30 using typename Base::SolverType;
31
32 // Methods
33 DgBcAcousticPerturbStraightDuctExit(SolverType& solver_, MInt bcId) : Base(solver_, bcId), m_wallBc(solver_, bcId) {}
34 MString name() const override { return "Straight duct"; }
35
36 void init() override;
37
38 void apply(const MFloat time) override {
40 }
41
42 void applyAtSurface(const MInt surfaceId, const MFloat time);
43
44 private:
45 // Wall boundary condition
47
48 // Position of duct exit: interval [p1,p2]
50};
51
52/* \brief Initialize boundary condition.
53 *
54 * Reads the property ductPosition which determines the position of the duct
55 * exit.
56 */
57template <MInt nDim, class SysEqn>
59 // Check that this boundary condition is not accidentally used in 3D
60 IF_CONSTEXPR(nDim != 2) { TERMM(1, "This boundary condition is only usable for 2D simulations"); }
61
74 for(MInt i = 0; i < 2; i++) {
75 m_ductPosition[i] = Context::getSolverProperty<MFloat>("ductPosition", solver().solverId(), AT_, i);
76 }
77}
78
79
80template <MInt nDim, class SysEqn>
82 const MFloat* const coordinates = &surfaces().coords(surfaceId, 0);
83 const MInt sOrientation = surfaces().orientation(surfaceId);
84
85 const MFloat pos = coordinates[(sOrientation + 1) % 2];
86 const MFloat lb = m_ductPosition[0];
87 const MFloat ub = m_ductPosition[1];
88
89 // Check position of surface center
90 if(lb > pos || pos > ub) {
91 // Apply wall boundary condition
92 m_wallBc.applyAtSurface(surfaceId, time);
93 } else {
94 // Calculate flux with the inner state of a surface and boundary state
95 const MInt noNodes1D = surfaces().noNodes1D(surfaceId);
96
97 const MFloat* surfaceStateL = &surfaces().variables(surfaceId, 0);
98 const MFloat* surfaceStateR = &surfaces().variables(surfaceId, 1);
99 const MFloat* outerState = (surfaces().nghbrElementIds(surfaceId, 0) == -1) ? surfaceStateL : surfaceStateR;
100 MFloatTensor oS(const_cast<MFloat*>(outerState), noNodes1D, SysEqn::noVars());
101
102 // Check the orientation of the Duct-exit and set the outer state
103 if(sOrientation == 1) {
104 for(MInt n = 0; n < noNodes1D; n++) {
105 // for y-orientation x-velocity is zero
106 oS(n, 0) = 0.0;
107 oS(n, 1) = sin(2 * PI * time);
108 oS(n, 2) = sin(2 * PI * time);
109 }
110 } else {
111 for(MInt n = 0.0; n < noNodes1D; n++) {
112 // for x orientation y-velocity is zero
113 oS(n, 0) = sin(2 * PI * time);
114 oS(n, 1) = 0;
115 oS(n, 2) = sin(2 * PI * time);
116 }
117 }
118
119 // Call regular Riemann solver
120 const MFloat* nodeVarsL = &surfaces().nodeVars(surfaceId, 0);
121 const MFloat* nodeVarsR = &surfaces().nodeVars(surfaceId, 1);
122 const MFloat* innerNodeVars = (surfaces().nghbrElementIds(surfaceId, 0) == -1) ? nodeVarsR : nodeVarsL;
123 sysEqn().calcRiemann(innerNodeVars, innerNodeVars, surfaceStateL, surfaceStateR, noNodes1D, sOrientation,
124 flux(surfaceId));
125 }
126}
127
128#endif // DGBOUNDARYCONDITIONSTRAIGHTDUCTEXIT_H_
Solid (slip) wall boundary condition.
void applyAtSurface(const MInt surfaceId, const MFloat time)
void apply(const MFloat time) override
Apply method to apply boundary condition.
MString name() const override
Returns name of boundary condition.
DgBcAcousticPerturbSolidWall< nDim, SysEqn > m_wallBc
SurfaceCollector & surfaces()
Return reference to surfaces.
DgCartesianSolver< nDim, SysEqn > SolverType
SysEqn & sysEqn()
Return reference to SysEqn object.
SolverType & solver()
Return reference to solver.
MInt begin() const
Return index of first surface.
MInt end() const
Return index of one-past-last surface.
MFloat * flux(const MInt i)
Return pointer to surface flux.
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
void loop(Functor &&fun, Class *object, const IdType begin, const IdType end, Args... args)