Skip to content

Commit f109353

Browse files
committed
PASSMO-NL: build error with REL_PREC corrected (ppassmo module also impacted)
PASSMO: checking error due to modified tol (chnaged from 1e-10 to 1e-16 for comparisons with soildynamic module) not coherent with provided tests results. Reverting to 1e-10 (precision error to be further investigated).
1 parent 5f991ed commit f109353

File tree

14 files changed

+99
-85
lines changed

14 files changed

+99
-85
lines changed

femutils/ArcaneFemFunctions.h

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
using namespace Arcane;
3030
using namespace Arcane::FemUtils;
31-
Real REL_PREC{1.0e-15};
3231
/*---------------------------------------------------------------------------*/
3332
/**
3433
* @brief Contains various functions & operations related to FEM calculations.
@@ -1752,6 +1751,7 @@ class ArcaneFemFunctions
17521751
#ifdef _DEBUG
17531752
ARCANE_ASSERT(inod >= 0 && inod < 8);
17541753
#endif
1754+
Real tol{1.0e-15};
17551755

17561756
auto r{ ref_coord[0] }, s{ ref_coord[1] };
17571757
auto ri{ 1. }, si{ 1. };
@@ -1793,16 +1793,17 @@ class ArcaneFemFunctions
17931793
Phi = (1 + r0) * (1 + s0) * t0 / 4.;
17941794

17951795
else { // Middle nodes
1796-
if (fabs(ri) < REL_PREC)
1796+
if (fabs(ri) < tol)
17971797
Phi = (1 - r * r) * (1 + s0) / 2.;
1798-
else if (fabs(si) < REL_PREC)
1798+
else if (fabs(si) < tol)
17991799
Phi = (1 - s * s) * (1 + r0) / 2.;
18001800
}
18011801
return Phi;
18021802
}
18031803

18041804
static inline Real3 quad8ShapeFuncDeriv(Integer inod, Real3 ref_coord)
18051805
{
1806+
Real tol{1.0e-15};
18061807

18071808
auto r{ ref_coord[0] }, s{ ref_coord[1] };
18081809
auto ri{ 1. }, si{ 1. };
@@ -1845,11 +1846,11 @@ class ArcaneFemFunctions
18451846
dPhi.y = si * (1 + r0) * (t0 + 1. + s0) / 4.;
18461847
}
18471848
else { // Middle nodes
1848-
if (fabs(ri) < REL_PREC) {
1849+
if (fabs(ri) < tol) {
18491850
dPhi.x = -r * (1 + s0);
18501851
dPhi.y = si * (1 - r * r) / 2.;
18511852
}
1852-
else if (fabs(si) < REL_PREC) {
1853+
else if (fabs(si) < tol) {
18531854
dPhi.x = -s * (1 + r0);
18541855
dPhi.y = ri * (1 - s * s) / 2.;
18551856
}
@@ -1980,6 +1981,8 @@ class ArcaneFemFunctions
19801981
#ifdef _DEBUG
19811982
ARCANE_ASSERT(inod >= 0 && inod < 20);
19821983
#endif
1984+
Real tol{1.0e-15};
1985+
19831986
auto x{ ref_coord[0] }, y{ ref_coord[1] }, z{ ref_coord[2] };
19841987
auto ri{ 1. }, si{ 1. }, ti{ 1. }; // Normalized coordinates (=+-1) =>node index 0 = (1,1,1)
19851988

@@ -2059,18 +2062,19 @@ class ArcaneFemFunctions
20592062
Phi = (1 + r0) * (1 + s0) * (1 + t0) * t / 8.;
20602063

20612064
else { // Middle nodes
2062-
if (math::abs(ri) < REL_PREC)
2065+
if (math::abs(ri) < tol)
20632066
Phi = (1 - x * x) * (1 + s0) * (1 + t0) / 4.;
2064-
else if (math::abs(si) < REL_PREC)
2067+
else if (math::abs(si) < tol)
20652068
Phi = (1 - y * y) * (1 + r0) * (1 + t0) / 4.;
2066-
else if (math::abs(ti) < REL_PREC)
2069+
else if (math::abs(ti) < tol)
20672070
Phi = (1 - z * z) * (1 + r0) * (1 + s0) / 4.;
20682071
}
20692072
return Phi;
20702073
}
20712074

20722075
static inline Real3 hexa20ShapeFuncDeriv(Integer inod, Real3 ref_coord)
20732076
{
2077+
Real tol{1.0e-15};
20742078

20752079
auto x{ ref_coord[0] }, y{ ref_coord[1] }, z{ ref_coord[2] };
20762080
auto ri{ 1. }, si{ 1. }, ti{ 1. }; // Normalized coordinates (=+-1) =>node index 0 = (1,1,1)
@@ -2147,17 +2151,17 @@ class ArcaneFemFunctions
21472151
}
21482152
else { // Middle nodes
21492153
auto x2{ x * x }, y2{ y * y }, z2{ z * z };
2150-
if (math::abs(ri) < REL_PREC) {
2154+
if (math::abs(ri) < tol) {
21512155
dPhi.x = -x * (1 + s0) * (1 + t0) / 2.;
21522156
dPhi.y = si * (1 - x2) * (1 + t0) / 4.;
21532157
dPhi.z = ti * (1 - x2) * (1 + s0) / 4.;
21542158
}
2155-
else if (math::abs(si) < REL_PREC) {
2159+
else if (math::abs(si) < tol) {
21562160
dPhi.x = ri * (1 - y2) * (1 + t0) / 4.;
21572161
dPhi.y = -y * (1 + r0) * (1 + t0) / 2.;
21582162
dPhi.z = ti * (1 - y2) * (1 + r0) / 4.;
21592163
}
2160-
else if (math::abs(ti) < REL_PREC) {
2164+
else if (math::abs(ti) < tol) {
21612165
dPhi.x = ri * (1 - z2) * (1 + s0) / 4.;
21622166
dPhi.y = si * (1 - z2) * (1 + r0) / 4.;
21632167
dPhi.z = -z * (1 + r0) * (1 + s0) / 2.;
@@ -2468,6 +2472,8 @@ class ArcaneFemFunctions
24682472
#ifdef _DEBUG
24692473
ARCANE_ASSERT(inod >= 0 && inod < 5);
24702474
#endif
2475+
Real tol{1.0e-15};
2476+
24712477
auto r{ ref_coord[0] }, s{ ref_coord[1] }, t{ ref_coord[2] };
24722478
auto r1{ -1. }, s1{ 1. }, r2{ -1. }, s2{ -1. };
24732479

@@ -2476,7 +2482,7 @@ class ArcaneFemFunctions
24762482
auto ti{ t - 1. };
24772483
auto t0{ 0. };
24782484

2479-
if (math::abs(ti) < REL_PREC)
2485+
if (math::abs(ti) < tol)
24802486
ti = 0.;
24812487
else
24822488
t0 = -1. / ti / 4.;
@@ -2507,13 +2513,15 @@ class ArcaneFemFunctions
25072513
#ifdef _DEBUG
25082514
ARCANE_ASSERT(inod >= 0 && inod < 5);
25092515
#endif
2516+
Real tol{1.0e-15};
2517+
25102518
auto r{ ref_coord[0] }, s{ ref_coord[1] }, t{ ref_coord[2] };
25112519
auto r1{ -1. }, s1{ 1. }, r2{ -1. }, s2{ -1. };
25122520

25132521
auto ti{ t - 1. };
25142522
auto t0{ 0. };
25152523

2516-
if (math::abs(ti) < REL_PREC)
2524+
if (math::abs(ti) < tol)
25172525
ti = 0.;
25182526
else
25192527
t0 = -1. / ti / 4.;
@@ -2544,7 +2552,7 @@ class ArcaneFemFunctions
25442552
dPhi.x = t0 * (rr * r + rs * s + r12 * ti);
25452553
dPhi.y = t0 * (rs * r + ss * s + s12 * ti);
25462554

2547-
if (math::abs(ti) < REL_PREC)
2555+
if (math::abs(ti) < tol)
25482556
dPhi.z = 0.;
25492557
else
25502558
dPhi.z = t0 * (r12 * r + s12 * s + 2. * ti) + t02 * (r1 * r + s1 * s + ti) * (r2 * r + s2 * s + ti);

femutils/FemUtils.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -821,14 +821,6 @@ class Tensor2
821821

822822
return mat;
823823
}
824-
//! Friend function to convert Real3x3 matrix (symmetric) to Tensor
825-
ARCCORE_HOST_DEVICE friend Tensor2 fromReal3x3ToTensor2(const Real3x3& mat) {
826-
Tensor2 vector;
827-
for (Arcane::Int32 i = 0; i < 3; i++) vector(i) = mat[i][i];
828-
for (Arcane::Int32 i = 3; i < 5; i++) vector(i) = mat[0][i - 2];
829-
vector(5) = mat[1][2];
830-
return vector;
831-
}
832824
};
833825

834826
/*---------------------------------------------------------------------------*/

