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

#include <TestPhysTraceExtractBndCond.hpp>

Inheritance diagram for TestPhysTraceExtractBndCond< TData >:
[legend]

Public Member Functions

 TestPhysTraceExtractBndCond ()
 
void Configure (unsigned int boundaryRegionId)
 
void SetFixture (const unsigned int nhomo) override
 
void SetTestCase ()
 
void RunTestCase ()
 
template<typename ExecSpace >
void RunTestCase ()
 
- Public Member Functions inherited from TestOp< TData, FieldState::Phys, FieldState::Phys >
 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 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.
 

Protected Attributes

MultiRegions::ExpListSharedPtr m_bcExpList
 
unsigned int m_inputInterleaveWidth = 1
 Interleave width the volume field is given to Apply() at.
 
- Protected Attributes inherited from TestOp< TData, FieldState::Phys, FieldState::Phys >
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
 

Additional Inherited Members

- Static Public Member Functions inherited from TestOp< TData, FieldState::Phys, FieldState::Phys >
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.
 

Detailed Description

template<typename TData>
class TestPhysTraceExtractBndCond< TData >

Definition at line 59 of file TestPhysTraceExtractBndCond.hpp.

Constructor & Destructor Documentation

◆ TestPhysTraceExtractBndCond()

template<typename TData >
TestPhysTraceExtractBndCond< TData >::TestPhysTraceExtractBndCond ( )
inline

Member Function Documentation

◆ Configure()

template<typename TData >
void TestPhysTraceExtractBndCond< TData >::Configure ( unsigned int  boundaryRegionId)
inline

Definition at line 68 of file TestPhysTraceExtractBndCond.hpp.

69 {
70 this->SetSession();
71 this->SetExpList();
72 this->fixt_explist->SetDataWarehouse();
73
74 auto graph = this->fixt_explist->GetGraph();
76 const auto &bregions = bcs.GetBoundaryRegions();
77 const auto regionIter = bregions.find(boundaryRegionId);
78 ASSERTL0(regionIter != bregions.end(),
79 "Boundary region id not found in this mesh.");
80
81 const auto &vars = this->session->GetVariables();
83 this->session, *(regionIter->second), graph, true, vars[0], false,
84 this->session->GetComm(), Collections::eNoImpType);
85 m_bcExpList->SetDataWarehouse();
86
87 SetFixture(1);
88 }
#define ASSERTL0(condition, msg)
SpatialDomains::MeshGraphSharedPtr graph
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< MultiRegions::ExpList > fixt_explist
Definition TestOp.hpp:439
LibUtilities::SessionReaderSharedPtr session
Definition TestOp.hpp:440
void SetFixture(const unsigned int nhomo) override
MultiRegions::ExpListSharedPtr m_bcExpList

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::Collections::eNoImpType, TestOp< TData, FieldState::Phys, FieldState::Phys >::fixt_explist, Nektar::SpatialDomains::BoundaryConditions::GetBoundaryRegions(), graph, TestPhysTraceExtractBndCond< TData >::m_bcExpList, TestOp< TData, FieldState::Phys, FieldState::Phys >::session, TestOp< TData, FieldState::Phys, FieldState::Phys >::SetExpList(), TestPhysTraceExtractBndCond< TData >::SetFixture(), and TestOp< TData, FieldState::Phys, FieldState::Phys >::SetSession().

◆ RunTestCase() [1/2]

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

Definition at line 183 of file TestPhysTraceExtractBndCond.hpp.

184 {
185 const std::string execStr(GlobalConfiguration::ExecStr());
186 if (execStr == NektarSpaces::Serial::name)
187 {
188 RunTestCase<NektarSpaces::Serial>();
189 }
190 else if (execStr == NektarSpaces::AVX::name)
191 {
192 RunTestCase<NektarSpaces::AVX>();
193 }
194 else
195 {
197 "TestPhysTraceExtractBndCond runs on Serial and AVX, "
198 "not on " +
199 execStr);
200 }
201 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
static const std::string name
Definition Backends.hpp:107
static const std::string name
Definition Backends.hpp:101

References Nektar::ErrorUtil::efatal, Nektar::NektarSpaces::Serial::name, Nektar::NektarSpaces::AVX::name, and NEKERROR.

◆ RunTestCase() [2/2]

