From d0cb0d2eedb14b2184d96a73d38e67ceb5da1239 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Wed, 5 Jun 2019 14:46:40 +0200 Subject: [PATCH] [CL] Apply readability-braces-around-statements. --- ChemistryLib/CreateOutput.cpp | 6 ++++++ ChemistryLib/CreatePhreeqcIO.cpp | 4 ++++ ChemistryLib/Output.cpp | 6 ++++++ ChemistryLib/PhreeqcIO.cpp | 14 ++++++++++++++ ChemistryLib/PhreeqcIOData/AqueousSolution.cpp | 8 ++++++++ ChemistryLib/PhreeqcIOData/EquilibriumPhase.cpp | 2 ++ ChemistryLib/PhreeqcIOData/KineticReactant.cpp | 4 ++++ ChemistryLib/PhreeqcIOData/ReactionRate.cpp | 4 ++++ 8 files changed, 48 insertions(+) diff --git a/ChemistryLib/CreateOutput.cpp b/ChemistryLib/CreateOutput.cpp index e0678dd1c48..310a2037b74 100644 --- a/ChemistryLib/CreateOutput.cpp +++ b/ChemistryLib/CreateOutput.cpp @@ -22,13 +22,19 @@ std::unique_ptr<Output> createOutput( std::vector<OutputItem> accepted_items{{"pH", ItemType::pH}, {"pe", ItemType::pe}}; for (auto const& component : components) + { accepted_items.emplace_back(component.name, ItemType::Component); + } for (auto const& equilibrium_phase : equilibrium_phases) + { accepted_items.emplace_back(equilibrium_phase.name, ItemType::EquilibriumPhase); + } for (auto const& kinetic_reactant : kinetic_reactants) + { accepted_items.emplace_back(kinetic_reactant.name, ItemType::KineticReactant); + } // Record ids of which phreeqc output items will be dropped. BasicOutputSetups basic_output_setups(project_file_name); diff --git a/ChemistryLib/CreatePhreeqcIO.cpp b/ChemistryLib/CreatePhreeqcIO.cpp index dd5ed3a468a..95a0ecd7c5d 100644 --- a/ChemistryLib/CreatePhreeqcIO.cpp +++ b/ChemistryLib/CreatePhreeqcIO.cpp @@ -65,18 +65,22 @@ std::unique_ptr<PhreeqcIO> createPhreeqcIO( if (process_id_to_component_name_map_element == process_id_to_component_name_map.end()) + { OGS_FATAL( "Component %s given in <solution>/<components> is not found in " "specified coupled processes (see " "<process>/<process_variables>/<concentration>).", component.name.c_str()); + } } if (components_per_chem_sys.size() + 1 != process_id_to_component_name_map.size()) + { OGS_FATAL( "The number of components given in <solution>/<components> is not " "in line with the number of transport processes - 1 which stands " "for the transport process of hydrogen."); + } std::vector<AqueousSolution> aqueous_solutions( num_chemical_systems, aqueous_solution_per_chem_sys); diff --git a/ChemistryLib/Output.cpp b/ChemistryLib/Output.cpp index 6eed8b29076..64593e54754 100644 --- a/ChemistryLib/Output.cpp +++ b/ChemistryLib/Output.cpp @@ -41,7 +41,9 @@ std::ofstream& operator<<(std::ofstream& out, Output const& output) output.getOutputItemsByItemType(ItemType::Component); out << "-totals"; for (auto const& component_item : component_items) + { out << " " << component_item.name; + } out << "\n"; auto const equilibrium_phase_items = @@ -50,7 +52,9 @@ std::ofstream& operator<<(std::ofstream& out, Output const& output) { out << "-equilibrium_phases"; for (auto const& equilibrium_phase_item : equilibrium_phase_items) + { out << " " << equilibrium_phase_item.name; + } out << "\n"; } @@ -60,7 +64,9 @@ std::ofstream& operator<<(std::ofstream& out, Output const& output) { out << "-kinetic_reactants"; for (auto const& kinetic_reactant_item : kinetic_reactant_items) + { out << " " << kinetic_reactant_item.name; + } out << "\n"; } diff --git a/ChemistryLib/PhreeqcIO.cpp b/ChemistryLib/PhreeqcIO.cpp index 6a3580b6de1..faa62265ad1 100644 --- a/ChemistryLib/PhreeqcIO.cpp +++ b/ChemistryLib/PhreeqcIO.cpp @@ -118,14 +118,18 @@ void PhreeqcIO::writeInputsToFile() std::ofstream out(_phreeqc_input_file, std::ofstream::out); if (!out) + { OGS_FATAL("Could not open file '%s' for writing phreeqc inputs.", _phreeqc_input_file.c_str()); + } out << *this; if (!out) + { OGS_FATAL("Failed in generating phreeqc input file '%s'.", _phreeqc_input_file.c_str()); + } out.close(); } @@ -188,9 +192,11 @@ void PhreeqcIO::execute() // load a specific database in the working directory if (!database_loaded(instance_id)) + { OGS_FATAL( "Failed in loading the specified thermodynamic database file: %s.", _database.c_str()); + } SetSelectedOutputFileOn(instance_id, 1); @@ -213,14 +219,18 @@ void PhreeqcIO::readOutputsFromFile() std::ifstream in(phreeqc_result_file); if (!in) + { OGS_FATAL("Could not open phreeqc result file '%s'.", phreeqc_result_file.c_str()); + } in >> *this; if (!in) + { OGS_FATAL("Error when reading phreeqc result file '%s'", phreeqc_result_file.c_str()); + } in.close(); } @@ -244,10 +254,12 @@ std::ifstream& operator>>(std::ifstream& in, PhreeqcIO& phreeqc_io) // Get calculation result of the solution after the reaction if (!std::getline(in, line)) + { OGS_FATAL( "Error when reading calculation result of Solution %u after " "the reaction.", chemical_system_id); + } std::vector<double> accepted_items; std::vector<std::string> items; @@ -259,7 +271,9 @@ std::ifstream& operator>>(std::ifstream& in, PhreeqcIO& phreeqc_io) { if (std::find(dropped_item_ids.begin(), dropped_item_ids.end(), item_id) == dropped_item_ids.end()) + { accepted_items.push_back(std::stod(items[item_id])); + } } assert(accepted_items.size() == output.accepted_items.size()); diff --git a/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp b/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp index 6680a4d4536..8867e80dd97 100644 --- a/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp +++ b/ChemistryLib/PhreeqcIOData/AqueousSolution.cpp @@ -48,14 +48,20 @@ AqueousSolution createAqueousSolution(BaseLib::ConfigTree const& config) if (means_of_adjusting_charge_in_str) { if (*means_of_adjusting_charge_in_str == "pH") + { means_of_adjusting_charge = MeansOfAdjustingCharge::pH; + } else if (*means_of_adjusting_charge_in_str == "pe") + { means_of_adjusting_charge = MeansOfAdjustingCharge::pe; + } else + { OGS_FATAL( "Error in specifying means of adjusting charge. Achieving " "charge balance is currently supported with the way of " "adjusting pH value or pe value."); + } } else { @@ -99,7 +105,9 @@ std::ofstream& operator<<(std::ofstream& out, out << "units mol/kgw\n"; for (auto const& component : aqueous_solution.components) + { out << component.name << " " << component.amount << "\n"; + } return out; } diff --git a/ChemistryLib/PhreeqcIOData/EquilibriumPhase.cpp b/ChemistryLib/PhreeqcIOData/EquilibriumPhase.cpp index 05888627e5c..e92d7b06641 100644 --- a/ChemistryLib/PhreeqcIOData/EquilibriumPhase.cpp +++ b/ChemistryLib/PhreeqcIOData/EquilibriumPhase.cpp @@ -18,7 +18,9 @@ std::vector<EquilibriumPhase> createEquilibriumPhases( boost::optional<BaseLib::ConfigTree> const& config) { if (!config) + { return {}; + } std::vector<EquilibriumPhase> equilibrium_phases; for ( diff --git a/ChemistryLib/PhreeqcIOData/KineticReactant.cpp b/ChemistryLib/PhreeqcIOData/KineticReactant.cpp index 6f6c76b5d20..e4e39a22a9e 100644 --- a/ChemistryLib/PhreeqcIOData/KineticReactant.cpp +++ b/ChemistryLib/PhreeqcIOData/KineticReactant.cpp @@ -18,7 +18,9 @@ std::vector<KineticReactant> createKineticReactants( boost::optional<BaseLib::ConfigTree> const& config) { if (!config) + { return {}; + } std::vector<KineticReactant> kinetic_reactants; for ( @@ -58,7 +60,9 @@ std::ofstream& operator<<(std::ofstream& out, { out << "-parms"; for (auto const& parameter : kinetic_reactant.parameters) + { out << " " << parameter; + } out << "\n"; } } diff --git a/ChemistryLib/PhreeqcIOData/ReactionRate.cpp b/ChemistryLib/PhreeqcIOData/ReactionRate.cpp index ee967a40371..00331c51f0e 100644 --- a/ChemistryLib/PhreeqcIOData/ReactionRate.cpp +++ b/ChemistryLib/PhreeqcIOData/ReactionRate.cpp @@ -18,7 +18,9 @@ std::vector<ReactionRate> createReactionRates( boost::optional<BaseLib::ConfigTree> const& config) { if (!config) + { return {}; + } std::vector<ReactionRate> reaction_rates; for (auto const& rate_config : @@ -37,7 +39,9 @@ std::vector<ReactionRate> createReactionRates( auto const& expression_statement : //! \ogs_file_param{prj__chemical_system__rates__rate__expression__statement} expression_config.getConfigParameterList<std::string>("statement")) + { expression_statements.push_back(expression_statement); + } reaction_rates.emplace_back(std::move(kinetic_reactant), std::move(expression_statements)); -- GitLab