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
38
39 using CachePhi = boost::tuple<int, int, MatrixDouble>;
40
41 CGGUserPolynomialBase(boost::shared_ptr<CachePhi> cache_phi = nullptr);
43
44 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
45 BaseFunctionUnknownInterface **iface) const;
46 MoFEMErrorCode getValue(MatrixDouble &pts,
47 boost::shared_ptr<BaseFunctionCtx> ctx_ptr);
48
49private:
50 MatrixDouble shapeFun;
51 boost::shared_ptr<CachePhi> cachePhiPtr;
52
53 MoFEMErrorCode getValueHdivForCGGBubble(MatrixDouble &pts);
54};
55
56struct ContactTree;
57
62 LOG /*linar extenion*/,
63 LOG_QUADRATIC /*quadratic extension*/,
65};
67
68using MatrixPtr = boost::shared_ptr<MatrixDouble>;
69using VectorPtr = boost::shared_ptr<VectorDouble>;
70
71using EntData = EntitiesFieldData::EntData;
72using UserDataOperator = ForcesAndSourcesCore::UserDataOperator;
73using VolUserDataOperator = VolumeElementForcesAndSourcesCore::UserDataOperator;
74using FaceUserDataOperator = FaceElementForcesAndSourcesCore::UserDataOperator;
75using EleOnSide = PipelineManager::ElementsAndOpsByDim<SPACE_DIM>::FaceSideEle;
76using SideEleOp = EleOnSide::UserDataOperator;
77
79
80struct AnalyticalExprPython;
81
83 : public boost::enable_shared_from_this<DataAtIntegrationPts> {
84
85 MatrixDouble approxPAtPts;
86 MatrixDouble approxSigmaAtPts;
87 MatrixDouble divPAtPts;
88 MatrixDouble gradPAtPts;
89 MatrixDouble divSigmaAtPts;
90 MatrixDouble wL2AtPts;
91 MatrixDouble wL2DotAtPts;
92 MatrixDouble wL2DotDotAtPts;
94 MatrixDouble stretchTensorAtPts;
95 VectorDouble jacobianAtPts;
96 MatrixDouble tractionAtPts;
97
103 MatrixDouble rotAxisAtPts;
104 MatrixDouble rotAxisDotAtPts;
106 MatrixDouble rotAxis0AtPts;
107 MatrixDouble WAtPts;
108 MatrixDouble W0AtPts;
109 MatrixDouble GAtPts;
110 MatrixDouble G0AtPts;
111 MatrixDouble wH1AtPts;
112 MatrixDouble XH1AtPts;
113 MatrixDouble contactL2AtPts;
114 MatrixDouble wGradH1AtPts;
115 MatrixDouble logStretch2H1AtPts;
117
118 MatrixDouble hAtPts;
119 MatrixDouble hdOmegaAtPts;
120 MatrixDouble hdLogStretchAtPts;
121 MatrixDouble leviKirchhoffAtPts;
126 MatrixDouble adjointPdUAtPts;
128 MatrixDouble adjointPdUdPAtPts;
129 MatrixDouble rotMatAtPts;
130 MatrixDouble PAtPts;
131 MatrixDouble SigmaAtPts;
132 VectorDouble energyAtPts; //< this is density of energy at integration points
133 MatrixDouble flowL2AtPts;
134
135 MatrixDouble varRotAxis;
136 MatrixDouble varLogStreach;
137 MatrixDouble varPiola;
138 MatrixDouble varDivPiola;
139 MatrixDouble varWL2;
140
141 MatrixDouble P_du;
142
143 MatrixDouble eigenVals;
144 MatrixDouble eigenVecs;
145 VectorInt nbUniq;
146 MatrixDouble eigenValsC;
147 MatrixDouble eigenVecsC;
148 VectorInt nbUniqC;
149
150 MatrixDouble matD;
151 MatrixDouble matAxiatorD;
152 MatrixDouble matDeviatorD;
153 MatrixDouble matInvD;
154
156
157 MatrixDouble facePiolaAtPts;
158 MatrixDouble hybridDispAtPts;
162
163 double mu;
164 double lambda;
165 double piolaScale = 1.;
166 double faceEnergy = 0.;
167
168 inline auto getPiolaScalePtr() {
169 return boost::shared_ptr<double>(shared_from_this(), &piolaScale);
170 }
171
173 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
175 }
177 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &approxPAtPts);
178 }
179
181 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &divPAtPts);
182 }
183
185 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &gradPAtPts);
186 }
187
189 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &divSigmaAtPts);
190 }
191
193 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wL2AtPts);
194 }
195
197 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wL2DotAtPts);
198 }
199
201 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wL2DotDotAtPts);
202 }
203
205 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
207 }
208
210 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
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(), &rotAxisAtPts);
226 }
227
229 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &rotAxis0AtPts);
230 }
231
233 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
235 }
236
238 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
240 }
241
243 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &GAtPts);
244 }
245
247 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &GAtPts);
248 }
249
251 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &matD);
252 }
253
255 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &matInvD);
256 }
257
259 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &matAxiatorD);
260 }
261
263 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &matDeviatorD);
264 }
265
267 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wH1AtPts);
268 }
269
271 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &XH1AtPts);
272 }
273
275 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &contactL2AtPts);
276 }
277
279 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &wGradH1AtPts);
280 }
281
283 return boost::shared_ptr<VectorDouble>(shared_from_this(), &jacobianAtPts);
284 }
285
287 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
289 };
290
292 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varRotAxis);
293 }
294
296 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varLogStreach);
297 }
298
300 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varPiola);
301 }
302
304 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varDivPiola);
305 }
306
308 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &varWL2);
309 }
310
312 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
314 }
315
317 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &facePiolaAtPts);
318 }
319
321 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
323 }
324
326 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
328 }
329
331 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &eigenVals);
332 }
333
334 boost::shared_ptr<PhysicalEquations> physicsPtr;
335};
336
337struct OpJacobian;
338
339// Forward declarations
340struct ExternalStrain;
341using ExternalStrainVec = std::vector<ExternalStrain>;
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 recordTape(const int tag, DTensor2Ptr *t_h) = 0;
364
365 virtual UserDataOperator *
366 returnOpJacobian(const int tag, const bool eval_rhs, const bool eval_lhs,
367 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
368 boost::shared_ptr<PhysicalEquations> physics_ptr);
369
370 virtual VolUserDataOperator *
371 returnOpSpatialPhysical(const std::string &field_name,
372 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
373 const double alpha_u);
374
375 virtual VolUserDataOperator *
377 const std::string &field_name,
378 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
379 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
380 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv);
381
383 std::string row_field, std::string col_field,
384 boost::shared_ptr<DataAtIntegrationPts> data_ptr, const double alpha);
385
386 virtual VolUserDataOperator *
387 returnOpCalculateEnergy(boost::shared_ptr<DataAtIntegrationPts> data_ptr,
388 boost::shared_ptr<double> total_energy_ptr);
389
391 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
392 boost::shared_ptr<PhysicalEquations> physics_ptr);
393
395 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
396 boost::shared_ptr<PhysicalEquations> physics_ptr);
397
398 virtual VolUserDataOperator *
399 returnOpSetScale(boost::shared_ptr<double> scale_ptr,
400 boost::shared_ptr<PhysicalEquations> physics_ptr);
401
402 std::vector<double> activeVariables;
403 std::vector<double> dependentVariablesPiola;
405
406 /** \name Active variables */
407
408 /**@{*/
409
410 template <int S>
411 inline static DTensor2Ptr get_VecTensor2(std::vector<double> &v) {
412 return DTensor2Ptr(&v[S + 0], &v[S + 1], &v[S + 2], &v[S + 3], &v[S + 4],
413 &v[S + 5], &v[S + 6], &v[S + 7], &v[S + 8]);
414 }
415
416 template <int S>
417 inline static DTensor0Ptr get_VecTensor0(std::vector<double> &v) {
418 return DTensor0Ptr(&v[S + 0]);
419 }
420
421 template <int S0>
422 inline static DTensor3Ptr get_vecTensor3(std::vector<double> &v,
423 const int nba) {
424
425 const int A00 = nba * 0 + S0;
426 const int A01 = nba * 1 + S0;
427 const int A02 = nba * 2 + S0;
428 const int A10 = nba * 3 + S0;
429 const int A11 = nba * 4 + S0;
430 const int A12 = nba * 5 + S0;
431 const int A20 = nba * 6 + S0;
432 const int A21 = nba * 7 + S0;
433 const int A22 = nba * 8 + S0;
434
435 return DTensor3Ptr(
436
437 &v[A00 + 0], &v[A00 + 1], &v[A00 + 2], &v[A01 + 0], &v[A01 + 1],
438 &v[A01 + 2], &v[A02 + 0], &v[A02 + 1], &v[A02 + 2],
439
440 &v[A10 + 0], &v[A10 + 1], &v[A10 + 2], &v[A11 + 0], &v[A11 + 1],
441 &v[A11 + 2], &v[A12 + 0], &v[A12 + 1], &v[A12 + 2],
442
443 &v[A20 + 0], &v[A20 + 1], &v[A20 + 2], &v[A21 + 0], &v[A21 + 1],
444 &v[A21 + 2], &v[A22 + 0], &v[A22 + 1], &v[A22 + 2]
445
446 );
447 }
448
449 /**@}*/
450
451 /** \name Active variables */
452
453 /**@{*/
454
455 inline DTensor2Ptr get_h() { return get_VecTensor2<0>(activeVariables); }
456
457 /**@}*/
458
459 /** \name Dependent variables */
460
461 /**@{*/
462
464 return get_VecTensor2<0>(dependentVariablesPiola);
465 }
466
467 /**@}*/
468
469 /** \name Derivatives of dependent variables */
470
471 /**@{*/
472
474 return get_vecTensor3<0>(dependentVariablesPiolaDirevatives,
475 activeVariables.size());
476 }
478 return get_vecTensor3<3>(dependentVariablesPiolaDirevatives,
479 activeVariables.size());
480 }
482 return get_vecTensor3<6>(dependentVariablesPiolaDirevatives,
483 activeVariables.size());
484 }
485
486 /**@}*/
487};
488
489struct BcDisp {
490 BcDisp(std::string name, std::vector<double> attr, Range faces);
491 std::string blockName;
493 VectorDouble3 vals;
494 VectorInt3 flags;
495};
496using BcDispVec = std::vector<BcDisp>;
497
498struct BcRot {
499 BcRot(std::string name, std::vector<double> attr, Range faces);
500 std::string blockName;
502 VectorDouble vals;
503 double theta;
504};
505using BcRotVec = std::vector<BcRot>;
506
507typedef std::vector<Range> TractionFreeBc;
508
510 TractionBc(std::string name, std::vector<double> attr, Range faces);
511 std::string blockName;
513 VectorDouble3 vals;
514 VectorInt3 flags;
515};
516using TractionBcVec = std::vector<TractionBc>;
517
519 NormalDisplacementBc(std::string name, std::vector<double> attr, Range faces);
520 std::string blockName;
522 double val;
523};
524using NormalDisplacementBcVec = std::vector<NormalDisplacementBc>;
525
527 AnalyticalDisplacementBc(std::string name, std::vector<double> attr,
528 Range faces);
529 std::string blockName;
531 VectorInt3 flags;
532};
533using AnalyticalDisplacementBcVec = std::vector<AnalyticalDisplacementBc>;
534
536 AnalyticalTractionBc(std::string name, std::vector<double> attr, Range faces);
537 std::string blockName;
539 VectorInt3 flags;
540};
541using AnalyticalTractionBcVec = std::vector<AnalyticalTractionBc>;
542
544 PressureBc(std::string name, std::vector<double> attr, Range faces);
545 std::string blockName;
547 double val;
548};
549using PressureBcVec = std::vector<PressureBc>;
550
552 ExternalStrain(std::string name, std::vector<double> attr, Range ents);
553 std::string blockName;
555 double val;
557};
558
559 #ifdef ENABLE_PYTHON_BINDING
560struct AnalyticalExprPython {
561 AnalyticalExprPython() = default;
562 virtual ~AnalyticalExprPython() = default;
563
564 MoFEMErrorCode analyticalExprInit(const std::string py_file);
565 MoFEMErrorCode evalAnalyticalDisp(double delta_t, double t, np::ndarray x,
566 np::ndarray y, np::ndarray z,
567 np::ndarray nx, np::ndarray ny,
568 np::ndarray nz,
569 const std::string &block_name,
570 np::ndarray &analytical_expr);
571 MoFEMErrorCode evalAnalyticalTraction(double delta_t, double t, np::ndarray x,
572 np::ndarray y, np::ndarray z,
573 np::ndarray nx, np::ndarray ny,
574 np::ndarray nz,
575 const std::string &block_name,
576 np::ndarray &analytical_expr);
577
578 template <typename T>
579 inline std::vector<T>
580 py_list_to_std_vector(const boost::python::object &iterable) {
581 return std::vector<T>(boost::python::stl_input_iterator<T>(iterable),
582 boost::python::stl_input_iterator<T>());
583 }
584
585private:
586 bp::object mainNamespace;
587 bp::object analyticalDispFun;
588 bp::object analyticalTractionFun;
589};
590
591extern boost::weak_ptr<AnalyticalExprPython> AnalyticalExprPythonWeakPtr;
592 #endif
593
594 #include "EshelbianCore.hpp"
595 #include "EshelbianOperators.hpp"
596
597} // namespace EshelbianPlasticity
598
599#endif //__ESHELBIAN_PLASTICITY_HPP__
constexpr int SPACE_DIM
constexpr auto A
const double v
phase velocity of light in medium (cm/ns)
boost::shared_ptr< MatrixDouble > MatrixPtr
std::vector< AnalyticalTractionBc > AnalyticalTractionBcVec
std::vector< TractionBc > TractionBcVec
std::vector< AnalyticalDisplacementBc > AnalyticalDisplacementBcVec
std::vector< PressureBc > PressureBcVec
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
std::vector< BcDisp > BcDispVec
boost::shared_ptr< VectorDouble > VectorPtr
constexpr double t
plate stiffness
Definition plate.cpp:58
constexpr auto field_name
MoFEMErrorCode getValueHdivForCGGBubble(MatrixDouble &pts)
MoFEMErrorCode getValue(MatrixDouble &pts, boost::shared_ptr< BaseFunctionCtx > ctx_ptr)
boost::tuple< int, int, MatrixDouble > CachePhi
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, BaseFunctionUnknownInterface **iface) const
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)