Debian Codegraph @

fem/tmop/metrics/303.cpp

raw
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 "../pa.hpp"
13 #include "../mult/mult3.hpp"
14 #include "../tools/energy3.hpp"
15 #include "../assemble/grad3.hpp"
16
17 namespace mfem
18 {
19
20 struct TMOP_PA_Metric_303 : TMOP_PA_Metric_3D
21 {
22 MFEM_HOST_DEVICE real_t EvalW(const real_t (&Jpt)[DIM * DIM],
23 const real_t *w) const final
24 {
25 real_t B[9];
26 MFEM_CONTRACT_VAR(w);
27 kernels::InvariantsEvaluator3D ie(Args().J(Jpt).B(B));
28 // mu_303 = I1b/3 - 1
29 return ie.Get_I1b() / 3. - 1.;
30 }
31
32 MFEM_HOST_DEVICE void EvalP(const real_t (&Jpt)[9],
33 const real_t *w, real_t (&P)[9]) const final
34 {
35 MFEM_CONTRACT_VAR(w);
36 // dI1b/3
37 real_t B[9];
38 real_t dI1b[9], dI3b[9];
39 kernels::InvariantsEvaluator3D ie(
40 Args().J(Jpt).B(B).dI1b(dI1b).dI3b(dI3b));
41 kernels::Set(3, 3, 1. / 3., ie.Get_dI1b(), P);
42 }
43
44 MFEM_HOST_DEVICE void AssembleH(const int qx, const int qy, const int qz,
45 const int e,
46 const real_t weight,
47 real_t *Jrt,
48 real_t *Jpr,
49 const real_t (&Jpt)[9],
50 const real_t *w,
51 const DeviceTensor<8> &H) const final
52 {
53 MFEM_CONTRACT_VAR(w);
54 real_t B[9];
55 real_t dI1b[9], ddI1[9], ddI1b[9];
56 real_t dI2[9], dI2b[9], ddI2[9], ddI2b[9];
57 real_t *dI3b = Jrt, *ddI3b = Jpr;
58
59 // ddI1b/3
60 kernels::InvariantsEvaluator3D ie(Args()
61 .J(Jpt)
62 .B(B)
63 .dI1b(dI1b)
64 .ddI1(ddI1)
65 .ddI1b(ddI1b)
66 .dI2(dI2)
67 .dI2b(dI2b)
68 .ddI2(ddI2)
69 .ddI2b(ddI2b)
70 .dI3b(dI3b)
71 .ddI3b(ddI3b));
72
73 const real_t c1 = weight / 3.;
74 for (int i = 0; i < DIM; i++)
75 {
76 for (int j = 0; j < DIM; j++)
77 {
78 ConstDeviceMatrix ddi1b(ie.Get_ddI1b(i, j), DIM, DIM);
79 for (int r = 0; r < DIM; r++)
80 {
81 for (int c = 0; c < DIM; c++)
82 {
83 const real_t dp = ddi1b(r, c);
84 H(r, c, i, j, qx, qy, qz, e) = c1 * dp;
85 }
86 }
87 }
88 }
89 }
90 };
91
92 using metric = TMOP_PA_Metric_303;
93
94 using assemble = TMOPAssembleGradPA3D;
95 using energy = TMOPEnergyPA3D;
96 using mult = TMOPAddMultPA3D;
97
98 MFEM_TMOP_REGISTER_METRIC(metric, assemble, energy, mult, 303);
99
100 } // namespace mfem