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 UpdateFactors (StdRegions::FactorMap factors) override
 Update the supplied factor map. More...
 
void UpdateVarcoeffs (StdRegions::VarCoeffMap &varcoeffs) override
 Check the validity of supplied variable coefficients. Note that the m_varcoeffs are not implemented for the MatrixFree 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)
 

Private Member Functions

 Helmholtz_MatrixFree (vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
 
- Private Member Functions inherited from Nektar::Collections::MatrixFreeBase
 MatrixFreeBase ()=default
 
 MatrixFreeBase (const unsigned int nIn, const unsigned int nOut, const unsigned int nCollSize)
 
- 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
 
StdRegions::VarCoeffMap m_varcoeffs
 
- Private Attributes inherited from Nektar::Collections::MatrixFreeBase
bool m_isPadded {false}
 flag for padding More...
 
unsigned int m_nElmtPad
 size after padding More...
 
unsigned int m_nIn
 actural size of input array More...
 
unsigned int m_nOut
 actural size of output array More...
 

Additional Inherited Members

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

Detailed Description

Helmholtz operator using matrix free operators.

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

715 : Operator(pCollExp, pGeomData, factors),
716 MatrixFreeBase(pCollExp[0]->GetStdExp()->GetNcoeffs(),
717 pCollExp[0]->GetStdExp()->GetNcoeffs(),
718 pCollExp.size()),
720 {
721
722 m_nmtot = m_numElmt * pCollExp[0]->GetStdExp()->GetNcoeffs();
723
724 const auto dim = pCollExp[0]->GetStdExp()->GetShapeDimension();
725
726 // Basis vector.
727 std::vector<LibUtilities::BasisSharedPtr> basis(dim);
728 for (auto i = 0; i < dim; ++i)
729 {
730 basis[i] = pCollExp[0]->GetBasis(i);
731 }
732
733 // Get shape type
734 auto shapeType = pCollExp[0]->GetStdExp()->DetShapeType();
735
736 // Generate operator string and create operator.
737 std::string op_string = "Helmholtz";
738 op_string += MatrixFree::GetOpstring(shapeType, m_isDeformed);
740 op_string, basis, pCollExp.size());
741
742 // Set Jacobian
743 oper->SetJac(pGeomData->GetJacInterLeave(pCollExp, m_nElmtPad));
744
745 // Store derivative factor
746 oper->SetDF(pGeomData->GetDerivFactorsInterLeave(pCollExp, m_nElmtPad));
747
748 oper->SetUpBdata(basis);
749 oper->SetUpDBdata(basis);
750 oper->SetUpZW(basis);
751 oper->SetUpD(basis);
752
753 m_oper = std::dynamic_pointer_cast<MatrixFree::Helmholtz>(oper);
754 ASSERTL0(m_oper, "Failed to cast pointer.");
755
756 // Set factors
759 this->UpdateFactors(factors);
760 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
std::shared_ptr< MatrixFree::Helmholtz > m_oper
void UpdateFactors(StdRegions::FactorMap factors) override
Update the supplied factor map.
unsigned int m_nElmtPad
size after padding
unsigned int m_numElmt
number of elements that the operator is applied on
Definition: Operator.h:219
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.
OperatorFactory & GetOperatorFactory()
Returns the singleton Operator factory object.
Definition: Operator.cpp:44
static FactorMap NullFactorMap
Definition: StdRegions.hpp:435
static VarCoeffMap NullVarCoeffMap
Definition: StdRegions.hpp:376
StdRegions::ConstFactorMap factors

References ASSERTL0, 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, m_varcoeffs, Nektar::StdRegions::NullFactorMap, Nektar::StdRegions::NullVarCoeffMap, and UpdateFactors().

Member Function Documentation

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

599 {
600 (*m_oper)(input, output0);
601 }

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

607 {
608 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
609 }
#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_MatrixFree::UpdateFactors ( StdRegions::FactorMap  factors)
inlineoverridevirtual

Update the supplied factor map.

Reimplemented from Nektar::Collections::Operator.

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

615 {
616 if (factors == m_factors)
617 {
618 return;
619 }
620
622
623 // Set lambda for this call
624 auto x = factors.find(StdRegions::eFactorLambda);
625 ASSERTL1(
626 x != factors.end(),
627 "Constant factor not defined: " +
628 std::string(
630 m_oper->SetLambda(x->second);
631
632 // set constant diffusion coefficients
633 bool isConstVarDiff = false;
634 Array<OneD, NekDouble> diff = Array<OneD, NekDouble>(6, 0.0);
635 diff[0] = diff[2] = diff[5] = 1.0;
636
637 auto xd00 = factors.find(StdRegions::eFactorCoeffD00);
638 if (xd00 != factors.end() && xd00->second != 1.0)
639 {
640 isConstVarDiff = true;
641 diff[0] = xd00->second;
642 }
643
644 auto xd01 = factors.find(StdRegions::eFactorCoeffD01);
645 if (xd01 != factors.end() && xd01->second != 0.0)
646 {
647 isConstVarDiff = true;
648 diff[1] = xd01->second;
649 }
650
651 auto xd11 = factors.find(StdRegions::eFactorCoeffD11);
652 if (xd11 != factors.end() && xd11->second != 1.0)
653 {
654 isConstVarDiff = true;
655 diff[2] = xd11->second;
656 }
657
658 auto xd02 = factors.find(StdRegions::eFactorCoeffD02);
659 if (xd02 != factors.end() && xd02->second != 0.0)
660 {
661 isConstVarDiff = true;
662 diff[3] = xd02->second;
663 }
664
665 auto xd12 = factors.find(StdRegions::eFactorCoeffD12);
666 if (xd12 != factors.end() && xd12->second != 0.0)
667 {
668 isConstVarDiff = true;
669 diff[4] = xd12->second;
670 }
671
672 auto xd22 = factors.find(StdRegions::eFactorCoeffD22);
673 if (xd22 != factors.end() && xd22->second != 1.0)
674 {
675 isConstVarDiff = true;
676 diff[5] = xd22->second;
677 }
678
679 if (isConstVarDiff)
680 {
681 m_oper->SetConstVarDiffusion(diff);
682 }
683
684 // set random here for fn variable diffusion
685 auto k = factors.find(StdRegions::eFactorTau);
686 if (k != factors.end() && k->second != 0.0)
687 {
688 m_oper->SetVarDiffusion(diff);
689 }
690 }
#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:413

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

◆ UpdateVarcoeffs()

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

Check the validity of supplied variable coefficients. Note that the m_varcoeffs are not implemented for the MatrixFree 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 701 of file library/Collections/Helmholtz.cpp.

702 {
703 m_varcoeffs = varcoeffs;
704 }

References m_varcoeffs.

Member Data Documentation

◆ m_factors

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

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

Referenced by Helmholtz_MatrixFree(), and UpdateFactors().

◆ m_nmtot

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

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

Referenced by Helmholtz_MatrixFree().

◆ m_oper

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

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

Referenced by Helmholtz_MatrixFree(), and UpdateFactors().

◆ m_varcoeffs

StdRegions::VarCoeffMap Nektar::Collections::Helmholtz_MatrixFree::m_varcoeffs
private

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

Referenced by Helmholtz_MatrixFree(), and UpdateVarcoeffs().