v0.16.3
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw Struct Reference

#include "users_modules/eshelbian_plasticity/src/impl/PlasticIncrementalOptimizationInternal.hpp"

Inheritance diagram for EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw:
[legend]
Collaboration diagram for EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw:
[legend]

Public Types

using IncrementTensor = FTensor::Tensor1< double, plasticLogarithmicStretchCoordinateSize >
 
using GradientTensor = FTensor::Tensor1< double, plasticLocalLawActiveCount >
 
using DirectionTensor = FTensor::Tensor1< double, plasticLocalLawActiveCount >
 
using HessianActionTensor = FTensor::Tensor1< double, plasticLocalLawActiveCount >
 
- Public Types inherited from MatOps::PhysicalEquations
using HookFunction = std::function< MoFEMErrorCode(boost::shared_ptr< MatOpsData >, int, EntityHandle, int)>
 

Public Member Functions

 PlasticLocalLaw (boost::shared_ptr< MatOps::MatOpsData > mat_ops_data_ptr, int tag)
 
MoFEMErrorCode getOptions (MoFEM::Interface *m_field_ptr=nullptr) override
 
MoFEMErrorCode setParams (FEMethod *fe_ptr, int gg) override
 
MoFEMErrorCode recordTape () override
 
ForcesAndSourcesCore::UserDataOperator * createOp (boost::shared_ptr< MatOps::PhysicalEquations > physical_ptr, bool eval_stress, bool eval_tangent, bool update) override
 
MoFEMErrorCode setParameters (const PlasticLocalLawParameters &parameters)
 
const PlasticLocalLawParameters & getParameters () const
 
MoFEMErrorCode evaluateValue (const IncrementTensor &t_increment, double latent, PlasticLocalLawTerms &terms)
 
MoFEMErrorCode evaluateGradient (const IncrementTensor &t_increment, double latent, GradientTensor &t_gradient)
 
MoFEMErrorCode evaluateHessianAction (const IncrementTensor &t_increment, double latent, const DirectionTensor &t_direction, HessianActionTensor &t_hessian_action)
 
- Public Member Functions inherited from MatOps::PhysicalEquations
 PhysicalEquations ()=delete
 
 PhysicalEquations (boost::shared_ptr< MatOpsData > mat_ops_data_ptr, int tag, boost::shared_ptr< std::map< int, Range > > tag_vs_range_ptr=nullptr)
 
virtual ~PhysicalEquations ()=default
 
virtual MoFEMErrorCode setParams (FEMethod *fe_ptr, int gg)=0
 
virtual MoFEMErrorCode addBlockParameters (MoFEM::Interface &m_field, const std::string &block_name, int block_id, const Range &block_entities, const std::vector< double > &block_data)
 
virtual ForcesAndSourcesCore::UserDataOperator * createOp (boost::shared_ptr< PhysicalEquations > physical_ptr, bool eval_stress, bool eval_tangent, bool update)=0
 
virtual MoFEMErrorCode evaluateVariable (int tag, EntityHandle entity, int gg)
 
virtual MoFEMErrorCode evaluateDerivatives (int tag, EntityHandle entity, int gg)
 
virtual MoFEMErrorCode updateState (int tag, EntityHandle entity, int gg)
 

Static Public Attributes

static constexpr const char * tapeName = "EshelbianPlasticLocalLaw"
 
static constexpr const char * incrementDataName = "plastic_increment"
 
static constexpr const char * latentDataName = "plastic_latent"
 
static constexpr const char * densityDataName = "plastic_density"
 
static constexpr const char * densityGradientDataName
 

Private Member Functions

MoFEMErrorCode applyParameters ()
 
MoFEMErrorCode setActiveVariables (const IncrementTensor &t_increment, double latent)
 

Private Attributes

PlasticLocalLawParameters currentParameters {1., 0., 0., 0., 1., 1.}
 
std::vector< double > parameterVector
 
bool tapeRecorded = false
 

Additional Inherited Members

- Public Attributes inherited from MatOps::PhysicalEquations
HookFunction hookEvaluateVariable = AdolCEvaluation::evaluateVariable
 
HookFunction hookEvaluateDerivatives = AdolCEvaluation::evaluateDerivatives
 
HookFunction hookUpdateState = AdolCEvaluation::evaluateVariable
 
int tAg
 
boost::shared_ptr< std::map< int, Range > > tagVsRangePtr
 
std::vector< std::pair< Range, std::vector< double > > > paramVecByRange
 
boost::shared_ptr< MatOpsData > matOpsDataPtr
 

Detailed Description

ADOL-C tape of the local density as a MatOps physical equation.

Active variables are the pointwise field values (five trace-free coordinates of Delta H^p, then psi), never P0 coefficients, so the same tape serves every polynomial order. Parameters are set per point with setParameters(); the tape is recorded once. The coefficient gradient rows (basis functions, reference-volume weights) are assembled by the calling operator, not here. createOp() is intentionally unsupported: EP operators call the point evaluators directly.

