Skip to content

Commit d802c5d

Browse files
committed
Use new implementation of added mass (provided through Chrono's ChLoadHydrodynamics)
1 parent 0d49296 commit d802c5d

4 files changed

Lines changed: 16 additions & 201 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ set(HC_SOURCES
342342
# Chrono coupling layer (bridges Chrono physics with Chrono-free core)
343343
src/hydro/chrono/chrono_state_utils.cpp
344344
src/hydro/chrono/chrono_hydro_coupler.cpp
345-
src/hydro/chrono/added_mass.cpp
346345
src/hydro/force_components/hydrostatics_component.cpp
347346
src/hydro/force_components/radiation_component.cpp
348347
src/hydro/force_components/excitation_component.cpp
@@ -354,6 +353,7 @@ set(HC_SOURCES
354353
set(HC_HEADERS
355354
${PROJECT_BINARY_DIR}/hydroc/config.h
356355
${PROJECT_BINARY_DIR}/hydroc/version.h
356+
include/hydroc/hydro_system.h
357357
include/hydroc/helper.h
358358
include/hydroc/hydro_forces.h
359359
include/hydroc/logging.h
@@ -362,7 +362,6 @@ set(HC_HEADERS
362362
include/hydroc/core/hydro_forces.h
363363
include/hydroc/core/hydro_types.h
364364
include/hydroc/core/system_state.h
365-
include/hydroc/coupling/added_mass.h
366365
include/hydroc/coupling/chrono_coupler.h
367366
include/hydroc/io/h5_reader.h
368367
include/hydroc/io/h5_writer.h

include/hydroc/coupling/added_mass.h

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/hydro/chrono/added_mass.cpp

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/hydro/hydro_system.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*********************************************************************/
1111

1212
#include "hydroc/hydro_system.h"
13-
#include <hydroc/coupling/added_mass.h>
1413
#include <hydroc/io/h5_reader.h>
1514
#include <hydroc/waves/wave_base.h>
1615
#include <hydroc/waves/regular_wave.h>
@@ -32,6 +31,7 @@
3231
#include <chrono/physics/ChLoadsBody.h>
3332
#include <chrono/physics/ChSystemNSC.h>
3433
#include <chrono/physics/ChSystemSMC.h>
34+
#include <chrono/physics/ChLoadHydrodynamics.h>
3535
#include <chrono/solver/ChIterativeSolverLS.h>
3636
#include <chrono/solver/ChSolverPMINRES.h>
3737
#include <chrono/timestepper/ChTimestepper.h>
@@ -60,14 +60,9 @@
6060
// Local using declarations for Chrono types (implementation only - not leaked to users)
6161
// These provide convenience within this translation unit while keeping the public header clean.
6262
using chrono::ChBody;
63-
using chrono::ChBodyEasyMesh;
6463
using chrono::ChForce;
65-
using chrono::ChFunction;
66-
using chrono::ChLoadable;
67-
using chrono::ChLoadContainer;
68-
using chrono::ChSolver;
69-
using chrono::ChSystem;
70-
using chrono::ChVector3d;
64+
using chrono::ChBodyAddedMassBlocks;
65+
using chrono::ChLoadHydrodynamics;
7166

7267
// kDofPerBody is already defined in hydro_system.h as constexpr
7368
const int kDofLinOrRot = 3;
@@ -232,7 +227,7 @@ HydroSystem::HydroSystem(std::vector<std::shared_ptr<ChBody>> user_bodies,
232227
std::string h5_file_name,
233228
std::shared_ptr<WaveBase> waves)
234229
: bodies_(user_bodies),
235-
num_bodies_(bodies_.size()),
230+
num_bodies_((int)bodies_.size()),
236231
file_info_(H5FileInfo(h5_file_name, num_bodies_).ReadH5Data()),
237232
hydro_forces_(nullptr),
238233
chrono_coupler_(nullptr),
@@ -283,19 +278,17 @@ HydroSystem::HydroSystem(std::vector<std::shared_ptr<ChBody>> user_bodies,
283278
force_per_body_.emplace_back(bodies_[b], this);
284279
}
285280

286-
// Handle added mass info (applied via Chrono load system)
287-
my_loadcontainer = std::make_shared<ChLoadContainer>();
288-
289-
std::vector<std::shared_ptr<ChLoadable>> loadables(bodies_.size());
290-
for (int i = 0; i < static_cast<int>(bodies_.size()); ++i) {
291-
loadables[i] = bodies_[i];
281+
// Handle added mass info (applied via a Chrono ChLoadHydrodynamics)
282+
const auto& body_info = file_info_.GetBodyInfos();
283+
ChBodyAddedMassBlocks body_blocks;
284+
for (size_t i = 0; i < num_bodies_; i++) {
285+
body_blocks.insert(std::pair(bodies_[i], body_info[i].inf_added_mass));
286+
}
287+
if (num_bodies_ > 0) {
288+
auto hydro_load = chrono_types::make_shared<ChLoadHydrodynamics>(body_blocks);
289+
hydro_load->SetVerbose(false);
290+
bodies_[0]->GetSystem()->Add(hydro_load);
292291
}
293-
294-
my_loadbodyinertia =
295-
std::make_shared<ChLoadAddedMass>(file_info_.GetBodyInfos(), loadables, bodies_[0]->GetSystem());
296-
297-
bodies_[0]->GetSystem()->Add(my_loadcontainer);
298-
my_loadcontainer->Add(my_loadbodyinertia);
299292

300293
// Set up hydro inputs
301294
user_waves_ = waves;
@@ -547,9 +540,8 @@ void HydroSystem::EnsureHydroForcesAndCoupler() {
547540
// CoordinateFuncForBody(). The main force path now goes through HydroForces.
548541
std::vector<double> HydroSystem::ComputeForceRadiationDampingConv() {
549542
auto __t0 = std::chrono::steady_clock::now();
550-
const int total_dofs = kDofPerBody * num_bodies_;
551543

552-
assert(total_dofs > 0);
544+
assert(kDofPerBody * num_bodies_ > 0);
553545

554546
// Ensure radiation component exists with current settings
555547
EnsureRadiationComponent();
@@ -603,7 +595,6 @@ double HydroSystem::GetRIRFval(int row, int col, int st) {
603595
}
604596

605597
int body_index = row / kDofPerBody;
606-
int col_dof = col % kDofPerBody;
607598
int row_dof = row % kDofPerBody;
608599

609600
if (convolution_mode_ == hydrochrono::hydro::RadiationConvolutionMode::TaperedDirect) {

0 commit comments

Comments
 (0)