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

#include <TestFwdTransBC.hpp>

Inheritance diagram for TestFwdTransBC< TData >:
[legend]

Public Member Functions

 TestFwdTransBC ()=default
 
void SetFixture (const unsigned int nhomo) override
 
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 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.
 

Private Member Functions

std::shared_ptr< MultiRegions::ContField > CreateBoundaryField (const std::string &variable) const
 
std::vector< MultiRegions::ExpListSharedPtr > GetBoundaryConditionExpansions () const
 
std::vector< TData > GetBoundaryPhysValues () const
 
size_t GetTotalBoundaryPoints (const std::vector< MultiRegions::ExpListSharedPtr > &boundaryExp) const
 
size_t GetTotalBoundaryCoeffs (const std::vector< MultiRegions::ExpListSharedPtr > &boundaryExp) const
 
template<FieldState TState>
std::vector< BlockAttributes< TState > > GetBoundaryBlockAttributes () const
 

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 TestFwdTransBC< TData >

Definition at line 49 of file TestFwdTransBC.hpp.

Constructor & Destructor Documentation

◆ TestFwdTransBC()

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

Member Function Documentation

◆ CreateBoundaryField()

template<typename TData >
std::shared_ptr< MultiRegions::ContField > TestFwdTransBC< TData >::CreateBoundaryField ( const std::string &  variable) const
inlineprivate

Definition at line 184 of file TestFwdTransBC.hpp.

186 {
188 auto bcfield =
190 this->session, graph, variable, true, false,
192 bcfield->EvaluateBoundaryConditions(0.0);
193
194 return bcfield;
195 }
SpatialDomains::MeshGraphSharedPtr graph
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
LibUtilities::SessionReaderSharedPtr session
Definition TestOp.hpp:440

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::Collections::eNoCollection, graph, Nektar::SpatialDomains::MeshGraphIO::Read(), and TestOp< TData, FieldState::Phys, FieldState::Coeff >::session.

Referenced by TestFwdTransBC< TData >::GetBoundaryConditionExpansions(), and TestFwdTransBC< TData >::GetBoundaryPhysValues().

◆ ExpectedSolution()

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

Definition at line 140 of file TestFwdTransBC.hpp.

141 {
142 const auto &components = this->session->GetVariables();
143 const auto nComp = components.size();
144 const auto boundaryExp = GetBoundaryConditionExpansions();
145 const auto totalPhys = GetTotalBoundaryPoints(boundaryExp);
146 const auto totalCoeffs = GetTotalBoundaryCoeffs(boundaryExp);
147 auto inPhys = this->fixt_in->template ToArray<double>();
148 Array<OneD, double> result(totalCoeffs * nComp, 0.0);
149 size_t physOffset = 0;
150 size_t coeffOffset = 0;
151
152 for (const auto &expList : boundaryExp)
153 {
154 const auto nphys = expList->GetTotPoints();
155 const auto ncoeffs = expList->GetNcoeffs();
157
158 for (unsigned int i = 0; i < nComp; ++i)
159 {
160 if (expList->GetExpType() == MultiRegions::e0D)
161 {
162 std::copy(inPhys.data() + i * totalPhys + physOffset,
163 inPhys.data() + i * totalPhys + physOffset +
164 ncoeffs,
165 result.data() + i * totalCoeffs + coeffOffset);
166 }
167 else
168 {
169 expList->FwdTransBndConstrained(
170 inPhys + i * totalPhys + physOffset,
171 tmp = result + i * totalCoeffs + coeffOffset);
172 }
173 }
174
175 physOffset += nphys;
176 coeffOffset += ncoeffs;
177 }
178
179 this->fixt_expected->template CopyArray<NektarSpaces::HostSpace>(
180 result);
181 }
size_t GetTotalBoundaryCoeffs(const std::vector< MultiRegions::ExpListSharedPtr > &boundaryExp) const
std::vector< MultiRegions::ExpListSharedPtr > GetBoundaryConditionExpansions() const
size_t GetTotalBoundaryPoints(const std::vector< MultiRegions::ExpListSharedPtr > &boundaryExp) const

