1 #include "../../include/userInputParameters.h" 2 #include <deal.II/base/mpi.h> 3 #include <deal.II/base/utilities.h> 11 unsigned int number_of_constants = input_file_reader.
num_constants;
18 for (
unsigned int i=0; i<number_of_constants; i++){
19 std::string constants_text =
"Model constant ";
22 std::vector<std::string> model_constants_strings = dealii::Utilities::split_string_list(parameter_handler.get(constants_text));
25 if (model_constants_strings.size() < 2){
26 std::cerr <<
"PRISMS-PF ERROR: Users must input two fields for user-defined variables (value and type)." << std::endl;
30 std::vector<std::string> model_constants_type_strings = dealii::Utilities::split_string_list(model_constants_strings.at(model_constants_strings.size()-1),
' ');
32 if (model_constants_strings.size() == 2){
33 if (boost::iequals(model_constants_type_strings.at(0),
"double")){
34 model_constants.push_back(dealii::Utilities::string_to_double(model_constants_strings.at(0)));
37 else if (boost::iequals(model_constants_type_strings.at(0),
"int")){
38 model_constants.push_back(dealii::Utilities::string_to_int(model_constants_strings.at(0)));
40 else if (boost::iequals(model_constants_type_strings.at(0),
"bool")){
42 if (boost::iequals(model_constants_strings.at(0),
"true")){
48 model_constants.push_back(temp);
51 std::cerr <<
"PRISMS-PF ERROR: The type for user-defined variables must be 'double', 'int', 'bool', 'tensor', or 'elastic constants'." << std::endl;
56 if (boost::iequals(model_constants_type_strings.at(0),
"tensor")){
57 unsigned int num_elements = model_constants_strings.size()-1;
60 unsigned int open_parentheses = 0;
61 unsigned int close_parentheses = 0;
62 for (
unsigned int element=0; element<num_elements; element++){
63 std::size_t index = 0;
64 while (index != std::string::npos){
65 index = model_constants_strings.at(element).find(
"(");
66 if (index != std::string::npos) {
67 model_constants_strings.at(element).erase(index,1);
72 while (index != std::string::npos){
73 index = model_constants_strings.at(element).find(
")");
74 if (index != std::string::npos) {
75 model_constants_strings.at(element).erase(index,1);
80 if (open_parentheses != close_parentheses){
81 std::cerr <<
"PRISMS-PF ERROR: User-defined constant tensor does not have the same number of open and close parentheses." << std::endl;
85 if (open_parentheses < 3){
86 if (num_elements > 1 && num_elements < 4){
87 dealii::Tensor<1,dim> temp;
88 for (
unsigned int i=0; i<dim; i++){
89 temp[i] = dealii::Utilities::string_to_double(model_constants_strings.at(i));
91 model_constants.push_back(temp);
94 std::cerr <<
"PRISMS-PF ERROR: The columns in user-defined constant tensors cannot be longer than 3 elements (internally truncated to the number of dimensions)." << std::endl;
99 else if (open_parentheses < 5){
100 unsigned int row_length;
101 if (num_elements == 4){
104 std::cerr <<
"PRISMS-PF ERROR: User-defined constant tensor does not have enough elements, for 3D calculations matrices must be 3x3." << std::endl;
108 else if (num_elements == 9){
112 std::cerr <<
"PRISMS-PF ERROR: User-defined constant tensor does not have the correct number of elements, matrices must be 2x2 or 3x3." << std::endl;
116 dealii::Tensor<2,dim> temp;
117 for (
unsigned int i=0; i<dim; i++){
118 for (
unsigned int j=0; j<dim; j++){
119 temp[i][j] = dealii::Utilities::string_to_double(model_constants_strings.at(i*row_length+j));
122 model_constants.push_back(temp);
125 else if (boost::iequals(model_constants_type_strings.at(1),
"elastic") && boost::iequals(model_constants_type_strings.at(2),
"constants")){
126 unsigned int num_elements = model_constants_strings.size()-1;
129 unsigned int open_parentheses = 0;
130 unsigned int close_parentheses = 0;
131 for (
unsigned int element=0; element<num_elements; element++){
132 std::size_t index = 0;
133 while (index != std::string::npos){
134 index = model_constants_strings.at(element).find(
"(");
135 if (index != std::string::npos) {
136 model_constants_strings.at(element).erase(index,1);
141 while (index != std::string::npos){
142 index = model_constants_strings.at(element).find(
")");
143 if (index != std::string::npos) {
144 model_constants_strings.at(element).erase(index,1);
149 if (open_parentheses != close_parentheses){
150 std::cerr <<
"PRISMS-PF ERROR: User-defined elastic constant list does not have the same number of open and close parentheses." << std::endl;
155 std::vector<double> temp_elastic_constants;
156 for (
unsigned int i=0; i<num_elements; i++){
157 temp_elastic_constants.push_back(dealii::Utilities::string_to_double(model_constants_strings.at(i)));
160 std::string elastic_const_symmetry = model_constants_type_strings.at(0);
161 dealii::Tensor<2,2*dim-1+dim/3> temp = get_Cij_tensor(temp_elastic_constants,elastic_const_symmetry);
162 model_constants.push_back(temp);
165 std::cerr <<
"PRISMS-PF ERROR: Only user-defined constant tensors may have multiple elements." << std::endl;
180 if (elastic_const_symmetry ==
"isotropic"){
183 else if (elastic_const_symmetry ==
"transverse"){
186 else if (elastic_const_symmetry ==
"orthotropic"){
189 else if (elastic_const_symmetry ==
"anisotropic"){
194 std::cerr <<
"Elastic material model is invalid, please use isotropic, transverse, orthotropic, or anisotropic" << std::endl;
199 if ((mat_model ==
ANISOTROPIC) && (dim == 2) && elastic_constants.size() == 21) {
200 std::vector<double> elastic_constants_temp = elastic_constants;
201 elastic_constants.clear();
202 std::vector<unsigned int> indices_2D = {0, 1, 5, 6, 10, 14};
203 for (
unsigned int i=0; i<indices_2D.size(); i++){
204 elastic_constants.push_back(elastic_constants_temp.at(indices_2D.at(i)));
208 dealii::ConditionalOStream pcout(std::cout, dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD)==0);
211 return getCIJMatrix(mat_model, elastic_constants, pcout);
240 dealii::Tensor<2, 2*dim-1+dim/3> CIJ;
242 pcout <<
"Reading material model:";
249 pcout <<
" ISOTROPIC \n";
250 CIJ[0][0]=constants[0];
254 std::cout <<
"\nelasticityModels: Supported models in 1D - ISOTROPIC\n";
255 std::cout <<
"See /src/elasticityModels.h\n";
266 pcout <<
" ISOTROPIC \n";
267 double E=constants[0], nu=constants[1];
268 double mu=E/(2*(1+nu)), lambda= nu*E/((1+nu)*(1-2*nu));
269 CIJ[0][0]=lambda+2*mu;
270 CIJ[1][1]=lambda+2*mu;
272 CIJ[0][1]=CIJ[1][0]=lambda;
276 pcout <<
" ANISOTROPIC \n";
277 CIJ[0][0]=constants[0];
278 CIJ[1][1]=constants[1];
279 CIJ[2][2]=constants[2];
280 CIJ[0][1]=CIJ[1][0]=constants[3];
281 CIJ[0][2]=CIJ[2][0]=constants[4];
282 CIJ[1][2]=CIJ[2][1]=constants[5];
286 std::cout <<
"\nelasticityModels: Supported models in 2D - ISOTROPIC/ANISOTROPIC\n";
287 std::cout <<
"See /src/elasticityModels.h\n";
298 pcout <<
" ISOTROPIC \n";
299 double E=constants[0], nu=constants[1];
300 double mu=E/(2*(1+nu)), lambda= nu*E/((1+nu)*(1-2*nu));
301 CIJ[0][0]=lambda+2*mu;
302 CIJ[1][1]=lambda+2*mu;
303 CIJ[2][2]=lambda+2*mu;
307 CIJ[0][1]=CIJ[1][0]=lambda;
308 CIJ[0][2]=CIJ[2][0]=lambda;
309 CIJ[1][2]=CIJ[2][1]=lambda;
313 pcout <<
" TRANSVERSE \n";
314 CIJ[0][0]=constants[0];
315 CIJ[1][1]=constants[0];
316 CIJ[2][2]=constants[1];
317 CIJ[3][3]=constants[2];
318 CIJ[4][4]=constants[2];
319 CIJ[5][5]=(constants[0]-constants[3])/2.0;
320 CIJ[0][1]=CIJ[1][0]=constants[3];
321 CIJ[0][2]=CIJ[2][0]=constants[4];
322 CIJ[1][2]=CIJ[2][1]=constants[4];
326 pcout <<
" ORTHOTROPIC \n";
327 CIJ[0][0]=constants[0];
328 CIJ[1][1]=constants[1];
329 CIJ[2][2]=constants[2];
330 CIJ[3][3]=constants[3];
331 CIJ[4][4]=constants[4];
332 CIJ[5][5]=constants[5];
333 CIJ[0][1]=CIJ[1][0]=constants[6];
334 CIJ[0][2]=CIJ[2][0]=constants[7];
335 CIJ[1][2]=CIJ[2][1]=constants[8];
339 pcout <<
" ANISOTROPIC \n";
340 CIJ[0][0]=constants[0];
341 CIJ[1][1]=constants[1];
342 CIJ[2][2]=constants[2];
343 CIJ[3][3]=constants[3];
344 CIJ[4][4]=constants[4];
345 CIJ[5][5]=constants[5];
346 CIJ[0][1]=CIJ[1][0]=constants[6];
347 CIJ[0][2]=CIJ[2][0]=constants[7];
348 CIJ[0][3]=CIJ[3][0]=constants[8];
349 CIJ[0][4]=CIJ[4][0]=constants[9];
350 CIJ[0][5]=CIJ[5][0]=constants[10];
351 CIJ[1][2]=CIJ[2][1]=constants[11];
352 CIJ[1][3]=CIJ[3][1]=constants[12];
353 CIJ[1][4]=CIJ[4][1]=constants[13];
354 CIJ[1][5]=CIJ[5][1]=constants[14];
355 CIJ[2][3]=CIJ[3][2]=constants[15];
356 CIJ[2][4]=CIJ[4][2]=constants[16];
357 CIJ[2][5]=CIJ[5][2]=constants[17];
358 CIJ[3][4]=CIJ[4][3]=constants[18];
359 CIJ[3][5]=CIJ[5][3]=constants[19];
360 CIJ[4][5]=CIJ[5][4]=constants[20];
364 std::cout <<
"\nelasticityModels: Supported models in 3D - ISOTROPIC/TRANSVERSE/ORTHOTROPIC/ANISOTROPIC\n";
365 std::cout <<
"See /src/elasticityModels.h\n";
372 std::cout <<
"\nelasticityModels: DIM is not 1/2/3\n";
377 pcout <<
"Elasticity matrix (Voigt notation):\n";
379 for (
unsigned int i=0; i<2*dim-1+dim/3; i++){
380 for (
unsigned int j=0; j<2*dim-1+dim/3; j++){
381 sprintf(buffer,
"%8.3e ", CIJ[i][j]);
391 #include "../../include/userInputParameters_template_instantiations.h"