Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Nektar::MultiRegions::GJPStabilisation Class Reference

#include <GJPStabilisation.h>

Public Member Functions

 GJPStabilisation (ExpListSharedPtr field)
 
 ~GJPStabilisation ()
 
void Apply (const Array< OneD, NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const Array< OneD, NekDouble > &pUnorm=NullNekDouble1DArray, const NekDouble scale=1.0) const
 
Array< OneD, Array< OneD, NekDouble > > & GetTraceNormals (void)
 
int GetNumTracePts (void) const
 
bool IsSemiImplicit () const
 
bool IsExplicit () const
 
bool IsImplicit () const
 
Array< OneD, NekDoubleGetTraceWeightVarFactors (void)
 

Private Member Functions

void ConstructLocalTraceJump (const int dir, const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &store) const
 
void ConstructLocalTraceJumpSI (const int dir, const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &store) const
 
void IProductwrtStdDerivBaseOnTraceMat (int i, Array< OneD, NekDouble > &in, Array< OneD, NekDouble > &out) const
 
void StdDerivOnTraceFromModes (int i, Array< OneD, NekDouble > &in, Array< OneD, NekDouble > &out) const
 
void TraceJumpFromLocTraceNormDeriv (Array< OneD, NekDouble > &normderiv, Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd) const
 

Private Attributes

unsigned m_coordDim
 
unsigned m_traceDim
 
unsigned m_nLocTracePts
 
GJPFormulation m_formulation = eGJPNoFormulation
 
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
 
MultiRegions::ExpListSharedPtr m_dgfield
 DG expansion for projection evalaution along trace.
 
Array< OneD, Array< OneD, NekDouble > > m_scalTrace
 Scale factor for phys values along trace involving the local normals and geometric factors.
 
Array< OneD, NekDoublem_locTraceWeights
 
std::vector< unsigned > m_traceOffset
 phys offset in trace expannsion of each trace as we loop over elmts
 
std::vector< unsigned > m_locTracePts0
 npoints in local trace expannsion in dir 0
 
std::vector< unsigned > m_locTracePts1
 npoints in local trace expannsion in dir 1
 
std::vector< unsigned > m_ntrace
 list of the number of traces over an element;
 
std::map< int, std::pair< LocalRegions::ExpansionSharedPtr, LocalRegions::ExpansionSharedPtr > > m_interpTrace
 local trace and multiregion dg trace if different (i.e variable p and BC trace)
 
std::vector< bool > m_traceFwd
 
std::vector< std::pair< int, Array< OneD, DNekMatSharedPtr > > > m_StdDBaseOnTraceMat
 
std::vector< NekDoublem_locEdgeScale
 

Static Private Attributes

static std::string GJPStabilisationLookupIds []
 

Detailed Description

Definition at line 54 of file GJPStabilisation.h.

Constructor & Destructor Documentation

◆ GJPStabilisation()

Nektar::MultiRegions::GJPStabilisation::GJPStabilisation ( ExpListSharedPtr  field)

Definition at line 47 of file GJPStabilisation.cpp.

