40#include <SolverCore/GlobalLinSysOps/LinearSolvers/LinearSolverOp.hpp>
41#include <SolverCore/GlobalLinSysOps/LinearSystems/LinearADRSolve/LinearADRSolveOp.hpp>
42#include <SolverCore/PreconOps/PreconOp.hpp>
55template <
typename TData>
79 const unsigned int numComp =
81 const size_t nphys = this->
m_expList->GetTotPoints();
89 this->
m_in.template Initialize<NektarSpaces::HostSpace>(0.0);
91 if (this->
m_session->DefinesFunction(
"Forcing"))
93 for (
unsigned int n = 0; n < numComp; ++n)
96 "Forcing", n % this->
m_session->GetVariables().size());
98 func->Evaluate(x, y, z, fceVar);
102 for (
unsigned int blk = 0; blk < this->
m_in.
GetBlocks().size(); ++blk)
106 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
107 for (
unsigned int n = 0; n < numComp; ++n)
109 auto xptr = x.data();
110 auto yptr = y.data();
111 auto zptr = z.data();
112 auto fceptr = fce.data() + n * nphys;
114 for (
size_t el = 0, cnt = 0;
el < block.GetNumElements(); ++
el)
116 for (
unsigned int phys = 0; phys < block.GetNumData();
119 if (this->
m_session->DefinesFunction(
"Forcing"))
121 inptr[cnt] = *(fceptr++);
125 inptr[cnt] = 1.0 + n;
128 for (
unsigned int p = 1; p < 4; ++p)
131 (n + 1) * p * std::pow(*xptr, p);
137 for (
unsigned int p = 1; p < 4; ++p)
139 inptr[cnt] += (n + 1) * p *
148 for (
unsigned int p = 1; p < 4; ++p)
151 (n + 1) * p * std::pow(*xptr, p) *
152 std::pow(*yptr, p) * std::pow(*zptr, p);
162 inptr += block.CompSize();
166 this->
m_out.template Initialize<NektarSpaces::HostSpace>(0.0);
170 ? this->
m_session->GetParameter(
"Lambda")
208 auto advelblockAttr = GetBlockAttributes<TData, FieldState::Phys>(
210 MultiRegions::UnitInterleaveWidths(this->
m_expList));
213 vel.template CopyArray<NektarSpaces::HostSpace>(
m_vel);
215 std::string execStr(GlobalConfiguration::ExecStr());
216 std::string implStr(GlobalConfiguration::ImplStr());
219 if (implStr ==
"SumFac" || execStr ==
"AVX")
222 NektarSpaces::GetVectorWidth<TData>(execStr), execStr);
224 NektarSpaces::GetVectorWidth<TData>(execStr));
227 auto op = LinearADRSolveOp<TData>::Create(
233 linsolve->SetVerboseOutput(
true);
237 op->SetLinearSolver(linsolve);
238 op->SetPrecon(precon);
246 const unsigned int numComp =
248 const size_t nphys = this->
m_expList->GetTotPoints();
249 const size_t ncoeffs = this->
m_expList->GetNcoeffs();
250 const auto &variables = this->
m_session->GetVariables();
279 std::vector<StdRegions::VarCoeffType> velCoeffType = {
287 varcoeffs[velCoeffType[d]] = tmpVel;
293 for (
unsigned int n = 0; n < numComp; ++n)
300 expListVar->LinearAdvectionDiffusionReactionSolve(
301 inphysVar, outcoeffsVar, factors, varcoeffs);
305 this->
m_expected.template CopyArray<NektarSpaces::HostSpace>(outcoeffs);
334 const size_t nphys = this->
m_expList->GetTotPoints();
336 std::vector<StdRegions::VarCoeffType> velCoeffType = {
344 varcoeffs[velCoeffType[d]] = tmpVel;
351 const std::string &variable)
364 const size_t nphys = expListVar->GetTotPoints();
365 const size_t ncoeffs = expListVar->GetNcoeffs();
369 auto key = expListVar->LinearAdvectionDiffusionReactionSolve(
372 return expListVar->GenGlobalMatrixFull(
373 key, expListVar->GetLocalToGlobalMap());
379 const auto &variables = this->
m_session->GetVariables();
380 std::string iterSolver =
381 this->
m_session->DefinesSolverInfo(
"LinSysIterSolver")
382 ? this->
m_session->GetSolverInfo(
"LinSysIterSolver")
383 :
"ConjugateGradient";
384 std::string gmresSolver =
385 iterSolver.find(
"Loc") != std::string::npos ?
"GMRESLoc" :
"GMRES";
387 if (this->
m_session->DefinesSolverInfo(
"LinSysIterSolver"))
389 this->
m_session->SetSolverInfo(
"LinSysIterSolver", gmresSolver);
391 for (
const auto &var : variables)
393 this->
m_session->SetGlobalSysSolnInfo(var,
"GlobalSysSoln",
395 this->
m_session->SetGlobalSysSolnInfo(var,
"LinSysIterSolver",
409#if defined(NEKTAR_ENABLE_SINGLE_PRECISION)
410#define TESTFLOAT(type, filename) \
411 class type##float : public TestLinearADRSolve<float> \
416 m_meshName = filename; \
420#define TESTFLOAT(type, filename)
422#if defined(NEKTAR_ENABLE_DOUBLE_PRECISION)
423#define TESTDOUBLE(type, filename) \
424 class type : public TestLinearADRSolve<double> \
429 m_meshName = filename; \
433#define TESTDOUBLE(type, filename)
435#define TEST(type, filename) \
436 TESTFLOAT(type, filename) \
437 TESTDOUBLE(type, filename)
440TEST(Helmholtz1D_Seg,
"run/Helmholtz1D_P8.xml")
441TEST(Helmholtz1D_Seg_3C, "run/Helmholtz1D_3C.xml")
443TEST(Helmholtz2D_Tri_Quad, "run/Helmholtz2D_varP.xml")
444TEST(Helmholtz2D_Tri_Quad_3C, "run/Helmholtz2D_3C.xml")
446TEST(Helmholtz2D_AllBCs, "run/Helmholtz2D_P7_AllBCs.xml")
448TEST(Helmholtz3D_Hex, "run/Helmholtz3D_Hex_Heterogeneous.xml")
449TEST(Helmholtz3D_Hex_3C, "run/Helmholtz3D_Hex_3C.xml")
450TEST(Helmholtz3D_Hex_3C_Single, "run/Helmholtz3D_Hex_3C_Single.xml")
452TEST(Helmholtz3D_Prism, "run/Helmholtz3D_Prism_VarP.xml")
454TEST(Helmholtz3D_Pyr, "run/Helmholtz3D_Pyr_VarP.xml")
456TEST(Helmholtz3D_Tet, "run/Helmholtz3D_Tet_VarP.xml")
SpatialDomains::MeshGraphSharedPtr graph
#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.
void SetInterleaveWidth(const unsigned int &interleaveWidth)
unsigned int GetNumComponents() const
Gets the number of components for a vector field.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
This class is the abstraction of a global continuous two- dimensional spectral/hp element expansion w...
ContField()
The default constructor.
std::shared_ptr< DNekMat > GenGlobalMatrixFull(const GlobalLinSysKey &mkey, const std::shared_ptr< AssemblyMapCG > &locToGloMap)
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
void ConfigureExpectedSolverInfo()
StdRegions::ConstFactorMap BuildFactors() const
std::vector< TData > m_diffCoeff
std::shared_ptr< ContFieldMatrixAccessor > BuildExpectedExpList(const std::string &variable)
Array< OneD, TData > m_vel
TestLinearADRSolve()=default
StdRegions::VarCoeffMap BuildVarCoeffs(const Array< OneD, TData > &vel) const
DNekMatSharedPtr BuildGlobalADRMatrix(const std::string &variable, const Array< OneD, TData > &vel)
void RunTestCase(const std::string &method)
Field< TData, FieldState::Coeff > m_out
Field< TData, FieldState::Phys > m_in
ExpListSharedPtr m_expList
SessionReaderSharedPtr m_session
Field< TData, FieldState::Coeff > m_expected
std::map< ConstFactorType, NekDouble > ConstFactorMap
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
std::shared_ptr< DNekMat > DNekMatSharedPtr
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)