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

Helmholtz operator using matrix free operators. More...

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

Public Member Functions

 ~Helmholtz_MatrixFree () final
 
void operator() (const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output0, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) override final
 Perform operation. More...
 
void operator() (int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
 
virtual void CheckFactors (StdRegions::FactorMap factors, int coll_phys_offset) override
 Check the validity of the supplied factor map. 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 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 ~Operator ()
 
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 expansion pointer. More...
 
StdRegions::StdExpansionSharedPtr GetExpSharedPtr ()
 Get expansion pointer. More...
 

Private Member Functions

 Helmholtz_MatrixFree (vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
 
- Private Member Functions inherited from Nektar::Collections::MatrixFreeOneInOneOut
 MatrixFreeOneInOneOut (const unsigned int nIn, const unsigned int nOut, const unsigned int nCollSize)
 Constructor. More...
 

Private Attributes

std::shared_ptr< MatrixFree::Helmholtz > m_oper
 
unsigned int m_nmtot
 
StdRegions::FactorMap m_factors
 
- Private Attributes inherited from Nektar::Collections::MatrixFreeOneInOneOut
Array< OneD, NekDoublem_input
 padded input/output vectors More...
 
Array< OneD, NekDoublem_output
 

Additional Inherited Members

- Protected Attributes inherited from Nektar::Collections::Operator
bool m_isDeformed
 
StdRegions::StdExpansionSharedPtr m_stdExp
 
unsigned int m_numElmt
 
unsigned int m_nqe
 
unsigned int m_wspSize
 

Detailed Description

Helmholtz operator using matrix free operators.

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

Constructor & Destructor Documentation

◆ ~Helmholtz_MatrixFree()

Nektar::Collections::Helmholtz_MatrixFree::~Helmholtz_MatrixFree ( )
inlinefinal

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

557 {
558 }

◆ Helmholtz_MatrixFree()

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

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

681 : Operator(pCollExp, pGeomData, factors),
682 MatrixFreeOneInOneOut(pCollExp[0]->GetStdExp()->GetNcoeffs(),
683 pCollExp[0]->GetStdExp()->GetNcoeffs(),
684 pCollExp.size())
685 {
686
687 m_nmtot = m_numElmt * pCollExp[0]->GetStdExp()->GetNcoeffs();
688
689 const auto dim = pCollExp[0]->GetStdExp()->GetShapeDimension();
690
691 // Basis vector.
692 std::vector<LibUtilities::BasisSharedPtr> basis(dim);
693 for (auto i = 0; i < dim; ++i)
694 {
695 basis[i] = pCollExp[0]->GetBasis(i);
696 }
697
698 // Get shape type
699 auto shapeType = pCollExp[0]->GetStdExp()->DetShapeType();
700
701 // Generate operator string and create operator.
702 std::string op_string = "Helmholtz";
703 op_string += MatrixFree::GetOpstring(shapeType, m_isDeformed);
705 op_string, basis, m_nElmtPad);
706
707 // Set Jacobian
708 oper->SetJac(pGeomData->GetJacInterLeave(pCollExp, m_nElmtPad));
709
710 // Store derivative factor
711 oper->SetDF(pGeomData->GetDerivFactorsInterLeave(pCollExp, m_nElmtPad));
712
713 m_oper = std::dynamic_pointer_cast<MatrixFree::Helmholtz>(oper);
714 ASSERTL0(m_oper, "Failed to cast pointer.");
715
716 // Set factors
718 this->CheckFactors(factors, 0);
719 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
std::shared_ptr< MatrixFree::Helmholtz > m_oper
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset) override
Check the validity of the supplied factor map.
unsigned int m_nElmtPad
size after padding
MatrixFreeOneInOneOut(const unsigned int nIn, const unsigned int nOut, const unsigned int nCollSize)
Constructor.
Operator(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
Constructor.
Definition: Operator.cpp:43
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:144
OperatorFactory & GetOperatorFactory()
Returns the singleton Operator factory object.
Definition: Operator.cpp:117
static FactorMap NullFactorMap
Definition: StdRegions.hpp:413
StdRegions::ConstFactorMap factors

References ASSERTL0, CheckFactors(), Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::Collections::GetOperatorFactory(), m_factors, Nektar::Collections::Operator::m_isDeformed, Nektar::Collections::MatrixFreeBase::m_nElmtPad, m_nmtot, Nektar::Collections::Operator::m_numElmt, m_oper, and Nektar::StdRegions::NullFactorMap.

Member Function Documentation

◆ CheckFactors()

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

Check the validity of the supplied factor map.

Implements Nektar::Collections::Operator.

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

594 {
595 boost::ignore_unused(coll_phys_offset);
596
597 if (factors == m_factors)
598 {
599 return;
600 }
601
603
604 // Set lambda for this call
605 auto x = factors.find(StdRegions::eFactorLambda);
606 ASSERTL1(
607 x != factors.end(),
608 "Constant factor not defined: " +
609 std::string(
611 m_oper->SetLambda(x->second);
612
613 // set constant diffusion coefficients
614 bool isConstVarDiff = false;
615 Array<OneD, NekDouble> diff = Array<OneD, NekDouble>(6, 0.0);
616 diff[0] = diff[2] = diff[5] = 1.0;
617
618 auto xd00 = factors.find(StdRegions::eFactorCoeffD00);
619 if (xd00 != factors.end() && xd00->second != 1.0)
620 {
621 isConstVarDiff = true;
622 diff[0] = xd00->second;
623 }
624
625 auto xd01 = factors.find(StdRegions::eFactorCoeffD01);
626 if (xd01 != factors.end() && xd01->second != 0.0)
627 {
628 isConstVarDiff = true;
629 diff[1] = xd01->second;
630 }
631
632 auto xd11 = factors.find(StdRegions::eFactorCoeffD11);
633 if (xd11 != factors.end() && xd11->second != 1.0)
634 {
635 isConstVarDiff = true;
636 diff[2] = xd11->second;
637 }
638
639 auto xd02 = factors.find(StdRegions::eFactorCoeffD02);
640 if (xd02 != factors.end() && xd02->second != 0.0)
641 {
642 isConstVarDiff = true;
643 diff[3] = xd02->second;
644 }
645
646 auto xd12 = factors.find(StdRegions::eFactorCoeffD12);
647 if (xd12 != factors.end() && xd12->second != 0.0)
648 {
649 isConstVarDiff = true;
650 diff[4] = xd12->second;
651 }
652
653 auto xd22 = factors.find(StdRegions::eFactorCoeffD22);
654 if (xd22 != factors.end() && xd22->second != 1.0)
655 {
656 isConstVarDiff = true;
657 diff[5] = xd22->second;
658 }
659
660 if (isConstVarDiff)
661 {
662 m_oper->SetConstVarDiffusion(diff);
663 }
664
665 // set random here for fn variable diffusion
666 auto k = factors.find(StdRegions::eFactorTau);
667 if (k != factors.end() && k->second != 0.0)
668 {
669 m_oper->SetVarDiffusion(diff);
670 }
671 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:391

References ASSERTL1, Nektar::StdRegions::ConstFactorTypeMap, Nektar::StdRegions::eFactorCoeffD00, Nektar::StdRegions::eFactorCoeffD01, Nektar::StdRegions::eFactorCoeffD02, Nektar::StdRegions::eFactorCoeffD11, Nektar::StdRegions::eFactorCoeffD12, Nektar::StdRegions::eFactorCoeffD22, Nektar::StdRegions::eFactorLambda, Nektar::StdRegions::eFactorTau, Nektar::VarcoeffHashingTest::factors, m_factors, and m_oper.

Referenced by Helmholtz_MatrixFree().

◆ operator()() [1/2]

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

Perform operation.

Implements Nektar::Collections::Operator.

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

565 {
566 boost::ignore_unused(output1, output2, wsp);
567
568 if (m_isPadded)
569 {
570 // copy into padded vector
571 Vmath::Vcopy(m_nmtot, input, 1, m_input, 1);
572 (*m_oper)(m_input, m_output);
573 Vmath::Vcopy(m_nmtot, m_output, 1, output0, 1);
574 }
575 else
576 {
577 (*m_oper)(input, output0);
578 }
579 }
Array< OneD, NekDouble > m_input
padded input/output vectors
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1191

References Nektar::Collections::MatrixFreeOneInOneOut::m_input, Nektar::Collections::MatrixFreeBase::m_isPadded, m_nmtot, Nektar::Collections::MatrixFreeOneInOneOut::m_output, and Vmath::Vcopy().

◆ operator()() [2/2]

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

Implements Nektar::Collections::Operator.

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

584 {
585 boost::ignore_unused(dir, input, output, wsp);
586 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
587 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:209

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

Member Data Documentation

◆ m_factors

StdRegions::FactorMap Nektar::Collections::Helmholtz_MatrixFree::m_factors
private

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

Referenced by CheckFactors(), and Helmholtz_MatrixFree().

◆ m_nmtot

unsigned int Nektar::Collections::Helmholtz_MatrixFree::m_nmtot
private

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

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

◆ m_oper

std::shared_ptr<MatrixFree::Helmholtz> Nektar::Collections::Helmholtz_MatrixFree::m_oper
private

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

Referenced by CheckFactors(), and Helmholtz_MatrixFree().