Skip to content

Commit 525f8a9

Browse files
committed
Remove redundant num_bodies from wave classes; infer from HydroSystem
num_bodies was duplicated across wave constructors, IrregularWaveParams, and HydroSystem - always the same value. Move ownership to WaveBase and set it automatically in HydroSystem::AddWaves(), eliminating a source of configuration errors and simplifying the wave creation API.
1 parent 5359bc7 commit 525f8a9

31 files changed

Lines changed: 43 additions & 76 deletions

demos/f3of/demo_f3of_dt1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ int main(int argc, char* argv[]) {
153153
// ---------------- End DT specific set up, now add hydro forces ----------------------------------
154154

155155
// define wave parameters (not used in this demo TODO have hydroforces constructor without hydro inputs)
156-
auto default_dont_add_waves = std::make_shared<NoWave>(3);
156+
auto default_dont_add_waves = std::make_shared<NoWave>();
157157

158158
// set up hydro forces
159159
std::vector<std::shared_ptr<ChBody>> bodies;

demos/f3of/demo_f3of_dt2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ int main(int argc, char* argv[]) {
158158
system.AddLink(base_rev);
159159

160160
// define wave parameters (not used in this demo TODO have hydroforces constructor without hydro inputs)
161-
auto default_dont_add_waves = std::make_shared<NoWave>(3);
161+
auto default_dont_add_waves = std::make_shared<NoWave>();
162162

163163
// set up hydro forces
164164
std::vector<std::shared_ptr<ChBody>> bodies;

demos/f3of/demo_f3of_dt3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ int main(int argc, char* argv[]) {
155155
anchor->SetConstrainedCoords(true, true, true, true, true, true); // x, y, z, Rx, Ry, Rz
156156

157157
// define wave parameters (not used in this demo TODO have hydroforces constructor without hydro inputs)
158-
auto default_dont_add_waves = std::make_shared<NoWave>(3);
158+
auto default_dont_add_waves = std::make_shared<NoWave>();
159159

160160
// set up hydro forces
161161
std::vector<std::shared_ptr<ChBody>> bodies;

demos/oswec/demo_oswec_decay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ int main(int argc, char* argv[]) {
184184
revolute->Initialize(base_body, flap_body, ChFramed(ChVector3d(0.0, 0.0, -8.9), revoluteRot));
185185
system.AddLink(revolute);
186186

187-
auto default_dont_add_waves = std::make_shared<NoWave>(2);
187+
auto default_dont_add_waves = std::make_shared<NoWave>();
188188

189189
//// attach hydrodynamic forces to body
190190
std::vector<std::shared_ptr<ChBody>> bodies;

demos/oswec/demo_oswec_reg_waves.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ int main(int argc, char* argv[]) {
198198
bodies.push_back(flap_body);
199199
bodies.push_back(base_body);
200200

201-
auto my_hydro_inputs = std::make_shared<RegularWave>(static_cast<unsigned int>(bodies.size()));
201+
auto my_hydro_inputs = std::make_shared<RegularWave>();
202202
my_hydro_inputs->regular_wave_amplitude_ = 0.01;
203203
my_hydro_inputs->regular_wave_omega_ = (2 * CH_PI) / (periods[reg_wave_num - 1]);
204204

demos/rm3/demo_rm3_decay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ int main(int argc, char* argv[]) {
116116
prismatic_pto->SetDampingCoefficient(0.0);
117117
system.AddLink(prismatic_pto);
118118

119-
auto default_dont_add_waves = std::make_shared<NoWave>(2);
119+
auto default_dont_add_waves = std::make_shared<NoWave>();
120120

121121
// attach hydrodynamic forces to body
122122
std::vector<std::shared_ptr<ChBody>> bodies;

demos/rm3/demo_rm3_reg_waves.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ int main(int argc, char* argv[]) {
133133
bodies.push_back(plate_body2);
134134

135135
// define wave parameters
136-
auto my_hydro_inputs = std::make_shared<RegularWave>(static_cast<unsigned int>(bodies.size()));
136+
auto my_hydro_inputs = std::make_shared<RegularWave>();
137137
my_hydro_inputs->regular_wave_amplitude_ = 1.0;
138138
my_hydro_inputs->regular_wave_omega_ = 2.10;
139139

demos/sphere/demo_sphere_decay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ int main(int argc, char* argv[]) {
8585
// my_hydro_inputs.regular_wave_amplitude = 0.022;
8686
// my_hydro_inputs.regular_wave_omega = 2.10;
8787

88-
auto default_dont_add_waves = std::make_shared<NoWave>(1);
88+
auto default_dont_add_waves = std::make_shared<NoWave>();
8989

9090
// attach hydrodynamic forces to body
9191
std::vector<std::shared_ptr<ChBody>> bodies;

demos/sphere/demo_sphere_irreg_waves.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ int main(int argc, char* argv[]) {
103103
bodies.push_back(sphereBody);
104104

105105
IrregularWaveParams wave_inputs;
106-
wave_inputs.num_bodies_ = (unsigned int)bodies.size();
107106
wave_inputs.simulation_dt_ = timestep;
108107
wave_inputs.simulation_duration_ = simulationDuration;
109108
wave_inputs.ramp_duration_ = 60.0;

demos/sphere/demo_sphere_irreg_waves_eta_import.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ int main(int argc, char* argv[]) {
106106
std::cout << "Defining irregular wave input parameters..." << std::endl;
107107
IrregularWaveParams params;
108108
std::cout << "bodies.size() = " << bodies.size() << std::endl;
109-
params.num_bodies_ = (unsigned int)bodies.size();
110109
params.simulation_dt_ = timestep;
111110
params.simulation_duration_ = simulationDuration;
112111
params.ramp_duration_ = 0.0;

0 commit comments

Comments
 (0)