| 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_007 : 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() * (1.0 + 1.0 / ie.Get_I2()) - 4.0; |
| 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], dI2[4], dI2b[4]; |
| 34 |
kernels::InvariantsEvaluator2D ie( |
| 35 |
Args().J(Jpt).dI1(dI1).dI2(dI2).dI2b(dI2b)); |
| 36 |
const real_t I2 = ie.Get_I2(); |
| 37 |
kernels::Add(2, 2, 1.0 + 1.0 / I2, ie.Get_dI1(), -ie.Get_I1() / (I2 * I2), |
| 38 |
ie.Get_dI2(), P); |
| 39 |
} |
| 40 |
|
| 41 |
MFEM_HOST_DEVICE void AssembleH(const int qx, const int qy, |
| 42 |
const int e, |
| 43 |
const real_t weight, |
| 44 |
const real_t (&Jpt)[4], |
| 45 |
const real_t *w, |
| 46 |
const DeviceTensor<7> &H) const final |
| 47 |
{ |
| 48 |
MFEM_CONTRACT_VAR(w); |
| 49 |
real_t ddI1[4], ddI2[4], dI1[4], dI2[4], dI2b[4]; |
| 50 |
kernels::InvariantsEvaluator2D ie( |
| 51 |
Args().J(Jpt).ddI1(ddI1).ddI2(ddI2).dI1(dI1).dI2(dI2).dI2b(dI2b)); |
| 52 |
const real_t c1 = 1. / ie.Get_I2(); |
| 53 |
const real_t c2 = weight * c1 * c1; |
| 54 |
const real_t c3 = ie.Get_I1() * c2; |
| 55 |
ConstDeviceMatrix di1(ie.Get_dI1(), DIM, DIM); |
| 56 |
ConstDeviceMatrix di2(ie.Get_dI2(), DIM, DIM); |
| 57 |
|
| 58 |
for (int i = 0; i < DIM; i++) |
| 59 |
{ |
| 60 |
for (int j = 0; j < DIM; j++) |
| 61 |
{ |
| 62 |
ConstDeviceMatrix ddi1(ie.Get_ddI1(i, j), DIM, DIM); |
| 63 |
ConstDeviceMatrix ddi2(ie.Get_ddI2(i, j), DIM, DIM); |
| 64 |
for (int r = 0; r < DIM; r++) |
| 65 |
{ |
| 66 |
for (int c = 0; c < DIM; c++) |
| 67 |
{ |
| 68 |
H(r, c, i, j, qx, qy, e) = |
| 69 |
weight * (1.0 + c1) * ddi1(r, c) - c3 * ddi2(r, c) - |
| 70 |
c2 * (di1(i, j) * di2(r, c) + di2(i, j) * di1(r, c)) + |
| 71 |
2.0 * c1 * c3 * di2(r, c) * di2(i, j); |
| 72 |
} |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
}; |
| 78 |
|
| 79 |
using metric = TMOP_PA_Metric_007; |
| 80 |
|
| 81 |
using assemble = TMOPAssembleGradPA2D; |
| 82 |
using energy = TMOPEnergyPA2D; |
| 83 |
using mult = TMOPAddMultPA2D; |
| 84 |
|
| 85 |
MFEM_TMOP_REGISTER_METRIC(metric, assemble, energy, mult, 7); |
| 86 |
|
| 87 |
} // namespace mfem |