References Nektar::MultiRegions::e0D, TestOp< TData, FieldState::Phys, FieldState::Coeff >::fixt_expected, TestOp< TData, FieldState::Phys, FieldState::Coeff >::fixt_in, TestFwdTransBC< TData >::GetBoundaryConditionExpansions(), TestFwdTransBC< TData >::GetTotalBoundaryCoeffs(), TestFwdTransBC< TData >::GetTotalBoundaryPoints(), and TestOp< TData, FieldState::Phys, FieldState::Coeff >::session.

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

◆ GetBoundaryBlockAttributes()

template<typename TData >
template<FieldState TState>
std::vector< BlockAttributes< TState > > TestFwdTransBC< TData >::GetBoundaryBlockAttributes ( ) const
inlineprivate

Definition at line 278 of file TestFwdTransBC.hpp.

279 {
280 const auto boundaryExp = GetBoundaryConditionExpansions();
281 std::vector<BlockAttributes<TState>> blockAttr;
282 size_t nBlocks = 0;
283 for (const auto &expList : boundaryExp)
284 {
285 nBlocks += GetBlockAttributes<TData, TState>(
286 expList, MultiRegions::UnitInterleaveWidths(expList))
287 .size();
288 }
289
290 blockAttr.reserve(nBlocks);
291 for (const auto &expList : boundaryExp)
292 {
293 auto bcBlockAttr = GetBlockAttributes<TData, TState>(
294 expList, MultiRegions::UnitInterleaveWidths(expList));
295 for (const auto &attr : bcBlockAttr)
296 {
297 blockAttr.emplace_back(attr);
298 }
299 }
300
301 return blockAttr;
302 }

References TestFwdTransBC< TData >::GetBoundaryConditionExpansions().

◆ GetBoundaryConditionExpansions()

template<typename TData >
std::vector< MultiRegions::ExpListSharedPtr > TestFwdTransBC< TData >::GetBoundaryConditionExpansions ( ) const
inlineprivate

Definition at line 197 of file TestFwdTransBC.hpp.

199 {
200 auto bcfield = CreateBoundaryField(this->session->GetVariables()[0]);
201 const auto &bndExp = bcfield->GetBndCondExpansions();
202
203 std::vector<MultiRegions::ExpListSharedPtr> result;
204 result.reserve(bndExp.size());
205 for (size_t i = 0; i < bndExp.size(); ++i)
206 {
207 result.push_back(bndExp[i]);
208 }
209
210 return result;
211 }
std::shared_ptr< MultiRegions::ContField > CreateBoundaryField(const std::string &variable) const

References TestFwdTransBC< TData >::CreateBoundaryField(), and TestOp< TData, FieldState::Phys, FieldState::Coeff >::session.

Referenced by TestFwdTransBC< TData >::ExpectedSolution(), TestFwdTransBC< TData >::GetBoundaryBlockAttributes(), TestFwdTransBC< TData >::GetBoundaryPhysValues(), and TestFwdTransBC< TData >::RunTestCase().

◆ GetBoundaryPhysValues()

template<typename TData >
std::vector< TData > TestFwdTransBC< TData >::GetBoundaryPhysValues ( ) const
inlineprivate

Definition at line 213 of file TestFwdTransBC.hpp.

214 {
215 const auto &components = this->session->GetVariables();
216 const auto nComp = components.size();
217 const auto boundaryExp = GetBoundaryConditionExpansions();
218 const auto totalPhys = GetTotalBoundaryPoints(boundaryExp);
219 const auto expType = this->fixt_explist->GetExpType();
220 std::vector<TData> result(totalPhys * nComp, 0.0);
221
222 for (unsigned int i = 0; i < nComp; ++i)
223 {
224 auto bcfield = CreateBoundaryField(components[i]);
225 const auto &bndExp = bcfield->GetBndCondExpansions();
226 size_t physOffset = 0;
227
228 for (size_t j = 0; j < bndExp.size(); ++j)
229 {
230 const auto &expList = bndExp[j];
231 const auto nphys = expList->GetTotPoints();
232
233 if (expType == MultiRegions::e1D)
234 {
235 const auto &coeffs = expList->GetCoeffs();
236 std::copy(coeffs.begin(), coeffs.begin() + nphys,
237 result.begin() + i * totalPhys + physOffset);
238 }
239 else
240 {
241 const auto &phys = expList->GetPhys();
242 std::copy(phys.begin(), phys.begin() + nphys,
243 result.begin() + i * totalPhys + physOffset);
244 }
245
246 physOffset += nphys;
247 }
248 }
249
250 return result;
251 }
std::shared_ptr< MultiRegions::ExpList > fixt_explist
Definition TestOp.hpp:439