template<typename TData >
template<typename ExecSpace >
void TestPhysTraceExtractBndCond< TData >::RunTestCase ( )
inline

Definition at line 203 of file TestPhysTraceExtractBndCond.hpp.

204 {
206 this->fixt_explist, this->session->GetVariables(), m_bcExpList,
207 ExecSpace::name);
208
209 if (m_inputInterleaveWidth == 1)
210 {
211 op.Apply(*this->fixt_in, *this->fixt_out);
212 return;
213 }
214
215 // Extract at the wider interleave width, then again at width 1 into
216 // a cleared output, so that the gather index is built for both.
217 this->fixt_in->ReshapeStorage(m_inputInterleaveWidth, ExecSpace::name);
218 op.Apply(*this->fixt_in, *this->fixt_out);
219 BOOST_TEST(this->Compare(1.0E-10));
220
221 this->fixt_in->ReshapeStorage(1, ExecSpace::name);
222 for (auto &block : this->fixt_out->GetBlocks())
223 {
224 auto outptr =
225 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
226 std::fill(outptr,
227 outptr + block.CompSize() * block.GetNumComponents() *
228 block.GetNumHomoModes(),
229 TData(0));
230 }
231 op.Apply(*this->fixt_in, *this->fixt_out);
232 }
void ReshapeStorage(const unsigned int &interleaveWidth, const std::string &execSpace)
Extracts a volume field onto the points of a boundary region of a continuous field.
virtual bool Compare(TData tol)
Compare this field to another field, with absolute tolerance tol. The two must have the same blocks a...
Definition TestOp.hpp:335
unsigned int m_inputInterleaveWidth
Interleave width the volume field is given to Apply() at.

References Nektar::MultiRegions::detail::PhysTraceExtractBndCond< ExecSpace, TData >::Apply(), TestOp< TData, FieldState::Phys, FieldState::Phys >::Compare(), TestOp< TData, FieldState::Phys, FieldState::Phys >::fixt_explist, TestOp< TData, FieldState::Phys, FieldState::Phys >::fixt_in, TestOp< TData, FieldState::Phys, FieldState::Phys >::fixt_out, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), TestPhysTraceExtractBndCond< TData >::m_bcExpList, TestPhysTraceExtractBndCond< TData >::m_inputInterleaveWidth, Nektar::LibUtilities::Field< TData, TState >::ReshapeStorage(), and TestOp< TData, FieldState::Phys, FieldState::Phys >::session.

◆ SetFixture()

template<typename TData >
void TestPhysTraceExtractBndCond< TData >::SetFixture ( const unsigned int  nhomo)
inlineoverridevirtual

Reimplemented from TestOp< TData, FieldState::Phys, FieldState::Phys >.

Definition at line 90 of file TestPhysTraceExtractBndCond.hpp.

91 {
92 auto nvars = this->session->GetVariables().size();
93 auto inblockAttr = GetBlockAttributes<TData, FieldState::Phys>(
94 this->fixt_explist,
95 MultiRegions::UnitInterleaveWidths(this->fixt_explist));
96 auto outblockAttr = GetBlockAttributes<TData, FieldState::Phys>(
97 m_bcExpList, MultiRegions::UnitInterleaveWidths(m_bcExpList));
98
99 auto f_in =
100 Field<TData, FieldState::Phys>("f_in", inblockAttr, nvars, nhomo);
101 auto f_out =
102 Field<TData, FieldState::Phys>("f_out", outblockAttr, nvars, nhomo);
103 auto f_expected = Field<TData, FieldState::Phys>(
104 "f_expected", outblockAttr, nvars, nhomo);
105 this->fixt_in = new Field<TData, FieldState::Phys>(std::move(f_in));
106 this->fixt_out = new Field<TData, FieldState::Phys>(std::move(f_out));
107 this->fixt_expected =
108 new Field<TData, FieldState::Phys>(std::move(f_expected));
109 }
A Field represents expansion data to be operated on.

References TestOp< TData, FieldState::Phys, FieldState::Phys >::fixt_expected, TestOp< TData, FieldState::Phys, FieldState::Phys >::fixt_explist, TestOp< TData, FieldState::Phys, FieldState::Phys >::fixt_in, TestOp< TData, FieldState::Phys, FieldState::Phys >::fixt_out, TestPhysTraceExtractBndCond< TData >::m_bcExpList, and TestOp< TData, FieldState::Phys, FieldState::Phys >::session.

