41 template <
typename MaterialType,
typename StateType,
typename... parameter_types>
42 auto uniaxial_stress_test(
double t_max,
size_t num_steps,
const MaterialType material,
const StateType initial_state,
43 std::function<
double(
double)> epsilon_xx,
const parameter_types... parameter_functions)
47 auto state = initial_state;
49 auto sigma_yy_and_zz = [&](
auto x) {
50 auto epsilon_yy = x[0];
51 auto epsilon_zz = x[1];
52 using T = decltype(epsilon_yy);
54 du_dx[0][0] = epsilon_xx(t);
55 du_dx[1][1] = epsilon_yy;
56 du_dx[2][2] = epsilon_zz;
57 auto state_copy = state;
58 auto stress = material(state_copy, du_dx, parameter_functions(t)...);
59 return tensor{{stress[1][1], stress[2][2]}};
62 std::vector<tuple<double, tensor<double, 3, 3>,
tensor<double, 3, 3>, StateType> > output_history;
63 output_history.reserve(num_steps);
66 const double dt = t_max / double(num_steps - 1);
67 for (
size_t i = 0; i < num_steps; i++) {
69 auto epsilon_yy_and_zz =
find_root(sigma_yy_and_zz, initial_guess);
70 dudx[0][0] = epsilon_xx(t);
71 dudx[1][1] = epsilon_yy_and_zz[0];
72 dudx[2][2] = epsilon_yy_and_zz[1];
74 auto stress = material(state, dudx, parameter_functions(t)...);
75 output_history.push_back(
tuple{t, dudx, stress, state});
80 return output_history;
102 template <
typename MaterialType,
typename StateType,
typename... functions>
104 const StateType initial_state,
const functions... f)
107 const double dt = t_max / double(num_steps - 1);
108 auto state = initial_state;
110 using output_type = decltype(
std::tuple{t, state, f(0.0)..., decltype(material(state, f(0.0)...)){}});
111 std::vector<output_type> history;
112 history.reserve(num_steps);
114 for (
size_t i = 0; i < num_steps; i++) {
115 auto material_output = material(state, f(t)...);
116 history.push_back(
std::tuple{t, state, f(t)..., material_output});
Accelerator functionality.
auto uniaxial_stress_test(double t_max, size_t num_steps, const MaterialType material, const StateType initial_state, std::function< double(double)> epsilon_xx, const parameter_types... parameter_functions)
Drive the material model thorugh a uniaxial tension experiment.
auto find_root(function &&f, tensor< double, n > x0)
Finds a root of a vector-valued nonlinear function.
tuple(T...) -> tuple< T... >
Class template argument deduction rule for tuples.
auto single_quadrature_point_test(double t_max, size_t num_steps, const MaterialType material, const StateType initial_state, const functions... f)
This function takes a material model (and associate state variables), subjects it to a time history o...
Arbitrary-rank tensor class.
This is a class that mimics most of std::tuple's interface, except that it is usable in CUDA kernels ...
Implementation of the tensor class used by Functional.
Implements a std::tuple-like object that works in CUDA kernels.