Skip to content

Commit

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

See merge request ogs/ogs!4721
  • Loading branch information
endJunction committed Aug 29, 2023
2 parents 9f947c0 + ff8d22c commit 099fdf0
Show file tree
Hide file tree
Showing 55 changed files with 168 additions and 194 deletions.
2 changes: 1 addition & 1 deletion Applications/DataHolderLib/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool Project::getUniqueName(std::string& name) const
cpName = cpName + "-" + std::to_string(count);
}

for (auto& mesh : _mesh_vec)
for (auto const& mesh : _mesh_vec)
{
if (cpName == mesh->getName())
{
Expand Down
8 changes: 4 additions & 4 deletions Applications/FileIO/GMSInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ void GMSInterface::writeBoreholesToGMS(

for (auto station_as_point : *stations)
{
auto* station = static_cast<GeoLib::StationBorehole*>(station_as_point);
std::vector<GeoLib::Point*> profile = station->getProfile();
std::vector<std::string> soilNames = station->getSoilNames();
// std::size_t idx = 0;
auto const* station =
static_cast<GeoLib::StationBorehole*>(station_as_point);
std::vector<GeoLib::Point*> const& profile = station->getProfile();
std::vector<std::string> const& soilNames = station->getSoilNames();
std::string current_soil_name;

std::size_t nLayers = profile.size();
Expand Down
2 changes: 1 addition & 1 deletion Applications/FileIO/Gmsh/GMSHPolygonTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ void GMSHPolygonTree::writeAdditionalPointData(std::size_t& pnt_id_offset,
std::size_t sfc_number,
std::ostream& out) const
{
if (auto* adaptive_mesh_density =
if (auto const* adaptive_mesh_density =
dynamic_cast<GMSHAdaptiveMeshDensity*>(&_mesh_density_strategy))
{
std::vector<GeoLib::Point*> steiner_pnts;
Expand Down
2 changes: 1 addition & 1 deletion Applications/FileIO/GocadIO/GocadAsciiReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ bool parseNodes(std::ifstream& in,

/// Parses the segments of the current line
bool parseLineSegments(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
6 changes: 3 additions & 3 deletions Applications/FileIO/GocadIO/GocadSGridReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,9 @@ void GocadSGridReader::applySplitInformation(
}
}

void GocadSGridReader::modifyElement(MeshLib::Element* hex,
MeshLib::Node const* node2sub,
MeshLib::Node* substitute_node)
void GocadSGridReader::modifyElement(MeshLib::Element const* const hex,
MeshLib::Node const* const node2sub,
MeshLib::Node* const substitute_node)
{
// get the node pointers of the cell
MeshLib::Node* const* hex_nodes(hex->getNodes());
Expand Down
2 changes: 1 addition & 1 deletion Applications/FileIO/GocadIO/GocadSGridReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class GocadSGridReader final
void applySplitInformation(
std::vector<MeshLib::Node*>& nodes,
std::vector<MeshLib::Element*> const& elements) const;
static void modifyElement(MeshLib::Element* hex,
static void modifyElement(MeshLib::Element const* hex,
MeshLib::Node const* node2sub,
MeshLib::Node* substitute_node);

Expand Down
2 changes: 1 addition & 1 deletion Applications/FileIO/Legacy/createSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ bool createSurface(GeoLib::Polyline const& ply,
WARN("Call to '{:s}' returned non-zero value {:d}.", gmsh_command,
gmsh_return_value);
}
auto surface_mesh = MeshLib::IO::readMeshFromFile(msh_file.string());
auto const* surface_mesh = MeshLib::IO::readMeshFromFile(msh_file.string());
if (!surface_mesh)
{
WARN("The surface mesh could not be created.");
Expand Down
6 changes: 2 additions & 4 deletions Applications/Utils/MeshEdit/NodeReordering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,9 @@ void reorderNonlinearNodes(MeshLib::Mesh& mesh)
}

BaseLib::makeVectorUnique(base_nodes,
[](MeshLib::Node* a, MeshLib::Node* b)
{ return a->getID() < b->getID(); });
MeshLib::idsComparator<MeshLib::Node*>);
BaseLib::makeVectorUnique(nonlinear_nodes,
[](MeshLib::Node* a, MeshLib::Node* b)
{ return a->getID() < b->getID(); });
MeshLib::idsComparator<MeshLib::Node*>);

std::vector<MeshLib::Node*>& allnodes =
const_cast<std::vector<MeshLib::Node*>&>(mesh.getNodes());
Expand Down
2 changes: 1 addition & 1 deletion ChemistryLib/CreateChemicalSolverInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ createChemicalSolverInterface<ChemicalSolver::PhreeqcKernel>(
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
18 changes: 10 additions & 8 deletions ChemistryLib/PhreeqcIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ std::ostream& operator<<(std::ostream& os, PhreeqcIO const& phreeqc_io)
return os;
}

void PhreeqcIO::callPhreeqc()
void PhreeqcIO::callPhreeqc() const
{
INFO("Phreeqc: Executing chemical calculation.");
if (RunFile(phreeqc_instance_id, _phreeqc_input_file.c_str()) != IPQ_OK)
Expand Down Expand Up @@ -826,11 +826,12 @@ std::istream& operator>>(std::istream& in, PhreeqcIO& phreeqc_io)
auto const& secondary_variables =
user_punch->secondary_variables;
// Update values of secondary variables
auto& secondary_variable = BaseLib::findElementOrError(
secondary_variables.begin(), secondary_variables.end(),
compare_by_name,
"Could not find secondary variable '" + item_name +
"'.");
auto const& secondary_variable =
BaseLib::findElementOrError(
secondary_variables.begin(),
secondary_variables.end(), compare_by_name,
"Could not find secondary variable '" + item_name +
"'.");
(*secondary_variable.value)[chemical_system_id] =
accepted_items[item_id];
break;
Expand Down Expand Up @@ -896,13 +897,14 @@ void PhreeqcIO::computeSecondaryVariable(
std::size_t const ele_id,
std::vector<GlobalIndexType> const& chemical_system_indices)
{
for (auto& kinetic_reactant : _chemical_system->kinetic_reactants)
for (auto const& kinetic_reactant : _chemical_system->kinetic_reactants)
{
(*kinetic_reactant.mesh_prop_molality)[ele_id] =
averageReactantMolality(kinetic_reactant, chemical_system_indices);
}

for (auto& equilibrium_reactant : _chemical_system->equilibrium_reactants)
for (auto const& equilibrium_reactant :
_chemical_system->equilibrium_reactants)
{
(*equilibrium_reactant.mesh_prop_molality)[ele_id] =
averageReactantMolality(equilibrium_reactant,
Expand Down
2 changes: 1 addition & 1 deletion ChemistryLib/PhreeqcIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class PhreeqcIO final : public ChemicalSolverInterface
private:
void writeInputsToFile(double const dt);

void callPhreeqc();
void callPhreeqc() const;

void readOutputsFromFile();

Expand Down
1 change: 1 addition & 0 deletions ChemistryLib/PhreeqcKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ static bool isHydrogen(std::string_view const element)
void PhreeqcKernel::setAqueousSolutions(
std::vector<GlobalVector*> const& process_solutions)
{
assert(!process_solutions.empty());
// Loop over chemical systems
std::size_t const num_chemical_systems = process_solutions[0]->size();
for (std::size_t chemical_system_id = 0;
Expand Down
2 changes: 1 addition & 1 deletion ChemistryLib/PhreeqcKernelData/CreateKineticReactant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ std::unique_ptr<Kinetics> createKineticReactants(
//! \ogs_file_param{prj__chemical_system__kinetic_reactants__kinetic_reactant__initial_amount}
reactant_config.getConfigParameter<double>("initial_amount");

auto amount = MeshLib::getOrCreateMeshProperty<double>(
auto* const amount = MeshLib::getOrCreateMeshProperty<double>(
const_cast<MeshLib::Mesh&>(mesh),
name,
MeshLib::MeshItemType::Node,
Expand Down
16 changes: 6 additions & 10 deletions GeoLib/GEOObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ const PolylineVec* GEOObjects::getPolylineVecObj(const std::string& name) const
bool GEOObjects::removePolylineVec(std::string const& name)
{
_callbacks->removePolylineVec(name);
auto it =
std::find_if(_ply_vecs.begin(), _ply_vecs.end(),
[&name](PolylineVec* v) { return v->getName() == name; });
auto it = std::find_if(_ply_vecs.begin(), _ply_vecs.end(),
[&name](PolylineVec const* const v)
{ return v->getName() == name; });
if (it != _ply_vecs.end())
{
delete *it;
Expand Down Expand Up @@ -342,7 +342,7 @@ void GEOObjects::getStationVectorNames(std::vector<std::string>& names) const
std::vector<std::string> GEOObjects::getGeometryNames() const
{
std::vector<std::string> names;
for (auto point : _pnt_vecs)
for (auto const point : _pnt_vecs)
{
if (point->getType() == PointVec::PointType::POINT)
{
Expand Down Expand Up @@ -385,10 +385,7 @@ int GEOObjects::mergeGeometries(std::vector<std::string> const& geo_names,

std::vector<std::size_t> pnt_offsets(n_geo_names, 0);

if (!mergePoints(geo_names, merged_geo_name, pnt_offsets))
{
return 1;
}
mergePoints(geo_names, merged_geo_name, pnt_offsets);

mergePolylines(geo_names, merged_geo_name, pnt_offsets);

Expand All @@ -397,7 +394,7 @@ int GEOObjects::mergeGeometries(std::vector<std::string> const& geo_names,
return 0;
}

bool GEOObjects::mergePoints(std::vector<std::string> const& geo_names,
void GEOObjects::mergePoints(std::vector<std::string> const& geo_names,
std::string& merged_geo_name,
std::vector<std::size_t>& pnt_offsets)
{
Expand Down Expand Up @@ -442,7 +439,6 @@ bool GEOObjects::mergePoints(std::vector<std::string> const& geo_names,

addPointVec(std::move(merged_points), merged_geo_name,
std::move(merged_pnt_names), 1e-6);
return true;
}

void GEOObjects::mergePolylines(std::vector<std::string> const& geo_names,
Expand Down
3 changes: 1 addition & 2 deletions GeoLib/GEOObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,8 @@ class GEOObjects final
* @param merged_geo_name The (new) name of the geometry resulting from
* merging.
* @param pnt_offsets offsets in the merged vector storing the points
* @return true, if merging the points succeeded, else false
*/
bool mergePoints(std::vector<std::string> const& geo_names,
void mergePoints(std::vector<std::string> const& geo_names,
std::string& merged_geo_name,
std::vector<std::size_t>& pnt_offsets);

Expand Down
7 changes: 3 additions & 4 deletions GeoLib/Grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,9 @@ Grid<POINT>::Grid(InputIterator first, InputIterator last,
{max[0] - min[0], max[1] - min[1], max[2] - min[2]}};

// enlarge delta
for (auto& d : delta)
{
d = std::nextafter(d, std::numeric_limits<double>::max());
}
constexpr double direction = std::numeric_limits<double>::max();
std::transform(begin(delta), end(delta), begin(delta),
[](double const d) { return std::nextafter(d, direction); });

assert(n_pnts > 0);
initNumberOfSteps(max_num_per_grid_cell, static_cast<std::size_t>(n_pnts),
Expand Down
2 changes: 1 addition & 1 deletion GeoLib/Polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ bool Polygon::getNextIntersectionPointPolygonLine(
}
else
{
for (auto polygon : _simple_polygon_list)
for (auto const* polygon : _simple_polygon_list)
{
for (auto seg_it(polygon->begin()); seg_it != polygon->end();
++seg_it)
Expand Down
7 changes: 0 additions & 7 deletions GeoLib/Polyline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,6 @@ LineSegment Polyline::getSegment(std::size_t i) const
_ply_pnts[_ply_pnt_ids[i + 1]], false);
}

LineSegment Polyline::getSegment(std::size_t i)
{
assert(i < getNumberOfSegments());
return LineSegment(_ply_pnts[_ply_pnt_ids[i]],
_ply_pnts[_ply_pnt_ids[i + 1]], false);
}

void Polyline::setPointID(std::size_t idx, std::size_t id)
{
assert(idx < _ply_pnt_ids.size());
Expand Down
1 change: 0 additions & 1 deletion GeoLib/Polyline.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ class Polyline : public GeoObject
std::vector<std::size_t> _ply_pnt_ids;

LineSegment getSegment(std::size_t i) const;
LineSegment getSegment(std::size_t i);
};

bool containsEdge (const Polyline& ply, std::size_t id0, std::size_t id1);
Expand Down
16 changes: 6 additions & 10 deletions GeoLib/QuadTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,11 @@ template <typename POINT> class QuadTree
return false;
}

if (!_is_leaf) {
for (auto& child : _children)
{
if (child->addPoint(pnt))
{
return true;
}
}
return false;
if (!_is_leaf)
{
return std::any_of(begin(_children), end(_children),
[&pnt](auto* child)
{ return child->addPoint(pnt); });
}

// check if point is already in quadtree
Expand Down Expand Up @@ -540,7 +536,7 @@ template <typename POINT> class QuadTree
_is_leaf = false;
}

static bool needToRefine (QuadTree<POINT>* node)
static bool needToRefine(QuadTree<POINT> const* const node)
{
QuadTree<POINT>* north_neighbor (node->getNorthNeighbor ());
if (north_neighbor != nullptr)
Expand Down
5 changes: 3 additions & 2 deletions GeoLib/Station.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@

namespace GeoLib
{
Station::Station(double x, double y, double z, std::string name)
Station::Station(double const x, double const y, double const z,
std::string name)
: Point(x, y, z), _name(std::move(name))
{
}

Station::Station(Point* coords, std::string name)
Station::Station(Point const* const coords, std::string name)
: Point(*coords), _name(std::move(name))
{
}
Expand Down
2 changes: 1 addition & 1 deletion GeoLib/Station.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Station : public Point
explicit Station(double x = 0.0, double y = 0.0, double z = 0.0,
std::string name = "");

explicit Station(Point* coords, std::string name = "");
explicit Station(Point const* coords, std::string name = "");

/**
* Constructor copies the source object
Expand Down
4 changes: 1 addition & 3 deletions MaterialLib/MPL/CheckMaterialSpatialDistributionMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ void checkMaterialSpatialDistributionMap(
ContainerLiquid const& required_properties_liquid_phase,
ContainerGas const& required_properties_gas_phase)
{
for (auto const& element : mesh.getElements())
for (auto const element_id : mesh.getElements() | MeshLib::views::ids)
{
auto const element_id = element->getID();

auto const& medium = *media_map.getMedium(element_id);
if (!required_properties_medium.empty())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,9 @@ PermeabilityMohrCoulombFailureIndexModel<DisplacementDim>::value(
if (f >= 1.0)
{
const double exp_value = std::exp(b_ * f);
for (auto& k_i : k_data)
{
k_i = std::min(k_i + kr_ * exp_value, k_max_);
}
std::transform(begin(k_data), end(k_data), begin(k_data),
[&](double const k_i)
{ return std::min(k_i + kr_ * exp_value, k_max_); });
}

// Local coordinate transformation is only applied for the case that the
Expand Down
2 changes: 1 addition & 1 deletion MeshGeoToolsLib/AppendLinesAlongPolyline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ std::unique_ptr<MeshLib::Mesh> appendLinesAlongPolylines(
// for each polyline
for (std::size_t k(0); k < n_ply; k++)
{
auto* ply = ply_vec.getVector()[k];
auto const* const ply = ply_vec.getVector()[k];

// search nodes on the polyline
MeshGeoToolsLib::MeshNodesAlongPolyline mshNodesAlongPoly(
Expand Down
2 changes: 1 addition & 1 deletion MeshGeoToolsLib/MeshNodesAlongSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ MeshNodesAlongSurface::MeshNodesAlongSurface(MeshLib::Mesh const& mesh,
// loop over all nodes
for (std::size_t i = 0; i < n_nodes; i++)
{
auto* node = mesh_nodes[i];
auto const* const node = mesh_nodes[i];
if (!sfc.isPntInBoundingVolume(*node, epsilon_radius))
{
continue;
Expand Down
Loading

0 comments on commit 099fdf0

Please sign in to comment.