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

#include <TestMultiplyByElmtInvMass.hpp>

Inheritance diagram for TestMultiplyByElmtInvMass< TData >:
[legend]

Public Member Functions

 TestMultiplyByElmtInvMass ()=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 TestMultiplyByElmtInvMass< TData >

Definition at line 46 of file TestMultiplyByElmtInvMass.hpp.

Constructor & Destructor Documentation

◆ TestMultiplyByElmtInvMass()

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

Member Function Documentation

◆ ExpectedSolution()

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

Definition at line 85 of file TestMultiplyByElmtInvMass.hpp.

86 {
87 // Calculate expected result from Nektar++
88 unsigned int numComp = this->fixt_in->GetNumComponents();
89 size_t ncoeffs = this->fixt_explist->GetNcoeffs();
90
91 Array<OneD, TData> incoeffs = this->fixt_in->ToArray();
92 Array<OneD, TData> outcoeffs(ncoeffs * numComp), tmp;
93
94 // MultiplyByElmtInvMass is not virtual and builds its block matrix
95 // from the expansion list's own elements, so a homogeneous list is
96 // driven one plane at a time. The planes of a variable are
97 // consecutive within that variable's slice.
98 auto homoExpList =
99 std::dynamic_pointer_cast<MultiRegions::ExpListHomogeneous1D>(
100 this->fixt_explist);
101 const unsigned int nhomo = this->fixt_in->GetNumHomoModes();
102
103 if (homoExpList && nhomo > 1)
104 {
105 const size_t planeNcoeffs = ncoeffs / nhomo;
106 for (unsigned int i = 0; i < numComp; ++i)
107 {
108 for (unsigned int pl = 0; pl < nhomo; ++pl)
109 {
110 const size_t offset = i * ncoeffs + pl * planeNcoeffs;
111 homoExpList->GetPlane(pl)->MultiplyByElmtInvMass(
112 incoeffs + offset, tmp = outcoeffs + offset);
113 }
114 }
115 }
116 else
117 {
118 for (unsigned int i = 0; i < numComp; ++i)
119 {
120 this->fixt_explist->MultiplyByElmtInvMass(
121 incoeffs + i * ncoeffs, tmp = outcoeffs + i * ncoeffs);
122 }
123 }
124 this->fixt_expected->template CopyArray<NektarSpaces::HostSpace>(
125 outcoeffs);
126 }
Nektar::Array< Nektar::OneD, TDataOut > ToArray()
Copy the data to a Nektar::Array, component by component and element by element, without padding,...
unsigned int GetNumHomoModes() const
Gets the number of homogeneous modes.
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(), Nektar::LibUtilities::Field< TData, TState >::GetNumHomoModes(), and Nektar::LibUtilities::Field< TData, TState >::ToArray().

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

◆ RunTestCase()

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

Definition at line 78 of file TestMultiplyByElmtInvMass.hpp.

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

References Nektar::MultiRegions::MultiplyByElmtInvMassOp< 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 TestMultiplyByElmtInvMass< TData >::SetTestCase ( )
inline

Definition at line 52 of file TestMultiplyByElmtInvMass.hpp.

53 {
54 for (unsigned int blk = 0; blk < this->fixt_in->GetBlocks().size();
55 ++blk)
56 {
57 auto &block = this->fixt_in->GetBlocks()[blk];
58 auto inptr =
59 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
60 for (unsigned int n = 0; n < this->fixt_in->GetNumComponents() *
61 this->fixt_in->GetNumHomoModes();
62 ++n)
63 {
64 for (size_t el = 0, cnt = 0; el < block.GetNumElements(); ++el)
65 {
66 for (unsigned int coeff = 0; coeff < block.GetNumData();
67 ++coeff, ++cnt)
68 {
69 inptr[cnt] = coeff + n;
70 }
71 }
72 inptr += block.CompSize();
73 }
74 }
76 }
SpatialDomains::Geometry * el
std::vector< BlockAccessor< TData, TState > > & GetBlocks()
Get BlockAccessors for the field.

References el, TestMultiplyByElmtInvMass< 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().