45StructuralPythonMaterial :: StructuralPythonMaterial(
int n,
Domain *d) :
50void StructuralPythonMaterial :: initializeFrom(
InputRecord &ir)
52 StructuralMaterial :: initializeFrom(ir);
56 module = bp::import(moduleName.c_str());
63 auto tryDef=[&](
const std::string& attr, bp::object& callable)->
bool{
64 if(PyObject_HasAttrString(
module.ptr(),attr.c_str())){
65 callable=
module.attr(attr.c_str());
66 if(!PyCallable_Check(callable.ptr())){
OOFEM_WARNING(
"Object %s is not callable",attr.c_str());
return false; }
67 }
else callable=bp::object();
85 StructuralMaterial :: giveInputRecord(input);
99 return bp::extract<FloatArray>(func(oldStrain, oldStress, strain, stateDict, tempStateDict, tStep->
giveTargetTime()));
104 return bp::extract<FloatMatrix>(func(oldStrain, oldStress, stateDict, tempStateDict, tStep->
giveTargetTime()));
119 for (
int i = 1; i <= 6; ++i ) {
144 for (
int i = 1; i <= 9; ++i ) {
148 auto dvP = (vPh - vP) /
pert;
167 ms->giveStrainVector(), ms->giveStressVector(), strain,
168 ms->giveStateDictionary(), ms->giveTempStateDictionary(), tStep);
170 ms->letTempStrainVectorBe(strain);
171 ms->letTempStressVectorBe(answer);
182 ms->giveFVector(), ms->givePVector(), vF,
183 ms->giveStateDictionary(), ms->giveTempStateDictionary(), tStep);
185 auto F = from_voigt_form(vF);
188 auto vE = to_voigt_strain(
E);
190 auto P = from_voigt_form(vP);
191 auto S =
dot(Finv, P);
192 auto vS = to_voigt_stress(
S);
194 ms->letTempStrainVectorBe(vE);
195 ms->letTempStressVectorBe(vS);
196 ms->letTempPVectorBe(vP);
197 ms->letTempFVectorBe(vF);
211 bp::extract<double> exNum(val);
212 bp::extract<FloatArray> exMat(val);
213 if ( exNum.check() ) {
216 }
else if ( exMat.check() ) {
220 OOFEM_WARNING(
"Dictionary entry of material state not float or something convertible to FloatArray");
228void StructuralPythonMaterialStatus :: initTempStatus()
230 StructuralMaterialStatus :: initTempStatus();
235StructuralPythonMaterialStatus :: StructuralPythonMaterialStatus(
GaussPoint *
gp) :
241void StructuralPythonMaterialStatus :: updateYourself(
TimeStep *tStep)
243 StructuralMaterialStatus :: updateYourself(tStep);
249void StructuralPythonMaterialStatus :: reinitTempStateDictionary()
#define REGISTER_Material(class)
double & at(std::size_t i)
void subtract(const FloatArray &src)
void setColumn(const FloatArrayF< N > &src, std::size_t c)
void resize(Index rows, Index cols)
void setColumn(const FloatArray &src, int c)
GaussPoint * gp
Associated integration point.
virtual MaterialStatus * giveStatus(GaussPoint *gp) const
const FloatArray & giveTempFVector() const
Returns the const pointer to receiver's temporary deformation gradient vector.
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 & giveTempPVector() const
Returns the const pointer to receiver's temporary first Piola-Kirchhoff stress vector.
const FloatArray & giveTempStrainVector() const
Returns the const pointer to receiver's temporary strain vector.
StructuralMaterial(int n, Domain *d)
int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep) override
bp::dict stateDict
Internal state variables.
bp::object giveStateDictionary()
bp::object giveTempStateDictionary()
void reinitTempStateDictionary()
bp::object module
module containing functions (created from moduleName)
FloatArrayF< 9 > giveFirstPKStressVector_3d(const FloatArrayF< 9 > &vF, GaussPoint *gp, TimeStep *tStep) const override
Default implementation relies on giveRealStressVector for second Piola-Kirchoff stress.
std::string moduleName
Name of the file that contains the python function.
FloatMatrix callTangentFunction(bp::object func, const FloatArray &oldStrain, const FloatArray &oldStress, bp::object stateDict, bp::object tempStateDict, TimeStep *tStep) const
double pert
Numerical pertubation for numerical tangents.
bp::object smallDefTangent
void giveRealStressVector_3d(FloatArray &answer, GaussPoint *gp, const FloatArray &reducedStrain, TimeStep *tStep)
bp::object smallDef
callable for small deformations
bp::object largeDefTangent
FloatArray callStressFunction(bp::object func, const FloatArray &oldStrain, const FloatArray &oldStress, const FloatArray &strain, bp::object stateDict, bp::object tempStateDict, TimeStep *tStep) const
double giveTargetTime()
Returns target time.
#define OOFEM_WARNING(...)
FloatMatrixF< N, P > Tdot(const FloatMatrixF< M, N > &a, const FloatMatrixF< M, P > &b)
Computes .
double dot(const FloatArray &x, const FloatArray &y)
FloatMatrixF< N, N > inv(const FloatMatrixF< N, N > &mat, double zeropiv=1e-24)
Computes the inverse.
FloatMatrixF< N, N > eye()
Constructs an identity matrix.
#define _IFT_StructuralPythonMaterial_moduleName