Skip to content

Commit 0a466a1

Browse files
authored
Merge pull request #159 from thelfer/149-add-evaluators
149 add evaluators
2 parents 47642da + 63df448 commit 0a466a1

113 files changed

Lines changed: 12725 additions & 150 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ project("mfront-generic-interface"
1111
DESCRIPTION "${MFrontGenericInterfaceSupportDescription}"
1212
HOMEPAGE_URL "https://thelfer.github.io/mgis/web/index.html")
1313

14+
write_basic_package_version_file(
15+
"${PROJECT_BINARY_DIR}/mgis-config-version.cmake"
16+
VERSION "${VERSION}"
17+
COMPATIBILITY SameMinorVersion)
18+
install(FILES "${PROJECT_BINARY_DIR}/mgis-config-version.cmake"
19+
DESTINATION "${mgis_export_install_path}")
20+
1421
set(CMAKE_CXX_STANDARD 20)
1522
set(CXX_STANDARD_REQUIRED ON)
1623

@@ -22,6 +29,11 @@ option(enable-portable-build "produce binary that can be shared between various
2229
# find_package (Eigen3 REQUIRED)
2330
# endif (enable-eigen-bindings)
2431

32+
# enable mgis-function
33+
option(enable-mgis-function "enable mgis function" ON)
34+
# enable exceptions usage
35+
option(enable-exceptions "use exceptions to report contract violation and error reporting" OFF)
36+
2537
# C-bindings (placed before compiler detection)
2638
option(enable-c-bindings "enable c bindings support")
2739

bindings/c/tests/BoundsCheckTest-c.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ int main(const int argc, const char* const* argv) {
8383
long double lowerBound;
8484
check_status(
8585
mgis_bv_behaviour_get_lower_bound(&lowerBound, b, "YoungModulus"));
86-
check(fabs(lowerBound - yg_min) < eps * yg_min,
86+
check(fabsl(lowerBound - yg_min) < eps * yg_min,
8787
"invalid lower bound for 'YoungModulus'");
8888
int hasUpperBound;
8989
check_status(mgis_bv_behaviour_has_upper_bound(&hasUpperBound, b, "YoungModulus"));
9090
check(hasUpperBound, "'YoungModulus' shall have an upper bound");
9191
long double upperBound;
9292
check_status(
9393
mgis_bv_behaviour_get_upper_bound(&upperBound, b, "YoungModulus"));
94-
check(fabs(upperBound - yg_max) < eps * yg_max,
94+
check(fabsl(upperBound - yg_max) < eps * yg_max,
9595
"invalid upper bound for 'YoungModulus'");
9696
// physical bounds
9797
int hasPhysicalBounds;
@@ -103,7 +103,7 @@ int main(const int argc, const char* const* argv) {
103103
long double lowerPhysicalBound;
104104
check_status(mgis_bv_behaviour_get_lower_physical_bound(&lowerPhysicalBound,
105105
b, "YoungModulus"));
106-
check(fabs(lowerPhysicalBound) < eps * yg_min,
106+
check(fabsl(lowerPhysicalBound) < eps * yg_min,
107107
"invalid physical lower bound for 'YoungModulus'");
108108
int hasUpperPhysicalBound;
109109
check_status(mgis_bv_behaviour_has_upper_physical_bound(&hasUpperPhysicalBound, b, "YoungModulus"));

bindings/julia/src/Behaviour.cxx

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include "MGIS/Julia/JuliaUtilities.hxx"
1919

2020
void declareBehaviour(jlcxx::Module &m) {
21-
using mgis::behaviour::BehaviourDescription;
2221
using mgis::behaviour::Behaviour;
22+
using mgis::behaviour::BehaviourDescription;
2323
using mgis::behaviour::FiniteStrainBehaviourOptions;
2424
using mgis::behaviour::Hypothesis;
2525
//
@@ -32,9 +32,11 @@ void declareBehaviour(jlcxx::Module &m) {
3232
&mgis::behaviour::setParameter;
3333
void (*setParameter2)(const Behaviour &, const std::string &, const int) =
3434
&mgis::behaviour::setParameter;
35-
double (*getParameterDefaultValue1)(const BehaviourDescription &, const std::string &) =
35+
double (*getParameterDefaultValue1)(const BehaviourDescription &,
36+
const std::string &) =
3637
&mgis::behaviour::getParameterDefaultValue<double>;
37-
int (*getParameterDefaultValue2)(const BehaviourDescription &, const std::string &) =
38+
int (*getParameterDefaultValue2)(const BehaviourDescription &,
39+
const std::string &) =
3840
&mgis::behaviour::getParameterDefaultValue<int>;
3941
unsigned short (*getParameterDefaultValue3)(const BehaviourDescription &,
4042
const std::string &) =
@@ -45,19 +47,25 @@ void declareBehaviour(jlcxx::Module &m) {
4547
mgis::behaviour::hasLowerBound;
4648
bool (*hasUpperBound)(const BehaviourDescription &, const std::string &) =
4749
mgis::behaviour::hasUpperBound;
48-
long double (*getLowerBound)(const BehaviourDescription &, const std::string &) =
50+
long double (*getLowerBound)(const BehaviourDescription &,
51+
const std::string &) =
4952
mgis::behaviour::getLowerBound;
50-
long double (*getUpperBound)(const BehaviourDescription &, const std::string &) =
53+
long double (*getUpperBound)(const BehaviourDescription &,
54+
const std::string &) =
5155
mgis::behaviour::getUpperBound;
5256
bool (*hasPhysicalBounds)(const BehaviourDescription &, const std::string &) =
5357
mgis::behaviour::hasPhysicalBounds;
54-
bool (*hasLowerPhysicalBound)(const BehaviourDescription &, const std::string &) =
58+
bool (*hasLowerPhysicalBound)(const BehaviourDescription &,
59+
const std::string &) =
5560
mgis::behaviour::hasLowerPhysicalBound;
56-
bool (*hasUpperPhysicalBound)(const BehaviourDescription &, const std::string &) =
61+
bool (*hasUpperPhysicalBound)(const BehaviourDescription &,
62+
const std::string &) =
5763
mgis::behaviour::hasUpperPhysicalBound;
58-
long double (*getLowerPhysicalBound)(const BehaviourDescription &, const std::string &) =
64+
long double (*getLowerPhysicalBound)(const BehaviourDescription &,
65+
const std::string &) =
5966
mgis::behaviour::getLowerPhysicalBound;
60-
long double (*getUpperPhysicalBound)(const BehaviourDescription &, const std::string &) =
67+
long double (*getUpperPhysicalBound)(const BehaviourDescription &,
68+
const std::string &) =
6169
mgis::behaviour::getUpperPhysicalBound;
6270
//!
6371
m.add_bits<FiniteStrainBehaviourOptions::StressMeasure>(
@@ -89,20 +97,22 @@ void declareBehaviour(jlcxx::Module &m) {
8997
[](const FiniteStrainBehaviourOptions &o) noexcept {
9098
return o.stress_measure;
9199
})
92-
.method("set_stress_measure!",
93-
[](FiniteStrainBehaviourOptions &o,
94-
const FiniteStrainBehaviourOptions::StressMeasure &s) noexcept {
95-
o.stress_measure = s;
96-
})
100+
.method(
101+
"set_stress_measure!",
102+
[](FiniteStrainBehaviourOptions &o,
103+
const FiniteStrainBehaviourOptions::StressMeasure &s) noexcept {
104+
o.stress_measure = s;
105+
})
97106
.method("get_tangent_operator",
98107
[](const FiniteStrainBehaviourOptions &o) noexcept {
99108
return o.tangent_operator;
100109
})
101-
.method("set_tangent_operator!",
102-
[](FiniteStrainBehaviourOptions &o,
103-
const FiniteStrainBehaviourOptions::TangentOperator &to) noexcept {
104-
o.tangent_operator = to;
105-
});
110+
.method(
111+
"set_tangent_operator!",
112+
[](FiniteStrainBehaviourOptions &o,
113+
const FiniteStrainBehaviourOptions::TangentOperator &to) noexcept {
114+
o.tangent_operator = to;
115+
});
106116
//
107117
m.add_bits<Behaviour::BehaviourType>("BehaviourType");
108118
m.set_const("GENERALBEHAVIOUR", Behaviour::GENERALBEHAVIOUR);
@@ -135,16 +145,24 @@ void declareBehaviour(jlcxx::Module &m) {
135145
Behaviour::FINITESTRAINKINEMATIC_F_CAUCHY);
136146
//
137147
m.add_type<Behaviour>("Behaviour")
138-
.method("get_library", [](const Behaviour &b) noexcept { return b.library; })
139-
.method("get_behaviour", [](const Behaviour &b) noexcept { return b.behaviour; })
140-
.method("get_hypothesis", [](const Behaviour &b) noexcept { return b.hypothesis; })
141-
.method("get_function", [](const Behaviour &b) noexcept { return b.function; })
142-
.method("get_source", [](const Behaviour &b) noexcept { return b.source; })
148+
.method("get_library",
149+
[](const Behaviour &b) noexcept { return b.library; })
150+
.method("get_behaviour",
151+
[](const Behaviour &b) noexcept { return b.behaviour; })
152+
.method("get_hypothesis",
153+
[](const Behaviour &b) noexcept { return b.hypothesis; })
154+
.method("get_function",
155+
[](const Behaviour &b) noexcept { return b.function; })
156+
.method("get_source",
157+
[](const Behaviour &b) noexcept { return b.source; })
143158
.method("get_tfel_version",
144159
[](const Behaviour &b) noexcept { return b.tfel_version; })
145-
.method("get_behaviour_type", [](const Behaviour &b) noexcept { return b.btype; })
146-
.method("get_symmetry", [](const Behaviour &b) noexcept { return b.symmetry; })
147-
.method("get_kinematic", [](const Behaviour &b) noexcept { return b.kinematic; })
160+
.method("get_behaviour_type",
161+
[](const Behaviour &b) noexcept { return b.btype; })
162+
.method("get_symmetry",
163+
[](const Behaviour &b) noexcept { return b.symmetry; })
164+
.method("get_kinematic",
165+
[](const Behaviour &b) noexcept { return b.kinematic; })
148166
.method("get_material_properties",
149167
[](const Behaviour &b) { return b.mps; })
150168
.method("get_internal_state_variables",

bindings/julia/src/BehaviourData.cxx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,30 @@ void declareBehaviourData(jlcxx::Module& m) {
3030
.method("set_time_increment!",
3131
[](BehaviourData& d, const mgis::real v) noexcept { d.dt = v; })
3232
.method("get_tangent_operator",
33-
[](BehaviourData& d) noexcept -> std::vector<mgis::real>& { return d.K; })
33+
[](BehaviourData& d) noexcept -> std::vector<mgis::real>& {
34+
return d.K;
35+
})
3436
.method("set_tangent_operator!",
3537
[](BehaviourData& d, const jlcxx::ArrayRef<mgis::real>& a) {
3638
mgis::julia::assign(d.K, a);
3739
})
3840
.method("get_time_increment_increase_factor",
3941
[](BehaviourData& d) noexcept -> mgis::real& { return d.rdt; })
4042
.method("set_time_increment_increase_factor!",
41-
[](BehaviourData& d, const mgis::real& v) noexcept -> void { d.rdt = v; })
42-
.method("get_s0", [](BehaviourData& d) noexcept -> State& { return d.s0; })
43-
.method("get_s1", [](BehaviourData& d) noexcept -> State& { return d.s1; })
43+
[](BehaviourData& d, const mgis::real& v) noexcept -> void {
44+
d.rdt = v;
45+
})
46+
.method("get_s0",
47+
[](BehaviourData& d) noexcept -> State& { return d.s0; })
48+
.method("get_s1",
49+
[](BehaviourData& d) noexcept -> State& { return d.s1; })
4450
.method("get_initial_state",
4551
[](BehaviourData& d) noexcept -> State& { return d.s0; })
4652
.method("get_final_state",
4753
[](BehaviourData& d) noexcept -> State& { return d.s1; })
48-
.method("update", [](BehaviourData& d) { update(d); })
49-
.method("revert", [](BehaviourData& d) { revert(d); })
50-
.method("make_view", [](BehaviourData& d) -> BehaviourDataView {
51-
return make_view(d);})
52-
;
54+
.method("update", [](BehaviourData& d) { update(d); })
55+
.method("revert", [](BehaviourData& d) { revert(d); })
56+
.method("make_view", [](BehaviourData& d) -> BehaviourDataView {
57+
return make_view(d);
58+
});
5359
} // end of declareBehaviourData

bindings/julia/src/State.cxx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,22 @@ void declareState(jlcxx::Module& m) {
2323
using mgis::behaviour::State;
2424
m.add_type<State>("State")
2525
.constructor<const Behaviour&>()
26-
.method("set_stored_energy!",
27-
[](State& s, const mgis::real v) noexcept { s.stored_energy = v; })
26+
.method(
27+
"set_stored_energy!",
28+
[](State& s, const mgis::real v) noexcept { s.stored_energy = v; })
2829
.method("get_stored_energy",
2930
[](State& s) noexcept -> mgis::real& { return s.stored_energy; })
3031
.method("set_dissipated_energy!",
31-
[](State& s, const mgis::real v) noexcept { s.dissipated_energy = v; })
32-
.method("get_dissipated_energy",
33-
[](State& s) noexcept -> mgis::real& { return s.dissipated_energy; })
32+
[](State& s, const mgis::real v) noexcept {
33+
s.dissipated_energy = v;
34+
})
35+
.method(
36+
"get_dissipated_energy",
37+
[](State& s) noexcept -> mgis::real& { return s.dissipated_energy; })
3438
.method("get_gradients",
35-
[](State& s) noexcept -> std::vector<mgis::real>& { return s.gradients; })
39+
[](State& s) noexcept -> std::vector<mgis::real>& {
40+
return s.gradients;
41+
})
3642
.method("set_gradients!",
3743
[](State& s, const jlcxx::ArrayRef<mgis::real>& a) {
3844
mgis::julia::assign(s.gradients, a);

bindings/python/src/Behaviour.cxx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "MGIS/Behaviour/Behaviour.hxx"
2020

2121
// forward declaration
22-
void declareBehaviour(pybind11::module_&);
22+
void declareBehaviour(pybind11::module_ &);
2323

2424
static void rotate_gradients_in_place_member(
2525
const mgis::behaviour::Behaviour &b,
@@ -242,14 +242,11 @@ void declareBehaviour(pybind11::module_ &m) {
242242
// wrapping free functions
243243
m.def("rotateGradients", rotate_gradients_in_place);
244244
m.def("rotateGradients", rotate_gradients_out_of_place);
245-
m.def("rotateThermodynamicForces",
246-
rotate_thermodynamic_forces_in_place);
247-
m.def("rotateThermodynamicForces",
248-
rotate_thermodynamic_forces_out_of_place);
245+
m.def("rotateThermodynamicForces", rotate_thermodynamic_forces_in_place);
246+
m.def("rotateThermodynamicForces", rotate_thermodynamic_forces_out_of_place);
247+
m.def("rotateTangentOperatorBlocks", rotate_tangent_operator_blocks_in_place);
249248
m.def("rotateTangentOperatorBlocks",
250-
rotate_tangent_operator_blocks_in_place);
251-
m.def("rotateTangentOperatorBlocks",
252-
rotate_tangent_operator_blocks_out_of_place);
249+
rotate_tangent_operator_blocks_out_of_place);
253250

254251
m.def("load", load_ptr);
255252
m.def("load", load_ptr2);

bindings/python/src/BehaviourData.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020

2121
void declareBehaviourData(pybind11::module_& m);
2222

23-
static pybind11::object BehaviourData_getK(
24-
mgis::behaviour::BehaviourData& d) {
23+
static pybind11::object BehaviourData_getK(mgis::behaviour::BehaviourData& d) {
2524
if (d.s0.b.to_blocks.size() == 1u) {
2625
const auto s =
2726
getVariableSize(d.s0.b.to_blocks.front().first, d.s0.b.hypothesis);

bindings/python/src/BehaviourDescription.cxx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "MGIS/Behaviour/BehaviourDescription.hxx"
2020

2121
// forward declaration
22-
void declareBehaviourDescription(pybind11::module_&);
22+
void declareBehaviourDescription(pybind11::module_ &);
2323

2424
static const char *BehaviourDescription_getType(
2525
const mgis::behaviour::BehaviourDescription &b) {
@@ -289,18 +289,15 @@ void declareBehaviourDescription(pybind11::module_ &m) {
289289
.def("getLowerPhysicalBound ", getLowerPhysicalBound)
290290
.def("getUpperPhysicalBound ", getUpperPhysicalBound);
291291

292-
m.def(
293-
"isStandardFiniteStrainBehaviour",
294-
mgis::behaviour::isStandardFiniteStrainBehaviour,
295-
"return if the given behaviour is a standard finite strain behaviour, "
296-
"i.e. is a finite strain behaviour using the standard finite strain "
297-
"kinematic (called F-Cauchy although the stress measure can be chosen "
298-
"when loading the behaviour)");
292+
m.def("isStandardFiniteStrainBehaviour",
293+
mgis::behaviour::isStandardFiniteStrainBehaviour,
294+
"return if the given behaviour is a standard finite strain behaviour, "
295+
"i.e. is a finite strain behaviour using the standard finite strain "
296+
"kinematic (called F-Cauchy although the stress measure can be chosen "
297+
"when loading the behaviour)");
299298
m.def("getParameterDefaultValue", getParameterDefaultValue1);
300-
m.def("getIntegerParameterDefaultValue",
301-
getParameterDefaultValue2);
302-
m.def("getUnsignedShortParameterDefaultValue",
303-
getParameterDefaultValue3);
299+
m.def("getIntegerParameterDefaultValue", getParameterDefaultValue2);
300+
m.def("getUnsignedShortParameterDefaultValue", getParameterDefaultValue3);
304301
m.def("hasBounds", hasBounds);
305302
m.def("hasLowerBound", hasLowerBound);
306303
m.def("hasUpperBound", hasUpperBound);

bindings/python/src/MaterialDataManager.cxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
void declareMaterialDataManager(pybind11::module_&);
2222

2323
static void MaterialDataManagerInitializer_bindTangentOperator(
24-
mgis::behaviour::MaterialDataManagerInitializer& i,
25-
pybind11::object K) {
24+
mgis::behaviour::MaterialDataManagerInitializer& i, pybind11::object K) {
2625
i.K = mgis::python::mgis_convert_to_span(K);
2726
} // end of MaterialDataManagerInitializer_bindTangentOperator
2827

2928
static void MaterialDataManagerInitializer_bindSpeedOfSound(
30-
mgis::behaviour::MaterialDataManagerInitializer& i,
31-
pybind11::object vs) {
29+
mgis::behaviour::MaterialDataManagerInitializer& i, pybind11::object vs) {
3230
i.speed_of_sound = mgis::python::mgis_convert_to_span(vs);
3331
} // end of MaterialDataManagerInitializer_bindSpeedOfSound
3432

@@ -56,7 +54,7 @@ static pybind11::object MaterialDataManager_getK(
5654
return mgis::python::wrapInNumPyArray(d.K, s);
5755
} // end of MaterialDataManager_getK
5856

59-
void declareMaterialDataManager(pybind11::module_&m) {
57+
void declareMaterialDataManager(pybind11::module_& m) {
6058
using mgis::size_type;
6159
using mgis::behaviour::Behaviour;
6260
using mgis::behaviour::MaterialDataManager;

bindings/python/src/MaterialStateManager.cxx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,27 @@
2020
#include "MGIS/Behaviour/MaterialStateManager.hxx"
2121

2222
static void MaterialStateManagerInitializer_bindGradients(
23-
mgis::behaviour::MaterialStateManagerInitializer& i,
24-
pybind11::object K) {
23+
mgis::behaviour::MaterialStateManagerInitializer& i, pybind11::object K) {
2524
i.gradients = mgis::python::mgis_convert_to_span(K);
2625
} // end of MaterialStateManagerInitializer_bindGradients
2726

2827
static void MaterialStateManagerInitializer_bindThermodynamicForces(
29-
mgis::behaviour::MaterialStateManagerInitializer& i,
30-
pybind11::object K) {
28+
mgis::behaviour::MaterialStateManagerInitializer& i, pybind11::object K) {
3129
i.thermodynamic_forces = mgis::python::mgis_convert_to_span(K);
3230
} // end of MaterialStateManagerInitializer_bindThermodynamicForces
3331

3432
static void MaterialStateManagerInitializer_bindInternalStateVariables(
35-
mgis::behaviour::MaterialStateManagerInitializer& i,
36-
pybind11::object K) {
33+
mgis::behaviour::MaterialStateManagerInitializer& i, pybind11::object K) {
3734
i.internal_state_variables = mgis::python::mgis_convert_to_span(K);
3835
} // end of MaterialStateManagerInitializer_bindInternalStateVariables
3936

4037
static void MaterialStateManagerInitializer_bindStoredEnergies(
41-
mgis::behaviour::MaterialStateManagerInitializer& i,
42-
pybind11::object K) {
38+
mgis::behaviour::MaterialStateManagerInitializer& i, pybind11::object K) {
4339
i.stored_energies = mgis::python::mgis_convert_to_span(K);
4440
} // end of MaterialStateManagerInitializer_bindStoredEnergies
4541

4642
static void MaterialStateManagerInitializer_bindDissipatedEnergies(
47-
mgis::behaviour::MaterialStateManagerInitializer& i,
48-
pybind11::object K) {
43+
mgis::behaviour::MaterialStateManagerInitializer& i, pybind11::object K) {
4944
i.dissipated_energies = mgis::python::mgis_convert_to_span(K);
5045
} // end of MaterialStateManagerInitializer_bindDissipatedEnergies
5146

0 commit comments

Comments
 (0)