|
10 | 10 | *********************************************************************/ |
11 | 11 |
|
12 | 12 | #include "hydroc/hydro_system.h" |
13 | | -#include <hydroc/coupling/added_mass.h> |
14 | 13 | #include <hydroc/io/h5_reader.h> |
15 | 14 | #include <hydroc/waves/wave_base.h> |
16 | 15 | #include <hydroc/waves/regular_wave.h> |
|
32 | 31 | #include <chrono/physics/ChLoadsBody.h> |
33 | 32 | #include <chrono/physics/ChSystemNSC.h> |
34 | 33 | #include <chrono/physics/ChSystemSMC.h> |
| 34 | +#include <chrono/physics/ChLoadHydrodynamics.h> |
35 | 35 | #include <chrono/solver/ChIterativeSolverLS.h> |
36 | 36 | #include <chrono/solver/ChSolverPMINRES.h> |
37 | 37 | #include <chrono/timestepper/ChTimestepper.h> |
|
60 | 60 | // Local using declarations for Chrono types (implementation only - not leaked to users) |
61 | 61 | // These provide convenience within this translation unit while keeping the public header clean. |
62 | 62 | using chrono::ChBody; |
63 | | -using chrono::ChBodyEasyMesh; |
64 | 63 | 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; |
71 | 66 |
|
72 | 67 | // kDofPerBody is already defined in hydro_system.h as constexpr |
73 | 68 | const int kDofLinOrRot = 3; |
@@ -232,7 +227,7 @@ HydroSystem::HydroSystem(std::vector<std::shared_ptr<ChBody>> user_bodies, |
232 | 227 | std::string h5_file_name, |
233 | 228 | std::shared_ptr<WaveBase> waves) |
234 | 229 | : bodies_(user_bodies), |
235 | | - num_bodies_(bodies_.size()), |
| 230 | + num_bodies_((int)bodies_.size()), |
236 | 231 | file_info_(H5FileInfo(h5_file_name, num_bodies_).ReadH5Data()), |
237 | 232 | hydro_forces_(nullptr), |
238 | 233 | chrono_coupler_(nullptr), |
@@ -283,19 +278,17 @@ HydroSystem::HydroSystem(std::vector<std::shared_ptr<ChBody>> user_bodies, |
283 | 278 | force_per_body_.emplace_back(bodies_[b], this); |
284 | 279 | } |
285 | 280 |
|
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); |
292 | 291 | } |
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); |
299 | 292 |
|
300 | 293 | // Set up hydro inputs |
301 | 294 | user_waves_ = waves; |
@@ -547,9 +540,8 @@ void HydroSystem::EnsureHydroForcesAndCoupler() { |
547 | 540 | // CoordinateFuncForBody(). The main force path now goes through HydroForces. |
548 | 541 | std::vector<double> HydroSystem::ComputeForceRadiationDampingConv() { |
549 | 542 | auto __t0 = std::chrono::steady_clock::now(); |
550 | | - const int total_dofs = kDofPerBody * num_bodies_; |
551 | 543 |
|
552 | | - assert(total_dofs > 0); |
| 544 | + assert(kDofPerBody * num_bodies_ > 0); |
553 | 545 |
|
554 | 546 | // Ensure radiation component exists with current settings |
555 | 547 | EnsureRadiationComponent(); |
@@ -603,7 +595,6 @@ double HydroSystem::GetRIRFval(int row, int col, int st) { |
603 | 595 | } |
604 | 596 |
|
605 | 597 | int body_index = row / kDofPerBody; |
606 | | - int col_dof = col % kDofPerBody; |
607 | 598 | int row_dof = row % kDofPerBody; |
608 | 599 |
|
609 | 600 | if (convolution_mode_ == hydrochrono::hydro::RadiationConvolutionMode::TaperedDirect) { |
|
0 commit comments