83template <
typename TData,
FieldState stateIn = FieldState::Coeff,
93 BOOST_TEST_MESSAGE(
"teardown fixture");
130 const unsigned int nhomoZ = 1)
141 std::string execStr(GlobalConfiguration::ExecStr());
142 std::string implStr(GlobalConfiguration::ImplStr());
144 BOOST_TEST_MESSAGE(
"Creating input and output fields");
150 char **argv =
new char *[argc];
151 argv[0] = strdup(
"exe_name");
153 argv[2] = strdup((
"--opExecSpace=" + execStr).c_str());
154 argv[3] = strdup((
"--opImpl=" + implStr).c_str());
158 for (
int i = 0; i < argc; ++i)
168 if constexpr (std::is_same_v<TExpList, MultiRegions::ContField>)
175 else if constexpr (std::is_same_v<TExpList, MultiRegions::DisContField>)
177 const auto &vars = this->
session->GetVariables();
178 const std::string var = vars.empty() ?
"DefaultVar" : vars[0];
185 else if constexpr (std::is_same_v<TExpList, MultiRegions::ExpList>)
197 if constexpr (std::is_same_v<TExpList, MultiRegions::ContField>)
209 else if constexpr (std::is_same_v<TExpList, MultiRegions::DisContField>)
220 else if constexpr (std::is_same_v<TExpList, MultiRegions::ExpList>)
235 const unsigned int nhomoZ = 1)
238 if constexpr (std::is_same_v<TExpList, MultiRegions::ContField>)
251 false,
false,
graph,
"u",
false,
254 else if constexpr (std::is_same_v<TExpList, MultiRegions::DisContField>)
267 false,
false,
graph,
"u",
270 else if constexpr (std::is_same_v<TExpList, MultiRegions::ExpList>)
291 auto nin = this->
session->GetVariables().size();
292 auto nout = this->
session->GetVariables().size();
293 auto inblockAttr = GetBlockAttributes<TData, stateIn>(
295 MultiRegions::UnitInterleaveWidths(this->
fixt_explist));
296 auto outblockAttr = GetBlockAttributes<TData, stateOut>(
298 MultiRegions::UnitInterleaveWidths(this->
fixt_explist));
319 const std::string execStr(GlobalConfiguration::ExecStr());
320 const unsigned vecWidth = NektarSpaces::GetVectorWidth<TData>(execStr);
321 for (
unsigned blk = 0; blk < field.GetBlocks().size(); ++blk)
323 field.GetBlocks()[blk].ReshapeStorage(blk % 2 ? 1u : vecWidth,
340 this->fixt_out->GetNumComponents())
342 std::cout <<
"Mismatch of number of components." << std::endl;
347 this->fixt_out->GetNumHomoModes())
349 std::cout <<
"Mismatch of number of homogeneous modes."
355 this->fixt_out->GetBlocks().size())
357 std::cout <<
"Mismatch of block size." << std::endl;
364 const std::vector<TData> out =
365 this->
fixt_out->template ToVector<TData>();
366 const std::vector<TData> expected =
370 const size_t compSize = out.size() / nCompHomo;
376 printf(
"#elm #pts output expected "
379 size_t blkOffset = 0;
385 if ((outBlock.GetNumElements() != expBlock.GetNumElements()) ||
386 (outBlock.GetNumData() != expBlock.GetNumData()))
388 std::cout <<
"Mismatch of block structure." << std::endl;
391 const size_t nElmts = outBlock.GetNumElements();
392 const unsigned int nPts = outBlock.GetNumData();
394 for (
unsigned int n = 0; n < nCompHomo; ++n)
396 const TData *outptr = out.data() + n * compSize + blkOffset;
397 const TData *expptr =
398 expected.data() + n * compSize + blkOffset;
399 size_t MisMatchcnt = 0, total = 0;
401 for (
size_t el = 0, cnt = 0;
el < nElmts; ++
el)
403 for (
unsigned int pts = 0; pts < nPts; ++pts, ++cnt)
405 if (std::isnan(outptr[cnt]) ||
406 std::isinf(outptr[cnt]) ||
407 std::abs(outptr[cnt] - expptr[cnt]) > tol)
409 printf(
"%04lu %04u %20.16f %20.16f %20.16f\n",
el,
410 pts, outptr[cnt], expptr[cnt],
411 std::abs(outptr[cnt] - expptr[cnt]));
420 std::cout <<
"Number of mismatches in component " << n
421 <<
" on block " << blk <<
" is " << MisMatchcnt
422 <<
" out of " << total <<
" on rank: " <<
rank
427 blkOffset += nElmts * nPts;
SpatialDomains::MeshGraphSharedPtr graph
#define NEKTAR_TEST_GLOBAL_CONFIGURATION(args)
SpatialDomains::Geometry * el
Describes the specification for a Basis.
A Field represents expansion data to be operated on.
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.
Defines a specification for a set of points.
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Base class for all multi-elemental spectral/hp expansions.
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
virtual bool Compare(TData tol)
Compare this field to another field, with absolute tolerance tol. The two must have the same blocks a...
void SetExpList3DH1(const unsigned int nhomo=1)
std::shared_ptr< MultiRegions::ExpList > fixt_explist
Field< TData, stateOut > * fixt_out
Field< TData, stateIn > * fixt_out_2
Field< TData, stateIn > * fixt_in
void Configure3DH1(const unsigned int nhomo=1)
void SetExpList3DH2(const unsigned int nhomoY=1, const unsigned int nhomoZ=1)
void Configure3DH2(const unsigned int nhomoY=1, const unsigned int nhomoZ=1)
virtual void SetFixture(const unsigned int nhomo)
Field< TData, stateOut > * fixt_expected
LibUtilities::SessionReaderSharedPtr session
static void MixInterleaveWidths(TField &field)
Put the blocks of field at alternating interleave widths, the execution space's vector width on even ...
std::shared_ptr< SessionReader > SessionReaderSharedPtr
@ eFourierEvenlySpaced
1D Evenly-spaced points using Fourier Fit
@ eFourier
Fourier Expansion .
@ ExecAndImpl
exe – ExecName ImplName
FieldState
Possible states for Field data.