42#include <SolverCore/PreconOps/PreconOp.hpp>
114 for (
unsigned int blk = 0; blk <
m_in.
GetBlocks().size(); ++blk)
118 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
119 for (
size_t el = 0, cnt = 0;
el < block.GetNumElements(); ++
el)
121 for (
unsigned int coeff = 0; coeff < block.GetNumData();
135 const auto coordDim =
m_expList->GetCoordim(0);
136 const auto nDiffCoeff = coordDim * (coordDim + 1) / 2;
143 else if (coordDim == 2)
175 auto lhs = std::make_shared<LHSOp<TData>>(
m_expList,
182 const unsigned int ncomp =
m_session->GetVariables().size();
185 GetBlockAttributes<TData, FieldState::Coeff>(
188 op->SetLambda(2.0 *
m_lambda + 1.0);
189 precon->Configure(lhs);
190 assmb->Apply(
m_in, first);
191 if (execStr ==
"AVX")
194 NektarSpaces::GetVectorWidth<TData>(execStr), execStr);
196 precon->Apply(first, first);
199 precon->Configure(lhs);
203 if (execStr ==
"AVX")
218 auto nin =
m_session->GetVariables().size();
228 auto map = std::dynamic_pointer_cast<ContField>(
m_expList)
229 ->GetLocalToGlobalMap();
235 precond->BuildPreconditioner();
236 for (
unsigned int n = 0; n < nin; n++)
239 precond->DoPreconditioner(incoeffs + n * ncoeff,
240 tmp = outcoeffs + n * ncoeff,
true);
242 m_expected.template CopyArray<NektarSpaces::HostSpace>(outcoeffs);
258 std::cout <<
"Mismatch of number of components." << std::endl;
264 std::cout <<
"Mismatch of number of homogeneous modes."
271 std::cout <<
"Mismatch of block size." << std::endl;
278 const std::vector<TData> out =
m_out.template ToVector<TData>();
279 const std::vector<TData> expected =
281 const size_t compSize =
288 printf(
"#elm #pts output expected "
291 size_t blkOffset = 0;
296 if ((outBlock.GetNumElements() != expBlock.GetNumElements()) ||
297 (outBlock.GetNumData() != expBlock.GetNumData()))
299 std::cout <<
"Mismatch of block structure." << std::endl;
302 const size_t nElmts = outBlock.GetNumElements();
303 const unsigned int nPts = outBlock.GetNumData();
305 for (
unsigned int n = 0;
308 const TData *outptr = out.data() + n * compSize + blkOffset;
309 const TData *expptr =
310 expected.data() + n * compSize + blkOffset;
311 size_t MisMatchcnt = 0, total = 0;
313 for (
size_t el = 0, cnt = 0;
el < nElmts; ++
el)
315 for (
unsigned int pts = 0; pts < nPts; ++pts, ++cnt)
317 if (std::isnan(outptr[cnt]) ||
318 std::isinf(outptr[cnt]) ||
319 std::abs(outptr[cnt] - expptr[cnt]) > tol)
321 printf(
"%04lu %04u %20.16f %20.16f %20.16f\n",
el,
322 pts, outptr[cnt], expptr[cnt],
323 std::abs(outptr[cnt] - expptr[cnt]));
332 std::cout <<
"Number of mismatches in component " << n
333 <<
" on block " << blk <<
" is " << MisMatchcnt
334 <<
" out of " << total <<
" on rank: " <<
rank
339 blkOffset += nElmts * nPts;
362 std::string execStr(GlobalConfiguration::ExecStr());
363 std::string implStr(GlobalConfiguration::ImplStr());
365 BOOST_TEST_MESSAGE(
"Creating input and output fields");
371 char **argv =
new char *[argc];
372 argv[0] = strdup(
"exe_name");
374 argv[2] = strdup((
"--opExecSpace=" + execStr).c_str());
375 argv[3] = strdup((
"--opImpl=" + implStr).c_str());
379 for (
int i = 0; i < argc; ++i)
401 const unsigned int ncomp =
m_session->GetVariables().size();
402 auto blockAttr = GetBlockAttributes<TData, FieldState::Coeff>(
413#if defined(NEKTAR_ENABLE_SINGLE_PRECISION)
414#define TESTFLOAT(type, filename) \
415 class type##float : public TestPreconOps<float> \
420 m_meshName = filename; \
424#define TESTFLOAT(type, filename)
426#if defined(NEKTAR_ENABLE_DOUBLE_PRECISION)
427#define TESTDOUBLE(type, filename) \
428 class type : public TestPreconOps<double> \
433 m_meshName = filename; \
437#define TESTDOUBLE(type, filename)
439#define TEST(type, filename) \
440 TESTFLOAT(type, filename) \
441 TESTDOUBLE(type, filename)
444TEST(Helmholtz1D_Seg,
"run/Helmholtz1D_P8.xml")
446TEST(Helmholtz1D_3C, "run/Helmholtz1D_3C.xml")
448TEST(Helmholtz2D_Tri_Quad, "run/Helmholtz2D_varP.xml")
450TEST(Helmholtz2D_AllBCs, "run/Helmholtz2D_P7_AllBCs.xml")
452TEST(Helmholtz2D_3C, "run/Helmholtz2D_3C.xml")
454TEST(Helmholtz3D_Hex, "run/Helmholtz3D_Hex_Heterogeneous.xml")
456TEST(Helmholtz3D_Hex_3C, "run/Helmholtz3D_Hex_3C.xml")
458TEST(Helmholtz3D_Prism, "run/Helmholtz3D_Prism_VarP.xml")
460TEST(Helmholtz3D_Pyr, "run/Helmholtz3D_Pyr_VarP.xml")
462TEST(Helmholtz3D_Tet, "run/Helmholtz3D_Tet_VarP.xml")
464#include <UnitTests/TestBoostTeardown.hpp>
Public interface for the assemble-scatter operator, which makes element-wise coefficient storage glob...
Public interface of the weak Helmholtz (Helmholtz) element operator, which maps a coefficient-space f...
SpatialDomains::MeshGraphSharedPtr graph
#define NEKTAR_TEST_GLOBAL_CONFIGURATION(args)
#define TEST(type, filename)
SpatialDomains::Geometry * el
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.
Nektar::Array< Nektar::OneD, TDataOut > ToArray()
Copy the data to a Nektar::Array, component by component and element by element, without padding,...
unsigned int GetNumHomoModes() const
Gets the number of homogeneous modes.
unsigned int GetNumComponents() const
Gets the number of components for a vector field.
tBasePtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
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::shared_ptr< AssmbScatrZeroDirOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="")
Create an implementation of this operator through the operator factory.
Describe a linear system.
static std::shared_ptr< HelmholtzOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
Create a weak-Helmholtz operator through the operator and block-operator factories.
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)
Compares a preconditioner operator against its legacy counterpart.
void SetTestCase(const std::string &method)
Set the input coefficients and the problem parameters, and record the result the preconditioner is ex...
void RunTestCase(const std::string &method)
Build the preconditioner for method, configure it against the Helmholtz operator and apply it to the ...
void Configure()
Read the session, build the continuous expansion list and allocate the fields the test cases work on.
SessionReaderSharedPtr m_session
Field< TData, FieldState::Coeff > m_out
void ExpectedSolution(const std::string &method)
The oracle: the legacy MultiRegions preconditioner of the same name, built on a GlobalLinSys for the ...
ExpListSharedPtr m_expList
Field< TData, FieldState::Coeff > m_in
Field< TData, FieldState::Coeff > m_expected
std::vector< TData > m_diffCoeff
bool Compare(TData tol)
Compare the computed field to the expected one, with absolute tolerance tol. The two must have the sa...
void SetExpList()
A continuous field: the preconditioners act on the assembled, globally continuous coefficients,...
std::shared_ptr< SessionReader > SessionReaderSharedPtr
GlobalLinSysFactory & GetGlobalLinSysFactory()
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
PreconFactory & GetPreconFactory()
std::map< ConstFactorType, NekDouble > ConstFactorMap
@ ExecAndImpl
exe – ExecName ImplName