Skip to content

Commit

Permalink
Merge pull request #592 from thelfer/577-mfront-define-material-prope…
Browse files Browse the repository at this point in the history
…rties-through-raw-data

577 mfront define material properties through raw data
  • Loading branch information
thelfer committed Jun 26, 2024
2 parents 7bf9126 + c714cfb commit 14dace8
Show file tree
Hide file tree
Showing 281 changed files with 4,169 additions and 3,362 deletions.
6 changes: 3 additions & 3 deletions bindings/python/include/TFEL/Python/TupleConverter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace tfel::python::internals {
using namespace boost::python;
return incref(make_tuple(std::get<S>(t)...).ptr());
} // end of exe
}; // end of build_python_tuple
}; // end of build_python_tuple

template <typename T, int n>
T extract_nth_elt(const boost::python::tuple& l) {
Expand All @@ -92,7 +92,7 @@ namespace tfel::python::internals {
const integer_sequence<S...>&) {
new (s) std::tuple<Types...>(extract_nth_elt<Types, S>(l)...);
} // end of exe
}; // end of build_tuple
}; // end of build_tuple

/*!
* \brief convert tuple converter to python tuple
Expand All @@ -102,7 +102,7 @@ namespace tfel::python::internals {
static PyObject* convert(const std::tuple<Types...>& t) {
return build_python_tuple<Types...>::exe(t);
} // end of convert
}; // end of struct tuple_to_python_tuple
}; // end of struct tuple_to_python_tuple

template <typename... Types>
struct tuple_from_python_tuple {
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/mfront/BehaviourData.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void declareBehaviourData() {
using namespace boost::python;
using namespace mfront;

const VariableDescription& (BehaviourData::*ptr)(const std::string&)const =
const VariableDescription& (BehaviourData::*ptr)(const std::string&) const =
&BehaviourData::getVariableDescription;

class_<BehaviourData>("BehaviourData")
Expand Down
74 changes: 39 additions & 35 deletions bindings/python/mfront/OverridableImplementation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,26 @@ void declareOverridableImplementation() {
a);
},
"override the name of the author")
.def("overrideDate",
+[](mfront::OverridableImplementation& i, const std::string& a) {
i.setOverridenValue<mfront::OverridableImplementation::DATE>(a);
},
"override the date at which the implementation was written")
.def(
"overrideDate",
+[](mfront::OverridableImplementation& i, const std::string& a) {
i.setOverridenValue<mfront::OverridableImplementation::DATE>(a);
},
"override the date at which the implementation was written")
.def(
"overrideDescription",
+[](mfront::OverridableImplementation& i, const std::string& a) {
i.setOverridenValue<mfront::OverridableImplementation::DESCRIPTION>(
a);
},
"override the description")
.def("overrideMaterial",
+[](mfront::OverridableImplementation& i, const std::string& a) {
i.setOverridenValue<
mfront::OverridableImplementation::MATERIAL_NAME>(a);
},
"override the name of the material")
.def(
"overrideMaterial",
+[](mfront::OverridableImplementation& i, const std::string& a) {
i.setOverridenValue<
mfront::OverridableImplementation::MATERIAL_NAME>(a);
},
"override the name of the material")
.def(
"overrideMaterialPropertyName",
+[](mfront::OverridableImplementation& i, const std::string& a) {
Expand All @@ -65,30 +67,32 @@ void declareOverridableImplementation() {
},
"override the name of the material property (fails if the source "
"file does not describe a material property)")
.def("overrideBehaviourName",
+[](mfront::OverridableImplementation& i, const std::string& a) {
if (i.getTargetType() != mfront::AbstractDSL::BEHAVIOURDSL) {
tfel::raise(
"overrideBehaviourName: invalid call (the DSL does not "
"describe a behaviour)");
}
i.setOverridenValue<mfront::OverridableImplementation::
MATERIAL_KNOWLEDGE_IDENTIFIER>(a);
},
"override the name of the behaviour (fails if the source file does "
"not describe a behaviour)")
.def("overrideModelName",
+[](mfront::OverridableImplementation& i, const std::string& a) {
if (i.getTargetType() != mfront::AbstractDSL::MODELDSL) {
tfel::raise(
"overrideModelName: invalid call (the DSL does not describe "
"a model");
}
i.setOverridenValue<mfront::OverridableImplementation::
MATERIAL_KNOWLEDGE_IDENTIFIER>(a);
},
"override the name of the model (fails if the source file does not "
"describe a model)")
.def(
"overrideBehaviourName",
+[](mfront::OverridableImplementation& i, const std::string& a) {
if (i.getTargetType() != mfront::AbstractDSL::BEHAVIOURDSL) {
tfel::raise(
"overrideBehaviourName: invalid call (the DSL does not "
"describe a behaviour)");
}
i.setOverridenValue<mfront::OverridableImplementation::
MATERIAL_KNOWLEDGE_IDENTIFIER>(a);
},
"override the name of the behaviour (fails if the source file does "
"not describe a behaviour)")
.def(
"overrideModelName",
+[](mfront::OverridableImplementation& i, const std::string& a) {
if (i.getTargetType() != mfront::AbstractDSL::MODELDSL) {
tfel::raise(
"overrideModelName: invalid call (the DSL does not describe "
"a model");
}
i.setOverridenValue<mfront::OverridableImplementation::
MATERIAL_KNOWLEDGE_IDENTIFIER>(a);
},
"override the name of the model (fails if the source file does not "
"describe a model)")
.def("overrideByAParameter",
&mfront::OverridableImplementation::overrideByAParameter,
"override a variable by the given parameter")
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/mfront/VariableDescription.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void declareVariableDescription() {
const VariableBoundsDescription& (VariableDescription::*getBounds_1)() const =
&VariableDescription::getBounds;
const VariableBoundsDescription& (VariableDescription::*getBounds_2)(
const unsigned short)const = &VariableDescription::getBounds;
const unsigned short) const = &VariableDescription::getBounds;
void (VariableDescription::*setBounds_1)(const VariableBoundsDescription&) =
&VariableDescription::setBounds;
void (VariableDescription::*setBounds_2)(const VariableBoundsDescription&,
Expand All @@ -52,7 +52,7 @@ void declareVariableDescription() {
const VariableBoundsDescription& (VariableDescription::*getPhysicalBounds_1)()
const = &VariableDescription::getPhysicalBounds;
const VariableBoundsDescription& (VariableDescription::*getPhysicalBounds_2)(
const unsigned short)const = &VariableDescription::getPhysicalBounds;
const unsigned short) const = &VariableDescription::getPhysicalBounds;
void (VariableDescription::*setPhysicalBounds_1)(
const VariableBoundsDescription&) =
&VariableDescription::setPhysicalBounds;
Expand Down
1 change: 1 addition & 0 deletions bindings/python/mtest/CurrentState.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ void declareCurrentState() {
.add_property("iv1", CurrentState_getiv1)
.add_property("evs0", CurrentState_getesv0)
.add_property("desv", CurrentState_getdesv)
.def_readonly("position", &mtest::CurrentState::position)
.def("setInternalStateVariableValue", ptr,
"set the value of a scalar internal state variable\n"
"\n"
Expand Down
63 changes: 25 additions & 38 deletions docs/mfront/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
macro(install_mfront_desc file)
# if(HAVE_PANDOC)
# ADD_CUSTOM_COMMAND(
# OUTPUT ${file}.html
# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.md
# DEPENDS ${PROJECT_SOURCE_DIR}/docs/web/mfront-template.html
# DEPENDS ${PROJECT_SOURCE_DIR}/docs/web/css/main.css
# COMMAND ${PANDOC}
# ARGS -f markdown-markdown_in_html_blocks+tex_math_single_backslash
# ARGS --mathjax
# ARGS ${ARGN}
# ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.md -o ${file}.html)
# add_custom_target(mfront-${file}-html ALL DEPENDS ${file}.html)
# add_dependencies(website mfront-${file}-html)
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.html
# DESTINATION share/doc/tfel/web/mfront
# COMPONENT website)
# endif(HAVE_PANDOC)
if(TFEL_APPEND_SUFFIX)
install(FILES ${file}.md
DESTINATION share/doc/mfront-${TFEL_SUFFIX}
Expand All @@ -27,21 +10,6 @@ macro(install_mfront_desc file)
endmacro(install_mfront_desc file)

macro(install_mfront_desc2 directory file)
# if(HAVE_PANDOC)
# ADD_CUSTOM_COMMAND(
# OUTPUT ${file}-${directory}.html
# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${directory}/${file}.md
# COMMAND ${PANDOC}
# ARGS -f markdown-markdown_in_html_blocks+tex_math_single_backslash
# ARGS --mathjax
# ARGS ${ARGN}
# ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${directory}/${file}.md -o ${file}-${directory}.html)
# add_custom_target(mfront-${file}-${directory}-html ALL DEPENDS ${file}-${directory}.html)
# add_dependencies(website mfront-${file}-${directory}-html)
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}-${directory}.html
# DESTINATION share/doc/tfel/web/mfront/${directory}/${file}.html
# COMPONENT website)
# endif(HAVE_PANDOC)
if(TFEL_APPEND_SUFFIX)
install(FILES ${directory}/${file}.md
DESTINATION share/doc/mfront-${TFEL_SUFFIX}/${directory}
Expand All @@ -53,6 +21,24 @@ macro(install_mfront_desc2 directory file)
endif(TFEL_APPEND_SUFFIX)
endmacro(install_mfront_desc2 directory file)

macro(install_mfront_desc3 directory1 directory2 file)
if(TFEL_APPEND_SUFFIX)
install(FILES ${directory1}/${file}.md
DESTINATION share/doc/mfront-${TFEL_SUFFIX}/${directory1}
COMPONENT mfront)
install(FILES ${directory1}/${file}.md
DESTINATION share/doc/mfront-${TFEL_SUFFIX}/${directory2}
COMPONENT mfront)
else(TFEL_APPEND_SUFFIX)
install(FILES ${directory1}/${file}.md
DESTINATION share/doc/mfront/${directory1}
COMPONENT mfront)
install(FILES ${directory1}/${file}.md
DESTINATION share/doc/mfront/${directory2}
COMPONENT mfront)
endif(TFEL_APPEND_SUFFIX)
endmacro(install_mfront_desc2 directory file)

install_mfront_desc(AdditionalConvergenceChecks)
install_mfront_desc(AdditionalTangentOperatorBlock)
install_mfront_desc(AdditionalTangentOperatorBlocks)
Expand Down Expand Up @@ -154,12 +140,13 @@ install_mfront_desc(UseQt)

install_mfront_desc2(Implicit HillTensor)

install_mfront_desc2(MaterialLaw Constant)
install_mfront_desc2(MaterialLaw Function)
install_mfront_desc2(MaterialLaw Input)
install_mfront_desc2(MaterialLaw Law)
install_mfront_desc2(MaterialLaw MFront)
install_mfront_desc2(MaterialLaw Output)
install_mfront_desc3(MaterialLaw MaterialProperty Constant)
install_mfront_desc3(MaterialLaw MaterialProperty Data)
install_mfront_desc3(MaterialLaw MaterialProperty Function)
install_mfront_desc3(MaterialLaw MaterialProperty Input)
install_mfront_desc3(MaterialLaw MaterialProperty Law)
install_mfront_desc3(MaterialLaw MaterialProperty MFront)
install_mfront_desc3(MaterialLaw MaterialProperty Output)

install_mfront_desc2(Model ConstantMaterialProperty)
install_mfront_desc2(Model Domain)
Expand Down
52 changes: 52 additions & 0 deletions docs/mfront/MaterialLaw/Data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
The `@Data` keyword allow the definition of a material properties using
the interpolation of a set of values.

The `@Data` keyword is followed by a set of options defining:

- the interpolation option,
- the set of values,
- the extrapolation option.

The precise syntax depends on the number of inputs of the material
property.

## Material properties without input

The only option accepted is `value`.

## Material properties with only one input

The `values` option is required. It must be a map associating values of
the input and values of the output.

The `interpolation` option is optional. It must be a string. The values
`linear` and `cubic_spline` are accepted.

The `extrapolation` option is optional. It must be a boolean or a
string:

- The boolean value `true` means that a linear extrapolation will be performed.
- The boolean value `false` or the string value `bound_to_last_value` or
the string value `constant` means that a constant value will be used
for extrapolation.

## Example of usage

~~~~{.cpp}
@DSL MaterialProperty;
@Law LinearDataInterpolation;
@UseQt true;
@UnitSystem SI;
@Output stress E;
E.setGlossaryName("YoungModulus");
@StateVariable temperature T;
T.setGlossaryName("Temperature");
@Data {
values: { 293.15 : 240e9, 693.15 : 180e9, 893.15 : 170e9 },
interpolation : "linear"
}
~~~~
2 changes: 1 addition & 1 deletion docs/mfront/MaterialLaw/Function.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ thus introduced by the interfaces. We advice the user to use this
{
const real C0 = 575.57;
const real C1 = -21094.;
Cp = C0+C1/T;
Cp = C0 + C1 / T;
}
~~~~
2 changes: 1 addition & 1 deletion docs/mfront/lsdyna/mfront-lsdyna.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace lsdyna {
}
return "";
#endif /* (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__) */
} // end of getErrorMessage
} // end of getErrorMessage

