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

Per-block interface of the weak Laplacian: applies the operator to every element of one block. More...

#include <LaplacianBlockOp.hpp>

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

Public Member Functions

void SetDiffCoeff (std::vector< TData > &diffCoeff)
 Set the packed diffusion tensor for subsequent Apply() calls; see LaplacianOp::SetDiffCoeff for the packing order.
 
void SetVarDiffCoeff (LibUtilities::BlockAccessor< TData, FieldState::Phys > &diffCoeff)
 Borrow a physical-space tensor block in the constant tensor's order.
 
- Public Member Functions inherited from Nektar::MultiRegions::ElmtBlockOp< FieldState::Coeff, FieldState::Coeff, TData >
void Apply (LibUtilities::BlockAccessor< TData, TFieldIn > &inblock, LibUtilities::BlockAccessor< TData, TFieldOut > &outblock)
 Apply the element operation to every element of the block.
 
void operator() (LibUtilities::BlockAccessor< TData, TFieldIn > &inblock, LibUtilities::BlockAccessor< TData, TFieldOut > &outblock)
 Call operator; equivalent to Apply().
 
- Public Member Functions inherited from Nektar::MultiRegions::BlockOperator< TData >
virtual ~BlockOperator ()=default
 

Static Public Member Functions

static std::shared_ptr< LaplacianBlockOp< TData > > Create (const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse, const std::string &execStr, const std::string &implStr)
 Create one Laplacian block operator through the block-operator factory, under the key "BlockLaplacian" + execStr + implStr.
 
- Static Public Member Functions inherited from Nektar::MultiRegions::ElmtBlockOp< FieldState::Coeff, FieldState::Coeff, TData >
static std::shared_ptr< TOperator< TData > > Create (const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse, const std::string &execStr, const std::string &implStr)
 Create one block operator through the block-operator factory.
 
- Static Public Member Functions inherited from Nektar::MultiRegions::BlockOperator< TData >
template<template< typename > typename TOperator>
static std::shared_ptr< TOperator< TData > > Create (const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse, const std::string &execStr)
 Create a concrete block-operator instance through the block-operator factory.
 

Static Public Attributes

static const std::string name = "BlockLaplacian"
 Block-operator base name; Create() appends the execution space and implementation to it to form the factory key.
 

Protected Member Functions

 LaplacianBlockOp (const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse)
 Construct the interface part of a concrete block operator; called by the factory-registered creator functions.
 
 ~LaplacianBlockOp () override=default
 
- Protected Member Functions inherited from Nektar::MultiRegions::ElmtBlockOp< FieldState::Coeff, FieldState::Coeff, TData >
 ElmtBlockOp (const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse)
 Construct the interface part of a concrete block operator; called by the factory-registered creator functions.
 
 ~ElmtBlockOp () override=default
 
virtual void v_Apply (LibUtilities::BlockAccessor< TData, TFieldIn > &inblock, LibUtilities::BlockAccessor< TData, TFieldOut > &outblock)=0
 Implementation hook for Apply().
 
- Protected Member Functions inherited from Nektar::MultiRegions::BlockOperator< TData >
 BlockOperator (const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse)
 Construct the interface part of a concrete block operator; called by the factory-registered creator functions.
 

Protected Attributes

bool m_useDiffCoeff = false
 Apply the tensor; false selects the direct geometric metric for constant unit diffusion.
 
LibUtilities::BlockAccessor< TData, FieldState::Phys > * m_varDiffCoeff
 Non-owning pointer; values are read anew on every Apply().
 
LibUtilities::MemoryRegion< TData > m_diffCoeff
 Packed symmetric diffusion tensor; set by SetDiffCoeff() before Apply().
 
- Protected Attributes inherited from Nektar::MultiRegions::ElmtBlockOp< FieldState::Coeff, FieldState::Coeff, TData >
bool m_warnOnceTemplate
 Set once the generated ShapeBlock switch code has warned that an element size outside the templated switch range fell back to the runtime-sized OperatorND call, so that the warning is issued only once per block operator (see the BlockOpSwitch templates in LibUtilities/BasicUtils/Switch).
 
- Protected Attributes inherited from Nektar::MultiRegions::BlockOperator< TData >
unsigned int m_block_idx
 Index of the block within the expansion list's Collections.
 
LocalRegions::ExpansionSharedPtr m_exp
 Representative expansion of the block (its first element).
 
