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

#include <TestIProductWRTBase.hpp>

Inheritance diagram for TestIProductWRTBase< TData >:
[legend]

Public Member Functions

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

Definition at line 44 of file TestIProductWRTBase.hpp.

Constructor & Destructor Documentation

◆ TestIProductWRTBase()

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

Member Function Documentation

◆ ExpectedSolution()

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

Definition at line 87 of file TestIProductWRTBase.hpp.

88 {
89 // Calculate expected result from Nektar++
90 const unsigned int numComp = this->fixt_in->GetNumComponents();
91 const size_t ncoeffs = this->fixt_explist->GetNcoeffs();
92 const size_t nphys = this->fixt_explist->GetTotPoints();
93
94 Array<OneD, TData> inphys = this->fixt_in->ToArray();
95 Array<OneD, TData> outcoeffs(numComp * ncoeffs);
97 for (unsigned int i = 0; i < numComp; ++i)
98 {
99 this->fixt_explist->IProductWRTBase(inphys + i * nphys,
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::Phys, FieldState::Coeff >::fixt_expected, TestOp< TData, FieldState::Phys, FieldState::Coeff >::fixt_explist, TestOp< TData, FieldState::Phys, FieldState::Coeff >::fixt_in, Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), and Nektar::LibUtilities::Field< TData, TState >::ToArray().

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

◆ RunTestCase()

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

Definition at line 80 of file TestIProductWRTBase.hpp.

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

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

◆ SetTestCase()

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

Definition at line 50 of file TestIProductWRTBase.hpp.

51 {
52 // Set initial conditions.
53 for (unsigned int blk = 0; blk < this->fixt_in->GetBlocks().size();
54 ++blk)
55 {
56 auto &block = this->fixt_in->GetBlocks()[blk];
57 TData *inptr =
58 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
59
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 phys = 0; phys < block.GetNumData();
67 ++phys, ++cnt)
68 {
69 inptr[cnt] = phys + n;
70 }
71 }
72 inptr += block.CompSize();
73 }
74 }
75
76 // Compute expected solution.
78 }
SpatialDomains::Geometry * el
std::vector< BlockAccessor< TData, TState > > & GetBlocks()
Get BlockAccessors for the field.
unsigned int GetNumHomoModes() const
Gets the number of homogeneous modes.

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