12 #include "../tmop.hpp"
13 #include "../linearform.hpp"
14 #include "../pgridfunc.hpp"
15 #include "../tmop_tools.hpp"
16 #include "../quadinterpolator.hpp"
17 #include "../../general/forall.hpp"
18 #include "../../linalg/kernels.hpp"
26 MFEM_VERIFY(
PA.enabled,
"PA extension setup has not been done!");
27 MFEM_VERIFY(
PA.fes == &fes,
"");
35 PA.Jtr_debug_grad =
true;
59 MFEM_VERIFY(
PA.enabled,
"AssemblePA_Limiting but PA is not enabled!");
60 MFEM_VERIFY(
lim_func,
"No TMOP_LimiterFunction specification!")
61 MFEM_VERIFY(dynamic_cast<TMOP_QuadraticLimiter*>(
lim_func),
62 "Only TMOP_QuadraticLimiter is supported");
66 if (NE == 0) {
return; }
72 PA.H0.UseDevice(
true);
73 PA.H0.SetSize(
PA.dim *
PA.dim *
PA.nq * NE, mt);
76 PA.C0.UseDevice(
true);
78 dynamic_cast<ConstantCoefficient*>(
lim_coeff))
82 PA.C0(0) = cQ->constant;
88 for (
int e = 0; e < NE; ++e)
102 PA.X0.UseDevice(
true);
111 PA.LD.UseDevice(
true);
131 if (dim == 2) { done = ComputeAllElementTargets<2>(fes, ir, xe, Jtr); }
132 if (dim == 3) { done = ComputeAllElementTargets<3>(fes, ir, xe, Jtr); }
168 PA.Jtr_needs_update =
false;
169 PA.Jtr_debug_grad =
false;
171 if (
PA.ne == 0) {
return; }
186 if (ne == 0) {
return; }
188 MFEM_VERIFY(
PA.dim == 2 ||
PA.dim == 3,
"Not yet implemented!");
190 "mixed meshes are not supported");
191 MFEM_VERIFY(!fes.
IsVariableOrder(),
"variable orders are not supported");
196 "PA Only supports Ordering::byNODES!");
200 PA.maps = &fe.GetDofToQuad(ir, mode);
204 PA.E.UseDevice(
true);
208 PA.H.UseDevice(
true);
209 PA.H.SetSize(dim*dim * dim*dim * nq*ne, mt);
216 PA.Jtr.SetSize(dim, dim,
PA.ne*
PA.nq, mt);
217 PA.Jtr_needs_update =
true;
218 PA.Jtr_debug_grad =
false;
228 MFEM_VERIFY(
PA.Jtr_needs_update ==
false,
"");
232 MFEM_VERIFY(
PA.Jtr_debug_grad ==
true,
"AssembleGradPA() was not called"
233 " or Jtr was overwritten by another method!");
275 MFEM_VERIFY(
PA.Jtr_needs_update ==
false,
"");
279 MFEM_VERIFY(
PA.Jtr_debug_grad ==
true,
"AssembleGradPA() was not called or "
280 "Jtr was overwritten by another method!");
int GetNPoints() const
Returns the number of the points in the integration rule.
Abstract class for all finite elements.
virtual void AddMultGradPA(const Vector &, Vector &) const
Method for partially assembled gradient action.
void AssembleGradPA_2D(const Vector &) const
Ordering::Type GetOrdering() const
Return the ordering method.
void AddMultGradPA_C0_3D(const Vector &, Vector &) const
void AddMultPA_C0_2D(const Vector &, Vector &) const
Class for an integration rule - an Array of IntegrationPoint.
bool IsVariableOrder() const
Returns true if the space contains elements of varying polynomial orders.
Tensor product representation using 1D matrices/tensors with dimensions using 1D number of quadrature...
A coefficient that is constant across space and time.
const GeometricFactors * GetGeometricFactors(const IntegrationRule &ir, const int flags, MemoryType d_mt=MemoryType::DEFAULT)
Return the mesh geometric factors corresponding to the given integration rule.
double GetLocalStateEnergyPA_3D(const Vector &) const
const GridFunction * lim_dist
struct mfem::TMOP_Integrator::@23 PA
virtual double GetLocalStateEnergyPA(const Vector &) const
Compute the local (to the MPI rank) energy with partial assembly.
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
virtual void ComputeAllElementTargets(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
Computes reference-to-target transformation Jacobians for all quadrature points in all elements...
int GetNE() const
Returns number of elements.
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
const IntegrationRule * ir
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
virtual void AssembleGradPA(const Vector &, const FiniteElementSpace &)
Prepare the integrator for partial assembly (PA) gradient evaluations on the given FE space fes at th...
void AddMultGradPA_C0_2D(const Vector &, Vector &) const
void AssembleDiagonalPA_C0_2D(Vector &) const
Mesh * GetMesh() const
Returns the mesh.
void AssembleDiagonalPA_3D(Vector &) const
static MemoryType GetDeviceMemoryType()
Get the current Device MemoryType. This is the MemoryType used by most MFEM classes when allocating m...
static MemoryType GetMemoryType()
(DEPRECATED) Equivalent to GetDeviceMemoryType().
void AssembleDiagonalPA_2D(Vector &) const
const TargetConstructor * targetC
const GridFunction * lim_nodes0
virtual void AssemblePA(const FiniteElementSpace &)
Method defining partial assembly.
double GetLocalStateEnergyPA_2D(const Vector &) const
FiniteElementSpace * FESpace()
void AssemblePA_Limiting()
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i-th element.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
MemoryType
Memory types supported by MFEM.
bool UsesPhysicalCoordinates() const
Return true if the methods ComputeElementTargets(), ComputeAllElementTargets(), and ComputeElementTar...
double GetLocalStateEnergyPA_C0_2D(const Vector &) const
void AddMultGradPA_2D(const Vector &, Vector &) const
void AddMultPA_3D(const Vector &, Vector &) const
void AddMultPA_2D(const Vector &, Vector &) const
virtual const DofToQuad & GetDofToQuad(const IntegrationRule &ir, DofToQuad::Mode mode) const
Return a DofToQuad structure corresponding to the given IntegrationRule using the given DofToQuad::Mo...
void AssembleGradPA_C0_2D(const Vector &) const
Mode
Type of data stored in the arrays B, Bt, G, and Gt.
void AssembleDiagonalPA_C0_3D(Vector &) const
const FiniteElementSpace * fes
const IntegrationRule & EnergyIntegrationRule(const FiniteElement &el) const
ElementDofOrdering
Constants describing the possible orderings of the DOFs in one element.
void AssembleGradPA_3D(const Vector &) const
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
void AddMultGradPA_3D(const Vector &, Vector &) const
void ComputeAllElementTargets_Fallback(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
Lexicographic ordering for tensor-product FiniteElements.
const ElementRestrictionOperator * GetElementRestriction(ElementDofOrdering e_ordering) const
Return an Operator that converts L-vectors to E-vectors.
virtual void AssembleGradDiagonalPA(Vector &) const
Method for computing the diagonal of the gradient with partial assembly.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
void ComputeAllElementTargets(const Vector &xe=Vector()) const
double GetLocalStateEnergyPA_C0_3D(const Vector &) const
void AddMultPA_C0_3D(const Vector &, Vector &) const
Rank 3 tensor (array of matrices)
TMOP_LimiterFunction * lim_func
virtual void AddMultPA(const Vector &, Vector &) const
Method for partially assembled action.
void AssembleGradPA_C0_3D(const Vector &) const
MFEM_HOST_DEVICE DeviceTensor< sizeof...(Dims), T > Reshape(T *ptr, Dims...dims)
Wrap a pointer as a DeviceTensor with automatically deduced template parameters.
bool ComputeAllElementTargets(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const