57int const MFrontUserMaterial :: mfront2oo9[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
58int const MFrontUserMaterial :: mfront2oo6[6] = {0, 1, 2, 3, 4, 5};
62MFrontUserMaterial :: ~MFrontUserMaterial()
69 using namespace mgis::behaviour;
71 StructuralMaterial :: initializeFrom(ir);
81 strncpy(this->libname,
libname.c_str(), 199);
82 strncpy(this->modelname,
modelname.c_str(), 199);
84 this->
behaviour = std::make_unique<Behaviour>(load(this->libname, this->modelname, Hypothesis::TRIDIMENSIONAL));
88 const auto nprops = mgis::behaviour::getArraySize(this->
behaviour->mps, this->behaviour->hypothesis);
90 throw(std::runtime_error(
"wrong number of material properties"));
93 const auto nesvs = mgis::behaviour::getArraySize(this->
behaviour->esvs, this->behaviour->hypothesis);
95 throw(std::runtime_error(
"wrong number of external state variables"));
97 if (this->
behaviour->esvs[0].name !=
"Temperature") {
98 throw(std::runtime_error(
"the temperature is the only external state variable supported so far"));
105 StructuralMaterial :: giveInputRecord(input);
115MFrontUserMaterial :: give3dMaterialStiffnessMatrix(MatResponseMode mode,
GaussPoint *gp,
TimeStep *tStep)
const
118 if (!ms->hasTangent()) {
128 for (
int i = 1; i <= strain.
giveSize(); ++i) {
133 stressh.
times(1.0 / h);
143MFrontUserMaterial :: give3dMaterialStiffnessMatrix_dPdF(MatResponseMode mode,
GaussPoint *gp,
TimeStep *tStep)
const
146 if (!ms->hasTangent()) {
148 const auto &vF = ms->giveTempFVector();
153 auto const &vF = ms->giveTempFVector();
154 auto const &stress = ms->giveTempPVector();
156 for (
int i = 1; i <= 9; ++i ) {
160 auto ds = (stressh - stress) * (1. / h);
171MFrontUserMaterial :: givePlaneStrainStiffMtrx_dPdF(MatResponseMode mmode,
GaussPoint *gp,
TimeStep *tStep)
const
174 return dPdF3D({0, 1, 2, 5, 8}, {0, 1, 2, 5, 8});
186 auto old_state = ms->giveStateVector();
187 auto new_state = old_state;
195 auto mfront_old_strain = old_strain[
mfront2oo6];
199 mfront_stress[3] *= 2.;
200 mfront_stress[4] *= 2.;
201 mfront_stress[5] *= 2.;
202 mfront_old_strain[3] /= 2.;
203 mfront_old_strain[4] /= 2.;
204 mfront_old_strain[5] /= 2.;
205 mfront_new_strain[3] /= 2.;
206 mfront_new_strain[4] /= 2.;
207 mfront_new_strain[5] /= 2.;
210 double externalStateVariables[1] = {293.15};
211 double stored_energy = 0;
212 double dissipated_energy = 0;
214 mgis::behaviour::BehaviourDataView v;
218#ifdef MGIS_BEHAVIOUR_API_VERSION
219#if MGIS_BEHAVIOUR_API_VERSION == 1
222 v.speed_of_sound =
nullptr;
224#error "Unsupported MGIS' behaviour API"
230 v.K = &mfront_jacobian(0, 0);
234 v.s0.gradients = &mfront_old_strain[0];
235 v.s0.thermodynamic_forces = &old_stress[0];
236 v.s0.material_properties =
nullptr;
237 v.s0.internal_state_variables = &old_state[0];
238 v.s0.external_state_variables = externalStateVariables;
239 v.s0.stored_energy = &stored_energy;
240 v.s0.dissipated_energy = &dissipated_energy;
242 v.s1.gradients = &mfront_new_strain[0];
243 v.s1.thermodynamic_forces = &mfront_stress[0];
244 v.s1.material_properties =
nullptr;
245 v.s1.internal_state_variables = &new_state[0];
246 v.s1.external_state_variables = externalStateVariables;
247 v.s1.stored_energy = &stored_energy;
248 v.s1.dissipated_energy = &dissipated_energy;
259 ms->letTempStrainVectorBe(strain);
260 ms->letTempStressVectorBe(stress);
261 ms->letTempStateVectorBe(new_state);
262 ms->letTempTangentBe(jacobian);
270 if ( type == IST_Undefined || type == IST_AbaqusStateVector ) {
272 answer = ms->giveStateVector();
274 }
else if (type == IST_StressTensor) {
275 answer = ms->giveStressVector();
279 return StructuralMaterial :: giveIPValue(answer, gp, type, tStep);
283void MFrontUserMaterialStatus :: initTempStatus()
285 StructuralMaterialStatus :: initTempStatus();
289MFrontUserMaterialStatus :: MFrontUserMaterialStatus(
GaussPoint *
gp,
const mgis::behaviour::Behaviour &b) :
295 const auto numState = mgis::behaviour::getArraySize(b.isvs, b.hypothesis);
303void MFrontUserMaterialStatus :: updateYourself(
TimeStep *tStep)
305 StructuralMaterialStatus :: updateYourself(tStep);
309void MFrontUserMaterialStatus :: printOutputAt(FILE *File,
TimeStep *tStep)
const
311 StructuralMaterialStatus :: printOutputAt(File, tStep);
313 fprintf(File,
" stateVector ");
315 for (
auto &var : state ) {
316 fprintf( File,
" % .4e", var );
#define REGISTER_Material(class)
Index giveSize() const
Returns the size of receiver.
void add(const FloatArray &src)
void subtract(const FloatArray &src)
void setColumn(const FloatArrayF< N > &src, std::size_t c)
void setColumn(const FloatArray &src, int c)
IntegrationPointStatus * giveMaterialStatus(IntegrationPointStatusIDType key=IPSID_Default)
GaussPoint * gp
Associated integration point.
FloatArray stateVector
General state vector.
const FloatArray & giveStateVector() const
bool hasTangentFlag
Checker to see if tangent has been computed.
FloatArray tempStateVector
Temporary state vector.
std::unique_ptr< mgis::behaviour::Behaviour > behaviour
pointer to the MGIS behaviour
FloatArrayF< 6 > giveRealStressVector_3d(const FloatArrayF< 6 > &strain, GaussPoint *gp, TimeStep *tStep) const override
Default implementation relies on giveRealStressVector for second Piola-Kirchoff stress.
static int const mfront2oo6[6]
MFrontUserMaterial(int n, Domain *d)
Constructor.
FloatArray properties
Material properties.
FloatArrayF< 6 > initialStress
Initial stress.
FloatMatrixF< 9, 9 > give3dMaterialStiffnessMatrix_dPdF(MatResponseMode mode, GaussPoint *gp, TimeStep *tStep) const override
virtual MaterialStatus * giveStatus(GaussPoint *gp) const
const FloatArray & giveTempStressVector() const
Returns the const pointer to receiver's temporary stress vector.
StructuralMaterialStatus(GaussPoint *g)
Constructor. Creates new StructuralMaterialStatus with IntegrationPoint g.
const FloatArray & giveTempStrainVector() const
Returns the const pointer to receiver's temporary strain vector.
FloatArray strainVector
Equilibrated strain vector in reduced form.
StructuralMaterial(int n, Domain *d)
virtual FloatArrayF< 9 > giveFirstPKStressVector_3d(const FloatArrayF< 9 > &vF, GaussPoint *gp, TimeStep *tStep) const
Default implementation relies on giveRealStressVector for second Piola-Kirchoff stress.
double giveTimeIncrement()
Returns solution step associated time increment.
#define _IFT_MFrontUserMaterial_properties
#define _IFT_MFrontUserMaterial_libpath
#define _IFT_MFrontUserMaterial_modelname
FloatArrayF< N > zeros()
For more readable code.