PRISMS-PF  v2.1
load_BC_list.cc
Go to the documentation of this file.
1 #include "../../include/userInputParameters.h"
2 
3 // ==========================================================================================
4 // Method to extract the list of boundary conditions
5 // ==========================================================================================
6 template <int dim>
7 void userInputParameters<dim>::load_BC_list(std::vector<std::string> list_of_BCs){
8  // Load the BC information from the strings into a varBCs object
9  // Move this to a new method and write a unit test for it!!!!
10 
11  std::vector<std::string> temp;
12 
13  for (unsigned int i=0; i<list_of_BCs.size(); i++){
14  varBCs<dim> newBC;
15  temp = dealii::Utilities::split_string_list(list_of_BCs[i]);
16 
17  // If there is only one BC listed, make another dim*2-1 copies of it so that the same BC is applied for all boundaries
18  if (temp.size() == 1){
19  for (unsigned int boundary=0; boundary<(dim*2-1); boundary++){
20  temp.push_back(temp[0]);
21  }
22  }
23 
24  // Load the BC for each boundary into 'newBC'
25  for (unsigned int i=0; i<(2*dim); i++){
26  if (boost::iequals(temp[i],"NATURAL")){
27  newBC.var_BC_type.push_back(NATURAL);
28  newBC.var_BC_val.push_back(0.0);
29  }
30  else if (boost::iequals(temp[i],"PERIODIC")){
31  newBC.var_BC_type.push_back(PERIODIC);
32  newBC.var_BC_val.push_back(0.0);
33  }
34  else if (boost::iequals(temp[i],"NON_UNIFORM_DIRICHLET")){
35  newBC.var_BC_type.push_back(NON_UNIFORM_DIRICHLET);
36  newBC.var_BC_val.push_back(0.0);
37  }
38  else if (boost::iequals(temp[i].substr(0,9),"DIRICHLET")){
39  newBC.var_BC_type.push_back(DIRICHLET);
40  std::string dirichlet_val = temp[i].substr(10,temp[i].size());
41  dirichlet_val = dealii::Utilities::trim(dirichlet_val);
42  newBC.var_BC_val.push_back(dealii::Utilities::string_to_double(dirichlet_val));
43  }
44  else if (boost::iequals(temp[i].substr(0,7),"NEUMANN")){
45  newBC.var_BC_type.push_back(NEUMANN);
46  std::string neumann_val = temp[i].substr(8,temp[i].size());
47  neumann_val = dealii::Utilities::trim(neumann_val);
48  newBC.var_BC_val.push_back(dealii::Utilities::string_to_double(neumann_val));
49  }
50  else {
51  std::cout << temp[i].substr(0,8) << std::endl;
52  std::cout << "Error: Boundary conditions specified improperly." << std::endl;
53  abort();
54  }
55  }
56  BC_list.push_back(newBC);
57 
58  // Validate input using something like this:
59  // try{
60  // if ((BC_type_dim1_min == "PERIODIC") && (BC_type_dim1_max != "PERIODIC")){
61  // throw 0;
62  // }
63  // if ((BC_type_dim2_min == "PERIODIC") && (BC_type_dim2_max != "PERIODIC")){
64  // throw 0;
65  // }
66  // if ((BC_type_dim3_min == "PERIODIC") && (BC_type_dim3_max != "PERIODIC")){
67  // throw 0;
68  // }
69  // }
70  // catch (int e){
71  // if (e == 0){
72  // std::cout << "Error: For periodic BCs, both faces for a given direction must be set as periodic. "
73  // "Please check the BCs that are set in ICs_and_BCs.h." << std::endl;
74  // }
75  // abort();
76  // }
77  }
78 
79 }
80 
81 // Template instantiations
82 #include "../../include/userInputParameters_template_instantiations.h"
Definition: varBCs.h:12
Definition: varBCs.h:16
std::vector< double > var_BC_val
Definition: varBCs.h:20
std::vector< BC_type > var_BC_type
Definition: varBCs.h:19
Definition: varBCs.h:12
void load_BC_list(const std::vector< std::string > list_of_BCs)
Definition: load_BC_list.cc:7