Debian Codegraph @

fem/tmop/metrics/001.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/mult2.hpp"
14 #include "../tools/energy2.hpp"
15 #include "../assemble/grad2.hpp"
16
17 namespace mfem
18 {
19
20 struct TMOP_PA_Metric_001 : TMOP_PA_Metric_2D
21 {
22 MFEM_HOST_DEVICE real_t EvalW(const real_t (&Jpt)[4],
23 const real_t *) const final
24 {
25 kernels::InvariantsEvaluator2D ie(Args().J(Jpt));
26 return ie.Get_I1();
27 };
28
29 MFEM_HOST_DEVICE void EvalP(const real_t (&Jpt)[4],
30 const real_t *w, real_t (&P)[4]) const final
31 {
32 MFEM_CONTRACT_VAR(w);
33 real_t dI1[4];
34 kernels::InvariantsEvaluator2D ie(Args().J(Jpt).dI1(dI1));
35 kernels::Set(2, 2, 1.0, ie.Get_dI1(), P);
36 }
37
38 MFEM_HOST_DEVICE void AssembleH(const int qx,
39 const int qy,
40 const int e,
41 const real_t weight,
42 const real_t (&Jpt)[4],
43 const real_t *w,
44 const DeviceTensor<7> &H) const final
45 {
46 MFEM_CONTRACT_VAR(w);
47 // weight * ddI1
48 real_t ddI1[4];
49 kernels::InvariantsEvaluator2D ie(Args().J(Jpt).ddI1(ddI1));
50 for (int i = 0; i < DIM; i++)
51 {
52 for (int j = 0; j < DIM; j++)
53 {
54 ConstDeviceMatrix ddi1(ie.Get_ddI1(i, j), DIM, DIM);
55 for (int r = 0; r < DIM; r++)
56 {
57 for (int c = 0; c < DIM; c++)
58 {
59 const real_t h = ddi1(r, c);
60 H(r, c, i, j, qx, qy, e) = weight * h;
61 }
62 }
63 }
64 }
65 }
66 };
67
68 using metric = TMOP_PA_Metric_001;
69
70 using assemble = TMOPAssembleGradPA2D;
71 using energy = TMOPEnergyPA2D;
72 using mult = TMOPAddMultPA2D;
73
74 MFEM_TMOP_REGISTER_METRIC(metric, assemble, energy, mult, 1);
75
76 } // namespace mfem