23 MFEM_VERIFY(
PA.enabled,
"PA extension setup has not been done!");
24 MFEM_VERIFY(
PA.fes == &
fes,
"");
42 PA.Jtr_debug_grad =
true;
68 MFEM_VERIFY(
PA.enabled,
"AssemblePA_Limiting but PA is not enabled!");
69 MFEM_VERIFY(
lim_func,
"No TMOP_LimiterFunction specification!")
73 "Only TMOP_QuadraticLimiter and TMOP_ExponentialLimiter are supported");
77 if (NE == 0) {
return; }
84 PA.H0.SetSize(
PA.dim *
PA.dim *
PA.nq * NE, mt);
87 PA.C0.UseDevice(
true);
92 PA.C0(0) = cQ->constant;
98 for (
int e = 0; e < NE; ++e)
112 PA.XL.UseDevice(
true);
121 PA.LD.UseDevice(
true);
127 else {
PA.LD = 1.0; }
174 PA.Jtr_needs_update =
false;
175 PA.Jtr_debug_grad =
false;
177 if (
PA.ne == 0) {
return; }
182 "TMOP_Integrator::ComputeAllElementTargets() called with "
183 "different IntegrationRule than the one used in AssemblePA()!");
204 const int nal =
PA.nal;
205 const bool alc_is_qvec =
206 (
nal > 0) ? (
PA.ALC.Size() ==
nal *
PA.nq *
PA.ne) :
false;
207 if (
PA.MC.Size() == 1 &&
PA.C0.Size() <= 1 && !alc_is_qvec) {
return; }
212 if (alc_is_qvec) {
PA.ALC.HostWrite(); }
216 for (
int e = 0; e <
PA.ne; ++e)
219 PA.fes->GetMesh()->GetElementTransformation(e, x_loc, T);
221 if (
PA.MC.Size() > 1)
223 for (
int q = 0; q <
PA.nq; ++q)
229 if (
PA.C0.Size() > 1)
231 for (
int q = 0; q <
PA.nq; ++q)
240 for (
int c = 0; c <
nal; c++)
243 for (
int q = 0; q <
PA.nq; ++q)
245 ALC_c[q + e *
PA.nq] =
263 if (
ne == 0) {
return; }
266 MFEM_VERIFY(
PA.dim == 2 ||
PA.dim == 3,
"Not yet implemented!");
268 "TMOP+PA does not support mixed meshes.");
271 "TMOP+PA only supports squares and cubes.");
274 "TMOP+PAP only supports Ordering::byNODES!");
291 PA.X0.UseDevice(
true);
297 PA.E.UseDevice(
true);
301 PA.H.UseDevice(
true);
305 PA.O.UseDevice(
true);
315 PA.MC(0) = cc->constant;
321 for (
int e = 0; e <
PA.ne; ++e)
341 PA.Jtr_needs_update =
true;
342 PA.Jtr_debug_grad =
false;
354 MFEM_VERIFY(
nal > 0,
"internal error");
359 MFEM_VERIFY(alfes && alfes->
GetVDim() == 1,
"internal error");
361 MFEM_VERIFY(strcmp(alfes->
FEColl()->
Name(),
PA.fes->FEColl()->Name()) == 0 &&
363 "The PA code assumes the same FE spaces for mesh and limiting.");
365 PA.AL_grads_assembled =
false;
371 bool all_const =
true;
372 for (
int c = 0; c <
nal; c++)
380 PA.ALC.UseDevice(
true);
384 real_t *ALC_all =
PA.ALC.HostWrite();
385 for (
int c = 0; c <
nal; c++)
388 MFEM_VERIFY(cc,
"internal error");
389 ALC_all[c] = cc->constant;
397 real_t *ALC_all =
PA.ALC.HostWrite();
398 for (
int c = 0; c <
nal; c++)
401 for (
int e = 0; e <
PA.ne; ++e)
404 for (
int q = 0; q <
PA.ir->GetNPoints(); ++q)
406 ALC_c[q + e *
PA.nq] =
421 const Array<int> *lex = (nfe && nfe->GetLexicographicOrdering().Size() > 0)
422 ? &nfe->GetLexicographicOrdering() :
nullptr;
430 MFEM_VERIFY(lex->
Size() ==
nodes.GetNPoints(),
"");
431 for (
int i = 0; i <
nodes.GetNPoints(); i++)
441 const int ndofs = alfes->
GetVSize();
443 const int Esize = alf_R->
Height();
445 PA.ALF.UseDevice(
true);
447 PA.ALFmF0.UseDevice(
true);
450 for (
int c = 0; c <
nal; c++)
453 ALF0c.
MakeRef(
PA.ALFmF0, c * Esize, Esize);
455 MFEM_VERIFY(
adapt_lim_gf[c]->Size() == ndofs,
"internal error");
456 MFEM_VERIFY(
adapt_lim_gf0[c]->Size() == ndofs,
"internal error");
473 const int dim =
PA.dim;
476 PA.ALFH.UseDevice(
true);
485 MFEM_VERIFY(
PA.Jtr_needs_update ==
false,
"");
489 MFEM_VERIFY(
PA.Jtr_debug_grad ==
true,
490 "AssembleGradPA() was not called"
491 " or Jtr was overwritten by another method!");
559 MFEM_VERIFY(
PA.Jtr_needs_update ==
false,
"");
563 MFEM_VERIFY(
PA.Jtr_debug_grad ==
true,
564 "AssembleGradPA() was not called or "
565 "Jtr was overwritten by another method!");
void ComputeAllElementTargets(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const override
Computes reference-to-target transformation Jacobians for all quadrature points in all elements.
int Size() const
Return the logical size of the array.
void UseDevice(bool use_dev) const
Set the device flag of the Array, i.e. the device flag of the Memory object used by the Array.
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
A coefficient that is constant across space and time.
Rank 3 tensor (array of matrices)
static MemoryType GetMemoryType()
(DEPRECATED) Equivalent to GetDeviceMemoryType().
static MemoryType GetDeviceMemoryType()
Get the current Device MemoryType. This is the MemoryType used by most MFEM classes when allocating m...
Mode
Type of data stored in the arrays B, Bt, G, and Gt.
@ TENSOR
Tensor product representation using 1D matrices/tensors with dimensions using 1D number of quadrature...
int GetOrder() const
Return the order (polynomial degree) of the FE collection, corresponding to the order/degree returned...
virtual const char * Name() const
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
bool IsVariableOrder() const
Returns true if the space contains elements of varying polynomial orders.
ElementTransformation * GetElementTransformation(int i) const
Ordering::Type GetOrdering() const
Return the ordering method.
const ElementRestrictionOperator * GetElementRestriction(ElementDofOrdering e_ordering) const
Return an Operator that converts L-vectors to E-vectors.
const FiniteElementCollection * FEColl() const
Mesh * GetMesh() const
Returns the mesh.
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
int GetVDim() const
Returns the vector dimension of the finite element space.
const FiniteElement * GetTypicalFE() const
Return GetFE(0) if the local mesh is not empty; otherwise return a typical FE based on the Geometry t...
Abstract class for all finite elements.
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...
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
int GetDof() const
Returns the number of degrees of freedom in the finite element.
FiniteElementSpace * FESpace()
Class for an integration rule - an Array of IntegrationPoint.
int GetNPoints() const
Returns the number of the points in the integration rule.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
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.
bool HasGeometry(Geometry::Type geom) const
Return true iff the given geom is encountered in the mesh. Geometries of dimensions lower than Dimens...
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
Class for standard nodal finite elements.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
Exponential limiter function in TMOP_Integrator.
void AddMultGradPA(const Vector &, Vector &) const override
Method for partially assembled gradient action.
real_t GetLocalStateEnergyPA_AdaptLim_2D() const
void GetLocalStateEnergyPA_3D(const Vector &x, real_t &energy) const
real_t GetLocalStateEnergyPA_C0_2D(const Vector &) const
TMOP_LimiterFunction * lim_func
void ComputeAllElementTargets(const Vector &xe=Vector()) const
void AddMultGradPA_AdaptLim_2D(const Vector &, Vector &) const
void AddMultPA_C0_3D(const Vector &, Vector &) const
void AddMultPA_AdaptLim_3D(const Vector &, Vector &) const
void AssembleDiagonalPA_2D(Vector &) const
void AssembleDiagonalPA_AdaptLim_3D(Vector &) const
const GridFunction * lim_dist
void AssembleDiagonalPA_C0_3D(Vector &) const
struct mfem::TMOP_Integrator::@25 PA
void AddMultGradPA_2D(const Vector &, Vector &) const
void AssembleGradPA_C0_2D(const Vector &) const
const TargetConstructor * targetC
void GetLocalStateEnergyPA_2D(const Vector &x, real_t &energy) const
const GridFunction * lim_nodes0
Array< Coefficient * > adapt_lim_coeff
const IntegrationRule * ir
void AssemblePA(const FiniteElementSpace &) override
Method defining partial assembly.
void AssembleGradDiagonalPA(Vector &) const override
Method for computing the diagonal of the gradient with partial assembly.
void AssembleDiagonalPA_C0_2D(Vector &) const
real_t GetLocalStateEnergyPA_C0_3D(const Vector &) const
void AddMultGradPA_3D(const Vector &, Vector &) const
const FiniteElementSpace * fes
void AssembleDiagonalPA_AdaptLim_2D(Vector &) const
void AssemblePA_Limiting()
const IntegrationRule & EnergyIntegrationRule(const FiniteElement &el) const
void AddMultPA_2D(const Vector &, Vector &) const
void AddMultGradPA_AdaptLim_3D(const Vector &, Vector &) const
real_t GetLocalStateEnergyPA_AdaptLim_3D() const
void AddMultPA_3D(const Vector &, Vector &) const
Array< GridFunction * > adapt_lim_gf0
void AssembleGradPA_AdaptLim_2D(const Vector &) const
void AssembleGradPA_C0_3D(const Vector &) const
void AssembleGradPA_2D(const Vector &) const
void AddMultPA_AdaptLim_2D(const Vector &, Vector &) const
void AssembleGradPA_AdaptLim_3D(const Vector &) const
Coefficient * metric_coeff
Array< GridFunction * > adapt_lim_gf
void AddMultPA(const Vector &, Vector &) const override
Method for partially assembled action.
void AddMultGradPA_C0_2D(const Vector &, Vector &) const
void AssembleDiagonalPA_3D(Vector &) const
void AssemblePA_AdaptLim()
void UpdateCoefficientsPA(const Vector &d_loc)
void AssembleGradPA_3D(const Vector &) const
Array< real_t > adapt_lim_delta_max
void AssembleGradPA(const Vector &, const FiniteElementSpace &) override
Prepare the integrator for partial assembly (PA) gradient evaluations on the given FE space fes at th...
void AddMultPA_C0_2D(const Vector &, Vector &) const
real_t GetLocalStateEnergyPA(const Vector &) const override
Compute the local (to the MPI rank) energy with partial assembly.
void AddMultGradPA_C0_3D(const Vector &, Vector &) const
Default limiter function in TMOP_Integrator.
bool UsesPhysicalCoordinates() const
Return true if the methods ComputeElementTargets(), ComputeAllElementTargets(), and ComputeElementTar...
void ComputeAllElementTargets_Fallback(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
bool ComputeAllElementTargets(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
int Size() const
Returns the size of the vector.
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
void SetSize(int s)
Resize the vector to size s.
void MakeRef(Vector &base, int offset, int size)
Reset the Vector to be a reference to a sub-vector of base.
void add(const Vector &v1, const Vector &v2, Vector &v)
MFEM_HOST_DEVICE DeviceTensor< sizeof...(Dims), T > Reshape(T *ptr, Dims... dims)
Wrap a pointer as a DeviceTensor with automatically deduced template parameters.
void GetPeriodicPositions(const Vector &x_0, const Vector &dx, const FiniteElementSpace &fesL2, const FiniteElementSpace &fesH1, Vector &x)
MemoryType
Memory types supported by MFEM.
ElementDofOrdering
Constants describing the possible orderings of the DOFs in one element.
std::array< int, NCMesh::MaxFaceNodes > nodes