Go to the documentation of this file.
47 using namespace Eigen;
51 template <
int nDim,
int nNodes >
70 using RhsSized = Matrix< double, sizeLoadVector, 1 >;
72 using CSized = Matrix< double, ParentGeometryElement::voigtSize, ParentGeometryElement::voigtSize >;
73 using Voigt = Matrix< double, ParentGeometryElement::voigtSize, 1 >;
90 inline const static auto layout = makeLayout( {
91 { .name =
"stress", .length = 6 },
92 { .name =
"strain", .length = 6 },
93 { .name =
"begin of material state", .length = 0 },
105 stress( &find(
"stress" ) ),
106 strain( &find(
"strain" ) ),
107 materialStateVars( &find(
"begin of material state" ),
108 nStateVars - getNumberOfRequiredStateVarsQuadraturePointOnly() ){};
113 std::unique_ptr< MarmotMaterialHypoElastic >
material;
117 return QPStateVarManager::getNumberOfRequiredStateVarsQuadraturePointOnly();
122 return getNumberOfRequiredStateVarsQuadraturePointOnly() + material->getNumberOfRequiredStateVars();
127 managedStateVars = std::make_unique< QPStateVarManager >( stateVars, nStateVars );
128 material->assignStateVars( managedStateVars->materialStateVars.data(),
129 managedStateVars->materialStateVars.size() );
133 : xi( xi ), weight( weight ), detJ( 0.0 ), J0xW( 0.0 ),
B(
BSized::Zero() ){};
136 std::vector< QuadraturePoint >
qps;
142 int getNumberOfRequiredStateVars();
144 std::vector< std::vector< std::string > > getNodeFields();
146 std::vector< int > getDofIndicesPermutationPattern();
156 void assignStateVars(
double* stateVars,
int nStateVars );
162 void assignNodeCoordinates(
const double* coordinates );
164 void initializeYourself();
166 void setInitialConditions( StateTypes state,
const double* values );
171 const int elementFace,
173 const double* QTotal,
177 void computeBodyForce(
double*
P,
180 const double* QTotal,
184 void computeYourself(
const double* QTotal,
194 const auto& qp = qps[qpNumber];
196 if ( qp.managedStateVars->contains( stateName ) ) {
197 return qp.managedStateVars->getStateView( stateName );
200 if ( stateName ==
"sdv" ) {
201 std::cout << __PRETTY_FUNCTION__ <<
" on 'sdv' is discouraged and deprecated, please use precise state name";
202 return { qp.managedStateVars->materialStateVars.data(),
203 static_cast< int >( qp.managedStateVars->materialStateVars.size() ) };
207 return qp.material->getStateView( stateName );
211 std::vector< double > getCoordinatesAtCenter();
213 std::vector< std::vector< double > > getCoordinatesAtQuadraturePoints();
215 int getNumberOfQuadraturePoints();
218 template <
int nDim,
int nNodes >
224 elementProperties( Map< const VectorXd >( nullptr, 0 ) ),
225 elLabel( elementID ),
226 sectionType( sectionType )
230 qps.push_back( std::move( qp ) );
234 template <
int nDim,
int nNodes >
237 return qps[0].getNumberOfRequiredStateVars() * qps.size();
240 template <
int nDim,
int nNodes >
245 static vector< vector< string > > nodeFields;
246 if ( nodeFields.empty() )
247 for (
int i = 0; i <
nNodes; i++ ) {
248 nodeFields.push_back( vector< string >() );
249 nodeFields[i].push_back(
"displacement" );
255 template <
int nDim,
int nNodes >
258 static std::vector< int > permutationPattern;
259 if ( permutationPattern.empty() )
261 permutationPattern.push_back( i );
263 return permutationPattern;
266 template <
int nDim,
int nNodes >
269 const int nQpStateVars = nStateVars / qps.size();
271 for (
size_t i = 0; i < qps.size(); i++ ) {
273 double* qpStateVars = stateVars + ( i * nQpStateVars );
274 qp.assignStateVars( qpStateVars, nQpStateVars );
278 template <
int nDim,
int nNodes >
281 new ( &elementProperties ) Eigen::Map< const Eigen::VectorXd >( elementPropertiesInfo.
elementProperties,
285 template <
int nDim,
int nNodes >
288 for (
auto& qp : qps ) {
297 << __PRETTY_FUNCTION__
298 <<
": invalid material assigned; cannot cast to MarmotMaterialHypoElastic!" );
300 if constexpr (
nDim == 3 )
301 qp.material->setCharacteristicElementLength( std::cbrt( 8 * qp.detJ ) );
302 if constexpr (
nDim == 2 )
303 qp.material->setCharacteristicElementLength( std::sqrt( 4 * qp.detJ ) );
304 if constexpr (
nDim == 1 )
305 qp.material->setCharacteristicElementLength( 2 * qp.detJ );
309 template <
int nDim,
int nNodes >
312 ParentGeometryElement::assignNodeCoordinates( coordinates );
315 template <
int nDim,
int nNodes >
323 qp.detJ = J.determinant();
324 qp.B = this->
B( dNdX );
326 if constexpr (
nDim == 3 ) {
327 qp.J0xW = qp.weight * qp.detJ;
329 if constexpr (
nDim == 2 ) {
330 const double& thickness = elementProperties[0];
331 qp.J0xW = qp.weight * qp.detJ * thickness;
333 if constexpr (
nDim == 1 ) {
334 const double& crossSection = elementProperties[0];
335 qp.J0xW = qp.weight * qp.detJ * crossSection;
340 template <
int nDim,
int nNodes >
350 using namespace ContinuumMechanics::VoigtNotation;
352 Map< const RhsSized > QTotal( QTotal_ );
353 Map< const RhsSized > dQ( dQ_ );
354 Map< KeSizedMatrix > Ke( Ke_ );
355 Map< RhsSized > Pe( Pe_ );
365 if constexpr (
nDim == 1 ) {
367 S = reduce3DVoigt< ParentGeometryElement::voigtSize >( qp.managedStateVars->stress );
368 qp.material->computeUniaxialStress( S.data(), C.data(), dE.data(), time, dT, pNewDT );
369 qp.managedStateVars->stress = make3DVoigt< ParentGeometryElement::voigtSize >( S );
372 else if constexpr (
nDim == 2 ) {
374 if ( sectionType == SectionType::PlaneStress ) {
376 S = reduce3DVoigt< ParentGeometryElement::voigtSize >( qp.managedStateVars->stress );
377 qp.material->computePlaneStress( S.data(), C.data(), dE.data(), time, dT, pNewDT );
378 qp.managedStateVars->stress = make3DVoigt< ParentGeometryElement::voigtSize >( S );
381 else if ( sectionType == SectionType::PlaneStrain ) {
386 Vector6d S6 = qp.managedStateVars->stress;
387 qp.material->computeStress( S6.data(), C66.data(), dE6.data(), time, dT, pNewDT );
388 qp.managedStateVars->stress = S6;
390 S = reduce3DVoigt< ParentGeometryElement::voigtSize >( S6 );
395 else if constexpr (
nDim == 3 ) {
396 if ( sectionType == SectionType::Solid ) {
398 S = qp.managedStateVars->stress;
399 qp.material->computeStress( S.data(), C.data(), dE.data(), time, dT, pNewDT );
400 qp.managedStateVars->stress = S;
404 qp.managedStateVars->strain += make3DVoigt< ParentGeometryElement::voigtSize >( dE );
409 Ke +=
B.transpose() * C *
B * qp.J0xW;
410 Pe -=
B.transpose() * S * qp.J0xW;
414 template <
int nDim,
int nNodes >
420 qp.material->initializeYourself();
427 XiSized coordAtGauss = this->
NB( this->
N( qp.xi ) ) * this->coordinates;
429 const double sigY1 = values[0];
430 const double sigY2 = values[2];
431 const double y1 = values[1];
432 const double y2 = values[3];
434 using namespace Math;
435 qp.managedStateVars->stress( 1 ) =
linearInterpolation( coordAtGauss[1], y1, y2, sigY1, sigY2 );
436 qp.managedStateVars->stress( 0 ) = values[4] * qp.managedStateVars->stress( 1 );
437 qp.managedStateVars->stress( 2 ) = values[5] * qp.managedStateVars->stress( 1 );
442 throw std::invalid_argument(
"Please use initializeStateVars directly on material" );
444 default:
throw std::invalid_argument(
MakeString() << __PRETTY_FUNCTION__ <<
": invalid initial condition" );
448 template <
int nDim,
int nNodes >
452 const int elementFace,
454 const double* QTotal,
458 Map< RhsSized > fU(
P );
460 switch ( loadType ) {
463 const double p = load[0];
470 Pk *= elementProperties[0];
480 const XiSized tractionVector( load );
484 Pk *= elementProperties[0];
490 throw std::invalid_argument(
"Invalid Load Type specified" );
495 template <
int nDim,
int nNodes >
499 const double* QTotal,
503 Map< RhsSized > Pe( P_ );
504 const Map< const Matrix< double, nDim, 1 > > f( load );
506 for (
const auto& qp : qps )
507 Pe += this->
NB( this->
N( qp.xi ) ).transpose() * f * qp.J0xW;
510 template <
int nDim,
int nNodes >
513 std::vector< double > coords(
nDim );
515 Eigen::Map< XiSized > coordsMap( &coords[0] );
516 const auto centerXi = XiSized::Zero();
517 coordsMap = this->
NB( this->
N( centerXi ) ) * this->coordinates;
521 template <
int nDim,
int nNodes >
524 std::vector< std::vector< double > > listedCoords;
526 std::vector< double > coords(
nDim );
527 Eigen::Map< XiSized > coordsMap( &coords[0] );
529 for (
const auto& qp : qps ) {
530 coordsMap = this->
NB( this->
N( qp.xi ) ) * this->coordinates;
531 listedCoords.push_back( coords );
537 template <
int nDim,
int nNodes >
typename ParentGeometryElement::XiSized XiSized
Definition: DisplacementFiniteElement.h:69
const SectionType sectionType
Definition: DisplacementFiniteElement.h:77
Map< const VectorXd > elementProperties
Definition: DisplacementFiniteElement.h:75
@ GeostaticStress
Definition: MarmotElement.h:42
BSized B
Definition: DisplacementFiniteElement.h:86
void assignProperty(const ElementProperties &marmotElementProperty)
Definition: DisplacementFiniteElement.h:279
Definition: MarmotElementProperty.h:42
@ MarmotMaterialStateVars
Definition: MarmotElement.h:43
@ UniaxialStress
Definition: DisplacementFiniteElement.h:56
Eigen::Matrix< double, 1, nNodes > dNdXiSized
Definition: MarmotFiniteElement.h:94
void initializeYourself()
Definition: DisplacementFiniteElement.h:316
std::vector< double > getCoordinatesAtCenter()
Definition: DisplacementFiniteElement.h:511
@ MarmotMaterialInitialization
Definition: MarmotElement.h:44
Definition: MarmotElement.h:34
Definition: MarmotGeometryElement.h:36
int getNDofPerElement()
Definition: DisplacementFiniteElement.h:152
Eigen::Matrix< double, 6, 6 > Matrix6d
Definition: MarmotTypedefs.h:35
Matrix< double, sizeLoadVector, sizeLoadVector > KeSizedMatrix
Definition: DisplacementFiniteElement.h:71
void setInitialConditions(StateTypes state, const double *values)
Definition: DisplacementFiniteElement.h:415
void assembleIntoParentVectorial(const Eigen::VectorXd &boundaryVector, Eigen::Ref< Eigen::VectorXd > ParentVector)
Definition: MarmotFiniteElementBoundary.cpp:274
Definition: MarmotFiniteElement.h:297
Definition: DisplacementFiniteElement.h:52
std::unique_ptr< MarmotMaterialHypoElastic > material
Definition: DisplacementFiniteElement.h:113
int getNumberOfQuadraturePoints()
Definition: DisplacementFiniteElement.h:538
constexpr int nDim
Definition: MarmotFiniteElement.h:112
void assignStateVars(double *stateVars, int nStateVars)
Definition: DisplacementFiniteElement.h:267
@ PlaneStrain
Definition: DisplacementFiniteElement.h:58
void assignStateVars(double *stateVars, int nStateVars)
Definition: DisplacementFiniteElement.h:125
Eigen::Matrix< double, voigtSize, nNodes *nDim > BSized
Definition: MarmotGeometryElement.h:59
int nMaterialProperties
Definition: MarmotElementProperty.h:34
A convenience auxiliary class for managing multiple statevars with arbitrary length in a single conse...
Definition: MarmotStateVarVectorManager.h:37
int getNumberOfRequiredStateVarsQuadraturePointOnly()
Definition: DisplacementFiniteElement.h:115
DistributedLoadTypes
Definition: MarmotElement.h:47
Eigen::Map< Vector6d > mVector6d
Definition: MarmotTypedefs.h:49
Eigen::Matrix< double, nDim, 1 > XiSized
Definition: MarmotGeometryElement.h:53
@ SurfaceTraction
Definition: MarmotElement.h:50
Eigen::VectorXd computeVectorialLoadVector(const Eigen::VectorXd &direction)
compute the element load vector for a unit vectorial load in a given direction.
Definition: MarmotFiniteElementBoundary.cpp:206
double linearInterpolation(double x, double x0, double x1, double y0, double y1)
Definition: MarmotMath.cpp:7
static MarmotMaterial * createMaterial(int materialCode, const double *materialProperties, int nMaterialProperties, int materialNumber)
const double * elementProperties
Definition: MarmotElementProperty.h:44
Definition: MarmotUtils.h:29
SectionType
Definition: DisplacementFiniteElement.h:55
void computeDistributedLoad(MarmotElement::DistributedLoadTypes loadType, double *P, double *K, const int elementFace, const double *load, const double *QTotal, const double *time, double dT)
Definition: DisplacementFiniteElement.h:449
@ Solid
Definition: DisplacementFiniteElement.h:59
Eigen::Matrix3d getPlaneStrainTangent(const Matrix6d &C)
Definition: MarmotLowerDimensionalStress.cpp:37
int getNumberOfRequiredStateVars()
Definition: DisplacementFiniteElement.h:235
Definition: DisplacementFiniteElement.h:49
This file includes functions needed for calculations with stress and strain tensors written in voigt ...
Definition: MarmotTesting.h:30
const int elLabel
Definition: DisplacementFiniteElement.h:76
Eigen::VectorXd computeSurfaceNormalVectorialLoadVector()
compute the element load vector for a unit vectorial load normal to the surface.
Definition: MarmotFiniteElementBoundary.cpp:147
@ PlaneStress
Definition: DisplacementFiniteElement.h:57
Eigen::Matrix< double, voigtSize, nNodes *nDim > B(const Eigen::Matrix< double, nDim, nNodes > &dNdX)
Definition: MarmotFiniteElement.h:116
double detJ
Definition: DisplacementFiniteElement.h:84
std::vector< QuadraturePoint > qps
Definition: DisplacementFiniteElement.h:136
Eigen::Matrix< double, nDim, nNodes > dNdXiSized
Definition: MarmotGeometryElement.h:58
StateTypes
Definition: MarmotElement.h:37
const Marmot::Vector6d P
Definition: MarmotVoigt.cpp:16
mVector6d stress
Definition: DisplacementFiniteElement.h:97
double J0xW
Definition: DisplacementFiniteElement.h:85
Matrix< double, ParentGeometryElement::voigtSize, 1 > Voigt
Definition: DisplacementFiniteElement.h:73
std::vector< std::vector< std::string > > getNodeFields()
Definition: DisplacementFiniteElement.h:241
Eigen::MatrixXd NB(const Eigen::VectorXd &N, const int nDoFPerNode)
const double * materialProperties
Definition: MarmotElementProperty.h:33
Definition: DisplacementFiniteElement.h:79
Eigen::Map< Eigen::VectorXd > materialStateVars
Definition: DisplacementFiniteElement.h:99
const XiSized xi
Definition: DisplacementFiniteElement.h:81
constexpr int nNodes
Definition: MarmotFiniteElement.h:92
Eigen::Matrix< double, 6, 1 > Vector6d
Definition: MarmotTypedefs.h:43
const std::vector< QuadraturePointInfo > & getGaussPointInfo(Marmot::FiniteElement::ElementShapes shape, IntegrationTypes integrationType)
Definition: MarmotFiniteElementBasic.cpp:100
const Marmot::FiniteElement::ElementShapes shape
Definition: MarmotGeometryElement.h:63
int nElementProperties
Definition: MarmotElementProperty.h:45
dNdXiSized dNdXi(double xi)
Definition: MarmotFiniteElement1D.cpp:22
int getNumberOfRequiredStateVars()
Definition: DisplacementFiniteElement.h:120
std::vector< std::vector< double > > getCoordinatesAtQuadraturePoints()
Definition: DisplacementFiniteElement.h:522
Marmot::Vector6d planeVoigtToVoigt(const Eigen::Vector3d &voigtPlane)
IntegrationTypes
Definition: MarmotFiniteElement.h:358
int getNSpatialDimensions()
Definition: DisplacementFiniteElement.h:150
QPStateVarManager(double *theStateVarVector, int nStateVars)
Definition: DisplacementFiniteElement.h:103
std::unique_ptr< QPStateVarManager > managedStateVars
Definition: DisplacementFiniteElement.h:111
const double weight
Definition: DisplacementFiniteElement.h:82
int getNNodes()
Definition: DisplacementFiniteElement.h:148
int materialCode
Definition: MarmotElementProperty.h:32
static int getNumberOfRequiredStateVarsQuadraturePointOnly()
Definition: DisplacementFiniteElement.h:101
Definition: MarmotElementProperty.h:30
QuadraturePoint(XiSized xi, double weight)
Definition: DisplacementFiniteElement.h:132
@ Pressure
Definition: MarmotElement.h:48
Eigen::MatrixXd Jacobian(const Eigen::MatrixXd &dN_dXi, const Eigen::VectorXd &coordinates)
void computeBodyForce(double *P, double *K, const double *load, const double *QTotal, const double *time, double dT)
Definition: DisplacementFiniteElement.h:496
NSized N(double xi)
Definition: MarmotFiniteElement1D.cpp:15
Definition: DisplacementFiniteElement.h:88
Eigen::Matrix< double, nDim, nDim > JacobianSized
Definition: MarmotGeometryElement.h:55
void computeYourself(const double *QTotal, const double *dQ, double *Pe, double *Ke, const double *time, double dT, double &pNewdT)
Definition: DisplacementFiniteElement.h:341
mVector6d strain
Definition: DisplacementFiniteElement.h:98
std::vector< int > getDofIndicesPermutationPattern()
Definition: DisplacementFiniteElement.h:256
Matrix< double, sizeLoadVector, 1 > RhsSized
Definition: DisplacementFiniteElement.h:70
Matrix< double, ParentGeometryElement::voigtSize, ParentGeometryElement::voigtSize > CSized
Definition: DisplacementFiniteElement.h:72
std::string getElementShape()
Definition: DisplacementFiniteElement.h:154
StateView getStateView(const std::string &stateName, int qpNumber)
Definition: DisplacementFiniteElement.h:192
Definition: MarmotMaterialHypoElastic.h:54
void assignNodeCoordinates(const double *coordinates)
Definition: DisplacementFiniteElement.h:310
Definition: MarmotJournal.h:32