LibUtilities::NekDataWarehouseSharedPtr m_dataWarehouse
 Data warehouse shared with the other operators on the expansion list.
 

Additional Inherited Members

- Public Types inherited from Nektar::MultiRegions::ElmtBlockOp< FieldState::Coeff, FieldState::Coeff, TData >
using InBlock = LibUtilities::BlockAccessor< TData, TFieldIn >
 Accessor type of this operator's input block.
 
using OutBlock = LibUtilities::BlockAccessor< TData, TFieldOut >
 Accessor type of this operator's output block; see InBlock.
 
- Static Protected Member Functions inherited from Nektar::MultiRegions::ElmtBlockOp< FieldState::Coeff, FieldState::Coeff, TData >
static void ShapeSwitch (const LibUtilities::ShapeType shape, TFunc &&func)
 Call func with the runtime shape as a compile-time constant, std::integral_constant<LibUtilities::ShapeType, ...>.
 
static void DispatchAppendFlag (const bool append, TFunc &&func)
 Call func with std::true_type if append and std::false_type otherwise.
 
static void DispatchScaleFlag (const TData scale, TFunc &&func)
 Call func with std::false_type if scale is one and std::true_type otherwise.
 
static void DispatchDeformedFlag (const bool deformed, TFunc &&func)
 Call func with std::true_type if deformed and std::false_type otherwise.
 
- Static Protected Member Functions inherited from Nektar::MultiRegions::BlockOperator< TData >
template<typename MemSpace >
static TData * GetStaticWorkSpace (const size_t size, const unsigned int streamID=0)
 Return a per-stream scratch buffer in MemSpace, sized to hold at least size elements of TData, growing and reallocating it as needed.
 

Detailed Description

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

Per-block interface of the weak Laplacian: applies the operator to every element of one block.

Sets the block states accepted by Apply() – coefficient space in and out – and carries the diffusion tensor m_diffCoeff shared by all implementations. The concrete implementations are the detail::LaplacianBlockOpImpl definitions in the headers listed in LaplacianOp.hpp; CMake includes exactly one of them per generated translation unit, matching the execution-space/implementation pair that unit registers with the block-operator factory.

Template Parameters
TDataFloating-point type of the field data.
See also
ElmtBlockOp for the Apply()/v_Apply() contract; LaplacianOp for the whole-field interface driving this class.

Definition at line 74 of file LaplacianBlockOp.hpp.

Constructor & Destructor Documentation

◆ LaplacianBlockOp()

template<typename TData >
Nektar::MultiRegions::LaplacianBlockOp< TData >::LaplacianBlockOp ( const unsigned int  block_idx,
const LocalRegions::ExpansionSharedPtr &  exp,
LibUtilities::NekDataWarehouseSharedPtr  dataWarehouse 
)
inlineprotected

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

Parameters
block_idxIndex of the block within the expansion list's Collections.
expRepresentative expansion of the block.
dataWarehouseData warehouse shared with the other operators on the expansion list.

Definition at line 175 of file LaplacianBlockOp.hpp.

178 : ElmtBlockOp<FieldState::Coeff, FieldState::Coeff, TData>(
179 block_idx, exp, dataWarehouse)
180 {
181 }

◆ ~LaplacianBlockOp()

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

Member Function Documentation

◆ Create()

template<typename TData >
static std::shared_ptr< LaplacianBlockOp< TData > > Nektar::MultiRegions::LaplacianBlockOp< TData >::Create ( const unsigned int  block_idx,
const LocalRegions::ExpansionSharedPtr &  exp,
LibUtilities::NekDataWarehouseSharedPtr  dataWarehouse,
const std::string &  execStr,
const std::string &  implStr 
)
inlinestatic

Create one Laplacian block operator through the block-operator factory, under the key "BlockLaplacian" + execStr + implStr.

Parameters
block_idxIndex of the block within the expansion list's Collections.
expRepresentative expansion of the block (its first element).
dataWarehouseData warehouse shared with the other operators on the expansion list.
execStrExecution-space part of the factory key.
implStrImplementation part of the factory key.
Returns
The newly created block operator.

Definition at line 93 of file LaplacianBlockOp.hpp.

98 {
99 return ElmtBlockOp<FieldState::Coeff, FieldState::Coeff, TData>::
100 template Create<LaplacianBlockOp>(block_idx, exp, dataWarehouse,
101 execStr, implStr);
102 }

