v0.15.5
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 varGradRotAxis;
118 MatrixDouble varLogStreach;
119 MatrixDouble varPiola;
120 MatrixDouble varDivPiola;
121 MatrixDouble varWL2;
122 MatrixDouble varHybridDispAtPts;
123
124 MatrixDouble P_du;
125
126 MatrixDouble eigenVals;
127 MatrixDouble eigenVecs;
128 VectorInt nbUniq;
129 MatrixDouble eigenValsC;
130 MatrixDouble eigenVecsC;
131 VectorInt nbUniqC;
132
133 MatrixDouble matD;
134 MatrixDouble matAxiatorD;
135 MatrixDouble matDeviatorD;
136 MatrixDouble matInvD;
137
139
140 MatrixDouble facePiolaAtPts;
141 MatrixDouble hybridDispAtPts;
142 MatrixDouble hybridDispDotAtPts;
146
147 double mu;
148 double lambda;
149 double piolaScale = 1.;
150 double faceEnergy = 0.;
151
152 inline auto getPiolaScalePtr() {
153 return boost::shared_ptr<double>(shared_from_this(), &piolaScale);
154 }
155
157 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
159 }
161 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &approxPAtPts);
162 }
163
165 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &divPAtPts);
166 }
167
169 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &gradPAtPts);
170 }
171
173 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &divSigmaAtPts);
174 }
175
177 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wL2AtPts);
178 }
179
181 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wL2DotAtPts);
182 }
183
185 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wL2DotDotAtPts);
186 }
187
189 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
191 }
192
194 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
196 }
197
199 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
201 }
202
204 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
206 }
207
209 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &rotAxisAtPts);
210 }
211
213 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &rotAxis0AtPts);
214 }
215
217 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
219 }
220
222 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
224 }
225
227 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &GAtPts);
228 }
229
231 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &GAtPts);
232 }
233
235 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &matD);
236 }
237
239 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &matInvD);
240 }
241
243 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &matAxiatorD);
244 }
245
247 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &matDeviatorD);
248 }
249
251 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wH1AtPts);
252 }
253
255 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &XH1AtPts);
256 }
257
259 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &contactL2AtPts);
260 }
261
263 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wGradH1AtPts);
264 }
265
267 return boost::shared_ptr<VectorDouble>(shared_from_this(), &jacobianAtPts);
268 }
269
271 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
273 };
274
276 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varRotAxis);
277 }
278
280 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
282 }
283
285 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varLogStreach);
286 }
287
289 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varPiola);
290 }
291
293 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varDivPiola);
294 }
295
297 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varWL2);
298 }
299
301 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
303 }
304
306 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
308 }
309
311 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &facePiolaAtPts);
312 }
313
315 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
317 }
318
320 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
322 }
323
325 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
327 }
328
330 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &eigenVals);
331 }
332
333 boost::shared_ptr<PhysicalEquations> physicsPtr;
334};
335
336struct OpJacobian;
337
338// Forward declarations
339struct ExternalStrain;
340using ExternalStrainVec = std::vector<ExternalStrain>;
341
343
350
352
355
357 PhysicalEquations(const int size_active, const int size_dependent)
358 : activeVariables(size_active, 0),
359 dependentVariablesPiola(size_dependent, 0),
360 dependentVariablesPiolaDirevatives(size_dependent * size_active, 0) {}
361 virtual ~PhysicalEquations() = default;
362
363 virtual MoFEMErrorCode setParams(const int tag, EntityHandle ent, int gg) {
364 return 0;
365 }
366 virtual MoFEMErrorCode recordTape(const int tag, DTensor2Ptr *t_h) = 0;
367
368 virtual UserDataOperator *
369 returnOpJacobian(const int tag, const bool eval_rhs, const bool eval_lhs,
370 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
371 boost::shared_ptr<PhysicalEquations> physics_ptr);
372
373 virtual VolUserDataOperator *
374 returnOpSpatialPhysical(const std::string &field_name,
375 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
376 const double alpha_u);
377
378 virtual VolUserDataOperator *
380 const std::string &field_name,
381 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
382 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
383 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv);
384
386 std::string row_field, std::string col_field,
387 boost::shared_ptr<DataAtIntegrationPts> data_ptr, const double alpha);
388
389 virtual VolUserDataOperator *
390 returnOpCalculateEnergy(boost::shared_ptr<DataAtIntegrationPts> data_ptr,
391 boost::shared_ptr<double> total_energy_ptr);
392
394 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
395 boost::shared_ptr<PhysicalEquations> physics_ptr);
396
398 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
399 boost::shared_ptr<PhysicalEquations> physics_ptr);
400
401 virtual VolUserDataOperator *
402 returnOpSetScale(boost::shared_ptr<double> scale_ptr,
403 boost::shared_ptr<PhysicalEquations> physics_ptr);
404
405 std::vector<double> activeVariables;
406 std::vector<double> dependentVariablesPiola;
408
409 /** \name Active variables */
410
411 /**@{*/
412
413 template <int S>
414 inline static DTensor2Ptr get_VecTensor2(std::vector<double> &v) {
415 return DTensor2Ptr(&v[S + 0], &v[S + 1], &v[S + 2], &v[S + 3], &v[S + 4],
416 &v[S + 5], &v[S + 6], &v[S + 7], &v[S + 8]);
417 }
418
419 template <int S>
420 inline static DTensor0Ptr get_VecTensor0(std::vector<double> &v) {
421 return DTensor0Ptr(&v[S + 0]);
422 }
423
424 template <int S0>
425 inline static DTensor3Ptr get_vecTensor3(std::vector<double> &v,
426 const int nba) {
427
428 const int A00 = nba * 0 + S0;
429 const int A01 = nba * 1 + S0;
430 const int A02 = nba * 2 + S0;
431 const int A10 = nba * 3 + S0;
432 const int A11 = nba * 4 + S0;
433 const int A12 = nba * 5 + S0;
434 const int A20 = nba * 6 + S0;
435 const int A21 = nba * 7 + S0;
436 const int A22 = nba * 8 + S0;
437
438 return DTensor3Ptr(
439
440 &v[A00 + 0], &v[A00 + 1], &v[A00 + 2], &v[A01 + 0], &v[A01 + 1],
441 &v[A01 + 2], &v[A02 + 0], &v[A02 + 1], &v[A02 + 2],
442
443 &v[A10 + 0], &v[A10 + 1], &v[A10 + 2], &v[A11 + 0], &v[A11 + 1],
444 &v[A11 + 2], &v[A12 + 0], &v[A12 + 1], &v[A12 + 2],
445
446 &v[A20 + 0], &v[A20 + 1], &v[A20 + 2], &v[A21 + 0], &v[A21 + 1],
447 &v[A21 + 2], &v[A22 + 0], &v[A22 + 1], &v[A22 + 2]
448
449 );
450 }
451
452 /**@}*/
453
454 /** \name Active variables */
455
456 /**@{*/
457
458 inline DTensor2Ptr get_h() { return get_VecTensor2<0>(activeVariables); }
459
460 /**@}*/
461
462 /** \name Dependent variables */
463
464 /**@{*/
465
467 return get_VecTensor2<0>(dependentVariablesPiola);
468 }
469
470 /**@}*/
471
472 /** \name Derivatives of dependent variables */
473
474 /**@{*/
475
477 return get_vecTensor3<0>(dependentVariablesPiolaDirevatives,
478 activeVariables.size());
479 }
481 return get_vecTensor3<3>(dependentVariablesPiolaDirevatives,
482 activeVariables.size());
483 }
485 return get_vecTensor3<6>(dependentVariablesPiolaDirevatives,
486 activeVariables.size());
487 }
488
489 /**@}*/
490};
491
492struct BcDisp {
493 BcDisp(std::string name, std::vector<double> attr, Range faces);
494 std::string blockName;
496 VectorDouble3 vals;
497 VectorInt3 flags;
498};
499using BcDispVec = std::vector<BcDisp>;
500
501struct BcRot {
502 BcRot(std::string name, std::vector<double> attr, Range faces);
503 std::string blockName;
505 VectorDouble vals;
506 double theta;
507};
508using BcRotVec = std::vector<BcRot>;
509
510typedef std::vector<Range> TractionFreeBc;
511
513 TractionBc(std::string name, std::vector<double> attr, Range faces);
514 std::string blockName;
516 VectorDouble3 vals;
517 VectorInt3 flags;
518};
519using TractionBcVec = std::vector<TractionBc>;
520
522 NormalDisplacementBc(std::string name, std::vector<double> attr, Range faces);
523 std::string blockName;
525 double val;
526};
527using NormalDisplacementBcVec = std::vector<NormalDisplacementBc>;
528
530 AnalyticalDisplacementBc(std::string name, std::vector<double> attr,
531 Range faces);
532 std::string blockName;
534 VectorInt3 flags;
535};
536using AnalyticalDisplacementBcVec = std::vector<AnalyticalDisplacementBc>;
537
539 AnalyticalTractionBc(std::string name, std::vector<double> attr, Range faces);
540 std::string blockName;
542 VectorInt3 flags;
543};
544using AnalyticalTractionBcVec = std::vector<AnalyticalTractionBc>;
545
547 PressureBc(std::string name, std::vector<double> attr, Range faces);
548 std::string blockName;
550 double val;
551};
552using PressureBcVec = std::vector<PressureBc>;
553
555 ExternalStrain(std::string name, std::vector<double> attr, Range ents);
556 std::string blockName;
558 double val;
560};
561
562template <typename OP_PTR>
563std::tuple<std::string, MatrixDouble>
564getAnalyticalExpr(OP_PTR op_ptr, MatrixDouble &analytical_expr,
565 const std::string block_name);
566
567template <typename OP_PTR>
568std::tuple<std::string, VectorDouble>
569getAnalyticalExternalStrain(OP_PTR op_ptr, VectorDouble &analytical_expr,
570 const std::string block_name);
571
572MatrixDouble analytical_expr_function(double delta_t, double t,
573 int nb_gauss_pts,
574 MatrixDouble &m_ref_coords,
575 MatrixDouble &m_ref_normals,
576 const std::string block_name);
577
578
579VectorDouble analytical_externalstrain_function(double delta_t, double t,
580 int nb_gauss_pts,
581 MatrixDouble &m_ref_coords,
582 const std::string block_name);
583
584 #ifdef ENABLE_PYTHON_BINDING
585struct AnalyticalExprPython {
586 AnalyticalExprPython() = default;
587 virtual ~AnalyticalExprPython() = default;
588
589 MoFEMErrorCode analyticalExprInit(const std::string py_file);
590 MoFEMErrorCode evalAnalyticalDisp(double delta_t, double t, np::ndarray x,
591 np::ndarray y, np::ndarray z,
592 np::ndarray nx, np::ndarray ny,
593 np::ndarray nz,
594 const std::string &block_name,
595 np::ndarray &analytical_expr);
596 MoFEMErrorCode evalAnalyticalTraction(double delta_t, double t, np::ndarray x,
597 np::ndarray y, np::ndarray z,
598 np::ndarray nx, np::ndarray ny,
599 np::ndarray nz,
600 const std::string &block_name,
601 np::ndarray &analytical_expr);
602
603 MoFEMErrorCode evalAnalyticalExternalStrain(double delta_t, double t,
604 np::ndarray x, np::ndarray y,
605 np::ndarray z,
606 const std::string &block_name,
607 np::ndarray &analytical_expr);
608 template <typename T>
609 inline std::vector<T>
610 py_list_to_std_vector(const boost::python::object &iterable) {
611 return std::vector<T>(boost::python::stl_input_iterator<T>(iterable),
612 boost::python::stl_input_iterator<T>());
613 }
614
615private:
616 bp::object mainNamespace;
617 bp::object analyticalDispFun;
618 bp::object analyticalTractionFun;
619 bp::object analyticalExternalStrainFun;
620};
621
622extern boost::weak_ptr<AnalyticalExprPython> AnalyticalExprPythonWeakPtr;
623 #endif
624
626 #include "EshelbianCore.hpp"
627 #include "EshelbianOperators.hpp"
628
629} // namespace EshelbianPlasticity
630
631#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 MoFEMErrorCode setParams(const int tag, EntityHandle ent, int gg)
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)