Skip to content

Commit c3588a9

Browse files
committed
PASSMONL DEVS: stress prediction implementation
1 parent 6c0c4e3 commit c3588a9

File tree

8 files changed

+150
-71
lines changed

8 files changed

+150
-71
lines changed

femutils/FemUtils.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,12 @@ class Tensor2
769769
this->add(tb);
770770
}
771771

772+
//! Add b to this Tensor2
773+
ARCCORE_HOST_DEVICE void add(const RealVector<6>& b) {
774+
for (Arcane::Int32 i = 0; i < 6; ++i)
775+
m_vec(i) += b(i);
776+
}
777+
772778
//! Substract b to this Tensor2
773779
ARCCORE_HOST_DEVICE void sub(const Tensor2& b) {
774780
for (Arcane::Int32 i = 0; i < 6; ++i)
@@ -780,6 +786,12 @@ class Tensor2
780786
this->sub(tb);
781787
}
782788

789+
//! Substract b to this Tensor2
790+
ARCCORE_HOST_DEVICE void sub(const RealVector<6>& b) {
791+
for (Arcane::Int32 i = 0; i < 6; ++i)
792+
m_vec(i) -= b(i);
793+
}
794+
783795
//! Scalar multiplication: Tensor * scalar
784796
ARCCORE_HOST_DEVICE Tensor2 operator*(Real scalar) const {
785797
Tensor2 result;

femutils/GaussDoFsOnCells.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class GaussDoFsOnCells::Impl
5757
VariableDoFReal* m_gauss_weight = nullptr;
5858
VariableDoFReal* m_gauss_jacobian = nullptr;
5959
VariableDoFArrayReal* m_gauss_law_param = nullptr;
60+
VariableDoFArrayReal* m_gauss_law_history_param = nullptr;
6061

6162
/* VariableDoFArrayTensor2* m_gauss_stress = nullptr;
6263
VariableDoFArrayTensor2* m_gauss_strain = nullptr;
@@ -90,6 +91,7 @@ GaussDoFsOnCells::
9091
delete m_p->m_gauss_strain;
9192
delete m_p->m_gauss_strain_plastic;
9293
delete m_p->m_gauss_law_param;
94+
delete m_p->m_gauss_law_history_param;
9395
delete m_p;
9496
}
9597

@@ -171,6 +173,7 @@ initialize(IMesh* mesh, Int32 max_nb_gauss_per_cell)
171173
m_p->m_gauss_shape = new VariableDoFArrayReal(VariableBuildInfo(mesh, "GaussShape", "GaussCellFamily"));
172174
m_p->m_gauss_shapederiv = new VariableDoFArrayReal3(VariableBuildInfo(mesh, "GaussShapeDeriv", "GaussCellFamily"));
173175
m_p->m_gauss_law_param = new VariableDoFArrayReal(VariableBuildInfo(mesh, "GaussLawParam", "GaussCellFamily"));
176+
m_p->m_gauss_law_history_param = new VariableDoFArrayReal(VariableBuildInfo(mesh, "GaussLawHistoryParam", "GaussCellFamily"));
174177

175178
/* m_p->m_gauss_stress = new VariableDoFArrayTensor2(VariableBuildInfo(mesh, "GaussStress", "GaussCellFamily"));
176179
m_p->m_gauss_strain = new VariableDoFArrayTensor2(VariableBuildInfo(mesh, "GaussStrain", "GaussCellFamily"));
@@ -236,6 +239,14 @@ VariableDoFArrayReal& GaussDoFsOnCells::
236239
gaussLawParam(){
237240
return *m_p->m_gauss_law_param;
238241
}
242+
243+
/*---------------------------------------------------------------------------*/
244+
/*---------------------------------------------------------------------------*/
245+
VariableDoFArrayReal& GaussDoFsOnCells::
246+
gaussLawHistoryParam(){
247+
return *m_p->m_gauss_law_param;
248+
}
249+
239250
/*---------------------------------------------------------------------------*/
240251
/*---------------------------------------------------------------------------*/
241252

femutils/GaussDoFsOnCells.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class GaussDoFsOnCells
7070
Arcane::VariableDoFReal& gaussWeight();
7171
Arcane::VariableDoFReal& gaussJacobian();
7272
Arcane::VariableDoFArrayReal& gaussLawParam();
73+
Arcane::VariableDoFArrayReal& gaussLawHistoryParam();
7374

7475
/* Arcane::VariableDoFArrayTensor2& gaussStress();
7576
Arcane::VariableDoFArrayTensor2& gaussStrain();

modules/passmonl/LawDispatcher.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ LawDispatcher::LawDispatcher(TypesNLDynamic::eLawType law_type, bool default_par
9696

9797
switch(law_type){
9898

99-
case TypesNLDynamic::UNKNOWN:
100-
case TypesNLDynamic::HOOKE: m_nb_law_param = 2;
99+
case TypesNLDynamic::HOOKE: m_nb_law_param = 2; m_nb_law_history_param = 0;
101100
break;
102101

103102
case TypesNLDynamic::DRUCKP:
104-
case TypesNLDynamic::MOHRC: m_nb_law_param = 7;
103+
case TypesNLDynamic::MOHRC: m_nb_law_param = 7; m_nb_law_history_param = 1;
105104
break;
106105

107-
default: m_nb_law_param = 2;
106+
case TypesNLDynamic::UNKNOWN:
107+
default: m_nb_law_param = 2; m_nb_law_history_param = 0;
108108
break;
109109
}
110110
}
@@ -171,10 +171,11 @@ Tensor4 LawDispatcher::computeTangentTensor(const Tensor2& sig) {
171171

172172
/*---------------------------------------------------------------------------*/
173173
/*---------------------------------------------------------------------------*/
174-
bool LawDispatcher::initState(const Tensor2& sig, RealConstArrayView& history_vars)
174+
bool LawDispatcher::initState(const Tensor2& sig)
175175
{
176176
if (sig == Tensor2::zero()) return true;
177177

178+
ConstArrayView<Real> history_vars = m_history_vars.constView();
178179
m_history_vars = initHistoryVars(history_vars);
179180

180181
auto f = m_init_state[m_law_type];
@@ -260,4 +261,5 @@ void ReadLawBlock(istream& is, Integer nblock) {
260261
stop = true;
261262
}
262263
} while(!stop);
263-
}
264+
}
265+

