37#include <SolverCore/Advection/AdvectionWeakDG/AdvectionWeakDGOp.hpp>
38#include <SolverCore/TraceFlux/TraceFluxOp.hpp>
50template <
typename TData>
52 :
public TestOp<TData, FieldState::Phys, FieldState::Phys,
53 MultiRegions::DisContField>
73 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
81 for (
size_t el = 0, cnt = 0;
el < block.GetNumElements(); ++
el)
86 for (
unsigned phys = 0; phys < block.GetNumData();
89 TData v = 1.0 + TData(n);
90 for (
unsigned d = 0; d < cdim; ++d)
92 v += TData(d + 1) * coords[d][phys];
97 inptr += block.CompSize();
100 eid += block.GetNumElements();
106 auto blocks_in = GetBlockAttributes<TData, FieldState::Phys>(
108 MultiRegions::UnitInterleaveWidths(this->
fixt_explist));
110 "f_advectVel", blocks_in, ndim, 1);
112 std::move(f_advectVel));
119 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
120 for (
unsigned nc = 0; nc < block.GetNumComponents(); ++nc)
122 for (
size_t el = 0, cnt = 0;
el < block.GetNumElements(); ++
el)
124 for (
unsigned phys = 0; phys < block.GetNumData();
131 inptr += block.CompSize();
138 for (
int i = 0; i < ndim; ++i)
143 auto blocks_trace = GetBlockAttributes<TData, FieldState::Phys>(
145 MultiRegions::UnitInterleaveWidths(this->fixt_explist->GetTrace()));
148 "f_traceAdvVel", blocks_trace, ndim, 1);
150 std::move(f_traceAdvVel));
158 block.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
159 for (
unsigned nc = 0; nc < block.GetNumComponents(); ++nc)
161 for (
size_t el = 0, cnt = 0;
el < block.GetNumElements(); ++
el)
163 for (
unsigned phys = 0; phys < block.GetNumData();
170 inptr += block.CompSize();
185 std::string riemName;
186 this->
session->LoadSolverInfo(
"UpwindType", riemName,
"Upwind");
191 riemName =
"ScalarTraceFlux" + riemName;
209 TraceFlux->SetTraceAdvVel(traceAdvVel);
212 AdvectOp->SetTraceFlux(TraceFlux);
217 AdvectOp->SetVolumeFluxOp(VolumeFluxOp);
228 std::string riemName;
229 this->
session->LoadSolverInfo(
"AdvectionType", advName,
"WeakDG");
234 this->
session->LoadSolverInfo(
"UpwindType", riemName,
"Upwind");
244 std::vector<std::string> variables = this->
session->GetVariables();
246 ASSERTL0(variables.size() >= numComp,
247 "numComp is larger than the number of variales");
249 for (
unsigned i = 0; i < numComp; ++i)
253 if (!this->
fixt_explist->GetExp(0)->IsBoundaryInteriorExpansion())
255 graph->ResetExpansionInfoToModified(variables[i]);
263 advObject->SetRiemannSolver(riemannSolver);
264 advObject->InitObject(this->
session, exp);
272 for (
unsigned i = 0; i < numComp; ++i)
275 for (
size_t j = 0; j < nphys; j++)
277 inarray[i][j] = in[i * nphys + j];
282 advObject->Advect(numComp, exp,
m_advectVel, inarray, outarray, 0);
284 for (
unsigned i = 0; i < numComp; ++i)
286 for (
size_t j = 0; j < nphys; ++j)
288 out[i * nphys + j] = outarray[i][j];
292 this->
fixt_expected->template CopyArray<NektarSpaces::HostSpace>(out);
297 const unsigned coordDim = this->
fixt_explist->GetCoordim(0);
298 const size_t nTracePts = this->
fixt_explist->GetTrace()->GetTotPoints();
305 for (
unsigned i = 0; i < coordDim; ++i)
310 this->
fixt_explist->GetTrace()->GetNormals(traceNormals);
313 for (
unsigned i = 0; i < coordDim; ++i)
315 for (
size_t j = 0; j < nTracePts; ++j)
330 "Dimension of flux array and velocity array do not match");
334 for (
int i = 0; i < flux.size(); ++i)
336 for (
int j = 0; j < flux[0].size(); ++j)
338 for (
int k = 0; k < nq; ++k)
340 flux[i][j][k] = physfield[i][k] *
m_advectVel[j][k];
355#if defined(NEKTAR_ENABLE_SINGLE_PRECISION)
356#define TESTFLOAT(type, filename) \
357 class type##float : public TestAdvectionWeakDG<float> \
362 meshName = filename; \
366#define TESTFLOAT(type, filename)
368#if defined(NEKTAR_ENABLE_DOUBLE_PRECISION)
369#define TESTDOUBLE(type, filename) \
370 class type : public TestAdvectionWeakDG<double> \
375 meshName = filename; \
379#define TESTDOUBLE(type, filename)
381#define TEST(type, filename) \
382 TESTFLOAT(type, filename) \
383 TESTDOUBLE(type, filename)
388TEST(SegOrtho, "run/Seg_Ortho_Dir.xml")
392TEST(TriOrtho, "run/Tri_Ortho_Dir.xml")
396TEST(Quad_Per, "run/Quad_Per.xml")
398TEST(QuadOrtho_Per, "run/Quad_Ortho_Per.xml")
400TEST(TriQuad_VarP, "run/TriQuad_varP_Dir.xml")
402TEST(Prism_VarP, "run/Prism_varP_Dir.xml")
406TEST(HexOrtho, "run/Hex_Ortho_Dir.xml")
408TEST(Hex_Per, "run/Hex_Per.xml")
412TEST(PrismOrtho, "run/Prism_Ortho_Dir.xml")
416TEST(PyrOrtho, "run/Pyr_Ortho_Dir.xml")
420TEST(TetOrtho, "run/Tet_Ortho_Dir.xml")
422TEST(CubeAllElements, "run/cube_all_elements_dir.xml")
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define TEST(type, filename)
SpatialDomains::MeshGraphSharedPtr graph
SpatialDomains::Geometry * el
A Field represents expansion data to be operated on.
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,...
std::vector< std::string > GetComponentNames() const
Gets a copy of the components names for a vector field.
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 std::shared_ptr< LinearAdvVolumeFluxOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="")
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)
void GetFluxVector(const Array< OneD, Array< OneD, TData > > &physfield, Array< OneD, Array< OneD, Array< OneD, TData > > > &flux)
TestAdvectionWeakDG()=default
LibUtilities::Field< TData, FieldState::Phys > * fixt_advectVel
Array< OneD, TData > m_traceAdvVel
Array< OneD, Array< OneD, TData > > m_advectVel
Array< OneD, TData > m_normalVel
LibUtilities::Field< TData, FieldState::Phys > * fixt_traceAdvVel
const Array< OneD, TData > & GetNormalVel()
std::shared_ptr< MultiRegions::ExpList > fixt_explist
Field< TData, stateOut > * fixt_out
Field< TData, stateIn > * fixt_in
Field< TData, stateOut > * fixt_expected
LibUtilities::SessionReaderSharedPtr session
template std::vector< BlockAttributes< FieldState::Phys > > GetLocTraceBlockAttributes< double, FieldState::Phys >(const MultiRegions::ExpListSharedPtr explist, const unsigned interleave_width, const bool useGLLTracePoints)
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
RiemannSolverFactory & GetRiemannSolverFactory()