Definition at line 144 of file PlasticIncrementalOptimizationInternal.hpp.

Member Typedef Documentation

◆ DirectionTensor

Definition at line 155 of file PlasticIncrementalOptimizationInternal.hpp.

◆ GradientTensor

Definition at line 154 of file PlasticIncrementalOptimizationInternal.hpp.

◆ HessianActionTensor

Definition at line 156 of file PlasticIncrementalOptimizationInternal.hpp.

◆ IncrementTensor

Definition at line 152 of file PlasticIncrementalOptimizationInternal.hpp.

Constructor & Destructor Documentation

◆ PlasticLocalLaw()

EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::PlasticLocalLaw ( boost::shared_ptr< MatOps::MatOpsData >  mat_ops_data_ptr,
int  tag 
)

Definition at line 998 of file PlasticIncrementalOptimizationOperators.cpp.

1000 : MatOps::PhysicalEquations(mat_ops_data_ptr, tag) {
1001 if (!matOpsDataPtr)
1003 "Plastic local law requires MatOps data");
1005}
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
boost::shared_ptr< MatOpsData > matOpsDataPtr
Definition MatOps.hpp:176

Member Function Documentation

◆ applyParameters()

MoFEMErrorCode EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::applyParameters ( )
private

Definition at line 1068 of file PlasticIncrementalOptimizationOperators.cpp.

1068 {
1076 if (tapeRecorded)
1077 set_param_vec(tAg, parameterVector.size(), parameterVector.data());
1079}
#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()

◆ createOp()

ForcesAndSourcesCore::UserDataOperator * EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::createOp ( boost::shared_ptr< MatOps::PhysicalEquations >  physical_ptr,
bool  eval_stress,
bool  eval_tangent,
bool  update 
)
override

Definition at line 1018 of file PlasticIncrementalOptimizationOperators.cpp.

1019 {
1021 "Plastic local law has no generic operator; EP operators "
1022 "call its point evaluators directly");
1023 return nullptr;
1024}
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32

◆ evaluateGradient()

MoFEMErrorCode EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::evaluateGradient ( const IncrementTensor &  t_increment,
double  latent,
GradientTensor &  t_gradient 
)

Euclidean gradient of the density w.r.t. (h_1..h_5, psi).

Definition at line 1173 of file PlasticIncrementalOptimizationOperators.cpp.

1174 {
1176 CHKERR setActiveVariables(t_increment, latent);
1178 auto &gradient_data =
1179 *matOpsDataPtr->getDependentDerivativesDataPtr(densityGradientDataName);
1180 for (int a = 0; a != plasticLocalLawActiveCount; ++a)
1181 t_gradient(a) = gradient_data.data()[a];
1183}
boost::shared_ptr< VectorDouble > latent
constexpr double a
#define CHKERR
Inline error check.
virtual MoFEMErrorCode evaluateDerivatives(int tag, EntityHandle entity, int gg)
Definition MatOps.hpp:163

◆ evaluateHessianAction()

MoFEMErrorCode EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::evaluateHessianAction ( const IncrementTensor &  t_increment,
double  latent,
const DirectionTensor &  t_direction,
HessianActionTensor &  t_hessian_action 
)

Hessian-vector product of the density in active-variable order.

Definition at line 1185 of file PlasticIncrementalOptimizationOperators.cpp.

1187 {
1189 CHKERR setActiveVariables(t_increment, latent);
1190 std::array<double, plasticLocalLawActiveCount> active;
1191 std::array<double, plasticLocalLawActiveCount> direction;
1192 std::array<double, plasticLocalLawActiveCount> action;
1193 for (int l = 0; l != plasticLogarithmicStretchCoordinateSize; ++l) {
1194 active[l] = t_increment(l);
1195 direction[l] = t_direction(l);
1196 }
1200 const int result = ::hess_vec(tAg, plasticLocalLawActiveCount, active.data(),
1201 direction.data(), action.data());
1202 if (result < 0)
1203 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
1204 "ADOL-C plastic local-law Hessian action failed with code %d",
1205 result);
1206 for (int a = 0; a != plasticLocalLawActiveCount; ++a) {
1207 if (!std::isfinite(action[a]))
1208 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
1209 "Plastic local-law Hessian action component %d is not finite", a);
1210 t_hessian_action(a) = action[a];
1211 }
1213}
bool active
boost::shared_ptr< MatrixDouble > direction
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition definitions.h:34
@ MOFEM_INVALID_DATA
Definition definitions.h:36
FTensor::Index< 'l', 3 > l

◆ evaluateValue()

MoFEMErrorCode EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::evaluateValue ( const IncrementTensor &  t_increment,
double  latent,
PlasticLocalLawTerms &  terms 
)