modules/passmo/ElastodynamicModule.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
/*---------------------------------------------------------------------------*/
3030
using namespace Arcane;
3131
using namespace Arcane::FemUtils;
32-
extern Real REL_PREC;
3332
/*---------------------------------------------------------------------------*/
3433
/*---------------------------------------------------------------------------*/
3534
ElastodynamicModule::ElastodynamicModule(const ModuleBuildInfo& mbi)
@@ -422,6 +421,8 @@ _initGaussStep()
422421
VariableDoFArrayReal& gauss_shape(m_gauss_on_cells.gaussShape());
423422
VariableDoFArrayReal3& gauss_shapederiv(m_gauss_on_cells.gaussShapeDeriv());
424423

424+
Real tol{1.0e-15};
425+
425426
ENUMERATE_CELL (icell, allCells()) {
426427
const Cell& cell = *icell;
427428
auto cell_type = cell.type();
@@ -456,7 +457,7 @@ _initGaussStep()
456457
else
457458
jacobian = ArcaneFemFunctions::MeshOperation::computeLengthEdge2(cell, m_node_coord) / 2.;
458459

459-
if (fabs(jacobian) < REL_PREC) {
460+
if (fabs(jacobian) < tol) {
460461
ARCANE_FATAL("Cell jacobian is null");
461462
}
462463
gauss_jacobian[gauss_pti] = jacobian;
@@ -549,7 +550,8 @@ _checkResultFile()
549550
if (filename.empty())
550551
return;
551552
const double epsilon = 1.0e-4;
552-
const double min_value_to_test = 1.0e-16;
553+
// const double min_value_to_test = 1.0e-16;
554+
const double min_value_to_test = 1.0e-10;
553555
Arcane::FemUtils::checkNodeResultFile(traceMng(), filename, m_displ, epsilon, min_value_to_test);
554556
}
555557
/*---------------------------------------------------------------------------*/
@@ -1354,6 +1356,7 @@ _computeJacobian(const ItemWithNodes& cell,const Int32& ig, const RealUniqueArra
13541356

13551357
// Jacobian matrix computed at the integration point
13561358
Real3x3 jac;
1359+
Real tol{1.0e-15};
13571360

13581361
for (Int32 inod = 0, indx = 4; inod < n; ++inod) {
13591362

@@ -1380,7 +1383,7 @@ _computeJacobian(const ItemWithNodes& cell,const Int32& ig, const RealUniqueArra
13801383
else
13811384
jacobian = ArcaneFemFunctions::MeshOperation::computeLengthEdge2(cell, m_node_coord) / 2.;
13821385

1383-
if (fabs(jacobian) < REL_PREC) {
1386+
if (fabs(jacobian) < tol) {
13841387
ARCANE_FATAL("Cell jacobian is null");
13851388
}
13861389
return jac;

modules/passmo/analytic_func.cc

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,25 @@
2525
* \brief Ricker analytical function.
2626
*/
2727
Real AnalyticFunc::getRicker(const Real& time) const{
28+
Real tol{1.0e-15};
2829
Real PI{acos(-1.)},
29-
t{ PI * (time - m_ts) / m_tp },
30-
t2{ t * t },
31-
expt{ m_amplit * exp(-t2) },
32-
k{ 1.5 - sqrt(1.5) },
33-
val{0.};
30+
t{ PI * (time - m_ts) / m_tp },
31+
t2{ t * t },
32+
expt{ m_amplit * exp(-t2) },
33+
k{ 1.5 - sqrt(1.5) },
34+
val{0.};
3435

3536
switch (m_order){
36-
case 0 : val = expt; break;
37+
case 0 : val = expt; break;
3738

38-
case 1 : val = - sqrt(2.)*exp(0.5)*expt*t; break;
39+
case 1 : val = - sqrt(2.)*exp(0.5)*expt*t; break;
3940

40-
case 3 : val = exp(k)*expt*(1.5 - t2)*t/sqrt(1.5)/sqrt(k); break;
41+
case 3 : val = exp(k)*expt*(1.5 - t2)*t/sqrt(1.5)/sqrt(k); break;
4142

42-
default : val = 0.5*exp(1.5)*expt*(t2 - 0.5); break; // Default = order 2
43+
default : val = 0.5*exp(1.5)*expt*(t2 - 0.5); break; // Default = order 2
4344
}
4445

45-
if (fabs(val) <= REL_PREC) val = 0.;
46+
if (fabs(val) <= tol) val = 0.;
4647
return val;
4748
}
4849

@@ -52,9 +53,10 @@ Real AnalyticFunc::getRicker(const Real& time) const{
5253
* \brief Harmonic function: A*sin(2*PI*t/tp + phase)
5354
*/
5455
Real AnalyticFunc::getHarmonic(const Real& time) const{
56+
Real tol{1.0e-15};
5557
Real PI{acos(-1.)};
5658
Real val = m_amplit*sin(2*PI*time/m_tp + m_phase);
57-
if (fabs(val) <= REL_PREC) val = 0.;
59+
if (fabs(val) <= tol) val = 0.;
5860
return val;
5961
}
6062

@@ -64,12 +66,13 @@ Real AnalyticFunc::getHarmonic(const Real& time) const{
6466
* \brief Decay analytical function: f(t) = A*exp(-coef*t)
6567
*/
6668
Real AnalyticFunc::getDecay(const Real& time) const{
69+
Real tol{1.0e-15};
6770
Real x = -m_coef*time;
6871
if (x >= DBL_MAX_10_EXP) x = DBL_MAX_10_EXP;
6972
else if (x < DBL_MIN_10_EXP) x = DBL_MIN_10_EXP;
7073

7174
Real val = m_amplit*exp(x);
72-
if (fabs(val) <= REL_PREC) val = 0.;
75+
if (fabs(val) <= tol) val = 0.;
7376
return val;
7477
}
7578

@@ -79,13 +82,14 @@ Real AnalyticFunc::getDecay(const Real& time) const{
7982
* \brief Tsang function: : f(t) = A*sin(2*PI*t/tp + phase)*exp(-coef*t)
8083
*/
8184
Real AnalyticFunc::getTsang(const Real& time) const{
85+
Real tol{1.0e-15};
8286
Real PI{acos(-1.)};
8387
Real x = -m_coef*time;
8488
if (x >= DBL_MAX_10_EXP) x = DBL_MAX_10_EXP;
8589
else if (x < DBL_MIN_10_EXP) x = DBL_MIN_10_EXP;
8690

8791
Real val = m_amplit*exp(x)*sin(2*PI*time/m_tp + m_phase);
88-
if (fabs(val) <= REL_PREC) val = 0.;
92+
if (fabs(val) <= tol) val = 0.;
8993
return val;
9094
}
9195

@@ -98,4 +102,3 @@ Real AnalyticFunc::getDirac(const Real& time) const{
98102
if (time != m_tp) return 0.;
99103
return m_amplit;
100104
}
101-

modules/passmo/analytical_func.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "arcane/MathUtils.h"
2121
#include <arcane/VariableTypes.h>
2222
using namespace Arcane;
23-
extern Real REL_PREC;
2423

2524
/*!
2625
* \brief Class to define analytical functions useful to define incident wave motions

modules/passmonl/LawDispatcher.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern RealUniqueArray HookeInitHistoryVars(RealConstArrayView& /*history_vars*/
3434
extern bool HookeInitState(const Tensor2& /*sig*/, RealArrayView& /*history_vars*/);
3535
extern RealUniqueArray HookeReadLawParams(Real /*lambda*/, Real /*mu*/, bool /*default_param*/, const String& /*name*/, Integer /*ilaw*/);
3636
extern Tensor4 HookeComputeStress(RealConstArrayView& /*law_params*/, RealArrayView& /*history_vars*/, Tensor2& /*sig*/, Tensor2& /*eps*/, Tensor2& /*epsp*/, Tensor2& /*dsig*/,
37-
const Tensor2& /*deps*/, bool /*is_converge*/);
37+
const Tensor2& /*deps*/, bool /*isRef*/);
3838

3939
/*---------------------------------------------------------------------------*/
4040
/*---------------------------------------------------------------------------*/
@@ -48,7 +48,7 @@ extern RealUniqueArray DruckPInitHistoryVars(RealConstArrayView& /*history_vars*
4848
extern bool DruckPInitState(const Tensor2& /*sig*/, RealArrayView& /*history_vars*/);
4949
extern RealUniqueArray DruckPReadLawParams(Real /*lambda*/, Real /*mu*/, bool /*default_param*/, const String& /*name*/, Integer /*ilaw*/);
5050
extern Tensor4 DruckPComputeStress(RealConstArrayView& /*law_params*/, RealArrayView& /*history_vars*/, Tensor2& /*sig*/, Tensor2& /*eps*/, Tensor2& /*epsp*/, Tensor2& /*dsig*/,
51-
const Tensor2& /*deps*/, bool /*is_converge*/);
51+
const Tensor2& /*deps*/, bool /*isRef*/);
5252
/*---------------------------------------------------------------------------*/
5353
/*---------------------------------------------------------------------------*/
5454

@@ -129,16 +129,16 @@ void LawDispatcher::setStrainIncrement(const Tensor2& tensor) { m_deps = tensor;
129129

130130
/*---------------------------------------------------------------------------*/
131131
/*---------------------------------------------------------------------------*/
132-
void LawDispatcher::computeStress(bool is_converge) {
132+
void LawDispatcher::computeStress(bool isRef) {
133133

134134
auto f = m_compute_stress[m_law_type];
135135
RealConstArrayView law_params = m_law_params.constView();
136136
RealArrayView history_vars = m_history_vars.view();
137137

138138
if (f != nullptr)
139139
{
140-
Tensor4 tangent_tensor = f(law_params,history_vars,m_sig,m_eps,m_epsp,m_dsig,m_deps,is_converge);
141-
if (is_converge) m_tangent_tensor = tangent_tensor;
140+
Tensor4 tangent_tensor = f(law_params,history_vars,m_sig,m_eps,m_epsp,m_dsig,m_deps,isRef);
141+
if (isRef) m_tangent_tensor = tangent_tensor;
142142
}
143143
}
144144

modules/passmonl/LawDispatcher.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class LawDispatcher {
4747
Tensor4 computeTangentTensor(const Tensor2& sig);
4848
bool initState(const Tensor2& sig, RealConstArrayView& history_vars);
4949
RealUniqueArray initHistoryVars(RealConstArrayView& history_vars);
50-
void computeStress(bool is_converge);
50+
void computeStress(bool isRef);
5151
RealUniqueArray initConsts(RealConstArrayView& law_params);
5252
RealUniqueArray readLawParams(Real lambda, Real mu, bool default_param, const String& name, Integer ilaw);
5353
RealUniqueArray updateHistoryVars();
@@ -79,13 +79,15 @@ class LawDispatcher {
7979
}
8080

8181
private:
82-
std::function<Tensor4(RealConstArrayView& law_params, RealArrayView& history_vars, Tensor2& sig, Tensor2& eps, Tensor2& epsp, Tensor2& dsig,
83-
const Tensor2& deps, bool is_converge)> m_compute_stress[NB_LAW_TYPE];
82+
std::function<Tensor4(RealConstArrayView& law_params, RealArrayView& history_vars, Tensor2& sig, Tensor2& eps, Tensor2& epsp, Tensor2& dsig,
83+
const Tensor2& deps, bool isRef)> m_compute_stress[NB_LAW_TYPE];
8484
std::function<Tensor4(RealConstArrayView& law_params, const Tensor2& sig)> m_compute_elast_tensor[NB_LAW_TYPE];
85-
std::function<Tensor4(RealConstArrayView& law_params, RealArrayView& history_vars, const Tensor2& sig, const Tensor2& deps)> m_compute_tangent_tensor[NB_LAW_TYPE];
85+
std::function<Tensor4(RealConstArrayView& law_params, RealArrayView& history_vars,
86+
const Tensor2& sig, const Tensor2& deps)> m_compute_tangent_tensor[NB_LAW_TYPE];
8687
std::function<bool(const Tensor2& sig, RealArrayView& history_vars)> m_init_state[NB_LAW_TYPE];
8788
std::function<RealUniqueArray(RealConstArrayView& history_vars)> m_init_history_vars[NB_LAW_TYPE];
88-
std::function<RealUniqueArray(Real lambda, Real mu, bool default_param, const String& name, Integer ilaw)> m_read_law_params[NB_LAW_TYPE];
89+
std::function<RealUniqueArray(Real lambda, Real mu, bool default_param,
90+
const String& name, Integer ilaw)> m_read_law_params[NB_LAW_TYPE];
8991
std::function<RealUniqueArray(RealConstArrayView& law_params)> m_init_consts[NB_LAW_TYPE];
9092

9193
Tensor2 m_sig{};

modules/passmonl/NLDynamicModule.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,12 +2373,11 @@ void NLDynamicModule::stress_prediction(bool init, bool isRef)
23732373
DoFLocalId gauss_pti = gauss_point.dofId(cell, ig);
23742374
Int32 gaussnum = gauss_pti.localId();
23752375

2376-
Tensor2 epsn;
2376+
Tensor2 epsn, sign, epspn;
23772377
epsn.fromReal3x3ToTensor2(gauss_strain[gauss_pti][1]);
2378-
Tensor2 sign;
23792378
sign.fromReal3x3ToTensor2(gauss_stress[gauss_pti][1]);
2380-
Tensor2 epspn;
23812379
epspn.fromReal3x3ToTensor2(gauss_strain_plastic[gauss_pti][1]);
2380+
23822381
Tensor2 deps;
23832382
{
23842383
// calcul deps à faire avec unodes
@@ -2410,7 +2409,7 @@ void NLDynamicModule::stress_prediction(bool init, bool isRef)
24102409
/*---------------------------------------------------------------------------*/
24112410
// ! Stress correction
24122411
//
2413-
void NLDynamicModule::stress_correction(bool isRef)
2412+
void NLDynamicModule::stress_correction(bool converge, bool isRef)
24142413
{
24152414
}
24162415

0 commit comments

Comments
 (0)