Skip to content

Commit 9f683e6

Browse files
committed
Fix miscellaneous compilation warnings
1 parent f5b05e8 commit 9f683e6

16 files changed

Lines changed: 50 additions & 54 deletions

demos/oswec/demo_oswec_decay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ std::array<double, 3> rotate_vector_3d(std::array<double, 3> vector,
4141
std::array<double, 3> axis,
4242
double angle_in_degrees) {
4343
// Convert the angle from degrees to radians
44-
double angle_in_radians = angle_in_degrees * M_PI / 180.0;
44+
double angle_in_radians = angle_in_degrees * CH_DEG_TO_RAD;
4545

4646
// Normalize the axis vector
4747
axis = normalize(axis);

demos/oswec/demo_oswec_reg_waves.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ std::array<double, 3> rotate_vector_3d(std::array<double, 3> vector,
4141
std::array<double, 3> axis,
4242
double angle_in_degrees) {
4343
// Convert the angle from degrees to radians
44-
double angle_in_radians = angle_in_degrees * M_PI / 180.0;
44+
double angle_in_radians = angle_in_degrees * CH_DEG_TO_RAD;
4545

4646
// Normalize the axis vector
4747
axis = normalize(axis);
@@ -64,7 +64,7 @@ std::array<double, 3> add_vectors(std::array<double, 3> v1, std::array<double, 3
6464
int main(int argc, char* argv[]) {
6565
std::vector<double> periods = {4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0,
6666
18.5, 19.0, 19.25, 19.5, 20.0, 21.0, 22.0, 24.0};
67-
int reg_wave_num_max = periods.size();
67+
int reg_wave_num_max = (int)periods.size();
6868

6969
for (int reg_wave_num = 1; reg_wave_num <= reg_wave_num_max; ++reg_wave_num) {
7070
std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n";
@@ -111,9 +111,8 @@ int main(int argc, char* argv[]) {
111111
std::array<double, 3> origin_to_hinge = {0, 0, -8.9};
112112
std::array<double, 3> hinge_to_cg = {0, 0, 5};
113113
std::array<double, 3> axis = {0, 1, 0};
114-
double angle_in_degrees = 0.0;
115114

116-
// std::array<double, 3> rotated_hinge_to_cg = rotate_vector_3d(hinge_to_cg, axis, angle_in_degrees);
115+
// std::array<double, 3> rotated_hinge_to_cg = rotate_vector_3d(hinge_to_cg, axis, 0);
117116

118117
// std::array<double, 3> new_cg = add_vectors(origin_to_hinge, rotated_hinge_to_cg);
119118

@@ -142,10 +141,9 @@ int main(int argc, char* argv[]) {
142141
// define the float's initial conditions
143142
system.Add(flap_body);
144143
flap_body->SetName("body1");
145-
auto ang_rad = CH_PI / 18.0;
146144
// flap_body->SetPos(ChVector3d(new_cg[0], new_cg[1], new_cg[2]));
147145
flap_body->SetPos(ChVector3d(0.0, 0.0, -3.9));
148-
// flap_body->SetRot(QuatFromAngleY(ang_rad));
146+
// flap_body->SetRot(QuatFromAngleY(CH_PI / 18.0));
149147
flap_body->SetMass(127000.0);
150148
flap_body->SetInertiaXX(ChVector3d(1.85e6, 1.85e6, 1.85e6));
151149
// notes: mass and inertia added to added mass and system mass correctly.

demos/sphere/demo_sphere_irreg_waves.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ int main(int argc, char* argv[]) {
105105
bodies.push_back(sphereBody);
106106

107107
IrregularWaveParams wave_inputs;
108-
wave_inputs.num_bodies_ = bodies.size();
108+
wave_inputs.num_bodies_ = (unsigned int)bodies.size();
109109
wave_inputs.simulation_dt_ = timestep;
110110
wave_inputs.simulation_duration_ = simulationDuration;
111111
wave_inputs.ramp_duration_ = 60.0;
@@ -153,7 +153,7 @@ int main(int argc, char* argv[]) {
153153
// Create a visualization material
154154
auto fse_texture = chrono_types::make_shared<ChVisualMaterial>();
155155
fse_texture->SetDiffuseColor(ChColor(0.026f, 0.084f, 0.168f));
156-
fse_texture->SetOpacity(0.1);
156+
fse_texture->SetOpacity(0.1f);
157157
fse_mesh->GetVisualShape(0)->SetMaterial(0, fse_texture);
158158

159159
// for profiling

demos/sphere/demo_sphere_irreg_waves_eta_import.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ int main(int argc, char* argv[]) {
108108
std::cout << "Defining irregular wave input parameters..." << std::endl;
109109
IrregularWaveParams params;
110110
std::cout << "bodies.size() = " << bodies.size() << std::endl;
111-
params.num_bodies_ = bodies.size();
111+
params.num_bodies_ = (unsigned int)bodies.size();
112112
params.simulation_dt_ = timestep;
113113
params.simulation_duration_ = simulationDuration;
114114
params.ramp_duration_ = 0.0;

demos/sphere/demo_sphere_reg_waves.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int main(int argc, char* argv[]) {
2424
0.897597901, 0.785398163, 0.698131701, 0.628318531, 0.571198664};
2525
double task10_damping_coeffs[] = {398736.034, 118149.758, 90080.857, 161048.558, 322292.419,
2626
479668.979, 633979.761, 784083.286, 932117.647, 1077123.445};
27-
int reg_wave_num_max = task10_wave_amps.size();
27+
int reg_wave_num_max = (int)task10_wave_amps.size();
2828

2929
std::cout << "Num waves: " << reg_wave_num_max << std::endl;
3030

src/hydro/config/setup_from_yaml.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88

99
#include "setup_from_yaml.h"
1010
#include "config_loader.h"
11-
#include <hydroc/hydro_system.h> // For HydroSystem
11+
#include <hydroc/hydro_system.h>
1212
#include <hydroc/waves/wave_base.h>
1313
#include <hydroc/waves/regular_wave.h>
1414
#include <hydroc/waves/irregular_wave.h>
15-
#include <hydroc/logging.h> // For Logger
15+
#include <hydroc/logging.h>
1616
#include "../radiation/radiation_rirf_processing.h" // For TaperedDirectOptions (canonical type)
1717
#include "../force_components/radiation_component.h" // For RadiationConvolutionMode (canonical type)
1818
#include <filesystem>
1919
#include <iostream>
2020
#include <stdexcept>
21-
#include <cmath> // For M_PI
21+
#include <cmath>
2222
#include <unordered_map>
2323

2424
#ifndef M_PI
@@ -49,14 +49,15 @@ std::shared_ptr<WaveBase> CreateWaveFromSettings(const WaveSettings& wave_settin
4949

5050
if (type == "regular") {
5151
auto regular_wave = std::make_shared<RegularWave>(num_bodies);
52-
52+
5353
// Set wave parameters
54-
regular_wave->regular_wave_amplitude_ = wave_settings.height / 2.0; // Convert height to amplitude
55-
regular_wave->regular_wave_omega_ = 2.0 * M_PI / wave_settings.period; // Convert period to angular frequency
56-
regular_wave->regular_wave_phase_ = wave_settings.phase;
57-
58-
hydroc::debug::LogDebug(std::string("Attached wave model: RegularWave, H=") + std::to_string(wave_settings.height) +
59-
"m, T=" + std::to_string(wave_settings.period) + "s");
54+
regular_wave->regular_wave_amplitude_ = wave_settings.height / 2; // Convert height to amplitude
55+
regular_wave->regular_wave_omega_ = CH_2PI / wave_settings.period; // Convert period to angular frequency
56+
regular_wave->regular_wave_phase_ = wave_settings.phase;
57+
58+
hydroc::debug::LogDebug(std::string("Attached wave model: RegularWave, H=") +
59+
std::to_string(wave_settings.height) + "m, T=" + std::to_string(wave_settings.period) +
60+
"s");
6061

6162
return regular_wave;
6263

@@ -163,7 +164,7 @@ std::unique_ptr<HydroSystem> SetupHydroFromYAML(
163164
}
164165

165166
// Create wave object from settings (system-wide, not per-body)
166-
auto wave = CreateWaveFromSettings(hydro_data.waves, matched_bodies.size(),
167+
auto wave = CreateWaveFromSettings(hydro_data.waves, (unsigned int) matched_bodies.size(),
167168
timestep, sim_duration, ramp_duration);
168169

169170
// Create and initialize HydroSystem (multibody: all matched bodies passed in)

src/hydro/force_components/radiation_component.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ double RadiationComponent::GetRIRFval(int row, int col, int st) {
8484
}
8585

8686
int body_index = row / kDofPerBody;
87-
int col_dof = col % kDofPerBody;
8887
int row_dof = row % kDofPerBody;
8988

9089
if (convolution_mode_ == RadiationConvolutionMode::TaperedDirect) {

src/hydro/io/h5_reader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ Eigen::VectorXd HydroData::GetRIRFTimeVector() const {
331331
// check if all time vectors are the same within tolerance
332332
auto& rirf_time_vector = body_data_[0].rirf_time_vector;
333333
for (size_t ii = 1; ii < body_data_.size(); ii++) {
334-
for (size_t jj = 0; jj < body_data_[ii].rirf_time_vector.size(); jj++) {
334+
for (Eigen::Index jj = 0; jj < body_data_[ii].rirf_time_vector.size(); jj++) {
335335
if (abs(body_data_[ii].rirf_time_vector[jj] - rirf_time_vector[jj]) > tol) {
336336
throw std::runtime_error(
337337
"RIRF time vectors have to be exactly the same for all bodies. Difference found in body " +

src/hydro/io/simulation_export.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -957,9 +957,9 @@ void SimulationExporter::Finalize() {
957957
}
958958
}
959959
// Final succinct info line in Quiet mode
960-
int bodies = static_cast<int>(impl_->bodies.size());
961-
int dampers = static_cast<int>(impl_->tsdas.size() + impl_->rsdas.size());
962-
int samples = static_cast<int>(impl_->time.size());
960+
////int bodies = static_cast<int>(impl_->bodies.size());
961+
////int dampers = static_cast<int>(impl_->tsdas.size() + impl_->rsdas.size());
962+
////int samples = static_cast<int>(impl_->time.size());
963963
// meta/run runtime details (if provided via options)
964964
{
965965
auto g_run = impl_->writer.RequireGroup("/meta/run");

src/hydro/waves/irregular_wave.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ double IrregularWaves::GetElevation(const Eigen::Vector3d& position, double time
152152
Eigen::VectorXd IrregularWaves::GetForceAtTime(double t) {
153153
unsigned int total_dofs = params_.num_bodies_ * 6;
154154
Eigen::VectorXd f(total_dofs);
155-
for (int i = 0; i < total_dofs; i++) {
155+
for (unsigned int i = 0; i < total_dofs; i++) {
156156
f[i] = 0.0;
157157
}
158158

159-
for (int body = 0; body < params_.num_bodies_; body++) {
159+
for (unsigned int body = 0; body < params_.num_bodies_; body++) {
160160
for (int dof = 0; dof < 6; ++dof) {
161161
double f_dof = ExcitationConvolution(body, dof, t);
162162
unsigned int b_offset = body * 6;
@@ -281,7 +281,7 @@ void IrregularWaves::CreateFreeSurfaceElevation() {
281281
void IrregularWaves::ResampleIRF(double dt) {
282282
for (unsigned int b = 0; b < params_.num_bodies_; b++) {
283283
auto& time_array = ex_irf_time_sampled_[b];
284-
auto& width_array = ex_irf_width_sampled_[b];
284+
////auto& width_array = ex_irf_width_sampled_[b];
285285
auto& val_array = ex_irf_sampled_[b];
286286

287287
auto time_array_old = time_array;
@@ -331,12 +331,11 @@ double IrregularWaves::ExcitationConvolution(int body, int dof, double time) {
331331
} else if (t_tau >= tmax) {
332332
idx = static_cast<int>(free_surface_time_sampled_.size()) - 2;
333333
} else {
334-
idx = get_lower_index(t_tau, free_surface_time_sampled_);
334+
idx = (int)get_lower_index(t_tau, free_surface_time_sampled_);
335335
}
336336

337-
for (size_t j = 0; j < irf_time_array.size(); ++j) {
338-
double tau = irf_time_array[j];
339-
double t_tau = time - tau;
337+
for (Eigen::Index j = 0; j < irf_time_array.size(); ++j) {
338+
t_tau = time - irf_time_array[j];
340339
if (tmin <= t_tau && t_tau <= tmax) {
341340
while (free_surface_time_sampled_[idx] > t_tau) {
342341
idx -= 1;
@@ -357,8 +356,9 @@ double IrregularWaves::ExcitationConvolution(int body, int dof, double time) {
357356
auto w2 = 1.0 - w1;
358357
eta_val = w1 * eta1 + w2 * eta2;
359358
} else {
360-
throw std::runtime_error("Excitation convolution: wrong tau value " + std::to_string(tau) +
361-
" not between " + std::to_string(t1) + " and " + std::to_string(t2) + ".");
359+
throw std::runtime_error("Excitation convolution: wrong tau value " +
360+
std::to_string(irf_time_array[j]) + " not between " + std::to_string(t1) +
361+
" and " + std::to_string(t2) + ".");
362362
}
363363

364364
f_ex += irf_val_mat(dof, j) * eta_val * irf_width_array[j];

0 commit comments

Comments
 (0)