Operators and data structures for small strain plasticity.
#ifndef __ADOLCPLASTICITY_HPP_
#define __ADOLCPLASTICITY_HPP_
#ifndef WITH_ADOL_C
#error "MoFEM need to be compiled with ADOL-C"
#endif
return FTensor::Dg<double, 3, 6>{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0};
};
return FTensor::Dg<double, 3, 6>{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0};
};
return FTensor::Dg<double, 3, 6>{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0};
};
struct CommonData : boost::enable_shared_from_this<CommonData> {
};
};
}
}
return boost::shared_ptr<MatrixDouble>(shared_from_this(), &
gradAtGaussPts);
}
}
PetscBool b_bar =
bBar ? PETSC_TRUE : PETSC_FALSE;
CHKERR PetscOptionsGetBool(PETSC_NULLPTR, PETSC_NULLPTR,
"-b_bar", &b_bar,
PETSC_NULLPTR);
}
return boost::shared_ptr<MatrixDouble>(shared_from_this(), &
stressMatrix);
}
return boost::shared_ptr<MatrixDouble>(shared_from_this(),
}
}
};
struct ClosestPointProjection {
boost::function<int(
int,
int,
int)>
integrationRule = [](int, int,
int p) {
return 2 * (p - 1);
};
}
}
}
}
}
}
ublas::symmetric_matrix<double, ublas::lower>
C,
D;
MoFEMErrorCode
MoFEMErrorCode
virtual MoFEMErrorCode
boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pip,
std::string block_name, Sev sev) {
return 0;
}
bool &recalculate_elastic_tangent) {
return 0;
}
return 0;
}
ublas::matrix<double, ublas::column_major>
dataA;
SmartPetscObj<SNES>
sNes;
};
template <int DIM, StrainType STRAIN>
boost::shared_ptr<ClosestPointProjection> cp_ptr, bool calc_lhs);
template <>
boost::shared_ptr<ClosestPointProjection> cp_ptr, bool calc_lhs);
template <>
boost::shared_ptr<ClosestPointProjection> cp_ptr, bool calc_lhs);
template <>
boost::shared_ptr<ClosestPointProjection> cp_ptr, bool calc_lhs);
template <>
boost::shared_ptr<ClosestPointProjection> cp_ptr, bool calc_lhs);
template <int DIM, IntegrationType I, typename AssemblyDomainEleOp>
struct OpRhsImpl;
template <int DIM, IntegrationType I, typename AssemblyDomainEleOp>
struct OpLhsImpl;
template <typename DomainEleOp> struct ADOLCPlasticityIntegrators {
template <AssemblyType A> struct Assembly {
typename FormsIntegrators<DomainEleOp>::template Assembly<A>::OpBase;
template <int DIM, IntegrationType I>
using OpRhs = OpRhsImpl<DIM, I, AssemblyDomainEleOp>;
template <int DIM, IntegrationType I>
using OpLhs = OpLhsImpl<DIM, I, AssemblyDomainEleOp>;
};
};
using Pip = boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator>;
template <int DIM, AssemblyType A, IntegrationType I, typename DomainEleOp>
std::string block_name, boost::shared_ptr<CommonData> common_data_ptr,
boost::shared_ptr<ClosestPointProjection> cp_ptr, Sev sev = Sev::inform) {
using P = ADOLCPlasticityIntegrators<DomainEleOp>;
CHKERR cp_ptr->addMatBlockOps(m_field, pip, block_name, sev);
pip.push_back(
pip.push_back(
new typename P::template Assembly<A>::template
OpRhs<DIM, I>(
}
template <int DIM, AssemblyType A, IntegrationType I, typename DomainEleOp>
MoFEMErrorCode
std::string block_name,
boost::shared_ptr<CommonData> common_data_ptr,
boost::shared_ptr<ClosestPointProjection> cp_ptr) {
using P = ADOLCPlasticityIntegrators<DomainEleOp>;
CHKERR cp_ptr->addMatBlockOps(m_field, pip, block_name, Sev::noisy);
pip.push_back(
pip.push_back(
new typename P::template Assembly<A>::template
OpLhs<DIM, I>(
}
template <int DIM>
MoFEMErrorCode
std::string block_name,
boost::shared_ptr<CommonData> common_data_ptr,
boost::shared_ptr<ClosestPointProjection> cp_ptr);
template <>
MoFEMErrorCode
std::string block_name,
boost::shared_ptr<CommonData> common_data_ptr,
boost::shared_ptr<ClosestPointProjection> cp_ptr);
template <>
MoFEMErrorCode
std::string block_name,
boost::shared_ptr<CommonData> common_data_ptr,
boost::shared_ptr<ClosestPointProjection> cp_ptr);
struct TSUpdate {
};
boost::shared_ptr<FEMethod> fe_ptr);
struct MakeB {
MatrixDouble &storage, const bool b_bar,
const int nb_integration_pts, double *w_ptr,
MatrixDouble &storage, const bool b_bar,
const int nb_integration_pts, double *w_ptr,
};
template <int DIM, typename AssemblyDomainEleOp>
boost::shared_ptr<CommonData> common_data_ptr);
MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &data);
private:
boost::shared_ptr<CommonData> commonDataPtr;
MatrixDouble baseStorage;
};
template <int DIM, typename AssemblyDomainEleOp>
boost::shared_ptr<CommonData> common_data_ptr);
MoFEMErrorCode iNtegrate(DataForcesAndSourcesCore::EntData &row_data,
DataForcesAndSourcesCore::EntData &col_data);
protected:
boost::shared_ptr<CommonData> commonDataPtr;
MatrixDouble baseRowStorage;
MatrixDouble baseColStorage;
};
template <int DIM, typename AssemblyDomainEleOp>
string field_name, boost::shared_ptr<CommonData> common_data_ptr)
commonDataPtr(common_data_ptr) {}
template <int DIM, typename AssemblyDomainEleOp>
EntitiesFieldData::EntData &data) {
double *w_ptr = &(OP::getGaussPts()(DIM, 0));
data, baseStorage, commonDataPtr->bBar, OP::getGaussPts().size2(), w_ptr,
auto t_stress = getFTensor2SymmetricFromMat<3>(commonDataPtr->stressMatrix);
const auto vol = OP::getMeasure();
auto t_w = OP::getFTensor0IntegrationWeight();
for (int gg = 0; gg != OP::nbIntegrationPts; gg++) {
double alpha = vol * t_w;
for (int bb = 0; bb != OP::nbRows; ++bb) {
OP::locF[bb] += alpha * (t_stress(
i,
j) * t_diff(
i,
j));
++t_diff;
}
++t_w;
++t_stress;
}
}
template <int DIM, typename AssemblyDomainEleOp>
string field_name, boost::shared_ptr<CommonData> common_data_ptr)
AssemblyDomainEleOp::OPROWCOL),
commonDataPtr(common_data_ptr) {
this->sYmm = false;
}
template <int DIM, typename AssemblyDomainEleOp>
DataForcesAndSourcesCore::EntData &row_data,
DataForcesAndSourcesCore::EntData &col_data) {
double *w_ptr = &(OP::getGaussPts()(DIM, 0));
row_data, baseRowStorage, commonDataPtr->bBar, OP::getGaussPts().size2(),
col_data, baseColStorage, commonDataPtr->bBar, OP::getGaussPts().size2(),
auto get_ftensor2_symmetric = [&](auto &storage, const auto gg,
const auto rr) {
&storage(gg, 6 * rr + 0), &storage(gg, 6 * rr + 1),
&storage(gg, 6 * rr + 2), &storage(gg, 6 * rr + 3),
&storage(gg, 6 * rr + 4), &storage(gg, 6 * rr + 5)};
};
auto t_Cep =
getFTensor4DdgFromMat<3, 3, 1>(commonDataPtr->materialTangentOperator);
const auto vol = OP::getMeasure();
auto t_w = OP::getFTensor0IntegrationWeight();
for (int gg = 0; gg != OP::nbIntegrationPts; ++gg) {
const double alpha = vol * t_w;
++t_w;
for (auto rr = 0; rr != OP::nbRows; ++rr) {
t_rowCep(
k,
l) = t_Cep(
i,
j,
k,
l) * t_diff_row(
i,
j);
auto t_diff_col = get_ftensor2_symmetric(baseColStorage, gg, 0);
for (auto cc = 0; cc != OP::nbCols; ++cc) {
OP::locMat(rr, cc) += alpha * (t_rowCep(
k,
l) * t_diff_col(
k,
l));
++t_diff_col;
}
++t_diff_row;
}
++t_Cep;
}
}
}
#endif
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
MoFEMErrorCode opFactoryDomainLhs(MoFEM::Interface &m_field, string field_name, Pip &pip, std::string block_name, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr)
Assemble the left hand side, i.e. tangent matrix.
MoFEMErrorCode opFactoryDomainUpdate(MoFEM::Interface &m_field, Pip &pip, std::string block_name, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr)
Push operators to update history variables.
MoFEMErrorCode opFactoryDomainRhs(MoFEM::Interface &m_field, string field_name, Pip &pip, std::string block_name, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr, Sev sev=Sev::inform)
Assemble the left hand side, i.e. tangent matrix.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
ForcesAndSourcesCore::UserDataOperator * getRawPtrOpCalculateStress< 3, SMALL_STRAIN >(MoFEM::Interface &m_field, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr, bool calc_lhs)
ForcesAndSourcesCore::UserDataOperator * getRawPtrOpCalculateStress< 2, SMALL_STRAIN >(MoFEM::Interface &m_field, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr, bool calc_lhs)
FTensor::Dg< double, 3, 6 > strain_to_voight_op()
Op convert strain tensor to Vight strain vector.
FTensor::Dg< double, 3, 6 > voight_to_stress_op()
Op convert Vight stress vector to stress tensor.
MoFEMErrorCode opFactoryDomainUpdate< 2 >(MoFEM::Interface &m_field, Pip &pip, std::string block_name, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr)
Push operators to update history variables.
MoFEMErrorCode ADOLCPlasticityJac(SNES, Vec, Mat, Mat, void *ctx)
Internal SNES function used at integration points to calulate tangent matrix.
FTensor::Dg< double, 3, 6 > voight_to_strain_op()
Op convert Vight strain vector to strain tensor.
MoFEMErrorCode ADOLCPlasticityRes(SNES snes, Vec chi, Vec r, void *ctx)
Internal SNES function used at integration points to calulate stress.
ForcesAndSourcesCore::UserDataOperator * getRawPtrOpCalculateStress(MoFEM::Interface &m_field, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr, bool calc_lhs)
Get opreator to calulate stress.
boost::shared_ptr< TSUpdate > createTSUpdate(std::string fe_name, boost::shared_ptr< FEMethod > fe_ptr)
ForcesAndSourcesCore::UserDataOperator * getRawPtrOpCalculateStress< 2, LARGE_STRAIN >(MoFEM::Interface &m_field, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr, bool calc_lhs)
ForcesAndSourcesCore::UserDataOperator * getRawPtrOpCalculateStress< 3, LARGE_STRAIN >(MoFEM::Interface &m_field, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr, bool calc_lhs)
boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > Pip
MoFEMErrorCode opFactoryDomainUpdate< 3 >(MoFEM::Interface &m_field, Pip &pip, std::string block_name, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr)
Push operators to update history variables.
constexpr auto field_name
VectorAdaptor activeVariablesW
MatrixDouble partial2HSigmaFlux
VectorAdaptor getInternalFluxes()
MoFEMErrorCode playY_NoGradient()
ublas::vector< adouble > a_internalFluxes
MoFEMErrorCode recordTapes()
Record tapes.
ublas::vector< adouble > a_plasticStrain
std::array< int, LAST_TAPE > tapesTags
MoFEMErrorCode solveClosestProjection()
Solve nonlinear system of equations to find stress, internal fluxes, and Lagrange plastic multiplier.
VectorAdaptor partialYFlux
MatrixDouble partialWStrainPlasticStrain
MoFEMErrorCode recordH()
Record flow potential.
MoFEMErrorCode evaluatePotentials()
friend MoFEMErrorCode ADOLCPlasticityRes(SNES, Vec, Vec, void *ctx)
Function executed by nested SENES at evaluationg residual.
MoFEMErrorCode recordY()
Record yield function.
boost::function< int(int, int, int)> integrationRule
virtual MoFEMErrorCode flowPotential()=0
Set flow potential.
VectorAdaptor getActiveVariablesYH()
ublas::symmetric_matrix< double, ublas::lower > partial2HFlux
MoFEMErrorCode recordW()
Record strain energy.
virtual MoFEMErrorCode addMatBlockOps(MoFEM::Interface &m_field, boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pip, std::string block_name, Sev sev)
Get model parameters from blocks.
VectorAdaptor partialHFlux
ublas::symmetric_matrix< double, ublas::lower > D
MoFEMErrorCode calculateA()
VectorDouble internalVariables0
VectorAdaptor partialHSigma
MoFEMErrorCode playH_NoHessian()
ublas::vector< adouble > a_internalVariables
VectorAdaptor getTotalStrain()
ublas::symmetric_matrix< double, ublas::lower > C
virtual MoFEMErrorCode setParams(short tag, bool &recalculate_elastic_tangent)
Set parameters for ADOL-C of constitutive relations.
virtual MoFEMErrorCode codedHessianW(vector< double * >)
VectorAdaptor partialYSigma
MoFEMErrorCode playPotentials_NoHessian()
SmartPetscObj< Vec > dChi
SmartPetscObj< SNES > sNes
virtual MoFEMErrorCode yieldFunction()=0
Set yield function.
VectorAdaptor getInternalVariables()
MoFEMErrorCode calculateR(Vec R)
MoFEMErrorCode createMatAVecR()
ublas::vector< adouble > a_sTress
MoFEMErrorCode consistentTangent()
Calculate consistent tangent matrix.
MoFEMErrorCode playW_NoHessian()
ublas::symmetric_matrix< double, ublas::lower > partial2HSigma
VectorAdaptor getPlasticStrain()
ublas::vector< adouble > a_sTrain
friend MoFEMErrorCode ADOLCPlasticityJac(SNES, Vec, Mat, Mat, void *ctx)
Function executed by nested SENES at evaluationg tangent matrix.
ublas::matrix< double, ublas::column_major > dataA
VectorDouble plasticStrain0
virtual MoFEMErrorCode freeHemholtzEnergy()=0
Set Hemholtz energy.
MoFEMErrorCode playPotentials()
VectorAdaptor getStress()
MoFEMErrorCode snesCreate()
Create nested snes.
MatrixDouble materialTangentOperator
MoFEMErrorCode getDefaultMaterialParameters()
double * plasticStrainPtr
auto getPlasticStrain(int gg=0)
MatrixDouble activeVariablesW
MatrixDouble plasticStrainMatrix
MatrixDouble stressMatrix
MatrixDouble gradAtGaussPts
auto getInternalVariables(int gg=0)
auto getFTensor1StressAtGaussPts(int gg=0)
auto getFTensor1PlasticStrainAtGaussPts(int gg=0)
boost::shared_ptr< MatrixDouble > getStressMatrixPtr()
double * internalVariablesPtr
auto getGradAtGaussPtsPtr()
int internalVariablesSize
vector< double > deltaGamma
boost::shared_ptr< MatrixDouble > getPlasticStrainMatrixPtr()
static FTensor::Tensor2_symmetric< FTensor::PackPtr< double *, 6 >, 3 > getFTensor2SymmetricDiffBase(DataForcesAndSourcesCore::EntData &data, MatrixDouble &storage, const bool b_bar, const int nb_integration_pts, double *w_ptr, FTensor::Number< 2 >)
MoFEMErrorCode iNtegrate(DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
OpLhsImpl(std::string field_name, boost::shared_ptr< CommonData > common_data_ptr)
MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &data)
OpRhsImpl(std::string field_name, boost::shared_ptr< CommonData > common_data_ptr)
virtual MoFEMErrorCode postProcess(TS ts)=0
Deprecated interface functions.
FormsIntegrators< DomainEleOp >::Assembly< A >::OpBase AssemblyDomainEleOp