Skip to content

Commit

Permalink
Bug Fix: Parse required before optional (Exawind#642)
Browse files Browse the repository at this point in the history
* Bug Fix: Parse required before optional

* Remove computations from parameter gathering

* Cpp-Check
  • Loading branch information
psakievich authored Jun 23, 2022
1 parent ad8e321 commit e640d42
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions amr-wind/wind_energy/actuator/disk/Joukowsky_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ void required_parameters(JoukowskyData& meta, const utils::ActParser& pp)
pp.get("num_points_t", meta.num_vel_pts_t);
pp.get("num_points_r", meta.num_vel_pts_r);
pp.getarr("angular_velocity", meta.angular_velocity);
meta.num_force_pts = meta.num_vel_pts_r * meta.num_vel_pts_t;
meta.num_vel_pts = meta.num_force_pts * 2;
meta.dr = 0.5 * meta.diameter / meta.num_vel_pts_r;
}

void parse_and_gather_params(const utils::ActParser& pp, JoukowskyData& data)
{
check_for_parse_conflicts(pp);
optional_parameters(data, pp);
required_parameters(data, pp);
optional_parameters(data, pp);
ops::base::final_checks(data);
data.num_force_pts = data.num_vel_pts_r * data.num_vel_pts_t;
data.num_vel_pts = data.num_force_pts * 2;
data.dr = 0.5 * data.diameter / data.num_vel_pts_r;
}

void prepare_netcdf_file(
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/wind_energy/actuator/disk/disk_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void collect_parse_dependencies(
const std::string& p2,
std::ostringstream& ss);

void check_error_stream(std::ostringstream& error_collector);
void check_error_stream(const std::ostringstream& error_collector);

void required_parameters(DiskBaseData& meta, const utils::ActParser& pp);

Expand Down
2 changes: 1 addition & 1 deletion amr-wind/wind_energy/actuator/disk/disk_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void optional_parameters(DiskBaseData& meta, const utils::ActParser& pp)
}
}

void check_error_stream(std::ostringstream& error_collector)
void check_error_stream(const std::ostringstream& error_collector)
{
if (!error_collector.str().empty()) {
amrex::Abort(
Expand Down
10 changes: 5 additions & 5 deletions amr-wind/wind_energy/actuator/disk/uniform_ct_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ void optional_parameters(DiskBaseData& meta, const utils::ActParser& pp)
ops::base::optional_parameters(meta, pp);
// params for the sampling disk
pp.query("num_points_t", meta.num_vel_pts_t);
// 2x 1 for sampling up stream and one for sampling at the disk
meta.num_vel_pts = meta.num_vel_pts_r * meta.num_vel_pts_t * 2;
pp.query("spreading_type", meta.spreading_type);
}
void required_parameters(DiskBaseData& meta, const utils::ActParser& pp)
{
ops::base::required_parameters(meta, pp);
pp.get("num_points_r", meta.num_force_pts);
meta.num_vel_pts_r = meta.num_force_pts;
meta.dr = 0.5 * meta.diameter / meta.num_force_pts;
}
void parse_and_gather_params(const utils::ActParser& pp, UniformCtData& data)
{
check_for_parse_conflicts(pp);
optional_parameters(data, pp);
required_parameters(data, pp);
optional_parameters(data, pp);
ops::base::final_checks(data);
data.num_vel_pts_r = data.num_force_pts;
data.dr = 0.5 * data.diameter / data.num_force_pts;
// 2x 1 for sampling up stream and one for sampling at the disk
data.num_vel_pts = data.num_vel_pts_r * data.num_vel_pts_t * 2;
}
} // namespace uniformct
} // namespace ops
Expand Down

0 comments on commit e640d42

Please sign in to comment.