Nektar++
Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
Nektar::EnforceEntropyPressure Class Reference

Outflow characteristic boundary conditions for compressible flow problems. More...

#include <EnforceEntropyPressure.h>

Inheritance diagram for Nektar::EnforceEntropyPressure:
[legend]

Static Public Member Functions

static CFSBndCondSharedPtr create (const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, Array< OneD, NekDouble > > &pTraceNormals, const int pSpaceDim, const int bcRegion, const int cnt)
 Creates an instance of this class. More...
 

Static Public Attributes

static std::string className
 Name of the class. More...
 

Protected Member Functions

void v_Apply (Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray, const NekDouble &time) override
 
void GenerateRotationMatrices (const Array< OneD, const Array< OneD, NekDouble > > &normals)
 
void FromToRotation (Array< OneD, const NekDouble > &from, Array< OneD, const NekDouble > &to, NekDouble *mat)
 
SOLVER_UTILS_EXPORT void rotateToNormal (const Array< OneD, const Array< OneD, NekDouble > > &inarray, const Array< OneD, const Array< OneD, NekDouble > > &normals, const Array< OneD, const Array< OneD, NekDouble > > &vecLocs, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
SOLVER_UTILS_EXPORT void rotateFromNormal (const Array< OneD, const Array< OneD, NekDouble > > &inarray, const Array< OneD, const Array< OneD, NekDouble > > &normals, const Array< OneD, const Array< OneD, NekDouble > > &vecLocs, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
- Protected Member Functions inherited from Nektar::CFSBndCond
 CFSBndCond (const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, Array< OneD, NekDouble > > &pTraceNormals, const int pSpaceDim, const int bcRegion, const int cnt)
 Constructor. More...
 
virtual void v_Apply (Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray, const NekDouble &time)=0
 
virtual void v_ApplyBwdWeight ()
 

Protected Attributes

int m_npts
 
Array< OneD, NekDoublem_rhoBC
 
Array< OneD, Array< OneD, NekDouble > > m_velBC
 
Array< OneD, NekDoublem_pBC
 
Array< OneD, NekDoublem_VnInf
 Reference normal velocity. More...
 
Array< OneD, int > m_bndToTraceMap
 
Array< OneD, Array< OneD, NekDouble > > m_bndPhys
 
- Protected Attributes inherited from Nektar::CFSBndCond
LibUtilities::SessionReaderSharedPtr m_session
 Session reader. More...
 
Array< OneD, MultiRegions::ExpListSharedPtrm_fields
 Array of fields. More...
 
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
 Trace normals. More...
 
int m_spacedim
 Space dimension. More...
 
VariableConverterSharedPtr m_varConv
 Auxiliary object to convert variables. More...
 
NekDouble m_diffusionAveWeight
 Weight for average calculation of diffusion term. More...
 
NekDouble m_gamma
 Parameters of the flow. More...
 
NekDouble m_rhoInf
 
NekDouble m_pInf
 
NekDouble m_pOut
 
Array< OneD, NekDoublem_velInf
 
int m_bcRegion
 Id of the boundary region. More...
 
int m_offset
 Offset. More...
 

Private Member Functions

 EnforceEntropyPressure (const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, Array< OneD, NekDouble > > &pTraceNormals, const int pSpaceDim, const int bcRegion, const int cnt)
 
 ~EnforceEntropyPressure (void) override
 

Friends

class MemoryManager< EnforceEntropyPressure >
 

Additional Inherited Members

- Public Member Functions inherited from Nektar::CFSBndCond
virtual ~CFSBndCond ()
 
void Apply (Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray, const NekDouble &time=0)
 Apply the boundary condition. More...
 
void ApplyBwdWeight ()
 Apply the Weight of boundary condition. More...
 

Detailed Description

Outflow characteristic boundary conditions for compressible flow problems.

Definition at line 51 of file EnforceEntropyPressure.h.

Constructor & Destructor Documentation

◆ EnforceEntropyPressure()

Nektar::EnforceEntropyPressure::EnforceEntropyPressure ( const LibUtilities::SessionReaderSharedPtr pSession,
const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const Array< OneD, Array< OneD, NekDouble > > &  pTraceNormals,
const int  pSpaceDim,
const int  bcRegion,
const int  cnt 
)
private

Definition at line 50 of file EnforceEntropyPressure.cpp.

55 : CFSBndCond(pSession, pFields, pTraceNormals, pSpaceDim, bcRegion, cnt)
56{
57
59 m_fields[0]->GetBndCondExpansions()[m_bcRegion];
60
61 //-> Gather a list of index from trace to this boundary
62 m_npts = bndexp->GetTotPoints();
63
64 m_bndToTraceMap = Array<OneD, int>(m_npts, -1);
65
66 const Array<OneD, const int> &traceBndMap = m_fields[0]->GetTraceBndMap();
67
68 // Construct a map for the boundary to trace map for easy acess to
69 // phys space points
70 int cnt1 = 0;
71 for (int e = 0; e < bndexp->GetNumElmts(); ++e)
72 {
73 int nTracePts = bndexp->GetExp(e)->GetTotPoints();
74
75 int id =
76 m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[m_offset + e]);
77
78 // Loop on the points of the m_bcRegion
79 for (int i = 0; i < nTracePts; i++)
80 {
81 // the ith point in region e
82 m_bndToTraceMap[cnt1++] = id + i;
83 }
84 }
85
86 Array<OneD, Array<OneD, NekDouble>> BCvals(m_fields.size());
87 m_bndPhys = Array<OneD, Array<OneD, NekDouble>>(m_fields.size());
88
89 for (int i = 0; i < m_fields.size(); ++i)
90 {
91 m_bndPhys[i] =
92 m_fields[i]->GetBndCondExpansions()[m_bcRegion]->UpdatePhys();
93
94 BCvals[i] = Array<OneD, NekDouble>(m_npts);
95 Vmath::Vcopy(m_npts, m_bndPhys[i], 1, BCvals[i], 1);
96 }
97
98 // Set up boudnary required BCs
99 m_rhoBC = Array<OneD, NekDouble>(m_npts);
100 Vmath::Vcopy(m_npts, BCvals[0], 1, m_rhoBC, 1);
101
102 m_velBC = Array<OneD, Array<OneD, NekDouble>>(m_spacedim);
103 // Evaluate velocity on boundary
104 for (int i = 0; i < m_spacedim; ++i)
105 {
106 m_velBC[i] = Array<OneD, NekDouble>(m_npts);
107 Vmath::Vcopy(m_npts, BCvals[i + 1], 1, m_velBC[i], 1);
108 Vmath::Vdiv(m_npts, m_velBC[i], 1, m_rhoBC, 1, m_velBC[i], 1);
109 }
110 m_pBC = Array<OneD, NekDouble>(m_npts);
111 m_varConv->GetPressure(BCvals, m_pBC);
112
113 // Computing the normal velocity for characteristics coming
114 // from outside the computational domain
115 m_VnInf = Array<OneD, NekDouble>(m_npts, 0.0);
116 for (int i = 0; i < m_spacedim; i++)
117 {
118 for (int j = 0; j < m_npts; ++j)
119 {
120 m_VnInf[j] += m_traceNormals[i][m_bndToTraceMap[j]] * m_velBC[i][j];
121 }
122 }
123}
CFSBndCond(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, Array< OneD, NekDouble > > &pTraceNormals, const int pSpaceDim, const int bcRegion, const int cnt)
Constructor.
Definition: CFSBndCond.cpp:47
int m_spacedim
Space dimension.
Definition: CFSBndCond.h:95
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Trace normals.
Definition: CFSBndCond.h:93
int m_bcRegion
Id of the boundary region.
Definition: CFSBndCond.h:109
VariableConverterSharedPtr m_varConv
Auxiliary object to convert variables.
Definition: CFSBndCond.h:97
int m_offset
Offset.
Definition: CFSBndCond.h:111
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array of fields.
Definition: CFSBndCond.h:91
Array< OneD, Array< OneD, NekDouble > > m_velBC
Array< OneD, NekDouble > m_VnInf
Reference normal velocity.
Array< OneD, NekDouble > m_rhoBC
Array< OneD, Array< OneD, NekDouble > > m_bndPhys
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
Definition: Vmath.hpp:126
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825

References Nektar::CFSBndCond::m_bcRegion, m_bndPhys, m_bndToTraceMap, Nektar::CFSBndCond::m_fields, m_npts, Nektar::CFSBndCond::m_offset, m_pBC, m_rhoBC, Nektar::CFSBndCond::m_spacedim, Nektar::CFSBndCond::m_traceNormals, Nektar::CFSBndCond::m_varConv, m_velBC, m_VnInf, Vmath::Vcopy(), and Vmath::Vdiv().

◆ ~EnforceEntropyPressure()

Nektar::EnforceEntropyPressure::~EnforceEntropyPressure ( void  )
inlineoverrideprivate

Definition at line 118 of file EnforceEntropyPressure.h.

118{};

Member Function Documentation

◆ create()

static CFSBndCondSharedPtr Nektar::EnforceEntropyPressure::create ( const LibUtilities::SessionReaderSharedPtr pSession,
const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const Array< OneD, Array< OneD, NekDouble > > &  pTraceNormals,
const int  pSpaceDim,
const int  bcRegion,
const int  cnt 
)
inlinestatic

Creates an instance of this class.

Definition at line 57 of file EnforceEntropyPressure.h.

62 {
65 pSession, pFields, pTraceNormals, pSpaceDim, bcRegion, cnt);
66 return p;
67 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< CFSBndCond > CFSBndCondSharedPtr
A shared pointer to a boundary condition object.
Definition: CFSBndCond.h:51

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and CellMLToNektar.cellml_metadata::p.

◆ FromToRotation()

void Nektar::EnforceEntropyPressure::FromToRotation ( Array< OneD, const NekDouble > &  from,
Array< OneD, const NekDouble > &  to,
NekDouble mat 
)
protected

◆ GenerateRotationMatrices()

void Nektar::EnforceEntropyPressure::GenerateRotationMatrices ( const Array< OneD, const Array< OneD, NekDouble > > &  normals)
protected

◆ rotateFromNormal()

SOLVER_UTILS_EXPORT void Nektar::EnforceEntropyPressure::rotateFromNormal ( const Array< OneD, const Array< OneD, NekDouble > > &  inarray,
const Array< OneD, const Array< OneD, NekDouble > > &  normals,
const Array< OneD, const Array< OneD, NekDouble > > &  vecLocs,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)
protected

◆ rotateToNormal()

SOLVER_UTILS_EXPORT void Nektar::EnforceEntropyPressure::rotateToNormal ( const Array< OneD, const Array< OneD, NekDouble > > &  inarray,
const Array< OneD, const Array< OneD, NekDouble > > &  normals,
const Array< OneD, const Array< OneD, NekDouble > > &  vecLocs,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)
protected

◆ v_Apply()

void Nektar::EnforceEntropyPressure::v_Apply ( Array< OneD, Array< OneD, NekDouble > > &  Fwd,
Array< OneD, Array< OneD, NekDouble > > &  physarray,
const NekDouble time 
)
overrideprotectedvirtual

Implements Nektar::CFSBndCond.

Definition at line 125 of file EnforceEntropyPressure.cpp.

129{
130 int i, j;
131 int nDimensions = m_spacedim;
132
133 Array<OneD, Array<OneD, NekDouble>> FwdBnd(Fwd.size());
134 Array<OneD, Array<OneD, NekDouble>> bndPhys(Fwd.size());
135
136 // make a local copy of Fwd along boundary of interest
137 for (i = 0; i < Fwd.size(); ++i)
138 {
139 FwdBnd[i] = Array<OneD, NekDouble>(m_npts);
140 for (j = 0; j < m_npts; ++j)
141 {
142 FwdBnd[i][j] = Fwd[i][m_bndToTraceMap[j]];
143 }
144 }
145
146 // Computing the normal velocity for characteristics coming
147 // from inside the computational domain
148 Array<OneD, NekDouble> Vn(m_npts, 0.0);
149
150 for (i = 0; i < nDimensions; ++i)
151 {
152 for (j = 0; j < m_npts; ++j)
153 {
154 Vn[j] += m_traceNormals[i][m_bndToTraceMap[j]] * FwdBnd[i + 1][j];
155 }
156 }
157 // divide by density.
158 Vmath::Vdiv(m_npts, Vn, 1, FwdBnd[0], 1, Vn, 1);
159
160 // Get speed of sound
161 Array<OneD, NekDouble> pressure(m_npts);
162 Array<OneD, NekDouble> soundSpeed(m_npts);
163
164 m_varConv->GetPressure(FwdBnd, pressure);
165 m_varConv->GetSoundSpeed(FwdBnd, soundSpeed);
166
167 // Get Mach. Note: it is computed by Vn/c
168 Array<OneD, NekDouble> Mach(m_npts, 0.0);
169 Vmath::Vdiv(m_npts, Vn, 1, soundSpeed, 1, Mach, 1);
170 Vmath::Vabs(m_npts, Mach, 1, Mach, 1);
171
172 // Auxiliary variables
173 Array<OneD, NekDouble> velBC(nDimensions, 0.0);
174
175 // L represents properties outside boundary
176 // R represents properties inside boundary (numerical state)
177 NekDouble rhoL, uL, pL;
178 NekDouble EBC, rR, cstar, pstar, rhostar, ustar; // vn
179
180 NekDouble gamMinOne = m_gamma - 1.0;
181 NekDouble twoOverGamMinOne = 2.0 / gamMinOne;
182 NekDouble gamInv = 1.0 / m_gamma;
183
184 // Loop on m_bcRegions
185 for (int pnt = 0; pnt < m_npts; ++pnt)
186 {
187 // Impose inflow Riemann invariant
188 if (Vn[pnt] <= 0.0)
189 {
190 // Subsonic flows
191 if (Mach[pnt] < 1.00)
192 {
193 // right characteristic
194 rR = -Vn[pnt] - sqrt(m_gamma * pressure[pnt] / FwdBnd[0][pnt]) *
195 twoOverGamMinOne;
196 // vn = -m_VnInf[pnt]; //vn BC
197
198 // fix rhostar and pstar to be the input values
199 // compute ustar using left-pointing characteristic line IR^-
200 pstar = m_pBC[pnt];
201 rhostar = m_rhoBC[pnt];
202 cstar = sqrt(m_gamma * pstar / rhostar);
203 ustar = rR + cstar * twoOverGamMinOne;
204
205 // add supplement equation that rhoL=rhostar
206 // then pL=pstar, according to IL^0
207 // and uL=ustar, according to IL^+
208 rhoL = rhostar;
209 pL = pstar;
210 uL = ustar;
211
212 // std subsnoic inflow
213 // rhoL = m_rhoBC[pnt];
214 // uL = -m_VnInf[pnt];
215 // pL = m_pBC[pnt];
216 }
217 else // Supersonic inflow
218 {
219 // all characteristics are from left so just impose
220 // star state to left values
221 // Note: m_vnInf is the negative of the normal velocity
222 // across boundary
223 rhoL = m_rhoBC[pnt];
224 uL = -m_VnInf[pnt];
225 pL = m_pBC[pnt];
226 }
227
228 // Boundary energy
229 EBC = pL * twoOverGamMinOne * 0.5;
230
231 // evaluate the different between the left state normal
232 // velocity and that from the desired condition (note
233 // m_VnInf is using an outwards normal definition.
234 NekDouble VnDiff = uL + m_VnInf[pnt];
235
236 // Boundary velocities & Kinite energy
237 // Note: normals are negated since they point outwards in
238 // the domain
239
240 // Note: Can just use the BC values directly!!
241 for (j = 0; j < nDimensions; ++j)
242 {
243 // Set velocity to the desired conditions modified to
244 // take account of the normal state for Riemann
245 // problem. (Negative accounts for outwards normal definition)
246 // velBC[j] = m_velBC[j][pnt];
247 velBC[j] = m_velBC[j][pnt] -
248 VnDiff * m_traceNormals[j][m_bndToTraceMap[pnt]];
249
250 EBC += 0.5 * rhoL * velBC[j] * velBC[j];
251 }
252
253 //-------------------------------------------------------------------------
254 // Impose Left hand Riemann Invariant boundary conditions
255 m_bndPhys[0][pnt] = rhoL;
256 for (j = 0; j < nDimensions; ++j)
257 {
258 m_bndPhys[j + 1][pnt] = rhoL * velBC[j];
259 }
260 m_bndPhys[nDimensions + 1][pnt] = EBC;
261 }
262 else // Outflow
263 {
264
265 // Note: Allowing the switch can cause worse convergence in this
266 // type BC.
267 // So improve it later.
268 if (Mach[pnt] < 1.00)
269 {
270 // subsonic outflow: fix pstar
271 rR = -Vn[pnt] - sqrt(m_gamma * pressure[pnt] / FwdBnd[0][pnt]) *
272 twoOverGamMinOne;
273 // vn = -m_VnInf[pnt];
274
275 pstar = m_pBC[pnt];
276 rhostar = FwdBnd[0][pnt] * pow((pstar / pressure[pnt]), gamInv);
277 cstar = sqrt(m_gamma * pstar / rhostar);
278 ustar = rR + cstar * twoOverGamMinOne;
279
280 rhoL = rhostar;
281 uL = ustar;
282 pL = pstar;
283 }
284 else
285 {
286 // supersonic outflow
287 // Just set to imposed state and let Riemann BC dictate values
288 rhoL = m_rhoBC[pnt];
289 uL = -m_VnInf[pnt];
290 pL = m_pBC[pnt];
291 }
292
293 // Boundary energy
294 EBC = pL * twoOverGamMinOne * 0.5;
295
296 // Boundary velocities & Kinite energy
297 // Note: normals are negated since they point outwards in
298 // the domain
299 for (j = 0; j < nDimensions; ++j)
300 {
301 velBC[j] = -1.0 * uL * m_traceNormals[j][m_bndToTraceMap[pnt]];
302 EBC += 0.5 * rhoL * velBC[j] * velBC[j];
303 }
304
305 // Impose Left hand Riemann Invariant boundary conditions
306 m_bndPhys[0][pnt] = rhoL;
307 for (j = 0; j < nDimensions; ++j)
308 {
309 m_bndPhys[j + 1][pnt] = rhoL * velBC[j];
310 }
311 m_bndPhys[nDimensions + 1][pnt] = EBC;
312 }
313 }
314}
NekDouble m_gamma
Parameters of the flow.
Definition: CFSBndCond.h:102
double NekDouble
void Vabs(int n, const T *x, const int incx, T *y, const int incy)
vabs: y = |x|
Definition: Vmath.hpp:352
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294

References m_bndPhys, m_bndToTraceMap, Nektar::CFSBndCond::m_gamma, m_npts, m_pBC, m_rhoBC, Nektar::CFSBndCond::m_spacedim, Nektar::CFSBndCond::m_traceNormals, Nektar::CFSBndCond::m_varConv, m_velBC, m_VnInf, CG_Iterations::pressure, tinysimd::sqrt(), Vmath::Vabs(), and Vmath::Vdiv().

Friends And Related Function Documentation

◆ MemoryManager< EnforceEntropyPressure >

friend class MemoryManager< EnforceEntropyPressure >
friend

Definition at line 1 of file EnforceEntropyPressure.h.

Member Data Documentation

◆ className

std::string Nektar::EnforceEntropyPressure::className
static
Initial value:
=
"EnforceEntropyPressure", EnforceEntropyPressure::create,
"Riemann boundary condition enforcing entropy and pressure.")
static CFSBndCondSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, Array< OneD, NekDouble > > &pTraceNormals, const int pSpaceDim, const int bcRegion, const int cnt)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:197
CFSBndCondFactory & GetCFSBndCondFactory()
Declaration of the boundary condition factory singleton.
Definition: CFSBndCond.cpp:41

