Skip to content

Commit 6c0c4e3

Browse files
committed
Build failure in FemUtils corrected: missing functions from Passmo(nl) modules added in FemUtils.h/.cc files.
1 parent f109353 commit 6c0c4e3

File tree

9 files changed

+192
-70
lines changed

9 files changed

+192
-70
lines changed

femutils/FemUtils.cc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
namespace Arcane::FemUtils
2929
{
30+
3031
using namespace Arcane::MatVec;
3132

3233
/*---------------------------------------------------------------------------*/
@@ -259,7 +260,55 @@ void checkNodeResultFile(ITraceMng* tm, const String& filename,
259260
/*---------------------------------------------------------------------------*/
260261
/*---------------------------------------------------------------------------*/
261262

263+
Real real3x3Trace(const Real3x3& mat) {
264+
return mat[0][0] + mat[1][1] + mat[2][2];
265+
}
266+
267+
/*---------------------------------------------------------------------------*/
268+
/*---------------------------------------------------------------------------*/
269+
270+
Real3 real3x3GetSupOutdiagonal(const Real3x3& mat) {
271+
return {mat[0][1], mat[0][2], mat[1][2]};
272+
}
273+
274+
/*---------------------------------------------------------------------------*/
275+
/*---------------------------------------------------------------------------*/
276+
277+
Real3 real3x3GetLowOutdiagonal(const Real3x3& mat){
278+
return {mat[1][0], mat[2][0], mat[2][1]};
279+
}
280+
281+
/*---------------------------------------------------------------------------*/
282+
/*---------------------------------------------------------------------------*/
283+
Real3 diagonalReal3x3(const Real3x3& mat){
284+
return { mat[0][0], mat[1][1], mat[2][2]} ;
262285
}
263286

264287
/*---------------------------------------------------------------------------*/
265288
/*---------------------------------------------------------------------------*/
289+
Real3x3 outdiagonalReal3x3(const Real3x3& mat){
290+
Real3 diag = diagonalReal3x3(mat);
291+
Real3x3 mdiag;
292+
mdiag.x.x = diag.x;
293+
mdiag.y.y = diag.y;
294+
mdiag.z.z = diag.z;
295+
return (mat - mdiag);
296+
}
297+
298+
/*---------------------------------------------------------------------------*/
299+
/*---------------------------------------------------------------------------*/
300+
301+
bool real3x3IsSym(const Real3x3& mat)
302+
{
303+
Real3 matsup = real3x3GetSupOutdiagonal(mat);
304+
Real3 matlow = real3x3GetLowOutdiagonal(mat);
305+
return (matsup == matlow);
306+
}
307+
308+
/*---------------------------------------------------------------------------*/
309+
/*---------------------------------------------------------------------------*/
310+
311+
} //end namespace Arcane::FemUtils
312+
313+
/*---------------------------------------------------------------------------*/
314+
/*---------------------------------------------------------------------------*/

femutils/FemUtils.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <arccore/base/ArccoreGlobal.h>
2929
#include <array>
3030
#include <arcane/MeshVariableArrayRef.h>
31+
3132
/*---------------------------------------------------------------------------*/
3233
/*---------------------------------------------------------------------------*/
3334

@@ -547,6 +548,58 @@ ARCCORE_HOST_DEVICE massMatrix(const RealVector<N>& lhs, const RealVector<N>& rh
547548

548549
/*---------------------------------------------------------------------------*/
549550
/*---------------------------------------------------------------------------*/
551+
/*!
552+
* \brief Checking whether a Real3x3 is symmetric (useful for Passmo(nl) modules)
553+
*/
554+
extern "C++" bool
555+
real3x3IsSym(const Arcane::Real3x3& mat);
556+
557+
/*---------------------------------------------------------------------------*/
558+
/*---------------------------------------------------------------------------*/
559+
/*!
560+
* \brief Diagonal of a Real3x3 obtained as a new Real3x3 (useful for Passmo(nl) modules)
561+
*/
562+
extern "C++" Real3
563+
diagonalReal3x3(const Real3x3& mat);
564+
565+
/*---------------------------------------------------------------------------*/
566+
/*---------------------------------------------------------------------------*/
567+
/*!
568+
* \brief Diagonal of a Real3x3 obtained as a new Real3x3
569+
* (useful for Passmo(nl) modules)
570+
*/
571+
extern "C++" Real3x3
572+
outdiagonalReal3x3(const Real3x3& mat);
573+
574+
/*---------------------------------------------------------------------------*/
575+
/*---------------------------------------------------------------------------*/
576+
/*!
577+
* \brief Compute the trace of a Real3x3 (useful for Passmo(nl) modules)
578+
*/
579+
extern "C++" Real
580+
real3x3Trace(const Real3x3& mat);
581+
582+
/*---------------------------------------------------------------------------*/
583+
/*---------------------------------------------------------------------------*/
584+
/*!
585+
* \brief Return the out-diagonal terms of the upper part of a Real3x3
586+
* (useful for Passmo(nl) modules)
587+
*/
588+
extern "C++"
589+
Real3 real3x3GetSupOutdiagonal(const Real3x3& mat);
590+
591+
/*---------------------------------------------------------------------------*/
592+
/*---------------------------------------------------------------------------*/
593+
/*!
594+
* \brief Return the out-diagonal terms of the lower part of a Real3x3
595+
* (useful for Passmo(nl) modules)
596+
*/
597+
extern "C++"
598+
Real3 real3x3GetLowOutdiagonal(const Real3x3& mat);
599+
600+
/*---------------------------------------------------------------------------*/
601+
/*---------------------------------------------------------------------------*/
602+
550603
class Tensor2
551604
{
552605
RealVector<6> m_vec;

modules/passmonl/LawDispatcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#define PASSMO_LAWDISPATCHER_H
1818

1919
#include "TypesNLdynamic.h"
20-
#include "FemUtils.h"
20+
//#include "FemUtils.h"
2121
#include "utilFEM.h"
2222

2323
//! Number of available constitutive models: for the moment, defining max 10

modules/passmonl/NLDynamicModule.cc

Lines changed: 81 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,20 +1670,22 @@ _computeK(const Real& lambda, const Real& mu, const DoFLocalId& igauss, const In
16701670
VariableDoFReal& gauss_jacobian(m_gauss_on_cells.gaussJacobian());
16711671

16721672
auto jacobian = gauss_jacobian[igauss];
1673-
1673+
auto a{ lambda + 2.*mu };
16741674
auto size{NDIM * nb_nodes};
16751675

16761676
// Setting the "B" matrix size for the max number of nodes in 3D:
16771677
// 8 nodes for a lin element/20 nodes for a quadratic one
1678-
RealUniqueArray2 Bmat(NDIM, size);
1678+
RealUniqueArray2 Bmat = _getB(igauss,nb_nodes);
16791679

1680-
auto a{ lambda + 2.*mu };
1680+
/*
1681+
RealUniqueArray2 Bmat(NDIM, size);
16811682
16821683
for (int i = 0; i < NDIM; ++i)
16831684
for (int j = 0; j < size; ++j) {
16841685
Bmat(i, j) = 0.;
16851686
}
16861687
1688+
16871689
// ! Computes the Inverse Jacobian Matrix of a 2D or 3D finite-element
16881690
auto jac = gauss_jacobmat[igauss];
16891691
Real3x3 ijac;
@@ -1697,22 +1699,21 @@ _computeK(const Real& lambda, const Real& mu, const DoFLocalId& igauss, const In
16971699
ijac.y.x = -jac.y.x / jacobian;
16981700
ijac.y.y = jac.x.x / jacobian;
16991701
}
1700-
1701-
auto wt = gauss_weight[igauss] * jacobian;
1702-
1703-
//------------------------------------------------------
1704-
// Elementary Derivation Matrix B at current Gauss point
1705-
//------------------------------------------------------
1706-
for (Int32 inod = 0; inod < nb_nodes; ++inod) {
1707-
auto dPhi = gauss_shapederiv[igauss][inod];
1708-
for (int i = 0; i < NDIM; ++i){
1709-
auto bi{0.};
1710-
for (int j = 0; j < NDIM; ++j) {
1711-
bi += ijac[i][j] * dPhi[j];
1712-
}
1713-
Bmat(i, inod) = bi;
1714-
}
1702+
//------------------------------------------------------
1703+
// Elementary Derivation Matrix B at current Gauss point
1704+
//------------------------------------------------------
1705+
for (Int32 inod = 0; inod < nb_nodes; ++inod) {
1706+
auto dPhi = gauss_shapederiv[igauss][inod];
1707+
for (int i = 0; i < NDIM; ++i){
1708+
auto bi{0.};
1709+
for (int j = 0; j < NDIM; ++j) {
1710+
bi += ijac[i][j] * dPhi[j];
1711+
}
1712+
Bmat(i, inod) = bi;
17151713
}
1714+
}
1715+
*/
1716+
auto wt = gauss_weight[igauss] * jacobian;
17161717

17171718
//----------------------------------------------
17181719
// Elementary Stiffness (Ke) Matrix assembly
@@ -1803,7 +1804,12 @@ _computeK(const Real& lambda, const Real& mu, const DoFLocalId& igauss, const In
18031804
D(0,1) = D(0,2) = D(1,2) = lambda
18041805
All other terms = 0.
18051806
------------------------------------------------------------------------------------*/
1806-
auto kij = wt * (Bii(0) * (a * Bjj(0) + lambda * Bjj(1) + lambda * Bjj(2)) + Bii(1) * (lambda * Bjj(0) + a * Bjj(1) + lambda * Bjj(2)) + Bii(2) * (lambda * Bjj(0) + lambda * Bjj(1) + a * Bjj(2)) + Bii(3) * (mu * Bjj(3)) + Bii(4) * (mu * Bjj(4)) + Bii(5) * (mu * Bjj(5)));
1807+
auto kij = wt * (Bii(0) * (a * Bjj(0) + lambda * Bjj(1) + lambda * Bjj(2))
1808+
+ Bii(1) * (lambda * Bjj(0) + a * Bjj(1) + lambda * Bjj(2))
1809+
+ Bii(2) * (lambda * Bjj(0) + lambda * Bjj(1) + a * Bjj(2))
1810+
+ Bii(3) * (mu * Bjj(3))
1811+
+ Bii(4) * (mu * Bjj(4))
1812+
+ Bii(5) * (mu * Bjj(5)));
18071813

18081814
Ke(ii, jj) = kij;
18091815
Ke(jj, ii) = kij;
@@ -2340,7 +2346,60 @@ _assembleLinearRHS(){
23402346
}
23412347
}
23422348
}
2349+
/*---------------------------------------------------------------------------*/
2350+
/*---------------------------------------------------------------------------*/
2351+
// ! Compute Elementary Derivation Matrix B at current Gauss point
2352+
2353+
RealUniqueArray2 NLDynamicModule::
2354+
_getB(const DoFLocalId& igauss, const Int32& nb_nodes)
2355+
{
23432356

2357+
auto gauss_point(m_gauss_on_cells.gaussCellConnectivityView());
2358+
VariableDoFArrayReal3& gauss_shapederiv(m_gauss_on_cells.gaussShapeDeriv());
2359+
VariableDoFReal3x3& gauss_jacobmat(m_gauss_on_cells.gaussJacobMat());
2360+
VariableDoFReal& gauss_jacobian(m_gauss_on_cells.gaussJacobian());
2361+
2362+
auto jacobian = gauss_jacobian[igauss];
2363+
auto size{ NDIM * nb_nodes };
2364+
2365+
// Setting the "B" matrix size for the max number of nodes in 3D:
2366+
// 8 nodes for a lin element/20 nodes for a quadratic one
2367+
RealUniqueArray2 Bmat(NDIM, size);
2368+
2369+
for (int i = 0; i < NDIM; ++i)
2370+
for (int j = 0; j < size; ++j) {
2371+
Bmat(i, j) = 0.;
2372+
}
2373+
2374+
// ! Computes the Inverse Jacobian Matrix of a 2D or 3D finite-element
2375+
auto jac = gauss_jacobmat[igauss];
2376+
Real3x3 ijac;
2377+
2378+
if (NDIM == 3) {
2379+
ijac = math::inverseMatrix(jac);
2380+
}
2381+
else {
2382+
ijac.x.x = jac.y.y / jacobian;
2383+
ijac.x.y = -jac.x.y / jacobian;
2384+
ijac.y.x = -jac.y.x / jacobian;
2385+
ijac.y.y = jac.x.x / jacobian;
2386+
}
2387+
2388+
//------------------------------------------------------
2389+
// Elementary Derivation Matrix B at current Gauss point
2390+
//------------------------------------------------------
2391+
for (Int32 inod = 0; inod < nb_nodes; ++inod) {
2392+
auto dPhi = gauss_shapederiv[igauss][inod];
2393+
for (int i = 0; i < NDIM; ++i) {
2394+
auto bi{ 0. };
2395+
for (int j = 0; j < NDIM; ++j) {
2396+
bi += ijac[i][j] * dPhi[j];
2397+
}
2398+
Bmat(i, inod) = bi;
2399+
}
2400+
}
2401+
return Bmat;
2402+
}
23442403
/*---------------------------------------------------------------------------*/
23452404
/*---------------------------------------------------------------------------*/
23462405
// ! Stress prediction
@@ -2349,6 +2408,7 @@ void NLDynamicModule::stress_prediction(bool init, bool isRef)
23492408
{
23502409
auto gauss_point(m_gauss_on_cells.gaussCellConnectivityView());
23512410

2411+
VariableDoFReal& gauss_weight(m_gauss_on_cells.gaussWeight());
23522412
VariableDoFArrayReal3x3& gauss_stress(m_gauss_on_cells.gaussStress());
23532413
VariableDoFArrayReal3x3& gauss_strain(m_gauss_on_cells.gaussStrain());
23542414
VariableDoFArrayReal3x3& gauss_strain_plastic(m_gauss_on_cells.gaussStrainPlastic());
@@ -2378,9 +2438,10 @@ void NLDynamicModule::stress_prediction(bool init, bool isRef)
23782438
sign.fromReal3x3ToTensor2(gauss_stress[gauss_pti][1]);
23792439
epspn.fromReal3x3ToTensor2(gauss_strain_plastic[gauss_pti][1]);
23802440

2441+
// Compute strain increment for this interation
23812442
Tensor2 deps;
23822443
{
2383-
// calcul deps à faire avec unodes
2444+
RealUniqueArray2 Bmat = _getB(gauss_pti,cell_nbnod);
23842445
}
23852446

23862447
for (Int32 ip = 0; ip < nblaw; ++ip) {

modules/passmonl/NLDynamicModule.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ class NLDynamicModule
171171
RealUniqueArray2& Ke, const Real3& RhoC);
172172

173173
bool _iterate();
174+
175+
RealUniqueArray2 _getB(const DoFLocalId& igauss, const Int32& nb_nodes);
176+
174177
void stress_prediction(bool init, bool isRef);
175178
void stress_correction(bool converge, bool isRef);
176179

modules/passmonl/druckerp.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* \brief Implementation of Drücker-Prager constitutive law
1717
*/
1818
#include "TypesNLdynamic.h"
19-
#include "FemUtils.h"
19+
//#include "FemUtils.h"
2020
#include "utilFEM.h"
2121

2222
/*---------------------------------------------------------------------------*/

modules/passmonl/hooke.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* \brief Implementation of Drücker-Prager constitutive law
1717
*/
1818
#include "TypesNLdynamic.h"
19-
#include "FemUtils.h"
19+
//#include "FemUtils.h"
2020
#include "utilFEM.h"
2121

2222
/*---------------------------------------------------------------------------*/

modules/passmonl/utilFEM.cc

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,18 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* utilFEM.h (C) 2022-2024 */
8+
/* utilFEM.h (C) 2022-2025 */
99
/* */
1010
/* PASSMO : Performant Assessment for Seismic Site Modelling with finite- */
1111
/* element (FEM) numerical modelling approach */
1212
/* Created by : E. Foerster */
1313
/*---------------------------------------------------------------------------*/
1414
/*---------------------------------------------------------------------------*/
1515
#include "FemUtils.h"
16-
#include "ArcaneFemFunctions.h"
1716
#include "utilFEM.h"
1817

19-
using namespace Arcane;
2018
using namespace Arcane::FemUtils;
2119

22-
/*---------------------------------------------------------------------------*/
23-
Real real3x3Trace(const Real3x3& mat) {
24-
return mat[0][0] + mat[1][1] + mat[2][2];
25-
}
26-
/*---------------------------------------------------------------------------*/
27-
Real3 real3x3GetSupOutdiagonal(const Real3x3& mat) {
28-
return {mat[0][1], mat[0][2], mat[1][2]};
29-
}
30-
/*---------------------------------------------------------------------------*/
31-
Real3 real3x3GetLowOutdiagonal(const Real3x3& mat){
32-
return {mat[1][0], mat[2][0], mat[2][1]};
33-
}
34-
/*---------------------------------------------------------------------------*/
35-
Real3x3 diagonalReal3x3(const Real3x3& mat){
36-
Real3x3 newmat;
37-
newmat[0][0] = mat[0][0];
38-
newmat[1][1] = mat[1][1];
39-
newmat[2][2] = mat[2][2];
40-
return newmat;
41-
}
42-
/*---------------------------------------------------------------------------*/
43-
Real3x3 outdiagonalReal3x3(const Real3x3& mat){
44-
return (mat - diagonalReal3x3(mat));
45-
}
46-
47-
bool real3x3IsSym(const Real3x3& mat)
48-
{
49-
Real3 matsup = real3x3GetSupOutdiagonal(mat);
50-
Real3 matlow = real3x3GetLowOutdiagonal(mat);
51-
return (matsup == matlow);
52-
}
53-
5420
//! Friend function for multiplication: Tensor4 * Tensor2
5521
Arcane::FemUtils::Tensor2 operator*(const Tensor4& tens, const Arcane::FemUtils::Tensor2& vector) {
5622
Arcane::FemUtils::Tensor2 result;

0 commit comments

Comments
 (0)