Referenced by TestPhysTraceExtractBndCond< TData >::Configure().

◆ SetTestCase()

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

Definition at line 111 of file TestPhysTraceExtractBndCond.hpp.

112 {
113 // Seed the volume field with u = x + 2y + 3z at every quadrature
114 // point, for every component.
115 for (unsigned blk = 0; blk < this->fixt_in->GetBlocks().size(); ++blk)
116 {
117 auto &block = this->fixt_in->GetBlocks()[blk];
118 auto collection =
120 const auto &expansions = collection.GetExpVector();
121
122 auto inptr =
123 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
124 for (unsigned n = 0; n < this->fixt_in->GetNumComponents() *
125 this->fixt_in->GetNumHomoModes();
126 ++n)
127 {
128 size_t cnt = 0;
129 for (size_t el = 0; el < expansions.size(); ++el)
130 {
131 const auto npts = expansions[el]->GetTotPoints();
132 // GetCoords() leaves z unset on a two-dimensional mesh.
133 Array<OneD, NekDouble> x(npts), y(npts), z(npts, 0.0);
134 expansions[el]->GetCoords(x, y, z);
135 for (int q = 0; q < npts; ++q, ++cnt)
136 {
137 inptr[cnt] = PhysTraceExtractBndCondTestFn<TData>(
138 static_cast<TData>(x[q]), static_cast<TData>(y[q]),
139 static_cast<TData>(z[q]));
140 }
141 }
142 inptr += block.CompSize();
143 }
144 }
145
146 // Expected: evaluate the same polynomial directly at the boundary
147 // region's own coordinates.
148 for (unsigned blk = 0; blk < this->fixt_expected->GetBlocks().size();
149 ++blk)
150 {
151 auto &block = this->fixt_expected->GetBlocks()[blk];
152 auto collection = MultiRegions::GetCollection(m_bcExpList, blk);
153 const auto &expansions = collection.GetExpVector();
154
155 auto expptr =
156 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
157 for (unsigned n = 0; n < this->fixt_expected->GetNumComponents() *
159 ++n)
160 {
161 size_t cnt = 0;
162 for (size_t el = 0; el < expansions.size(); ++el)
163 {
164 const auto npts = expansions[el]->GetTotPoints();
165 // GetCoords() leaves z unset on a two-dimensional mesh.
166 Array<OneD, NekDouble> x(npts), y(npts), z(npts, 0.0);
167 expansions[el]->GetCoords(x, y, z);
168 for (int q = 0; q < npts; ++q, ++cnt)
169 {
170 expptr[cnt] = PhysTraceExtractBndCondTestFn<TData>(
171 static_cast<TData>(x[q]), static_cast<TData>(y[q]),
172 static_cast<TData>(z[q]));
173 }
174 }
175 expptr += block.CompSize();
176 }
177 }
178 }
SpatialDomains::Geometry * el
std::vector< BlockAccessor< TData, TState > > & GetBlocks()
Get BlockAccessors for the field.
unsigned int GetNumHomoModes() const
Gets the number of homogeneous modes.
unsigned int GetNumComponents() const
Gets the number of components for a vector field.
Collections::Collection GetCollection(MultiRegions::ExpListSharedPtr expansionList, unsigned int block_idx)

References el, TestOp< TData, FieldState::Phys, FieldState::Phys >::fixt_expected, TestOp< TData, FieldState::Phys, FieldState::Phys >::fixt_explist, TestOp< TData, FieldState::Phys, FieldState::Phys >::fixt_in, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::MultiRegions::GetCollection(), Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), Nektar::LibUtilities::Field< TData, TState >::GetNumHomoModes(), and TestPhysTraceExtractBndCond< TData >::m_bcExpList.

Member Data Documentation

◆ m_bcExpList

template<typename TData >
MultiRegions::ExpListSharedPtr TestPhysTraceExtractBndCond< TData >::m_bcExpList
protected

◆ m_inputInterleaveWidth

template<typename TData >
unsigned int TestPhysTraceExtractBndCond< TData >::m_inputInterleaveWidth = 1
protected

Interleave width the volume field is given to Apply() at.

Definition at line 237 of file TestPhysTraceExtractBndCond.hpp.

Referenced by TestPhysTraceExtractBndCond< TData >::RunTestCase().