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=default
 
void operator() (const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output0, 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 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 ~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 ()
 

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 Member Functions inherited from Nektar::Collections::Helmholtz_Helper
 Helmholtz_Helper ()
 

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 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...
 
- 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...
 

Detailed Description

Helmholtz operator using matrix free operators.

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

Constructor & Destructor Documentation

◆ ~Helmholtz_MatrixFree()

Nektar::Collections::Helmholtz_MatrixFree::~Helmholtz_MatrixFree ( )
finaldefault

◆ Helmholtz_MatrixFree()

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

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

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

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

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

Perform operation.

Implements Nektar::Collections::Operator.

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

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.hpp:825

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

Implements Nektar::Collections::Operator.

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

585 {
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:202

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

Member Data Documentation

◆ m_factors

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

Definition at line 674 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 673 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 672 of file library/Collections/Helmholtz.cpp.

Referenced by CheckFactors(), and Helmholtz_MatrixFree().