Density from the tape; the other terms from the shared formula.

Definition at line 1152 of file PlasticIncrementalOptimizationOperators.cpp.

1153 {
1155 CHKERR setActiveVariables(t_increment, latent);
1158 const double tape_density =
1159 (*matOpsDataPtr->getDependentDataPtr(densityDataName))(0, 0);
1160#ifndef NDEBUG
1161 if (std::isfinite(tape_density) && std::isfinite(terms.density) &&
1162 std::abs(tape_density - terms.density) >
1163 1e-12 * std::max(1., std::abs(terms.density)))
1164 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
1165 "Plastic local law tape value %g differs from direct value %g",
1166 tape_density, terms.density);
1167#endif
1168 terms.density = tape_density;
1170}
PlasticLocalLawTermsT< T > evaluatePlasticLocalLawTerms(const FTensor::Tensor1< T, plasticLogarithmicStretchCoordinateSize > &t_increment, const T &latent, const PlasticLocalLawParametersT< S > &p)
virtual MoFEMErrorCode evaluateVariable(int tag, EntityHandle entity, int gg)
Definition MatOps.hpp:158

◆ getOptions()

MoFEMErrorCode EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::getOptions ( MoFEM::Interface *  m_field_ptr = nullptr)
overridevirtual

Implements MatOps::PhysicalEquations.

Definition at line 1007 of file PlasticIncrementalOptimizationOperators.cpp.

1007 {
1008 // Parameters come from the optimisation problem and the state at each
1009 // point, not from material blocks or the command line.
1010 return 0;
1011}

◆ getParameters()

const PlasticLocalLawParameters & EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::getParameters ( ) const
inline

Definition at line 171 of file PlasticIncrementalOptimizationInternal.hpp.

171 {
172 return currentParameters;
173 }

◆ recordTape()

MoFEMErrorCode EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::recordTape ( )
overridevirtual

Implements MatOps::PhysicalEquations.

Definition at line 1081 of file PlasticIncrementalOptimizationOperators.cpp.

1081 {
1083 constexpr int nb_coords = plasticLogarithmicStretchCoordinateSize;
1084
1085 matOpsDataPtr->insertActiveData(incrementDataName,
1086 MatrixDouble(nb_coords, 1));
1087 matOpsDataPtr->insertActiveData(latentDataName, MatrixDouble(1, 1));
1088 matOpsDataPtr->insertDependentData(densityDataName, MatrixDouble(1, 1));
1089 matOpsDataPtr->insertDependentDerivativesData(
1091 matOpsDataPtr->getActiveDataPtr(incrementDataName)
1092 ->resize(nb_coords, 1, false);
1093 matOpsDataPtr->getActiveDataPtr(latentDataName)->resize(1, 1, false);
1094 matOpsDataPtr->getDependentDataPtr(densityDataName)->resize(1, 1, false);
1095 matOpsDataPtr->getDependentDerivativesDataPtr(densityGradientDataName)
1096 ->resize(plasticLocalLawActiveCount, 1, false);
1097
1098 auto &increment_data = *matOpsDataPtr->getActiveDataPtr(incrementDataName);
1099 auto &latent_data = *matOpsDataPtr->getActiveDataPtr(latentDataName);
1100 auto &density_data = *matOpsDataPtr->getDependentDataPtr(densityDataName);
1101 increment_data.clear();
1102 latent_data(0, 0) = 0;
1103
1104 // The recording point is immaterial: the law is branch-free. Parameter
1105 // values recorded here are replaced by set_param_vec on every update.
1107 adouble ta_latent;
1108 PlasticLocalLawParametersT<adouble> ta_parameters;
1109
1110 trace_on(tAg);
1111 // Parameter order must match applyParameters().
1112 ta_parameters.yieldStress = mkparam(currentParameters.yieldStress);
1113 ta_parameters.hardeningModulus = mkparam(currentParameters.hardeningModulus);
1114 ta_parameters.committedKappa = mkparam(currentParameters.committedKappa);
1115 ta_parameters.latentCentre = mkparam(currentParameters.latentCentre);
1116 ta_parameters.proximalCoefficient =
1118 ta_parameters.regularisationEpsilon =
1120 // Independent-variable order must match the MatOps active sequence:
1121 // increment coordinates first, then the latent value.
1122 for (int l = 0; l != nb_coords; ++l)
1123 ta_increment(l) <<= increment_data(l, 0);
1124 ta_latent <<= latent_data(0, 0);
1125 auto ta_terms =
1126 evaluatePlasticLocalLawTerms(ta_increment, ta_latent, ta_parameters);
1127 ta_terms.density >>= density_data(0, 0);
1128 trace_off();
1129
1130 tapeRecorded = true;
1133}
UBlasMatrix< double > MatrixDouble
Definition Types.hpp:77

◆ setActiveVariables()

MoFEMErrorCode EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::setActiveVariables ( const IncrementTensor &  t_increment,
double  latent 
)
private

Definition at line 1136 of file PlasticIncrementalOptimizationOperators.cpp.

1137 {
1139 if (!tapeRecorded)
1140 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
1141 "Plastic local law tape is not recorded");
1142 auto &increment_data = *matOpsDataPtr->getActiveDataPtr(incrementDataName);
1143 auto &latent_data = *matOpsDataPtr->getActiveDataPtr(latentDataName);
1144 for (int l = 0; l != plasticLogarithmicStretchCoordinateSize; ++l) {
1145 increment_data(l, 0) = t_increment(l);
1146 }
1147 latent_data(0, 0) = latent;
1149}

