39#include <SolverCore/NormOps/NormL2/NormL2Op.hpp>
40#include <SolverCore/NormOps/NormLinf/NormLinfOp.hpp>
117 const auto nphys =
m_expList->GetTotPoints();
126 for (
unsigned int blk = 0; blk <
m_in.
GetBlocks().size(); ++blk)
130 inblock.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
131 for (
unsigned int n = 0;
134 const auto scale =
static_cast<TData
>(n + 1);
135 for (
size_t el = 0, cnt = 0;
el < inblock.GetNumElements();
138 for (
unsigned int phys = 0; phys < inblock.GetNumData();
141 const auto xc =
static_cast<TData
>(x[cnt]);
142 const auto yc =
static_cast<TData
>(y[cnt]);
143 const auto zc =
static_cast<TData
>(z[cnt]);
146 static_cast<TData
>(0.3) * scale +
147 static_cast<TData
>(0.2) * scale * xc +
148 static_cast<TData
>(0.1) * (n + 2) * yc * yc -
149 static_cast<TData
>(0.05) * scale * zc;
151 const auto base_plus_error =
152 static_cast<TData
>(0.02) * scale *
153 (
static_cast<TData
>(1.0) + xc * xc +
154 static_cast<TData
>(0.5) * yc +
155 static_cast<TData
>(0.25) * zc * zc) +
156 static_cast<TData
>(0.003) * (n + 1) *
158 inptr[cnt] = base - base_plus_error;
161 inptr += inblock.CompSize();
190 std::string execStr =
195 l2Op->SetRootOnly(
true);
200 linfOp->SetRootOnly(
true);
219 std::cout <<
"Mismatch of norm vector sizes." << std::endl;
224 std::cout <<
" - Non-interleaved cases: " << std::endl;
225 for (
unsigned int comp = 0; comp < numComp; ++comp)
228 const auto l2NormalisedDiff = std::abs(
230 const auto linfDiff =
235 std::cout <<
"Component " << comp
236 <<
" mismatch: " <<
"L2(actual=" <<
m_l2Test[comp]
238 <<
", diff=" << l2Diff <<
")" << std::endl;
242 if (l2NormalisedDiff > tol)
244 std::cout <<
"Component " << comp <<
" mismatch: "
247 <<
", diff=" << l2NormalisedDiff <<
")" << std::endl;
253 std::cout <<
"Component " << comp
254 <<
" mismatch: " <<
"Linf(actual=" <<
m_linfTest[comp]
256 <<
", diff=" << linfDiff <<
")" << std::endl;
261 std::cout <<
" - Interleaved cases: " << std::endl;
262 for (
unsigned int comp = 0; comp < numComp; ++comp)
265 const auto l2NormalisedDiff = std::abs(
267 const auto linfDiff =
272 std::cout <<
"Component " << comp
273 <<
" mismatch: " <<
"L2(actual=" <<
m_l2Test2[comp]
275 <<
", diff=" << l2Diff <<
")" << std::endl;
279 if (l2NormalisedDiff > tol)
281 std::cout <<
"Component " << comp
282 <<
" mismatch: " <<
"L2 normalised(actual="
285 <<
", diff=" << l2NormalisedDiff <<
")" << std::endl;
291 std::cout <<
"Component " << comp <<
" mismatch: "
294 <<
", diff=" << linfDiff <<
")" << std::endl;
324 std::string execStr(GlobalConfiguration::ExecStr());
326 BOOST_TEST_MESSAGE(
"Creating input field");
332 char **argv =
new char *[argc];
333 argv[0] = strdup(
"exe_name");
335 argv[2] = strdup((
"--opExecSpace=" + execStr).c_str());
339 for (
int i = 0; i < argc; ++i)
369 const unsigned int ncomp =
m_session->GetVariables().size();
370 auto blockAttr = GetBlockAttributes<TData, FieldState::Phys>(
384 const auto nphys =
m_expList->GetTotPoints();
394 m_expList->GetPlane(0)->GetTotPoints(), 1.0)) *
401 for (
unsigned int comp = 0; comp < numComp; ++comp)
412#if defined(NEKTAR_ENABLE_SINGLE_PRECISION)
413#define TESTFLOAT(type, filename) \
414 class type##float : public TestNormOps<float> \
419 m_meshName = filename; \
423#define TESTFLOAT(type, filename)
425#if defined(NEKTAR_ENABLE_DOUBLE_PRECISION)
426#define TESTDOUBLE(type, filename) \
427 class type : public TestNormOps<double> \
432 m_meshName = filename; \
436#define TESTDOUBLE(type, filename)
438#define TEST(type, filename) \
439 TESTFLOAT(type, filename) \
440 TESTDOUBLE(type, filename)
445TEST(SegSEM, "run/line_sem.xml")
447TEST(Seg3D, "run/segment_3D.xml")
451TEST(Quad3D, "run/square_3D.xml")
453TEST(QuadVarP, "run/square_varp.xml")
455TEST(QuadSEM, "run/square_sem.xml")
459TEST(Tri3D, "run/tri_3D.xml")
461TEST(TriVarP, "run/tri_varp.xml")
463TEST(TriNodal, "run/tri_nodal.xml")
465TEST(SquareAllElements, "run/square_all_elements.xml")
469TEST(HexVarP, "run/hex_varp.xml")
471TEST(HexSEM, "run/hex_sem.xml")
475TEST(PrismVarP, "run/prism_varp.xml")
477TEST(PrismNodal, "run/prism_nodal.xml")
481TEST(PyrVarP, "run/pyr_varp.xml")
485TEST(TetVarP, "run/tet_varp.xml")
487TEST(TetNodal, "run/tet_nodal.xml")
489TEST(CubePrismHex, "run/cube_prismhex.xml")
491TEST(CubeAllElements, "run/cube_all_elements.xml")
493#include <UnitTests/TestBoostTeardown.hpp>
SpatialDomains::MeshGraphSharedPtr graph
#define NEKTAR_TEST_GLOBAL_CONFIGURATION(args)
#define TEST(type, filename)
SpatialDomains::Geometry * el
Describes the specification for a Basis.
A Field represents expansion data to be operated on.
void ReshapeStorage(const unsigned int &interleaveWidth, const std::string &execSpace)
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.
static std::string GetOpExecSpace(std::shared_ptr< LibUtilities::SessionReader > session, const bool warn=true)
Return the execution space name ("opExecSpace") for an operator.
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
std::vector< TData > m_linfTest
std::vector< TData > m_l2NormalisedTest2
std::vector< TData > m_linfTest2
void SetTestCase()
Fill the input field with an analytic expression and record the norms it is expected to have.
SessionReaderSharedPtr m_session
Field< TData, FieldState::Phys > m_in
unsigned int m_nhomo
Number of planes; 1 without a homogeneous direction.
static constexpr double m_homoLen
Homogeneous length of the 3DH1 cases, other than 1 so that it shows.
std::vector< TData > m_l2Test
std::vector< TData > m_l2Expected
void Configure()
Read the session, build the expansion list and allocate the field the test cases work on.
void Configure3DH1(const unsigned int nhomo)
As Configure, on a 3DH1 expansion list with nhomo planes.
std::vector< TData > m_l2NormalisedTest
void RunTestCase()
Apply the norm operators, once on the non-interleaved storage reduced to every rank and once on the i...
void ExpectedSolution()
The oracle: the norms the expansion list computes from the same data, independently of the operators ...
std::vector< TData > m_l2Test2
std::vector< TData > m_l2NormalisedExpected
ExpListSharedPtr m_expList
bool Compare(const TData tol)
Compare both sets of norms against the expected ones, with absolute tolerance tol.
std::vector< TData > m_linfExpected
std::shared_ptr< SessionReader > SessionReaderSharedPtr
@ eFourierEvenlySpaced
1D Evenly-spaced points using Fourier Fit
@ eFourier
Fourier Expansion .
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.