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::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
 
StdRegions::VarCoeffMap m_varcoeffs
 
- 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
 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 722 of file library/Collections/Helmholtz.cpp.

725 : Operator(pCollExp, pGeomData, factors),
726 MatrixFreeOneInOneOut(pCollExp[0]->GetStdExp()->GetNcoeffs(),
727 pCollExp[0]->GetStdExp()->GetNcoeffs(),
728 pCollExp.size()),
730 {
731
732 m_nmtot = m_numElmt * pCollExp[0]->GetStdExp()->GetNcoeffs();
733
734 const auto dim = pCollExp[0]->GetStdExp()->GetShapeDimension();
735
736 // Basis vector.
737 std::vector<LibUtilities::BasisSharedPtr> basis(dim);
738 for (auto i = 0; i < dim; ++i)
739 {
740 basis[i] = pCollExp[0]->GetBasis(i);
741 }
742
743 // Get shape type
744 auto shapeType = pCollExp[0]->GetStdExp()->DetShapeType();
745
746 // Generate operator string and create operator.
747 std::string op_string = "Helmholtz";
748 op_string += MatrixFree::GetOpstring(shapeType, m_isDeformed);
750 op_string, basis, m_nElmtPad);
751
752 // Set Jacobian
753 oper->SetJac(pGeomData->GetJacInterLeave(pCollExp, m_nElmtPad));
754
755 // Store derivative factor
756 oper->SetDF(pGeomData->GetDerivFactorsInterLeave(pCollExp, m_nElmtPad));
757
758 m_oper = std::dynamic_pointer_cast<MatrixFree::Helmholtz>(oper);
759 ASSERTL0(m_oper, "Failed to cast pointer.");
760
761 // Set factors
764 this->UpdateFactors(factors);
765 }
#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
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: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 if (m_isPadded)
601 {
602 // copy into padded vector
603 Vmath::Vcopy(m_nmtot, input, 1, m_input, 1);
604 (*m_oper)(m_input, m_output);
605 Vmath::Vcopy(m_nmtot, m_output, 1, output0, 1);
606 }
607 else
608 {
609 (*m_oper)(input, output0);
610 }
611 }
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 613 of file library/Collections/Helmholtz.cpp.

617 {
618 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
619 }
#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 624 of file library/Collections/Helmholtz.cpp.

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

712 {
713 m_varcoeffs = varcoeffs;
714 }

References m_varcoeffs.

Member Data Documentation

◆ m_factors

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

Definition at line 719 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 718 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 717 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 720 of file library/Collections/Helmholtz.cpp.

Referenced by Helmholtz_MatrixFree(), and UpdateVarcoeffs().