References TestFwdTransBC< TData >::CreateBoundaryField(), Nektar::MultiRegions::e1D, TestOp< TData, FieldState::Phys, FieldState::Coeff >::fixt_explist, TestFwdTransBC< TData >::GetBoundaryConditionExpansions(), TestFwdTransBC< TData >::GetTotalBoundaryPoints(), and TestOp< TData, FieldState::Phys, FieldState::Coeff >::session.

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

◆ GetTotalBoundaryCoeffs()

template<typename TData >
size_t TestFwdTransBC< TData >::GetTotalBoundaryCoeffs ( const std::vector< MultiRegions::ExpListSharedPtr > &  boundaryExp) const
inlineprivate

Definition at line 265 of file TestFwdTransBC.hpp.

267 {
268 size_t totalCoeffs = 0;
269 for (const auto &expList : boundaryExp)
270 {
271 totalCoeffs += expList->GetNcoeffs();
272 }
273
274 return totalCoeffs;
275 }

Referenced by TestFwdTransBC< TData >::ExpectedSolution(), and TestFwdTransBC< TData >::RunTestCase().

◆ GetTotalBoundaryPoints()

template<typename TData >
size_t TestFwdTransBC< TData >::GetTotalBoundaryPoints ( const std::vector< MultiRegions::ExpListSharedPtr > &  boundaryExp) const
inlineprivate

Definition at line 253 of file TestFwdTransBC.hpp.

255 {
256 size_t totalPhys = 0;
257 for (const auto &expList : boundaryExp)
258 {
259 totalPhys += expList->GetTotPoints();
260 }
261
262 return totalPhys;
263 }

Referenced by TestFwdTransBC< TData >::ExpectedSolution(), TestFwdTransBC< TData >::GetBoundaryPhysValues(), and TestFwdTransBC< TData >::RunTestCase().

◆ RunTestCase()

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

Definition at line 83 of file TestFwdTransBC.hpp.

