Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
Nektar::MultiRegions::HelmholtzOp< TData > Class Template Referenceabstract

Whole-field interface of the weak Helmholtz operator: maps coefficient-space fields to coefficient space. More...

#include <HelmholtzOp.hpp>

Inheritance diagram for Nektar::MultiRegions::HelmholtzOp< TData >:
[legend]

Public Member Functions

void SetLambda (TData lambda)
 Set the scalar weight \(\lambda\) of the mass term used by subsequent Apply() calls.
 
void SetDiffCoeff (std::vector< TData > &diffCoeff)
 Set the constant symmetric diffusion tensor \(\mathbf{D}\) used by subsequent Apply() calls.
 
void SetVarDiffCoeff (LibUtilities::Field< TData, FieldState::Phys > &diffCoeff)
 Set a spatially varying symmetric diffusion tensor.
 
- Public Member Functions inherited from Nektar::MultiRegions::ElmtOp< FieldState::Coeff, FieldState::Coeff, TData >
void Apply (LibUtilities::Field< TData, TFieldIn > &in, LibUtilities::Field< TData, TFieldOut > &out)
 Apply the operator to in, writing the result to out.
 
void operator() (LibUtilities::Field< TData, TFieldIn > &in, LibUtilities::Field< TData, TFieldOut > &out)
 Call operator; equivalent to Apply().
 
- Public Member Functions inherited from Nektar::MultiRegions::Operator< TData >
virtual ~Operator ()=default
 
 Operator (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > components)
 Construct the interface part of a concrete operator; called by the factory-registered creator functions.
 

Static Public Member Functions

