Nektar++
Loading...
Searching...
No Matches
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.
 
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.
 
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.
 
- Public Member Functions inherited from Nektar::Collections::Operator
 Operator (std::vector< LocalRegions::ExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
 Constructor.
 
virtual ~Operator ()=default
 
unsigned int GetWspSize ()
 Get the size of the required workspace.
 
unsigned int GetNumElmt ()
 Get number of elements.
 
StdRegions::StdExpansionSharedPtr GetExpSharedPtr ()
 Get expansion pointer.
 
unsigned int GetInputSize (void)
 
unsigned int GetOutputSize (void)
 
unsigned int GetPhysSize (void)
 
unsigned int GetCoeffSize (void)
 

Private Member Functions

 Helmholtz_MatrixFree (vector< LocalRegions::ExpansionSharedPtr > 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
 
unsigned int m_nElmtPad
 size after padding
 
unsigned int m_nIn
 actural size of input array
 
unsigned int m_nOut
 actural size of output array
 

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
 
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
 
unsigned int m_outputSize
 number of modes or quadrature points that are taken as output from an operator
 

Detailed Description

Helmholtz operator using matrix free operators.

Definition at line 586 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< LocalRegions::ExpansionSharedPtr pCollExp,
CoalescedGeomDataSharedPtr  pGeomData,
StdRegions::FactorMap  factors 
)
inlineprivate

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

716 : Operator(pCollExp, pGeomData, factors),
717 MatrixFreeBase(pCollExp[0]->GetNcoeffs(), pCollExp[0]->GetNcoeffs(),
718 pCollExp.size()),
720 {
721
722 m_nmtot = m_numElmt * pCollExp[0]->GetNcoeffs();
723
724 const auto dim = pCollExp[0]->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]->DetShapeType();
735
736 // Generate operator string and create operator.
737 std::string op_string = "Helmholtz";
738 op_string += MatrixFree::GetOpstring(shapeType, m_isDeformed);
739 auto oper = MatrixFree::GetOperatorFactory().CreateInstance(
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)
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:232
Operator(std::vector< LocalRegions::ExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
Constructor.
Definition Operator.cpp:66
static FactorMap NullFactorMap
static VarCoeffMap NullVarCoeffMap

References ASSERTL0, 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 595 of file library/Collections/Helmholtz.cpp.

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

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

608 {
609 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
610 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...

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

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

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

703 {
704 m_varcoeffs = varcoeffs;
705 }

References m_varcoeffs.

Member Data Documentation

◆ m_factors

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

Definition at line 710 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 709 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 708 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 711 of file library/Collections/Helmholtz.cpp.

Referenced by Helmholtz_MatrixFree(), and UpdateVarcoeffs().