MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
tmop_pa_jp3.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#include "../tmop.hpp"
13#include "tmop_pa.hpp"
14#include "../tmop_tools.hpp"
17
18namespace mfem
19{
20
22 const int NE,
23 const Array<real_t> &b_,
24 const Array<real_t> &g_,
25 const Vector &x_,
26 Vector &DetJ,
27 const int d1d,
28 const int q1d)
29{
30 constexpr int DIM = 3;
31 const int D1D = T_D1D ? T_D1D : d1d;
32 const int Q1D = T_Q1D ? T_Q1D : q1d;
33
34 const auto b = Reshape(b_.Read(), Q1D, D1D);
35 const auto g = Reshape(g_.Read(), Q1D, D1D);
36 const auto X = Reshape(x_.Read(), D1D, D1D, D1D, DIM, NE);
37
38 auto E = Reshape(DetJ.Write(), Q1D, Q1D, Q1D, NE);
39
40 mfem::forall_3D(NE, Q1D, Q1D, Q1D, [=] MFEM_HOST_DEVICE (int e)
41 {
42 const int D1D = T_D1D ? T_D1D : d1d;
43 const int Q1D = T_Q1D ? T_Q1D : q1d;
44 constexpr int MQ1 = T_Q1D ? T_Q1D : T_MAX;
45 constexpr int MD1 = T_D1D ? T_D1D : T_MAX;
46
47 MFEM_SHARED real_t BG[2][MQ1*MD1];
48 MFEM_SHARED real_t DDD[3][MD1*MD1*MD1];
49 MFEM_SHARED real_t DDQ[6][MD1*MD1*MQ1];
50 MFEM_SHARED real_t DQQ[9][MD1*MQ1*MQ1];
51 MFEM_SHARED real_t QQQ[9][MQ1*MQ1*MQ1];
52
53 kernels::internal::LoadX<MD1>(e,D1D,X,DDD);
54 kernels::internal::LoadBG<MD1,MQ1>(D1D,Q1D,b,g,BG);
55
56 kernels::internal::GradX<MD1,MQ1>(D1D,Q1D,BG,DDD,DDQ);
57 kernels::internal::GradY<MD1,MQ1>(D1D,Q1D,BG,DDQ,DQQ);
58 kernels::internal::GradZ<MD1,MQ1>(D1D,Q1D,BG,DQQ,QQQ);
59
60 MFEM_FOREACH_THREAD(qz,z,Q1D)
61 {
62 MFEM_FOREACH_THREAD(qy,y,Q1D)
63 {
64 MFEM_FOREACH_THREAD(qx,x,Q1D)
65 {
66 real_t J[9];
67 kernels::internal::PullGrad<MQ1>(Q1D,qx,qy,qz,QQQ,J);
68 E(qx,qy,qz,e) = kernels::Det<3>(J);
69 }
70 }
71 }
72 });
73
74 return DetJ.Min();
75}
76
78 const Vector &D) const
79{
81
82 const Operator *RD = fes->GetElementRestriction(ordering);
84 DE.UseDevice(true);
85 RD->Mult(D, DE);
86
87 const Operator *RX = x_0.FESpace()->GetElementRestriction(ordering);
89 XE.UseDevice(true);
90 RX->Mult(x_0, XE);
91 XE += DE;
92
93 auto maps = fes->GetTypicalFE()->GetDofToQuad(ir, DofToQuad::TENSOR);
94 const int NE = fes->GetMesh()->GetNE();
95 const int NQ = ir.GetNPoints();
96 const int D1D = maps.ndof;
97 const int Q1D = maps.nqpt;
98 const int id = (D1D << 4 ) | Q1D;
99 const Array<real_t> &B = maps.B;
100 const Array<real_t> &G = maps.G;
101
102 Vector E(NE*NQ);
103 E.UseDevice(true);
104
105 MFEM_LAUNCH_TMOP_KERNEL(MinDetJpr_Kernel_3D,id,NE,B,G,XE,E);
106}
107
108} // namespace mfem
const T * Read(bool on_dev=true) const
Shortcut for mfem::Read(a.GetMemory(), a.Size(), on_dev).
Definition array.hpp:337
static MemoryType GetDeviceMemoryType()
Get the current Device MemoryType. This is the MemoryType used by most MFEM classes when allocating m...
Definition device.hpp:274
@ TENSOR
Tensor product representation using 1D matrices/tensors with dimensions using 1D number of quadrature...
Definition fe_base.hpp:165
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:244
const ElementRestrictionOperator * GetElementRestriction(ElementDofOrdering e_ordering) const
Return an Operator that converts L-vectors to E-vectors.
Definition fespace.cpp:1510
Mesh * GetMesh() const
Returns the mesh.
Definition fespace.hpp:679
const FiniteElement * GetTypicalFE() const
Return GetFE(0) if the local mesh is not empty; otherwise return a typical FE based on the Geometry t...
Definition fespace.cpp:3871
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...
Definition fe_base.cpp:365
FiniteElementSpace * FESpace()
int GetNPoints() const
Returns the number of the points in the integration rule.
Definition intrules.hpp:256
int GetNE() const
Returns number of elements.
Definition mesh.hpp:1282
Abstract operator.
Definition operator.hpp:25
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
Definition operator.hpp:66
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
real_t MinDetJpr_3D(const FiniteElementSpace *, const Vector &) const
const IntegrationRule & ir
Vector data type.
Definition vector.hpp:82
virtual const real_t * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
Definition vector.hpp:494
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
Definition vector.hpp:144
real_t Min() const
Returns the minimal element of the vector.
Definition vector.cpp:1123
virtual real_t * Write(bool on_dev=true)
Shortcut for mfem::Write(vec.GetMemory(), vec.Size(), on_dev).
Definition vector.hpp:502
real_t b
Definition lissajous.cpp:42
constexpr int DIM
MFEM_HOST_DEVICE T Det(const T *data)
Compute the determinant of a square matrix of size dim with given data.
Definition kernels.hpp:237
MFEM_REGISTER_TMOP_KERNELS(void, DatcSize, const int NE, const int ncomp, const int sizeidx, const real_t input_min_size, const DenseMatrix &w_, const Array< real_t > &b_, const Vector &x_, const Vector &nc_reduce, DenseTensor &j_, const int d1d, const int q1d)
MFEM_HOST_DEVICE DeviceTensor< sizeof...(Dims), T > Reshape(T *ptr, Dims... dims)
Wrap a pointer as a DeviceTensor with automatically deduced template parameters.
Definition dtensor.hpp:131
void forall_3D(int N, int X, int Y, int Z, lambda &&body)
Definition forall.hpp:774
float real_t
Definition config.hpp:43
ElementDofOrdering
Constants describing the possible orderings of the DOFs in one element.
Definition fespace.hpp:83