13
13
*/
14
14
15
15
#include < cmath>
16
+ #include < array>
16
17
#include < cstdlib>
17
18
#include < iostream>
18
19
#include < string_view>
@@ -53,6 +54,63 @@ void check_behaviour(const mgis::behaviour::Behaviour& b,
53
54
check (getVariableSize (o, h) == 3 , " invalid post-processing output size" );
54
55
} // end of check_behaviour
55
56
57
+ void call_postprocessing (const mgis::behaviour::Behaviour& b){
58
+ using namespace mgis ::behaviour;
59
+ constexpr auto e =
60
+ std::array<mgis::real, 6u >{1.3e-2 , 1.2e-2 , 1.4e-2 , 0 ., 0 ., 0 .};
61
+ constexpr auto e2 =
62
+ std::array<mgis::real, 6u >{1.2e-2 , 1.3e-2 , 1.4e-2 , 0 ., 0 ., 0 .};
63
+ constexpr auto eps = 10 * std::numeric_limits<mgis::real>::epsilon ();
64
+ auto d = BehaviourData{b};
65
+ // initialize the states
66
+ setExternalStateVariable (d.s0 , " Temperature" , 293.15 );
67
+ setExternalStateVariable (d.s1 , " Temperature" , 293.15 );
68
+ //
69
+ for (mgis::size_type i = 0 ; i != 6 ; ++i) {
70
+ d.s1 .gradients [i] = e[i];
71
+ }
72
+ //
73
+ auto outputs = allocatePostProcessingVariables (b, " PrincipalStrain" );
74
+ if (!check (outputs.size () == 3u , " invalid outputs initialisation" )) {
75
+ return ;
76
+ }
77
+ auto v = make_view (d);
78
+ executePostProcessing (outputs, v, b, " PrincipalStrain" );
79
+ for (mgis::size_type i = 0 ; i != 3 ; ++i) {
80
+ check (std::abs (outputs[i] - e2 [i]) < eps, " invalid output value" );
81
+ }
82
+ } // end of call_postprocessing
83
+
84
+ void call_postprocessing2 (const mgis::behaviour::Behaviour& b){
85
+ using namespace mgis ::behaviour;
86
+ constexpr auto e =
87
+ std::array<mgis::real, 6u >{1.3e-2 , 1.2e-2 , 1.4e-2 , 0 ., 0 ., 0 .};
88
+ constexpr auto e2 =
89
+ std::array<mgis::real, 6u >{1.2e-2 , 1.3e-2 , 1.4e-2 , 0 ., 0 ., 0 .};
90
+ constexpr auto eps = 10 * std::numeric_limits<mgis::real>::epsilon ();
91
+ auto m = MaterialDataManager{b, 2u };
92
+ // initialize the states
93
+ setMaterialProperty (m.s1 , " YoungModulus" , 150e9 );
94
+ setMaterialProperty (m.s1 , " PoissonRatio" , 0.3 );
95
+ setExternalStateVariable (m.s1 , " Temperature" , 293.15 );
96
+ update (m);
97
+ //
98
+ for (mgis::size_type i = 0 ; i != 6 ; ++i) {
99
+ m.s1 .gradients [i] = e[i];
100
+ m.s1 .gradients [6 + i] = e[i];
101
+ }
102
+ //
103
+ auto outputs = allocatePostProcessingVariables (m, " PrincipalStrain" );
104
+ if (!check (outputs.size () == 6u , " invalid outputs initialisation" )) {
105
+ return ;
106
+ }
107
+ executePostProcessing (outputs, m, " PrincipalStrain" );
108
+ for (mgis::size_type i = 0 ; i != 3 ; ++i) {
109
+ check (std::abs (outputs[i] - e2 [i]) < eps, " invalid output value" );
110
+ check (std::abs (outputs[3 + i] - e2 [i]) < eps, " invalid output value" );
111
+ }
112
+ } // end of call_postprocessing2
113
+
56
114
int main (const int argc, const char * const * argv) {
57
115
using namespace mgis ::behaviour;
58
116
constexpr const auto h = Hypothesis::TRIDIMENSIONAL;
@@ -62,6 +120,8 @@ int main(const int argc, const char* const* argv) {
62
120
try {
63
121
const auto b = load (argv[1 ], argv[2 ], h);
64
122
check_behaviour (b, h);
123
+ call_postprocessing (b);
124
+ call_postprocessing2 (b);
65
125
} catch (std::exception & e) {
66
126
std::cerr << e.what () << std::endl;
67
127
return EXIT_FAILURE;
0 commit comments