◆ SetDiffCoeff()

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

Set the packed diffusion tensor for subsequent Apply() calls; see LaplacianOp::SetDiffCoeff for the packing order.

The entries are copied into a MemoryRegion, from which the implementations obtain a pointer in the memory space they run in.

Parameters
diffCoeffPacked tensor entries.

Definition at line 117 of file LaplacianBlockOp.hpp.

118 {
119 const auto coordDim = this->m_exp->GetCoordim();
120 const auto nDiffCoeff = coordDim * (coordDim + 1) / 2;
121 ASSERTL0(diffCoeff.size() == nDiffCoeff,
122 "The number of diffusion coefficients must match 1, 3 or 6 "
123 "for a 1D, 2D or 3D case, respectively.")
124
125 this->m_diffCoeff = LibUtilities::MemoryRegion<
126 TData>::template FromVector<NektarSpaces::HostSpace>(diffCoeff);
128 for (unsigned int j = 0, c = 0; j < coordDim; ++j)
129 {
130 for (unsigned int i = 0; i <= j; ++i, ++c)
131 {
132 m_useDiffCoeff |= diffCoeff[c] != TData(i == j);
133 }
134 }
135 m_varDiffCoeff = nullptr;
136 }
#define ASSERTL0(condition, msg)
LocalRegions::ExpansionSharedPtr m_exp
Representative expansion of the block (its first element).
bool m_useDiffCoeff
Apply the tensor; false selects the direct geometric metric for constant unit diffusion.
LibUtilities::BlockAccessor< TData, FieldState::Phys > * m_varDiffCoeff
Non-owning pointer; values are read anew on every Apply().
LibUtilities::MemoryRegion< TData > m_diffCoeff
Packed symmetric diffusion tensor; set by SetDiffCoeff() before Apply().

References ASSERTL0, Nektar::MultiRegions::LaplacianBlockOp< TData >::m_diffCoeff, Nektar::MultiRegions::BlockOperator< TData >::m_exp, Nektar::MultiRegions::LaplacianBlockOp< TData >::m_useDiffCoeff, and Nektar::MultiRegions::LaplacianBlockOp< TData >::m_varDiffCoeff.

◆ SetVarDiffCoeff()

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

Borrow a physical-space tensor block in the constant tensor's order.

Definition at line 139 of file LaplacianBlockOp.hpp.

141 {
142 const auto coordDim = this->m_exp->GetCoordim();
143 ASSERTL0(diffCoeff.GetNumComponents() == coordDim * (coordDim + 1) / 2,
144 "Variable diffusion tensor must have 1, 3 or 6 components for "
145 "a 1D, 2D or 3D case, respectively.");
146 ASSERTL0(diffCoeff.GetNumData() == this->m_exp->GetTotPoints(),
147 "Diffusion coefficient must use the expansion quadrature");
148 m_varDiffCoeff = &diffCoeff;
149 m_useDiffCoeff = true;
150 }

References ASSERTL0, Nektar::LibUtilities::BlockAccessor< TData, TState >::GetNumComponents(), Nektar::LibUtilities::BlockAttributes< TState >::GetNumData(), Nektar::MultiRegions::BlockOperator< TData >::m_exp, Nektar::MultiRegions::LaplacianBlockOp< TData >::m_useDiffCoeff, and Nektar::MultiRegions::LaplacianBlockOp< TData >::m_varDiffCoeff.

Member Data Documentation

◆ m_diffCoeff

template<typename TData >
LibUtilities::MemoryRegion<TData> Nektar::MultiRegions::LaplacianBlockOp< TData >::m_diffCoeff
protected

◆ m_useDiffCoeff

template<typename TData >
bool Nektar::MultiRegions::LaplacianBlockOp< TData >::m_useDiffCoeff = false
protected

◆ m_varDiffCoeff

template<typename TData >
LibUtilities::BlockAccessor<TData, FieldState::Phys>* Nektar::MultiRegions::LaplacianBlockOp< TData >::m_varDiffCoeff
protected

◆ name

template<typename TData >
const std::string Nektar::MultiRegions::LaplacianBlockOp< TData >::name = "BlockLaplacian"
inlinestatic

Block-operator base name; Create() appends the execution space and implementation to it to form the factory key.

Definition at line 106 of file LaplacianBlockOp.hpp.