PRISMS-PF  v2.1
loadVariableAttributes.cc
Go to the documentation of this file.
1 #include "../../include/userInputParameters.h"
2 //#include "../../include/sortIndexEntryPairList.h"
3 #include "../../include/EquationDependencyParser.h"
4 
5 template <int dim>
7 
8  // Pull some variable values from variable_attributes
9  number_of_variables = variable_attributes.number_of_variables;
10  var_name = variable_attributes.var_name;
11  var_type = variable_attributes.var_type;
12  var_eq_type = variable_attributes.var_eq_type;
13 
14  var_nonlinear = variable_attributes.var_nonlinear;
15 
16  pp_calc_integral = variable_attributes.pp_calc_integral;
17 
18  pp_number_of_variables = variable_attributes.pp_number_of_variables;
19  pp_var_name = variable_attributes.pp_var_name;
20  pp_var_type = variable_attributes.pp_var_type;
21 
22  // Load some nucleation parameters
23  for (unsigned int i=0; i<number_of_variables; i++){
24  if (variable_attributes.nucleating_variable.at(i)==true){
25  nucleating_variable_indices.push_back(i);
26  }
27  if (variable_attributes.need_value_nucleation.at(i) || variable_attributes.nucleating_variable.at(i)){
28  nucleation_need_value.push_back(i);
29  }
30  }
31 
32  if (nucleating_variable_indices.size() > 0){
33  nucleation_occurs = true;
34  }
35  else {
36  nucleation_occurs = false;
37  }
38 
39 
40  // Load these attributes into the varInfoList objects
41 
42  // Load variable information for calculating the RHS for explicit equations
43  num_var_explicit_RHS = 0;
44  for (unsigned int i=0; i<number_of_variables; i++){
46  num_var_explicit_RHS++;
47  }
48  }
49  varInfoListExplicitRHS.reserve(num_var_explicit_RHS);
50  unsigned int scalar_var_index = 0;
51  unsigned int vector_var_index = 0;
52  for (unsigned int i=0; i<number_of_variables; i++){
53  variable_info varInfo;
54 
55  varInfo.need_value = variable_attributes.equation_dependency_parser.need_value_explicit_RHS[i];
57  varInfo.need_hessian = variable_attributes.equation_dependency_parser.need_hessian_explicit_RHS[i];
60 
61  varInfo.global_var_index = i;
62 
63  if (varInfo.need_value or varInfo.need_gradient or varInfo.need_hessian){
64  varInfo.var_needed = true;
65  }
66  else {
67  varInfo.var_needed = false;
68  }
69 
70  if (var_type[i] == SCALAR){
71  varInfo.is_scalar = true;
72  if (varInfo.var_needed){
73  varInfo.scalar_or_vector_index = scalar_var_index;
74  scalar_var_index++;
75  }
76  }
77  else {
78  varInfo.is_scalar = false;
79  if (varInfo.var_needed){
80  varInfo.scalar_or_vector_index = vector_var_index;
81  vector_var_index++;
82  }
83  }
84 
85  varInfoListExplicitRHS.push_back(varInfo);
86  }
87 
88  // Load variable information for calculating the RHS for nonexplicit equations
89  num_var_nonexplicit_RHS = 0;
90  for (unsigned int i=0; i<number_of_variables; i++){
92  num_var_nonexplicit_RHS++;
93  }
94  }
95  varInfoListNonexplicitRHS.reserve(num_var_nonexplicit_RHS);
96  scalar_var_index = 0;
97  vector_var_index = 0;
98  for (unsigned int i=0; i<number_of_variables; i++){
99  variable_info varInfo;
100 
101  varInfo.need_value = variable_attributes.equation_dependency_parser.need_value_nonexplicit_RHS[i];
106 
107  varInfo.global_var_index = i;
108 
109  if (varInfo.need_value or varInfo.need_gradient or varInfo.need_hessian){
110  varInfo.var_needed = true;
111  }
112  else {
113  varInfo.var_needed = false;
114  }
115 
116  if (var_type[i] == SCALAR){
117  varInfo.is_scalar = true;
118  if (varInfo.var_needed){
119  varInfo.scalar_or_vector_index = scalar_var_index;
120  scalar_var_index++;
121  }
122  }
123  else {
124  varInfo.is_scalar = false;
125  if (varInfo.var_needed){
126  varInfo.scalar_or_vector_index = vector_var_index;
127  vector_var_index++;
128  }
129  }
130 
131  varInfoListNonexplicitRHS.push_back(varInfo);
132  }
133 
134  // Load variable information for calculating the LHS
135  num_var_LHS = 0;
136  for (unsigned int i=0; i<number_of_variables; i++){
138  num_var_LHS++;
139  }
140  }
141 
142  varInfoListLHS.reserve(num_var_LHS);
143  scalar_var_index = 0;
144  vector_var_index = 0;
145  for (unsigned int i=0; i<number_of_variables; i++){
146  variable_info varInfo;
147 
148  varInfo.need_value = variable_attributes.equation_dependency_parser.need_value_nonexplicit_LHS[i];
153 
154  varInfo.global_var_index = i;
155 
156 
157  if (varInfo.need_value or varInfo.need_gradient or varInfo.need_hessian){
158  varInfo.var_needed = true;
159  }
160  else {
161  varInfo.var_needed = false;
162  }
163 
164  if (var_type[i] == SCALAR){
165  varInfo.is_scalar = true;
166  if (varInfo.var_needed){
167  varInfo.scalar_or_vector_index = scalar_var_index;
168  scalar_var_index++;
169  }
170  }
171  else {
172  varInfo.is_scalar = false;
173  if (varInfo.var_needed){
174  varInfo.scalar_or_vector_index = vector_var_index;
175  vector_var_index++;
176  }
177  }
178 
179  varInfoListLHS.push_back(varInfo);
180  }
181 
182  varChangeInfoListLHS.reserve(num_var_LHS);
183  scalar_var_index = 0;
184  vector_var_index = 0;
185  for (unsigned int i=0; i<number_of_variables; i++){
186  variable_info varInfo;
187 
191 
192  // FOR NOW, TAKING THESE FROM THE VARIABLE ITSELF!!
195 
196  varInfo.global_var_index = i;
197 
198  if (varInfo.need_value or varInfo.need_gradient or varInfo.need_hessian){
199  varInfo.var_needed = true;
200  }
201  else {
202  varInfo.var_needed = false;
203  }
204 
205  if (var_type[i] == SCALAR){
206  varInfo.is_scalar = true;
207  if (varInfo.var_needed){
208  varInfo.scalar_or_vector_index = scalar_var_index;
209  scalar_var_index++;
210  }
211  }
212  else {
213  varInfo.is_scalar = false;
214  if (varInfo.var_needed){
215  varInfo.scalar_or_vector_index = vector_var_index;
216  vector_var_index++;
217  }
218  }
219 
220  varChangeInfoListLHS.push_back(varInfo);
221  }
222 
223  // Load variable information for postprocessing
224  // First, the info list for the base field variables
225  pp_baseVarInfoList.reserve(number_of_variables);
226  scalar_var_index = 0;
227  vector_var_index = 0;
228  for (unsigned int i=0; i<number_of_variables; i++){
229  variable_info varInfo;
230 
231  varInfo.need_value = variable_attributes.equation_dependency_parser.pp_need_value[i];
232  varInfo.need_gradient = variable_attributes.equation_dependency_parser.pp_need_gradient[i];
233  varInfo.need_hessian = variable_attributes.equation_dependency_parser.pp_need_hessian[i];
234 
235  varInfo.global_var_index = i;
236 
237  if (variable_attributes.equation_dependency_parser.pp_need_value[i] or variable_attributes.equation_dependency_parser.pp_need_gradient[i] or variable_attributes.equation_dependency_parser.pp_need_hessian[i]){
238  varInfo.var_needed = true;
239  }
240  else {
241  varInfo.var_needed = false;
242  }
243 
244  if (var_type[i] == SCALAR){
245  varInfo.is_scalar = true;
246  if (varInfo.var_needed){
247  varInfo.scalar_or_vector_index = scalar_var_index;
248  scalar_var_index++;
249  }
250  }
251  else {
252  varInfo.is_scalar = false;
253  if (varInfo.var_needed){
254  varInfo.scalar_or_vector_index = vector_var_index;
255  vector_var_index++;
256  }
257  }
258 
259  pp_baseVarInfoList.push_back(varInfo);
260  }
261 
262  // Now load the information for the post-processing variables
263  // Parameters for postprocessing
264  if (pp_number_of_variables > 0){
265  postProcessingRequired = true;
266  }
267  else {
268  postProcessingRequired = false;
269  }
270 
271  num_integrated_fields = 0;
272  for (unsigned int i=0; i<pp_number_of_variables; i++){
273  if (pp_calc_integral[i]){
274  num_integrated_fields++;
275  integrated_field_indices.push_back(i);
276  }
277  }
278 
279  // The info list for the postprocessing field variables
280  pp_varInfoList.reserve(pp_number_of_variables);
281  scalar_var_index = 0;
282  vector_var_index = 0;
283  for (unsigned int i=0; i<pp_number_of_variables; i++){
284  variable_info varInfo;
285  varInfo.var_needed = true;
286 
287  varInfo.value_residual = variable_attributes.equation_dependency_parser.pp_need_value_residual[i];
289 
290  varInfo.global_var_index = i;
291  if (pp_var_type[i] == SCALAR){
292  varInfo.is_scalar = true;
293  varInfo.scalar_or_vector_index = scalar_var_index;
294  scalar_var_index++;
295  }
296  else {
297  varInfo.is_scalar = false;
298  varInfo.scalar_or_vector_index = vector_var_index;
299  vector_var_index++;
300  }
301  pp_varInfoList.push_back(varInfo);
302  }
303 
304 }
305 
306 // Template instantiations
307 #include "../../include/userInputParameters_template_instantiations.h"
std::vector< std::string > var_name
std::vector< bool > pp_calc_integral
std::vector< bool > need_value_explicit_RHS
std::vector< bool > pp_need_gradient_residual
std::vector< bool > need_hessian_nonexplicit_RHS
std::vector< bool > need_value_nonexplicit_LHS
unsigned int scalar_or_vector_index
std::vector< PDEType > var_eq_type
std::vector< bool > need_value_change_nonexplicit_LHS
std::vector< bool > need_value_residual_explicit_RHS
std::vector< bool > pp_need_hessian
std::vector< bool > need_gradient_nonexplicit_RHS
std::vector< bool > var_nonlinear
std::vector< bool > need_hessian_nonexplicit_LHS
EquationDependencyParser equation_dependency_parser
std::vector< bool > need_hessian_change_nonexplicit_LHS
void loadVariableAttributes(variableAttributeLoader variable_attributes)
std::vector< bool > need_gradient_nonexplicit_LHS
std::vector< bool > need_gradient_change_nonexplicit_LHS
std::vector< bool > need_value_nonexplicit_RHS
std::vector< bool > need_value_residual_nonexplicit_LHS
std::vector< bool > need_hessian_explicit_RHS
std::vector< bool > pp_need_value_residual
std::vector< std::string > pp_var_name
std::vector< fieldType > pp_var_type
std::vector< bool > nucleating_variable
std::vector< bool > pp_need_gradient
std::vector< bool > need_value_residual_nonexplicit_RHS
std::vector< bool > need_value_nucleation
unsigned int global_var_index
std::vector< bool > need_gradient_explicit_RHS
std::vector< bool > need_gradient_residual_nonexplicit_LHS
std::vector< bool > need_gradient_residual_nonexplicit_RHS
std::vector< bool > need_gradient_residual_explicit_RHS
std::vector< fieldType > var_type