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

#include <TestMass.hpp>

Inheritance diagram for TestMass< TData >:
[legend]

Public Member Functions

 TestMass ()=default
 
void SetTestCase ()
 
void RunTestCase ()
 
void ExpectedSolution ()
 
- Public Member Functions inherited from TestOp< TData, FieldState::Coeff, FieldState::Coeff >
 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 >
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 >
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 TestMass< TData >

Definition at line 44 of file TestMass.hpp.

Constructor & Destructor Documentation

◆ TestMass()

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

Member Function Documentation

◆ ExpectedSolution()

template<typename TData >
void TestMass< TData >::ExpectedSolution ( )
inline

Definition at line 86 of file TestMass.hpp.

87 {
88 // Calculate expected result from Nektar++.
89 const unsigned int numComp = this->fixt_in->GetNumComponents();
90 const size_t ncoeffs = this->fixt_explist->GetNcoeffs();
91 const size_t nphys = this->fixt_explist->GetTotPoints();
92
93 Array<OneD, TData> incoeffs = this->fixt_in->ToArray();
94 Array<OneD, TData> bwdtrans(nphys);
95 Array<OneD, TData> outcoeffs(numComp * ncoeffs), tmp;
96 for (unsigned int i = 0; i < numComp; ++i)
97 {
98 this->fixt_explist->BwdTrans(incoeffs + i * ncoeffs, bwdtrans);
99 this->fixt_explist->IProductWRTBase(bwdtrans,
100 tmp = outcoeffs + i * ncoeffs);
101 }
102 this->fixt_expected->template CopyArray<NektarSpaces::HostSpace>(
103 outcoeffs);
104 }
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.
std::shared_ptr< MultiRegions::ExpList > fixt_explist
Definition TestOp.hpp:439

References TestOp< TData, FieldState::Coeff, FieldState::Coeff >::fixt_expected, TestOp< TData, FieldState::Coeff, FieldState::Coeff >::fixt_explist, TestOp< TData, FieldState::Coeff, FieldState::Coeff >::fixt_in, Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), and Nektar::LibUtilities::Field< TData, TState >::ToArray().

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

◆ RunTestCase()

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

Definition at line 79 of file TestMass.hpp.

80 {
81 auto op = MassOp<TData>::Create(this->fixt_explist,
82 this->session->GetVariables());
83 op->Apply(*this->fixt_in, *this->fixt_out);
84 }
static std::shared_ptr< MassOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
Build a complete Mass operator through the operator and block-operator factories.
Definition MassOp.hpp:155
LibUtilities::SessionReaderSharedPtr session
Definition TestOp.hpp:440

References Nektar::MultiRegions::MassOp< TData >::Create(), TestOp< TData, FieldState::Coeff, FieldState::Coeff >::fixt_explist, TestOp< TData, FieldState::Coeff, FieldState::Coeff >::fixt_in, TestOp< TData, FieldState::Coeff, FieldState::Coeff >::fixt_out, and TestOp< TData, FieldState::Coeff, FieldState::Coeff >::session.

◆ SetTestCase()

template<typename TData >
void TestMass< TData >::SetTestCase ( )
inline

Definition at line 49 of file TestMass.hpp.

50 {
51 // Set initial conditions.
52 for (unsigned int blk = 0; blk < this->fixt_in->GetBlocks().size();
53 ++blk)
54 {
55 auto &block = this->fixt_in->GetBlocks()[blk];
56 auto inptr =
57 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
58
59 for (unsigned int n = 0; n < this->fixt_in->GetNumComponents() *
60 this->fixt_in->GetNumHomoModes();
61 ++n)
62 {
63 for (size_t el = 0, cnt = 0; el < block.GetNumElements(); ++el)
64 {
65 for (unsigned int coeff = 0; coeff < block.GetNumData();
66 ++coeff, ++cnt)
67 {
68 inptr[cnt] = coeff + n;
69 }
70 }
71 inptr += block.CompSize();
72 }
73 }
74
75 // Compute expected solution.
77 }
SpatialDomains::Geometry * el
std::vector< BlockAccessor< TData, TState > > & GetBlocks()
Get BlockAccessors for the field.
unsigned int GetNumHomoModes() const
Gets the number of homogeneous modes.
void ExpectedSolution()
Definition TestMass.hpp:86

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