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

Helmholtz operator using LocalRegions implementation. More...

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

Public Member Functions

 ~Helmholtz_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 the validity of supplied variable coefficients. Note that the m_varcoeffs are not implemented for the IterPerExp operator. There exists a specialised implementation for variable diffusion in the above function UpdateFactors. 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
 
bool m_HasVarCoeffDiff
 
Array< OneD, Array< OneD, NekDouble > > m_diff
 
const StdRegions::ConstFactorType m_factorCoeffDef [3][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

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

Detailed Description

Helmholtz operator using LocalRegions implementation.

Definition at line 191 of file library/Collections/Helmholtz.cpp.

Constructor & Destructor Documentation

◆ ~Helmholtz_IterPerExp()

Nektar::Collections::Helmholtz_IterPerExp::~Helmholtz_IterPerExp ( )
finaldefault

◆ Helmholtz_IterPerExp()

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

Definition at line 528 of file library/Collections/Helmholtz.cpp.

531 : Operator(pCollExp, pGeomData, factors), Helmholtz_Helper()
532 {
533 m_dim = pCollExp[0]->GetShapeDimension();
534 m_coordim = pCollExp[0]->GetCoordim();
535 int nqtot = m_stdExp->GetTotPoints();
536
537 m_derivFac = pGeomData->GetDerivFactors(pCollExp);
538 m_jac = pGeomData->GetJac(pCollExp);
539 m_wspSize = (2 * m_coordim + 1) * nqtot;
540
541 m_lambda = 1.0;
542 m_HasVarCoeffDiff = false;
545 this->UpdateFactors(factors);
546 }
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_coordim, m_derivFac, m_dim, m_factors, m_HasVarCoeffDiff, 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::Helmholtz_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.

Implements Nektar::Collections::Operator.

Definition at line 198 of file library/Collections/Helmholtz.cpp.

203 {
204 const int nCoeffs = m_stdExp->GetNcoeffs();
205 const int nPhys = m_stdExp->GetTotPoints();
206
207 ASSERTL1(input.size() >= m_numElmt * nCoeffs,
208 "input array size is insufficient");
209 ASSERTL1(output.size() >= m_numElmt * nCoeffs,
210 "output array size is insufficient");
211
212 Array<OneD, NekDouble> tmpphys, t1;
213 Array<OneD, Array<OneD, NekDouble>> dtmp(3);
214 Array<OneD, Array<OneD, NekDouble>> tmp(3);
215
216 tmpphys = wsp;
217 for (int i = 1; i < m_coordim + 1; ++i)
218 {
219 dtmp[i - 1] = wsp + i * nPhys;
220 tmp[i - 1] = wsp + (i + m_coordim) * nPhys;
221 }
222
223 for (int i = 0; i < m_numElmt; ++i)
224 {
225 m_stdExp->BwdTrans(input + i * nCoeffs, tmpphys);
226
227 // local derivative
228 m_stdExp->PhysDeriv(tmpphys, dtmp[0], dtmp[1], dtmp[2]);
229
230 // determine mass matrix term
231 if (m_isDeformed)
232 {
233 Vmath::Vmul(nPhys, m_jac + i * nPhys, 1, tmpphys, 1, tmpphys,
234 1);
235 }
236 else
237 {
238 Vmath::Smul(nPhys, m_jac[i], tmpphys, 1, tmpphys, 1);
239 }
240
241 m_stdExp->IProductWRTBase(tmpphys, t1 = output + i * nCoeffs);
242 Vmath::Smul(nCoeffs, m_lambda, output + i * nCoeffs, 1,
243 t1 = output + i * nCoeffs, 1);
244
245 if (m_isDeformed)
246 {
247 // calculate full derivative
248 for (int j = 0; j < m_coordim; ++j)
249 {
250 Vmath::Vmul(nPhys,
251 m_derivFac[j * m_dim].origin() + i * nPhys, 1,
252 &dtmp[0][0], 1, &tmp[j][0], 1);
253
254 for (int k = 1; k < m_dim; ++k)
255 {
257 nPhys,
258 m_derivFac[j * m_dim + k].origin() + i * nPhys, 1,
259 &dtmp[k][0], 1, &tmp[j][0], 1, &tmp[j][0], 1);
260 }
261 }
262
264 {
265 // calculate dtmp[i] = dx/dxi sum_j diff[0][j] tmp[j]
266 // + dy/dxi sum_j diff[1][j] tmp[j]
267 // + dz/dxi sum_j diff[2][j] tmp[j]
268
269 // First term
270 Vmath::Smul(nPhys, m_diff[0][0], &tmp[0][0], 1, &tmpphys[0],
271 1);
272 for (int l = 1; l < m_coordim; ++l)
273 {
274 Vmath::Svtvp(nPhys, m_diff[0][l], &tmp[l][0], 1,
275 &tmpphys[0], 1, &tmpphys[0], 1);
276 }
277
278 for (int j = 0; j < m_dim; ++j)
279 {
280 Vmath::Vmul(nPhys, m_derivFac[j].origin() + i * nPhys,
281 1, &tmpphys[0], 1, &dtmp[j][0], 1);
282 }
283
284 // Second and third terms
285 for (int k = 1; k < m_coordim; ++k)
286 {
287 Vmath::Smul(nPhys, m_diff[k][0], &tmp[0][0], 1,
288 &tmpphys[0], 1);
289 for (int l = 1; l < m_coordim; ++l)
290 {
291 Vmath::Svtvp(nPhys, m_diff[k][l], &tmp[l][0], 1,
292 &tmpphys[0], 1, &tmpphys[0], 1);
293 }
294
295 for (int j = 0; j < m_dim; ++j)
296 {
297 Vmath::Vvtvp(nPhys,
298 m_derivFac[j + k * m_dim].origin() +
299 i * nPhys,
300 1, &tmpphys[0], 1, &dtmp[j][0], 1,
301 &dtmp[j][0], 1);
302 }
303 }
304 }
305 else
306 {
307 // calculate dx/dxi tmp[0] + dy/dxi tmp[1]
308 // + dz/dxi tmp[2]
309 for (int j = 0; j < m_dim; ++j)
310 {
311 Vmath::Vmul(nPhys, m_derivFac[j].origin() + i * nPhys,
312 1, &tmp[0][0], 1, &dtmp[j][0], 1);
313
314 for (int k = 1; k < m_coordim; ++k)
315 {
316 Vmath::Vvtvp(nPhys,
317 m_derivFac[j + k * m_dim].origin() +
318 i * nPhys,
319 1, &tmp[k][0], 1, &dtmp[j][0], 1,
320 &dtmp[j][0], 1);
321 }
322 }
323 }
324
325 // calculate Iproduct WRT Std Deriv
326 for (int j = 0; j < m_dim; ++j)
327 {
328 // multiply by Jacobian
329 Vmath::Vmul(nPhys, m_jac + i * nPhys, 1, dtmp[j], 1,
330 dtmp[j], 1);
331
332 m_stdExp->IProductWRTDerivBase(j, dtmp[j], tmp[0]);
333 Vmath::Vadd(nCoeffs, tmp[0], 1, output + i * nCoeffs, 1,
334 t1 = output + i * nCoeffs, 1);
335 }
336 }
337 else
338 {
339 // calculate full derivative
340 for (int j = 0; j < m_coordim; ++j)
341 {
342 Vmath::Smul(nPhys, m_derivFac[j * m_dim][i], &dtmp[0][0], 1,
343 &tmp[j][0], 1);
344
345 for (int k = 1; k < m_dim; ++k)
346 {
347 Vmath::Svtvp(nPhys, m_derivFac[j * m_dim + k][i],
348 &dtmp[k][0], 1, &tmp[j][0], 1, &tmp[j][0],
349 1);
350 }
351 }
352
354 {
355 // calculate dtmp[i] = dx/dxi sum_j diff[0][j] tmp[j]
356 // + dy/dxi sum_j diff[1][j] tmp[j]
357 // + dz/dxi sum_j diff[2][j] tmp[j]
358
359 // First term
360 Vmath::Smul(nPhys, m_diff[0][0], &tmp[0][0], 1, &tmpphys[0],
361 1);
362 for (int l = 1; l < m_coordim; ++l)
363 {
364 Vmath::Svtvp(nPhys, m_diff[0][l], &tmp[l][0], 1,
365 &tmpphys[0], 1, &tmpphys[0], 1);
366 }
367
368 for (int j = 0; j < m_dim; ++j)
369 {
370 Vmath::Smul(nPhys, m_derivFac[j][i], &tmpphys[0], 1,
371 &dtmp[j][0], 1);
372 }
373
374 // Second and third terms
375 for (int k = 1; k < m_coordim; ++k)
376 {
377 Vmath::Smul(nPhys, m_diff[k][0], &tmp[0][0], 1,
378 &tmpphys[0], 1);
379 for (int l = 1; l < m_coordim; ++l)
380 {
381 Vmath::Svtvp(nPhys, m_diff[k][l], &tmp[l][0], 1,
382 &tmpphys[0], 1, &tmpphys[0], 1);
383 }
384
385 for (int j = 0; j < m_dim; ++j)
386 {
387 Vmath::Svtvp(nPhys, m_derivFac[j + k * m_dim][i],
388 &tmpphys[0], 1, &dtmp[j][0], 1,
389 &dtmp[j][0], 1);
390 }
391 }
392 }
393 else
394 {
395 // calculate dx/dxi tmp[0] + dy/dxi tmp[2]
396 // + dz/dxi tmp[3]
397 for (int j = 0; j < m_dim; ++j)
398 {
399 Vmath::Smul(nPhys, m_derivFac[j][i], &tmp[0][0], 1,
400 &dtmp[j][0], 1);
401
402 for (int k = 1; k < m_coordim; ++k)
403 {
404 Vmath::Svtvp(nPhys, m_derivFac[j + k * m_dim][i],
405 &tmp[k][0], 1, &dtmp[j][0], 1,
406 &dtmp[j][0], 1);
407 }
408 }
409 }
410
411 // calculate Iproduct WRT Std Deriv
412 for (int j = 0; j < m_dim; ++j)
413 {
414 // multiply by Jacobian
415 Vmath::Smul(nPhys, m_jac[i], dtmp[j], 1, dtmp[j], 1);
416
417 m_stdExp->IProductWRTDerivBase(j, dtmp[j], tmp[0]);
418 Vmath::Vadd(nCoeffs, tmp[0], 1, output + i * nCoeffs, 1,
419 t1 = output + i * nCoeffs, 1);
420 }
421 }
422 }
423 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
Array< OneD, Array< OneD, NekDouble > > m_diff
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_coordim, m_derivFac, m_diff, m_dim, m_HasVarCoeffDiff, 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::Helmholtz_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 425 of file library/Collections/Helmholtz.cpp.

429 {
430 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
431 }
#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::Helmholtz_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 438 of file library/Collections/Helmholtz.cpp.

439 {
440 // If match previous factors, nothing to do.
441 if (m_factors == factors)
442 {
443 return;
444 }
445
447
448 // Check Lambda constant of Helmholtz operator
449 auto x = factors.find(StdRegions::eFactorLambda);
450 ASSERTL1(
451 x != factors.end(),
452 "Constant factor not defined: " +
453 std::string(
455 m_lambda = x->second;
456
457 // If varcoeffs not supplied, nothing else to do.
458 m_HasVarCoeffDiff = false;
460 if (d == factors.end())
461 {
462 return;
463 }
464
465 m_diff = Array<OneD, Array<OneD, NekDouble>>(m_coordim);
466 for (int i = 0; i < m_coordim; ++i)
467 {
468 m_diff[i] = Array<OneD, NekDouble>(m_coordim, 0.0);
469 }
470
471 for (int i = 0; i < m_coordim; ++i)
472 {
473 d = factors.find(m_factorCoeffDef[i][i]);
474 if (d != factors.end())
475 {
476 m_diff[i][i] = d->second;
477 }
478 else
479 {
480 m_diff[i][i] = 1.0;
481 }
482
483 for (int j = i + 1; j < m_coordim; ++j)
484 {
485 d = factors.find(m_factorCoeffDef[i][j]);
486 if (d != factors.end())
487 {
488 m_diff[i][j] = m_diff[j][i] = d->second;
489 }
490 }
491 }
492 m_HasVarCoeffDiff = true;
493 }
const StdRegions::ConstFactorType m_factorCoeffDef[3][3]
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:413
std::vector< double > d(NPUPPER *NPUPPER)

References ASSERTL1, Nektar::StdRegions::ConstFactorTypeMap, Nektar::UnitTests::d(), Nektar::StdRegions::eFactorCoeffD00, Nektar::StdRegions::eFactorLambda, Nektar::VarcoeffHashingTest::factors, m_coordim, m_diff, m_factorCoeffDef, m_factors, m_HasVarCoeffDiff, and m_lambda.

Referenced by Helmholtz_IterPerExp().

◆ UpdateVarcoeffs()

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

Check the validity of supplied variable coefficients. Note that the m_varcoeffs are not implemented for the IterPerExp operator. There exists a specialised implementation for variable diffusion in the above function UpdateFactors.

Parameters
varcoeffsMap of varcoeffs

Reimplemented from Nektar::Collections::Operator.

Definition at line 504 of file library/Collections/Helmholtz.cpp.

505 {
506 m_varcoeffs = varcoeffs;
507 }

References m_varcoeffs.

Member Data Documentation

◆ m_coordim

int Nektar::Collections::Helmholtz_IterPerExp::m_coordim
protected

◆ m_derivFac

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

Definition at line 510 of file library/Collections/Helmholtz.cpp.

Referenced by Helmholtz_IterPerExp(), and operator()().

◆ m_diff

Array<OneD, Array<OneD, NekDouble> > Nektar::Collections::Helmholtz_IterPerExp::m_diff
protected

Definition at line 518 of file library/Collections/Helmholtz.cpp.

Referenced by operator()(), and UpdateFactors().

◆ m_dim

int Nektar::Collections::Helmholtz_IterPerExp::m_dim
protected

Definition at line 512 of file library/Collections/Helmholtz.cpp.

Referenced by Helmholtz_IterPerExp(), and operator()().

◆ m_factorCoeffDef

const StdRegions::ConstFactorType Nektar::Collections::Helmholtz_IterPerExp::m_factorCoeffDef[3][3]
protected

◆ m_factors

StdRegions::FactorMap Nektar::Collections::Helmholtz_IterPerExp::m_factors
protected

Definition at line 514 of file library/Collections/Helmholtz.cpp.

Referenced by Helmholtz_IterPerExp(), and UpdateFactors().

◆ m_HasVarCoeffDiff

bool Nektar::Collections::Helmholtz_IterPerExp::m_HasVarCoeffDiff
protected

◆ m_jac

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

Definition at line 511 of file library/Collections/Helmholtz.cpp.

Referenced by Helmholtz_IterPerExp(), and operator()().

◆ m_lambda

NekDouble Nektar::Collections::Helmholtz_IterPerExp::m_lambda
protected

◆ m_varcoeffs

StdRegions::VarCoeffMap Nektar::Collections::Helmholtz_IterPerExp::m_varcoeffs
protected

Definition at line 515 of file library/Collections/Helmholtz.cpp.

Referenced by Helmholtz_IterPerExp(), and UpdateVarcoeffs().