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>;
342
349
351
354
356 PhysicalEquations(const int size_active, const int size_dependent)
357 : activeVariables(size_active, 0),
358 dependentVariablesPiola(size_dependent, 0),
359 dependentVariablesPiolaDirevatives(size_dependent * size_active, 0) {}
360 virtual ~PhysicalEquations() = default;
361
362 virtual MoFEMErrorCode recordTape(const int tag, DTensor2Ptr *t_h) = 0;
363
364 virtual UserDataOperator *
365 returnOpJacobian(const int tag, const bool eval_rhs, const bool eval_lhs,
366 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
367 boost::shared_ptr<PhysicalEquations> physics_ptr);
368
369 virtual VolUserDataOperator *
370 returnOpSpatialPhysical(const std::string &field_name,
371 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
372 const double alpha_u);
373
374 virtual VolUserDataOperator *
376 const std::string &field_name,
377 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
378 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
379 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv);
380
382 std::string row_field, std::string col_field,
383 boost::shared_ptr<DataAtIntegrationPts> data_ptr, const double alpha);
384
385 virtual VolUserDataOperator *
386 returnOpCalculateEnergy(boost::shared_ptr<DataAtIntegrationPts> data_ptr,
387 boost::shared_ptr<double> total_energy_ptr);
388
390 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
391 boost::shared_ptr<PhysicalEquations> physics_ptr);
392
394 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
395 boost::shared_ptr<PhysicalEquations> physics_ptr);
396
397 virtual VolUserDataOperator *
398 returnOpSetScale(boost::shared_ptr<double> scale_ptr,
399 boost::shared_ptr<PhysicalEquations> physics_ptr);
400
401 std::vector<double> activeVariables;
402 std::vector<double> dependentVariablesPiola;
404
405 /** \name Active variables */
406
407 /**@{*/
408
409 template <int S>
410 inline static DTensor2Ptr get_VecTensor2(std::vector<double> &v) {
411 return DTensor2Ptr(&v[S + 0], &v[S + 1], &v[S + 2], &v[S + 3], &v[S + 4],
412 &v[S + 5], &v[S + 6], &v[S + 7], &v[S + 8]);
413 }
414
415 template <int S>
416 inline static DTensor0Ptr get_VecTensor0(std::vector<double> &v) {
417 return DTensor0Ptr(&v[S + 0]);
418 }
419
420 template <int S0>
421 inline static DTensor3Ptr get_vecTensor3(std::vector<double> &v,
422 const int nba) {
423
424 const int A00 = nba * 0 + S0;
425 const int A01 = nba * 1 + S0;
426 const int A02 = nba * 2 + S0;
427 const int A10 = nba * 3 + S0;
428 const int A11 = nba * 4 + S0;
429 const int A12 = nba * 5 + S0;
430 const int A20 = nba * 6 + S0;
431 const int A21 = nba * 7 + S0;
432 const int A22 = nba * 8 + S0;
433
434 return DTensor3Ptr(
435
436 &v[A00 + 0], &v[A00 + 1], &v[A00 + 2], &v[A01 + 0], &v[A01 + 1],
437 &v[A01 + 2], &v[A02 + 0], &v[A02 + 1], &v[A02 + 2],
438
439 &v[A10 + 0], &v[A10 + 1], &v[A10 + 2], &v[A11 + 0], &v[A11 + 1],
440 &v[A11 + 2], &v[A12 + 0], &v[A12 + 1], &v[A12 + 2],
441
442 &v[A20 + 0], &v[A20 + 1], &v[A20 + 2], &v[A21 + 0], &v[A21 + 1],
443 &v[A21 + 2], &v[A22 + 0], &v[A22 + 1], &v[A22 + 2]
444
445 );
446 }
447
448 /**@}*/
449
450 /** \name Active variables */
451
452 /**@{*/
453
454 inline DTensor2Ptr get_h() { return get_VecTensor2<0>(activeVariables); }
455
456 /**@}*/
457
458 /** \name Dependent variables */
459
460 /**@{*/
461
463 return get_VecTensor2<0>(dependentVariablesPiola);
464 }
465
466 /**@}*/
467
468 /** \name Derivatives of dependent variables */
469
470 /**@{*/
471
473 return get_vecTensor3<0>(dependentVariablesPiolaDirevatives,
474 activeVariables.size());
475 }
477 return get_vecTensor3<3>(dependentVariablesPiolaDirevatives,
478 activeVariables.size());
479 }
481 return get_vecTensor3<6>(dependentVariablesPiolaDirevatives,
482 activeVariables.size());
483 }
484
485 /**@}*/
486};
487
488struct BcDisp {
489 BcDisp(std::string name, std::vector<double> attr, Range faces);
490 std::string blockName;
492 VectorDouble3 vals;
493 VectorInt3 flags;
494};
495using BcDispVec = std::vector<BcDisp>;
496
497struct BcRot {
498 BcRot(std::string name, std::vector<double> attr, Range faces);
499 std::string blockName;
501 VectorDouble vals;
502 double theta;
503};
504using BcRotVec = std::vector<BcRot>;
505
506typedef std::vector<Range> TractionFreeBc;
507
509 TractionBc(std::string name, std::vector<double> attr, Range faces);
510 std::string blockName;
512 VectorDouble3 vals;
513 VectorInt3 flags;
514};
515using TractionBcVec = std::vector<TractionBc>;
516
518 NormalDisplacementBc(std::string name, std::vector<double> attr, Range faces);
519 std::string blockName;
521 double val;
522};
523using NormalDisplacementBcVec = std::vector<NormalDisplacementBc>;
524
526 AnalyticalDisplacementBc(std::string name, std::vector<double> attr,
527 Range faces);
528 std::string blockName;
530 VectorInt3 flags;
531};
532using AnalyticalDisplacementBcVec = std::vector<AnalyticalDisplacementBc>;
533
535 AnalyticalTractionBc(std::string name, std::vector<double> attr, Range faces);
536 std::string blockName;
538 VectorInt3 flags;
539};
540using AnalyticalTractionBcVec = std::vector<AnalyticalTractionBc>;
541
543 PressureBc(std::string name, std::vector<double> attr, Range faces);
544 std::string blockName;
546 double val;
547};
548using PressureBcVec = std::vector<PressureBc>;
549
551 ExternalStrain(std::string name, std::vector<double> attr, Range ents);
552 std::string blockName;
554 double val;
556};
557
558template <typename OP_PTR>
559std::tuple<std::string, MatrixDouble>
560getAnalyticalExpr(OP_PTR op_ptr, MatrixDouble &analytical_expr,
561 const std::string block_name);
562
563template <typename OP_PTR>
564std::tuple<std::string, VectorDouble>
565getAnalyticalExternalStrain(OP_PTR op_ptr, VectorDouble &analytical_expr,
566 const std::string block_name);
567
568MatrixDouble analytical_expr_function(double delta_t, double t,
569 int nb_gauss_pts,
570 MatrixDouble &m_ref_coords,
571 MatrixDouble &m_ref_normals,
572 const std::string block_name);
573
574
575VectorDouble analytical_externalstrain_function(double delta_t, double t,
576 int nb_gauss_pts,
577 MatrixDouble &m_ref_coords,
578 const std::string block_name);
579
580 #ifdef ENABLE_PYTHON_BINDING
581struct AnalyticalExprPython {
582 AnalyticalExprPython() = default;
583 virtual ~AnalyticalExprPython() = default;
584
585 MoFEMErrorCode analyticalExprInit(const std::string py_file);
586 MoFEMErrorCode evalAnalyticalDisp(double delta_t, double t, np::ndarray x,
587 np::ndarray y, np::ndarray z,
588 np::ndarray nx, np::ndarray ny,
589 np::ndarray nz,
590 const std::string &block_name,
591 np::ndarray &analytical_expr);
592 MoFEMErrorCode evalAnalyticalTraction(double delta_t, double t, np::ndarray x,
593 np::ndarray y, np::ndarray z,
594 np::ndarray nx, np::ndarray ny,
595 np::ndarray nz,
596 const std::string &block_name,
597 np::ndarray &analytical_expr);
598
599 MoFEMErrorCode evalAnalyticalExternalStrain(double delta_t, double t,
600 np::ndarray x, np::ndarray y,
601 np::ndarray z,
602 const std::string &block_name,
603 np::ndarray &analytical_expr);
604 template <typename T>
605 inline std::vector<T>
606 py_list_to_std_vector(const boost::python::object &iterable) {
607 return std::vector<T>(boost::python::stl_input_iterator<T>(iterable),
608 boost::python::stl_input_iterator<T>());
609 }
610
611private:
612 bp::object mainNamespace;
613 bp::object analyticalDispFun;
614 bp::object analyticalTractionFun;
615 bp::object analyticalExternalStrainFun;
616};
617
618extern boost::weak_ptr<AnalyticalExprPython> AnalyticalExprPythonWeakPtr;
619 #endif
620
622 #include "EshelbianCore.hpp"
623 #include "EshelbianOperators.hpp"
624
625} // namespace EshelbianPlasticity
626
627#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)