static void log(const std::string& m) {
static std::ofstream log("mfront-lsdyna.log");
Expand Down
10 changes: 7 additions & 3 deletions docs/mfront/mfront/SICCreepBehaviour-ple.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* \date 06 / 12 / 07
*/

MechanicalBehaviour 'IsotropicUmatBehaviour' 'libUmatBehaviour.so' 'umatSiCCreep' MaterialProperty<constant> 'YoungModulus' 150.e9 MaterialProperty<constant> 'PoissonRatio' 0.3 MaterialProperty<
constant> 'ThermalExpansion' 0. MaterialProperty<constant> 'MassDensity' 0. InternalStateVariable<Stensor> 'ElasticStrain' InternalStateVariable<Scalar> 'EquivalentViscoplasticStrain' EndOfMechanicalBehaviour
EndOfMaterial
MechanicalBehaviour 'IsotropicUmatBehaviour' 'libUmatBehaviour.so' 'umatSiCCreep' MaterialProperty <
constant > 'YoungModulus' 150.e9 MaterialProperty < constant >
'PoissonRatio' 0.3 MaterialProperty < constant >
'ThermalExpansion' 0. MaterialProperty < constant >
'MassDensity' 0. InternalStateVariable < Stensor >
'ElasticStrain' InternalStateVariable < Scalar >
'EquivalentViscoplasticStrain' EndOfMechanicalBehaviour EndOfMaterial
4 changes: 2 additions & 2 deletions docs/tutorial/mfront/EllipticCreep.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace tfel {
static_assert(tfel::typetraits::IsFundamentalNumericType<Type>::cond);
static_assert(tfel::typetraits::IsReal<Type>::cond);

friend std::ostream& operator<<<>(std::ostream&, const EllipticCreep&);
friend std::ostream& operator<< <>(std::ostream&, const EllipticCreep&);

static constexpr unsigned short TVectorSize = N;
typedef tfel::math::StensorDimeToSize<N> StensorDimeToSize;
Expand Down Expand Up @@ -833,7 +833,7 @@ namespace tfel {
*/
static std::string getName(void) { return std::string("EllipticCreep"); }
}; // end of struct Name
} // end of namespace utilities
} // end of namespace utilities
} // end of namespace tfel

#endif /* LIB_TFELMATERIAL_ELLIPTICCREEP_HXX_ */
2 changes: 1 addition & 1 deletion docs/web/cxx/mfront/src/PorousStressCriterionTemplate.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace mfront {
return std::make_shared<__StressCriterionName__StressCriterion>();
});
} // end of __StressCriterionName__StressCriterionProxy
}; // end of struct __StressCriterionName__StressCriterionProxy
}; // end of struct __StressCriterionName__StressCriterionProxy

static __StressCriterionName__StressCriterionProxy proxy;

Expand Down
2 changes: 1 addition & 1 deletion docs/web/cxx/mfront/src/StressCriterionTemplate.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace mfront {
return std::make_shared<__StressCriterionName__StressCriterion>();
});
} // end of __StressCriterionName__StressCriterionProxy
}; // end of struct __StressCriterionName__StressCriterionProxy
}; // end of struct __StressCriterionName__StressCriterionProxy

static __StressCriterionName__StressCriterionProxy proxy;

Expand Down
Loading

0 comments on commit 14dace8

Please sign in to comment.