Skip to content

Commit

Permalink
Merge pull request #5866 from tjhei/more-tidy-fixes
Browse files Browse the repository at this point in the history
several clang-tidy fixes
  • Loading branch information
gassmoeller authored Jun 11, 2024
2 parents 590e4e2 + b4a35a8 commit d1cf3b8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 73 deletions.
4 changes: 2 additions & 2 deletions include/aspect/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -1164,8 +1164,8 @@ namespace aspect
* @param random_number_generator a reference to a mt19937 random number generator.
*/
std::vector<Tensor<2,3>>
rotation_matrices_random_draw_volume_weighting(const std::vector<double> volume_fractions,
const std::vector<Tensor<2,3>> rotation_matrices,
rotation_matrices_random_draw_volume_weighting(const std::vector<double> &volume_fractions,
const std::vector<Tensor<2,3>> &rotation_matrices,
const unsigned int n_output_matrices,
std::mt19937 &random_number_generator);

Expand Down
1 change: 1 addition & 0 deletions source/simulator/introspection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ namespace aspect
make_extractor_sequence (const std::vector<unsigned int> &compositional_fields)
{
std::vector<FEValuesExtractors::Scalar> x;
x.reserve(compositional_fields.size());
for (const unsigned int compositional_field : compositional_fields)
x.emplace_back(compositional_field);
return x;
Expand Down
69 changes: 1 addition & 68 deletions source/simulator/parameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,7 @@ namespace aspect
+ ">."));

// the easy part: get the name of the compositional field
const std::string key = split_parts[0];
const std::string &key = split_parts[0];

// check that the names used are actually names of fields,
// are solved by particles, and are unique in this list
Expand Down Expand Up @@ -2167,73 +2167,6 @@ namespace aspect
}
prm.leave_subsection();

prm.enter_subsection ("Boundary traction model");
{
const std::vector<std::string> x_prescribed_traction_boundary_indicators
= Utilities::split_string_list
(prm.get ("Prescribed traction boundary indicators"));
for (const auto &p : x_prescribed_traction_boundary_indicators)
{
// each entry has the format (white space is optional):
// <id> [x][y][z] : <value (might have spaces)>
//
// first tease apart the two halves
const std::vector<std::string> split_parts = Utilities::split_string_list (p, ':');
AssertThrow (split_parts.size() == 2,
ExcMessage ("The format for prescribed traction boundary indicators "
"requires that each entry has the form `"
"<id> [x][y][z] : <value>', but there does not "
"appear to be a colon in the entry <"
+ p
+ ">."));

// the easy part: get the value
const std::string value = split_parts[1];

// now for the rest. since we don't know whether there is a
// component selector, start reading at the end and subtracting
// letters x, y and z
std::string key_and_comp = split_parts[0];
std::string comp;
while ((key_and_comp.size()>0) &&
((key_and_comp[key_and_comp.size()-1] == 'x')
||
(key_and_comp[key_and_comp.size()-1] == 'y')
||
((key_and_comp[key_and_comp.size()-1] == 'z') && (dim==3))))
{
comp += key_and_comp[key_and_comp.size()-1];
key_and_comp.erase (--key_and_comp.end());
}

// we've stopped reading component selectors now. there are three
// possibilities:
// - no characters are left. this means that key_and_comp only
// consisted of a single word that only consisted of 'x', 'y'
// and 'z's. then this would have been a mistake to classify
// as a component selector, and we better undo it
// - the last character of key_and_comp is not a whitespace. this
// means that the last word in key_and_comp ended in an 'x', 'y'
// or 'z', but this was not meant to be a component selector.
// in that case, put these characters back.
// - otherwise, we split successfully. eat spaces that may be at
// the end of key_and_comp to get key
if (key_and_comp.size() == 0)
key_and_comp.swap (comp);
else if (key_and_comp[key_and_comp.size()-1] != ' ')
{
key_and_comp += comp;
comp = "";
}
else
{
while ((key_and_comp.size()>0) && (key_and_comp[key_and_comp.size()-1] == ' '))
key_and_comp.erase (--key_and_comp.end());
}
}
}
prm.leave_subsection ();

prm.enter_subsection ("Boundary heat flux model");
{
try
Expand Down
6 changes: 3 additions & 3 deletions source/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ namespace aspect
{
// Check for environment variable override to ASPECT_SOURCE_DIR
char const *ASPECT_SOURCE_DIR_env = getenv("ASPECT_SOURCE_DIR");
if (ASPECT_SOURCE_DIR_env != NULL)
if (ASPECT_SOURCE_DIR_env != nullptr)
{
return Utilities::replace_in_string(location,
"$ASPECT_SOURCE_DIR",
Expand Down Expand Up @@ -3042,8 +3042,8 @@ namespace aspect


std::vector<Tensor<2,3>>
rotation_matrices_random_draw_volume_weighting(const std::vector<double> volume_fraction,
const std::vector<Tensor<2,3>> rotation_matrices,
rotation_matrices_random_draw_volume_weighting(const std::vector<double> &volume_fraction,
const std::vector<Tensor<2,3>> &rotation_matrices,
const unsigned int n_output_matrices,
std::mt19937 &random_number_generator)
{
Expand Down

0 comments on commit d1cf3b8

Please sign in to comment.