Nektar++
Loading...
Searching...
No Matches
Public Member Functions | List of all members
TestAssmbScatr< TData > Class Template Reference

#include <TestAssmbScatr.hpp>

Inheritance diagram for TestAssmbScatr< TData >:
[legend]

Public Member Functions

 TestAssmbScatr ()=default
 
void SetTestCase (bool ZeroDir=false)
 
void RunTestCase ()
 
void RunTestCaseZeroDir ()
 
std::shared_ptr< AssmbScatrOp< TData > > CreateOp (bool ZeroDir=false)
 Create the operator under test, the zero-Dirichlet variant if ZeroDir is set.
 
void RunTestCaseAtWidth (AssmbScatrOp< TData > &op, const unsigned int interleaveWidth)
 Reshape the input to interleaveWidth and apply op to it.
 
void ExpectedSolution (bool ZeroDir=false)
 
- Public Member Functions inherited from TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >
 TestOp ()=default
 
virtual ~TestOp ()
 
void Configure (void)
 
void Configure3DH1 (const unsigned int nhomo=1)
 
void Configure3DH2 (const unsigned int nhomoY=1, const unsigned int nhomoZ=1)
 
void SetSession (void)
 
void SetExpList (void)
 
void SetExpList3DH1 (const unsigned int nhomo=1)
 
void SetExpList3DH2 (const unsigned int nhomoY=1, const unsigned int nhomoZ=1)
 
virtual void SetFixture (const unsigned int nhomo)
 
virtual bool Compare (TData tol)
 Compare this field to another field, with absolute tolerance tol. The two must have the same blocks and components; their interleave widths may differ.
 

Additional Inherited Members

- Static Public Member Functions inherited from TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >
static void MixInterleaveWidths (TField &field)
 Put the blocks of field at alternating interleave widths, the execution space's vector width on even blocks and 1 on odd ones, reshaping the data in place: a field whose blocks differ in width, for an operator that must read any mix, such as the trace flux, which addresses each trace at the width of the element block it lies in. On Serial every width is 1 and nothing changes.
 
- Protected Attributes inherited from TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >
std::string meshName
 
Field< TData, stateIn > * fixt_in
 
Field< TData, stateOut > * fixt_out
 
Field< TData, stateIn > * fixt_out_2
 
Field< TData, stateOut > * fixt_expected
 
std::shared_ptr< MultiRegions::ExpList > fixt_explist
 
LibUtilities::SessionReaderSharedPtr session
 

Detailed Description

template<typename TData>
class TestAssmbScatr< TData >

Definition at line 51 of file TestAssmbScatr.hpp.

Constructor & Destructor Documentation

◆ TestAssmbScatr()

template<typename TData >
TestAssmbScatr< TData >::TestAssmbScatr ( )
default

Member Function Documentation

◆ CreateOp()

template<typename TData >
std::shared_ptr< AssmbScatrOp< TData > > TestAssmbScatr< TData >::CreateOp ( bool  ZeroDir = false)
inline

Create the operator under test, the zero-Dirichlet variant if ZeroDir is set.

Definition at line 120 of file TestAssmbScatr.hpp.

121 {
122 if (ZeroDir)
123 {
125 this->fixt_explist, this->session->GetVariables());
126 }
128 this->session->GetVariables());
129 }
static std::shared_ptr< AssmbScatrOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="")
Create an assemble-scatter operator through the operator factory.
static std::shared_ptr< AssmbScatrZeroDirOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="")
Create an implementation of this operator through the operator factory.
std::shared_ptr< MultiRegions::ExpList > fixt_explist
Definition TestOp.hpp:439

References Nektar::MultiRegions::AssmbScatrOp< TData >::Create(), Nektar::MultiRegions::AssmbScatrZeroDirOp< TData >::Create(), TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >::fixt_explist, and TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >::session.

◆ ExpectedSolution()

template<typename TData >
void TestAssmbScatr< TData >::ExpectedSolution ( bool  ZeroDir = false)
inline

Definition at line 141 of file TestAssmbScatr.hpp.