48{
49 LibUtilities::SessionReaderSharedPtr session = pField->GetSession();
50
51 bool test;
52
53 session->MatchSolverInfo("GJPStabilisation", "Explicit", test, false);
54 if (test)
55 {
57 }
58
59 session->MatchSolverInfo("GJPStabilisation", "Implicit", test, false);
60 if (test)
61 {
63
64 ASSERTL0(session->MatchSolverInfo("GlobalSysSoln", "IterativeFull"),
65 "To use GJP Fully implicit stabilisation you must use a "
66 "Iterative Full solver");
67 }
68
69 session->MatchSolverInfo("GJPStabilisation", "SemiImplicit", test, false);
70 if (test)
71 {
73 }
75 "Need a valid formualtion type for GradientJumpStabilisation: "
76 "Explicit, Implicit, SemiImplicit");
77
78 // Call GetTrace on the initialising field will set up
79 // DG. Store a copy so that if we make a soft copy of
80 // this class we can re-used this field for operators.
81 pField->GetTrace();
82 m_dgfield = pField;
83
84 m_coordDim = m_dgfield->GetCoordim(0);
85 m_traceDim = m_dgfield->GetShapeDimension() - 1;
86
87 // set up trace normals but would be better if could use
88 // equation system definition
89 m_traceNormals = Array<OneD, Array<OneD, NekDouble>>(m_coordDim);
90 for (int i = 0; i < m_coordDim; ++i)
91 {
93 Array<OneD, NekDouble>(m_dgfield->GetTrace()->GetNpoints());
94 }
95 m_dgfield->GetTrace()->GetNormals(m_traceNormals);
96
97 m_scalTrace = Array<OneD, Array<OneD, NekDouble>>(m_traceDim + 1);
98
99 MultiRegions::ExpListSharedPtr dgtrace = m_dgfield->GetTrace();
100
101 const std::shared_ptr<LocalRegions::ExpansionVector> exp =
102 m_dgfield->GetExp();
103
104 Array<OneD, Array<OneD, NekDouble>> dfactors[3];
105 Array<OneD, NekDouble> e_tmp;
106
107 m_nLocTracePts = 0;
108 for (unsigned e = 0; e < (*exp).size(); ++e)
109 {
110 for (unsigned t = 0; t < (*exp)[e]->GetNtraces(); ++t)
111 {
112 m_nLocTracePts += (*exp)[e]->GetLocTraceExp(t)->GetTotPoints();
113 }
114 }
115
116 m_scalTrace = Array<OneD, Array<OneD, NekDouble>>(m_traceDim + 1);
117 for (int i = 0; i < m_traceDim + 1; ++i)
118 {
119 m_scalTrace[i] = Array<OneD, NekDouble>(m_nLocTracePts);
120 }
121
122 int cnt = 0;
123 int offset_phys = 0;
124 Array<OneD, Array<OneD, Array<OneD, NekDouble>>> dbasis;
125 Array<OneD, Array<OneD, Array<OneD, unsigned int>>> traceToCoeffMap;
126
127 Array<OneD, int> sign, sign1;
128 NekDouble h, p;
129 std::map<unsigned, std::pair<NekDouble, unsigned>> hpscale;
130
132 std::dynamic_pointer_cast<MultiRegions::DisContField>(m_dgfield);
133
134 for (int e = 0; e < m_dgfield->GetExpSize(); ++e)
135 {
136 LocalRegions::ExpansionSharedPtr elmt = (*exp)[e];
137
138 elmt->NormalTraceDerivFactors(dfactors[0], dfactors[1], dfactors[2]);
139
140 for (int n = 0; n < elmt->GetNtraces(); ++n, ++cnt)
141 {
142 // collect offset for traces in dgtrace
143 unsigned eid = dgfield->GetTraceElmtId(e, n);
144 m_traceOffset.push_back(dgtrace->GetPhys_Offset(eid));
146 elmt->GetLocTraceExp(n);
147 unsigned LocTracepts = LocTraceExp->GetTotPoints();
148 if (LocTracepts != dgtrace->GetExp(eid)->GetTotPoints())
149 {
150 m_interpTrace[cnt] =
151 std::make_pair(LocTraceExp, dgtrace->GetExp(eid));
152 }
153
154 m_locTracePts0.push_back(LocTraceExp->GetNumPoints(0));
155 if (m_traceDim == 1)
156 {
157 m_locTracePts1.push_back(1);
158 }
159 else
160 {
161 m_locTracePts1.push_back(LocTraceExp->GetNumPoints(1));
162 }
163 m_traceFwd.push_back(dgfield->IsLeftAdjacentTrace(e, n));
164
165 // gather h and p average informatoin
166 elmt->TraceNormLen(n, h, p);
167 unsigned edgeid = elmt->GetTraceExp(n)->GetGeom()->GetGlobalID();
168 if (hpscale.count(edgeid))
169 {
170 auto hp = hpscale[edgeid];
171 hpscale[edgeid] = std::pair<NekDouble, unsigned>(
172 0.5 * (hp.first + h), (int)(0.5 * (hp.second + p)));
173 }
174 else
175 {
176 hpscale[edgeid] = std::pair<NekDouble, unsigned>(h, p);
177 }
178
179 int nptrace = dfactors[0][n].size();
180 for (int i = 0; i < m_traceDim + 1; ++i)
181 {
182 Vmath::Smul(nptrace, 1.0, dfactors[i][n], 1,
183 e_tmp = m_scalTrace[i] + offset_phys, 1);
184 }
185 offset_phys += nptrace;
186 }
187 m_ntrace.push_back(elmt->GetNtraces());
188 }
189 m_nLocTracePts = offset_phys;
190
191 m_locTraceWeights = Array<OneD, NekDouble>(m_nLocTracePts);
192 // set up scale factors
193 for (int e = 0; e < m_dgfield->GetExpSize(); ++e)
194 {
195 LocalRegions::ExpansionSharedPtr elmt = (*exp)[e];
196 for (int n = 0; n < elmt->GetNtraces(); ++n, ++cnt)
197 {
198 unsigned edgeid = elmt->GetTraceExp(n)->GetGeom()->GetGlobalID();
199
200 ASSERTL1(hpscale.count(edgeid), "Scale has not been defined");
201 auto hp = hpscale[edgeid];
202 NekDouble h = hp.first;
203 unsigned p = hp.second;
204 NekDouble jumpScal =
205 (p == 1) ? 0.02 * h * h : 0.8 * pow(p + 1, -4.0) * h * h;
206
207 m_locEdgeScale.push_back(jumpScal);
208 }
209 }
210
211 m_locTraceWeights = Array<OneD, NekDouble>(m_nLocTracePts, 1.0);
212
213 // Generate array of quadrature and Jacobian for loc Trace
214 unsigned offset = 0;
215 cnt = 0;
216 for (int e = 0; e < m_dgfield->GetExpSize(); ++e)
217 {
218 for (unsigned j = 0; j < m_ntrace[e]; ++j)
219 {
220 unsigned eid =
221 std::dynamic_pointer_cast<MultiRegions::DisContField>(m_dgfield)
222 ->GetTraceElmtId(e, j);
223
224 if (m_interpTrace.count(cnt)) // manage interpolated case
225 {
226 m_interpTrace[cnt].first->MultiplyByQuadratureMetric(
227 m_locTraceWeights + offset,
228 e_tmp = m_locTraceWeights + offset);
229 }
230 else
231 {
232 dgtrace->GetExp(eid)->MultiplyByQuadratureMetric(
233 m_locTraceWeights + offset,
234 e_tmp = m_locTraceWeights + offset);
235
236 // reverse data if necessary
237 m_dgfield->GetExp(e)->ReOrientTracePhysVals(
238 m_dgfield->GetExp(e)->GetTraceOrient(j), e_tmp, e_tmp,
239 m_locTracePts0[cnt], m_locTracePts1[cnt], false);
240 }
241 offset += m_locTracePts0[cnt] * m_locTracePts1[cnt];
242 cnt++;
243 }
244 }
245 // Assemble list of Matrix Product
246 Array<OneD, DNekMatSharedPtr> TraceMat;
247
248 m_dgfield->GetExp(0)->StdDerivBaseOnTraceMat(TraceMat);
249
250 int nelmt = 1;
251 Array<OneD, const LibUtilities::BasisSharedPtr> base_sav =
252 m_dgfield->GetExp(0)->GetBase();
253
254 for (int n = 1; n < m_dgfield->GetExpSize(); ++n)
255 {
256 const Array<OneD, const LibUtilities::BasisSharedPtr> &base =
257 m_dgfield->GetExp(n)->GetBase();
258
259 // check to see if same element expansion as previous matrix and if
260 // so can reused
261 int i;
262 for (i = 0; i < base.size(); ++i)
263 {
264 if (base[i] != base_sav[i])
265 {
266 break;
267 }
268 }
269
270 if (i == base.size())
271 {
272 nelmt++;
273 }
274 else
275 {
276 // save previous block of data.
277 m_StdDBaseOnTraceMat.push_back(
278 std::pair<int, Array<OneD, DNekMatSharedPtr>>(nelmt, TraceMat));
279
280 // start new block
281 m_dgfield->GetExp(n)->StdDerivBaseOnTraceMat(TraceMat);
282 nelmt = 1;
283 base_sav = m_dgfield->GetExp(n)->GetBase();
284 }
285 }
286
287 // save latest block of data.
288 m_StdDBaseOnTraceMat.push_back(
289 std::pair<int, Array<OneD, DNekMatSharedPtr>>(nelmt, TraceMat));
290}
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define sign(a, b)
return the sign(b)*a
Definition Polylib.cpp:47
std::vector< unsigned > m_locTracePts1
npoints in local trace expannsion in dir 1
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
std::vector< unsigned > m_locTracePts0
npoints in local trace expannsion in dir 0
std::vector< std::pair< int, Array< OneD, DNekMatSharedPtr > > > m_StdDBaseOnTraceMat
std::vector< unsigned > m_ntrace
list of the number of traces over an element;
std::map< int, std::pair< LocalRegions::ExpansionSharedPtr, LocalRegions::ExpansionSharedPtr > > m_interpTrace
local trace and multiregion dg trace if different (i.e variable p and BC trace)
Array< OneD, NekDouble > m_locTraceWeights
std::vector< unsigned > m_traceOffset
phys offset in trace expannsion of each trace as we loop over elmts
Array< OneD, Array< OneD, NekDouble > > m_scalTrace
Scale factor for phys values along trace involving the local normals and geometric factors.
MultiRegions::ExpListSharedPtr m_dgfield
DG expansion for projection evalaution along trace.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition Expansion.h:66
const Array< OneD, NekDouble > base(3, 0.0)
std::shared_ptr< DisContField > DisContFieldSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::vector< double > p(NPUPPER)
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition Vmath.hpp:100

