Nektar++
Loading...
Searching...
No Matches
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.
 
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.
 
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.
 
- Public Member Functions inherited from Nektar::Collections::Operator
 Operator (std::vector< LocalRegions::ExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
 Constructor.
 
virtual ~Operator ()=default
 
unsigned int GetWspSize ()
 Get the size of the required workspace.
 
unsigned int GetNumElmt ()
 Get number of elements.
 
StdRegions::StdExpansionSharedPtr GetExpSharedPtr ()
 Get expansion pointer.
 
unsigned int GetInputSize (void)
 
unsigned int GetOutputSize (void)
 
unsigned int GetPhysSize (void)
 
unsigned int GetCoeffSize (void)
 

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
 
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
 
unsigned int m_outputSize
 number of modes or quadrature points that are taken as output from an operator
 

Private Member Functions

 Helmholtz_IterPerExp (vector< LocalRegions::ExpansionSharedPtr > 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 192 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< LocalRegions::ExpansionSharedPtr pCollExp,
CoalescedGeomDataSharedPtr  pGeomData,
StdRegions::FactorMap  factors 
)
inlineprivate

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

532 : Operator(pCollExp, pGeomData, factors), Helmholtz_Helper()
533 {
534 m_dim = pCollExp[0]->GetShapeDimension();
535 m_coordim = pCollExp[0]->GetCoordim();
536 int nqtot = m_stdExp->GetTotPoints();
537
538 m_derivFac = pGeomData->GetDerivFactors(pCollExp);
539 m_jac = pGeomData->GetJac(pCollExp);
540 m_wspSize = (2 * m_coordim + 1) * nqtot;
541
542 m_lambda = 1.0;
543 m_HasVarCoeffDiff = false;
546 this->UpdateFactors(factors);
547 }
void UpdateFactors(StdRegions::FactorMap factors) override
Check the validity of supplied constant factors.
StdRegions::StdExpansionSharedPtr m_stdExp
Definition Operator.h:230
Operator(std::vector< LocalRegions::ExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
Constructor.
Definition Operator.cpp:66
static FactorMap NullFactorMap
static VarCoeffMap NullVarCoeffMap

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 199 of file library/Collections/Helmholtz.cpp.

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

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

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 439 of file library/Collections/Helmholtz.cpp.

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

References ASSERTL1, Nektar::StdRegions::ConstFactorTypeMap, Nektar::StdRegions::eFactorCoeffD00, Nektar::StdRegions::eFactorLambda, 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 505 of file library/Collections/Helmholtz.cpp.

506 {
507 m_varcoeffs = varcoeffs;
508 }

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 511 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 519 of file library/Collections/Helmholtz.cpp.

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

◆ m_dim

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

Definition at line 513 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 515 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 512 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 516 of file library/Collections/Helmholtz.cpp.

Referenced by Helmholtz_IterPerExp(), and UpdateVarcoeffs().