142 {
143 std::vector<std::string> variables = this->session->GetVariables();
144 std::vector<std::shared_ptr<MultiRegions::ContField>> contfields;
146 unsigned int numComp = this->fixt_in->GetNumComponents();
147
148 for (auto &variable : variables)
149 {
150 contfields.push_back(
152 this->session, graph, variable, true, false,
154 }
155
156 // Calculate expected result from Nektar++.
157 size_t ncoeffs = this->fixt_explist->GetNcoeffs();
158 Array<OneD, double> incoeffs = this->fixt_in->ToArray();
159 Array<OneD, double> outcoeffs(numComp * ncoeffs);
160
161 for (unsigned int i = 0; i < variables.size(); ++i)
162 {
164 auto map = contfields[i]->GetLocalToGlobalMap();
165 map->Assemble(incoeffs + i * ncoeffs,
166 tmp = outcoeffs + i * ncoeffs);
167 if (ZeroDir)
168 {
169 Vmath::Zero(map->GetNumGlobalDirBndCoeffs(),
170 tmp = outcoeffs + i * ncoeffs, 1);
171 }
172 map->GlobalToLocal(outcoeffs + i * ncoeffs,
173 tmp = outcoeffs + i * ncoeffs);
174 }
175 this->fixt_expected->template CopyArray<NektarSpaces::HostSpace>(
176 outcoeffs);
177 }
SpatialDomains::MeshGraphSharedPtr graph
Nektar::Array< Nektar::OneD, TDataOut > ToArray()
Copy the data to a Nektar::Array, component by component and element by element, without padding,...
unsigned int GetNumComponents() const
Gets the number of components for a vector field.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
void Zero(int n, T *x, const int incx)
Zero vector.
Definition Vmath.hpp:275

References Nektar::Collections::eNoCollection, TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >::fixt_expected, TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >::fixt_explist, TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >::fixt_in, Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), graph, Nektar::SpatialDomains::MeshGraphIO::Read(), TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >::session, Nektar::LibUtilities::Field< TData, TState >::ToArray(), and Vmath::Zero().

Referenced by TestAssmbScatr< TData >::SetTestCase().

◆ RunTestCase()

template<typename TData >
void TestAssmbScatr< TData >::RunTestCase ( )
inline

Definition at line 86 of file TestAssmbScatr.hpp.

87 {
88 std::string execStr = Operator<TData>::GetOpExecSpace(this->session);
89
90 // reshape this->fixt_in
91 if (execStr == "AVX")
92 {
94 NektarSpaces::GetVectorWidth<TData>(execStr), execStr);
95 }
96
98 this->session->GetVariables());
99 op->Apply(*this->fixt_in, *this->fixt_out);
100 }
void ReshapeStorage(const unsigned int &interleaveWidth, const std::string &execSpace)
static std::string GetOpExecSpace(std::shared_ptr< LibUtilities::SessionReader > session, const bool warn=true)
Return the execution space name ("opExecSpace") for an operator.
Definition Operator.hpp:190

References Nektar::MultiRegions::AssmbScatrOp< TData >::Create(), TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >::fixt_explist, TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >::fixt_in, TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >::fixt_out, Nektar::MultiRegions::Operator< TData >::GetOpExecSpace(), Nektar::LibUtilities::Field< TData, TState >::ReshapeStorage(), and TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >::session.

◆ RunTestCaseAtWidth()

template<typename TData >
void TestAssmbScatr< TData >::RunTestCaseAtWidth ( AssmbScatrOp< TData > &  op,
const unsigned int  interleaveWidth 
)
inline

◆ RunTestCaseZeroDir()

template<typename TData >
void TestAssmbScatr< TData >::RunTestCaseZeroDir ( )
inline

◆ SetTestCase()

template<typename TData >
void TestAssmbScatr< TData >::SetTestCase ( bool  ZeroDir = false)
inline

Definition at line 58 of file TestAssmbScatr.hpp.

59 {
60 // Set initial conditions.
61 for (unsigned int blk = 0; blk < this->fixt_in->GetBlocks().size();
62 ++blk)
63 {
64 auto &block = this->fixt_in->GetBlocks()[blk];
65 auto inptr =
66 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
67 for (unsigned int nc = 0; nc < this->fixt_in->GetNumComponents();
68 ++nc)
69 {
70 for (size_t el = 0, cnt = 0; el < block.GetNumElements(); ++el)
71 {
72 for (unsigned int coeff = 0; coeff < block.GetNumData();
73 ++coeff, ++cnt)
74 {
75 inptr[cnt] = coeff + nc;
76 }
77 }
78 inptr += block.CompSize();
79 }
80 }
81
82 // Compute expected solution.
83 ExpectedSolution(ZeroDir);
84 }
SpatialDomains::Geometry * el
std::vector< BlockAccessor< TData, TState > > & GetBlocks()
Get BlockAccessors for the field.
void ExpectedSolution(bool ZeroDir=false)

References el, TestAssmbScatr< TData >::ExpectedSolution(), TestOp< TData, FieldState::Coeff, FieldState::Coeff, ContField >::fixt_in, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), and Nektar::LibUtilities::Field< TData, TState >::GetNumComponents().