References ASSERTL0, ASSERTL1, Nektar::MultiRegions::eGJPExplicit, Nektar::MultiRegions::eGJPImplicit, Nektar::MultiRegions::eGJPNoFormulation, Nektar::MultiRegions::eGJPSemiImplicit, m_coordDim, m_dgfield, m_formulation, m_interpTrace, m_locEdgeScale, m_locTracePts0, m_locTracePts1, m_locTraceWeights, m_nLocTracePts, m_ntrace, m_scalTrace, m_StdDBaseOnTraceMat, m_traceDim, m_traceFwd, m_traceNormals, m_traceOffset, sign, and Vmath::Smul().

◆ ~GJPStabilisation()

Nektar::MultiRegions::GJPStabilisation::~GJPStabilisation ( )
inline

Definition at line 59 of file GJPStabilisation.h.

59{};

Member Function Documentation

◆ Apply()

void Nektar::MultiRegions::GJPStabilisation::Apply ( const Array< OneD, NekDouble > &  inarray,
Array< OneD, NekDouble > &  outarray,
const Array< OneD, NekDouble > &  pUnorm = NullNekDouble1DArray,
const NekDouble  scale = 1.0 
) const

Definition at line 292 of file GJPStabilisation.cpp.

296{
297 int ncoeffs = m_dgfield->GetNcoeffs();
298 int nTracePts = m_dgfield->GetTrace()->GetTotPoints();
299 LibUtilities::Timer timer, timer1;
300 timer.Start();
301 timer1.Start();
302
303 Array<OneD, NekDouble> FilterCoeffs(ncoeffs), CoeffsTmp(ncoeffs);
304 Array<OneD, NekDouble> Fwd(nTracePts, 0.0), Bwd(nTracePts, 0.0);
305 Array<OneD, NekDouble> Store(m_nLocTracePts);
306 Array<OneD, NekDouble> unorm;
307
308 if (pUnorm == NullNekDouble1DArray)
309 {
310 unorm = Array<OneD, NekDouble>(nTracePts, 1.0);
311 }
312 else
313 {
314 unorm = pUnorm;
315 }
316
317 Array<OneD, NekDouble> dudn(m_nLocTracePts, 0.0);
318
319 timer1.Stop();
320 timer1.AccumulateRegion("GJP:Init", 10);
321 timer1.Start();
322
323 // Fwd Trans
324 m_dgfield->FwdTransLocalElmt(inarray, FilterCoeffs);
325
326 // Construct local derivaitves on trace
327 for (int n = 0; n < m_coordDim; ++n)
328 {
329 StdDerivOnTraceFromModes(n, FilterCoeffs, Store);
330 Vmath::Vvtvp(m_nLocTracePts, Store, 1, m_scalTrace[n], 1, dudn, 1, dudn,
331 1);
332 }
333
334 timer1.Stop();
335 timer1.AccumulateRegion("GJP:FwdTrans + StdDerivFromModes", 10);
336 timer1.Start();
337
339 {
340 // want to put Fwd vals on bwd trace and vice versa
341 TraceJumpFromLocTraceNormDeriv(dudn, Bwd, Fwd);
342 }
343 else
344 {
345 TraceJumpFromLocTraceNormDeriv(dudn, Fwd, Bwd);
346 Vmath::Vadd(nTracePts, Fwd, 1, Bwd, 1, Fwd, 1);
347 }
348 timer1.Stop();
349 timer1.AccumulateRegion("GJP:TransJumpFromLocDeriv", 10);
350 timer1.Start();
351
353 {
354 Vmath::Vmul(nTracePts, unorm, 1, Fwd, 1, Fwd, 1);
355 Vmath::Vmul(nTracePts, unorm, 1, Bwd, 1, Bwd, 1);
356 // Evaluate trace inner product with respect to derivative of the
357 // basis
358 ConstructLocalTraceJumpSI(0, Fwd, Bwd, Store);
359 timer1.Stop();
360 timer1.AccumulateRegion("GJP:Construct Trace ", 10);
361 timer1.Start();
362 IProductwrtStdDerivBaseOnTraceMat(0, Store, FilterCoeffs);
363 timer1.Stop();
364 timer1.AccumulateRegion("GJP:Deriv on Trace", 10);
365
366 timer1.Start();
367
368 for (int i = 0; i < m_traceDim; ++i)
369 {
370 ConstructLocalTraceJumpSI(i + 1, Fwd, Bwd, Store);
371 timer1.Stop();
372 timer1.AccumulateRegion("GJP:Construct Trace ", 10);
373
374 timer1.Start();
375 IProductwrtStdDerivBaseOnTraceMat(i + 1, Store, CoeffsTmp);
376 timer1.Stop();
377 timer1.AccumulateRegion("GJP:Deriv on Trace", 10);
378
379 timer1.Start();
380 Vmath::Vadd(ncoeffs, CoeffsTmp, 1, FilterCoeffs, 1, FilterCoeffs,
381 1);
382 }
383 }
384 else
385 {
386 Vmath::Vmul(nTracePts, unorm, 1, Fwd, 1, Fwd, 1);
387
388 // Evaluate trace inner product with respect to derivitive of the
389 // basis
390 ConstructLocalTraceJump(0, Fwd, Store);
391 IProductwrtStdDerivBaseOnTraceMat(0, Store, FilterCoeffs);
392
393 for (int i = 0; i < m_traceDim; ++i)
394 {
395 ConstructLocalTraceJump(i + 1, Fwd, Store);
396 IProductwrtStdDerivBaseOnTraceMat(i + 1, Store, CoeffsTmp);
397 Vmath::Vadd(ncoeffs, CoeffsTmp, 1, FilterCoeffs, 1, FilterCoeffs,
398 1);
399 }
400 }
401
402 Vmath::Svtvp(ncoeffs, scale, FilterCoeffs, 1, outarray, 1, outarray, 1);
403 timer.Stop();
404 // Elapsed time
405 timer.AccumulateRegion("GJP:Total", 10);
406}
void StdDerivOnTraceFromModes(int i, Array< OneD, NekDouble > &in, Array< OneD, NekDouble > &out) const
void ConstructLocalTraceJump(const int dir, const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &store) const
void TraceJumpFromLocTraceNormDeriv(Array< OneD, NekDouble > &normderiv, Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd) const
void IProductwrtStdDerivBaseOnTraceMat(int i, Array< OneD, NekDouble > &in, Array< OneD, NekDouble > &out) const
void ConstructLocalTraceJumpSI(const int dir, const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &store) const
static Array< OneD, NekDouble > NullNekDouble1DArray
void Vmul(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:72
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvp (scalar times vector plus vector): z = alpha*x + y.
Definition Vmath.hpp:396
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition Vmath.hpp:366
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition Vmath.hpp:180

References Nektar::LibUtilities::Timer::AccumulateRegion(), ConstructLocalTraceJump(), ConstructLocalTraceJumpSI(), Nektar::MultiRegions::eGJPSemiImplicit, IProductwrtStdDerivBaseOnTraceMat(), m_coordDim, m_dgfield, m_formulation, m_nLocTracePts, m_scalTrace, m_traceDim, Nektar::NullNekDouble1DArray, Nektar::LibUtilities::Timer::Start(), StdDerivOnTraceFromModes(), Nektar::LibUtilities::Timer::Stop(), Vmath::Svtvp(), TraceJumpFromLocTraceNormDeriv(), Vmath::Vadd(), Vmath::Vmul(), and Vmath::Vvtvp().

◆ ConstructLocalTraceJump()

void Nektar::MultiRegions::GJPStabilisation::ConstructLocalTraceJump ( const int  dir,
const Array< OneD, const NekDouble > &  in,
Array< OneD, NekDouble > &  store 
) const
private

construct the gradient jump on local trace using input 'in' which is in trace orientation

Definition at line 412 of file GJPStabilisation.cpp.

415{
416 LibUtilities::Timer timer;
417 unsigned offset = 0;
418 unsigned cnt = 0;
419 Array<OneD, NekDouble> tmp;
420
421 for (unsigned e = 0; e < m_dgfield->GetExpSize(); ++e)
422 {
423 for (unsigned j = 0; j < m_ntrace[e]; ++j)
424 {
425 unsigned locTracePts = m_locTracePts0[cnt] * m_locTracePts1[cnt];
426
427 NekDouble jumpScal = m_locEdgeScale[cnt];
428
429 if (m_interpTrace.count(cnt)) // variable p and BCs
430 {
431 auto it = m_interpTrace.find(cnt);
432
434 m_dgfield->GetExp(e)->GetTraceOrient(j);
435
436 // interpolate to new space
437 it->second.first->PhysInterp(
438 it->second.second, in + m_traceOffset[cnt],
439 tmp = store + offset,
441
442 // reorientate
443 m_dgfield->GetExp(e)->ReOrientTracePhysVals(
444 orient, tmp, tmp, m_locTracePts0[cnt], m_locTracePts1[cnt],
445 false);
446 }
447 else
448 {
449 tmp = store + offset;
450 timer.Start();
451 // Reverse data if necessary - using mapping from trace to local
452 // trace
453 m_dgfield->GetExp(e)->ReOrientTracePhysVals(
454 m_dgfield->GetExp(e)->GetTraceOrient(j),
455 in + m_traceOffset[cnt], tmp, m_locTracePts0[cnt],
456 m_locTracePts1[cnt], false);
457 timer.Stop();
458 timer.AccumulateRegion("GJPStab::Construct Trace:: Reorient",
459 10);
460 }
461
462 // multiply by local factors in local trace space
463 for (unsigned i = 0; i < locTracePts; ++i)
464 {
465 tmp[i] *= jumpScal * m_scalTrace[dir][offset + i] *
466 m_locTraceWeights[offset + i];
467 }
468
469 offset += locTracePts;
470 cnt++;
471 }
472 }
473}

References Nektar::LibUtilities::Timer::AccumulateRegion(), Nektar::StdRegions::eDir1FwdDir2_Dir2FwdDir1, m_dgfield, m_interpTrace, m_locEdgeScale, m_locTracePts0, m_locTracePts1, m_locTraceWeights, m_ntrace, m_scalTrace, m_traceOffset, Nektar::LibUtilities::Timer::Start(), and Nektar::LibUtilities::Timer::Stop().

Referenced by Apply().

◆ ConstructLocalTraceJumpSI()

void Nektar::MultiRegions::GJPStabilisation::ConstructLocalTraceJumpSI ( const int  dir,
const Array< OneD, const NekDouble > &  Fwd,
const Array< OneD, const NekDouble > &  Bwd,
Array< OneD, NekDouble > &  store 
) const
private

Definition at line 475 of file GJPStabilisation.cpp.

479{
480 unsigned offset = 0;
481 unsigned cnt = 0;
482 Array<OneD, NekDouble> tmp;
483 LibUtilities::Timer timer;
484
485 for (unsigned e = 0; e < m_dgfield->GetExpSize(); ++e)
486 {
487 for (unsigned j = 0; j < m_ntrace[e]; ++j)
488 {
489 unsigned locTracePts = m_locTracePts0[cnt] * m_locTracePts1[cnt];
490
491 NekDouble jumpScal = m_locEdgeScale[cnt];
492
493 if (m_traceFwd[cnt])
494 {
495 if (m_interpTrace.count(cnt)) // variable p and BCs
496 {
497 auto it = m_interpTrace.find(cnt);
498
500 m_dgfield->GetExp(e)->GetTraceOrient(j);
501
502 // interpolate to new space
503 it->second.first->PhysInterp(
504 it->second.second, Fwd + m_traceOffset[cnt],
505 tmp = store + offset,
507
508 // reorientate
509 m_dgfield->GetExp(e)->ReOrientTracePhysVals(
510 orient, tmp, tmp, m_locTracePts0[cnt],
511 m_locTracePts1[cnt], false);
512 }
513 else
514 {
515 // Reverse data if necessary - using mapping from trace to
516 // local trace
517 timer.Start();
518 m_dgfield->GetExp(e)->ReOrientTracePhysVals(
519 m_dgfield->GetExp(e)->GetTraceOrient(j),
520 Fwd + m_traceOffset[cnt], tmp = store + offset,
521 m_locTracePts0[cnt], m_locTracePts1[cnt], false);
522 timer.Stop();
523 timer.AccumulateRegion(
524 "GJPStab::Construct Trace:: Reorient", 10);
525 }
526 }
527 else
528 {
529 if (m_interpTrace.count(cnt)) // variable p and BCs
530 {
531 auto it = m_interpTrace.find(cnt);
532
534 m_dgfield->GetExp(e)->GetTraceOrient(j);
535
536 // interpolate to new space
537 it->second.first->PhysInterp(
538 it->second.second, Fwd + m_traceOffset[cnt],
539 tmp = store + offset,
541
542 // reorientate
543 m_dgfield->GetExp(e)->ReOrientTracePhysVals(
544 orient, tmp, tmp, m_locTracePts0[cnt],
545 m_locTracePts1[cnt], false);
546 }
547 else
548 {
549 // Reverse data if necessary - using mapping from trace to
550 // local trace
551 timer.Start();
552 m_dgfield->GetExp(e)->ReOrientTracePhysVals(
553 m_dgfield->GetExp(e)->GetTraceOrient(j),
554 Bwd + m_traceOffset[cnt], tmp = store + offset,
555 m_locTracePts0[cnt], m_locTracePts1[cnt], false);
556 timer.Stop();
557 timer.AccumulateRegion(
558 "GJPStab::Construct Trace:: Reorient", 10);
559 }
560 }
561 // multiply by local factors in local trace space
562 for (unsigned i = 0; i < locTracePts; ++i)
563 {
564 tmp[i] *= jumpScal * m_scalTrace[dir][offset + i] *
565 m_locTraceWeights[offset + i];
566 }
567
568 offset += locTracePts;
569 cnt++;
570 }
571 }
572 ASSERTL1(offset <= 2 * m_dgfield->GetTrace()->GetTotPoints(),
573 "Stroage is not large enough");
574}

References Nektar::LibUtilities::Timer::AccumulateRegion(), ASSERTL1, Nektar::StdRegions::eDir1FwdDir2_Dir2FwdDir1, m_dgfield, m_interpTrace, m_locEdgeScale, m_locTracePts0, m_locTracePts1, m_locTraceWeights, m_ntrace, m_scalTrace, m_traceFwd, m_traceOffset, Nektar::LibUtilities::Timer::Start(), and Nektar::LibUtilities::Timer::Stop().

Referenced by Apply().

◆ GetNumTracePts()

int Nektar::MultiRegions::GJPStabilisation::GetNumTracePts ( void  ) const
inline

Definition at line 71 of file GJPStabilisation.h.

72 {
73 return m_dgfield->GetTrace()->GetTotPoints();
74 }

References m_dgfield.

◆ GetTraceNormals()

Array< OneD, Array< OneD, NekDouble > > & Nektar::MultiRegions::GJPStabilisation::GetTraceNormals ( void  )
inline

Definition at line 66 of file GJPStabilisation.h.

67 {
68 return m_traceNormals;
69 }

References m_traceNormals.

◆ GetTraceWeightVarFactors()

Array< OneD, NekDouble > Nektar::MultiRegions::GJPStabilisation::GetTraceWeightVarFactors ( void  )

Definition at line 673 of file GJPStabilisation.cpp.

674{
675
676 Array<OneD, NekDouble> returnval(m_dgfield->GetNumElmts() * 6, 0.0);
677
678 unsigned cnt = 0;
679 for (unsigned e = 0; e < m_dgfield->GetExpSize(); ++e)
680 {
681 for (unsigned n = 0; n < m_dgfield->GetExp(e)->GetNtraces(); ++n)
682 {
683 returnval[6 * e + n] = m_locEdgeScale[cnt++];
684 }
685 }
686 return returnval;
687}

References m_dgfield, and m_locEdgeScale.

◆ IProductwrtStdDerivBaseOnTraceMat()

void Nektar::MultiRegions::GJPStabilisation::IProductwrtStdDerivBaseOnTraceMat ( int  i,
Array< OneD, NekDouble > &  in,
Array< OneD, NekDouble > &  out 
) const
private

Definition at line 579 of file GJPStabilisation.cpp.

581{
582 unsigned cnt = 0;
583 unsigned cnt1 = 0;
584
585 for (auto &it : m_StdDBaseOnTraceMat)
586 {
587 unsigned modes = it.second[dir]->GetRows();
588 unsigned tracepts = it.second[dir]->GetColumns();
589
590 Blas::Dgemm('N', 'N', modes, it.first, tracepts, 1.0,
591 &(it.second[dir]->GetPtr())[0], modes, &in[0] + cnt,
592 tracepts, 0.0, &out[0] + cnt1, modes);
593
594 cnt += tracepts * it.first;
595 cnt1 += modes * it.first;
596 }
597}
static void Dgemm(const char &transa, const char &transb, const int &m, const int &n, const int &k, const double &alpha, const double *a, const int &lda, const double *b, const int &ldb, const double &beta, double *c, const int &ldc)
BLAS level 3: Matrix-matrix multiply C = A x B where op(A)[m x k], op(B)[k x n], C[m x n] DGEMM perfo...
Definition Blas.hpp:324

References Blas::Dgemm(), and m_StdDBaseOnTraceMat.

Referenced by Apply().

◆ IsExplicit()

bool Nektar::MultiRegions::GJPStabilisation::IsExplicit ( ) const
inline

Definition at line 81 of file GJPStabilisation.h.

82 {
83 return (m_formulation == eGJPExplicit);
84 }

References Nektar::MultiRegions::eGJPExplicit, and m_formulation.

◆ IsImplicit()

bool Nektar::MultiRegions::GJPStabilisation::IsImplicit ( ) const
inline

Definition at line 86 of file GJPStabilisation.h.

87 {
88 return (m_formulation == eGJPImplicit);
89 }

References Nektar::MultiRegions::eGJPImplicit, and m_formulation.

◆ IsSemiImplicit()

bool Nektar::MultiRegions::GJPStabilisation::IsSemiImplicit ( ) const
inline

Definition at line 76 of file GJPStabilisation.h.

77 {
79 }

References Nektar::MultiRegions::eGJPSemiImplicit, and m_formulation.

◆ StdDerivOnTraceFromModes()

void Nektar::MultiRegions::GJPStabilisation::StdDerivOnTraceFromModes ( int  i,
Array< OneD, NekDouble > &  in,
Array< OneD, NekDouble > &  out 
) const
private

Definition at line 653 of file GJPStabilisation.cpp.

655{
656 unsigned cnt = 0;
657 unsigned cnt1 = 0;
658
659 for (auto &it : m_StdDBaseOnTraceMat)
660 {
661 unsigned modes = it.second[dir]->GetRows();
662 unsigned tracepts = it.second[dir]->GetColumns();
663
664 Blas::Dgemm('T', 'N', tracepts, it.first, modes, 1.0,
665 &(it.second[dir]->GetPtr())[0], modes, &in[0] + cnt, modes,
666 0.0, &out[0] + cnt1, tracepts);
667
668 cnt += modes * it.first;
669 cnt1 += tracepts * it.first;
670 }
671}

References Blas::Dgemm(), and m_StdDBaseOnTraceMat.

Referenced by Apply().

◆ TraceJumpFromLocTraceNormDeriv()

void Nektar::MultiRegions::GJPStabilisation::TraceJumpFromLocTraceNormDeriv ( Array< OneD, NekDouble > &  normderiv,
Array< OneD, NekDouble > &  Fwd,
Array< OneD, NekDouble > &  Bwd 
) const
private

Definition at line 599 of file GJPStabilisation.cpp.

602{
603 unsigned offset = 0;
604 unsigned cnt = 0;
605 Array<OneD, NekDouble> tmp, tmp1;
606
607 for (unsigned e = 0; e < m_dgfield->GetExpSize(); ++e)
608 {
609 for (unsigned j = 0; j < m_ntrace[e]; ++j)
610 {
611 unsigned locTracePts = m_locTracePts0[cnt] * m_locTracePts1[cnt];
612
613 tmp = normderiv + offset;
614 ASSERTL0(offset < normderiv.size(), "Issue");
615 // Reverse data if necessary
616 m_dgfield->GetExp(e)->ReOrientTracePhysVals(
617 m_dgfield->GetExp(e)->GetTraceOrient(j), tmp, tmp,
618 m_locTracePts0[cnt], m_locTracePts1[cnt]);
619
620 if (m_traceFwd[cnt])
621 {
622 tmp1 = Fwd + m_traceOffset[cnt];
623 }
624 else
625 {
626 tmp1 = Bwd + m_traceOffset[cnt];
627 }
628
629 if (m_interpTrace.count(cnt)) // variable p and BCs
630 {
631 auto it = m_interpTrace.find(cnt);
632 it->second.second->PhysInterp(it->second.first, tmp, tmp1);
633 }
634 else
635 {
636 Vmath::Vcopy(locTracePts, tmp, 1, tmp1, 1);
637 }
638
639 offset += locTracePts;
640 cnt++;
641 }
642 }
643
644 // globally assemble Fwd and Bwd traces;
645 m_dgfield->PeriodicBwdCopy(Fwd, Bwd);
646 m_dgfield->FillBwdWithBoundCond(Fwd, Bwd, true);
647 m_dgfield->GetTraceMap()->GetAssemblyCommDG()->PerformExchange(Fwd, Bwd);
648}
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition Vmath.hpp:825

References ASSERTL0, m_dgfield, m_interpTrace, m_locTracePts0, m_locTracePts1, m_ntrace, m_traceFwd, m_traceOffset, and Vmath::Vcopy().

Referenced by Apply().

Member Data Documentation

◆ GJPStabilisationLookupIds

std::string Nektar::MultiRegions::GJPStabilisation::GJPStabilisationLookupIds
staticprivate
Initial value:
= {
"GJPStabilisation", "Explicit", eExplicitGJPStabilisation),
"GJPStabilisation", "SemiImplicit", eSemiImplicitGJPStabilisation),
"GJPStabilisation", "Implicit", eFullImplicitGJPStabilisation),
}
static std::string RegisterEnumValue(std::string pEnum, std::string pString, int pEnumValue)
Registers an enumeration value.

Definition at line 98 of file GJPStabilisation.h.

◆ m_coordDim

unsigned Nektar::MultiRegions::GJPStabilisation::m_coordDim
private

Definition at line 94 of file GJPStabilisation.h.

Referenced by Apply(), and GJPStabilisation().

◆ m_dgfield

MultiRegions::ExpListSharedPtr Nektar::MultiRegions::GJPStabilisation::m_dgfield
private

DG expansion for projection evalaution along trace.

Definition at line 104 of file GJPStabilisation.h.

Referenced by Apply(), ConstructLocalTraceJump(), ConstructLocalTraceJumpSI(), GetNumTracePts(), GetTraceWeightVarFactors(), GJPStabilisation(), and TraceJumpFromLocTraceNormDeriv().

◆ m_formulation

GJPFormulation Nektar::MultiRegions::GJPStabilisation::m_formulation = eGJPNoFormulation
private

Definition at line 97 of file GJPStabilisation.h.

Referenced by Apply(), GJPStabilisation(), IsExplicit(), IsImplicit(), and IsSemiImplicit().

◆ m_interpTrace

std::map<int, std::pair<LocalRegions::ExpansionSharedPtr, LocalRegions::ExpansionSharedPtr> > Nektar::MultiRegions::GJPStabilisation::m_interpTrace
private

local trace and multiregion dg trace if different (i.e variable p and BC trace)

Definition at line 124 of file GJPStabilisation.h.

Referenced by ConstructLocalTraceJump(), ConstructLocalTraceJumpSI(), GJPStabilisation(), and TraceJumpFromLocTraceNormDeriv().

◆ m_locEdgeScale

std::vector<NekDouble> Nektar::MultiRegions::GJPStabilisation::m_locEdgeScale
private

◆ m_locTracePts0

std::vector<unsigned> Nektar::MultiRegions::GJPStabilisation::m_locTracePts0
private

npoints in local trace expannsion in dir 0

Definition at line 115 of file GJPStabilisation.h.

Referenced by ConstructLocalTraceJump(), ConstructLocalTraceJumpSI(), GJPStabilisation(), and TraceJumpFromLocTraceNormDeriv().

◆ m_locTracePts1

std::vector<unsigned> Nektar::MultiRegions::GJPStabilisation::m_locTracePts1
private

npoints in local trace expannsion in dir 1

Definition at line 117 of file GJPStabilisation.h.

Referenced by ConstructLocalTraceJump(), ConstructLocalTraceJumpSI(), GJPStabilisation(), and TraceJumpFromLocTraceNormDeriv().

◆ m_locTraceWeights

Array<OneD, NekDouble> Nektar::MultiRegions::GJPStabilisation::m_locTraceWeights
private

◆ m_nLocTracePts

unsigned Nektar::MultiRegions::GJPStabilisation::m_nLocTracePts
private

Definition at line 96 of file GJPStabilisation.h.

Referenced by Apply(), and GJPStabilisation().

◆ m_ntrace

std::vector<unsigned> Nektar::MultiRegions::GJPStabilisation::m_ntrace
private

list of the number of traces over an element;

Definition at line 119 of file GJPStabilisation.h.

Referenced by ConstructLocalTraceJump(), ConstructLocalTraceJumpSI(), GJPStabilisation(), and TraceJumpFromLocTraceNormDeriv().

◆ m_scalTrace

Array<OneD, Array<OneD, NekDouble> > Nektar::MultiRegions::GJPStabilisation::m_scalTrace
private

Scale factor for phys values along trace involving the local normals and geometric factors.

Definition at line 108 of file GJPStabilisation.h.

Referenced by Apply(), ConstructLocalTraceJump(), ConstructLocalTraceJumpSI(), and GJPStabilisation().

◆ m_StdDBaseOnTraceMat

std::vector<std::pair<int, Array<OneD, DNekMatSharedPtr> > > Nektar::MultiRegions::GJPStabilisation::m_StdDBaseOnTraceMat
private

◆ m_traceDim

unsigned Nektar::MultiRegions::GJPStabilisation::m_traceDim
private

Definition at line 95 of file GJPStabilisation.h.

Referenced by Apply(), and GJPStabilisation().

◆ m_traceFwd

std::vector<bool> Nektar::MultiRegions::GJPStabilisation::m_traceFwd
private

◆ m_traceNormals

Array<OneD, Array<OneD, NekDouble> > Nektar::MultiRegions::GJPStabilisation::m_traceNormals
private

Definition at line 101 of file GJPStabilisation.h.

Referenced by GetTraceNormals(), and GJPStabilisation().

◆ m_traceOffset

std::vector<unsigned> Nektar::MultiRegions::GJPStabilisation::m_traceOffset
private

phys offset in trace expannsion of each trace as we loop over elmts

Definition at line 113 of file GJPStabilisation.h.

Referenced by ConstructLocalTraceJump(), ConstructLocalTraceJumpSI(), GJPStabilisation(), and TraceJumpFromLocTraceNormDeriv().