| 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_315 : 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 |
// (I3b - 1)^2 |
| 29 |
const real_t a = ie.Get_I3b() - 1.0; |
| 30 |
return a * a; |
| 31 |
} |
| 32 |
|
| 33 |
MFEM_HOST_DEVICE void EvalP(const real_t (&Jpt)[9], |
| 34 |
const real_t *w, real_t (&P)[9]) const final |
| 35 |
{ |
| 36 |
MFEM_CONTRACT_VAR(w); |
| 37 |
// 2*(I3b - 1)*dI3b |
| 38 |
real_t dI3b[9]; |
| 39 |
kernels::InvariantsEvaluator3D ie(Args().J(Jpt).dI3b(dI3b)); |
| 40 |
real_t sign_detJ; |
| 41 |
const real_t I3b = ie.Get_I3b(sign_detJ); |
| 42 |
kernels::Set(3, 3, 2.0 * (I3b - 1.0), ie.Get_dI3b(sign_detJ), P); |
| 43 |
} |
| 44 |
|
| 45 |
MFEM_HOST_DEVICE void AssembleH(const int qx, const int qy, const int qz, |
| 46 |
const int e, |
| 47 |
const real_t weight, |
| 48 |
real_t *Jrt, |
| 49 |
real_t *Jpr, |
| 50 |
const real_t (&Jpt)[9], |
| 51 |
const real_t *w, |
| 52 |
const DeviceTensor<8> &H) const final |
| 53 |
{ |
| 54 |
MFEM_CONTRACT_VAR(w); |
| 55 |
real_t *dI3b = Jrt, *ddI3b = Jpr; |
| 56 |
// 2*(dI3b x dI3b) + 2*(I3b - 1)*ddI3b |
| 57 |
kernels::InvariantsEvaluator3D ie(Args().J(Jpt).dI3b(dI3b).ddI3b(ddI3b)); |
| 58 |
real_t sign_detJ; |
| 59 |
const real_t I3b = ie.Get_I3b(sign_detJ); |
| 60 |
ConstDeviceMatrix di3b(ie.Get_dI3b(sign_detJ), DIM, DIM); |
| 61 |
for (int i = 0; i < DIM; i++) |
| 62 |
{ |
| 63 |
for (int j = 0; j < DIM; j++) |
| 64 |
{ |
| 65 |
ConstDeviceMatrix ddi3b(ie.Get_ddI3b(i, j), DIM, DIM); |
| 66 |
for (int r = 0; r < DIM; r++) |
| 67 |
{ |
| 68 |
for (int c = 0; c < DIM; c++) |
| 69 |
{ |
| 70 |
const real_t dp = 2.0 * weight * (I3b - 1.0) * ddi3b(r, c) + |
| 71 |
2.0 * weight * di3b(r, c) * di3b(i, j); |
| 72 |
H(r, c, i, j, qx, qy, qz, e) = dp; |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
}; |
| 79 |
|
| 80 |
using metric = TMOP_PA_Metric_315; |
| 81 |
|
| 82 |
using assemble = TMOPAssembleGradPA3D; |
| 83 |
using energy = TMOPEnergyPA3D; |
| 84 |
using mult = TMOPAddMultPA3D; |
| 85 |
|
| 86 |
MFEM_TMOP_REGISTER_METRIC(metric, assemble, energy, mult, 315); |
| 87 |
|
| 88 |
} // namespace mfem |