◆ setParameters()

MoFEMErrorCode EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::setParameters ( const PlasticLocalLawParameters &  parameters)

Validate and apply parameters to the tape (set_param_vec).

Definition at line 1027 of file PlasticIncrementalOptimizationOperators.cpp.

1027 {
1029 const auto finite = [](double v) { return std::isfinite(v); };
1030 if (!finite(parameters.yieldStress) || !(parameters.yieldStress > 0))
1031 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
1032 "Plastic local law: yield stress must be finite and positive; "
1033 "got %g",
1034 parameters.yieldStress);
1035 if (!finite(parameters.hardeningModulus) || parameters.hardeningModulus < 0)
1036 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
1037 "Plastic local law: hardening modulus must be finite and "
1038 "non-negative; got %g",
1039 parameters.hardeningModulus);
1040 if (!finite(parameters.committedKappa) || parameters.committedKappa < 0)
1041 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
1042 "Plastic local law: committed kappa must be finite and "
1043 "non-negative; got %g",
1044 parameters.committedKappa);
1045 if (!finite(parameters.latentCentre))
1046 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
1047 "Plastic local law: latent centre must be finite; got %g",
1048 parameters.latentCentre);
1049 if (!finite(parameters.proximalCoefficient) ||
1050 !(parameters.proximalCoefficient > 0))
1051 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
1052 "Plastic local law: proximal coefficient must be finite and "
1053 "positive; got %g",
1054 parameters.proximalCoefficient);
1055 // The tape differentiates sqrt(2/3 H:H + eps^2); at eps = 0 the derivative
1056 // at the tensor origin is not finite, so the two-field law requires eps > 0.
1057 if (!finite(parameters.regularisationEpsilon) ||
1058 !(parameters.regularisationEpsilon > 0))
1059 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
1060 "Plastic local law: regularisation epsilon must be finite and "
1061 "positive; got %g",
1062 parameters.regularisationEpsilon);
1063 currentParameters = parameters;
1066}
const double v
phase velocity of light in medium (cm/ns)

◆ setParams()

MoFEMErrorCode EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::setParams ( FEMethod *  fe_ptr,
int  gg 
)
override

Definition at line 1013 of file PlasticIncrementalOptimizationOperators.cpp.

1013 {
1014 return applyParameters();
1015}

Member Data Documentation

◆ currentParameters

PlasticLocalLawParameters EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::currentParameters {1., 0., 0., 0., 1., 1.}
private

Definition at line 191 of file PlasticIncrementalOptimizationInternal.hpp.

191{1., 0., 0., 0., 1., 1.};

◆ densityDataName

constexpr const char* EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::densityDataName = "plastic_density"
staticconstexpr

Definition at line 148 of file PlasticIncrementalOptimizationInternal.hpp.

◆ densityGradientDataName

constexpr const char* EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::densityGradientDataName
staticconstexpr
Initial value:
=
"plastic_density_gradient"

Definition at line 149 of file PlasticIncrementalOptimizationInternal.hpp.

◆ incrementDataName

constexpr const char* EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::incrementDataName = "plastic_increment"
staticconstexpr

Definition at line 146 of file PlasticIncrementalOptimizationInternal.hpp.

◆ latentDataName

constexpr const char* EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::latentDataName = "plastic_latent"
staticconstexpr

Definition at line 147 of file PlasticIncrementalOptimizationInternal.hpp.

◆ parameterVector

std::vector<double> EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::parameterVector
private

Definition at line 192 of file PlasticIncrementalOptimizationInternal.hpp.

◆ tapeName

constexpr const char* EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::tapeName = "EshelbianPlasticLocalLaw"
staticconstexpr

Definition at line 145 of file PlasticIncrementalOptimizationInternal.hpp.

◆ tapeRecorded

bool EshelbianPlasticity::PlasticIncrementalOptimizationInternal::PlasticLocalLaw::tapeRecorded = false
private

Definition at line 193 of file PlasticIncrementalOptimizationInternal.hpp.


The documentation for this struct was generated from the following files: