TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Structural_dynamic_mesh_model.h
1/****************************************************************************
2* Copyright (c) 2025, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Structural_dynamic_mesh_model_included
17#define Structural_dynamic_mesh_model_included
18
19#include <Interprete_geometrique_base.h>
20#include <stdexcept>
21#include <vector>
22#include <map>
23
24#ifdef __NVCOMPILER
25#pragma diag_suppress 68
26#endif
27#include <MGIS/Behaviour/Behaviour.hxx>
28#include <MGIS/Behaviour/BehaviourDataView.hxx>
29#include <MGIS/Behaviour/Integrate.hxx>
30#ifdef __NVCOMPILER
31#pragma diag_warning 68
32#endif
33
34// this enum defines the stress measure that the behavior is expected to return when calling 'integrate'
35// cauchy -> cauchy stress tensor
36// pk1 -> first Piola-Kirchhoff tensor (aka Boussinesq tensor).
37// This one is non-symmetric. It is such that P=pk1:dFdt, and Div(pk1^t)=f
38// pk2 -> second Piola-Kirchhoff tensor
39// conjugate -> stress tensor conjugate with the input strain tensor, i.e. such that P=s:dedt
40// where 'P' is the mechanical power, 's' is the stress tensor and 'dedt' the rate of the input strain tensor
41enum class StressMeasureKind { cauchy, pk1, pk2, conjugate };
42
43// this enum defines the tangent operator that the behavior is expected to return when calling 'integrate'
44// none -> the tangent operator is not computed
45// dCauchydF -> derivative of the Cauchy stress tensor with respect to the gradient of the material deformation gradient
46// dPk2dE -> derivative of the 2nd Piola-Kirchhoff stress tensor with respect to the Green-Lagrange strain tensor
47// dPk1dF -> derivative of the 1st Piola-Kirchhoff stress tensor with respect to the gradient of the material deformation gradient
48enum class TangentOperatorKind { none, dCauchydF, dPk2dE, dPk1dF };
49
50class Domaine_ALE;
51
52
53class Structural_dynamic_mesh_model : public Interprete_geometrique_base
54{
55 Declare_instanciable_sans_constructeur(Structural_dynamic_mesh_model);
56
57
58public:
60 Entree& interpreter_(Entree&) override;
61
62 // Mfront behaviour
63 // ----------------
64
65 inline void setMfrontLibraryPath(const std::string& l) ;
66 inline void setMfrontModelName(const std::string& f) ;
67 inline void setMfrontHypothesis(const std::string& h) ;
68
69 // End Mfront behaviour
70 // --------------------
71
72 inline void setDensity(const double& rho) ;
73 inline void setInertialDamping(const double& D) ;
74 inline void setDtSafetyCoefficient(const double& c) ;
75 inline void setGridDtMin(const double& dt) ;
76 inline void setConfigurationResetDt(const double& dt) ;
77 inline void setMaxAddedMassRatio(const double& r) ;
78 inline void addMaterialProperty(const std::string name, const std::vector<double> val) ;
79 inline int getNbNodesPerElem() ;
80 inline double getDensity() ;
81 inline double getDampingCoefficient() ;
82 inline double getGridDtMin() ;
83 inline void setMassElem(const double& elmass) ;
84 inline const DoubleVect& getMeshPbPressure() const;
85 inline const DoubleVect& getMeshPbVonMises() const;
86 inline const DoubleTab& getMeshPbForceFace() const;
87 inline const DoubleTab& getMeshDisplacement() const {return u; }
88 inline const DoubleTab& getMeshVelocity() const {return v; }
89 inline const DoubleTab& getMeshAcceleration() const {return a; }
90 inline const DoubleTab& getMeshPosition() const {return x; }
91 inline const DoubleTab& getMeshReferenceConfiguration() const {return B0_; }
92 inline const DoubleTab& getMeshTransformationGradient() const {return Ft_; }
93 inline const DoubleTab& getMeshStress() const {return Stress_; }
94 inline const int& getMeshReferenceConfigurationNbComp() const {return dimB0_;}
95 inline const int& getMeshTransformationGradientNbComp() const {return nSymSize_;}
96 inline const int& getMeshStressNbComp() const {return symSize_;}
97
98 inline void applyDtCoefficient() ;
99
100 void initMfrontBehaviour() ;
101 void initDynamicMeshProblem(const double temps, const int nsom, const int nelem, const int nface, const MD_Vector& md, const MD_Vector& mde, const MD_Vector& mdf) ;
102
103 void setLocalFields(const int elnodes[4], const int elem) ;
104 void computeInternalForces(double& volume, double& xlong, double& cSound, double& Pressure, double& VonMises) ;
105 void setGlobalFields(const int elnodes[4], const double Pressure, const double VonMises) ;
106 double computeCriticalDt(const double volume, const double xlong, const double cSound, const double dtMin, double& scaleMass) ;
107 void computeForceFaces(const int nb_faces, const int nb_som_face, const IntTab& face_sommets) ;
108 void checkElemOrientation(int elnodes[4], const int elem) ;
109 void resumptionMesh(double, DoubleTab&, DoubleTab&, DoubleTab&, DoubleTab&, DoubleTab&, DoubleTab&, DoubleTab&);
110 inline void saveBeginning_of_stepVariables() ;
112
113 void solveDynamicMeshProblem(const double, const DoubleTab&, const IntVect&,
114 DoubleTab&, const int , const int , const int ,
115 const IntTab& , const int , const int , const IntTab& , const Domaine_ALE&) ;
116
117 // Global vectors and arrays for dynamic time integration
118 // ------------------------------------------------------
119
120 DoubleTab x ;
121 DoubleTab u ;
122 DoubleTab v ;
123 DoubleTab vp ;
124 DoubleTab a ;
125 DoubleTab ff ;
126
127 DoubleVect mass ;
128 DoubleVect nodalScaleMass ;
129 double totalMass = 0.;
130
131 // Public variables
132 // ----------------
133
134 int gridNStep = 0.;
135 double gridTime = 0.;
136 double gridTime_n=0. ;
137 double gridDt = 0.;
138 bool isMassBuilt = false;
139
141 double gridResetTime = 0.;
142
145
146 int resumption =0; //1 if resumption of calculation else 0
147
148 // ICoCo + FSI: acceleration solution within implicit iterations
149 // ----------------------------------------------------------------
150
151 int iCoCoImplicitIteration = -1 ; // Default, no ICoCo implicit coupling
154 DoubleTab xLast ;
155 DoubleTab vpLast ;
156 double dtLast ;
158
159protected:
160
161 // Mfront behaviour
162 // ----------------
163
164 mgis::behaviour::Behaviour mgisBehaviour_;
165 mgis::behaviour::BehaviourDataView mgisBehaviourData_;
166 std::vector<double> s0MaterialProperties_;
167 std::vector<double> s1MaterialProperties_;
168
169 static constexpr int stiffnessMatrixMinSize_ = 1 + mgis::behaviour::Behaviour::nopts;
170
171 void load_behaviour_(StressMeasureKind smk, TangentOperatorKind tok);
172
173
174 std::string l_; // behavior library path
175 std::string f_; // name of the behavior in the library
176 std::string h_; // modelling hypothesis (tridimentional, plane strain, plane stress, ...)
177 /*
178 Valid values for h_ are:
179 - `AxisymmetricalGeneralisedPlaneStrain`
180 - `AxisymmetricalGeneralisedPlaneStress`
181 - `Axisymmetrical`
182 - `PlaneStress`
183 - `PlaneStrain`
184 - `GeneralisedPlaneStrain`
185 - `Tridimensional`
186 */
187
188 std::map<std::string,std::vector<double>> matp_ ; // MFront material properties
189
190 double rdt_ = 1.; // this is used by mgis
191
192 // numerotation, mfront convention:
193 // for symetric tensors:
194 // - 2D: [t00, t11, t22, sqrt(2)*t01]
195 // - 3D: [t00, t11, t22, sqrt(2)*t01, sqrt(2)*t02, sqrt(2)*t12]
196 // for non-symetric tensors:
197 // - 2D: [t00, t11, t22, t01, t10]
198 // - 3D: [t00, t11, t22, t01, t10, t02, t20, t12, t21]
199 void integrate_behaviour_(double *const stress, // stress tensor
200 double *const ivar, // state variables
201 const double *const evar, // external variables
202 double *const stiff, // stiffness matrix
203 const double *const gradientOrStrain0, // deformation gradient or strain at the beginning of the time step
204 const double *const gradientOrStrain1, // deformation gradient or strain at the end of the time step
205 double *const vsound // speed of sound variables
206 );
207
208 // End Mfront behaviour
209 // --------------------
210
211 // Parameters and global variables
212 // -------------------------------
213
215 double density_ =0. ;
216 double dtSafetyCoefficient_ = 0.5 ;
217 double gridDtMin_ = 0 ;
218
219 int nSymSize_ =0; // length of non-symetric tensor in Voigt notation
220 int symSize_ =0; // length of symetric tensor in Voigt notation
221 int dimB0_ =0; // lenght of reference configuration array
222 DoubleTab Eta_ ; // Shape function derivatives
223
224 // Local variables for internal forces computation
225 // -----------------------------------------------
226
227 int iel_ =0; // id of current element
228 int nbn_ =0; // number of vertex nodes
229 DoubleTab xl_ ; // local current coordinates
230 DoubleTab ul_ ; // local nodal displacements
231 DoubleTab fl_ ; // local nodal forces
232
233 DoubleTab B0l_ ; // local B matrix on initial configuration
234
235 IntVect invertNum_ ; // need for inverting elem numerotation or not
236
237 // Global vectors and arrays for dynamic time integration
238 // ------------------------------------------------------
239
240 DoubleTab B0_ ;
241 DoubleTab Ft_ ;
242 DoubleTab Stress_ ;
243
244 DoubleVect massElem_ ;
245
246 // Fields for post-processing
247 DoubleVect meshPbPressure_ ;
248 DoubleVect meshPbVonMises_ ;
250
251 // ICoCo + FSI: save variables for implicit + subcycling iterations
252 // ----------------------------------------------------------------
253
254 double gridDt_n ;
256 DoubleTab x_n ;
257 DoubleTab u_n ;
258 DoubleTab v_n ;
259 DoubleTab a_n ;
260 DoubleTab B0_n ;
261 DoubleTab Ft_n ;
262 DoubleTab Stress_n ;
263
264 // ICoCo + FSI: acceleration solution within implicit iterations
265 // ----------------------------------------------------------------
266
267 DoubleVect cSoundElem_ ;
268
269 // Functions
270 // ---------
271
272 void triangleSurfLength_(double& aire, double& xlong, const double Det);
273 void tetrahedronVolLength_(double& vol, double& xlong, const double Det);
274 void setB0_(const DoubleTab& B) ;
275
276private:
277
278 // Mfront behaviour
279 // ----------------
280
281 int nbIvars_=0;
282 int nbEvars_ =0;
283 int sizeEvars_ =0;
284 int matpSize_ =0;
285 int KSize_ =0;
286 mgis::behaviour::Hypothesis hypothesis_;
287
288 bool loaded_ = false;
289
290 DoubleTab mfrontEvars_ ;
291
292 // End Mfront behaviour
293 // --------------------
294
295};
296
298{
299 l_ = l ;
300}
301
303{
304 f_ = f ;
305}
306
308{
309 h_ = h ;
310}
311
312inline void Structural_dynamic_mesh_model::setDensity(const double& rho)
313{
314 density_ = rho ;
315}
316
318{
319 inertialDamping_ = D ;
320}
321
326
328{
329 gridDtMin_ = dt ;
330}
331
333{
335 gridResetTime = configurationResetDt ; // first reset time
336}
337
339{
341}
342
343inline void Structural_dynamic_mesh_model::addMaterialProperty(const std::string name, const std::vector<double> val)
344{
345 matp_.insert(std::pair<std::string, std::vector<double>>(name, val)) ;
346}
347
349{
350 return nbn_ ;
351}
352
354{
355 return density_ ;
356}
357
362
363inline void Structural_dynamic_mesh_model::setMassElem(const double& elmass)
364{
365 massElem_[iel_] = elmass ;
366}
367
369{
370 return meshPbPressure_ ;
371}
372
374{
375 return meshPbVonMises_ ;
376}
377
379{
380 return meshPbForceFace_ ;
381}
382
387
389{
390 return gridDtMin_ ;
391}
392
394{
395 Cerr << "implicit iterations with structural grid problem: save beginning-of-step variables" << finl ;
397 gridDt_n = gridDt ;
399 x_n = x ;
400 u_n = u ;
401 v_n = v ;
402 a_n = a ;
403 B0_n = B0_ ;
404 Ft_n = Ft_ ;
405 Stress_n = Stress_ ;
406}
407
409{
410 Cerr << "implicit iterations with structural grid problem: reset variables to beginning-of-step" << finl ;
412 gridDt = gridDt_n ;
414 x = x_n ;
415 u = u_n ;
416 v = v_n ;
417 a = a_n ;
418 B0_ = B0_n ;
419 Ft_ = Ft_n ;
420 Stress_ = Stress_n ;
421}
422
423#endif
: Cette classe est un OWN_PTR mais l'objet pointe est partage entre plusieurs
Definition MD_Vector.h:48
friend class Entree
Definition Objet_U.h:76
mgis::behaviour::BehaviourDataView mgisBehaviourData_
void setMfrontLibraryPath(const std::string &l)
void setMfrontHypothesis(const std::string &h)
std::map< std::string, std::vector< double > > matp_
void triangleSurfLength_(double &aire, double &xlong, const double Det)
void load_behaviour_(StressMeasureKind smk, TangentOperatorKind tok)
void initDynamicMeshProblem(const double temps, const int nsom, const int nelem, const int nface, const MD_Vector &md, const MD_Vector &mde, const MD_Vector &mdf)
const DoubleTab & getMeshDisplacement() const
void setLocalFields(const int elnodes[4], const int elem)
void computeForceFaces(const int nb_faces, const int nb_som_face, const IntTab &face_sommets)
void resumptionMesh(double, DoubleTab &, DoubleTab &, DoubleTab &, DoubleTab &, DoubleTab &, DoubleTab &, DoubleTab &)
const DoubleTab & getMeshTransformationGradient() const
void integrate_behaviour_(double *const stress, double *const ivar, const double *const evar, double *const stiff, const double *const gradientOrStrain0, const double *const gradientOrStrain1, double *const vsound)
void tetrahedronVolLength_(double &vol, double &xlong, const double Det)
void solveDynamicMeshProblem(const double, const DoubleTab &, const IntVect &, DoubleTab &, const int, const int, const int, const IntTab &, const int, const int, const IntTab &, const Domaine_ALE &)
void setMfrontModelName(const std::string &f)
double computeCriticalDt(const double volume, const double xlong, const double cSound, const double dtMin, double &scaleMass)
void setGlobalFields(const int elnodes[4], const double Pressure, const double VonMises)
const DoubleTab & getMeshReferenceConfiguration() const
void computeInternalForces(double &volume, double &xlong, double &cSound, double &Pressure, double &VonMises)
const DoubleTab & getMeshAcceleration() const
void addMaterialProperty(const std::string name, const std::vector< double > val)
void checkElemOrientation(int elnodes[4], const int elem)