84 {
85 const auto &components = this->session->GetVariables();
86 const auto nComp = components.size();
87 const auto boundaryExp = GetBoundaryConditionExpansions();
88 const auto totalPhys = GetTotalBoundaryPoints(boundaryExp);
89 const auto totalCoeffs = GetTotalBoundaryCoeffs(boundaryExp);
90 auto inPhys = this->fixt_in->template ToArray<TData>();
91 std::vector<TData> result(totalCoeffs * nComp, 0.0);
92 size_t physOffset = 0;
93 size_t coeffOffset = 0;
94
95 for (const auto &expList : boundaryExp)
96 {
97 expList->SetDataWarehouse();
98
99 auto physBlocks = GetBlockAttributes<TData, FieldState::Phys>(
100 expList, MultiRegions::UnitInterleaveWidths(expList));
101 auto coeffBlocks = GetBlockAttributes<TData, FieldState::Coeff>(
102 expList, MultiRegions::UnitInterleaveWidths(expList));
103 Field<TData, FieldState::Phys> in("boundary phys", physBlocks,
104 nComp, 1);
105 Field<TData, FieldState::Coeff> out("boundary coeff", coeffBlocks,
106 nComp, 1);
107
108 const auto nphys = expList->GetTotPoints();
109 const auto ncoeffs = expList->GetNcoeffs();
110 Array<OneD, TData> localIn(nComp * nphys, 0.0);
111
112 for (unsigned int i = 0; i < nComp; ++i)
113 {
114 std::copy(inPhys.data() + i * totalPhys + physOffset,
115 inPhys.data() + i * totalPhys + physOffset + nphys,
116 localIn.data() + i * nphys);
117 }
118
119 in.template CopyArray<NektarSpaces::HostSpace>(localIn);
120 out.template Initialize<NektarSpaces::HostSpace>(0.0);
121
122 auto op = FwdTransBCOp<TData>::Create(expList, components);
123 op->Apply(in, out);
124
125 const auto outVec = out.template ToVector<TData>();
126 for (unsigned int i = 0; i < nComp; ++i)
127 {
128 std::copy(outVec.begin() + i * ncoeffs,
129 outVec.begin() + (i + 1) * ncoeffs,
130 result.begin() + i * totalCoeffs + coeffOffset);
131 }
132
133 physOffset += nphys;
134 coeffOffset += ncoeffs;
135 }
136
137 this->fixt_out->template CopyVector<NektarSpaces::HostSpace>(result);
138 }
A Field represents expansion data to be operated on.
static std::shared_ptr< FwdTransBCOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="")
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int const unsigned int const unsigned int const unsigned int const size_t const TData *NEK_RESTRICT const TData *NEK_RESTRICT const TUseSharedWsp TData *NEK_RESTRICT const TData *NEK_RESTRICT in
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int const unsigned int const unsigned int const unsigned int const size_t const TData *NEK_RESTRICT const TData *NEK_RESTRICT const TUseSharedWsp TData *NEK_RESTRICT const TData *NEK_RESTRICT TData *NEK_RESTRICT out

References Nektar::MultiRegions::FwdTransBCOp< TData >::Create(), TestOp< TData, FieldState::Phys, FieldState::Coeff >::fixt_in, TestOp< TData, FieldState::Phys, FieldState::Coeff >::fixt_out, TestFwdTransBC< TData >::GetBoundaryConditionExpansions(), TestFwdTransBC< TData >::GetTotalBoundaryCoeffs(), TestFwdTransBC< TData >::GetTotalBoundaryPoints(), and TestOp< TData, FieldState::Phys, FieldState::Coeff >::session.

◆ SetFixture()

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

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

Definition at line 54 of file TestFwdTransBC.hpp.

55 {
56 const auto &components = this->session->GetVariables();
57 auto inblockAttr = GetBoundaryBlockAttributes<FieldState::Phys>();
58 auto outblockAttr = GetBoundaryBlockAttributes<FieldState::Coeff>();
59
60 auto f_in = Field<TData, FieldState::Phys>("f_in", inblockAttr,
61 components, nhomo);
62 auto f_out = Field<TData, FieldState::Coeff>("f_out", outblockAttr,
63 components, nhomo);
64 auto f_expected = Field<TData, FieldState::Coeff>(
65 "f_expected", outblockAttr, components, nhomo);
66 this->fixt_in = new Field<TData, FieldState::Phys>(std::move(f_in));
67 this->fixt_out = new Field<TData, FieldState::Coeff>(std::move(f_out));
68 this->fixt_expected =
69 new Field<TData, FieldState::Coeff>(std::move(f_expected));
70 }

References TestOp< TData, FieldState::Phys, FieldState::Coeff >::fixt_expected, 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 TestFwdTransBC< TData >::SetTestCase ( )
inline

Definition at line 72 of file TestFwdTransBC.hpp.

73 {
74 this->fixt_in->template CopyVector<NektarSpaces::HostSpace>(
76
77 this->fixt_out->template Initialize<NektarSpaces::HostSpace>(0.0);
78
79 // Compute expected solution.
81 }
std::vector< TData > GetBoundaryPhysValues() const

References TestFwdTransBC< TData >::ExpectedSolution(), TestOp< TData, FieldState::Phys, FieldState::Coeff >::fixt_in, TestOp< TData, FieldState::Phys, FieldState::Coeff >::fixt_out, and TestFwdTransBC< TData >::GetBoundaryPhysValues().