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 CheckFactors (StdRegions::FactorMap factors, int coll_phys_offset) override
 Check the validity of supplied constant factors. 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 CheckFactors (StdRegions::FactorMap factors, int coll_phys_offset)=0
 Check the validity of the supplied factor map. 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 ()
 
unsigned int GetOutputSize ()
 

Protected Attributes

Array< TwoD, const NekDoublem_derivFac
 
Array< OneD, const NekDoublem_jac
 
int m_dim
 
int m_coordim
 
StdRegions::FactorMap m_factors
 
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...
 

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 ()
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Collections::Operator
virtual int v_GetInputSize ()
 This purely virtual function needs to be set-up for every operator inside Collections. It is responsible for returning the size of input collection, that the operator is applied on either in physical or coefficient space. More...
 
virtual int v_GetOutputSize ()
 This purely virtual function needs to be set-up for every operator inside Collections. It is responsible for returning the output size either in physical or coefficient space of an operator inside Collections. More...
 

Detailed Description

Helmholtz operator using LocalRegions implementation.

Definition at line 173 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 497 of file library/Collections/Helmholtz.cpp.

500 : Operator(pCollExp, pGeomData, factors), Helmholtz_Helper()
501 {
502 m_dim = pCollExp[0]->GetShapeDimension();
503 m_coordim = pCollExp[0]->GetCoordim();
504 int nqtot = m_stdExp->GetTotPoints();
505
506 m_derivFac = pGeomData->GetDerivFactors(pCollExp);
507 m_jac = pGeomData->GetJac(pCollExp);
508 m_wspSize = (2 * m_coordim + 1) * nqtot;
509
510 m_lambda = 1.0;
511 m_HasVarCoeffDiff = false;
513 this->CheckFactors(factors, 0);
514 }
void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of supplied constant factors.
StdRegions::StdExpansionSharedPtr m_stdExp
Definition: Operator.h:188
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:407
StdRegions::ConstFactorMap factors

References CheckFactors(), m_coordim, m_derivFac, m_dim, m_factors, m_HasVarCoeffDiff, m_jac, m_lambda, Nektar::Collections::Operator::m_stdExp, Nektar::Collections::Operator::m_wspSize, and Nektar::StdRegions::NullFactorMap.

Member Function Documentation

◆ CheckFactors()

void Nektar::Collections::Helmholtz_IterPerExp::CheckFactors ( StdRegions::FactorMap  factors,
int  coll_phys_offset 
)
inlineoverridevirtual

Check the validity of supplied constant factors.

Parameters
factorsMap of factors
coll_phys_offsetUnused

Implements Nektar::Collections::Operator.

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

423 {
424 // If match previous factors, nothing to do.
425 if (m_factors == factors)
426 {
427 return;
428 }
429
431
432 // Check Lambda constant of Helmholtz operator
433 auto x = factors.find(StdRegions::eFactorLambda);
434 ASSERTL1(
435 x != factors.end(),
436 "Constant factor not defined: " +
437 std::string(
439 m_lambda = x->second;
440
441 // If varcoeffs not supplied, nothing else to do.
442 m_HasVarCoeffDiff = false;
444 if (d == factors.end())
445 {
446 return;
447 }
448
449 m_diff = Array<OneD, Array<OneD, NekDouble>>(m_coordim);
450 for (int i = 0; i < m_coordim; ++i)
451 {
452 m_diff[i] = Array<OneD, NekDouble>(m_coordim, 0.0);
453 }
454
455 for (int i = 0; i < m_coordim; ++i)
456 {
457 d = factors.find(m_factorCoeffDef[i][i]);
458 if (d != factors.end())
459 {
460 m_diff[i][i] = d->second;
461 }
462 else
463 {
464 m_diff[i][i] = 1.0;
465 }
466
467 for (int j = i + 1; j < m_coordim; ++j)
468 {
469 d = factors.find(m_factorCoeffDef[i][j]);
470 if (d != factors.end())
471 {
472 m_diff[i][j] = m_diff[j][i] = d->second;
473 }
474 }
475 }
476 m_HasVarCoeffDiff = true;
477 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
const StdRegions::ConstFactorType m_factorCoeffDef[3][3]
Array< OneD, Array< OneD, NekDouble > > m_diff
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:385
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().

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

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

411 {
412 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
413 }
#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.

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

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

◆ m_dim

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

Definition at line 482 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 484 of file library/Collections/Helmholtz.cpp.

Referenced by CheckFactors(), and Helmholtz_IterPerExp().

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

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

◆ m_lambda

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