diff --git a/include/EquationDependencyParser.h b/include/EquationDependencyParser.h index 4a8dd1b03..cde6834a9 100644 --- a/include/EquationDependencyParser.h +++ b/include/EquationDependencyParser.h @@ -54,14 +54,14 @@ class EquationDependencyParser /* * Method to strip excess whitespace for the dependency lists */ - void + static void strip_dependency_whitespace(std::string &dependency_list); /** * Method to parse the RHS dependency strings and populate the vectors for * whether values, gradients, or hessians are needed. */ - void + static void parseDependencyListRHS( std::vector &variable_name_list, std::vector variable_eq_type, @@ -76,7 +76,7 @@ class EquationDependencyParser * Method to parse the LHS dependency strings and populate the vectors for * whether values, gradients, or hessians are needed. */ - void + static void parseDependencyListLHS( std::vector &variable_name_list, std::vector variable_eq_type, @@ -92,7 +92,7 @@ class EquationDependencyParser * Method to parse the postprocessing dependency strings and populate the * vectors for whether values, gradients, or hessians are needed. */ - void + static void parseDependencyListPP( std::vector &variable_name_list, unsigned int variable_index, diff --git a/include/SolverParameters.h b/include/SolverParameters.h index c63757fb8..52c6a8b73 100644 --- a/include/SolverParameters.h +++ b/include/SolverParameters.h @@ -95,8 +95,8 @@ class NonlinearSolverParameters : public SolverParametersBase * Method to get the maximum number of allowed iterations for the nonlinear * solver. */ - double - getMaxIterations(); + [[nodiscard]] double + getMaxIterations() const; /** * Method to load the parameters for one governing equation into the class. diff --git a/include/inputFileReader.h b/include/inputFileReader.h index 136c012e2..f37dc01ab 100644 --- a/include/inputFileReader.h +++ b/include/inputFileReader.h @@ -20,24 +20,24 @@ class inputFileReader // Method to get a list of entry values from multiple subsections in an input // file - [[nodiscard]] std::vector + [[nodiscard]] static std::vector get_subsection_entry_list(const std::string ¶meters_file_name, const std::string &subsec_name, const std::string &entry_name, - const std::string &default_entry) const; + const std::string &default_entry); // Method to count the number of related entries in an input file - [[nodiscard]] unsigned int + [[nodiscard]] static unsigned int get_number_of_entries(const std::string ¶meters_file_name, const std::string &keyword, - const std::string &entry_name) const; + const std::string &entry_name); // Get the trailing part of the entry name after a specified string (used to // extract the model constant names) - [[nodiscard]] std::vector + [[nodiscard]] static std::vector get_entry_name_ending_list(const std::string ¶meters_file_name, const std::string &keyword, - const std::string &entry_name_begining) const; + const std::string &entry_name_begining); // Method to declare the parameters to be read from an input file void @@ -48,12 +48,12 @@ class inputFileReader const std::vector &var_nucleates) const; // Method to check if a line has the desired contents and if so, extract it - bool + static bool parse_line(std::string line, const std::string &keyword, const std::string &entry_name, std::string &out_string, - bool expect_equals_sign) const; + bool expect_equals_sign); // Variables dealii::ParameterHandler parameter_handler; diff --git a/src/EquationDependencyParser/EquationDependencyParser.cc b/src/EquationDependencyParser/EquationDependencyParser.cc index ba199ba84..a6d6af7fa 100644 --- a/src/EquationDependencyParser/EquationDependencyParser.cc +++ b/src/EquationDependencyParser/EquationDependencyParser.cc @@ -22,7 +22,7 @@ EquationDependencyParser::parse(std::vector &var_name, std::vector &var_nonlinear) { // Determine the number of variables - size_t n_variables = var_name.size(); + const size_t n_variables = var_name.size(); // Resize the dependency evaluation flag vectors eval_flags_explicit_RHS.resize(n_variables, dealii::EvaluationFlags::nothing); @@ -47,7 +47,7 @@ EquationDependencyParser::parse(std::vector &var_name, // Now check for each variable_eq_type if (var_eq_type[i] == EXPLICIT_TIME_DEPENDENT) { - bool single_var_nonlinear; + bool single_var_nonlinear = false; parseDependencyListRHS(var_name, var_eq_type, @@ -62,7 +62,7 @@ EquationDependencyParser::parse(std::vector &var_name, } else if (var_eq_type[i] == AUXILIARY) { - bool single_var_nonlinear; + bool single_var_nonlinear = false; parseDependencyListRHS(var_name, var_eq_type, @@ -78,7 +78,8 @@ EquationDependencyParser::parse(std::vector &var_name, else if (var_eq_type[i] == IMPLICIT_TIME_DEPENDENT || var_eq_type[i] == TIME_INDEPENDENT) { - bool single_var_nonlinear_RHS, single_var_nonlinear_LHS; + bool single_var_nonlinear_RHS = false; + bool single_var_nonlinear_LHS = false; parseDependencyListRHS(var_name, var_eq_type, @@ -116,18 +117,18 @@ EquationDependencyParser::parseDependencyListRHS( bool &is_nonlinear) { // Split the dependency strings into lists of entries - std::vector split_value_dependency_list = + const std::vector split_value_dependency_list = dealii::Utilities::split_string_list(value_dependencies); std::vector split_gradient_dependency_list = dealii::Utilities::split_string_list(gradient_dependencies); // Check if either is empty and set value and gradient flags for the // residual appropriately - if (split_value_dependency_list.size() > 0) + if (!split_value_dependency_list.empty()) { residual_flags[variable_index] |= dealii::EvaluationFlags::values; } - if (split_gradient_dependency_list.size() > 0) + if (!split_gradient_dependency_list.empty()) { residual_flags[variable_index] |= dealii::EvaluationFlags::gradients; } @@ -166,15 +167,15 @@ EquationDependencyParser::parseDependencyListRHS( variable.end()); // Is the variable we are finding the dependencies for explicit - bool variable_is_explicit = + const bool variable_is_explicit = variable_eq_type[variable_index] == EXPLICIT_TIME_DEPENDENT; // Is the dependency variable explicit - bool dependency_variable_is_explicit = + const bool dependency_variable_is_explicit = variable_eq_type[dependency_variable_index] == EXPLICIT_TIME_DEPENDENT; // Is the dependency the variable - bool same_variable = variable_index == dependency_variable_index; + const bool same_variable = variable_index == dependency_variable_index; // Case if the dependency is x if (dependency == variable) @@ -225,18 +226,18 @@ EquationDependencyParser::parseDependencyListLHS( bool &is_nonlinear) { // Split the dependency strings into lists of entries - std::vector split_value_dependency_list = + const std::vector split_value_dependency_list = dealii::Utilities::split_string_list(value_dependencies); std::vector split_gradient_dependency_list = dealii::Utilities::split_string_list(gradient_dependencies); // Check if either is empty and set value and gradient flags for the // residual appropriately - if (split_value_dependency_list.size() > 0) + if (!split_value_dependency_list.empty()) { residual_flags[variable_index] |= dealii::EvaluationFlags::values; } - if (split_gradient_dependency_list.size() > 0) + if (!split_gradient_dependency_list.empty()) { residual_flags[variable_index] |= dealii::EvaluationFlags::gradients; } @@ -291,7 +292,7 @@ EquationDependencyParser::parseDependencyListLHS( variable.end()); // Is the variable we are finding the dependencies for explicit - bool dependency_variable_is_explicit = + const bool dependency_variable_is_explicit = variable_eq_type[dependency_variable_index] == EXPLICIT_TIME_DEPENDENT; // Case if the dependency is x @@ -380,8 +381,8 @@ EquationDependencyParser::pp_parse(std::vector &var_name, std::vector sorted_dependencies_gradient) { // Determine the number of variables - size_t n_variables = var_name.size(); - size_t n_postprocess_variables = pp_var_name.size(); + const size_t n_variables = var_name.size(); + const size_t n_postprocess_variables = pp_var_name.size(); // Resize the dependency evaluation flag vectors eval_flags_postprocess.resize(n_variables, dealii::EvaluationFlags::nothing); @@ -416,18 +417,18 @@ EquationDependencyParser::parseDependencyListPP( std::vector &residual_flags) { // Split the dependency strings into lists of entries - std::vector split_value_dependency_list = + const std::vector split_value_dependency_list = dealii::Utilities::split_string_list(value_dependencies); std::vector split_gradient_dependency_list = dealii::Utilities::split_string_list(gradient_dependencies); // Check if either is empty and set value and gradient flags for the // residual appropriately - if (split_value_dependency_list.size() > 0) + if (!split_value_dependency_list.empty()) { residual_flags[variable_index] |= dealii::EvaluationFlags::values; } - if (split_gradient_dependency_list.size() > 0) + if (!split_gradient_dependency_list.empty()) { residual_flags[variable_index] |= dealii::EvaluationFlags::gradients; } diff --git a/src/SolverParameters/SolverParameters.cc b/src/SolverParameters/SolverParameters.cc index f3579d6a3..f1c64c2cc 100644 --- a/src/SolverParameters/SolverParameters.cc +++ b/src/SolverParameters/SolverParameters.cc @@ -103,7 +103,7 @@ NonlinearSolverParameters::setMaxIterations(unsigned int _max_iterations) } double -NonlinearSolverParameters::getMaxIterations() +NonlinearSolverParameters::getMaxIterations() const { return max_iterations; } diff --git a/src/inputFileReader/inputFileReader.cc b/src/inputFileReader/inputFileReader.cc index 2e7cb3a66..bbd2de577 100644 --- a/src/inputFileReader/inputFileReader.cc +++ b/src/inputFileReader/inputFileReader.cc @@ -12,21 +12,19 @@ // Constructor inputFileReader::inputFileReader(const std::string &input_file_name, variableAttributeLoader &variable_attributes) + : var_types(variable_attributes.var_type) + , var_eq_types(variable_attributes.var_eq_type) + , num_pp_vars(variable_attributes.var_name_list_PP.size()) + , var_names(variable_attributes.var_name) + , var_nonlinear(variable_attributes.var_nonlinear) { // Extract an ordered vector of the variable types from variable_attributes - unsigned int number_of_variables = variable_attributes.var_name_list.size(); - var_types = variable_attributes.var_type; - var_eq_types = variable_attributes.var_eq_type; - var_names = variable_attributes.var_name; - - var_nonlinear = variable_attributes.var_nonlinear; + const unsigned int number_of_variables = variable_attributes.var_name_list.size(); var_nucleates = sortIndexEntryPairList(variable_attributes.nucleating_variable_list, number_of_variables, false); - num_pp_vars = variable_attributes.var_name_list_PP.size(); - num_constants = get_number_of_entries(input_file_name, "set", "Model constant"); model_constant_names = @@ -58,14 +56,14 @@ inputFileReader::parse_line(std::string line, const std::string &keyword, const std::string &entry_name, std::string &out_string, - const bool expect_equals_sign) const + const bool expect_equals_sign) { // Strip spaces at the front and back - while ((line.size() > 0) && (line[0] == ' ' || line[0] == '\t')) + while ((!line.empty()) && (line[0] == ' ' || line[0] == '\t')) { line.erase(0, 1); } - while ((line.size() > 0) && + while ((!line.empty()) && (line[line.size() - 1] == ' ' || line[line.size() - 1] == '\t')) { line.erase(line.size() - 1, std::string::npos); @@ -86,9 +84,9 @@ inputFileReader::parse_line(std::string line, return false; } } - if (entry_name.size() > 0) + if (!entry_name.empty()) { - if (!(line[keyword.size()] == ' ' || line[keyword.size()] == '\t')) + if (line[keyword.size()] != ' ' && line[keyword.size()] != '\t') { return false; } @@ -96,7 +94,7 @@ inputFileReader::parse_line(std::string line, // delete the "keyword" and then delete more spaces if present line.erase(0, keyword.size()); - while ((line.size() > 0) && (line[0] == ' ' || line[0] == '\t')) + while ((!line.empty()) && (line[0] == ' ' || line[0] == '\t')) { line.erase(0, 1); } @@ -107,7 +105,7 @@ inputFileReader::parse_line(std::string line, } line.erase(0, entry_name.size()); - while ((line.size() > 0) && (line[0] == ' ' || line[0] == '\t')) + while ((!line.empty()) && (line[0] == ' ' || line[0] == '\t')) { line.erase(0, 1); } @@ -115,14 +113,14 @@ inputFileReader::parse_line(std::string line, // we'd expect an equals size here if expect_equals_sign is true if (expect_equals_sign) { - if ((line.size() < 1) || (line[0] != '=')) + if ((line.empty()) || (line[0] != '=')) { return false; } } // remove comment - std::string::size_type pos = line.find('#'); + const std::string::size_type pos = line.find('#'); if (pos != std::string::npos) { line.erase(pos); @@ -135,12 +133,12 @@ inputFileReader::parse_line(std::string line, line.erase(0, 1); } - while ((line.size() > 0) && (line[0] == ' ' || line[0] == '\t')) + while ((!line.empty()) && (line[0] == ' ' || line[0] == '\t')) { line.erase(0, 1); } - while ((line.size() > 0) && + while ((!line.empty()) && (line[line.size() - 1] == ' ' || line[line.size() - 1] == '\t')) { line.erase(line.size() - 1, std::string::npos); @@ -156,15 +154,17 @@ std::vector inputFileReader::get_subsection_entry_list(const std::string ¶meters_file_name, const std::string &subsec_name, const std::string &entry_name, - const std::string &default_entry) const + const std::string &default_entry) { std::ifstream input_file; input_file.open(parameters_file_name); - std::string line, entry; - bool in_subsection = false; - bool found_entry, desired_entry_found; - unsigned int subsection_index; + std::string line; + std::string entry; + bool in_subsection = false; + bool found_entry = false; + bool desired_entry_found = false; + unsigned int subsection_index = 0; std::vector entry_list; std::vector index_list; @@ -229,13 +229,14 @@ inputFileReader::get_subsection_entry_list(const std::string ¶meters_file_na unsigned int inputFileReader::get_number_of_entries(const std::string ¶meters_file_name, const std::string &keyword, - const std::string &entry_name) const + const std::string &entry_name) { std::ifstream input_file; input_file.open(parameters_file_name); - std::string line, entry; - bool found_entry; + std::string line; + std::string entry; + bool found_entry = false; unsigned int count = 0; @@ -256,13 +257,14 @@ inputFileReader::get_number_of_entries(const std::string ¶meters_file_name, std::vector inputFileReader::get_entry_name_ending_list(const std::string ¶meters_file_name, const std::string &keyword, - const std::string &entry_name_begining) const + const std::string &entry_name_begining) { std::ifstream input_file; input_file.open(parameters_file_name); - std::string line, entry; - bool found_entry; + std::string line; + std::string entry; + bool found_entry = false; std::vector entry_name_end_list; @@ -276,13 +278,13 @@ inputFileReader::get_entry_name_ending_list(const std::string ¶meters_file_n // sign // Strip whitespace at the beginning - while ((entry.size() > 0) && (entry[0] == ' ' || entry[0] == '\t')) + while ((!entry.empty()) && (entry[0] == ' ' || entry[0] == '\t')) { entry.erase(0, 1); } // Strip everything up to the equals sign - while ((entry.size() > 0) && (entry[entry.size() - 1] != '=')) + while ((!entry.empty()) && (entry[entry.size() - 1] != '=')) { entry.erase(entry.size() - 1, std::string::npos); } @@ -291,7 +293,7 @@ inputFileReader::get_entry_name_ending_list(const std::string ¶meters_file_n entry.erase(entry.size() - 1, std::string::npos); // Strip whitespace between the entry name and the equals sign - while ((entry.size() > 0) && + while ((!entry.empty()) && (entry[entry.size() - 1] == ' ' || entry[entry.size() - 1] == '\t')) { entry.erase(entry.size() - 1, std::string::npos); diff --git a/src/parallelNucleationList/parallelNucleationList.cc b/src/parallelNucleationList/parallelNucleationList.cc index b50a2b7b3..76865b3dd 100644 --- a/src/parallelNucleationList/parallelNucleationList.cc +++ b/src/parallelNucleationList/parallelNucleationList.cc @@ -23,13 +23,13 @@ parallelNucleationList::buildGlobalNucleiList(double min_dist_between unsigned int old_num_nuclei) { // MPI INITIALIZATON - int numProcs = dealii::Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); - int thisProc = dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + const unsigned int numProcs = dealii::Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); + const unsigned int thisProc = dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); if (numProcs > 1) { // Cycle through each processor, sending and receiving, to append the list // of new nuclei - for (int proc_index = 0; proc_index < numProcs - 1; proc_index++) + for (unsigned int proc_index = 0; proc_index < numProcs - 1; proc_index++) { if (thisProc == proc_index) { @@ -104,12 +104,16 @@ parallelNucleationList::sendUpdate(int procno) const s_center_x.push_back(s_center[0]); s_center_y.push_back(s_center[1]); if (dim == 3) - s_center_z.push_back(s_center[2]); + { + s_center_z.push_back(s_center[2]); + } s_semiaxis_a.push_back(thisNuclei.semiaxes[0]); s_semiaxis_b.push_back(thisNuclei.semiaxes[1]); if (dim == 3) - s_semiaxis_c.push_back(thisNuclei.semiaxes[2]); + { + s_semiaxis_c.push_back(thisNuclei.semiaxes[2]); + } s_seededTime.push_back(thisNuclei.seededTime); s_seedingTime.push_back(thisNuclei.seedingTime); @@ -117,27 +121,32 @@ parallelNucleationList::sendUpdate(int procno) const s_orderParameterIndex.push_back(thisNuclei.orderParameterIndex); } // Send vectors to next processor - MPI_Send(&s_index[0], currnonucs, MPI_UNSIGNED, procno, 1, MPI_COMM_WORLD); - MPI_Send(&s_center_x[0], currnonucs, MPI_DOUBLE, procno, 2, MPI_COMM_WORLD); - MPI_Send(&s_center_y[0], currnonucs, MPI_DOUBLE, procno, 3, MPI_COMM_WORLD); + MPI_Send(s_index.data(), currnonucs, MPI_UNSIGNED, procno, 1, MPI_COMM_WORLD); + MPI_Send(s_center_x.data(), currnonucs, MPI_DOUBLE, procno, 2, MPI_COMM_WORLD); + MPI_Send(s_center_y.data(), currnonucs, MPI_DOUBLE, procno, 3, MPI_COMM_WORLD); if (dim == 3) { - MPI_Send(&s_center_z[0], currnonucs, MPI_DOUBLE, procno, 4, MPI_COMM_WORLD); - MPI_Send(&s_semiaxis_c[0], currnonucs, MPI_DOUBLE, procno, 7, MPI_COMM_WORLD); + MPI_Send(s_center_z.data(), currnonucs, MPI_DOUBLE, procno, 4, MPI_COMM_WORLD); + MPI_Send(s_semiaxis_c.data(), + currnonucs, + MPI_DOUBLE, + procno, + 7, + MPI_COMM_WORLD); } - MPI_Send(&s_semiaxis_a[0], currnonucs, MPI_DOUBLE, procno, 5, MPI_COMM_WORLD); - MPI_Send(&s_semiaxis_b[0], currnonucs, MPI_DOUBLE, procno, 6, MPI_COMM_WORLD); + MPI_Send(s_semiaxis_a.data(), currnonucs, MPI_DOUBLE, procno, 5, MPI_COMM_WORLD); + MPI_Send(s_semiaxis_b.data(), currnonucs, MPI_DOUBLE, procno, 6, MPI_COMM_WORLD); - MPI_Send(&s_seededTime[0], currnonucs, MPI_DOUBLE, procno, 8, MPI_COMM_WORLD); - MPI_Send(&s_seedingTime[0], currnonucs, MPI_DOUBLE, procno, 9, MPI_COMM_WORLD); - MPI_Send(&s_seedingTimestep[0], + MPI_Send(s_seededTime.data(), currnonucs, MPI_DOUBLE, procno, 8, MPI_COMM_WORLD); + MPI_Send(s_seedingTime.data(), currnonucs, MPI_DOUBLE, procno, 9, MPI_COMM_WORLD); + MPI_Send(s_seedingTimestep.data(), currnonucs, MPI_UNSIGNED, procno, 10, MPI_COMM_WORLD); - MPI_Send(&s_orderParameterIndex[0], + MPI_Send(s_orderParameterIndex.data(), currnonucs, MPI_UNSIGNED, procno, @@ -183,21 +192,21 @@ parallelNucleationList::receiveUpdate(int procno) std::vector r_orderParameterIndex(recvnonucs, 0); // Recieve vectors from processor procno - MPI_Recv(&r_index[0], + MPI_Recv(r_index.data(), recvnonucs, MPI_UNSIGNED, procno, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(&r_center_x[0], + MPI_Recv(r_center_x.data(), recvnonucs, MPI_DOUBLE, procno, 2, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(&r_center_y[0], + MPI_Recv(r_center_y.data(), recvnonucs, MPI_DOUBLE, procno, @@ -206,14 +215,14 @@ parallelNucleationList::receiveUpdate(int procno) MPI_STATUS_IGNORE); if (dim == 3) { - MPI_Recv(&r_center_z[0], + MPI_Recv(r_center_z.data(), recvnonucs, MPI_DOUBLE, procno, 4, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(&r_semiaxis_c[0], + MPI_Recv(r_semiaxis_c.data(), recvnonucs, MPI_DOUBLE, procno, @@ -222,14 +231,14 @@ parallelNucleationList::receiveUpdate(int procno) MPI_STATUS_IGNORE); } - MPI_Recv(&r_semiaxis_a[0], + MPI_Recv(r_semiaxis_a.data(), recvnonucs, MPI_DOUBLE, procno, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(&r_semiaxis_b[0], + MPI_Recv(r_semiaxis_b.data(), recvnonucs, MPI_DOUBLE, procno, @@ -237,28 +246,28 @@ parallelNucleationList::receiveUpdate(int procno) MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(&r_seededTime[0], + MPI_Recv(r_seededTime.data(), recvnonucs, MPI_DOUBLE, procno, 8, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(&r_seedingTime[0], + MPI_Recv(r_seedingTime.data(), recvnonucs, MPI_DOUBLE, procno, 9, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(&r_seedingTimestep[0], + MPI_Recv(r_seedingTimestep.data(), recvnonucs, MPI_UNSIGNED, procno, 10, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(&r_orderParameterIndex[0], + MPI_Recv(r_orderParameterIndex.data(), recvnonucs, MPI_UNSIGNED, procno, @@ -269,18 +278,23 @@ parallelNucleationList::receiveUpdate(int procno) // Loop to store info in vectors onto the nuclei structure for (int jnuc = 0; jnuc <= recvnonucs - 1; jnuc++) { - auto *temp = new nucleus; + auto temp = std::make_unique>(); + temp->index = r_index[jnuc]; dealii::Point r_center; r_center[0] = r_center_x[jnuc]; r_center[1] = r_center_y[jnuc]; if (dim == 3) - r_center[2] = r_center_z[jnuc]; + { + r_center[2] = r_center_z[jnuc]; + } temp->center = r_center; temp->semiaxes.push_back(r_semiaxis_a[jnuc]); temp->semiaxes.push_back(r_semiaxis_b[jnuc]); if (dim == 3) - temp->semiaxes.push_back(r_semiaxis_c[jnuc]); + { + temp->semiaxes.push_back(r_semiaxis_c[jnuc]); + } temp->seededTime = r_seededTime[jnuc]; temp->seedingTime = r_seedingTime[jnuc]; temp->seedingTimestep = r_seedingTimestep[jnuc]; @@ -305,7 +319,7 @@ parallelNucleationList::broadcastUpdate(int broadcastProc, int thisProc) { // Creating vectors of each quantity in nuclei. Each numbered acording to // the tags used for MPI_Send/MPI_Recv - unsigned int initial_vec_size; + unsigned int initial_vec_size = 0; if (thisProc == broadcastProc) { initial_vec_size = 0; @@ -364,29 +378,51 @@ parallelNucleationList::broadcastUpdate(int broadcastProc, int thisProc) } // Recieve vectors from processor procno - MPI_Bcast(&r_index[0], currnonucs, MPI_UNSIGNED, broadcastProc, MPI_COMM_WORLD); - MPI_Bcast(&r_center_x[0], currnonucs, MPI_DOUBLE, broadcastProc, MPI_COMM_WORLD); - MPI_Bcast(&r_center_y[0], currnonucs, MPI_DOUBLE, broadcastProc, MPI_COMM_WORLD); + MPI_Bcast(r_index.data(), currnonucs, MPI_UNSIGNED, broadcastProc, MPI_COMM_WORLD); + MPI_Bcast(r_center_x.data(), currnonucs, MPI_DOUBLE, broadcastProc, MPI_COMM_WORLD); + MPI_Bcast(r_center_y.data(), currnonucs, MPI_DOUBLE, broadcastProc, MPI_COMM_WORLD); if (dim == 3) - MPI_Bcast(&r_center_z[0], currnonucs, MPI_DOUBLE, broadcastProc, MPI_COMM_WORLD); - - MPI_Bcast(&r_semiaxis_a[0], currnonucs, MPI_DOUBLE, broadcastProc, MPI_COMM_WORLD); - MPI_Bcast(&r_semiaxis_b[0], currnonucs, MPI_DOUBLE, broadcastProc, MPI_COMM_WORLD); + { + MPI_Bcast(r_center_z.data(), + currnonucs, + MPI_DOUBLE, + broadcastProc, + MPI_COMM_WORLD); + } + MPI_Bcast(r_semiaxis_a.data(), + currnonucs, + MPI_DOUBLE, + broadcastProc, + MPI_COMM_WORLD); + MPI_Bcast(r_semiaxis_b.data(), + currnonucs, + MPI_DOUBLE, + broadcastProc, + MPI_COMM_WORLD); if (dim == 3) - MPI_Bcast(&r_semiaxis_c[0], - currnonucs, - MPI_DOUBLE, - broadcastProc, - MPI_COMM_WORLD); - - MPI_Bcast(&r_seededTime[0], currnonucs, MPI_DOUBLE, broadcastProc, MPI_COMM_WORLD); - MPI_Bcast(&r_seedingTime[0], currnonucs, MPI_DOUBLE, broadcastProc, MPI_COMM_WORLD); - MPI_Bcast(&r_seedingTimestep[0], + { + MPI_Bcast(r_semiaxis_c.data(), + currnonucs, + MPI_DOUBLE, + broadcastProc, + MPI_COMM_WORLD); + } + MPI_Bcast(r_seededTime.data(), + currnonucs, + MPI_DOUBLE, + broadcastProc, + MPI_COMM_WORLD); + MPI_Bcast(r_seedingTime.data(), + currnonucs, + MPI_DOUBLE, + broadcastProc, + MPI_COMM_WORLD); + MPI_Bcast(r_seedingTimestep.data(), currnonucs, MPI_UNSIGNED, broadcastProc, MPI_COMM_WORLD); - MPI_Bcast(&r_orderParameterIndex[0], + MPI_Bcast(r_orderParameterIndex.data(), currnonucs, MPI_UNSIGNED, broadcastProc, @@ -397,13 +433,16 @@ parallelNucleationList::broadcastUpdate(int broadcastProc, int thisProc) // Loop to store info in vectors onto the nuclei structure for (int jnuc = 0; jnuc <= currnonucs - 1; jnuc++) { - auto *temp = new nucleus; + auto temp = std::make_unique>(); + temp->index = r_index[jnuc]; dealii::Point r_center; r_center[0] = r_center_x[jnuc]; r_center[1] = r_center_y[jnuc]; if (dim == 3) - r_center[2] = r_center_z[jnuc]; + { + r_center[2] = r_center_z[jnuc]; + } temp->center = r_center; temp->semiaxes.push_back(r_semiaxis_a[jnuc]); temp->semiaxes.push_back(r_semiaxis_b[jnuc]); @@ -475,8 +514,10 @@ parallelNucleationList::removeSubsetOfNuclei( // methods to reduce duplication. // MPI INITIALIZATON - int numProcs = dealii::Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); - int thisProc = dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + const int numProcs = + static_cast(dealii::Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD)); + const int thisProc = + static_cast(dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD)); // Build a global list of nuclei to delete, first sending the length of the // vector of indices, then the vector itself @@ -488,9 +529,9 @@ parallelNucleationList::removeSubsetOfNuclei( { if (thisProc == proc_index) { - int currnonucs = nuclei_to_remove.size(); + int currnonucs = static_cast(nuclei_to_remove.size()); MPI_Send(&currnonucs, 1, MPI_INT, thisProc + 1, 0, MPI_COMM_WORLD); - MPI_Send(&nuclei_to_remove[0], + MPI_Send(nuclei_to_remove.data(), currnonucs, MPI_UNSIGNED, thisProc + 1, @@ -508,7 +549,7 @@ parallelNucleationList::removeSubsetOfNuclei( MPI_COMM_WORLD, MPI_STATUS_IGNORE); std::vector recieved_nuclei_to_remove(recvnonucs); - MPI_Recv(&recieved_nuclei_to_remove[0], + MPI_Recv(recieved_nuclei_to_remove.data(), recvnonucs, MPI_UNSIGNED, thisProc - 1, @@ -524,14 +565,14 @@ parallelNucleationList::removeSubsetOfNuclei( // The final processor now has the final list of the new nuclei, broadcast // it to all the other processors - int currnonucs = nuclei_to_remove.size(); + int currnonucs = static_cast(nuclei_to_remove.size()); MPI_Bcast(&currnonucs, 1, MPI_INT, numProcs - 1, MPI_COMM_WORLD); std::vector recieved_nuclei_to_remove(currnonucs); if (thisProc == numProcs - 1) { recieved_nuclei_to_remove = nuclei_to_remove; } - MPI_Bcast(&recieved_nuclei_to_remove[0], + MPI_Bcast(recieved_nuclei_to_remove.data(), currnonucs, MPI_UNSIGNED, numProcs - 1, @@ -539,9 +580,9 @@ parallelNucleationList::removeSubsetOfNuclei( nuclei_to_remove = recieved_nuclei_to_remove; } - for (unsigned int i : nuclei_to_remove) + for (const unsigned int nuclei : nuclei_to_remove) { - std::cout << thisProc << ": " << i << std::endl; + std::cout << thisProc << ": " << nuclei << std::endl; } // Remove the nuclei from the list @@ -549,9 +590,9 @@ parallelNucleationList::removeSubsetOfNuclei( for (unsigned int nuc = 0; nuc < newnuclei.size(); nuc++) { bool pruneNucleus = false; - for (unsigned int i : nuclei_to_remove) + for (const unsigned int nuclei : nuclei_to_remove) { - if (i == nuclei_size + nuc) + if (nuclei == nuclei_size + nuc) { pruneNucleus = true; break; diff --git a/src/userInputParameters/loadVariableAttributes.cc b/src/userInputParameters/loadVariableAttributes.cc index 942936973..82355d7e8 100644 --- a/src/userInputParameters/loadVariableAttributes.cc +++ b/src/userInputParameters/loadVariableAttributes.cc @@ -23,7 +23,7 @@ userInputParameters::loadVariableAttributes( // Load some nucleation parameters for (unsigned int i = 0; i < number_of_variables; i++) { - if (variable_attributes.nucleating_variable.at(i) == true) + if (variable_attributes.nucleating_variable.at(i)) { nucleating_variable_indices.push_back(i); } @@ -34,8 +34,8 @@ userInputParameters::loadVariableAttributes( } } - nucleating_variable_indices.size() > 0 ? nucleation_occurs = true - : nucleation_occurs = false; + !nucleating_variable_indices.empty() ? nucleation_occurs = true + : nucleation_occurs = false; // Load these attributes into the varInfoList objects @@ -43,7 +43,8 @@ userInputParameters::loadVariableAttributes( num_var_explicit_RHS = 0; for (unsigned int i = 0; i < number_of_variables; i++) { - if (!(variable_attributes.equation_dependency_parser.eval_flags_explicit_RHS[i] & + if (!static_cast( + variable_attributes.equation_dependency_parser.eval_flags_explicit_RHS[i] & dealii::EvaluationFlags::nothing)) { num_var_explicit_RHS++; @@ -52,19 +53,13 @@ userInputParameters::loadVariableAttributes( varInfoListExplicitRHS.reserve(num_var_explicit_RHS); for (unsigned int i = 0; i < number_of_variables; i++) { - variable_info varInfo; - - varInfo.evaluation_flags = - variable_attributes.equation_dependency_parser.eval_flags_explicit_RHS[i]; - - varInfo.residual_flags = variable_attributes.equation_dependency_parser - .eval_flags_residual_explicit_RHS[i]; - - varInfo.global_var_index = i; - - varInfo.var_needed = !(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing); - - varInfo.is_scalar = var_type[i] == SCALAR; + variable_info varInfo { + var_type[i] == SCALAR, + i, + variable_attributes.equation_dependency_parser.eval_flags_explicit_RHS[i], + variable_attributes.equation_dependency_parser + .eval_flags_residual_explicit_RHS[i], + !static_cast(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing)}; varInfoListExplicitRHS.push_back(varInfo); } @@ -73,7 +68,8 @@ userInputParameters::loadVariableAttributes( num_var_nonexplicit_RHS = 0; for (unsigned int i = 0; i < number_of_variables; i++) { - if (!(variable_attributes.equation_dependency_parser.eval_flags_nonexplicit_RHS[i] & + if (!static_cast( + variable_attributes.equation_dependency_parser.eval_flags_nonexplicit_RHS[i] & dealii::EvaluationFlags::nothing)) { num_var_nonexplicit_RHS++; @@ -82,19 +78,13 @@ userInputParameters::loadVariableAttributes( varInfoListNonexplicitRHS.reserve(num_var_nonexplicit_RHS); for (unsigned int i = 0; i < number_of_variables; i++) { - variable_info varInfo; - - varInfo.evaluation_flags = - variable_attributes.equation_dependency_parser.eval_flags_nonexplicit_RHS[i]; - - varInfo.residual_flags = variable_attributes.equation_dependency_parser - .eval_flags_residual_nonexplicit_RHS[i]; - - varInfo.global_var_index = i; - - varInfo.var_needed = !(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing); - - varInfo.is_scalar = var_type[i] == SCALAR; + variable_info varInfo { + var_type[i] == SCALAR, + i, + variable_attributes.equation_dependency_parser.eval_flags_nonexplicit_RHS[i], + variable_attributes.equation_dependency_parser + .eval_flags_residual_nonexplicit_RHS[i], + !static_cast(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing)}; varInfoListNonexplicitRHS.push_back(varInfo); } @@ -103,7 +93,8 @@ userInputParameters::loadVariableAttributes( num_var_LHS = 0; for (unsigned int i = 0; i < number_of_variables; i++) { - if (!(variable_attributes.equation_dependency_parser.eval_flags_nonexplicit_LHS[i] & + if (!static_cast( + variable_attributes.equation_dependency_parser.eval_flags_nonexplicit_LHS[i] & dealii::EvaluationFlags::nothing)) { num_var_LHS++; @@ -113,19 +104,13 @@ userInputParameters::loadVariableAttributes( varInfoListLHS.reserve(num_var_LHS); for (unsigned int i = 0; i < number_of_variables; i++) { - variable_info varInfo; - - varInfo.evaluation_flags = - variable_attributes.equation_dependency_parser.eval_flags_nonexplicit_LHS[i]; - - varInfo.residual_flags = variable_attributes.equation_dependency_parser - .eval_flags_residual_nonexplicit_LHS[i]; - - varInfo.global_var_index = i; - - varInfo.var_needed = !(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing); - - varInfo.is_scalar = var_type[i] == SCALAR; + variable_info varInfo { + var_type[i] == SCALAR, + i, + variable_attributes.equation_dependency_parser.eval_flags_nonexplicit_LHS[i], + variable_attributes.equation_dependency_parser + .eval_flags_residual_nonexplicit_LHS[i], + !static_cast(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing)}; varInfoListLHS.push_back(varInfo); } @@ -133,20 +118,14 @@ userInputParameters::loadVariableAttributes( varChangeInfoListLHS.reserve(num_var_LHS); for (unsigned int i = 0; i < number_of_variables; i++) { - variable_info varInfo; - - varInfo.evaluation_flags = variable_attributes.equation_dependency_parser - .eval_flags_change_nonexplicit_LHS[i]; - - // FOR NOW, TAKING THESE FROM THE VARIABLE ITSELF!! - varInfo.residual_flags = variable_attributes.equation_dependency_parser - .eval_flags_residual_nonexplicit_LHS[i]; - - varInfo.global_var_index = i; - - varInfo.var_needed = !(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing); - - varInfo.is_scalar = var_type[i] == SCALAR; + variable_info varInfo {var_type[i] == SCALAR, + i, + variable_attributes.equation_dependency_parser + .eval_flags_change_nonexplicit_LHS[i], + variable_attributes.equation_dependency_parser + .eval_flags_residual_nonexplicit_LHS[i], + !static_cast(varInfo.evaluation_flags & + dealii::EvaluationFlags::nothing)}; varChangeInfoListLHS.push_back(varInfo); } @@ -156,16 +135,12 @@ userInputParameters::loadVariableAttributes( pp_baseVarInfoList.reserve(number_of_variables); for (unsigned int i = 0; i < number_of_variables; i++) { - variable_info varInfo; - - varInfo.evaluation_flags = - variable_attributes.equation_dependency_parser.eval_flags_postprocess[i]; - - varInfo.global_var_index = i; - - varInfo.var_needed = !(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing); - - varInfo.is_scalar = var_type[i] == SCALAR; + variable_info varInfo { + var_type[i] == SCALAR, + i, + variable_attributes.equation_dependency_parser.eval_flags_postprocess[i], + dealii::EvaluationFlags::nothing, + !static_cast(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing)}; pp_baseVarInfoList.push_back(varInfo); } @@ -189,15 +164,12 @@ userInputParameters::loadVariableAttributes( pp_varInfoList.reserve(pp_number_of_variables); for (unsigned int i = 0; i < pp_number_of_variables; i++) { - variable_info varInfo; - varInfo.var_needed = true; - - varInfo.residual_flags = - variable_attributes.equation_dependency_parser.eval_flags_residual_postprocess[i]; - - varInfo.global_var_index = i; - - varInfo.is_scalar = pp_var_type[i] == SCALAR; + variable_info varInfo { + pp_var_type[i] == SCALAR, + i, + dealii::EvaluationFlags::nothing, + variable_attributes.equation_dependency_parser.eval_flags_residual_postprocess[i], + true}; pp_varInfoList.push_back(varInfo); } diff --git a/src/userInputParameters/load_user_constants.cc b/src/userInputParameters/load_user_constants.cc index 5726daff9..979747197 100644 --- a/src/userInputParameters/load_user_constants.cc +++ b/src/userInputParameters/load_user_constants.cc @@ -11,7 +11,7 @@ void userInputParameters::load_user_constants(inputFileReader &input_file_reader, dealii::ParameterHandler ¶meter_handler) { - unsigned int number_of_constants = input_file_reader.num_constants; + const unsigned int number_of_constants = input_file_reader.num_constants; for (unsigned int i = 0; i < input_file_reader.model_constant_names.size(); i++) { @@ -54,15 +54,7 @@ userInputParameters::load_user_constants(inputFileReader &input_fi } else if (boost::iequals(model_constants_type_strings.at(0), "bool")) { - bool temp; - if (boost::iequals(model_constants_strings.at(0), "true")) - { - temp = true; - } - else - { - temp = false; - } + bool temp = boost::iequals(model_constants_strings.at(0), "true"); model_constants.push_back(temp); } else @@ -78,7 +70,7 @@ userInputParameters::load_user_constants(inputFileReader &input_fi { if (boost::iequals(model_constants_type_strings.at(0), "tensor")) { - unsigned int num_elements = model_constants_strings.size() - 1; + const unsigned int num_elements = model_constants_strings.size() - 1; // Strip parentheses from the input, counting how many rows there // are @@ -139,7 +131,7 @@ userInputParameters::load_user_constants(inputFileReader &input_fi // Rank 2 tensor else if (open_parentheses < 5) { - unsigned int row_length; + unsigned int row_length = 0; if (num_elements == 4) { row_length = 2; @@ -180,7 +172,7 @@ userInputParameters::load_user_constants(inputFileReader &input_fi else if (boost::iequals(model_constants_type_strings.at(1), "elastic") && boost::iequals(model_constants_type_strings.at(2), "constants")) { - unsigned int num_elements = model_constants_strings.size() - 1; + const unsigned int num_elements = model_constants_strings.size() - 1; // Strip parentheses from the input, counting how many rows there // are @@ -226,7 +218,8 @@ userInputParameters::load_user_constants(inputFileReader &input_fi dealii::Utilities::string_to_double(model_constants_strings.at(i))); } - std::string elastic_const_symmetry = model_constants_type_strings.at(0); + const std::string elastic_const_symmetry = + model_constants_type_strings.at(0); dealii::Tensor<2, 2 *dim - 1 + dim / 3> temp = get_Cij_tensor(temp_elastic_constants, elastic_const_symmetry); model_constants.push_back(temp); @@ -283,7 +276,7 @@ userInputParameters::get_Cij_tensor(std::vector elastic_constants, { std::vector elastic_constants_temp = elastic_constants; elastic_constants.clear(); - std::vector indices_2D = {0, 1, 5, 6, 10, 14}; + const std::vector indices_2D = {0, 1, 5, 6, 10, 14}; for (const auto &index : indices_2D) { elastic_constants.push_back(elastic_constants_temp.at(index)); @@ -363,12 +356,13 @@ userInputParameters::getCIJMatrix(const elasticityModel model, case ISOTROPIC: { pcout << " ISOTROPIC \n"; - double E = constants[0], nu = constants[1]; - double mu = E / (2 * (1 + nu)), - lambda = nu * E / ((1 + nu) * (1 - 2 * nu)); - CIJ[0][0] = lambda + 2 * mu; - CIJ[1][1] = lambda + 2 * mu; - CIJ[2][2] = mu; + const double E = constants[0]; + const double nu = constants[1]; + const double mu = E / (2 * (1 + nu)); + const double lambda = nu * E / ((1 + nu) * (1 - 2 * nu)); + CIJ[0][0] = lambda + 2 * mu; + CIJ[1][1] = lambda + 2 * mu; + CIJ[2][2] = mu; CIJ[0][1] = CIJ[1][0] = lambda; break; } @@ -402,15 +396,16 @@ userInputParameters::getCIJMatrix(const elasticityModel model, case ISOTROPIC: { pcout << " ISOTROPIC \n"; - double E = constants[0], nu = constants[1]; - double mu = E / (2 * (1 + nu)), - lambda = nu * E / ((1 + nu) * (1 - 2 * nu)); - CIJ[0][0] = lambda + 2 * mu; - CIJ[1][1] = lambda + 2 * mu; - CIJ[2][2] = lambda + 2 * mu; - CIJ[3][3] = mu; - CIJ[4][4] = mu; - CIJ[5][5] = mu; + const double E = constants[0]; + const double nu = constants[1]; + const double mu = E / (2 * (1 + nu)); + const double lambda = nu * E / ((1 + nu) * (1 - 2 * nu)); + CIJ[0][0] = lambda + 2 * mu; + CIJ[1][1] = lambda + 2 * mu; + CIJ[2][2] = lambda + 2 * mu; + CIJ[3][3] = mu; + CIJ[4][4] = mu; + CIJ[5][5] = mu; CIJ[0][1] = CIJ[1][0] = lambda; CIJ[0][2] = CIJ[2][0] = lambda; CIJ[1][2] = CIJ[2][1] = lambda; diff --git a/src/userInputParameters/setTimeStepList.cc b/src/userInputParameters/setTimeStepList.cc index 7f7cc56b6..0382a8443 100644 --- a/src/userInputParameters/setTimeStepList.cc +++ b/src/userInputParameters/setTimeStepList.cc @@ -64,8 +64,8 @@ userInputParameters::setTimeStepList( timeStepList.push_back(1); for (unsigned int iter = 2; iter <= totalIncrements; iter++) { - unsigned int decade = std::ceil(std::log10(iter)); - unsigned int step_size = std::pow(10, decade) / numberOfOutputs; + const unsigned int decade = std::ceil(std::log10(iter)); + const unsigned int step_size = std::pow(10, decade) / numberOfOutputs; if (iter % step_size == 0) { timeStepList.push_back(iter); diff --git a/src/userInputParameters/userInputParameters.cc b/src/userInputParameters/userInputParameters.cc index a1f460ddb..867648bde 100644 --- a/src/userInputParameters/userInputParameters.cc +++ b/src/userInputParameters/userInputParameters.cc @@ -69,8 +69,8 @@ userInputParameters::userInputParameters(inputFileReader &input_fi parameter_handler.enter_subsection(subsection_text); { - std::string crit_type_string = parameter_handler.get("Criterion type"); - if (crit_type_string.size() > 0) + const std::string crit_type_string = parameter_handler.get("Criterion type"); + if (!crit_type_string.empty()) { RefinementCriterion new_criterion; new_criterion.variable_index = i; @@ -140,9 +140,9 @@ userInputParameters::userInputParameters(inputFileReader &input_fi } // Time stepping parameters - dtValue = parameter_handler.get_double("Time step"); - int totalIncrements_temp = parameter_handler.get_integer("Number of time steps"); - finalTime = parameter_handler.get_double("Simulation end time"); + dtValue = parameter_handler.get_double("Time step"); + const int totalIncrements_temp = parameter_handler.get_integer("Number of time steps"); + finalTime = parameter_handler.get_double("Simulation end time"); // Linear solver parameters for (unsigned int i = 0; i < number_of_variables; i++) @@ -157,7 +157,7 @@ userInputParameters::userInputParameters(inputFileReader &input_fi { // Set the tolerance type SolverToleranceType temp_type; - std::string type_string = parameter_handler.get("Tolerance type"); + const std::string type_string = parameter_handler.get("Tolerance type"); if (boost::iequals(type_string, "ABSOLUTE_RESIDUAL")) { temp_type = ABSOLUTE_RESIDUAL; @@ -187,10 +187,10 @@ userInputParameters::userInputParameters(inputFileReader &input_fi } // Set the tolerance value - double temp_value = parameter_handler.get_double("Tolerance value"); + const double temp_value = parameter_handler.get_double("Tolerance value"); // Set the maximum number of iterations - unsigned int temp_max_iterations = + const unsigned int temp_max_iterations = parameter_handler.get_integer("Maximum linear solver iterations"); linear_solver_parameters.loadParameters(i, @@ -219,7 +219,7 @@ userInputParameters::userInputParameters(inputFileReader &input_fi { // Set the tolerance type SolverToleranceType temp_type; - std::string type_string = parameter_handler.get("Tolerance type"); + const std::string type_string = parameter_handler.get("Tolerance type"); if (boost::iequals(type_string, "ABSOLUTE_RESIDUAL")) { temp_type = ABSOLUTE_RESIDUAL; @@ -243,24 +243,24 @@ userInputParameters::userInputParameters(inputFileReader &input_fi } // Set the tolerance value - double temp_value = parameter_handler.get_double("Tolerance value"); + const double temp_value = parameter_handler.get_double("Tolerance value"); // Set the backtrace damping flag - bool temp_backtrack_damping = + const bool temp_backtrack_damping = parameter_handler.get_bool("Use backtracking line search damping"); // Set the backtracking step size modifier - double temp_step_modifier = + const double temp_step_modifier = parameter_handler.get_double("Backtracking step size modifier"); // Set the constant that determines how much the residual must // decrease to be accepted as sufficient - double temp_residual_decrease_coeff = + const double temp_residual_decrease_coeff = parameter_handler.get_double("Backtracking residual decrease coefficient"); // Set the default damping coefficient (used if backtracking isn't // used) - double temp_damping_coefficient = + const double temp_damping_coefficient = parameter_handler.get_double("Constant damping value"); // Set whether to use the solution of Laplace's equation instead of @@ -301,15 +301,15 @@ userInputParameters::userInputParameters(inputFileReader &input_fi } // Set the max number of nonlinear iterations - if (var_nonlinear.size() == 0) + if (var_nonlinear.empty()) { nonlinear_solver_parameters.setMaxIterations(0); } // Output parameters - std::string output_condition = parameter_handler.get("Output condition"); - unsigned int num_outputs = parameter_handler.get_integer("Number of outputs"); - std::vector user_given_time_step_list_temp = + const std::string output_condition = parameter_handler.get("Output condition"); + const unsigned int num_outputs = parameter_handler.get_integer("Number of outputs"); + const std::vector user_given_time_step_list_temp = dealii::Utilities::string_to_int(dealii::Utilities::split_string_list( parameter_handler.get("List of time steps to output"))); std::vector user_given_time_step_list; @@ -445,10 +445,11 @@ userInputParameters::userInputParameters(inputFileReader &input_fi // Parameters for checkpoint/restart resume_from_checkpoint = parameter_handler.get_bool("Load from a checkpoint"); - std::string checkpoint_condition = parameter_handler.get("Checkpoint condition"); - unsigned int num_checkpoints = parameter_handler.get_integer("Number of checkpoints"); + const std::string checkpoint_condition = parameter_handler.get("Checkpoint condition"); + const unsigned int num_checkpoints = + parameter_handler.get_integer("Number of checkpoints"); - std::vector user_given_checkpoint_time_step_list_temp = + const std::vector user_given_checkpoint_time_step_list_temp = dealii::Utilities::string_to_int(dealii::Utilities::split_string_list( parameter_handler.get("List of time steps to save checkpoints"))); std::vector user_given_checkpoint_time_step_list; @@ -473,27 +474,27 @@ userInputParameters::userInputParameters(inputFileReader &input_fi parameter_handler.enter_subsection(nucleation_text); { - unsigned int var_index = i; - std::vector semiaxes = + const unsigned int var_index = i; + const std::vector semiaxes = dealii::Utilities::string_to_double(dealii::Utilities::split_string_list( parameter_handler.get("Nucleus semiaxes (x, y, z)"))); - std::vector ellipsoid_rotation = + const std::vector ellipsoid_rotation = dealii::Utilities::string_to_double(dealii::Utilities::split_string_list( parameter_handler.get("Nucleus rotation in degrees (x, y, z)"))); - std::vector freeze_semiaxes = + const std::vector freeze_semiaxes = dealii::Utilities::string_to_double(dealii::Utilities::split_string_list( parameter_handler.get("Freeze zone semiaxes (x, y, z)"))); - double hold_time = + const double hold_time = parameter_handler.get_double("Freeze time following nucleation"); - double no_nucleation_border_thickness = + const double no_nucleation_border_thickness = parameter_handler.get_double("Nucleation-free border thickness"); - nucleationParameters temp(var_index, - semiaxes, - freeze_semiaxes, - ellipsoid_rotation, - hold_time, - no_nucleation_border_thickness); + const nucleationParameters temp(var_index, + semiaxes, + freeze_semiaxes, + ellipsoid_rotation, + hold_time, + no_nucleation_border_thickness); nucleation_parameters_list.push_back(temp); // Validate nucleation input @@ -563,7 +564,7 @@ userInputParameters::userInputParameters(inputFileReader &input_fi buffer_between_grains = parameter_handler.get_double("Buffer between grains before reassignment"); - if (buffer_between_grains < 0.0 && grain_remapping_activated == true) + if (buffer_between_grains < 0.0 && grain_remapping_activated) { std::cerr << "PRISMS-PF Error: If grain reassignment is activated, a " "non-negative buffer distance must be given. See the 'Buffer " @@ -572,7 +573,7 @@ userInputParameters::userInputParameters(inputFileReader &input_fi abort(); } - std::vector variables_for_remapping_str = + const std::vector variables_for_remapping_str = dealii::Utilities::split_string_list( parameter_handler.get("Order parameter fields for grain reassignment")); for (const auto &field : variables_for_remapping_str) @@ -588,7 +589,7 @@ userInputParameters::userInputParameters(inputFileReader &input_fi break; } } - if (field_found == false && grain_remapping_activated == true) + if (!field_found && grain_remapping_activated) { std::cerr << "PRISMS-PF Error: Entries in the list of order " "parameter fields used for grain reassignment must " diff --git a/src/utilities/sortIndexEntryPairList.cc b/src/utilities/sortIndexEntryPairList.cc index 3bf75d1ff..9a9654b4a 100644 --- a/src/utilities/sortIndexEntryPairList.cc +++ b/src/utilities/sortIndexEntryPairList.cc @@ -7,7 +7,7 @@ sortIndexEntryPairList( bool default_value) { std::vector sorted_vec; - unsigned int entry_index; + unsigned int entry_index = 0; for (unsigned int i = 0; i < number_of_variables; i++) { bool entry_found = false; @@ -40,7 +40,7 @@ sortIndexEntryPairList( const std::string &default_value) { std::vector sorted_vec; - unsigned int entry_index; + unsigned int entry_index = 0; for (unsigned int i = 0; i < number_of_variables; i++) { bool entry_found = false; @@ -73,7 +73,7 @@ sortIndexEntryPairList( fieldType default_value) { std::vector sorted_vec; - unsigned int entry_index; + unsigned int entry_index = 0; for (unsigned int i = 0; i < number_of_variables; i++) { bool entry_found = false; @@ -106,7 +106,7 @@ sortIndexEntryPairList( PDEType default_value) { std::vector sorted_vec; - unsigned int entry_index; + unsigned int entry_index = 0; for (unsigned int i = 0; i < number_of_variables; i++) { bool entry_found = false; diff --git a/src/utilities/vectorBCFunction.cc b/src/utilities/vectorBCFunction.cc index ff4bfb6b7..fe683b7d0 100644 --- a/src/utilities/vectorBCFunction.cc +++ b/src/utilities/vectorBCFunction.cc @@ -35,7 +35,9 @@ vectorBCFunction::vector_value_list( { const unsigned int n_points = points.size(); for (unsigned int p = 0; p < n_points; ++p) - vectorBCFunction::vector_value(points[p], value_list[p]); + { + vectorBCFunction::vector_value(points[p], value_list[p]); + } } template class vectorBCFunction<1>; diff --git a/src/variableAttributeLoader/variableAttributeLoader.cc b/src/variableAttributeLoader/variableAttributeLoader.cc index 1a15ab204..26e946d9a 100644 --- a/src/variableAttributeLoader/variableAttributeLoader.cc +++ b/src/variableAttributeLoader/variableAttributeLoader.cc @@ -16,16 +16,16 @@ variableAttributeLoader::variableAttributeLoader() number_of_variables, EXPLICIT_TIME_DEPENDENT); - std::vector sorted_dependencies_value_RHS = + const std::vector sorted_dependencies_value_RHS = sortIndexEntryPairList(var_eq_dependencies_value_RHS, number_of_variables, ""); - std::vector sorted_dependencies_gradient_RHS = + const std::vector sorted_dependencies_gradient_RHS = sortIndexEntryPairList(var_eq_dependencies_gradient_RHS, number_of_variables, ""); - std::vector sorted_dependencies_value_LHS = + const std::vector sorted_dependencies_value_LHS = sortIndexEntryPairList(var_eq_dependencies_value_LHS, number_of_variables, ""); - std::vector sorted_dependencies_gradient_LHS = + const std::vector sorted_dependencies_gradient_LHS = sortIndexEntryPairList(var_eq_dependencies_gradient_LHS, number_of_variables, ""); nucleating_variable = @@ -49,10 +49,10 @@ variableAttributeLoader::variableAttributeLoader() pp_var_name = sortIndexEntryPairList(var_name_list_PP, pp_number_of_variables, "var"); pp_var_type = sortIndexEntryPairList(var_type_list_PP, pp_number_of_variables, SCALAR); - std::vector pp_sorted_dependencies_value = + const std::vector pp_sorted_dependencies_value = sortIndexEntryPairList(var_eq_dependencies_value_PP, pp_number_of_variables, ""); - std::vector pp_sorted_dependencies_gradient = + const std::vector pp_sorted_dependencies_gradient = sortIndexEntryPairList(var_eq_dependencies_gradient_PP, pp_number_of_variables, ""); pp_calc_integral =