69template <
typename TData>
71 :
public TestOp<TData, FieldState::Phys, FieldState::Phys,
72 MultiRegions::DisContField>
85 const int nmodes,
const int npts,
const TData tol)
96 for (
const bool lift : {
true,
false})
98 for (
const bool append : {
false,
true})
100 const TData scale = append ? TData(-0.7) : TData(1.0);
101 match =
RunVariant(lift, append, scale,
false, tol) && match;
102 if (GlobalConfiguration::ExecStr() ==
"AVX")
104 match =
RunVariant(lift, append, scale,
true, tol) && match;
123 const int nmodes,
const int npts)
126 for (
const auto &var : this->
session->GetVariables())
128 for (
const auto &expInfo :
graph->GetExpansionInfo(var))
130 expInfo.second->m_basisKeyVector =
132 expInfo.second->m_geomPtr, type, nmodes, npts);
135 const auto &vars = this->
session->GetVariables();
153 MultiRegions::detail::PhysLiftProjectForm::Pointwise)
157 const auto shape = exp->DetShapeType();
161 return exp->GetTotPoints() == 1;
168 const unsigned int dim = exp->GetShapeDimension();
169 const auto pointsKeys = exp->GetPointsKeys();
170 for (
unsigned int tr = 0; tr < dim; ++tr)
172 for (
unsigned int d = 0; d + 1 < dim; ++d)
174 if (!(pointsKeys[exp->GetGeom()->GetDir(tr, d)] ==
175 exp->GetTraceBasisKey(tr, d).GetPointsKey()))
188 GetBlockAttributes<TData, FieldState::Phys>(
192 for (
unsigned int blk = 0; blk < nblocks; ++blk)
197 const std::string name =
198 form == MultiRegions::detail::PhysLiftProjectForm::Pointwise
200 : form == MultiRegions::detail::PhysLiftProjectForm::StdInvMass
203 const bool deformed =
205 m_forms.insert(name + (deformed ?
"/deformed" :
"/affine") +
218 std::vector<TData> values = field.template ToVector<TData>();
219 for (
size_t i = 0; i < values.size(); ++i)
221 values[i] = TData(0.25) + std::sin(seed + TData(0.37) * i) +
222 TData(0.5) * std::cos(TData(1.3) * seed + 0.11 * i);
228 bool RunVariant(
const bool lift,
const bool append,
const TData scale,
229 const bool interleaved,
const TData tol)
232 const auto ncomp = this->
session->GetVariables().size();
233 const std::vector<std::string> comps(this->
session->GetVariables());
234 const auto physAttr = GetBlockAttributes<TData, FieldState::Phys>(
235 explist, MultiRegions::UnitInterleaveWidths(explist));
236 const auto coefAttr = GetBlockAttributes<TData, FieldState::Coeff>(
237 explist, MultiRegions::UnitInterleaveWidths(explist));
238 const auto traceAttr =
239 GetLocTraceBlockAttributes<TData, FieldState::Phys>(explist);
248 in.template Initialize<NektarSpaces::HostSpace>(0.0);
249 trace.template Initialize<NektarSpaces::HostSpace>(0.0);
250 out.template Initialize<NektarSpaces::HostSpace>(0.0);
251 expected.template Initialize<NektarSpaces::HostSpace>(0.0);
253 const auto inValues =
Values(in, 0.1);
254 const auto traceValues =
Values(trace, 0.7);
255 const auto outValues =
Values(out, 1.9);
256 in.template CopyVector<NektarSpaces::HostSpace>(inValues);
257 trace.template CopyVector<NektarSpaces::HostSpace>(traceValues);
258 sum.template CopyVector<NektarSpaces::HostSpace>(inValues);
261 out.template CopyVector<NektarSpaces::HostSpace>(outValues);
262 expected.template CopyVector<NektarSpaces::HostSpace>(outValues);
266 const std::string exec = GlobalConfiguration::ExecStr();
272 explist, comps, exec,
"Generic");
275 liftOp->SetAppend(
true);
276 bTransOp->SetIntegration(
false);
277 bTransOp->SetScale(scale);
278 bwdTransOp->SetAppend(append);
281 liftOp->Apply(trace,
sum);
283 bTransOp->Apply(
sum, coef);
284 invMassOp->Apply(coef, coef2);
285 bwdTransOp->Apply(coef2, expected);
290 op->SetAppend(append);
295 in.ReshapeStorage(interleaveWidth, exec);
300 op->Apply(in, trace, out);
307 bool match =
Matches(out.template ToVector<TData>(),
308 expected.template ToVector<TData>(), tol);
310 Matches(in.template ToVector<TData>(), inValues, TData(0)) && match;
312 Matches(trace.template ToVector<TData>(), traceValues, TData(0)) &&
316 std::cout <<
" mismatch: lift " << lift <<
", append " << append
317 <<
", interleaved " << interleaved << std::endl;
324 static bool Matches(
const std::vector<TData> &out,
325 const std::vector<TData> &expected,
const TData tol)
327 TData norm = 0, err = 0;
328 for (
size_t i = 0; i < out.size(); ++i)
330 norm = std::max(norm, std::abs(expected[i]));
331 err = std::max(err, std::isfinite(out[i])
332 ? std::abs(out[i] - expected[i])
333 : std::numeric_limits<TData>::max());
335 if (err > tol * norm)
337 std::cout <<
" max error " << err <<
" against max entry " << norm
346#if defined(NEKTAR_ENABLE_DOUBLE_PRECISION)
347#define TEST(type, filename) \
348 class type : public TestPhysLiftProject<double> \
353 meshName = filename; \
357#define TEST(type, filename)
362TEST(SegCurved, "run/segment_curved.xml")
363TEST(QuadTri, "run/square_all_elements.xml")
364TEST(QuadTriCurved, "run/square_all_elements_curved.xml")
366TEST(TriCurved, "run/tri_curved.xml")
368TEST(HexCurved, "run/hex_curved.xml")
370TEST(PrismCurved, "run/prism_curved.xml")
372TEST(PyrCurved, "run/pyr_curved.xml")
374TEST(TetCurved, "run/tet_curved.xml")
Public interface of the backward-transform (BwdTrans) element operator, which maps a field from coeff...
Whole-field interface of the IProductWRTBase element operator, which takes a physical-space field to ...
Public interface of the IProductWRTPhysTrace element operator, the discontinuous Galerkin lifting ter...
Whole-field interface of the MultiplyByElmtInvMass element operator, which multiplies a coefficient-s...
Public interface of the PhysLiftProject element operator: the trace lift followed by the projection t...
SpatialDomains::MeshGraphSharedPtr graph
#define TEST(type, filename)
std::map< int64_t, double > sum
std::vector< LocalRegions::ExpansionSharedPtr > & GetExpVector()
A Field represents expansion data to be operated on.
void ReshapeStorage(const unsigned int &interleaveWidth, const std::string &execSpace)
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static std::shared_ptr< BwdTransOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
Create a backward-transform operator through the operator and block-operator factories.
static std::shared_ptr< IProductWRTBaseOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
Build a complete IProductWRTBase operator through the operator and block-operator factories.
static std::shared_ptr< IProductWRTPhysTraceOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
Create a trace inner-product operator through the operator and block-operator factories.
static std::shared_ptr< MultiplyByElmtInvMassOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
Build a complete element-wise inverse mass operator through the operator and block-operator factories...
static std::shared_ptr< PhysLiftProjectOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
Create the operator through the operator and block-operator factories (see ElmtOp::Create()).
static LibUtilities::BasisKeyVector DefineBasisKeyFromExpansionType(Geometry *in, ExpansionType type, const int order, const int numpoints=-1)
The basis keys of expansion type type at order on in, with numpoints quadrature points in every direc...
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
std::shared_ptr< MultiRegions::ExpList > fixt_explist
LibUtilities::SessionReaderSharedPtr session
The lift-and-project operator against the chain it replaces, IProductWRTPhysTrace (appending) + IProd...
TestPhysLiftProject()=default
bool RunVariant(const bool lift, const bool append, const TData scale, const bool interleaved, const TData tol)
One variant: the operator and the chain from the same inputs.
bool RunExpansion(const SpatialDomains::ExpansionType type, const int nmodes, const int npts, const TData tol)
Run one expansion: type with nmodes modes and, when positive, npts points per direction (the type's o...
static std::vector< TData > Values(Field< TData, FieldState::Phys > &field, const TData seed)
Values for field, element-local and different in every entry and component.
void SetExpansions(const SpatialDomains::ExpansionType type, const int nmodes, const int npts)
Read the mesh and give every element type with nmodes modes and npts points, then build the expansion...
static bool DirectLift(const LocalRegions::ExpansionSharedPtr &exp)
Whether the Device SumFac and SumFacTOP implementations lift the trace of the block of exp directly a...
void RecordForms()
Note the form and geometry type of every block.
static bool Matches(const std::vector< TData > &out, const std::vector< TData > &expected, const TData tol)
Whether out matches expected within tol times the largest entry of expected.
std::set< std::string > m_forms
The forms and geometry types the cases run so far reached, as "Pointwise/affine" and so on,...
std::shared_ptr< Expansion > ExpansionSharedPtr
bool PhysLiftProjectDenseTail(const LocalRegions::ExpansionSharedPtr &exp)
Whether the Device SumFacTOP implementation applies the block whose representative expansion is exp t...
PhysLiftProjectForm PhysLiftProjectFormOf(const LocalRegions::ExpansionSharedPtr &exp)
The form the block whose representative expansion is exp takes. The square test is on the total count...
Collections::Collection GetCollection(MultiRegions::ExpListSharedPtr expansionList, unsigned int block_idx)
@ eDeformed
Geometry is curved or has non-constant factors.
typename abi< ScalarType, width >::type simd