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

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) final
 Perform operation. More...
 
void operator() (int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) final
 
virtual void CheckFactors (StdRegions::FactorMap factors, int coll_phys_offset)
 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 ~Operator ()
 
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 582 of file library/Collections/Helmholtz.cpp.

Constructor & Destructor Documentation

◆ ~Helmholtz_MatrixFree()

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

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

588  {
589  }

◆ Helmholtz_MatrixFree()

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

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

706  : Operator(pCollExp, pGeomData, factors),
707  MatrixFreeOneInOneOut(pCollExp[0]->GetStdExp()->GetNcoeffs(),
708  pCollExp[0]->GetStdExp()->GetNcoeffs(),
709  pCollExp.size())
710  {
711 
712  m_nmtot = m_numElmt*pCollExp[0]->GetStdExp()->GetNcoeffs();
713 
714  const auto dim = pCollExp[0]->GetStdExp()->GetShapeDimension();
715 
716  // Basis vector.
717  std::vector<LibUtilities::BasisSharedPtr> basis(dim);
718  for (auto i = 0; i < dim; ++i)
719  {
720  basis[i] = pCollExp[0]->GetBasis(i);
721  }
722 
723  // Get shape type
724  auto shapeType = pCollExp[0]->GetStdExp()->DetShapeType();
725 
726  // Generate operator string and create operator.
727  std::string op_string = "Helmholtz";
728  op_string += MatrixFree::GetOpstring(shapeType, m_isDeformed);
729  auto oper = MatrixFree::GetOperatorFactory().
730  CreateInstance(op_string, basis, m_nElmtPad);
731 
732  // Set Jacobian
733  oper->SetJac(pGeomData->GetJacInterLeave(pCollExp,m_nElmtPad));
734 
735  // Store derivative factor
736  oper->SetDF(pGeomData->GetDerivFactorsInterLeave
737  (pCollExp,m_nElmtPad));
738 
739  m_oper = std::dynamic_pointer_cast<MatrixFree::Helmholtz>(oper);
740  ASSERTL0(m_oper, "Failed to cast pointer.");
741 
742  // Set factors
744  this->CheckFactors(factors, 0);
745  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
virtual void CheckFactors(StdRegions::FactorMap factors, int coll_phys_offset)
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.
Operator(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
Constructor.
Definition: Operator.cpp:41
OperatorFactory & GetOperatorFactory()
Returns the singleton Operator factory object.
Definition: Operator.cpp:121
static FactorMap NullFactorMap
Definition: StdRegions.hpp:319

References ASSERTL0, Nektar::Collections::GetOperatorFactory(), and Nektar::StdRegions::NullFactorMap.

Member Function Documentation

◆ CheckFactors()

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

Check the validity of the supplied factor map.

Implements Nektar::Collections::Operator.

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

628  {
629  boost::ignore_unused(coll_phys_offset);
630 
631  if (factors == m_factors)
632  {
633  return;
634  }
635 
636  m_factors = factors;
637 
638  // Set lambda for this call
639  auto x = factors.find(StdRegions::eFactorLambda);
640  ASSERTL1(x != factors.end(),
641  "Constant factor not defined: "
642  + std::string(StdRegions::ConstFactorTypeMap[
644  m_oper->SetLambda(x->second);
645 
646  // set constant diffusion coefficients
647  bool isConstVarDiff = false;
648  Array<OneD, NekDouble> diff = Array<OneD, NekDouble> (6, 0.0);
649  diff[0] = diff[2] = diff[5] = 1.0;
650 
651  auto xd00 = factors.find(StdRegions::eFactorCoeffD00);
652  if (xd00 != factors.end() && xd00->second != 1.0) {
653  isConstVarDiff = true;
654  diff[0] = xd00->second;
655  }
656 
657  auto xd01 = factors.find(StdRegions::eFactorCoeffD01);
658  if (xd01 != factors.end() && xd01->second != 0.0) {
659  isConstVarDiff = true;
660  diff[1] = xd01->second;
661  }
662 
663  auto xd11 = factors.find(StdRegions::eFactorCoeffD11);
664  if (xd11 != factors.end() && xd11->second != 1.0) {
665  isConstVarDiff = true;
666  diff[2] = xd11->second;
667  }
668 
669  auto xd02 = factors.find(StdRegions::eFactorCoeffD02);
670  if (xd02 != factors.end() && xd02->second != 0.0) {
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  isConstVarDiff = true;
678  diff[4] = xd12->second;
679  }
680 
681  auto xd22 = factors.find(StdRegions::eFactorCoeffD22);
682  if (xd22 != factors.end() && xd22->second != 1.0) {
683  isConstVarDiff = true;
684  diff[5] = xd22->second;
685  }
686 
687  if (isConstVarDiff) {
688  m_oper->SetConstVarDiffusion(diff);
689  }
690 
691  // set random here for fn variable diffusion
692  auto k = factors.find(StdRegions::eFactorTau);
693  if (k != factors.end() && k->second != 0.0) {
694  m_oper->SetVarDiffusion(diff);
695  }
696  }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:250
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:296

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, and Nektar::StdRegions::eFactorTau.

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

597  {
598  boost::ignore_unused(output1,output2,wsp);
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.cpp:1199

References 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  boost::ignore_unused(dir,input,output,wsp);
619  NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
620  }
#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 NEKERROR.

Member Data Documentation

◆ m_factors

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

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

◆ m_nmtot

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

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

◆ m_oper

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

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