13 #include "../general/forall.hpp"
20 :
Operator(hFESpace_.GetVSize(), lFESpace_.GetVSize())
32 && dynamic_cast<const TensorBasisElement*>(hFESpace_.
GetFE(0)))
56 :
Operator(hFESpace_.GetVSize(), lFESpace_.GetVSize()), lFESpace(lFESpace_),
77 for (
int i = 0; i < mesh->
GetNE(); i++)
83 if (geom != cached_geom)
85 h_fe = hFESpace.
GetFE(i);
86 l_fe = lFESpace.
GetFE(i);
93 for (
int vd = 0; vd < vdim; vd++)
100 loc_prol.
Mult(subX, subY);
126 for (
int i = 0; i < mesh->
GetNE(); i++)
132 if (geom != cached_geom)
134 h_fe = hFESpace.
GetFE(i);
135 l_fe = lFESpace.
GetFE(i);
143 for (
int vd = 0; vd < vdim; vd++)
145 l_dofs.
Copy(l_vdofs);
147 h_dofs.
Copy(h_vdofs);
151 for (
int p = 0;
p < h_dofs.
Size(); ++
p)
159 loc_prol.
Mult(subX, subY);
163 for (
int p = 0;
p < h_dofs.
Size(); ++
p)
174 :
Operator(hFESpace_.GetVSize(), lFESpace_.GetVSize()), lFESpace(lFESpace_),
180 if (mesh->
GetNE() == 0)
188 MFEM_VERIFY(ltel,
"Low order FE space must be tensor product space");
192 MFEM_VERIFY(htel,
"High order FE space must be tensor product space");
205 NE = lFESpace.
GetNE();
213 elem_restrict_lex_l =
216 MFEM_VERIFY(elem_restrict_lex_l,
217 "Low order ElementRestriction not available");
219 elem_restrict_lex_h =
222 MFEM_VERIFY(elem_restrict_lex_h,
223 "High order ElementRestriction not available");
230 MFEM_VERIFY(dynamic_cast<const ElementRestriction*>(elem_restrict_lex_h),
231 "High order element restriction is of unsupported type");
239 namespace TransferKernels
254 for (
int dy = 0; dy < D1D; ++dy)
257 for (
int qy = 0; qy < Q1D; ++qy)
261 for (
int dx = 0; dx < D1D; ++dx)
263 const double s = x_(dx, dy, e);
264 for (
int qx = 0; qx < Q1D; ++qx)
266 sol_x[qx] += B_(qx, dx) * s;
269 for (
int qy = 0; qy < Q1D; ++qy)
271 const double d2q = B_(qy, dy);
272 for (
int qx = 0; qx < Q1D; ++qx)
274 y_(qx, qy, e) += d2q * sol_x[qx];
278 for (
int qy = 0; qy < Q1D; ++qy)
280 for (
int qx = 0; qx < Q1D; ++qx)
282 y_(qx, qy, e) *= m_(qx, qy, e);
292 auto x_ =
Reshape(localL.
Read(), D1D, D1D, D1D, NE);
301 for (
int dz = 0; dz < D1D; ++dz)
304 for (
int qy = 0; qy < Q1D; ++qy)
306 for (
int qx = 0; qx < Q1D; ++qx)
308 sol_xy[qy][qx] = 0.0;
311 for (
int dy = 0; dy < D1D; ++dy)
314 for (
int qx = 0; qx < Q1D; ++qx)
318 for (
int dx = 0; dx < D1D; ++dx)
320 const double s = x_(dx, dy, dz, e);
321 for (
int qx = 0; qx < Q1D; ++qx)
323 sol_x[qx] += B_(qx, dx) * s;
326 for (
int qy = 0; qy < Q1D; ++qy)
328 const double wy = B_(qy, dy);
329 for (
int qx = 0; qx < Q1D; ++qx)
331 sol_xy[qy][qx] += wy * sol_x[qx];
335 for (
int qz = 0; qz < Q1D; ++qz)
337 const double wz = B_(qz, dz);
338 for (
int qy = 0; qy < Q1D; ++qy)
340 for (
int qx = 0; qx < Q1D; ++qx)
342 y_(qx, qy, qz, e) += wz * sol_xy[qy][qx];
347 for (
int qz = 0; qz < Q1D; ++qz)
349 for (
int qy = 0; qy < Q1D; ++qy)
351 for (
int qx = 0; qx < Q1D; ++qx)
353 y_(qx, qy, qz, e) *= m_(qx, qy, qz, e);
373 for (
int qy = 0; qy < Q1D; ++qy)
376 for (
int dx = 0; dx < D1D; ++dx)
380 for (
int qx = 0; qx < Q1D; ++qx)
382 const double s = m_(qx, qy, e) * x_(qx, qy, e);
383 for (
int dx = 0; dx < D1D; ++dx)
385 sol_x[dx] += Bt_(dx, qx) * s;
388 for (
int dy = 0; dy < D1D; ++dy)
390 const double q2d = Bt_(dy, qy);
391 for (
int dx = 0; dx < D1D; ++dx)
393 y_(dx, dy, e) += q2d * sol_x[dx];
403 auto x_ =
Reshape(localH.
Read(), Q1D, Q1D, Q1D, NE);
412 for (
int qz = 0; qz < Q1D; ++qz)
415 for (
int dy = 0; dy < D1D; ++dy)
417 for (
int dx = 0; dx < D1D; ++dx)
422 for (
int qy = 0; qy < Q1D; ++qy)
425 for (
int dx = 0; dx < D1D; ++dx)
429 for (
int qx = 0; qx < Q1D; ++qx)
431 const double s = m_(qx, qy, qz, e) * x_(qx, qy, qz, e);
432 for (
int dx = 0; dx < D1D; ++dx)
434 sol_x[dx] += Bt_(dx, qx) * s;
437 for (
int dy = 0; dy < D1D; ++dy)
439 const double wy = Bt_(dy, qy);
440 for (
int dx = 0; dx < D1D; ++dx)
442 sol_xy[dy][dx] += wy * sol_x[dx];
446 for (
int dz = 0; dz < D1D; ++dz)
448 const double wz = Bt_(dz, qz);
449 for (
int dy = 0; dy < D1D; ++dy)
451 for (
int dx = 0; dx < D1D; ++dx)
453 y_(dx, dy, dz, e) += wz * sol_xy[dy][dx];
475 elem_restrict_lex_l->
Mult(x, localL);
486 MFEM_ABORT(
"TensorProductPRefinementTransferOperator::Mult not "
487 "implemented for dim = "
501 elem_restrict_lex_h->
Mult(x, localH);
512 MFEM_ABORT(
"TensorProductPRefinementTransferOperator::MultTranspose not "
513 "implemented for dim = "
523 :
Operator(hFESpace_.GetTrueVSize(), lFESpace_.GetTrueVSize()),
537 delete localTransferOperator;
543 localTransferOperator->
Mult(tmpL, tmpH);
int GetNPoints() const
Returns the number of the points in the integration rule.
Abstract class for all finite elements.
int Size() const
Return the logical size of the array.
void SetSubVector(const Array< int > &dofs, const double value)
Set the entries listed in dofs to the given value.
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
void BuildTranspose() const
Build and store internally the transpose of this matrix which will be used in the methods AddMultTran...
Class for an integration rule - an Array of IntegrationPoint.
virtual void MultTranspose(const Vector &x, Vector &y) const override
Restriction by applying the transpose of the Mult method.
Tensor product representation using 1D matrices/tensors with dimensions using 1D number of quadrature...
virtual ~TensorProductPRefinementTransferOperator()
Destructor.
virtual const Operator * GetProlongationMatrix() const
The returned Operator is owned by the FiniteElementSpace.
Matrix-free transfer operator between finite element spaces on the same mesh.
void SetSize(int s)
Resize the vector to size s.
static int DecodeDof(int dof)
Helpers to remove encoded sign from a DOF.
Pointer to an Operator of a specified type.
void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
virtual void MultTranspose(const Vector &x, Vector &y) const override
Restriction by applying the transpose of the Mult method.
void Copy(Array ©) const
Create a copy of the internal array to the provided copy.
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
int nqpt
Number of quadrature points. When mode is TENSOR, this is the 1D number.
Data type dense matrix using column-major storage.
int Size() const
Returns the size of the vector.
virtual ~TransferOperator()
Destructor.
int ndof
Number of degrees of freedom = number of basis functions. When mode is TENSOR, this is the 1D number...
~TrueTransferOperator()
Destructor.
int GetNE() const
Returns number of elements.
virtual void Mult(const Vector &x, Vector &y) const override
Interpolation or prolongation of a vector x corresponding to the coarse space to the vector y corresp...
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
Abstract parallel finite element space.
Geometry::Type GetElementBaseGeometry(int i) const
virtual ~PRefinementTransferOperator()
Destructor.
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
const Operator * GetElementRestriction(ElementDofOrdering e_ordering) const
Return an Operator that converts L-vectors to E-vectors.
DeviceTensor< sizeof...(Dims), T > Reshape(T *ptr, Dims...dims)
Wrap a pointer as a DeviceTensor with automatically deduced template parameters.
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
int GetNE() const
Returns number of elements in the mesh.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
ID for the base class Operator, i.e. any type.
double * ReadWrite(bool on_dev=true)
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), on_dev).
virtual void MultTranspose(const Vector &x, Vector &y) const override
Restriction by applying the transpose of the Mult method.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
TrueTransferOperator(const ParFiniteElementSpace &lFESpace_, const ParFiniteElementSpace &hFESpace_)
Constructs a transfer operator working on true degrees of freedom from from lFESpace to hFESpace...
Mesh * GetMesh() const
Returns the mesh.
static MemoryType GetMemoryType()
(DEPRECATED) Equivalent to GetDeviceMemoryType().
TensorProductPRefinementTransferOperator(const FiniteElementSpace &lFESpace_, const FiniteElementSpace &hFESpace_)
Constructs a transfer operator from lFESpace to hFESpace which have different FE collections.
virtual void GetElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
void Restriction2D(const int NE, const int D1D, const int Q1D, const Vector &localH, Vector &localL, const Array< double > &Bt, const Vector &mask)
const T * Read(bool on_dev=true) const
Shortcut for mfem::Read(a.GetMemory(), a.Size(), on_dev).
int GetVDim() const
Returns vector dimension.
void AddElementVector(const Array< int > &dofs, const Vector &elemvect)
Add elements of the elemvect Vector to the entries listed in dofs. Negative dof values cause the -dof...
Operator * Ptr() const
Access the underlying Operator pointer.
void GetTransferOperator(const FiniteElementSpace &coarse_fes, OperatorHandle &T) const
Construct and return an Operator that can be used to transfer GridFunction data from coarse_fes...
Array< double > Bt
Transpose of B.
double p(const Vector &x, double t)
virtual void MultTranspose(const Vector &x, Vector &y) const override
Restriction by applying the transpose of the Mult method.
void Transpose()
(*this) = (*this)^t
Matrix-free transfer operator between finite element spaces.
Operator that converts FiniteElementSpace L-vectors to E-vectors.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Matrix-free transfer operator between finite element spaces on the same mesh exploiting the tensor pr...
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
virtual void Mult(const Vector &x, Vector &y) const override
Interpolation or prolongation of a vector x corresponding to the coarse space to the vector y corresp...
void Restriction3D(const int NE, const int D1D, const int Q1D, const Vector &localH, Vector &localL, const Array< double > &Bt, const Vector &mask)
Structure representing the matrices/tensors needed to evaluate (in reference space) the values...
Array< double > B
Basis functions evaluated at quadrature points.
const Array< int > & GetDofMap() const
Get an Array<int> that maps lexicographically ordered indices to the indices of the respective nodes/...
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 SetOperatorOwner(bool own=true)
Set the ownership flag for the held Operator.
const double * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
virtual void Mult(const Vector &x, Vector &y) const override
Interpolation or prolongation of a vector x corresponding to the coarse space to the vector y corresp...
virtual const SparseMatrix * GetRestrictionMatrix() const
Get the R matrix which restricts a local dof vector to true dof vector.
PRefinementTransferOperator(const FiniteElementSpace &lFESpace_, const FiniteElementSpace &hFESpace_)
Constructs a transfer operator from lFESpace to hFESpace which have different FE collections.
void MultTranspose(const Vector &x, Vector &y) const
Multiply a vector with the transposed matrix. y = At * x.
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
virtual void Mult(const Vector &x, Vector &y) const override
Interpolation or prolongation of a true dof vector x to a true dof vector y.
Lexicographic ordering for tensor-product FiniteElements.
const FiniteElementCollection * FEColl() const
void Mult(const double *x, double *y) const
Matrix vector multiplication.
virtual void GetTransferMatrix(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &I) const
Return interpolation matrix, I, which maps dofs from a coarse element, fe, to the fine dofs on this f...
void Prolongation2D(const int NE, const int D1D, const int Q1D, const Vector &localL, Vector &localH, const Array< double > &B, const Vector &mask)
TransferOperator(const FiniteElementSpace &lFESpace, const FiniteElementSpace &hFESpace)
Constructs a transfer operator from lFESpace to hFESpace.
void Prolongation3D(const int NE, const int D1D, const int Q1D, const Vector &localL, Vector &localH, const Array< double > &B, const Vector &mask)
void DofsToVDofs(Array< int > &dofs, int ndofs=-1) const