2 #include "../../include/inputFileReader.h" 3 #include "../../include/sortIndexEntryPairList.h" 4 #include "../../include/EquationDependencyParser.h" 5 #include <deal.II/base/mpi.h> 6 #include <deal.II/base/utilities.h> 12 unsigned int number_of_variables = variable_attributes.
var_name_list.size();
27 if (dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0){
28 std::cout <<
"Number of constants: " <<
num_constants << std::endl;
29 std::cout <<
"Number of post-processing variables: " <<
num_pp_vars << std::endl;
34 #if (DEAL_II_VERSION_MAJOR < 9 && DEAL_II_VERSION_MINOR < 5) 45 std::string & out_string,
const bool expect_equals_sign)
const 49 while ((line.size() > 0) && (line[0] ==
' ' || line[0] ==
'\t'))
51 while ((line.size() > 0)
52 && (line[line.size() - 1] ==
' ' || line[line.size() - 1] ==
'\t'))
53 line.erase(line.size() - 1, std::string::npos);
57 if (line.size() < keyword.size())
60 for (
unsigned int i=0; i<keyword.size(); i++){
61 if (line[i] != keyword[i])
64 if (entry_name.size() > 0){
65 if (!(line[keyword.size()] ==
' ' || line[keyword.size()] ==
'\t'))
70 line.erase(0, keyword.size());
71 while ((line.size() > 0) && (line[0] ==
' ' || line[0] ==
'\t'))
74 if (line.find(entry_name) != 0)
77 line.erase(0, entry_name.size());
78 while ((line.size() > 0) && (line[0] ==
' ' || line[0] ==
'\t'))
82 if (expect_equals_sign){
83 if ((line.size() < 1) || (line[0] !=
'='))
88 std::string::size_type pos = line.find(
'#');
89 if (pos != std::string::npos)
94 if (expect_equals_sign)
97 while ((line.size() > 0) && (line[0] ==
' ' || line[0] ==
'\t'))
100 while ((line.size() > 0) && (line[line.size()-1] ==
' ' || line[line.size()-1] ==
'\t'))
101 line.erase(line.size()-1, std::string::npos);
109 const std::string subsec_name,
const std::string entry_name,
const std::string default_entry)
const 112 std::ifstream input_file;
113 input_file.open(parameters_file_name);
115 std::string line, entry;
116 bool in_subsection =
false;
117 bool found_entry, desired_entry_found;
118 unsigned int subsection_index;
119 std::vector<std::string> entry_list;
120 std::vector<unsigned int> index_list;
123 while (std::getline(input_file, line))
127 found_entry =
parse_line(line,
"subsection",subsec_name, entry,
false);
129 in_subsection =
true;
130 subsection_index = dealii::Utilities::string_to_int(entry);
131 desired_entry_found =
false;
136 found_entry =
parse_line(line,
"set", entry_name, entry,
true);
138 entry_list.push_back(entry);
139 index_list.push_back(subsection_index);
140 desired_entry_found =
true;
142 found_entry =
parse_line(line,
"end",
"", entry,
false);
144 if (!desired_entry_found){
145 entry_list.push_back(default_entry);
146 index_list.push_back(subsection_index);
148 in_subsection =
false;
149 desired_entry_found =
false;
155 std::vector<std::string> sorted_entry_list;
156 for (
unsigned int i=0; i<entry_list.size(); i++){
157 for (
unsigned int j=0; j<entry_list.size(); j++){
159 sorted_entry_list.push_back(entry_list[index_list[j]]);
164 return sorted_entry_list;
169 const std::string keyword,
const std::string entry_name)
const 172 std::ifstream input_file;
173 input_file.open(parameters_file_name);
175 std::string line, entry;
178 unsigned int count = 0;
181 while (std::getline(input_file, line))
184 found_entry =
parse_line(line, keyword, entry_name, entry,
false);
193 const std::string keyword,
const std::string entry_name_begining)
const 196 std::ifstream input_file;
197 input_file.open(parameters_file_name);
199 std::string line, entry;
202 std::vector<std::string> entry_name_end_list;
205 while (std::getline(input_file, line))
208 found_entry =
parse_line(line, keyword, entry_name_begining, entry,
false);
214 while ((entry.size() > 0) && (entry[0] ==
' ' || entry[0] ==
'\t'))
218 while ((entry.size() > 0) && (entry[entry.size() - 1] !=
'=' ))
219 entry.erase(entry.size() - 1, std::string::npos);
222 entry.erase(entry.size() - 1, std::string::npos);
225 while ((entry.size() > 0) && (entry[entry.size() - 1] ==
' ' || entry[entry.size() - 1] ==
'\t'))
226 entry.erase(entry.size() - 1, std::string::npos);
229 entry_name_end_list.push_back(entry);
233 return entry_name_end_list;
237 const std::vector<fieldType> var_types,
238 const std::vector<PDEType> var_eq_types,
239 const unsigned int num_of_constants,
240 const std::vector<bool> var_nucleates)
const {
243 parameter_handler.declare_entry(
"Number of dimensions",
"-1",dealii::Patterns::Integer(),
"The number of dimensions for the simulation.");
245 parameter_handler.declare_entry(
"Domain size X",
"-1",dealii::Patterns::Double(),
"The size of the domain in the x direction.");
246 parameter_handler.declare_entry(
"Domain size Y",
"-1",dealii::Patterns::Double(),
"The size of the domain in the y direction.");
247 parameter_handler.declare_entry(
"Domain size Z",
"-1",dealii::Patterns::Double(),
"The size of the domain in the z direction.");
248 parameter_handler.declare_entry(
"Element degree",
"1",dealii::Patterns::Integer(),
"The polynomial order of the finte element.");
249 parameter_handler.declare_entry(
"Subdivisions X",
"1",dealii::Patterns::Integer(),
"The number of mesh subdivisions in the x direction.");
250 parameter_handler.declare_entry(
"Subdivisions Y",
"1",dealii::Patterns::Integer(),
"The number of mesh subdivisions in the y direction.");
251 parameter_handler.declare_entry(
"Subdivisions Z",
"1",dealii::Patterns::Integer(),
"The number of mesh subdivisions in the z direction.");
252 parameter_handler.declare_entry(
"Refine factor",
"-1",dealii::Patterns::Integer(),
"The number of initial refinements of the coarse mesh.");
254 parameter_handler.declare_entry(
"Mesh adaptivity",
"false",dealii::Patterns::Bool(),
"Whether to enable mesh adaptivity.");
255 parameter_handler.declare_entry(
"Max refinement level",
"-1",dealii::Patterns::Integer(),
"The maximum level of refinement.");
256 parameter_handler.declare_entry(
"Min refinement level",
"-1",dealii::Patterns::Integer(),
"The minimum level of refinement.");
257 parameter_handler.declare_entry(
"Refinement criteria fields",
"0",dealii::Patterns::List(dealii::Patterns::Anything()),
"The list of fields used to determine mesh refinement.");
258 parameter_handler.declare_entry(
"Refinement window max",
"",dealii::Patterns::List(dealii::Patterns::Anything()),
"The upper limit for refinement for each of the criteria fields.");
259 parameter_handler.declare_entry(
"Refinement window min",
"",dealii::Patterns::List(dealii::Patterns::Anything()),
"The lower limit for refinement for each of the criteria fields.");
260 parameter_handler.declare_entry(
"Steps between remeshing operations",
"1",dealii::Patterns::Integer(),
"The number of time steps between mesh refinement operations.");
262 parameter_handler.declare_entry(
"Number of time steps",
"-1",dealii::Patterns::Integer(),
"The time step size for the simulation.");
263 parameter_handler.declare_entry(
"Time step",
"-0.1",dealii::Patterns::Double(),
"The time step size for the simulation.");
264 parameter_handler.declare_entry(
"Simulation end time",
"-0.1",dealii::Patterns::Double(),
"The value of simulated time where the simulation ends.");
266 for (
unsigned int i=0; i<
var_types.size(); i++){
268 std::string subsection_text =
"Linear solver parameters: ";
272 parameter_handler.declare_entry(
"Tolerance type",
"RELATIVE_RESIDUAL_CHANGE",dealii::Patterns::Anything(),
"The tolerance type for the linear solver.");
273 parameter_handler.declare_entry(
"Tolerance value",
"1.0e-10",dealii::Patterns::Double(),
"The value of for the linear solver tolerance.");
274 parameter_handler.declare_entry(
"Maximum linear solver iterations",
"1000",dealii::Patterns::Integer(),
"The maximum number of linear solver iterations before the loop is stopped.");
281 parameter_handler.declare_entry(
"Maximum nonlinear solver iterations",
"100",dealii::Patterns::Integer(),
"The maximum number of nonlinear solver iterations before the loop is stopped.");
283 for (
unsigned int i=0; i<
var_types.size(); i++){
285 std::string subsection_text =
"Nonlinear solver parameters: ";
289 parameter_handler.declare_entry(
"Tolerance type",
"ABSOLUTE_SOLUTION_CHANGE",dealii::Patterns::Anything(),
"The tolerance type for the nonlinear solver.");
290 parameter_handler.declare_entry(
"Tolerance value",
"1.0e-10",dealii::Patterns::Double(),
"The value of for the nonlinear solver tolerance.");
291 parameter_handler.declare_entry(
"Use backtracking line search damping",
"true",dealii::Patterns::Bool(),
"Whether to use a backtracking line-search to find the best choice of the damping coefficient.");
292 parameter_handler.declare_entry(
"Backtracking step size modifier",
"0.5",dealii::Patterns::Double(),
"The constant that determines how much the step size decreases per backtrack. The 'tau' parameter.");
293 parameter_handler.declare_entry(
"Backtracking residual decrease coefficient",
"1.0",dealii::Patterns::Double(),
"The constant that determines how much the residual must decrease to be accepted as sufficient. The 'c' parameter.");
294 parameter_handler.declare_entry(
"Constant damping value",
"1.0",dealii::Patterns::Double(),
"The constant damping value to be used if the backtrace line-search approach isn't used.");
295 parameter_handler.declare_entry(
"Use Laplace's equation to determine the initial guess",
"false",dealii::Patterns::Bool(),
"Whether to use the solution of Laplace's equation instead of the IC in ICs_and_BCs.h as the initial guess for nonlinear, time independent equations. This guarantees smoothness and compliance with BCs.");
301 parameter_handler.declare_entry(
"Output file name (base)",
"solution",dealii::Patterns::Anything(),
"The name for the output file, before the time step and processor info are added.");
302 parameter_handler.declare_entry(
"Output file type",
"vtu",dealii::Patterns::Anything(),
"The output file type (either vtu or vtk).");
303 parameter_handler.declare_entry(
"Output separate files per process",
"false",dealii::Patterns::Bool(),
"Whether to output separate vtu files for each process in a parallel calculation (automatically set to true for vtk files).");
304 parameter_handler.declare_entry(
"Output condition",
"EQUAL_SPACING",dealii::Patterns::Anything(),
"The spacing type for outputing the solution fields.");
305 parameter_handler.declare_entry(
"List of time steps to output",
"0",dealii::Patterns::Anything(),
"The list of time steps to output, used for the LIST type.");
306 parameter_handler.declare_entry(
"Number of outputs",
"10",dealii::Patterns::Integer(),
"The number of outputs (or number of outputs per decade for the N_PER_DECADE type).");
307 parameter_handler.declare_entry(
"Skip print steps",
"1",dealii::Patterns::Integer(),
"The number of time steps between updates to the screen.");
310 parameter_handler.declare_entry(
"Load initial conditions",
"void",dealii::Patterns::Anything(),
"Whether to load the initial conditions for each variable from file.");
311 parameter_handler.declare_entry(
"Load parallel file",
"void",dealii::Patterns::Anything(),
"Whether all processors should read from a single file (versus each reading from separate files).");
312 parameter_handler.declare_entry(
"File names",
"void",dealii::Patterns::Anything(),
"The file name to load from for each variable.");
313 parameter_handler.declare_entry(
"Variable names in the files",
"void",dealii::Patterns::Anything(),
"What each variable is named in the file being loaded.");
316 parameter_handler.declare_entry(
"Load from a checkpoint",
"false",dealii::Patterns::Bool(),
"Whether to load from a checkpoint created during a previous simulation.");
317 parameter_handler.declare_entry(
"Checkpoint condition",
"EQUAL_SPACING",dealii::Patterns::Anything(),
"The spacing type for saving checkpoints.");
318 parameter_handler.declare_entry(
"List of time steps to save checkpoints",
"0",dealii::Patterns::Anything(),
"The list of time steps to save checkpoints, used for the LIST type.");
319 parameter_handler.declare_entry(
"Number of checkpoints",
"1",dealii::Patterns::Integer(),
"The number of checkpoints (or number of checkpoints per decade for the N_PER_DECADE type).");
323 for (
unsigned int i=0; i<
var_types.size(); i++){
325 std::string bc_text =
"Boundary condition for variable ";
327 parameter_handler.declare_entry(bc_text,
"",dealii::Patterns::Anything(),
"The boundary conditions for one of the governing equations).");
330 std::string bc_text =
"Boundary condition for variable ";
332 bc_text.append(
", x component");
333 parameter_handler.declare_entry(bc_text,
"",dealii::Patterns::Anything(),
"The boundary conditions for one of the governing equations).");
335 bc_text =
"Boundary condition for variable ";
337 bc_text.append(
", y component");
338 parameter_handler.declare_entry(bc_text,
"",dealii::Patterns::Anything(),
"The boundary conditions for one of the governing equations).");
340 bc_text =
"Boundary condition for variable ";
342 bc_text.append(
", z component");
343 parameter_handler.declare_entry(bc_text,
"",dealii::Patterns::Anything(),
"The boundary conditions for one of the governing equations).");
349 parameter_handler.declare_entry(
"Minimum allowed distance between nuclei",
"-1",dealii::Patterns::Double(),
"The minimum allowed distance between nuclei placed during the same time step.");
350 parameter_handler.declare_entry(
"Order parameter cutoff value",
"0.01",dealii::Patterns::Double(),
"Order parameter cutoff value for nucleation (when the sum of all order parameters is above this value, no nucleation is attempted).");
351 parameter_handler.declare_entry(
"Time steps between nucleation attempts",
"100",dealii::Patterns::Integer(),
"The number of time steps between nucleation attempts.");
353 for (
unsigned int i=0; i<
var_types.size(); i++){
355 std::string nucleation_text =
"Nucleation parameters: ";
359 parameter_handler.declare_entry(
"Nucleus semiaxes (x, y, z)",
"0,0,0",dealii::Patterns::List(dealii::Patterns::Double()),
"The semiaxes for nuclei placed with the explicit nucleation algorithm.");
360 parameter_handler.declare_entry(
"Nucleus rotation in degrees (x, y, z)",
"0,0,0",dealii::Patterns::List(dealii::Patterns::Double()),
"The rotation of the nuclei placed with the explicit nucleation algorithm. The rotations are given with respect to the normal direction using intrinsic Tait-Bryan angles.");
361 parameter_handler.declare_entry(
"Freeze zone semiaxes (x, y, z)",
"0,0,0",dealii::Patterns::List(dealii::Patterns::Double()),
"The semiaxes for region where the order parameter is frozen for a period of time after placement.");
362 parameter_handler.declare_entry(
"Freeze time following nucleation",
"0.0",dealii::Patterns::Double(),
"Duration that the order parameter is frozen after placement.");
363 parameter_handler.declare_entry(
"Nucleation-free border thickness",
"0.0",dealii::Patterns::Double(),
"The thickness of the nucleation-free region near the domain boundaries (ignored for periodic BCs).");
370 parameter_handler.declare_entry(
"Activate grain reassignment",
"false",dealii::Patterns::Bool(),
"Whether to enable the grain reassignment capabilities of PRISMS-PF where multiple grains are packed into a single order parameter.");
372 parameter_handler.declare_entry(
"Time steps between grain reassignments",
"100",dealii::Patterns::Integer(),
"The number of time steps between times when the grain reassignment algorithm is triggered.");
374 parameter_handler.declare_entry(
"Order parameter cutoff for grain identification",
"1.0e-4",dealii::Patterns::Double(),
"The threshold value of the order parameter where the element is considered to be in the grain or out of the grain.");
376 parameter_handler.declare_entry(
"Buffer between grains before reassignment",
"-1.0",dealii::Patterns::Double(),
"The buffer value added to the radius of all grains used to calculation whether grains should be reassigned.");
378 parameter_handler.declare_entry(
"Order parameter fields for grain reassignment",
"",dealii::Patterns::List(dealii::Patterns::Anything()),
"The list of field indices for the shared order parameters for grain reassignment.");
380 parameter_handler.declare_entry(
"Load grain structure",
"false",dealii::Patterns::Bool(),
"Whether to load a grain structure in from file.");
382 parameter_handler.declare_entry(
"Grain structure filename",
"",dealii::Patterns::Anything(),
"The filename (not including the '.vtk' extension) for the file holding the grain structure to be loaded.");
384 parameter_handler.declare_entry(
"Grain structure variable name",
"",dealii::Patterns::Anything(),
"The variable name in the file holding the grain structure to be loaded that contains the grain ids.");
386 parameter_handler.declare_entry(
"Number of smoothing cycles after grain structure loading",
"10",dealii::Patterns::Integer(),
"The number of times a diffusion smoother is run on the order parameters after the grains are loaded from file. The smoothing is necessary for the adaptive mesher to work properly.");
388 parameter_handler.declare_entry(
"Minimum radius for loaded grains",
"0.0",dealii::Patterns::Double(),
"The minimum radius for a body to be considered a grain instead of an artifact from the loading process.");
392 for (
unsigned int i=0; i<num_of_constants; i++){
393 std::string constants_text =
"Model constant ";
395 parameter_handler.declare_entry(constants_text,
"0",dealii::Patterns::Anything(),
"The value of a user-defined constant.");
std::vector< std::string > var_name
std::vector< std::pair< unsigned int, bool > > nucleating_variable_list
std::vector< std::pair< unsigned int, std::string > > var_name_list
std::vector< PDEType > var_eq_type
std::vector< bool > var_nonlinear
std::vector< bool > sortIndexEntryPairList(const std::vector< std::pair< unsigned int, bool > > unsorted_pair_list, unsigned int number_of_variables, bool default_value)
std::vector< fieldType > var_type
std::vector< std::pair< unsigned int, std::string > > var_name_list_PP