Skip to content

Commit

Permalink
Merge branch 'SmallFixes' into 'master'
Browse files Browse the repository at this point in the history
Small fixes

See merge request ogs/ogs!4677
  • Loading branch information
TomFischer committed Jul 19, 2023
2 parents 3eb9bfd + 175e3e9 commit 06d4628
Show file tree
Hide file tree
Showing 53 changed files with 709 additions and 778 deletions.
2 changes: 1 addition & 1 deletion Applications/ApplicationsLib/ProjectData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ void ProjectData::parseNonlinearSolvers(BaseLib::ConfigTree const& config)
auto const ls_name =
//! \ogs_file_param{prj__nonlinear_solvers__nonlinear_solver__linear_solver}
conf.getConfigParameter<std::string>("linear_solver");
auto& linear_solver = BaseLib::getOrError(
auto const& linear_solver = BaseLib::getOrError(
_linear_solvers, ls_name,
"A linear solver with the given name does not exist.");

Expand Down
10 changes: 5 additions & 5 deletions Applications/FileIO/FEFLOW/FEFLOWGeoInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ void FEFLOWGeoInterface::readFEFLOWFile(const std::string& filename,
std::stringstream line_stream;
while (!in.eof())
{
getline(in, line_string);
std::getline(in, line_string);
//....................................................................
// CLASS: the version number follows afterward, e.g. CLASS (v.5.313)
if (line_string.find("CLASS") != std::string::npos)
{
getline(in, line_string);
std::getline(in, line_string);
line_stream.str(line_string);
// problem class, time mode, problem orientation, dimension, ...
unsigned dummy = 0;
Expand All @@ -67,7 +67,7 @@ void FEFLOWGeoInterface::readFEFLOWFile(const std::string& filename,
// GRAVITY
else if (line_string == "GRAVITY")
{
getline(in, line_string);
std::getline(in, line_string);
line_stream.str(line_string);
double vec[3] = {};
line_stream >> vec[0] >> vec[1] >> vec[2];
Expand Down Expand Up @@ -126,7 +126,7 @@ void FEFLOWGeoInterface::readPoints(QDomElement& nodesEle,
std::string line_str;
while (!ss.eof())
{
std::getline(ss, line_str);
std::std::getline(ss, line_str);
boost::trim_right(line_str);
if (line_str.empty())
{
Expand Down Expand Up @@ -154,7 +154,7 @@ void FEFLOWGeoInterface::readSuperMesh(std::ifstream& in,
std::string line_string;
while (true)
{
getline(in, line_string);
std::getline(in, line_string);
BaseLib::trim(line_string);
oss << line_string << "\n";
if (line_string.find("</supermesh>") != std::string::npos)
Expand Down
6 changes: 3 additions & 3 deletions Applications/FileIO/FEFLOW/FEFLOWMeshInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ MeshLib::Mesh* FEFLOWMeshInterface::readFEFLOWFile(const std::string& filename)
// GRAVITY
else if (line_string == "GRAVITY")
{
getline(in, line_string);
std::getline(in, line_string);
line_stream.str(line_string);
double vec[3] = {};
line_stream >> vec[0] >> vec[1] >> vec[2];
Expand Down Expand Up @@ -325,7 +325,7 @@ void FEFLOWMeshInterface::readNodeCoordinates(
// each line
for (std::size_t i = 0; i < n_lines; i++)
{
getline(in, line_string);
std::getline(in, line_string);
line_stream.str(line_string);
for (unsigned j = 0; j < 12; j++)
{
Expand Down Expand Up @@ -626,7 +626,7 @@ void FEFLOWMeshInterface::readELEMENTALSETS(
while (true)
{
pos_prev_line = in.tellg();
getline(in, line_string);
std::getline(in, line_string);

unsigned mode = 0;
if (!in)
Expand Down
20 changes: 10 additions & 10 deletions Applications/FileIO/Gmsh/GmshReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ bool isGMSHMeshFile(const std::string& fname)
{
// read version
std::string version;
getline(input, version);
getline(input, version);
std::getline(input, version);
std::getline(input, version);
INFO("isGMSHMeshFile(): Found GMSH mesh file version: {:s}.", version);
input.close();
return true;
Expand Down Expand Up @@ -278,15 +278,15 @@ MeshLib::Mesh* readGMSHMesh(std::string const& fname)
return nullptr;
}

getline(in, line); // $MeshFormat keyword
std::getline(in, line); // $MeshFormat keyword
if (line.find("$MeshFormat") == std::string::npos)
{
in.close();
WARN("No GMSH file format recognized.");
return nullptr;
}

getline(in, line); // version-number file-type data-size
std::getline(in, line); // version-number file-type data-size
if (line.substr(0, 3) != "2.2")
{
WARN("Wrong gmsh file format version '{:s}'.", line.substr(0, 3));
Expand All @@ -298,7 +298,7 @@ MeshLib::Mesh* readGMSHMesh(std::string const& fname)
WARN("Currently reading gmsh binary file type is not supported.");
return nullptr;
}
getline(in, line); //$EndMeshFormat
std::getline(in, line); //$EndMeshFormat

std::vector<MeshLib::Node*> nodes;
std::vector<MeshLib::Element*> elements;
Expand All @@ -307,7 +307,7 @@ MeshLib::Mesh* readGMSHMesh(std::string const& fname)
while (line.find("$EndElements") == std::string::npos)
{
// Node data
getline(in, line); //$Nodes Keywords
std::getline(in, line); //$Nodes Keywords
if (line.find("$Nodes") != std::string::npos)
{
std::size_t n_nodes(0);
Expand All @@ -323,7 +323,7 @@ MeshLib::Mesh* readGMSHMesh(std::string const& fname)
id_map.insert(std::map<unsigned, unsigned>::value_type(id, i));
nodes[i] = new MeshLib::Node(x, y, z, id);
}
getline(in, line); // End Node keyword $EndNodes
std::getline(in, line); // End Node keyword $EndNodes
}

// Element data
Expand All @@ -348,7 +348,7 @@ MeshLib::Mesh* readGMSHMesh(std::string const& fname)
materials.push_back(mat_id);
}
}
getline(in, line); // END keyword
std::getline(in, line); // END keyword
}

if (line.find("PhysicalNames") != std::string::npos)
Expand All @@ -357,9 +357,9 @@ MeshLib::Mesh* readGMSHMesh(std::string const& fname)
in >> n_lines >> std::ws; // number-of-lines
for (std::size_t i = 0; i < n_lines; i++)
{
getline(in, line);
std::getline(in, line);
}
getline(in, line); // END keyword
std::getline(in, line); // END keyword
}
}
in.close();
Expand Down
4 changes: 2 additions & 2 deletions Applications/FileIO/GocadIO/GocadAsciiReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ bool parseProperties(std::ifstream& in,
// related keywords is found.
std::streampos pos = in.tellg();
std::string line;
while (getline(in, line))
while (std::getline(in, line))
{
std::string const key = propertyCheck(line);
// This is the intended way to exit this method:
Expand Down Expand Up @@ -446,7 +446,7 @@ bool parseLine(std::ifstream& in,

/// Parses the element data for the current mesh
bool parseElements(std::ifstream& in,
std::vector<MeshLib::Node*>& nodes,
std::vector<MeshLib::Node*> const& nodes,
std::vector<MeshLib::Element*>& elems,
std::map<std::size_t, std::size_t> const& node_id_map,
MeshLib::Properties& mesh_prop)
Expand Down
10 changes: 5 additions & 5 deletions Applications/FileIO/SWMM/SWMMInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ bool SwmmInterface::readSubcatchments(
std::ifstream& in, std::map<std::string, std::size_t> const& name_id_map)
{
std::string line;
while (getline(in, line))
while (std::getline(in, line))
{
if (isSectionFinished(line))
return true;
Expand Down Expand Up @@ -676,7 +676,7 @@ bool SwmmInterface::readSwmmInputToLineMesh()
_id_nodename_map.clear();
std::vector<MeshLib::Node*> nodes;
std::string line;
while (getline(in, line))
while (std::getline(in, line))
{
if (line == "[COORDINATES]")
{
Expand Down Expand Up @@ -724,7 +724,7 @@ bool SwmmInterface::readSwmmInputToLineMesh()
std::vector<double> max_depth(n_nodes);
std::size_t const n_types = 3;
std::array<std::size_t, n_types> n_elem_types{{0, 0, 0}};
while (getline(in, line))
while (std::getline(in, line))
{
if (line == "[RAINGAGES]")
{
Expand Down Expand Up @@ -1229,7 +1229,7 @@ std::string SwmmInterface::getArrayName(SwmmObject obj_type,
bool SwmmInterface::addRainGaugeTimeSeriesLocations(std::ifstream& in)
{
std::string line;
while (getline(in, line))
while (std::getline(in, line))
{
if (isSectionFinished(line))
break;
Expand Down Expand Up @@ -1261,7 +1261,7 @@ bool SwmmInterface::addRainGaugeTimeSeriesLocations(std::ifstream& in)
bool SwmmInterface::readPollutants(std::ifstream& in)
{
std::string line;
while (getline(in, line))
while (std::getline(in, line))
{
if (isSectionFinished(line))
return true;
Expand Down
19 changes: 9 additions & 10 deletions Applications/FileIO/TetGenInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <cstddef>
#include <fstream>
#include <range/v3/numeric/accumulate.hpp>
#include <string>

#include "BaseLib/FileTools.h"
Expand Down Expand Up @@ -94,7 +95,7 @@ std::size_t TetGenInterface::getNFacets(std::ifstream& input)
std::string line;
while (!input.fail())
{
getline(input, line);
std::getline(input, line);
if (input.fail())
{
ERR("TetGenInterface::getNFacets(): Error reading number of "
Expand Down Expand Up @@ -137,7 +138,7 @@ bool TetGenInterface::parseSmeshFacets(
std::size_t k(0);
while (k < nFacets && !input.fail())
{
getline(input, line);
std::getline(input, line);
if (input.fail())
{
ERR("TetGenInterface::parseFacets(): Error reading facet {:d}.", k);
Expand Down Expand Up @@ -201,11 +202,9 @@ bool TetGenInterface::parseSmeshFacets(
// the poly-file potentially defines a number of region attributes, these
// are ignored for now

std::size_t nTotalTriangles(0);
for (auto& surface : surfaces)
{
nTotalTriangles += surface->getNumberOfTriangles();
}
auto const nTotalTriangles = ranges::accumulate(
surfaces, std::size_t{0}, {},
[](auto const* surface) { return surface->getNumberOfTriangles(); });
if (nTotalTriangles == nFacets)
{
return true;
Expand Down Expand Up @@ -277,7 +276,7 @@ bool TetGenInterface::readNodesFromStream(std::ifstream& ins,
std::vector<MeshLib::Node*>& nodes)
{
std::string line;
getline(ins, line);
std::getline(ins, line);
std::size_t n_nodes;
std::size_t dim;
std::size_t n_attributes;
Expand All @@ -289,7 +288,7 @@ bool TetGenInterface::readNodesFromStream(std::ifstream& ins,
if (line.empty() || line.compare(0, 1, "#") == 0)
{
// this line is a comment - skip
getline(ins, line);
std::getline(ins, line);
continue;
}
// read header line
Expand Down Expand Up @@ -518,7 +517,7 @@ bool TetGenInterface::parseElements(std::ifstream& ins,
const unsigned offset = (_zero_based_idx) ? 0 : 1;
for (std::size_t k(0); k < n_tets && !ins.fail(); k++)
{
getline(ins, line);
std::getline(ins, line);
if (ins.fail())
{
ERR("TetGenInterface::parseElements(): Error reading tetrahedron "
Expand Down
7 changes: 4 additions & 3 deletions BaseLib/FileTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ bool substituteKeyword(std::string& result, std::string& parenthesized_string,
std::string const generated_fmt_string =
"{" + precision_specification +
type_specification[std::type_index(typeid(data))] + "}";
result = result.substr(0, begin) +
fmt::vformat(generated_fmt_string, fmt::make_format_args(data)) +
result.substr(end + 1, result.length() - (end + 1));
result.replace(
begin, end - begin + 1,
fmt::vformat(generated_fmt_string, fmt::make_format_args(data)));

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion BaseLib/StringTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ std::list<std::string> splitString(const std::string& str, char delim)
std::list<std::string> strList;
std::stringstream ss(str);
std::string item;
while (getline(ss, item, delim))
while (std::getline(ss, item, delim))
{
strList.push_back(item);
}
Expand Down
2 changes: 1 addition & 1 deletion ChemistryLib/CreateChemicalSolverInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ createChemicalSolverInterface<ChemicalSolver::SelfContained>(
auto const ls_name =
//! \ogs_file_param{prj__chemical_system__linear_solver}
config.getConfigParameter<std::string>("linear_solver");
auto& linear_solver = BaseLib::getOrError(
auto const& linear_solver = BaseLib::getOrError(
linear_solvers, ls_name,
"A linear solver with the given name does not exist.");

Expand Down
16 changes: 9 additions & 7 deletions ChemistryLib/PhreeqcIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,19 +799,20 @@ std::istream& operator>>(std::istream& in, PhreeqcIO& phreeqc_io)
case ItemType::EquilibriumReactant:
{
// Update amounts of equilibrium reactant
auto& equilibrium_reactant = BaseLib::findElementOrError(
equilibrium_reactants.begin(),
equilibrium_reactants.end(), compare_by_name,
"Could not find equilibrium reactant '" + item_name +
"'.");
auto const& equilibrium_reactant =
BaseLib::findElementOrError(
equilibrium_reactants.begin(),
equilibrium_reactants.end(), compare_by_name,
"Could not find equilibrium reactant '" +
item_name + "'.");
(*equilibrium_reactant.molality)[chemical_system_id] =
accepted_items[item_id];
break;
}
case ItemType::KineticReactant:
{
// Update amounts of kinetic reactants
auto& kinetic_reactant = BaseLib::findElementOrError(
auto const& kinetic_reactant = BaseLib::findElementOrError(
kinetic_reactants.begin(), kinetic_reactants.end(),
compare_by_name,
"Could not find kinetic reactant '" + item_name + "'.");
Expand All @@ -822,7 +823,8 @@ std::istream& operator>>(std::istream& in, PhreeqcIO& phreeqc_io)
case ItemType::SecondaryVariable:
{
assert(user_punch);
auto& secondary_variables = user_punch->secondary_variables;
auto const& secondary_variables =
user_punch->secondary_variables;
// Update values of secondary variables
auto& secondary_variable = BaseLib::findElementOrError(
secondary_variables.begin(), secondary_variables.end(),
Expand Down
Loading

0 comments on commit 06d4628

Please sign in to comment.