6#ifndef MAT_UMAT_IMPL_HPP
7#define MAT_UMAT_IMPL_HPP
24template <
int DIM,
int MODEL_TYPE>
30 EntityHandle entity,
int gg)
override {
34 "UMAT interface is not initialised");
38 umat.noel =
static_cast<int>(entity);
48 CHKERR umat.setStrainIncrementFromDeformationGradient();
58 boost::shared_ptr<MatOpsData> mat_ops_data_ptr)
override {
61 auto set_stress_from_umat_cauchy = [&]() {
64 auto t_P = getFTensor2FromPtr<DIM, DIM>(
65 mat_ops_data_ptr->getDependentDataPtr(
"P")->data().data());
70 for (
int i = 0;
i != DIM; ++
i)
71 for (
int Jidx = 0; Jidx != DIM; ++Jidx)
72 t_P(
i, Jidx) = sigma(
i, Jidx);
77 CHKERR set_stress_from_umat_cauchy();
83 boost::shared_ptr<MatOpsData> mat_ops_data_ptr)
override {
86 auto set_tangent_from_umat_cauchy = [&]() {
89 auto t_dP = getFTensor4FromPtr<DIM, DIM, DIM, DIM>(
90 mat_ops_data_ptr->getDependentDerivativesDataPtr(
"P_dF")
95 CHKERR umat.getCauchyTangentTensor(d_sigma_d_eps);
97 for (
int i = 0;
i != DIM; ++
i)
98 for (
int Jidx = 0; Jidx != DIM; ++Jidx)
99 for (
int m = 0;
m != DIM; ++
m)
100 for (
int N = 0;
N != DIM; ++
N)
107 CHKERR set_tangent_from_umat_cauchy();
112template <
int DIM,
int MODEL_TYPE>
118 EntityHandle entity,
int gg)
override {
128 boost::shared_ptr<MatOpsData> mat_ops_data_ptr)
override {
131 (void)mat_ops_data_ptr;
137 boost::shared_ptr<MatOpsData> mat_ops_data_ptr)
override {
140 (void)mat_ops_data_ptr;
145template <
int DIM,
int MODEL_TYPE>
151 EntityHandle entity,
int gg)
override {
161 boost::shared_ptr<MatOpsData> mat_ops_data_ptr)
override {
164 (void)mat_ops_data_ptr;
170 boost::shared_ptr<MatOpsData> mat_ops_data_ptr)
override {
173 (void)mat_ops_data_ptr;
178template <
int DIM,
int MODEL_TYPE>
195 createOp(boost::shared_ptr<PhysicalEquations> physical_ptr,
bool eval_stress,
196 bool eval_tangent,
bool update)
override;
205 char umat_library[PETSC_MAX_PATH_LEN] =
"./umat.so";
206 char umat_name[80] =
"UMAT";
207 PetscInt nstatev = 0;
209 const char *list_strain_type[] = {
"small",
"hencky",
"finite"};
211 PetscOptionsBegin(PETSC_COMM_WORLD,
"umat_",
"",
"none");
212 CHKERR PetscOptionsString(
"-library",
"Path to UMAT shared library",
"",
213 umat_library, umat_library,
sizeof(umat_library),
215 CHKERR PetscOptionsString(
"-name",
"UMAT material name",
"", umat_name,
216 umat_name,
sizeof(umat_name), PETSC_NULLPTR);
217 CHKERR PetscOptionsInt(
"-nstatev",
"Number of UMAT state variables",
"",
218 nstatev, &nstatev, PETSC_NULLPTR);
219 CHKERR PetscOptionsInt(
"-nprops",
"Number of UMAT material properties",
"",
220 nprops, &nprops, PETSC_NULLPTR);
221 CHKERR PetscOptionsScalar(
"-young_modulus",
"Default first property",
"",
223 CHKERR PetscOptionsScalar(
"-poisson_ratio",
"Default second property",
"",
226 "-strain_type",
"Strain type",
"", list_strain_type, 3,
227 list_strain_type[choice_strain], &choice_strain, PETSC_NULLPTR);
234 strainHandler = std::make_unique<SmallStrainHandler<DIM, MODEL_TYPE>>();
237 strainHandler = std::make_unique<HenckyStrainHandler<DIM, MODEL_TYPE>>();
240 strainHandler = std::make_unique<FiniteStrainHandler<DIM, MODEL_TYPE>>();
244 "Unsupported UMAT strain type");
249 "UMAT requires a positive number of properties");
254 "UMAT requires a non-negative number of state variables");
274 std::string block_name =
"MAT_UMAT";
277 std::regex((boost::format(
"%s(.*)") % block_name).str()))) {
278 std::vector<double> block_data;
279 CHKERR m->getAttributes(block_data);
282 "MAT_UMAT block requires at least %d attributes", nprops);
285 auto get_block_ents = [&]() {
288 m->meshset, ents,
true),
289 "can not get block entities");
295 std::vector<double>(block_data.begin(),
298 std::ostringstream properties_stream;
299 properties_stream <<
"[";
302 properties_stream <<
", ";
303 properties_stream << block_data[ii];
305 properties_stream <<
"]";
308 << *
m <<
" properties = " << properties_stream.str();
342 if (range.find(ent) != range.end()) {
364 DIM * DIM, DIM * DIM,
false);
413 for (
int dd = 0; dd != 3; ++dd)
442 bool has_stored_gradient =
false;
443 for (
int row = 0; row != DIM; ++row) {
444 for (
int col = 0; col != DIM; ++col) {
445 const double value = (*state_ptr)(row * DIM + col, 0);
447 has_stored_gradient = has_stored_gradient || std::abs(value) > 0;
451 if (!has_stored_gradient) {
463 for (
int row = 0; row != DIM; ++row) {
464 for (
int col = 0; col != DIM; ++col) {
465 (*state_ptr)(row *DIM + col, 0) =
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
@ MOFEM_OPERATION_UNSUCCESSFUL
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
FTensor::Index< 'i', SPACE_DIM > i
int umatTensorIndex(const int ii, const int jj)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
UBlasMatrix< double > MatrixDouble
implementation of Data Operators for Forces and Sources
FTensor::Index< 'm', 3 > m
MoFEMErrorCode runUmat(MatUmatImpl< DIM, MODEL_TYPE > &matUmatImpl, EntityHandle entity, int gg) override
MoFEMErrorCode convertTangent(MatUmatImpl< DIM, MODEL_TYPE > &matUmatImpl, boost::shared_ptr< MatOpsData > mat_ops_data_ptr) override
MoFEMErrorCode convertStress(MatUmatImpl< DIM, MODEL_TYPE > &matUmatImpl, boost::shared_ptr< MatOpsData > mat_ops_data_ptr) override
MoFEMErrorCode convertTangent(MatUmatImpl< DIM, MODEL_TYPE > &matUmatImpl, boost::shared_ptr< MatOpsData > mat_ops_data_ptr) override
MoFEMErrorCode runUmat(MatUmatImpl< DIM, MODEL_TYPE > &matUmatImpl, EntityHandle entity, int gg) override
MoFEMErrorCode convertStress(MatUmatImpl< DIM, MODEL_TYPE > &matUmatImpl, boost::shared_ptr< MatOpsData > mat_ops_data_ptr) override
MoFEMErrorCode storeCurrentDeformationGradient(EntityHandle entity, int gg)
MoFEMErrorCode loadPreviousStress(EntityHandle entity, int gg)
MoFEMErrorCode storeCurrentStress(EntityHandle entity, int gg)
static constexpr auto STRESS_TAG_NAME
static std::string getStateVariableTagName(const int index)
MoFEMErrorCode getOptions(MoFEM::Interface *m_field_ptr=nullptr) override
virtual MoFEMErrorCode recordAuxiliaryMatOpsData()
virtual MoFEMErrorCode loadPredef(EntityHandle entity, int gg)
ForcesAndSourcesCore::UserDataOperator * createOp(boost::shared_ptr< PhysicalEquations > physical_ptr, bool eval_stress, bool eval_tangent, bool update) override
std::vector< double > defaultMaterialParameters
MoFEMErrorCode recordTape() override
std::vector< double > currentMaterialParameters
static bool useDeformationGradient
std::unique_ptr< UmatInterfaceType > umatInterfacePtr
static constexpr auto STATEV_TAG_NAME
MoFEMErrorCode storeCurrentStateVariables(EntityHandle entity, int gg)
MoFEMErrorCode setParams(FEMethod *fe_ptr, int gg) override
int numberMaterialProperties
MoFEMErrorCode evaluateVariable(int, EntityHandle entity, int gg) override
static constexpr auto DFGRD0_TAG_NAME
virtual MoFEMErrorCode loadCoordinates(EntityHandle entity, int gg)
MoFEMErrorCode updateState(int, EntityHandle entity, int gg) override
std::unique_ptr< StrainHandler< DIM, MODEL_TYPE > > strainHandler
virtual MoFEMErrorCode bindAuxiliaryStateTags(MoFEM::Interface &m_field)
MoFEMErrorCode loadPreviousDeformationGradient(EntityHandle entity, int gg)
PhysicalEquations()=delete
MoFEM::Interface * mField
std::vector< double > stateVar
MoFEMErrorCode loadPreviousStateVariables(EntityHandle entity, int gg)
MoFEMErrorCode evaluateDerivatives(int, EntityHandle entity, int gg) override
PetscReal currentTimeIncrement
std::vector< std::pair< Range, std::vector< double > > > paramVecByRange
boost::shared_ptr< MatOpsData > matOpsDataPtr
PhysicalEquations()=delete
MoFEMErrorCode runUmat(MatUmatImpl< DIM, MODEL_TYPE > &matUmatImpl, EntityHandle entity, int gg) override
MoFEMErrorCode convertTangent(MatUmatImpl< DIM, MODEL_TYPE > &matUmatImpl, boost::shared_ptr< MatOpsData > mat_ops_data_ptr) override
MoFEMErrorCode convertStress(MatUmatImpl< DIM, MODEL_TYPE > &matUmatImpl, boost::shared_ptr< MatOpsData > mat_ops_data_ptr) override
Deprecated interface functions.
Structure for user loop methods on finite elements.
EntityHandle getFEEntityHandle() const
Get the entity handle of the current finite element.
Interface for managing meshsets containing materials and boundary conditions.
PetscReal ts_t
Current time value.
PetscReal ts_dt
Current time step size.
PetscInt ts_step
Current time step number.
static constexpr int NTENS
subroutine umat(stress, statev, ddsdde, sse, spd, scd, rpl, ddsddt, drplde, drpldt, stran, dstran, time, dtime, temp, dtemp, predef, dpred, cmname, ndi, nshr, ntens, nstatv, props, nprops, coords, drot, pnewdt, celent, dfgrd0, dfgrd1, noel, npt, layer, kspt, kstep, kinc)