Skip to content

Commit 7c8d1b0

Browse files
committed
Use nullptr in HydroForces and remove using namespace from added_mass header
1 parent 13f9e79 commit 7c8d1b0

3 files changed

Lines changed: 20 additions & 16 deletions

File tree

include/hydroc/coupling/added_mass.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
#include <chrono/physics/ChLoad.h>
2222
#include <chrono/physics/ChSystem.h>
2323

24-
using namespace chrono;
25-
2624
// =============================================================================
2725
class ChLoadAddedMass : public chrono::ChLoadCustomMultiple {
2826
public:
@@ -39,8 +37,8 @@ class ChLoadAddedMass : public chrono::ChLoadCustomMultiple {
3937
* @param system pointer to system containing the bodies, used for getting system mass matrix size at any time.
4038
*/
4139
ChLoadAddedMass(const std::vector<HydroData::BodyInfo>& body_info_struct,
42-
std::vector<std::shared_ptr<ChLoadable>>& bodies,
43-
ChSystem* system);
40+
std::vector<std::shared_ptr<chrono::ChLoadable>>& bodies,
41+
chrono::ChSystem* system);
4442

4543
/**
4644
* @brief "Virtual" copy constructor (covariant return type). Required from chrono inheritance.
@@ -56,8 +54,8 @@ class ChLoadAddedMass : public chrono::ChLoadCustomMultiple {
5654
* Called automatically at each Update().
5755
* The M*a term is not added: to this end one could use LoadIntLoadResidual_Mv afterward.
5856
*/
59-
virtual void ComputeQ(ChState* state_x, ///< state position to evaluate Q
60-
ChStateDelta* state_w ///< state speed to evaluate Q
57+
virtual void ComputeQ(chrono::ChState* state_x, ///< state position to evaluate Q
58+
chrono::ChStateDelta* state_w ///< state speed to evaluate Q
6159
) override {}
6260

6361
/**
@@ -71,7 +69,7 @@ class ChLoadAddedMass : public chrono::ChLoadCustomMultiple {
7169
* @param state_x state position to evaluate jacobians
7270
* @param state_w state speed to evaluate jacobians
7371
*/
74-
virtual void ComputeJacobian(ChState* state_x, ChStateDelta* state_w) override;
72+
virtual void ComputeJacobian(chrono::ChState* state_x, chrono::ChStateDelta* state_w) override;
7573

7674
/**
7775
* @brief Computes LoadIntLoadResidual_Mv for vector w, const c, and vector R. Also carried over from chrono
@@ -84,12 +82,14 @@ class ChLoadAddedMass : public chrono::ChLoadCustomMultiple {
8482
* @param w the w vector
8583
* @param c a scaling factor
8684
*/
87-
virtual void LoadIntLoadResidual_Mv(ChVectorDynamic<>& R, const ChVectorDynamic<>& w, const double c) override;
85+
virtual void LoadIntLoadResidual_Mv(chrono::ChVectorDynamic<>& R,
86+
const chrono::ChVectorDynamic<>& w,
87+
const double c) override;
8888

8989
private:
90-
ChSystem* system;
91-
ChMatrixDynamic<double> infinite_added_mass; ///< added mass at infinite frequency in global coordinates
92-
ChMatrixDynamic<double>
90+
chrono::ChSystem* system;
91+
chrono::ChMatrixDynamic<double> infinite_added_mass; ///< added mass at infinite frequency in global coordinates
92+
chrono::ChMatrixDynamic<double>
9393
infinite_added_mass_system; ///< added mass at infinite frequency in global coordinates (system matrix)
9494
virtual bool IsStiff() override { return true; } // this to force the use of the inertial M, R and K matrices
9595
};

src/hydro/chrono/added_mass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#include "chrono/physics/ChBody.h"
1414

15+
using namespace chrono;
16+
1517
ChLoadAddedMass::ChLoadAddedMass(const std::vector<HydroData::BodyInfo>& user_h5_body_data,
1618
std::vector<std::shared_ptr<ChLoadable>>& bodies,
1719
ChSystem* system)

src/hydro/hydro_forces.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
// Chrono includes needed for implementation (not exposed in public header)
2929
#include <chrono/physics/ChLoad.h>
30+
#include <chrono/physics/ChLoadable.h>
3031
#include <chrono/physics/ChBodyEasy.h>
3132
#include <chrono/physics/ChLoadsBody.h>
3233
#include <chrono/physics/ChSystemNSC.h>
@@ -62,6 +63,7 @@ using chrono::ChBody;
6263
using chrono::ChBodyEasyMesh;
6364
using chrono::ChForce;
6465
using chrono::ChFunction;
66+
using chrono::ChLoadable;
6567
using chrono::ChLoadContainer;
6668
using chrono::ChSolver;
6769
using chrono::ChSystem;
@@ -106,7 +108,7 @@ std::vector<double> Linspace(double start, double end, int num_points) {
106108

107109
// TODO reorder ComponentFunc implementation functions to match the header order of functions
108110
ComponentFunc::ComponentFunc() {
109-
base_ = NULL;
111+
base_ = nullptr;
110112
index_ = kDofPerBody;
111113
}
112114

@@ -122,7 +124,7 @@ ComponentFunc::ComponentFunc(const ComponentFunc& old) {
122124
}
123125

124126
double ComponentFunc::GetVal(double x) const {
125-
if (base_ == NULL) {
127+
if (base_ == nullptr) {
126128
std::cout << "base == Null!" << std::endl;
127129
return 0;
128130
}
@@ -156,7 +158,7 @@ ForceFunc6d::ForceFunc6d(std::shared_ptr<ChBody> object, HydroForces* user_all_f
156158
b_num_ = stoi(temp.erase(0, 4)); // 1-indexed body number
157159

158160
all_hydro_forces_ = user_all_forces;
159-
if (all_hydro_forces_ == NULL) {
161+
if (all_hydro_forces_ == nullptr) {
160162
std::cout << "all hydro forces null " << std::endl;
161163
}
162164
SetForce();
@@ -194,7 +196,7 @@ double ForceFunc6d::CoordinateFunc(int i) {
194196
}
195197

196198
void ForceFunc6d::SetForce() {
197-
if (chrono_force_ == NULL || body_ == NULL) {
199+
if (chrono_force_ == nullptr || body_ == nullptr) {
198200
std::cout << "set force null issue" << std::endl;
199201
}
200202
chrono_force_->SetF_x(force_ptrs_[0]);
@@ -203,7 +205,7 @@ void ForceFunc6d::SetForce() {
203205
}
204206

205207
void ForceFunc6d::SetTorque() {
206-
if (chrono_torque_ == NULL || body_ == NULL) {
208+
if (chrono_torque_ == nullptr || body_ == nullptr) {
207209
std::cout << "set torque null issue" << std::endl;
208210
}
209211
chrono_torque_->SetF_x(force_ptrs_[3]);

0 commit comments

Comments
 (0)