Nektar++
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp Class Referencefinal

LinearAdvectionDiffusionReaction operator using LocalRegions implementation. More...

Inheritance diagram for Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp:
[legend]

Public Member Functions

 ~LinearAdvectionDiffusionReaction_IterPerExp () final=default
 
void operator() (const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) final
 Perform operation. More...
 
void operator() (int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) final
 
void UpdateFactors (StdRegions::FactorMap factors) override
 Check the validity of supplied constant factors. More...
 
void UpdateVarcoeffs (StdRegions::VarCoeffMap &varcoeffs) override
 Check whether necessary advection velocities are supplied and copy into local array for operator. More...
 
- Public Member Functions inherited from Nektar::Collections::Operator
 Operator (std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
 Constructor. More...
 
virtual ~Operator ()=default
 
virtual COLLECTIONS_EXPORT void operator() (const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output0, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp=NullNekDouble1DArray)=0
 Perform operation. More...
 
virtual COLLECTIONS_EXPORT void operator() (int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp=NullNekDouble1DArray)=0
 
virtual COLLECTIONS_EXPORT void UpdateFactors (StdRegions::FactorMap factors)
 Update the supplied factor map. More...
 
virtual COLLECTIONS_EXPORT void UpdateVarcoeffs (StdRegions::VarCoeffMap &varcoeffs)
 Update the supplied variable coefficients. More...
 
unsigned int GetWspSize ()
 Get the size of the required workspace. More...
 
unsigned int GetNumElmt ()
 Get number of elements. More...
 
StdRegions::StdExpansionSharedPtr GetExpSharedPtr ()
 Get expansion pointer. More...
 
unsigned int GetInputSize (bool defaultIn=true)
 
unsigned int GetOutputSize (bool defaultOut=true)
 

Protected Attributes

Array< TwoD, const NekDoublem_derivFac
 
Array< OneD, const NekDoublem_jac
 
int m_dim
 
int m_coordim
 
StdRegions::FactorMap m_factors
 
StdRegions::VarCoeffMap m_varcoeffs
 
NekDouble m_lambda
 
Array< OneD, Array< OneD, NekDouble > > m_advVel
 
const StdRegions::VarCoeffType advVelTypes [3]
 
- Protected Attributes inherited from Nektar::Collections::Operator
bool m_isDeformed
 
StdRegions::StdExpansionSharedPtr m_stdExp
 
unsigned int m_numElmt
 number of elements that the operator is applied on More...
 
unsigned int m_nqe
 
unsigned int m_wspSize
 
unsigned int m_inputSize
 number of modes or quadrature points that are passed as input to an operator More...
 
unsigned int m_outputSize
 number of modes or quadrature points that are taken as output from an operator More...
 
unsigned int m_inputSizeOther
 Number of modes or quadrature points, opposite to m_inputSize. More...
 
unsigned int m_outputSizeOther
 Number of modes or quadrature points, opposite to m_outputSize. More...
 

Private Member Functions

 LinearAdvectionDiffusionReaction_IterPerExp (vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
 
- Private Member Functions inherited from Nektar::Collections::LinearAdvectionDiffusionReaction_Helper
 LinearAdvectionDiffusionReaction_Helper ()
 

Detailed Description

LinearAdvectionDiffusionReaction operator using LocalRegions implementation.

Definition at line 224 of file LinearAdvectionDiffusionReaction.cpp.

Constructor & Destructor Documentation

◆ ~LinearAdvectionDiffusionReaction_IterPerExp()

Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::~LinearAdvectionDiffusionReaction_IterPerExp ( )
finaldefault

◆ LinearAdvectionDiffusionReaction_IterPerExp()

Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::LinearAdvectionDiffusionReaction_IterPerExp ( vector< StdRegions::StdExpansionSharedPtr pCollExp,
CoalescedGeomDataSharedPtr  pGeomData,
StdRegions::FactorMap  factors 
)
inlineprivate

Definition at line 469 of file LinearAdvectionDiffusionReaction.cpp.

472 : Operator(pCollExp, pGeomData, factors),
474 {
475 m_dim = pCollExp[0]->GetShapeDimension();
476 m_coordim = pCollExp[0]->GetCoordim();
477 int nqtot = m_stdExp->GetTotPoints();
478
479 m_derivFac = pGeomData->GetDerivFactors(pCollExp);
480 m_jac = pGeomData->GetJac(pCollExp);
481 m_wspSize = (2 * m_coordim + 1) * nqtot;
482
483 m_lambda = 1.0;
484 m_advVel = Array<OneD, Array<OneD, NekDouble>>(m_coordim);
487 this->UpdateFactors(factors);
488 }
void UpdateFactors(StdRegions::FactorMap factors) override
Check the validity of supplied constant factors.
StdRegions::StdExpansionSharedPtr m_stdExp
Definition: Operator.h:217
Operator(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
Constructor.
Definition: Operator.cpp:66
static FactorMap NullFactorMap
Definition: StdRegions.hpp:435
static VarCoeffMap NullVarCoeffMap
Definition: StdRegions.hpp:376
StdRegions::ConstFactorMap factors

References m_advVel, m_coordim, m_derivFac, m_dim, m_factors, m_jac, m_lambda, Nektar::Collections::Operator::m_stdExp, m_varcoeffs, Nektar::Collections::Operator::m_wspSize, Nektar::StdRegions::NullFactorMap, Nektar::StdRegions::NullVarCoeffMap, and UpdateFactors().

Member Function Documentation

◆ operator()() [1/2]

void Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::operator() ( const Array< OneD, const NekDouble > &  input,
Array< OneD, NekDouble > &  output0,
Array< OneD, NekDouble > &  output1,
Array< OneD, NekDouble > &  output2,
Array< OneD, NekDouble > &  wsp 
)
inlinefinalvirtual

Perform operation.

Mass term

Add advection term

Determine Laplacian term

Implements Nektar::Collections::Operator.

Definition at line 233 of file LinearAdvectionDiffusionReaction.cpp.

238 {
239 const int nCoeffs = m_stdExp->GetNcoeffs();
240 const int nPhys = m_stdExp->GetTotPoints();
241
242 ASSERTL1(input.size() >= m_numElmt * nCoeffs,
243 "input array size is insufficient");
244 ASSERTL1(output.size() >= m_numElmt * nCoeffs,
245 "output array size is insufficient");
246
247 Array<OneD, NekDouble> tmpphys, t1;
248 Array<OneD, Array<OneD, NekDouble>> dtmp(3);
249 Array<OneD, Array<OneD, NekDouble>> tmp(3);
250
251 tmpphys = wsp;
252 for (int i = 1; i < m_coordim + 1; ++i)
253 {
254 dtmp[i - 1] = wsp + i * nPhys;
255 tmp[i - 1] = wsp + (i + m_coordim) * nPhys;
256 }
257
258 for (int i = 0; i < m_numElmt; ++i)
259 {
260 // Std u
261 m_stdExp->BwdTrans(input + i * nCoeffs, tmpphys);
262
263 // Std \nabla u
264 m_stdExp->PhysDeriv(tmpphys, dtmp[0], dtmp[1], dtmp[2]);
265
266 // Transform Std \nabla u -> Local \nabla u
267 // tmp[0] = dxi1/dx du/dxi1 + dxi2/dx du/dxi2 = du / dx
268 // tmp[1] = dxi1/dy du/dxi1 + dxi2/dy du/dxi2 = du / dy
269 if (m_isDeformed)
270 {
271 for (int j = 0; j < m_coordim; ++j)
272 {
273 Vmath::Vmul(nPhys,
274 m_derivFac[j * m_dim].origin() + i * nPhys, 1,
275 &dtmp[0][0], 1, &tmp[j][0], 1);
276
277 for (int k = 1; k < m_dim; ++k)
278 {
280 nPhys,
281 m_derivFac[j * m_dim + k].origin() + i * nPhys, 1,
282 &dtmp[k][0], 1, &tmp[j][0], 1, &tmp[j][0], 1);
283 }
284 }
285 }
286 else
287 {
288 for (int j = 0; j < m_coordim; ++j)
289 {
290 Vmath::Smul(nPhys, m_derivFac[j * m_dim][i], &dtmp[0][0], 1,
291 &tmp[j][0], 1);
292
293 for (int k = 1; k < m_dim; ++k)
294 {
295 Vmath::Svtvp(nPhys, m_derivFac[j * m_dim + k][i],
296 &dtmp[k][0], 1, &tmp[j][0], 1, &tmp[j][0],
297 1);
298 }
299 }
300 }
301
302 /// Mass term
303 // tmpphys *= \lambda = \lambda u
304 Vmath::Smul(nPhys, -m_lambda, tmpphys, 1, tmpphys, 1);
305
306 /// Add advection term
307 // tmpphys += V[0] * du / dx + V[1] * du / dy
308 for (int j = 0; j < m_coordim; ++j)
309 {
310 Vmath::Vvtvp(nPhys, m_advVel[j] + i * nPhys, 1, tmp[j], 1,
311 tmpphys, 1, tmpphys, 1);
312 }
313
314 // Multiply by Jacobian for inner product
315 if (m_isDeformed)
316 {
317 Vmath::Vmul(nPhys, m_jac + i * nPhys, 1, tmpphys, 1, tmpphys,
318 1);
319 }
320 else
321 {
322 Vmath::Smul(nPhys, m_jac[i], tmpphys, 1, tmpphys, 1);
323 }
324
325 // Compute inner product wrt base
326 m_stdExp->IProductWRTBase(tmpphys, t1 = output + i * nCoeffs);
327
328 /// Determine Laplacian term
329 // add derivFactors for IProdWRTDerivBase below
330 // dtmp[0] = dxi1/dx du/dx + dxi1/dy du/dy
331 // dtmp[1] = dxi2/dx du/dx + dxi2/dy du/dy
332 if (m_isDeformed)
333 {
334 for (int j = 0; j < m_dim; ++j)
335 {
336 Vmath::Vmul(nPhys, m_derivFac[j].origin() + i * nPhys, 1,
337 &tmp[0][0], 1, &dtmp[j][0], 1);
338
339 for (int k = 1; k < m_coordim; ++k)
340 {
342 nPhys,
343 m_derivFac[j + k * m_dim].origin() + i * nPhys, 1,
344 &tmp[k][0], 1, &dtmp[j][0], 1, &dtmp[j][0], 1);
345 }
346 }
347
348 // calculate Iproduct WRT Std Deriv
349 for (int j = 0; j < m_dim; ++j)
350 {
351
352 // multiply by Jacobian
353 Vmath::Vmul(nPhys, m_jac + i * nPhys, 1, dtmp[j], 1,
354 dtmp[j], 1);
355
356 m_stdExp->IProductWRTDerivBase(j, dtmp[j], tmp[0]);
357 Vmath::Vadd(nCoeffs, tmp[0], 1, output + i * nCoeffs, 1,
358 t1 = output + i * nCoeffs, 1);
359 }
360 }
361 else
362 {
363 for (int j = 0; j < m_dim; ++j)
364 {
365 Vmath::Smul(nPhys, m_derivFac[j][i], &tmp[0][0], 1,
366 &dtmp[j][0], 1);
367
368 for (int k = 1; k < m_coordim; ++k)
369 {
370 Vmath::Svtvp(nPhys, m_derivFac[j + k * m_dim][i],
371 &tmp[k][0], 1, &dtmp[j][0], 1, &dtmp[j][0],
372 1);
373 }
374 }
375
376 // calculate Iproduct WRT Std Deriv
377 for (int j = 0; j < m_dim; ++j)
378 {
379 // multiply by Jacobian for integration
380 Vmath::Smul(nPhys, m_jac[i], dtmp[j], 1, dtmp[j], 1);
381
382 m_stdExp->IProductWRTDerivBase(j, dtmp[j], tmp[0]);
383 Vmath::Vadd(nCoeffs, tmp[0], 1, output + i * nCoeffs, 1,
384 t1 = output + i * nCoeffs, 1);
385 }
386 }
387 }
388 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
unsigned int m_numElmt
number of elements that the operator is applied on
Definition: Operator.h:219
const NekPoint< NekDouble > origin
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
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 ASSERTL1, m_advVel, m_coordim, m_derivFac, m_dim, Nektar::Collections::Operator::m_isDeformed, m_jac, m_lambda, Nektar::Collections::Operator::m_numElmt, Nektar::Collections::Operator::m_stdExp, Nektar::MovementTests::origin, Vmath::Smul(), Vmath::Svtvp(), Vmath::Vadd(), Vmath::Vmul(), and Vmath::Vvtvp().

◆ operator()() [2/2]

void Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::operator() ( int  dir,
const Array< OneD, const NekDouble > &  input,
Array< OneD, NekDouble > &  output,
Array< OneD, NekDouble > &  wsp 
)
inlinefinalvirtual

Implements Nektar::Collections::Operator.

Definition at line 390 of file LinearAdvectionDiffusionReaction.cpp.

394 {
395 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
396 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202

References Nektar::ErrorUtil::efatal, and NEKERROR.

◆ UpdateFactors()

void Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::UpdateFactors ( StdRegions::FactorMap  factors)
inlineoverridevirtual

Check the validity of supplied constant factors.

Parameters
factorsMap of factors

Reimplemented from Nektar::Collections::Operator.

Definition at line 403 of file LinearAdvectionDiffusionReaction.cpp.

404 {
406
407 // Check Lambda constant of LinearAdvectionDiffusionReaction operator
408 auto x = factors.find(StdRegions::eFactorLambda);
409 ASSERTL1(
410 x != factors.end(),
411 "Constant factor not defined: " +
412 std::string(
414 m_lambda = x->second;
415 }
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:413

References ASSERTL1, Nektar::StdRegions::ConstFactorTypeMap, Nektar::StdRegions::eFactorLambda, Nektar::VarcoeffHashingTest::factors, m_factors, and m_lambda.

Referenced by LinearAdvectionDiffusionReaction_IterPerExp().

◆ UpdateVarcoeffs()

void Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::UpdateVarcoeffs ( StdRegions::VarCoeffMap varcoeffs)
inlineoverridevirtual

Check whether necessary advection velocities are supplied and copy into local array for operator.

Parameters
varcoeffsMap of variable coefficients

Reimplemented from Nektar::Collections::Operator.

Definition at line 423 of file LinearAdvectionDiffusionReaction.cpp.

424 {
425 // Check whether any varcoeffs are provided
426 if (varcoeffs.empty())
427 {
428 return;
429 }
430
431 // Check advection velocities count
432 int ndir = 0;
433 for (auto &x : advVelTypes)
434 {
435 if (varcoeffs.count(x))
436 {
437 ndir++;
438 }
439 }
440 ASSERTL0(ndir, "Must define at least one advection velocity");
441 ASSERTL1(ndir <= m_coordim,
442 "Number of constants is larger than coordinate dimensions");
443
444 // Copy new varcoeffs
445 m_varcoeffs = varcoeffs;
446
447 // Hold advection velocity reference
448 // separate copy required for operator
449 for (int i = 0; i < m_coordim; i++)
450 {
451 m_advVel[i] = m_varcoeffs.find(advVelTypes[i])->second.GetValue();
452 }
453 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208

References advVelTypes, ASSERTL0, ASSERTL1, m_advVel, m_coordim, and m_varcoeffs.

Member Data Documentation

◆ advVelTypes

const StdRegions::VarCoeffType Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::advVelTypes[3]
protected

◆ m_advVel

Array<OneD, Array<OneD, NekDouble> > Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::m_advVel
protected

◆ m_coordim

int Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::m_coordim
protected

◆ m_derivFac

Array<TwoD, const NekDouble> Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::m_derivFac
protected

◆ m_dim

int Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::m_dim
protected

◆ m_factors

StdRegions::FactorMap Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::m_factors
protected

◆ m_jac

Array<OneD, const NekDouble> Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::m_jac
protected

◆ m_lambda

NekDouble Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::m_lambda
protected

◆ m_varcoeffs

StdRegions::VarCoeffMap Nektar::Collections::LinearAdvectionDiffusionReaction_IterPerExp::m_varcoeffs
protected