Name of the class.

Definition at line 70 of file EnforceEntropyPressure.h.

◆ m_bndPhys

Array<OneD, Array<OneD, NekDouble> > Nektar::EnforceEntropyPressure::m_bndPhys
protected

Definition at line 87 of file EnforceEntropyPressure.h.

Referenced by EnforceEntropyPressure(), and v_Apply().

◆ m_bndToTraceMap

Array<OneD, int> Nektar::EnforceEntropyPressure::m_bndToTraceMap
protected

Definition at line 83 of file EnforceEntropyPressure.h.

Referenced by EnforceEntropyPressure(), and v_Apply().

◆ m_npts

int Nektar::EnforceEntropyPressure::m_npts
protected

Definition at line 73 of file EnforceEntropyPressure.h.

Referenced by EnforceEntropyPressure(), and v_Apply().

◆ m_pBC

Array<OneD, NekDouble> Nektar::EnforceEntropyPressure::m_pBC
protected

Definition at line 79 of file EnforceEntropyPressure.h.

Referenced by EnforceEntropyPressure(), and v_Apply().

◆ m_rhoBC

Array<OneD, NekDouble> Nektar::EnforceEntropyPressure::m_rhoBC
protected

Definition at line 75 of file EnforceEntropyPressure.h.

Referenced by EnforceEntropyPressure(), and v_Apply().

◆ m_velBC

Array<OneD, Array<OneD, NekDouble> > Nektar::EnforceEntropyPressure::m_velBC
protected

Definition at line 77 of file EnforceEntropyPressure.h.

Referenced by EnforceEntropyPressure(), and v_Apply().

◆ m_VnInf

Array<OneD, NekDouble> Nektar::EnforceEntropyPressure::m_VnInf
protected

Reference normal velocity.

Definition at line 81 of file EnforceEntropyPressure.h.

Referenced by EnforceEntropyPressure(), and v_Apply().