24static void PADGTraceSetup2D(
const int Q1D,
const int NF,
25 const Array<real_t> &w,
const Vector &det,
26 const Vector &nor,
const Vector &rho,
28 const real_t beta, Vector &op)
33 auto n =
Reshape(nor.Read(), Q1D, VDIM, NF);
34 const bool const_r = rho.Size() == 1;
36 const bool const_v =
vel.Size() == 2;
40 auto qd =
Reshape(op.Write(), Q1D, 2, 2, NF);
44 const int f = tid / Q1D;
45 const int q = tid % Q1D;
47 const real_t r = const_r ? R(0, 0) : R(q,
f);
48 const real_t v0 = const_v ? V(0, 0, 0) : V(0, q,
f);
49 const real_t v1 = const_v ? V(1, 0, 0) : V(1, q,
f);
50 const real_t dot = n(q, 0,
f) * v0 + n(q, 1,
f) * v1;
52 const real_t w = W[q] * r * d(q,
f);
61static void PADGTraceSetup3D(
const int Q1D,
const int NF,
62 const Array<real_t> &w,
const Vector &det,
63 const Vector &nor,
const Vector &rho,
65 const real_t beta, Vector &op)
70 auto n =
Reshape(nor.Read(), Q1D, Q1D, VDIM, NF);
71 const bool const_r = rho.Size() == 1;
72 auto R = const_r ?
Reshape(rho.Read(), 1, 1, 1)
74 const bool const_v =
vel.Size() == 3;
75 auto V = const_v ?
Reshape(
vel.Read(), 3, 1, 1, 1)
78 auto qd =
Reshape(op.Write(), Q1D, Q1D, 2, 2, NF);
80 mfem::forall(Q1D * Q1D * NF, [=] MFEM_HOST_DEVICE(
int tid)
82 int f = tid / (Q1D * Q1D);
83 int q2 = (tid / Q1D) % Q1D;
87 const real_t r = const_r ? R(0, 0, 0) : R(q1, q2,
f);
88 const real_t v0 = const_v ? V(0, 0, 0, 0) : V(0, q1, q2,
f);
89 const real_t v1 = const_v ? V(1, 0, 0, 0) : V(1, q1, q2,
f);
90 const real_t v2 = const_v ? V(2, 0, 0, 0) : V(2, q1, q2,
f);
91 const real_t dot = n(q1, q2, 0,
f) * v0 + n(q1, q2, 1,
f) * v1 +
94 const real_t w = W[q1 + q2 * Q1D] * r * d(q1, q2,
f);
95 qd(q1, q2, 0, 0,
f) = w * (
alpha / 2 *
dot + beta *
abs);
96 qd(q1, q2, 1, 0,
f) = w * (
alpha / 2 *
dot - beta *
abs);
97 qd(q1, q2, 0, 1,
f) = w * (-
alpha / 2 *
dot - beta *
abs);
98 qd(q1, q2, 1, 1,
f) = w * (-
alpha / 2 *
dot + beta *
abs);
104static void PADGTraceSetup(
const int dim,
const int D1D,
const int Q1D,
105 const int NF,
const Array<real_t> &W,
106 const Vector &det,
const Vector &nor,
107 const Vector &rho,
const Vector &
u,
112 MFEM_ABORT(
"dim==1 not supported in PADGTraceSetup");
116 PADGTraceSetup2D(Q1D, NF, W, det, nor, rho,
u,
alpha, beta, op);
120 PADGTraceSetup3D(Q1D, NF, W, det, nor, rho,
u,
alpha, beta, op);
124void DGTraceIntegrator::SetupPA(
const FiniteElementSpace &fes,
FaceType type)
130 Mesh *mesh = fes.GetMesh();
131 const FiniteElement &el = *fes.GetTypicalTraceElement();
132 const IntegrationRule *ir =
IntRule?
134 &
GetRule(el.GetGeomType(), el.GetOrder(),
135 *mesh->GetTypicalElementTransformation());
138 FaceQuadratureSpace qs(*mesh, *ir, type);
139 nf = qs.GetNumFaces();
140 if (
nf==0) {
return; }
141 const int symmDims = 4;
142 nq = ir->GetNPoints();
143 dim = mesh->Dimension();
144 geom = mesh->GetFaceGeometricFactors(
158 else if (ConstantCoefficient *const_rho =
159 dynamic_cast<ConstantCoefficient *
>(
rho))
161 r.SetConstant(const_rho->constant);
163 else if (QuadratureFunctionCoefficient *qf_rho =
164 dynamic_cast<QuadratureFunctionCoefficient *
>(
rho))
166 r.MakeRef(qf_rho->GetQuadFunction());
175 for (
int f = 0;
f < mesh->GetNumFacesWithGhost(); ++
f)
177 Mesh::FaceInformation face = mesh->GetFaceInformation(
f);
178 if (face.IsNonconformingCoarse() || !face.IsOfFaceType(type))
184 FaceElementTransformations &T =
185 *fes.GetMesh()->GetFaceElementTransformations(
f);
186 for (
int q = 0; q <
nq; ++q)
192 T.SetAllIntPoints(&ir->IntPoint(q));
193 const IntegrationPoint &eip1 = T.GetElement1IntPoint();
194 const IntegrationPoint &eip2 = T.GetElement2IntPoint();
197 if (face.IsBoundary())
199 rq =
rho->
Eval(*T.Elem1, eip1);
204 for (
int d = 0; d <
dim; ++d)
206 udotn += C_vel(d, iq, f_ind) * n(iq, d, f_ind);
210 rq =
rho->
Eval(*T.Elem2, eip2);
214 rq =
rho->
Eval(*T.Elem1, eip1);
221 MFEM_VERIFY(f_ind ==
nf,
"Incorrect number of faces.");
277DGTraceIntegrator::Kernels::Kernels()
299DGTraceIntegrator::ApplyPAKernels::Fallback(
int dim,
int,
int)
303 return internal::PADGTraceApply2D;
307 return internal::PADGTraceApply3D;
316DGTraceIntegrator::ApplyPATKernels::Fallback(
int dim,
int,
int)
320 return internal::PADGTraceApplyTranspose2D;
324 return internal::PADGTraceApplyTranspose3D;
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
void AddMultPA(const Vector &, Vector &) const override
Method for partially assembled action.
void AssemblePABoundaryFaces(const FiniteElementSpace &fes) override
void AddMultTransposePA(const Vector &x, Vector &y) const override
Method for partially assembled transposed action.
DGTraceIntegrator(real_t a, real_t b)
void AssemblePAInteriorFaces(const FiniteElementSpace &fes) override
void(*)(const int, const Array< real_t > &, const Array< real_t > &, const Vector &, const Vector &, Vector &, const int, const int) ApplyKernelType
arguments: nf, B, Bt, pa_data, x, y, dofs1D, quad1D
static const IntegrationRule & GetRule(Geometry::Type geom, int order, const FaceElementTransformations &T)
const FaceGeometricFactors * geom
Not owned.
const DofToQuad * maps
Not owned.
static void AddSpecialization()
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...
@ TENSOR
Tensor product representation using 1D matrices/tensors with dimensions using 1D number of quadrature...
Array< real_t > B
Basis functions evaluated at quadrature points.
int ndof
Number of degrees of freedom = number of basis functions. When mode is TENSOR, this is the 1D number.
int nqpt
Number of quadrature points. When mode is TENSOR, this is the 1D number.
Array< real_t > Bt
Transpose of B.
Vector normal
Normals at all quadrature points.
Vector detJ
Determinants of the Jacobians at all quadrature points.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
const IntegrationRule * IntRule
Base class for vector Coefficients that optionally depend on time and space.
virtual const real_t * HostRead() const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), false).
void SetSize(int s)
Resize the vector to size s.
MFEM_HOST_DEVICE T det(const tensor< T, 1, 1 > &A)
Returns the determinant of a matrix.
MFEM_HOST_DEVICE zero dot(const T &, zero)
the dot product of anything with zero is zero
const T * Read(const Memory< T > &mem, int size, bool on_dev=true)
Get a pointer for read access to mem with the mfem::Device's DeviceMemoryClass, if on_dev = true,...
real_t u(const Vector &xvec)
MFEM_HOST_DEVICE DeviceTensor< sizeof...(Dims), T > Reshape(T *ptr, Dims... dims)
Wrap a pointer as a DeviceTensor with automatically deduced template parameters.
int ToLexOrdering(const int dim, const int face_id, const int size1d, const int index)
Convert a dof face index from Native ordering to lexicographic ordering for quads and hexes.
@ COMPRESSED
Enable all above compressions.
MemoryType
Memory types supported by MFEM.
std::function< real_t(const Vector &)> f(real_t mass_coeff)
void forall(int N, lambda &&body)
void vel(const Vector &x, real_t t, Vector &u)
MFEM_HOST_DEVICE real_t abs(const Complex &z)