6#include <deal.II/base/tensor.h>
7#include <deal.II/base/utilities.h>
9#include <boost/algorithm/string/predicate.hpp>
10#include <boost/range/algorithm_ext/erase.hpp>
11#include <boost/variant.hpp>
17#include <prismspf/config.h>
26template <
unsigned int dim>
33 dealii::Tensor<1, dim>,
34 dealii::Tensor<2, dim>,
35 dealii::Tensor<2, (2 *
dim) - 1 + (
dim / 3)>>;
130 dealii::Tensor<1, dim>
137 dealii::Tensor<2, dim>
153 const std::vector<double> &
constants)
const;
188 for (
unsigned int i = 0;
i <
dim; ++
i)
198 for (
unsigned int i = 0;
i <
dim; ++
i)
200 for (
unsigned int j = 0;
j <
dim; ++
j)
207 template <
unsigned int D = dim>
209 operator()(
const dealii::Tensor<2, (2 *
D) - 1 + (
D / 3)> &value)
const
210 requires((
D != ((2 *
D) - 1 + (
D / 3))))
212 constexpr unsigned int dimension = (2 *
D) - 1 + (
D / 3);
225template <
unsigned int dim>
231 "Mismatch between constants in parameters.prm and CustomPDE.h. The constant "
232 "that you attempted to access was " +
235 return boost::get<double>(model_constants.at(
constant_name));
238template <
unsigned int dim>
244 "Mismatch between constants in parameters.prm and CustomPDE.h. The constant "
245 "that you attempted to access was " +
251template <
unsigned int dim>
257 "Mismatch between constants in parameters.prm and CustomPDE.h. The constant "
258 "that you attempted to access was " +
264template <
unsigned int dim>
265inline dealii::Tensor<1, dim>
271 " Mismatch between constants in parameters.prm and "
272 "CustomPDE.h. The constant that you attempted to access was " +
275 return boost::get<dealii::Tensor<1, dim>>(model_constants.at(
constant_name));
278template <
unsigned int dim>
279inline dealii::Tensor<2, dim>
285 "Mismatch between constants in parameters.prm and CustomPDE.h. The constant "
286 "that you attempted to access was " +
289 return boost::get<dealii::Tensor<2, dim>>(model_constants.at(
constant_name));
292template <
unsigned int dim>
293inline dealii::Tensor<2, (2 *
dim) - 1 + (
dim / 3)>
299 "Mismatch between constants in parameters.prm and CustomPDE.h. The constant "
300 "that you attempted to access was " +
303 return boost::get<dealii::Tensor<2, (2 *
dim) - 1 + (
dim / 3)>>(
307template <
unsigned int dim>
334 dealii::ExcMessage(
"User-defined elastic constant list does not have "
335 "the same number of open and close parentheses."));
341template <
unsigned int dim>
347 boost::range::remove_erase(
element,
'(');
348 boost::range::remove_erase(
element,
')');
352template <
unsigned int dim>
353inline dealii::Tensor<1, dim>
359 dealii::ExcMessage(
"The columns in user-defined constant tensors must be "
360 "equal to the maximum number of dimensions."));
362 dealii::Tensor<1, dim>
temp;
363 for (
unsigned int i = 0;
i <
dim;
i++)
371template <
unsigned int dim>
372inline dealii::Tensor<2, dim>
378 dealii::ExcMessage(
"User-defined constant tensor does not have the "
379 "correct number of elements, matrices must be 3x3."));
383 dealii::Tensor<2, dim>
temp;
384 for (
unsigned int i = 0;
i <
dim;
i++)
386 for (
unsigned int j = 0;
j <
dim;
j++)
396template <
unsigned int dim>
405 "At least two fields are required for user-defined variables (value and type)."));
452 dealii::Tensor<2, (2 *
dim) - 1 + (
dim / 3)>
temp =
459 "Only user-defined constant tensors may have multiple elements."));
463template <
unsigned int dim>
488 "The type for user-defined variables must be `double`, `int`, "
489 "`bool`, `tensor`, or `elastic constants`."));
493template <
unsigned int dim>
494inline dealii::Tensor<2, (2 *
dim) - 1 + (
dim / 3)>
518 AssertThrow(
false, dealii::ExcMessage(
"Invalid elasticity tensor type"));
529 const std::vector<unsigned int>
indices_2d = {0, 1, 5, 6, 10, 14};
535 return elastic_constants_temp.at(index);
542template <
unsigned int dim>
543inline dealii::Tensor<2, (2 *
dim) - 1 + (
dim / 3)>
545 const std::vector<double> &
constants)
const
573 "Invalid elasticity model type for 1D. We only accept "
574 "isotropic elasticity tensors."));
633 AssertThrow(
false, dealii::ExcMessage(
"Invalid elasticity model type"));
711 AssertThrow(
false, dealii::ExcMessage(
"Invalid elasticity model type"));
724template <
unsigned int dim>
728 if (!model_constants.empty())
731 <<
"================================================\n"
732 <<
" User Constants\n"
733 <<
"================================================\n";
static dealii::ConditionalOStream & pout_summary()
Log output stream for writing a summary.log file.
Definition conditional_ostreams.cc:34
Class for printing of variant types. This is bad practice and should be fixed.
Definition user_constants.h:164
void operator()(bool value) const
Definition user_constants.h:179
void operator()(int value) const
Definition user_constants.h:173
void operator()(double value) const
Definition user_constants.h:167
void operator()(const dealii::Tensor< 2, dim > &value) const
Definition user_constants.h:195
void operator()(const dealii::Tensor< 2,(2 *D) - 1+(D/3)> &value) const
Definition user_constants.h:209
void operator()(const dealii::Tensor< 1, dim > &value) const
Definition user_constants.h:185
Class the stores and manages user-defined constants.
Definition user_constants.h:28
InputVariant construct_user_constant(std::vector< std::string > &model_constants_strings)
Assign the specified user constant to whatever type.
Definition user_constants.h:398
double get_model_constant_double(const std::string &constant_name) const
Retrieve the double from the model_constants that are defined from the parameters....
Definition user_constants.h:227
dealii::Tensor< 2,(2 *dim) - 1+(dim/3)> get_model_constant_elasticity_tensor(const std::string &constant_name) const
Retrieve the elasticity tensor from the model_constants that are defined from the parameters....
Definition user_constants.h:294
dealii::Tensor< 2,(2 *dim) - 1+(dim/3)> get_cij_matrix(const ElasticityModel &model, const std::vector< double > &constants) const
Definition user_constants.h:544
dealii::Tensor< 2, dim > get_model_constant_rank_2_tensor(const std::string &constant_name) const
Retrieve the rank 2 tensor from the model_constants that are defined from the parameters....
Definition user_constants.h:280
bool get_model_constant_bool(const std::string &constant_name) const
Retrieve the bool from the model_constants that are defined from the parameters.prm parser....
Definition user_constants.h:253
void add_user_constant(const std::string &constant_name, std::vector< std::string > &model_constants_strings)
Print all user-specified constants.
Definition user_constants.h:101
std::map< std::string, InputVariant > model_constants
List of user-defined constants.
Definition user_constants.h:158
InputVariant primitive_model_constant(std::vector< std::string > &model_constants_strings)
Assign the primitive user constants (e.g., int, double, bool).
Definition user_constants.h:465
boost::variant< double, int, bool, dealii::Tensor< 1, dim >, dealii::Tensor< 2, dim >, dealii::Tensor< 2,(2 *dim) - 1+(dim/3)> > InputVariant
Definition user_constants.h:35
dealii::Tensor< 2,(2 *dim) - 1+(dim/3)> get_cij_tensor(std::vector< double > elastic_constants, const std::string &elastic_const_symmetry) const
Definition user_constants.h:495
dealii::Tensor< 1, dim > compute_rank_1_tensor_constant(const unsigned int &n_elements, const std::vector< std::string > &tensor_elements)
Compute a 1st rank tensor from user inputs .
Definition user_constants.h:354
int get_model_constant_int(const std::string &constant_name) const
Retrieve the int from the model_constants that are defined from the parameters.prm parser....
Definition user_constants.h:240
dealii::Tensor< 2, dim > compute_rank_2_tensor_constant(const unsigned int &n_elements, const std::vector< std::string > &tensor_elements)
Compute a 2nd rank tensor from user inputs .
Definition user_constants.h:373
unsigned int compute_tensor_parentheses(const unsigned int &n_elements, const std::vector< std::string > &tensor_elements)
Compute the number of tensor rows.
Definition user_constants.h:309
void print() const
Print all user-specified constants.
Definition user_constants.h:726
dealii::Tensor< 1, dim > get_model_constant_rank_1_tensor(const std::string &constant_name) const
Retrieve the rank 1 tensor from the model_constants that are defined from the parameters....
Definition user_constants.h:266
void remove_parentheses(std::vector< std::string > &tensor_elements)
Remove and leading and trailing parentheses.
Definition user_constants.h:343
@ Value
Use value of the variable as a criterion for refinement.
Definition grid_refiner_criterion.h:31
Definition conditional_ostreams.cc:20
ElasticityModel
Symmetry of elastic tensor.
Definition type_enums.h:40
@ Transverse
Definition type_enums.h:42
@ Anisotropic
Definition type_enums.h:44
@ Orthotropic
Definition type_enums.h:43
@ Isotropic
Definition type_enums.h:41