modules/passmonl/LawDispatcher.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class LawDispatcher {
4545
public:
4646
Tensor4 computeElastTensor(const Tensor2& sig);
4747
Tensor4 computeTangentTensor(const Tensor2& sig);
48-
bool initState(const Tensor2& sig, RealConstArrayView& history_vars);
48+
bool initState(const Tensor2& sig);
4949
RealUniqueArray initHistoryVars(RealConstArrayView& history_vars);
5050
void computeStress(bool isRef);
5151
RealUniqueArray initConsts(RealConstArrayView& law_params);
@@ -69,6 +69,7 @@ class LawDispatcher {
6969
void setStrainIncrement(const Tensor2&);
7070

7171
[[nodiscard]] Integer getNbLawParam() const { return m_nb_law_param; }
72+
[[nodiscard]] Integer getNbLawHistoryParam() const { return m_nb_law_history_param; }
7273

7374
void setLambda(Real lambda) { m_Lambda = lambda; }
7475
void setMu(Real mu) { m_Mu = mu; }
@@ -77,9 +78,12 @@ class LawDispatcher {
7778
void setLawParams(const RealUniqueArray& lawparams) {
7879
m_law_params = lawparams.clone();
7980
}
81+
void setLawHistoryParams(const RealUniqueArray& lawhistparams) {
82+
m_history_vars = lawhistparams.clone();
83+
}
8084

8185
private:
82-
std::function<Tensor4(RealConstArrayView& law_params, RealArrayView& history_vars, Tensor2& sig, Tensor2& eps, Tensor2& epsp, Tensor2& dsig,
86+
std::function<Tensor4(RealConstArrayView& law_params, RealArrayView& history_vars, Tensor2& sig, Tensor2& eps, Tensor2& epsp, Tensor2& dsig,
8387
const Tensor2& deps, bool isRef)> m_compute_stress[NB_LAW_TYPE];
8488
std::function<Tensor4(RealConstArrayView& law_params, const Tensor2& sig)> m_compute_elast_tensor[NB_LAW_TYPE];
8589
std::function<Tensor4(RealConstArrayView& law_params, RealArrayView& history_vars,
@@ -106,6 +110,7 @@ class LawDispatcher {
106110
String m_name{};
107111
bool m_default{true};
108112
Integer m_nb_law_param{2};
113+
Integer m_nb_law_history_param{0};
109114
};
110115

111116
#endif //PASSMO_LAWDISPATCHER_H

modules/passmonl/NLDynamic.axl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@
505505
<simple name="nb-law-param" type="integer" default = "2" optional="true">
506506
<description>Number of law parameters for the selected constitutive model (including the 2 elastic coef.)</description>
507507
</simple>
508+
<simple name="nb-law-hist-param" type="integer" default = "0" optional="true">
509+
<description>Number of law history parameters for the selected constitutive model</description>
510+
</simple>
508511
<simple name="i-law-param" type="integer" default = "0" optional="true">
509512
<description>ith law parameters block in the constitutive models file</description>
510513
</simple>

0 commit comments

Comments
 (0)