v0.15.0
Loading...
Searching...
No Matches
EshelbianPlasticity.hpp
Go to the documentation of this file.
1/**
2 * \file EshelbianPlasticity.hpp
3 * \brief Eshelbian plasticity interface
4 *
5 * \brief Problem implementation for mix element for large-strain elasticity
6 *
7 * For reference on mixed formulation see: \cite gopalakrishnan2012second and
8 * \cite cockburn2010new
9 *
10 * \todo Implementation of plasticity
11 */
12
13// DO NOT DELETE MIGHT BE USEFULL
14// #include <boost/multiprecision/mpfr.hpp>
15// using mpfr50 = boost::multiprecision::number<
16// boost::multiprecision::mpfr_float_backend<50>>;
17
18// inline mpfr50 exp_hi(const mpfr50 x) { return boost::multiprecision::exp(x); }
19// inline mpfr50 log_hi(const mpfr50 x) { return boost::multiprecision::log(x); }
20
21constexpr int SPACE_DIM = 3;
22// constexpr auto A = AssemblyType::BLOCK_SCHUR;
23constexpr auto A = AssemblyType::BLOCK_MAT;
24
25#ifndef __ESHELBIAN_PLASTICITY_HPP__
26 #define __ESHELBIAN_PLASTICITY_HPP__
27
28 #ifdef ENABLE_PYTHON_BINDING
29 #include <boost/python.hpp>
30 #include <boost/python/def.hpp>
31 #include <boost/python/numpy.hpp>
32namespace bp = boost::python;
33namespace np = boost::python::numpy;
34 #endif
35namespace EshelbianPlasticity {
36
37struct ContactTree;
38
43 LOG /*linar extenion*/,
44 LOG_QUADRATIC /*quadratic extension*/,
46};
48
49using MatrixPtr = boost::shared_ptr<MatrixDouble>;
50using VectorPtr = boost::shared_ptr<VectorDouble>;
51
52using EntData = EntitiesFieldData::EntData;
53using UserDataOperator = ForcesAndSourcesCore::UserDataOperator;
54using VolUserDataOperator = VolumeElementForcesAndSourcesCore::UserDataOperator;
55using FaceUserDataOperator = FaceElementForcesAndSourcesCore::UserDataOperator;
56using EleOnSide = PipelineManager::ElementsAndOpsByDim<SPACE_DIM>::FaceSideEle;
57using SideEleOp = EleOnSide::UserDataOperator;
58
60
61struct AnalyticalExprPython;
62
64 : public boost::enable_shared_from_this<DataAtIntegrationPts> {
65
66 MatrixDouble approxPAtPts;
67 MatrixDouble approxSigmaAtPts;
68 MatrixDouble divPAtPts;
69 MatrixDouble gradPAtPts;
70 MatrixDouble divSigmaAtPts;
71 MatrixDouble wL2AtPts;
72 MatrixDouble wL2DotAtPts;
73 MatrixDouble wL2DotDotAtPts;
75 MatrixDouble stretchTensorAtPts;
76 VectorDouble jacobianAtPts;
77 MatrixDouble tractionAtPts;
78
84 MatrixDouble rotAxisAtPts;
85 MatrixDouble rotAxisDotAtPts;
86 MatrixDouble rotAxisGradDotAtPts;
87 MatrixDouble rotAxis0AtPts;
88 MatrixDouble WAtPts;
89 MatrixDouble W0AtPts;
90 MatrixDouble GAtPts;
91 MatrixDouble G0AtPts;
92 MatrixDouble wH1AtPts;
93 MatrixDouble XH1AtPts;
94 MatrixDouble contactL2AtPts;
95 MatrixDouble wGradH1AtPts;
96 MatrixDouble logStretch2H1AtPts;
98
99 MatrixDouble hAtPts;
100 MatrixDouble hdOmegaAtPts;
101 MatrixDouble hdLogStretchAtPts;
102 MatrixDouble leviKirchhoffAtPts;
107 MatrixDouble adjointPdUAtPts;
109 MatrixDouble adjointPdUdPAtPts;
110 MatrixDouble rotMatAtPts;
111 MatrixDouble PAtPts;
112 MatrixDouble SigmaAtPts;
113 VectorDouble energyAtPts; //< this is density of energy at integration points
114 MatrixDouble flowL2AtPts;
115
116 MatrixDouble varRotAxis;
117 MatrixDouble varLogStreach;
118 MatrixDouble varPiola;
119 MatrixDouble varDivPiola;
120 MatrixDouble varWL2;
121
122 MatrixDouble P_du;
123
124 MatrixDouble eigenVals;
125 MatrixDouble eigenVecs;
126 VectorInt nbUniq;
127 MatrixDouble eigenValsC;
128 MatrixDouble eigenVecsC;
129 VectorInt nbUniqC;
130
131 MatrixDouble matD;
132 MatrixDouble matAxiatorD;
133 MatrixDouble matDeviatorD;
134 MatrixDouble matInvD;
135
137
138 MatrixDouble facePiolaAtPts;
139 MatrixDouble hybridDispAtPts;
140 MatrixDouble hybridDispDotAtPts;
144
145 double mu;
146 double lambda;
147 double piolaScale = 1.;
148 double faceEnergy = 0.;
149
150 inline auto getPiolaScalePtr() {
151 return boost::shared_ptr<double>(shared_from_this(), &piolaScale);
152 }
153
155 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
157 }
159 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &approxPAtPts);
160 }
161
163 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &divPAtPts);
164 }
165
167 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &gradPAtPts);
168 }
169
171 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &divSigmaAtPts);
172 }
173
175 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wL2AtPts);
176 }
177
179 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wL2DotAtPts);
180 }
181
183 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wL2DotDotAtPts);
184 }
185
187 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
189 }
190
192 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
194 }
195
197 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
199 }
200
202 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
204 }
205
207 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &rotAxisAtPts);
208 }
209
211 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &rotAxis0AtPts);
212 }
213
215 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
217 }
218
220 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
222 }
223
225 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &GAtPts);
226 }
227
229 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &GAtPts);
230 }
231
233 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &matD);
234 }
235
237 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &matInvD);
238 }
239
241 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &matAxiatorD);
242 }
243
245 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &matDeviatorD);
246 }
247
249 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wH1AtPts);
250 }
251
253 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &XH1AtPts);
254 }
255
257 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &contactL2AtPts);
258 }
259
261 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wGradH1AtPts);
262 }
263
265 return boost::shared_ptr<VectorDouble>(shared_from_this(), &jacobianAtPts);
266 }
267
269 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
271 };
272
274 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varRotAxis);
275 }
276
278 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varLogStreach);
279 }
280
282 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varPiola);
283 }
284
286 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varDivPiola);
287 }
288
290 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varWL2);
291 }
292
294 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
296 }
297
299 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &facePiolaAtPts);
300 }
301
303 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
305 }
306
308 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
310 }
311
313 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
315 }
316
318 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &eigenVals);
319 }
320
321 boost::shared_ptr<PhysicalEquations> physicsPtr;
322};
323
324struct OpJacobian;
325
326// Forward declarations
327struct ExternalStrain;
328using ExternalStrainVec = std::vector<ExternalStrain>;
330
337
339
342
344 PhysicalEquations(const int size_active, const int size_dependent)
345 : activeVariables(size_active, 0),
346 dependentVariablesPiola(size_dependent, 0),
347 dependentVariablesPiolaDirevatives(size_dependent * size_active, 0) {}
348 virtual ~PhysicalEquations() = default;
349
350 virtual MoFEMErrorCode recordTape(const int tag, DTensor2Ptr *t_h) = 0;
351
352 virtual UserDataOperator *
353 returnOpJacobian(const int tag, const bool eval_rhs, const bool eval_lhs,
354 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
355 boost::shared_ptr<PhysicalEquations> physics_ptr);
356
357 virtual VolUserDataOperator *
358 returnOpSpatialPhysical(const std::string &field_name,
359 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
360 const double alpha_u);
361
362 virtual VolUserDataOperator *
364 const std::string &field_name,
365 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
366 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
367 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv);
368
370 std::string row_field, std::string col_field,
371 boost::shared_ptr<DataAtIntegrationPts> data_ptr, const double alpha);
372
373 virtual VolUserDataOperator *
374 returnOpCalculateEnergy(boost::shared_ptr<DataAtIntegrationPts> data_ptr,
375 boost::shared_ptr<double> total_energy_ptr);
376
378 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
379 boost::shared_ptr<PhysicalEquations> physics_ptr);
380
382 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
383 boost::shared_ptr<PhysicalEquations> physics_ptr);
384
385 virtual VolUserDataOperator *
386 returnOpSetScale(boost::shared_ptr<double> scale_ptr,
387 boost::shared_ptr<PhysicalEquations> physics_ptr);
388
389 std::vector<double> activeVariables;
390 std::vector<double> dependentVariablesPiola;
392
393 /** \name Active variables */
394
395 /**@{*/
396
397 template <int S>
398 inline static DTensor2Ptr get_VecTensor2(std::vector<double> &v) {
399 return DTensor2Ptr(&v[S + 0], &v[S + 1], &v[S + 2], &v[S + 3], &v[S + 4],
400 &v[S + 5], &v[S + 6], &v[S + 7], &v[S + 8]);
401 }
402
403 template <int S>
404 inline static DTensor0Ptr get_VecTensor0(std::vector<double> &v) {
405 return DTensor0Ptr(&v[S + 0]);
406 }
407
408 template <int S0>
409 inline static DTensor3Ptr get_vecTensor3(std::vector<double> &v,
410 const int nba) {
411
412 const int A00 = nba * 0 + S0;
413 const int A01 = nba * 1 + S0;
414 const int A02 = nba * 2 + S0;
415 const int A10 = nba * 3 + S0;
416 const int A11 = nba * 4 + S0;
417 const int A12 = nba * 5 + S0;
418 const int A20 = nba * 6 + S0;
419 const int A21 = nba * 7 + S0;
420 const int A22 = nba * 8 + S0;
421
422 return DTensor3Ptr(
423
424 &v[A00 + 0], &v[A00 + 1], &v[A00 + 2], &v[A01 + 0], &v[A01 + 1],
425 &v[A01 + 2], &v[A02 + 0], &v[A02 + 1], &v[A02 + 2],
426
427 &v[A10 + 0], &v[A10 + 1], &v[A10 + 2], &v[A11 + 0], &v[A11 + 1],
428 &v[A11 + 2], &v[A12 + 0], &v[A12 + 1], &v[A12 + 2],
429
430 &v[A20 + 0], &v[A20 + 1], &v[A20 + 2], &v[A21 + 0], &v[A21 + 1],
431 &v[A21 + 2], &v[A22 + 0], &v[A22 + 1], &v[A22 + 2]
432
433 );
434 }
435
436 /**@}*/
437
438 /** \name Active variables */
439
440 /**@{*/
441
442 inline DTensor2Ptr get_h() { return get_VecTensor2<0>(activeVariables); }
443
444 /**@}*/
445
446 /** \name Dependent variables */
447
448 /**@{*/
449
451 return get_VecTensor2<0>(dependentVariablesPiola);
452 }
453
454 /**@}*/
455
456 /** \name Derivatives of dependent variables */
457
458 /**@{*/
459
461 return get_vecTensor3<0>(dependentVariablesPiolaDirevatives,
462 activeVariables.size());
463 }
465 return get_vecTensor3<3>(dependentVariablesPiolaDirevatives,
466 activeVariables.size());
467 }
469 return get_vecTensor3<6>(dependentVariablesPiolaDirevatives,
470 activeVariables.size());
471 }
472
473 /**@}*/
474};
475
476struct BcDisp {
477 BcDisp(std::string name, std::vector<double> attr, Range faces);
478 std::string blockName;
480 VectorDouble3 vals;
481 VectorInt3 flags;
482};
483using BcDispVec = std::vector<BcDisp>;
484
485struct BcRot {
486 BcRot(std::string name, std::vector<double> attr, Range faces);
487 std::string blockName;
489 VectorDouble vals;
490 double theta;
491};
492using BcRotVec = std::vector<BcRot>;
493
494typedef std::vector<Range> TractionFreeBc;
495
497 TractionBc(std::string name, std::vector<double> attr, Range faces);
498 std::string blockName;
500 VectorDouble3 vals;
501 VectorInt3 flags;
502};
503using TractionBcVec = std::vector<TractionBc>;
504
506 NormalDisplacementBc(std::string name, std::vector<double> attr, Range faces);
507 std::string blockName;
509 double val;
510};
511using NormalDisplacementBcVec = std::vector<NormalDisplacementBc>;
512
514 AnalyticalDisplacementBc(std::string name, std::vector<double> attr,
515 Range faces);
516 std::string blockName;
518 VectorInt3 flags;
519};
520using AnalyticalDisplacementBcVec = std::vector<AnalyticalDisplacementBc>;
521
523 AnalyticalTractionBc(std::string name, std::vector<double> attr, Range faces);
524 std::string blockName;
526 VectorInt3 flags;
527};
528using AnalyticalTractionBcVec = std::vector<AnalyticalTractionBc>;
529
531 PressureBc(std::string name, std::vector<double> attr, Range faces);
532 std::string blockName;
534 double val;
535};
536using PressureBcVec = std::vector<PressureBc>;
537
539 ExternalStrain(std::string name, std::vector<double> attr, Range ents);
540 std::string blockName;
542 double val;
544};
545
546template <typename OP_PTR>
547std::tuple<std::string, MatrixDouble>
548getAnalyticalExpr(OP_PTR op_ptr, MatrixDouble &analytical_expr,
549 const std::string block_name);
550
551template <typename OP_PTR>
552std::tuple<std::string, VectorDouble>
553getAnalyticalExternalStrain(OP_PTR op_ptr, VectorDouble &analytical_expr,
554 const std::string block_name);
555
556MatrixDouble analytical_expr_function(double delta_t, double t,
557 int nb_gauss_pts,
558 MatrixDouble &m_ref_coords,
559 MatrixDouble &m_ref_normals,
560 const std::string block_name);
561
562
563VectorDouble analytical_externalstrain_function(double delta_t, double t,
564 int nb_gauss_pts,
565 MatrixDouble &m_ref_coords,
566 const std::string block_name);
567
568 #ifdef ENABLE_PYTHON_BINDING
569struct AnalyticalExprPython {
570 AnalyticalExprPython() = default;
571 virtual ~AnalyticalExprPython() = default;
572
573 MoFEMErrorCode analyticalExprInit(const std::string py_file);
574 MoFEMErrorCode evalAnalyticalDisp(double delta_t, double t, np::ndarray x,
575 np::ndarray y, np::ndarray z,
576 np::ndarray nx, np::ndarray ny,
577 np::ndarray nz,
578 const std::string &block_name,
579 np::ndarray &analytical_expr);
580 MoFEMErrorCode evalAnalyticalTraction(double delta_t, double t, np::ndarray x,
581 np::ndarray y, np::ndarray z,
582 np::ndarray nx, np::ndarray ny,
583 np::ndarray nz,
584 const std::string &block_name,
585 np::ndarray &analytical_expr);
586
587 MoFEMErrorCode evalAnalyticalExternalStrain(double delta_t, double t,
588 np::ndarray x, np::ndarray y,
589 np::ndarray z,
590 const std::string &block_name,
591 np::ndarray &analytical_expr);
592 template <typename T>
593 inline std::vector<T>
594 py_list_to_std_vector(const boost::python::object &iterable) {
595 return std::vector<T>(boost::python::stl_input_iterator<T>(iterable),
596 boost::python::stl_input_iterator<T>());
597 }
598
599private:
600 bp::object mainNamespace;
601 bp::object analyticalDispFun;
602 bp::object analyticalTractionFun;
603 bp::object analyticalExternalStrainFun;
604};
605
606extern boost::weak_ptr<AnalyticalExprPython> AnalyticalExprPythonWeakPtr;
607 #endif
608
610 #include "EshelbianCore.hpp"
611 #include "EshelbianOperators.hpp"
612
613} // namespace EshelbianPlasticity
614
615#endif //__ESHELBIAN_PLASTICITY_HPP__
constexpr int SPACE_DIM
constexpr auto A
const double v
phase velocity of light in medium (cm/ns)
VectorDouble analytical_externalstrain_function(double delta_t, double t, int nb_gauss_pts, MatrixDouble &m_ref_coords, const std::string block_name)
boost::shared_ptr< MatrixDouble > MatrixPtr
std::vector< AnalyticalTractionBc > AnalyticalTractionBcVec
std::vector< TractionBc > TractionBcVec
std::tuple< std::string, VectorDouble > getAnalyticalExternalStrain(OP_PTR op_ptr, VectorDouble &analytical_expr, const std::string block_name)
std::vector< AnalyticalDisplacementBc > AnalyticalDisplacementBcVec
std::vector< PressureBc > PressureBcVec
std::tuple< std::string, MatrixDouble > getAnalyticalExpr(OP_PTR op_ptr, MatrixDouble &analytical_expr, const std::string block_name)
std::vector< Range > TractionFreeBc
std::vector< ExternalStrain > ExternalStrainVec
ForcesAndSourcesCore::UserDataOperator UserDataOperator
std::vector< BcRot > BcRotVec
std::vector< NormalDisplacementBc > NormalDisplacementBcVec
FaceElementForcesAndSourcesCore::UserDataOperator FaceUserDataOperator
PipelineManager::ElementsAndOpsByDim< SPACE_DIM >::FaceSideEle EleOnSide
MatrixDouble analytical_expr_function(double delta_t, double t, int nb_gauss_pts, MatrixDouble &m_ref_coords, MatrixDouble &m_ref_normals, const std::string block_name)
std::vector< BcDisp > BcDispVec
boost::shared_ptr< VectorDouble > VectorPtr
constexpr double t
plate stiffness
Definition plate.cpp:58
constexpr auto field_name
boost::shared_ptr< PhysicalEquations > physicsPtr
virtual VolUserDataOperator * returnOpCalculateVarStretchFromStress(boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< PhysicalEquations > physics_ptr)
virtual VolUserDataOperator * returnOpCalculateEnergy(boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< double > total_energy_ptr)
FTensor::Tensor3< double, 3, 3, 3 > DTensor3
FTensor::Tensor3< FTensor::PackPtr< double *, 1 >, 3, 3, 3 > DTensor3Ptr
virtual VolUserDataOperator * returnOpSpatialPhysical(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha_u)
virtual VolUserDataOperator * returnOpSpatialPhysicalExternalStrain(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< ExternalStrainVec > external_strain_vec_ptr, std::map< std::string, boost::shared_ptr< ScalingMethod > > smv)
FTensor::Tensor2< FTensor::PackPtr< double *, 1 >, 3, 3 > DTensor2Ptr
virtual VolUserDataOperator * returnOpCalculateStretchFromStress(boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< PhysicalEquations > physics_ptr)
static DTensor3Ptr get_vecTensor3(std::vector< double > &v, const int nba)
FTensor::Tensor2< adouble, 3, 3 > ATensor2
FTensor::Tensor2< double, 3, 3 > DTensor2
PhysicalEquations(const int size_active, const int size_dependent)
virtual VolUserDataOperator * returnOpSetScale(boost::shared_ptr< double > scale_ptr, boost::shared_ptr< PhysicalEquations > physics_ptr)
static DTensor2Ptr get_VecTensor2(std::vector< double > &v)
FTensor::Tensor1< adouble, 3 > ATensor1
FTensor::Tensor3< adouble, 3, 3, 3 > ATensor3
virtual MoFEMErrorCode recordTape(const int tag, DTensor2Ptr *t_h)=0
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > DTensor0Ptr
virtual VolUserDataOperator * returnOpSpatialPhysical_du_du(std::string row_field, std::string col_field, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha)
virtual UserDataOperator * returnOpJacobian(const int tag, const bool eval_rhs, const bool eval_lhs, boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< PhysicalEquations > physics_ptr)
static DTensor0Ptr get_VecTensor0(std::vector< double > &v)
Data on single entity (This is passed as argument to DataOperator::doWork)