static std::shared_ptr< HelmholtzOp< TData > > Create (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
 Create a weak-Helmholtz operator through the operator and block-operator factories.
 
- Static Public Member Functions inherited from Nektar::MultiRegions::ElmtOp< FieldState::Coeff, FieldState::Coeff, TData >
static std::shared_ptr< TOperator< TData > > Create (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
 Build a complete element operator: the whole-field interface object plus one block operator per element block.
 
static std::string GetOpImpl (const std::string &opName, const std::string &opExecSpace, LibUtilities::SessionReaderSharedPtr session, const StdRegions::StdExpansionSharedPtr &exp=nullptr, const std::string &policyName="")
 Return the implementation for an operator.
 
- Static Public Member Functions inherited from Nektar::MultiRegions::Operator< TData >
template<template< typename > typename TOperator>
static std::shared_ptr< TOperator< TData > > Create (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > components, const std::string &execStr)
 Create a concrete operator instance through the operator factory.
 
static std::string GetOpExecSpace (std::shared_ptr< LibUtilities::SessionReader > session, const bool warn=true)
 Return the execution space name ("opExecSpace") for an operator.
 
static const DefaultOpImplRule * GetDefaultOpImplRule (const StdRegions::StdExpansionSharedPtr &exp, const std::string &execSpace)
 Return the row of the default implementation table (DefaultOpImplTable.hpp) that a block of elements takes, or null if none does.
 
static std::string GetDefaultOpImpl (const StdRegions::StdExpansionSharedPtr &exp, const std::string &execSpace)
 Return the implementation a block of elements takes when neither the command line nor the session names one for its operator.
 
static std::vector< unsigned int > GetDefaultInterleaveWidths (const MultiRegions::ExpListSharedPtr &expansionList)
 Return the default interleave widths, one per block of expansionList, that persistent Fields (e.g. solution storage, time-integration and linear-solver workspace) built on it should be constructed with.
 
static bool IsDiscontinuousProjection (std::shared_ptr< LibUtilities::SessionReader > session)
 Return true if the session uses a Discontinuous (DG) projection.
 

Static Public Attributes

static const std::string name = "Helmholtz"
 Operator base name; Create() appends the execution space to it to form the factory key.
 

Protected Member Functions

 HelmholtzOp (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
 Construct the interface part of a concrete implementation; called by the factory-registered creator functions.
 
 ~HelmholtzOp () override=default
 
void v_Apply (LibUtilities::Field< TData, FieldState::Coeff > &in, LibUtilities::Field< TData, FieldState::Coeff > &out) override
 Apply the weak Helmholtz operator block by block.
 
virtual void v_ApplyFFT (LibUtilities::Field< TData, FieldState::Coeff > &in, LibUtilities::Field< TData, FieldState::Coeff > &out)=0
 Weak z-Laplacian, called by v_Apply() after the block loop; adds it to every output block of a multi-plane 3DH1 field and leaves any other field untouched.
 
- Protected Member Functions inherited from Nektar::MultiRegions::ElmtOp< FieldState::Coeff, FieldState::Coeff, TData >
 ElmtOp (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
 Construct the interface part of a concrete operator; called by the factory-registered creator functions.
 
 ~ElmtOp () override=default
 
virtual void v_Apply (LibUtilities::Field< TData, TFieldIn > &in, LibUtilities::Field< TData, TFieldOut > &out)=0
 Implementation hook for Apply().
 

Protected Attributes

bool m_isSetLambda = false
 Set by SetLambda(); checked by v_Apply() in debug builds.
 
bool m_isSetDiffCoeff = false
 Set by SetDiffCoeff(); checked by v_Apply() in debug builds.
 
bool m_isSetVarDiffCoeff = false
 Whether a spatially varying tensor is selected.
 
std::vector< std::shared_ptr< HelmholtzBlockOp< TData > > > m_blockOp
 One block operator per element block of the expansion list; populated by ElmtOp::Create().
 
- Protected Attributes inherited from Nektar::MultiRegions::Operator< TData >
MultiRegions::ExpListSharedPtr m_expansionList
 Expansion list the operator acts on.
 
std::vector< std::string > m_components
 Names of the field components the operator was built for.
 
LibUtilities::NekDataWarehouseSharedPtr m_dataWarehouse
 Data warehouse shared with the other operators on the expansion list, used to build and cache shared tables (basis matrices, mode indices, geometric factors) once.
 

Friends

class ElmtOp< FieldState::Coeff, FieldState::Coeff, TData >
 

Detailed Description

template<typename TData>
class Nektar::MultiRegions::HelmholtzOp< TData >

Whole-field interface of the weak Helmholtz operator: maps coefficient-space fields to coefficient space.

As with the other element-operator families, this class sets the Apply() field states at compile time – input and output in FieldState::Coeff – and drives one HelmholtzBlockOp per element block, followed by v_ApplyFFT(), which detail::HelmholtzOpImpl implements to add the weak z-Laplacian of a multi-plane 3DH1 field. See ElmtOp for the block decomposition and factory scheme.

Apply() always overwrites the output field.

Two settings specify what the block operators compute: the mass weight lambda and the packed symmetric diffusion tensor, forwarded to every block operator by SetLambda() and SetDiffCoeff().

Template Parameters
TDataFloating-point type of the field data.

Definition at line 173 of file HelmholtzOp.hpp.

Constructor & Destructor Documentation

◆ HelmholtzOp()

template<typename TData >
Nektar::MultiRegions::HelmholtzOp< TData >::HelmholtzOp ( const MultiRegions::ExpListSharedPtr &  expansionList,
const std::vector< std::string > &  components 
)
inlineprotected

Construct the interface part of a concrete implementation; called by the factory-registered creator functions.

Parameters
expansionListExpansion list the operator acts on.
componentsComponent names the operator is set up for.

Definition at line 307 of file HelmholtzOp.hpp.

310 components)
311 {
312 }
friend class ElmtOp< FieldState::Coeff, FieldState::Coeff, TData >

◆ ~HelmholtzOp()

template<typename TData >
Nektar::MultiRegions::HelmholtzOp< TData >::~HelmholtzOp ( )
overrideprotecteddefault

Member Function Documentation

◆ Create()

template<typename TData >
static std::shared_ptr< HelmholtzOp< TData > > Nektar::MultiRegions::HelmholtzOp< TData >::Create ( const MultiRegions::ExpListSharedPtr &  expansionList,
const std::vector< std::string > &  components,
const std::string &  execStr = "",
const std::string &  implStr = "" 
)
inlinestatic

Create a weak-Helmholtz operator through the operator and block-operator factories.

Builds the interface object under the factory key "Helmholtz" + execStr and one block operator per element block under "BlockHelmholtz" + execStr + implStr (see ElmtOp::Create for the two-stage construction and for the session defaults used when execStr / implStr are empty).

Parameters
expansionListExpansion list the operator acts on.
componentsNames of the field components the operator is set up for.
execStrExecution space ("Serial", "AVX" or "Device"); session default if empty.
implStrBlock implementation ("StdMat", "SumFac", "SumFacTOP"); session default if empty.
Returns
The assembled operator. SetLambda() and SetDiffCoeff() must still be called before Apply().

Definition at line 200 of file HelmholtzOp.hpp.

204 {
206 template Create<HelmholtzOp, HelmholtzBlockOp>(
207 expansionList, components, execStr, implStr);
208 }

Referenced by TestHelmholtz< TData >::RunTestCase(), and TestPreconOps< TData >::RunTestCase().

◆ SetDiffCoeff()

template<typename TData >
void Nektar::MultiRegions::HelmholtzOp< TData >::SetDiffCoeff ( std::vector< TData > &  diffCoeff)
inline

Set the constant symmetric diffusion tensor \(\mathbf{D}\) used by subsequent Apply() calls.

The tensor is passed in packed upper-triangular form, one entry per independent component, so diffCoeff holds ncoord * (ncoord + 1) / 2 values for a coordinate dimension of ncoord: {D00} in 1D, {D00, D01, D11} in 2D and {D00, D01, D11, D02, D12, D22} in 3D – the order the kernels index through LibUtilities::GetDiffCoeffMap() and the one the factors map onto. The values are copied down to every block operator; calling this again replaces them.

Parameters
diffCoeffPacked tensor entries, in the order above.

Definition at line 252 of file HelmholtzOp.hpp.

253 {
254 // Loop over the blocks.
255 for (unsigned int blk = 0; blk < this->m_blockOp.size(); ++blk)
256 {
257 this->m_blockOp[blk]->SetDiffCoeff(diffCoeff);
258 }
259 m_isSetDiffCoeff = true;
260 m_isSetVarDiffCoeff = false;
261 }
bool m_isSetVarDiffCoeff
Whether a spatially varying tensor is selected.
bool m_isSetDiffCoeff
Set by SetDiffCoeff(); checked by v_Apply() in debug builds.
std::vector< std::shared_ptr< HelmholtzBlockOp< TData > > > m_blockOp
One block operator per element block of the expansion list; populated by ElmtOp::Create().

References Nektar::MultiRegions::HelmholtzOp< TData >::m_blockOp, Nektar::MultiRegions::HelmholtzOp< TData >::m_isSetDiffCoeff, and Nektar::MultiRegions::HelmholtzOp< TData >::m_isSetVarDiffCoeff.

◆ SetLambda()

template<typename TData >
void Nektar::MultiRegions::HelmholtzOp< TData >::SetLambda ( TData  lambda)
inline

Set the scalar weight \(\lambda\) of the mass term used by subsequent Apply() calls.

The value is copied down to every block operator; calling this again replaces it. A lambda of zero leaves the plain weak Laplacian – the StdMat implementations then skip the mass term's two matrix multiplications entirely, while the sum-factorised ones take no special path: they carry the zero through as a scaling of the physical values.

Parameters
lambdaWeight of the \((\phi_{pq}, u)\) term.

Definition at line 227 of file HelmholtzOp.hpp.

228 {
229 // Loop over the blocks.
230 for (unsigned int blk = 0; blk < this->m_blockOp.size(); ++blk)
231 {
232 this->m_blockOp[blk]->SetLambda(lambda);
233 }
234 m_isSetLambda = true;
235 }
bool m_isSetLambda
Set by SetLambda(); checked by v_Apply() in debug builds.

References Nektar::MultiRegions::HelmholtzOp< TData >::m_blockOp, and Nektar::MultiRegions::HelmholtzOp< TData >::m_isSetLambda.

◆ SetVarDiffCoeff()

template<typename TData >
void Nektar::MultiRegions::HelmholtzOp< TData >::SetVarDiffCoeff ( LibUtilities::Field< TData, FieldState::Phys > &  diffCoeff)
inline

Set a spatially varying symmetric diffusion tensor.

Physical-space components use the same packed upper-triangular order as the constant overload: D00, D01, D11, D02, D12, D22. The field is borrowed and must outlive Apply(); changes to its values are visible on the next application. Implementations may change its interleaving. For homogeneous expansions these are the plane tensor components; the existing unit-coefficient homogeneous diffusion is retained.

Definition at line 273 of file HelmholtzOp.hpp.

275 {
276 ASSERTL0(diffCoeff.GetBlocks().size() == this->m_blockOp.size(),
277 "Diffusion coefficient blocks must match the expansion");
278 for (unsigned int blk = 0; blk < this->m_blockOp.size(); ++blk)
279 {
280 this->m_blockOp[blk]->SetVarDiffCoeff(diffCoeff.GetBlocks()[blk]);
281 }
282
283 m_isSetDiffCoeff = false;
284 m_isSetVarDiffCoeff = true;
285 }
#define ASSERTL0(condition, msg)

References ASSERTL0, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::MultiRegions::HelmholtzOp< TData >::m_blockOp, Nektar::MultiRegions::HelmholtzOp< TData >::m_isSetDiffCoeff, and Nektar::MultiRegions::HelmholtzOp< TData >::m_isSetVarDiffCoeff.

◆ v_Apply()

template<typename TData >
void Nektar::MultiRegions::HelmholtzOp< TData >::v_Apply ( LibUtilities::Field< TData, FieldState::Coeff > &  in,
LibUtilities::Field< TData, FieldState::Coeff > &  out 
)
inlineoverrideprotected

Apply the weak Helmholtz operator block by block.

Checks that in and out conform (equal component and homogeneous-mode counts) and that lambda and the diffusion tensor have been set, then hands each pair of blocks to the corresponding entry of m_blockOp. It then calls v_ApplyFFT(), which for a field with more than one homogeneous mode adds the weak z-Laplacian to out.

Parameters
inCoefficient-space input field.
outCoefficient-space output field; overwritten.

Definition at line 329 of file HelmholtzOp.hpp.

331 {
332 ASSERTL1(in.GetNumComponents() == out.GetNumComponents(),
333 "Number of input and output components differ");
334
335 ASSERTL1(in.GetNumHomoModes() == out.GetNumHomoModes(),
336 "Number of input and output homogeneous modes differ");
337
339 "lambda has not been set."
340 "Set the value with SetLambda() before calling Apply().");
341
343 "diffusion coefficient has not been set. "
344 "Set the value with SetDiffCoeff() or SetVarDiffCoeff() "
345 "before calling Apply().");
346
348 "can't set both DiffCoeff and VarDiffCoeff. "
349 "Set the value with SetDiffCoeff() or SetVarDiffCoeff() "
350 "before calling Apply().");
351
352 // Loop over the blocks.
353 for (unsigned int blk = 0; blk < this->m_blockOp.size(); ++blk)
354 {
355 // Block dependent.
356 auto &inblock = in.GetBlocks()[blk];
357 auto &outblock = out.GetBlocks()[blk];
358
359 this->m_blockOp[blk]->Apply(inblock, outblock);
360 }
361
362 // Apply FFT.
363 v_ApplyFFT(in, out);
364 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
virtual void v_ApplyFFT(LibUtilities::Field< TData, FieldState::Coeff > &in, LibUtilities::Field< TData, FieldState::Coeff > &out)=0
Weak z-Laplacian, called by v_Apply() after the block loop; adds it to every output block of a multi-...
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int const unsigned int const unsigned int const unsigned int const size_t const TData *NEK_RESTRICT const TData *NEK_RESTRICT const TUseSharedWsp TData *NEK_RESTRICT const TData *NEK_RESTRICT in
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int const unsigned int const unsigned int const unsigned int const size_t const TData *NEK_RESTRICT const TData *NEK_RESTRICT const TUseSharedWsp TData *NEK_RESTRICT const TData *NEK_RESTRICT TData *NEK_RESTRICT out

References ASSERTL1, Nektar::MultiRegions::HelmholtzOp< TData >::m_isSetDiffCoeff, Nektar::MultiRegions::HelmholtzOp< TData >::m_isSetLambda, Nektar::MultiRegions::HelmholtzOp< TData >::m_isSetVarDiffCoeff, and Nektar::MultiRegions::HelmholtzOp< TData >::v_ApplyFFT().

◆ v_ApplyFFT()

template<typename TData >
virtual void Nektar::MultiRegions::HelmholtzOp< TData >::v_ApplyFFT ( LibUtilities::Field< TData, FieldState::Coeff > &  in,
LibUtilities::Field< TData, FieldState::Coeff > &  out 
)
protectedpure virtual

Weak z-Laplacian, called by v_Apply() after the block loop; adds it to every output block of a multi-plane 3DH1 field and leaves any other field untouched.

Implemented in Nektar::MultiRegions::detail::HelmholtzOpImpl< ExecSpace, TData >.

Referenced by Nektar::MultiRegions::HelmholtzOp< TData >::v_Apply().

Friends And Related Symbol Documentation

◆ ElmtOp< FieldState::Coeff, FieldState::Coeff, TData >

template<typename TData >
friend class ElmtOp< FieldState::Coeff, FieldState::Coeff, TData >
friend

Definition at line 1 of file HelmholtzOp.hpp.

Member Data Documentation

◆ m_blockOp

template<typename TData >
std::vector<std::shared_ptr<HelmholtzBlockOp<TData> > > Nektar::MultiRegions::HelmholtzOp< TData >::m_blockOp
protected

◆ m_isSetDiffCoeff

template<typename TData >
bool Nektar::MultiRegions::HelmholtzOp< TData >::m_isSetDiffCoeff = false
protected

◆ m_isSetLambda

template<typename TData >
bool Nektar::MultiRegions::HelmholtzOp< TData >::m_isSetLambda = false
protected

◆ m_isSetVarDiffCoeff

template<typename TData >
bool Nektar::MultiRegions::HelmholtzOp< TData >::m_isSetVarDiffCoeff = false
protected

◆ name

template<typename TData >
const std::string Nektar::MultiRegions::HelmholtzOp< TData >::name = "Helmholtz"
inlinestatic

Operator base name; Create() appends the execution space to it to form the factory key.

Definition at line 212 of file HelmholtzOp.hpp.