12 #include "../tmop.hpp" 14 #include "../../general/forall.hpp" 15 #include "../../linalg/kernels.hpp" 24 const double input_min_size,
33 MFEM_VERIFY(ncomp==1,
"");
34 constexpr
int DIM = 3;
35 const int D1D = T_D1D ? T_D1D : d1d;
36 const int Q1D = T_Q1D ? T_Q1D : q1d;
37 MFEM_VERIFY(D1D <= Q1D,
"");
41 const auto X =
Reshape(x_.
Read(), D1D, D1D, D1D, ncomp, NE);
45 MFEM_VERIFY(sizeidx == 0,
"");
46 MFEM_VERIFY(MFEM_CUDA_BLOCKS==256,
"");
48 const double *nc_red = nc_reduce.
Read();
52 const int D1D = T_D1D ? T_D1D : d1d;
53 const int Q1D = T_Q1D ? T_Q1D : q1d;
54 constexpr
int MQ1 = T_Q1D ? T_Q1D : T_MAX;
55 constexpr
int MD1 = T_D1D ? T_D1D : T_MAX;
56 constexpr
int MDQ = (MQ1 > MD1) ? MQ1 : MD1;
58 MFEM_SHARED
double sB[MQ1*MD1];
59 MFEM_SHARED
double sm0[MDQ*MDQ*MDQ];
60 MFEM_SHARED
double sm1[MDQ*MDQ*MDQ];
62 kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,
b,sB);
70 kernels::internal::LoadX(e,D1D,sizeidx,X,DDD);
73 MFEM_SHARED
double min_size[MFEM_CUDA_BLOCKS];
76 MFEM_FOREACH_THREAD(
t,x,MFEM_CUDA_BLOCKS) { min_size[
t] =
infinity; }
78 MFEM_FOREACH_THREAD(dz,z,D1D)
80 MFEM_FOREACH_THREAD(dy,y,D1D)
82 MFEM_FOREACH_THREAD(dx,x,D1D)
84 M(dx,dy,dz) = D(dx,dy,dz);
89 for (
int wrk = MFEM_CUDA_BLOCKS >> 1; wrk > 0; wrk >>= 1)
91 MFEM_FOREACH_THREAD(
t,x,MFEM_CUDA_BLOCKS)
93 if (
t < wrk && MFEM_THREAD_ID(y)==0 && MFEM_THREAD_ID(z)==0)
95 min_size[
t] = fmin(min_size[
t], min_size[
t+wrk]);
101 if (input_min_size > 0.) { min = input_min_size; }
102 kernels::internal::EvalX(D1D,Q1D,B,DDD,DDQ);
103 kernels::internal::EvalY(D1D,Q1D,B,DDQ,DQQ);
104 kernels::internal::EvalZ(D1D,Q1D,B,DQQ,QQQ);
105 MFEM_FOREACH_THREAD(qx,x,Q1D)
107 MFEM_FOREACH_THREAD(qy,y,Q1D)
109 MFEM_FOREACH_THREAD(qz,z,Q1D)
112 kernels::internal::PullEval(qx,qy,qz,QQQ,T);
113 const double shape_par_vals = T;
114 const double size = fmax(shape_par_vals, min) / nc_red[e];
115 const double alpha = std::pow(size, 1.0/
DIM);
116 for (
int i = 0; i <
DIM; i++)
118 for (
int j = 0; j <
DIM; j++)
120 J(i,j,qx,qy,qz,e) =
alpha * W(i,j);
138 MFEM_VERIFY(
tspec_fesv,
"No target specifications have been set.");
152 const int NE = mesh->
GetNE();
154 if (NE == 0) {
return; }
157 "mixed meshes are not supported");
158 MFEM_VERIFY(!fes->
IsVariableOrder(),
"variable orders are not supported");
162 const DofToQuad &maps = fe.GetDofToQuad(ir, mode);
164 const int D1D = maps.
ndof;
165 const int Q1D = maps.
nqpt;
171 for (
int e = 0; e < NE; e++)
180 MFEM_VERIFY(R->
Height() == NE*
ncomp*D1D*D1D*D1D,
"");
185 const int id = (D1D << 4 ) | Q1D;
186 MFEM_LAUNCH_TMOP_KERNEL(DatcSize,
id,NE,
ncomp,
sizeidx,input_min_size,W,B,
187 tspec_e, nc_size_red, Jtr);
const T * Read(bool on_dev=true) const
Shortcut for mfem::Read(a.GetMemory(), a.Size(), on_dev).
Abstract class for all finite elements.
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...
void forall_3D(int N, int X, int Y, int Z, lambda &&body)
Class for an integration rule - an Array of IntegrationPoint.
bool IsVariableOrder() const
Returns true if the space contains elements of varying polynomial orders.
const TargetType target_type
Tensor product representation using 1D matrices/tensors with dimensions using 1D number of quadrature...
int Dimension() const
Dimension of the reference space used within the elements.
void SetSize(int s)
Resize the vector to size s.
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
int nqpt
Number of quadrature points. When mode is TENSOR, this is the 1D number.
Data type dense matrix using column-major storage.
virtual double * HostWrite()
Shortcut for mfem::Write(vec.GetMemory(), vec.Size(), false).
int ndof
Number of degrees of freedom = number of basis functions. When mode is TENSOR, this is the 1D number...
virtual 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 =0
Operator application: y=A(x).
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
const ElementRestrictionOperator * GetElementRestriction(ElementDofOrdering e_ordering) const
Return an Operator that converts L-vectors to E-vectors.
MFEM_REGISTER_TMOP_KERNELS(void, DatcSize, const int NE, const int ncomp, const int sizeidx, const double input_min_size, const DenseMatrix &w_, const Array< double > &b_, const Vector &x_, const Vector &nc_reduce, DenseTensor &j_, const int d1d, const int q1d)
static MemoryType GetDeviceMemoryType()
Get the current Device MemoryType. This is the MemoryType used by most MFEM classes when allocating m...
int GetElementSizeReduction(int i) const
FiniteElementSpace * tspec_fesv
A class for non-conforming AMR. The class is not used directly by the user, rather it is an extension...
A basic generic Tensor class, appropriate for use on the GPU.
Mesh * GetMesh() const
Returns the mesh.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
Structure representing the matrices/tensors needed to evaluate (in reference space) the values...
Array< double > B
Basis functions evaluated at quadrature points.
int GetNE() const
Returns number of elements.
Mode
Type of data stored in the arrays B, Bt, G, and Gt.
ElementDofOrdering
Constants describing the possible orderings of the DOFs in one element.
Lexicographic ordering for tensor-product FiniteElements.
double infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
const DenseMatrix & GetGeomToPerfGeomJac(int GeomType) const
NCMesh * ncmesh
Optional nonconforming mesh extension.
double * Write(bool on_dev=true)
Shortcut for mfem::Write(GetMemory(), TotalSize(), on_dev).
MFEM_HOST_DEVICE DeviceTensor< sizeof...(Dims), T > Reshape(T *ptr, Dims... dims)
Wrap a pointer as a DeviceTensor with automatically deduced template parameters.
Rank 3 tensor (array of matrices)
const double * Read(bool on_dev=true) const
Shortcut for mfem::Read( GetMemory(), TotalSize(), on_dev).
void ComputeAllElementTargets_Fallback(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const