Skip to content

Commit

Permalink
Merge pull request #28597 from hugary1995/neml2_action
Browse files Browse the repository at this point in the history
NEML2Action overhaul
  • Loading branch information
dschwen authored Dec 8, 2024
2 parents 1043bc5 + 8ae3d1d commit 61ff2ea
Show file tree
Hide file tree
Showing 140 changed files with 4,655 additions and 4,459 deletions.

This file was deleted.

34 changes: 0 additions & 34 deletions framework/include/userobjects/BatchPropertyDerivative.h

This file was deleted.

2 changes: 1 addition & 1 deletion framework/include/utils/InputParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ class InputParameters : public libMesh::Parameters
*
* In order to apply common parameter 4 statements must be satisfied
* (1) A local parameter must exist with the same name as common parameter
* (2) Common parameter must valid
* (2) Common parameter must be valid
* (3) Local parameter must be invalid OR not have been set from its default
* (4) Both cannot be private (unless \p allow_private = true)
*
Expand Down
23 changes: 23 additions & 0 deletions framework/include/utils/RankFourTensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,29 @@ class RankFourTensorTempl
template <typename T2>
RankFourTensorTempl(const RankFourTensorTempl<T2> & copy);

/**
* The conversion operator from a `SymmetricRankFourTensorTempl`
*/
template <typename T2>
RankFourTensorTempl(const SymmetricRankFourTensorTempl<T2> & t)
{
for (const auto a : make_range(SymmetricRankFourTensorTempl<T2>::N))
for (const auto b : make_range(SymmetricRankFourTensorTempl<T2>::N))
{
const auto & idx = SymmetricRankFourTensorTempl<T2>::full_index[a][b];
const auto i = idx[0];
const auto j = idx[1];
const auto k = idx[2];
const auto l = idx[3];

// Rijkl = Rjikl = Rijlk = Rjilk
(*this)(i, j, k, l) = t(a, b) / SymmetricRankFourTensorTempl<T2>::mandelFactor(a, b);
(*this)(j, i, k, l) = t(a, b) / SymmetricRankFourTensorTempl<T2>::mandelFactor(a, b);
(*this)(i, j, l, k) = t(a, b) / SymmetricRankFourTensorTempl<T2>::mandelFactor(a, b);
(*this)(j, i, l, k) = t(a, b) / SymmetricRankFourTensorTempl<T2>::mandelFactor(a, b);
}
}

// Named constructors
static RankFourTensorTempl<T> Identity() { return RankFourTensorTempl<T>(initIdentity); }
static RankFourTensorTempl<T> IdentityFour() { return RankFourTensorTempl<T>(initIdentityFour); };
Expand Down
5 changes: 4 additions & 1 deletion framework/include/utils/SymmetricRankFourTensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ class SymmetricRankFourTensorTempl
template <typename T2>
SymmetricRankFourTensorTempl(const SymmetricRankFourTensorTempl<T2> & copy);

// explicit cast to a full tensor
/// Copy constructor from RankFourTensorTempl<T>
explicit SymmetricRankFourTensorTempl(const RankFourTensorTempl<T> & a);

/// The conversion operator to `RankFourTensorTempl`
explicit operator RankFourTensorTempl<T>();

// Named constructors
Expand Down
33 changes: 20 additions & 13 deletions framework/include/utils/SymmetricRankFourTensorImplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,33 @@ SymmetricRankFourTensorTempl<T>::SymmetricRankFourTensorTempl(const InitMethod i
}

template <typename T>
SymmetricRankFourTensorTempl<T>::operator RankFourTensorTempl<T>()
SymmetricRankFourTensorTempl<T>::SymmetricRankFourTensorTempl(const RankFourTensorTempl<T> & t)
{
// Full tensor indices in the Mandel/Voigt representation
static constexpr unsigned int g[6][6][4] = {
{{1, 1, 1, 1}, {1, 1, 2, 2}, {1, 1, 3, 3}, {1, 1, 2, 3}, {1, 1, 1, 3}, {1, 1, 1, 2}},
{{2, 2, 1, 1}, {2, 2, 2, 2}, {2, 2, 3, 3}, {2, 2, 2, 3}, {2, 2, 1, 3}, {2, 2, 1, 2}},
{{3, 3, 1, 1}, {3, 3, 2, 2}, {3, 3, 3, 3}, {3, 3, 2, 3}, {3, 3, 1, 3}, {3, 3, 1, 2}},
{{2, 3, 1, 1}, {2, 3, 2, 2}, {2, 3, 3, 3}, {2, 3, 2, 3}, {2, 3, 1, 3}, {2, 3, 1, 2}},
{{1, 3, 1, 1}, {1, 3, 2, 2}, {1, 3, 3, 3}, {1, 3, 2, 3}, {1, 3, 1, 3}, {1, 3, 1, 2}},
{{1, 2, 1, 1}, {1, 2, 2, 2}, {1, 2, 3, 3}, {1, 2, 2, 3}, {1, 2, 1, 3}, {1, 2, 1, 2}}};
for (const auto a : make_range(N))
for (const auto b : make_range(N))
{
const auto & idx = full_index[a][b];
auto i = idx[0];
auto j = idx[1];
auto k = idx[2];
auto l = idx[3];
(*this)(a, b) =
(t(i, j, k, l) + t(j, i, l, k) + t(j, i, k, l) + t(i, j, l, k)) / 4 * mandelFactor(a, b);
}
}

template <typename T>
SymmetricRankFourTensorTempl<T>::operator RankFourTensorTempl<T>()
{
auto & q = *this;
RankFourTensorTempl<T> r;
for (const auto a : make_range(N))
for (const auto b : make_range(N))
{
const auto i = g[a][b][0] - 1;
const auto j = g[a][b][1] - 1;
const auto k = g[a][b][2] - 1;
const auto l = g[a][b][3] - 1;
const auto i = full_index[a][b][0];
const auto j = full_index[a][b][1];
const auto k = full_index[a][b][2];
const auto l = full_index[a][b][3];

// Rijkl = Rjikl = Rijlk = Rjilk
r(i, j, k, l) = q(a, b) / mandelFactor(a, b);
Expand Down
51 changes: 0 additions & 51 deletions framework/src/userobjects/BatchPropertyDerivative.C

This file was deleted.

Loading

0 comments on commit 61ff2ea

Please sign in to comment.