From 59f6abc330aa32c7030bce2aebcf286dd2f9fff1 Mon Sep 17 00:00:00 2001 From: DarioMangoni Date: Fri, 19 Apr 2024 11:54:54 +0200 Subject: [PATCH 1/5] Updated to Chrono v9 --- CMakeLists.txt | 10 ++++ demos/DeepCWind/demo_DeepCWind_decay.cpp | 35 ++++++------ demos/Test/Test_1.cpp | 40 ++++++------- demos/f3of/demo_F3OF_DT1.cpp | 51 ++++++++--------- demos/f3of/demo_F3OF_DT2.cpp | 57 +++++++++---------- demos/f3of/demo_F3OF_DT3.cpp | 56 +++++++++--------- demos/oswec/demo_oswec_decay.cpp | 40 +++++++------ demos/oswec/demo_oswec_reg_waves.cpp | 46 +++++++-------- demos/rm3/demo_rm3_decay.cpp | 30 +++++----- demos/rm3/demo_rm3_reg_waves.cpp | 30 +++++----- demos/sphere/demo_sphere_decay.cpp | 12 ++-- demos/sphere/demo_sphere_irreg_waves.cpp | 38 ++++++------- .../demo_sphere_irreg_waves_eta_import.cpp | 36 ++++++------ demos/sphere/demo_sphere_reg_waves.cpp | 28 +++++---- demos/sphere/sphere_irreg_waves.cpp | 40 +++++++------ include/hydroc/chloadaddedmass.h | 15 ++--- include/hydroc/hydro_forces.h | 2 +- src/chloadaddedmass.cpp | 19 +++---- src/gui/guihelper.cpp | 7 +-- src/helper.cpp | 4 +- src/hydro_forces.cpp | 18 +++--- 21 files changed, 292 insertions(+), 322 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 448bd4f..766a50c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ #-------------------------------------------------------------- cmake_minimum_required(VERSION 3.18.2) +cmake_policy(SET CMP0091 NEW) + # guard against in-source builds if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) @@ -41,6 +43,14 @@ project(HydroChrono # Add the cmake folder so the FindSphinx module is found set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) +#-------------------------------------------------------------- +# Important! To ensure ABI compatibility, use the same C++ standard +# as the one used to build the Chrono libraries. +#-------------------------------------------------------------- + +set(CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD ${CHRONO_CXX_STANDARD}) + # =================== # OPTIONS # =================== diff --git a/demos/DeepCWind/demo_DeepCWind_decay.cpp b/demos/DeepCWind/demo_DeepCWind_decay.cpp index 860d95d..13844b4 100644 --- a/demos/DeepCWind/demo_DeepCWind_decay.cpp +++ b/demos/DeepCWind/demo_DeepCWind_decay.cpp @@ -3,7 +3,6 @@ #include #include -#include #include // std::chrono::high_resolution_clock::now #include // std::setprecision @@ -11,7 +10,6 @@ // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; // usage: ./sphere_deca.exe [DATADIR] [--nogui] // @@ -20,7 +18,7 @@ using namespace chrono::geometry; // int main(int argc, char* argv[]) { // auto start = std::chrono::high_resolution_clock::now(); - GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; @@ -39,12 +37,11 @@ int main(int argc, char* argv[]) { // system/solver settings ChSystemSMC system; - system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.08; system.SetTimestepperType(ChTimestepper::Type::HHT); system.SetSolverType(ChSolver::Type::GMRES); - system.SetSolverMaxIterations(300); // the higher, the easier to keep the constraints satisfied. - system.SetStep(timestep); + system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. double simulationDuration = 1000.0; // Create user interface @@ -70,33 +67,33 @@ int main(int argc, char* argv[]) { // define the base's initial conditions system.Add(base); - base->SetNameString("body1"); - auto cg = ChVector<>(0.0, 0.0, -7.53); + base->SetName("body1"); + auto cg = ChVector3d(0.0, 0.0, -7.53); // offset used for heave/surge decay test - auto offset = ChVector<>(0.0, 0.0, 0.0); + auto offset = ChVector3d(0.0, 0.0, 0.0); base->SetPos(cg + offset); // Use for pitch decay test - double ang_rad = -3.95 * CH_C_PI / 180.0; - base->SetRot(Q_from_AngAxis(ang_rad, VECT_Y)); + double ang_rad = -3.95 * CH_PI / 180.0; + base->SetRot(QuatFromAngleY(ang_rad)); base->SetMass(1.419625e7); - base->SetInertiaXX(ChVector<>(1.2898e10, 1.2851e10, 1.4189e10)); + base->SetInertiaXX(ChVector3d(1.2898e10, 1.2851e10, 1.4189e10)); // add fixed ground for linear damping (surge or pitch) auto ground = chrono_types::make_shared(); system.AddBody(ground); ground->SetPos(cg); - ground->SetRot(Q_from_AngAxis(CH_C_PI / 2.0, VECT_X)); - ground->SetIdentifier(-1); - ground->SetBodyFixed(true); - ground->SetCollide(false); + ground->SetRot(QuatFromAngleX(CH_PI / 2.0)); + ground->SetTag(-1); + ground->SetFixed(true); + ground->EnableCollision(false); // define damping in pitch auto rot_damp = chrono_types::make_shared(); // need to set damping to 31 MN-m/(rad/s) rot_damp->SetDampingCoefficient(31e6); // puts Z axis for link into screen, keeping x axis the same (to the right) - ChQuaternion<> rev_rot = Q_from_AngAxis(CH_C_PI / 2.0, VECT_X); // do not change - rot_damp->Initialize(base, ground, false, ChCoordsys(cg, rev_rot), ChCoordsys(cg, rev_rot)); + ChQuaternion<> rev_rot = QuatFromAngleX(CH_PI / 2.0); // do not change + rot_damp->Initialize(base, ground, false, ChFramed(cg, rev_rot), ChFramed(cg, rev_rot)); system.AddLink(rot_damp); // set up hydro forces @@ -120,7 +117,7 @@ int main(int argc, char* argv[]) { // append data to output vector time_vector.push_back(system.GetChTime()); base_surge.push_back(base->GetPos().x()); - base_pitch.push_back(base->GetRot().Q_to_Euler123().y()); + base_pitch.push_back(base->GetRot().GetCardanAnglesXYZ().y()); } } diff --git a/demos/Test/Test_1.cpp b/demos/Test/Test_1.cpp index bcd503b..1fef3d9 100644 --- a/demos/Test/Test_1.cpp +++ b/demos/Test/Test_1.cpp @@ -94,7 +94,7 @@ class MyEventReceiver : public IEventReceiver { // wheel and the many radial rollers, already lined to the wheel with revolute joints.) // The function returns the pointer to the central wheel. std::shared_ptr create_mecanum_wheel(ChSystemNSC& sys, - ChVector<> shaft_position, + ChVector3d shaft_position, ChQuaternion<> shaft_alignment, double wheel_radius, double wheel_width, @@ -122,7 +122,7 @@ std::shared_ptr create_mecanum_wheel(ChSystemNSC& sys, double roller_elliptical_rad_Vert = wheel_radius * 1.0 / (cos(roller_angle)); for (int iroller = 0; iroller < n_rollers; iroller++) { - double pitch = CH_C_2PI * ((double)iroller / (double)n_rollers); + double pitch = CH_2PI * ((double)iroller / (double)n_rollers); double Roffset = -(wheel_radius - roller_midradius); @@ -131,9 +131,9 @@ std::shared_ptr create_mecanum_wheel(ChSystemNSC& sys, sys.Add(roller); // move it to slanted aligment - ChFrameMoving<> f1(ChVector<>(0, 0, -(wheel_radius - roller_midradius)), - Q_from_AngAxis(roller_angle, ChVector<>(0, 0, 1))); - ChFrameMoving<> f2(ChVector<>(0, 0, 0), Q_from_AngAxis(pitch, ChVector<>(0, 1, 0))); + ChFrameMoving<> f1(ChVector3d(0, 0, -(wheel_radius - roller_midradius)), + QuatFromAngleZ(roller_angle)); + ChFrameMoving<> f2(ChVector3d(0, 0, 0), QuatFromAngleY(pitch)); ChFrameMoving<> f3 = f1 >> f2 >> ftot; roller->ConcatenatePreTransformation(f3); @@ -150,7 +150,7 @@ std::shared_ptr create_mecanum_wheel(ChSystemNSC& sys, roller_elliptical_rad_Vert, roller_elliptical_rad_Hor, // Roffset); roller->GetCollisionModel()->BuildModel(); - roller->SetCollide(true); + roller->EnableCollision(true); // add visualization shape auto rollershape = @@ -161,7 +161,7 @@ std::shared_ptr create_mecanum_wheel(ChSystemNSC& sys, // Make the revolute joint between the roller and the central wheel // (preconcatenate rotation 90 degrees on X, to set axis of revolute joint) - ChFrameMoving<> fr(ChVector<>(0, 0, 0), Q_from_AngAxis(CH_C_PI / 2.0, ChVector<>(1, 0, 0))); + ChFrameMoving<> fr(ChVector3d(0, 0, 0), QuatFromAngleX(CH_PI / 2.0)); ChFrameMoving<> frabs = fr >> f3; auto link_roller = chrono_types::make_shared(); link_roller->Initialize(roller, centralWheel, frabs.GetCoord()); @@ -172,14 +172,14 @@ std::shared_ptr create_mecanum_wheel(ChSystemNSC& sys, } int main(int argc, char* argv[]) { - GetLog() << "Copyright (c) 2017 projectchrono.org\nChrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Copyright (c) 2017 projectchrono.org\nChrono version: " << CHRONO_VERSION << "\n\n"; // Create a ChronoENGINE physical system ChSystemNSC sys; double platform_radius = 8; double wheel_radius = 3; - double roller_angle = CH_C_PI / 4; + double roller_angle = CH_PI / 4; // Create the robot truss, as a circular platform auto platform = chrono_types::make_shared(platform_radius * 0.7, 2, // radius, height @@ -193,11 +193,11 @@ int main(int argc, char* argv[]) { // create the wheels and link them to the platform - ChFrame<> f0(ChVector<>(0, 0, 0), Q_from_AngAxis(CH_C_PI / 2.0, ChVector<>(1, 0, 0))); - ChFrame<> f1(ChVector<>(0, 0, platform_radius), QUNIT); - ChFrame<> f2_wA(VNULL, Q_from_AngAxis(0 * (CH_C_2PI / 3.0), ChVector<>(0, 1, 0))); - ChFrame<> f2_wB(VNULL, Q_from_AngAxis(1 * (CH_C_2PI / 3.0), ChVector<>(0, 1, 0))); - ChFrame<> f2_wC(VNULL, Q_from_AngAxis(2 * (CH_C_2PI / 3.0), ChVector<>(0, 1, 0))); + ChFrame<> f0(ChVector3d(0, 0, 0), QuatFromAngleX(CH_PI / 2.0)); + ChFrame<> f1(ChVector3d(0, 0, platform_radius), QUNIT); + ChFrame<> f2_wA(VNULL, QuatFromAngleY(0 * (CH_2PI / 3.0))); + ChFrame<> f2_wB(VNULL, QuatFromAngleY(1 * (CH_2PI / 3.0))); + ChFrame<> f2_wC(VNULL, QuatFromAngleY(2 * (CH_2PI / 3.0))); ChFrame<> ftot_wA = f0 >> f1 >> f2_wA; ChFrame<> ftot_wB = f0 >> f1 >> f2_wB; ChFrame<> ftot_wC = f0 >> f1 >> f2_wC; @@ -259,8 +259,8 @@ int main(int argc, char* argv[]) { true, // visualize true, // collide ground_mat); // contact material - ground->SetPos(ChVector<>(0, -5, 0)); - ground->SetBodyFixed(true); + ground->SetPos(ChVector3d(0, -5, 0)); + ground->SetFixed(true); ground->GetVisualShape(0)->SetTexture(GetChronoDataFile("textures/concrete.jpg"), 100, 100); sys.Add(ground); @@ -272,7 +272,7 @@ int main(int argc, char* argv[]) { vis->Initialize(); vis->AddLogo(); vis->AddSkyBox(); - vis->AddCamera(ChVector<>(0, 14, -20)); + vis->AddCamera(ChVector3d(0, 14, -20)); vis->AddTypicalLights(); vis->GetGUIEnvironment()->addStaticText(L"Use keys Q,W, A,Z, E,R to move the robot", rect(150, 10, 430, 40), @@ -286,7 +286,7 @@ int main(int argc, char* argv[]) { sys.SetTimestepperType(ChTimestepper::Type::EULER_IMPLICIT_PROJECTED); sys.SetSolverType(ChSolver::Type::PSOR); - sys.SetSolverMaxIterations(30); + sys.GetSolver()->AsIterative()->SetMaxIterations(30); // Simulation loop @@ -303,8 +303,8 @@ int main(int argc, char* argv[]) { // change motor speeds depending on user setpoints from GUI - ChVector<> imposed_speed(STATIC_x_speed, 0, STATIC_z_speed); - ChFrame<> roll_twist(ChVector<>(0, -wheel_radius, 0), Q_from_AngAxis(-roller_angle, ChVector<>(0, 1, 0))); + ChVector3d imposed_speed(STATIC_x_speed, 0, STATIC_z_speed); + ChFrame<> roll_twist(ChVector3d(0, -wheel_radius, 0), QuatFromAngleY(-roller_angle)); ChFrame<> abs_roll_wA = roll_twist >> f2_wA >> ChFrame<>(platform->GetCoord()); double wheel_A_rotspeed = diff --git a/demos/f3of/demo_F3OF_DT1.cpp b/demos/f3of/demo_F3OF_DT1.cpp index dded137..b575022 100644 --- a/demos/f3of/demo_F3OF_DT1.cpp +++ b/demos/f3of/demo_F3OF_DT1.cpp @@ -3,7 +3,6 @@ #include #include -#include #include // std::chrono::high_resolution_clock::now #include // std::setprecision @@ -11,7 +10,6 @@ // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; // usage: ./.exe [DATADIR] [--nogui] // @@ -19,7 +17,7 @@ using namespace chrono::geometry; // environment variable to give the data_directory. // int main(int argc, char* argv[]) { - GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; @@ -42,11 +40,10 @@ int main(int argc, char* argv[]) { // system/solver settings ChSystemSMC system; - system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.02; system.SetSolverType(ChSolver::Type::SPARSE_QR); - system.SetSolverMaxIterations(300); // the higher, the easier to keep the constraints satisfied. - system.SetStep(timestep); + system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 300.0; @@ -80,9 +77,9 @@ int main(int argc, char* argv[]) { // define the base's initial conditions (position and rotation defined later for specific test) system.Add(base); - base->SetNameString("body1"); + base->SetName("body1"); base->SetMass(1089825.0); - base->SetInertiaXX(ChVector<>(100000000.0, 76300000.0, 100000000.0)); + base->SetInertiaXX(ChVector3d(100000000.0, 76300000.0, 100000000.0)); std::cout << "Attempting to open mesh file: " << body2_meshfame << std::endl; std::shared_ptr flapFore = chrono_types::make_shared( // @@ -100,9 +97,9 @@ int main(int argc, char* argv[]) { // define the fore flap's initial conditions (position and rotation defined later for specific tests system.Add(flapFore); - flapFore->SetNameString("body2"); + flapFore->SetName("body2"); flapFore->SetMass(179250.0); - flapFore->SetInertiaXX(ChVector<>(100000000.0, 1300000.0, 100000000.0)); + flapFore->SetInertiaXX(ChVector3d(100000000.0, 1300000.0, 100000000.0)); std::cout << "Attempting to open mesh file: " << body3_meshfame << std::endl; std::shared_ptr flapAft = chrono_types::make_shared( // @@ -120,39 +117,39 @@ int main(int argc, char* argv[]) { // define the aft flap's initial conditions (position and rotation defined later for specific tests system.Add(flapAft); - flapAft->SetNameString("body3"); + flapAft->SetName("body3"); flapAft->SetMass(179250.0); - flapAft->SetInertiaXX(ChVector<>(100000000.0, 1300000.0, 100000000.0)); + flapAft->SetInertiaXX(ChVector3d(100000000.0, 1300000.0, 100000000.0)); // ---------------- DT1 set up (surge decay, flaps locked, no waves) ------------------------------ // set up pos/rotations - base->SetPos(ChVector<>(5.0, 0.0, -9.0)); - flapFore->SetPos(ChVector<>(5.0 + -12.5, 0.0, -9.0 + 3.5)); - flapAft->SetPos(ChVector<>(5.0 + 12.5, 0.0, -9.0 + 3.5)); + base->SetPos(ChVector3d(5.0, 0.0, -9.0)); + flapFore->SetPos(ChVector3d(5.0 + -12.5, 0.0, -9.0 + 3.5)); + flapAft->SetPos(ChVector3d(5.0 + 12.5, 0.0, -9.0 + 3.5)); // set up revolute joints and lock them auto revoluteFore = chrono_types::make_shared(); auto revoluteAft = chrono_types::make_shared(); - ChQuaternion<> revoluteRot = Q_from_AngX(CH_C_PI / 2.0); // do not change - revoluteFore->Initialize(base, flapFore, ChCoordsys<>(ChVector<>(5.0 - 12.5, 0.0, -9.0), revoluteRot)); + ChQuaternion<> revoluteRot = QuatFromAngleX(CH_PI / 2.0); // do not change + revoluteFore->Initialize(base, flapFore, ChFramed(ChVector3d(5.0 - 12.5, 0.0, -9.0), revoluteRot)); system.AddLink(revoluteFore); - revoluteAft->Initialize(base, flapAft, ChCoordsys<>(ChVector<>(5.0 + 12.5, 0.0, -9.0), revoluteRot)); + revoluteAft->Initialize(base, flapAft, ChFramed(ChVector3d(5.0 + 12.5, 0.0, -9.0), revoluteRot)); system.AddLink(revoluteAft); revoluteFore->Lock(true); revoluteAft->Lock(true); // create ground auto ground = chrono_types::make_shared(); system.AddBody(ground); - ground->SetPos(ChVector<>(0, 0, -9.0)); - ground->SetIdentifier(-1); - ground->SetBodyFixed(true); - ground->SetCollide(false); + ground->SetPos(ChVector3d(0, 0, -9.0)); + ground->SetTag(-1); + ground->SetFixed(true); + ground->EnableCollision(false); // add prismatic joint between the base and ground auto prismatic = chrono_types::make_shared(); - prismatic->Initialize(ground, base, ChCoordsys<>(ChVector<>(0.0, 0.0, -9.0), Q_from_AngY(CH_C_PI_2))); + prismatic->Initialize(ground, base, ChFramed(ChVector3d(0.0, 0.0, -9.0), QuatFromAngleY(CH_PI_2))); system.AddLink(prismatic); // add damping to prismatic joint auto prismatic_pto = chrono_types::make_shared(); - prismatic_pto->Initialize(ground, base, true, ChVector<>(0.0, 0.0, 0.0), ChVector<>(0.0, 0.0, 0.0)); + prismatic_pto->Initialize(ground, base, true, ChVector3d(0.0, 0.0, 0.0), ChVector3d(0.0, 0.0, 0.0)); prismatic_pto->SetSpringCoefficient(1e5); prismatic_pto->SetRestLength(0.0); system.AddLink(prismatic_pto); @@ -184,9 +181,9 @@ int main(int argc, char* argv[]) { // append data to output vector time_vector.push_back(system.GetChTime()); base_surge.push_back(base->GetPos().x()); - base_pitch.push_back(base->GetRot().Q_to_Euler123().y()); - fore_pitch.push_back(flapFore->GetRot().Q_to_Euler123().y()); - aft_pitch.push_back(flapAft->GetRot().Q_to_Euler123().y()); + base_pitch.push_back(base->GetRot().GetCardanAnglesXYZ().y()); + fore_pitch.push_back(flapFore->GetRot().GetCardanAnglesXYZ().y()); + aft_pitch.push_back(flapAft->GetRot().GetCardanAnglesXYZ().y()); } } diff --git a/demos/f3of/demo_F3OF_DT2.cpp b/demos/f3of/demo_F3OF_DT2.cpp index 9d1ad23..40a5e6a 100644 --- a/demos/f3of/demo_F3OF_DT2.cpp +++ b/demos/f3of/demo_F3OF_DT2.cpp @@ -3,7 +3,6 @@ #include #include -#include #include // std::chrono::high_resolution_clock::now #include // std::setprecision @@ -11,7 +10,6 @@ // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; // usage: ./.exe [DATADIR] [--nogui] // @@ -19,7 +17,7 @@ using namespace chrono::geometry; // environment variable to give the data_directory. // int main(int argc, char* argv[]) { - GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; @@ -42,11 +40,10 @@ int main(int argc, char* argv[]) { // system/solver settings ChSystemSMC system; - system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.02; system.SetSolverType(ChSolver::Type::SPARSE_QR); - system.SetSolverMaxIterations(300); // the higher, the easier to keep the constraints satisfied. - system.SetStep(timestep); + system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 300.0; @@ -80,9 +77,9 @@ int main(int argc, char* argv[]) { // define the base's initial conditions (position and rotation defined later for specific test) system.Add(base); - base->SetNameString("body1"); + base->SetName("body1"); base->SetMass(1089825.0); - base->SetInertiaXX(ChVector<>(100000000.0, 76300000.0, 100000000.0)); + base->SetInertiaXX(ChVector3d(100000000.0, 76300000.0, 100000000.0)); std::cout << "Attempting to open mesh file: " << body2_meshfame << std::endl; std::shared_ptr flapFore = chrono_types::make_shared( // @@ -100,9 +97,9 @@ int main(int argc, char* argv[]) { // define the fore flap's initial conditions (position and rotation defined later for specific tests system.Add(flapFore); - flapFore->SetNameString("body2"); + flapFore->SetName("body2"); flapFore->SetMass(179250.0); - flapFore->SetInertiaXX(ChVector<>(100000000.0, 1300000.0, 100000000.0)); + flapFore->SetInertiaXX(ChVector3d(100000000.0, 1300000.0, 100000000.0)); std::cout << "Attempting to open mesh file: " << body3_meshfame << std::endl; std::shared_ptr flapAft = chrono_types::make_shared( // @@ -120,47 +117,47 @@ int main(int argc, char* argv[]) { // define the aft flap's initial conditions (position and rotation defined later for specific tests system.Add(flapAft); - flapAft->SetNameString("body3"); + flapAft->SetName("body3"); flapAft->SetMass(179250.0); - flapAft->SetInertiaXX(ChVector<>(100000000.0, 1300000.0, 100000000.0)); + flapAft->SetInertiaXX(ChVector3d(100000000.0, 1300000.0, 100000000.0)); // ---------------- DT2 set up (flaps locked, base pitch decay, no waves) --------------------------------- // adjust initial pitch here only, rotations and positions calcuated from this: - double ang_rad = CH_C_PI / 18.0; + double ang_rad = CH_PI / 18.0; // set up pos/rotations (do not modify unless you know what you're doing) - base->SetPos(ChVector<>(0.0, 0.0, -9.0)); - base->SetRot(Q_from_AngAxis(ang_rad, VECT_Y)); - flapFore->SetRot(Q_from_AngAxis(ang_rad, VECT_Y)); - flapAft->SetRot(Q_from_AngAxis(ang_rad, VECT_Y)); - flapFore->SetPos(ChVector<>(-12.5 * std::cos(ang_rad) + 3.5 * std::sin(ang_rad), 0.0, + base->SetPos(ChVector3d(0.0, 0.0, -9.0)); + base->SetRot(QuatFromAngleY(ang_rad)); + flapFore->SetRot(QuatFromAngleY(ang_rad)); + flapAft->SetRot(QuatFromAngleY(ang_rad)); + flapFore->SetPos(ChVector3d(-12.5 * std::cos(ang_rad) + 3.5 * std::sin(ang_rad), 0.0, -9.0 + 12.5 * std::sin(ang_rad) + 3.5 * std::cos(ang_rad))); - flapAft->SetPos(ChVector<>(12.5 * std::cos(ang_rad) + 3.5 * std::sin(ang_rad), 0.0, + flapAft->SetPos(ChVector3d(12.5 * std::cos(ang_rad) + 3.5 * std::sin(ang_rad), 0.0, -9.0 - 12.5 * std::sin(ang_rad) + 3.5 * std::cos(ang_rad))); // set up revolute joints and lock them (do not modify unless you know what you're doing) auto revoluteFore = chrono_types::make_shared(); auto revoluteAft = chrono_types::make_shared(); - ChQuaternion<> revoluteRot = Q_from_AngX(CH_C_PI / 2.0); // do not change + ChQuaternion<> revoluteRot = QuatFromAngleX(CH_PI / 2.0); // do not change revoluteFore->Initialize( base, flapFore, - ChCoordsys<>(ChVector<>(-12.5 * std::cos(ang_rad), 0.0, -9.0 + 12.5 * std::sin(ang_rad)), revoluteRot)); + ChFramed(ChVector3d(-12.5 * std::cos(ang_rad), 0.0, -9.0 + 12.5 * std::sin(ang_rad)), revoluteRot)); system.AddLink(revoluteFore); revoluteAft->Initialize( base, flapAft, - ChCoordsys<>(ChVector<>(12.5 * std::cos(ang_rad), 0.0, -9.0 - 12.5 * std::sin(ang_rad)), revoluteRot)); + ChFramed(ChVector3d(12.5 * std::cos(ang_rad), 0.0, -9.0 - 12.5 * std::sin(ang_rad)), revoluteRot)); system.AddLink(revoluteAft); revoluteFore->Lock(true); revoluteAft->Lock(true); // create ground auto ground = chrono_types::make_shared(); system.AddBody(ground); - ground->SetPos(ChVector<>(0, 0, -9.0)); - ground->SetIdentifier(-1); - ground->SetBodyFixed(true); - ground->SetCollide(false); + ground->SetPos(ChVector3d(0, 0, -9.0)); + ground->SetTag(-1); + ground->SetFixed(true); + ground->EnableCollision(false); // add revolute joint between the base and ground auto base_rev = chrono_types::make_shared(); - base_rev->Initialize(base, ground, ChCoordsys<>(ChVector<>(0.0, 0.0, -9.0), revoluteRot)); + base_rev->Initialize(base, ground, ChFramed(ChVector3d(0.0, 0.0, -9.0), revoluteRot)); system.AddLink(base_rev); // define wave parameters (not used in this demo TODO have hydroforces constructor without hydro inputs) @@ -190,9 +187,9 @@ int main(int argc, char* argv[]) { // append data to output vector time_vector.push_back(system.GetChTime()); base_surge.push_back(base->GetPos().x()); - base_pitch.push_back(base->GetRot().Q_to_Euler123().y()); - fore_pitch.push_back(flapFore->GetRot().Q_to_Euler123().y()); - aft_pitch.push_back(flapAft->GetRot().Q_to_Euler123().y()); + base_pitch.push_back(base->GetRot().GetCardanAnglesXYZ().y()); + fore_pitch.push_back(flapFore->GetRot().GetCardanAnglesXYZ().y()); + aft_pitch.push_back(flapAft->GetRot().GetCardanAnglesXYZ().y()); } } diff --git a/demos/f3of/demo_F3OF_DT3.cpp b/demos/f3of/demo_F3OF_DT3.cpp index d99dd1c..3cfc828 100644 --- a/demos/f3of/demo_F3OF_DT3.cpp +++ b/demos/f3of/demo_F3OF_DT3.cpp @@ -11,7 +11,6 @@ // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; // usage: ./.exe [DATADIR] [--nogui] // @@ -19,7 +18,7 @@ using namespace chrono::geometry; // environment variable to give the data_directory. // int main(int argc, char* argv[]) { - GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; @@ -42,11 +41,10 @@ int main(int argc, char* argv[]) { // system/solver settings ChSystemSMC system; - system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.02; system.SetSolverType(ChSolver::Type::SPARSE_QR); - system.SetSolverMaxIterations(300); // the higher, the easier to keep the constraints satisfied. - system.SetStep(timestep); + system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 300.0; @@ -80,9 +78,9 @@ int main(int argc, char* argv[]) { // define the base's initial conditions (position and rotation defined later for specific test) system.Add(base); - base->SetNameString("body1"); + base->SetName("body1"); base->SetMass(1089825.0); - base->SetInertiaXX(ChVector<>(100000000.0, 76300000.0, 100000000.0)); + base->SetInertiaXX(ChVector3d(100000000.0, 76300000.0, 100000000.0)); std::cout << "Attempting to open mesh file: " << body2_meshfame << std::endl; std::shared_ptr flapFore = chrono_types::make_shared( // @@ -100,9 +98,9 @@ int main(int argc, char* argv[]) { // define the fore flap's initial conditions (position and rotation defined later for specific tests system.Add(flapFore); - flapFore->SetNameString("body2"); + flapFore->SetName("body2"); flapFore->SetMass(179250.0); - flapFore->SetInertiaXX(ChVector<>(100000000.0, 1300000.0, 100000000.0)); + flapFore->SetInertiaXX(ChVector3d(100000000.0, 1300000.0, 100000000.0)); std::cout << "Attempting to open mesh file: " << body3_meshfame << std::endl; std::shared_ptr flapAft = chrono_types::make_shared( // @@ -120,35 +118,35 @@ int main(int argc, char* argv[]) { // define the aft flap's initial conditions (position and rotation defined later for specific tests system.Add(flapAft); - flapAft->SetNameString("body3"); + flapAft->SetName("body3"); flapAft->SetMass(179250.0); - flapAft->SetInertiaXX(ChVector<>(100000000.0, 1300000.0, 100000000.0)); + flapAft->SetInertiaXX(ChVector3d(100000000.0, 1300000.0, 100000000.0)); // ---------------- DT3 set up (flap decay, base fixed, no waves) --------------------------------- - base->SetPos(ChVector<>(0.0, 0.0, -9.0)); - double fore_ang_rad = CH_C_PI / 18.0; // fore flap starts with 10 degree initial rotation - flapFore->SetRot(Q_from_AngAxis(fore_ang_rad, VECT_Y)); - flapFore->SetPos(ChVector<>(-12.5 + 3.5 * std::cos(CH_C_PI / 2.0 - fore_ang_rad), 0.0, - -9.0 + 3.5 * std::sin(CH_C_PI / 2.0 - fore_ang_rad))); + base->SetPos(ChVector3d(0.0, 0.0, -9.0)); + double fore_ang_rad = CH_PI / 18.0; // fore flap starts with 10 degree initial rotation + flapFore->SetRot(QuatFromAngleY(fore_ang_rad)); + flapFore->SetPos(ChVector3d(-12.5 + 3.5 * std::cos(CH_PI / 2.0 - fore_ang_rad), 0.0, + -9.0 + 3.5 * std::sin(CH_PI / 2.0 - fore_ang_rad))); double aft_ang_rad = 0.0; - flapAft->SetRot(Q_from_AngAxis(aft_ang_rad, VECT_Y)); - flapAft->SetPos(ChVector<>(12.5 + 3.5 * std::cos(CH_C_PI / 2.0 - aft_ang_rad), 0.0, - -9.0 + 3.5 * std::sin(CH_C_PI / 2.0 - fore_ang_rad))); + flapAft->SetRot(QuatFromAngleY(aft_ang_rad)); + flapAft->SetPos(ChVector3d(12.5 + 3.5 * std::cos(CH_PI / 2.0 - aft_ang_rad), 0.0, + -9.0 + 3.5 * std::sin(CH_PI / 2.0 - fore_ang_rad))); // set up revolute joints with damping for each flap auto revoluteFore = chrono_types::make_shared(); auto revoluteAft = chrono_types::make_shared(); - ChQuaternion<> revoluteRot = Q_from_AngX(CH_C_PI / 2.0); // do not change - revoluteFore->Initialize(base, flapFore, ChCoordsys<>(ChVector<>(-12.5, 0.0, -9.0), revoluteRot)); + ChQuaternion<> revoluteRot = QuatFromAngleX(CH_PI / 2.0); // do not change + revoluteFore->Initialize(base, flapFore, ChFramed(ChVector3d(-12.5, 0.0, -9.0), revoluteRot)); system.AddLink(revoluteFore); - revoluteAft->Initialize(base, flapAft, ChCoordsys<>(ChVector<>(12.5, 0.0, -9.0), revoluteRot)); + revoluteAft->Initialize(base, flapAft, ChFramed(ChVector3d(12.5, 0.0, -9.0), revoluteRot)); system.AddLink(revoluteAft); // create ground auto ground = chrono_types::make_shared(); system.AddBody(ground); - ground->SetPos(ChVector<>(0, 0, -12.0)); - ground->SetIdentifier(-1); - ground->SetBodyFixed(true); - ground->SetCollide(false); + ground->SetPos(ChVector3d(0, 0, -12.0)); + ground->SetTag(-1); + ground->SetFixed(true); + ground->EnableCollision(false); // fix base to ground with special constraint (don't use setfixed() because of mass matrix) auto anchor = chrono_types::make_shared(); anchor->Initialize(base, ground, false, base->GetVisualModelFrame(), base->GetVisualModelFrame()); @@ -181,9 +179,9 @@ int main(int argc, char* argv[]) { // append data to output vector time_vector.push_back(system.GetChTime()); base_surge.push_back(base->GetPos().x()); - base_pitch.push_back(base->GetRot().Q_to_Euler123().y()); - fore_pitch.push_back(flapFore->GetRot().Q_to_Euler123().y()); - aft_pitch.push_back(flapAft->GetRot().Q_to_Euler123().y()); + base_pitch.push_back(base->GetRot().GetCardanAnglesXYZ().y()); + fore_pitch.push_back(flapFore->GetRot().GetCardanAnglesXYZ().y()); + aft_pitch.push_back(flapAft->GetRot().GetCardanAnglesXYZ().y()); } } diff --git a/demos/oswec/demo_oswec_decay.cpp b/demos/oswec/demo_oswec_decay.cpp index d33aa98..bbf574d 100644 --- a/demos/oswec/demo_oswec_decay.cpp +++ b/demos/oswec/demo_oswec_decay.cpp @@ -11,7 +11,6 @@ // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; // usage: ./.exe [DATADIR] [--nogui] // @@ -61,7 +60,7 @@ std::array add_vectors(std::array v1, std::array(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.03; // system.SetTimestepperType(ChTimestepper::Type::HHT); system.SetSolverType(ChSolver::Type::GMRES); - // system.SetSolverMaxIterations(300); // the higher, the easier to keep the constraints satisfied. - system.SetStep(timestep); + // system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 400.0; @@ -135,12 +133,12 @@ int main(int argc, char* argv[]) { // define the float's initial conditions system.Add(flap_body); - flap_body->SetNameString("body1"); - auto ang_rad = CH_C_PI / 18.0; - flap_body->SetPos(ChVector<>(new_cg[0], new_cg[1], new_cg[2])); - flap_body->SetRot(Q_from_AngAxis(ang_rad, VECT_Y)); + flap_body->SetName("body1"); + auto ang_rad = CH_PI / 18.0; + flap_body->SetPos(ChVector3d(new_cg[0], new_cg[1], new_cg[2])); + flap_body->SetRot(QuatFromAngleY(ang_rad)); flap_body->SetMass(127000.0); - flap_body->SetInertiaXX(ChVector<>(1.85e6, 1.85e6, 1.85e6)); + flap_body->SetInertiaXX(ChVector3d(1.85e6, 1.85e6, 1.85e6)); // notes: mass and inertia added to added mass and system mass correctly. // set up body from a mesh @@ -160,19 +158,19 @@ int main(int argc, char* argv[]) { // define the plate's initial conditions system.Add(base_body); - base_body->SetNameString("body2"); - base_body->SetPos(ChVector<>(0, 0, -10.15)); + base_body->SetName("body2"); + base_body->SetPos(ChVector3d(0, 0, -10.15)); base_body->SetMass(999); - base_body->SetInertiaXX(ChVector<>(1, 1, 1)); - // base_body->SetBodyFixed(true); + base_body->SetInertiaXX(ChVector3d(1, 1, 1)); + // base_body->SetFixed(true); // create ground auto ground = chrono_types::make_shared(); system.AddBody(ground); - ground->SetPos(ChVector<>(0, 0, -10.15)); - ground->SetIdentifier(-1); - ground->SetBodyFixed(true); - ground->SetCollide(false); + ground->SetPos(ChVector3d(0, 0, -10.15)); + ground->SetTag(-1); + ground->SetFixed(true); + ground->EnableCollision(false); // fix base to ground with special constraint (don't use setfixed() because of mass matrix) auto anchor = chrono_types::make_shared(); anchor->Initialize(base_body, ground, false, base_body->GetVisualModelFrame(), base_body->GetVisualModelFrame()); @@ -180,9 +178,9 @@ int main(int argc, char* argv[]) { anchor->SetConstrainedCoords(true, true, true, true, true, true); // x, y, z, Rx, Ry, Rz // define base-fore flap joint - ChQuaternion<> revoluteRot = Q_from_AngX(CH_C_PI / 2.0); + ChQuaternion<> revoluteRot = QuatFromAngleX(CH_PI / 2.0); auto revolute = chrono_types::make_shared(); - revolute->Initialize(base_body, flap_body, ChCoordsys<>(ChVector<>(0.0, 0.0, -8.9), revoluteRot)); + revolute->Initialize(base_body, flap_body, ChFramed(ChVector3d(0.0, 0.0, -8.9), revoluteRot)); system.AddLink(revolute); auto default_dont_add_waves = std::make_shared(2); @@ -208,7 +206,7 @@ int main(int argc, char* argv[]) { // append data to output vector time_vector.push_back(system.GetChTime()); - flap_rot.push_back(flap_body->GetRot().Q_to_Euler123().y()); + flap_rot.push_back(flap_body->GetRot().GetCardanAnglesXYZ().y()); } } diff --git a/demos/oswec/demo_oswec_reg_waves.cpp b/demos/oswec/demo_oswec_reg_waves.cpp index aca92c4..ab14b69 100644 --- a/demos/oswec/demo_oswec_reg_waves.cpp +++ b/demos/oswec/demo_oswec_reg_waves.cpp @@ -11,7 +11,6 @@ // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; // usage: ./.exe [DATADIR] [--nogui] // @@ -65,7 +64,7 @@ int main(int argc, char* argv[]) { int reg_wave_num_max = periods.size(); for (int reg_wave_num = 1; reg_wave_num <= reg_wave_num_max; ++reg_wave_num) { - GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; @@ -87,12 +86,11 @@ int main(int argc, char* argv[]) { // system/solver settings ChSystemNSC system; - system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.03; // system.SetTimestepperType(ChTimestepper::Type::HHT); system.SetSolverType(ChSolver::Type::GMRES); - // system.SetSolverMaxIterations(300); // the higher, the easier to keep the constraints satisfied. - system.SetStep(timestep); + // system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 1000.0; @@ -139,13 +137,13 @@ int main(int argc, char* argv[]) { // define the float's initial conditions system.Add(flap_body); - flap_body->SetNameString("body1"); - auto ang_rad = CH_C_PI / 18.0; - // flap_body->SetPos(ChVector<>(new_cg[0], new_cg[1], new_cg[2])); - flap_body->SetPos(ChVector<>(0.0, 0.0, -3.9)); - //flap_body->SetRot(Q_from_AngAxis(ang_rad, VECT_Y)); + flap_body->SetName("body1"); + auto ang_rad = CH_PI / 18.0; + // flap_body->SetPos(ChVector3d(new_cg[0], new_cg[1], new_cg[2])); + flap_body->SetPos(ChVector3d(0.0, 0.0, -3.9)); + //flap_body->SetRot(QuatFromAngleY(ang_rad)); flap_body->SetMass(127000.0); - flap_body->SetInertiaXX(ChVector<>(1.85e6, 1.85e6, 1.85e6)); + flap_body->SetInertiaXX(ChVector3d(1.85e6, 1.85e6, 1.85e6)); // notes: mass and inertia added to added mass and system mass correctly. // set up body from a mesh @@ -165,19 +163,19 @@ int main(int argc, char* argv[]) { // define the plate's initial conditions system.Add(base_body); - base_body->SetNameString("body2"); - base_body->SetPos(ChVector<>(0, 0, -10.15)); + base_body->SetName("body2"); + base_body->SetPos(ChVector3d(0, 0, -10.15)); base_body->SetMass(1e9); - base_body->SetInertiaXX(ChVector<>(1e6, 1e6, 1e6)); - // base_body->SetBodyFixed(true); + base_body->SetInertiaXX(ChVector3d(1e6, 1e6, 1e6)); + // base_body->SetFixed(true); // create ground auto ground = chrono_types::make_shared(); system.AddBody(ground); - ground->SetPos(ChVector<>(0, 0, -10.15)); - ground->SetIdentifier(-1); - ground->SetBodyFixed(true); - ground->SetCollide(false); + ground->SetPos(ChVector3d(0, 0, -10.15)); + ground->SetTag(-1); + ground->SetFixed(true); + ground->EnableCollision(false); // fix base to ground with special constraint (don't use setfixed() because of mass matrix) auto anchor = chrono_types::make_shared(); anchor->Initialize(base_body, ground, false, base_body->GetVisualModelFrame(), @@ -186,9 +184,9 @@ int main(int argc, char* argv[]) { anchor->SetConstrainedCoords(true, true, true, true, true, true); // x, y, z, Rx, Ry, Rz // define base-fore flap joint - ChQuaternion<> revoluteRot = Q_from_AngX(CH_C_PI / 2.0); + ChQuaternion<> revoluteRot = QuatFromAngleX(CH_PI / 2.0); auto revolute = chrono_types::make_shared(); - revolute->Initialize(base_body, flap_body, ChCoordsys<>(ChVector<>(0.0, 0.0, -8.9), revoluteRot)); + revolute->Initialize(base_body, flap_body, ChFramed(ChVector3d(0.0, 0.0, -8.9), revoluteRot)); system.AddLink(revolute); // auto default_dont_add_waves = std::make_shared(2); @@ -198,9 +196,9 @@ int main(int argc, char* argv[]) { bodies.push_back(flap_body); bodies.push_back(base_body); - auto my_hydro_inputs = std::make_shared(bodies.size()); + auto my_hydro_inputs = std::make_shared(static_cast(bodies.size())); my_hydro_inputs->regular_wave_amplitude_ = 0.01; - my_hydro_inputs->regular_wave_omega_ = (2 * CH_C_PI)/(periods[reg_wave_num - 1]); + my_hydro_inputs->regular_wave_omega_ = (2 * CH_PI)/(periods[reg_wave_num - 1]); //// attach hydrodynamic forces to body /*std::vector> bodies; @@ -224,7 +222,7 @@ int main(int argc, char* argv[]) { // append data to output vector time_vector.push_back(system.GetChTime()); - flap_rot.push_back(flap_body->GetRot().Q_to_Euler123().y()); + flap_rot.push_back(flap_body->GetRot().GetCardanAnglesXYZ().y()); } } diff --git a/demos/rm3/demo_rm3_decay.cpp b/demos/rm3/demo_rm3_decay.cpp index 65070bd..5cf1885 100644 --- a/demos/rm3/demo_rm3_decay.cpp +++ b/demos/rm3/demo_rm3_decay.cpp @@ -10,7 +10,6 @@ // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; // usage: ./.exe [DATADIR] [--nogui] // @@ -18,7 +17,7 @@ using namespace chrono::geometry; // environment variable to give the data_directory. // int main(int argc, char* argv[]) { - GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; @@ -40,13 +39,12 @@ int main(int argc, char* argv[]) { // system/solver settings ChSystemNSC system; - system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.01; system.SetTimestepperType(ChTimestepper::Type::HHT); system.SetSolverType(ChSolver::Type::GMRES); - system.SetSolverMaxIterations(300); // the higher, the easier to keep the constraints satisfied. - system.SetStep(timestep); + system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 40.0; @@ -74,11 +72,11 @@ int main(int argc, char* argv[]) { // define the float's initial conditions system.Add(float_body1); - float_body1->SetNameString("body1"); - float_body1->SetPos(ChVector<>(0, 0, (-0.72 + 0.1))); + float_body1->SetName("body1"); + float_body1->SetPos(ChVector3d(0, 0, (-0.72 + 0.1))); float_body1->SetMass(725834); - float_body1->SetInertiaXX(ChVector<>(20907301.0, 21306090.66, 37085481.11)); - // float_body1->SetCollide(false); + float_body1->SetInertiaXX(ChVector3d(20907301.0, 21306090.66, 37085481.11)); + // float_body1->EnableCollision(false); // Create a visualization material auto red = chrono_types::make_shared(); @@ -102,20 +100,20 @@ int main(int argc, char* argv[]) { // define the plate's initial conditions system.Add(plate_body2); - plate_body2->SetNameString("body2"); - plate_body2->SetPos(ChVector<>(0, 0, (-21.29))); + plate_body2->SetName("body2"); + plate_body2->SetPos(ChVector3d(0, 0, (-21.29))); plate_body2->SetMass(886691); - plate_body2->SetInertiaXX(ChVector<>(94419614.57, 94407091.24, 28542224.82)); - // plate_body2->SetCollide(false); + plate_body2->SetInertiaXX(ChVector3d(94419614.57, 94407091.24, 28542224.82)); + // plate_body2->EnableCollision(false); // add prismatic joint between the two bodies auto prismatic = chrono_types::make_shared(); - prismatic->Initialize(float_body1, plate_body2, false, ChCoordsys<>(ChVector<>(0, 0, -0.72)), - ChCoordsys<>(ChVector<>(0, 0, -21.29))); + prismatic->Initialize(float_body1, plate_body2, false, ChFramed(ChVector3d(0, 0, -0.72)), + ChFramed(ChVector3d(0, 0, -21.29))); system.AddLink(prismatic); auto prismatic_pto = chrono_types::make_shared(); - prismatic_pto->Initialize(float_body1, plate_body2, false, ChVector<>(0, 0, -0.72), ChVector<>(0, 0, -21.29)); + prismatic_pto->Initialize(float_body1, plate_body2, false, ChVector3d(0, 0, -0.72), ChVector3d(0, 0, -21.29)); prismatic_pto->SetDampingCoefficient(0.0); system.AddLink(prismatic_pto); diff --git a/demos/rm3/demo_rm3_reg_waves.cpp b/demos/rm3/demo_rm3_reg_waves.cpp index 31a277d..70a9bdc 100644 --- a/demos/rm3/demo_rm3_reg_waves.cpp +++ b/demos/rm3/demo_rm3_reg_waves.cpp @@ -10,7 +10,6 @@ // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; // usage: ./.exe [DATADIR] [--nogui] // @@ -18,7 +17,7 @@ using namespace chrono::geometry; // environment variable to give the data_directory. // int main(int argc, char* argv[]) { - GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; @@ -40,12 +39,11 @@ int main(int argc, char* argv[]) { // system/solver settings ChSystemNSC system; - system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.01; system.SetTimestepperType(ChTimestepper::Type::HHT); system.SetSolverType(ChSolver::Type::GMRES); - system.SetSolverMaxIterations(300); // the higher, the easier to keep the constraints satisfied. - system.SetStep(timestep); + system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 40.0; @@ -74,11 +72,11 @@ int main(int argc, char* argv[]) { // define the float's initial conditions system.Add(float_body1); - float_body1->SetNameString("body1"); - float_body1->SetPos(ChVector<>(0, 0, -0.72)); + float_body1->SetName("body1"); + float_body1->SetPos(ChVector3d(0, 0, -0.72)); float_body1->SetMass(725834); - float_body1->SetInertiaXX(ChVector<>(20907301.0, 21306090.66, 37085481.11)); - // float_body1->SetCollide(false); + float_body1->SetInertiaXX(ChVector3d(20907301.0, 21306090.66, 37085481.11)); + // float_body1->EnableCollision(false); // Create a visualization material auto red = chrono_types::make_shared(); @@ -101,20 +99,20 @@ int main(int argc, char* argv[]) { // define the plate's initial conditions system.Add(plate_body2); - plate_body2->SetNameString("body2"); - plate_body2->SetPos(ChVector<>(0, 0, (-21.29))); + plate_body2->SetName("body2"); + plate_body2->SetPos(ChVector3d(0, 0, (-21.29))); plate_body2->SetMass(886691); - plate_body2->SetInertiaXX(ChVector<>(94419614.57, 94407091.24, 28542224.82)); - // plate_body2->SetCollide(false); + plate_body2->SetInertiaXX(ChVector3d(94419614.57, 94407091.24, 28542224.82)); + // plate_body2->EnableCollision(false); // add prismatic joint between the two bodies auto prismatic = chrono_types::make_shared(); - prismatic->Initialize(float_body1, plate_body2, false, ChCoordsys<>(ChVector<>(0, 0, -0.72)), - ChCoordsys<>(ChVector<>(0, 0, -21.29))); + prismatic->Initialize(float_body1, plate_body2, false, ChFramed(ChVector3d(0, 0, -0.72)), + ChFramed(ChVector3d(0, 0, -21.29))); system.AddLink(prismatic); auto prismatic_pto = chrono_types::make_shared(); - prismatic_pto->Initialize(float_body1, plate_body2, false, ChVector<>(0, 0, -0.72), ChVector<>(0, 0, -21.29)); + prismatic_pto->Initialize(float_body1, plate_body2, false, ChVector3d(0, 0, -0.72), ChVector3d(0, 0, -21.29)); prismatic_pto->SetDampingCoefficient(0.0); system.AddLink(prismatic_pto); diff --git a/demos/sphere/demo_sphere_decay.cpp b/demos/sphere/demo_sphere_decay.cpp index 99f3a25..ddb1da3 100644 --- a/demos/sphere/demo_sphere_decay.cpp +++ b/demos/sphere/demo_sphere_decay.cpp @@ -11,7 +11,6 @@ // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; // usage: ./sphere_deca.exe [DATADIR] [--nogui] // @@ -19,7 +18,7 @@ using namespace chrono::geometry; // environment variable to give the data_directory. // int main(int argc, char* argv[]) { - GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; @@ -41,12 +40,11 @@ int main(int argc, char* argv[]) { // system/solver settings ChSystemNSC system; - system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.015; system.SetSolverType(ChSolver::Type::GMRES); - system.SetSolverMaxIterations(300); // the higher, the easier to keep the constraints satisfied. - system.SetStep(timestep); + system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 40.0; @@ -73,8 +71,8 @@ int main(int argc, char* argv[]) { ); // define the body's initial conditions - sphereBody->SetNameString("body1"); // must set body name correctly! (must match .h5 file) - sphereBody->SetPos(ChVector<>(0, 0, -1)); + sphereBody->SetName("body1"); // must set body name correctly! (must match .h5 file) + sphereBody->SetPos(ChVector3d(0, 0, -1)); sphereBody->SetMass(261.8e3); // Create a visualization material diff --git a/demos/sphere/demo_sphere_irreg_waves.cpp b/demos/sphere/demo_sphere_irreg_waves.cpp index 4e35c3b..8aeb20d 100644 --- a/demos/sphere/demo_sphere_irreg_waves.cpp +++ b/demos/sphere/demo_sphere_irreg_waves.cpp @@ -12,7 +12,6 @@ // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; // usage: ./.exe [DATADIR] [--nogui] // @@ -20,7 +19,7 @@ using namespace chrono::geometry; // environment variable to give the data_directory. // int main(int argc, char* argv[]) { - GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; @@ -40,11 +39,10 @@ int main(int argc, char* argv[]) { // // system/solver settings ChSystemNSC system; - system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.015; system.SetSolverType(ChSolver::Type::GMRES); - system.SetSolverMaxIterations(300); - system.SetStep(timestep); + system.GetSolver()->AsIterative()->SetMaxIterations(300); ChRealtimeStepTimer realtime_timer; double simulationDuration = 600.0; @@ -56,10 +54,10 @@ int main(int argc, char* argv[]) { // Setup Ground auto ground = chrono_types::make_shared(); system.AddBody(ground); - ground->SetPos(ChVector<>(0, 0, -5)); - ground->SetIdentifier(-1); - ground->SetBodyFixed(true); - ground->SetCollide(false); + ground->SetPos(ChVector3d(0, 0, -5)); + ground->SetTag(-1); + ground->SetFixed(true); + ground->EnableCollision(false); // some io/viz options bool profilingOn = true; @@ -79,8 +77,8 @@ int main(int argc, char* argv[]) { // // define the body's initial conditions system.Add(sphereBody); - sphereBody->SetNameString("body1"); // must set body name correctly! (must match .h5 file) - sphereBody->SetPos(ChVector<>(0, 0, -2)); + sphereBody->SetName("body1"); // must set body name correctly! (must match .h5 file) + sphereBody->SetPos(ChVector3d(0, 0, -2)); sphereBody->SetMass(261.8e3); // create a visualization material @@ -92,8 +90,8 @@ int main(int argc, char* argv[]) { // add prismatic joint between sphere and ground (limit to heave motion only) auto prismatic = chrono_types::make_shared(); - prismatic->Initialize(sphereBody, ground, false, ChCoordsys<>(ChVector<>(0, 0, -2)), - ChCoordsys<>(ChVector<>(0, 0, -5))); + prismatic->Initialize(sphereBody, ground, false, ChFramed(ChVector3d(0, 0, -2)), + ChFramed(ChVector3d(0, 0, -5))); system.AddLink(prismatic); // create the spring between body_1 and ground. The spring end points are @@ -102,8 +100,8 @@ int main(int argc, char* argv[]) { double spring_coef = 0.0; double damping_coef = 0.0; auto spring_1 = chrono_types::make_shared(); - spring_1->Initialize(sphereBody, ground, false, ChVector<>(0, 0, -2), - ChVector<>(0, 0, -5)); // false means positions are in global frame + spring_1->Initialize(sphereBody, ground, false, ChVector3d(0, 0, -2), + ChVector3d(0, 0, -5)); // false means positions are in global frame spring_1->SetSpringCoefficient(spring_coef); spring_1->SetDampingCoefficient(damping_coef); system.AddLink(spring_1); @@ -137,9 +135,9 @@ int main(int argc, char* argv[]) { // set up free surface from a mesh auto fse_plane = chrono_types::make_shared(); - fse_plane->SetPos(ChVector<>(0, 0, 0)); - fse_plane->SetBodyFixed(true); - fse_plane->SetCollide(false); + fse_plane->SetPos(ChVector3d(0, 0, 0)); + fse_plane->SetFixed(true); + fse_plane->EnableCollision(false); system.AddBody(fse_plane); my_hydro_inputs->SetUpWaveMesh(); @@ -151,10 +149,10 @@ int main(int argc, char* argv[]) { false // do not collide ); fse_mesh->SetMass(1.0); - fse_mesh->SetPos_dt(my_hydro_inputs->GetWaveMeshVelocity()); + fse_mesh->SetPosDt(my_hydro_inputs->GetWaveMeshVelocity()); system.Add(fse_mesh); auto fse_prismatic = chrono_types::make_shared(); - fse_prismatic->Initialize(fse_plane, fse_mesh, ChCoordsys<>(ChVector<>(1.0, 0.0, 0.0), Q_from_AngY(CH_C_PI_2))); + fse_prismatic->Initialize(fse_plane, fse_mesh, ChFramed(ChVector3d(1.0, 0.0, 0.0), QuatFromAngleY(CH_PI_2))); system.AddLink(fse_prismatic); // Create a visualization material diff --git a/demos/sphere/demo_sphere_irreg_waves_eta_import.cpp b/demos/sphere/demo_sphere_irreg_waves_eta_import.cpp index 5eabb7e..32719eb 100644 --- a/demos/sphere/demo_sphere_irreg_waves_eta_import.cpp +++ b/demos/sphere/demo_sphere_irreg_waves_eta_import.cpp @@ -12,7 +12,6 @@ // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; // usage: ./.exe [DATADIR] [--nogui] // @@ -20,7 +19,7 @@ using namespace chrono::geometry; // environment variable to give the data_directory. // int main(int argc, char* argv[]) { - GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; @@ -40,11 +39,10 @@ int main(int argc, char* argv[]) { // system/solver settings ChSystemNSC system; - system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.015; system.SetSolverType(ChSolver::Type::GMRES); - system.SetSolverMaxIterations(300); - system.SetStep(timestep); + system.GetSolver()->AsIterative()->SetMaxIterations(300); ChRealtimeStepTimer realtime_timer; double simulationDuration = 600.0; @@ -56,10 +54,10 @@ int main(int argc, char* argv[]) { // Setup Ground auto ground = chrono_types::make_shared(); system.AddBody(ground); - ground->SetPos(ChVector<>(0, 0, -5)); - ground->SetIdentifier(-1); - ground->SetBodyFixed(true); - ground->SetCollide(false); + ground->SetPos(ChVector3d(0, 0, -5)); + ground->SetTag(-1); + ground->SetFixed(true); + ground->EnableCollision(false); // some io/viz options bool profilingOn = true; @@ -79,8 +77,8 @@ int main(int argc, char* argv[]) { // define the body's initial conditions system.Add(sphereBody); - sphereBody->SetNameString("body1"); // must set body name correctly! (must match .h5 file) - sphereBody->SetPos(ChVector<>(0, 0, -2)); + sphereBody->SetName("body1"); // must set body name correctly! (must match .h5 file) + sphereBody->SetPos(ChVector3d(0, 0, -2)); sphereBody->SetMass(261.8e3); // Create a visualization material @@ -92,8 +90,8 @@ int main(int argc, char* argv[]) { // add prismatic joint between sphere and ground (limit to heave motion only) auto prismatic = chrono_types::make_shared(); - prismatic->Initialize(sphereBody, ground, false, ChCoordsys<>(ChVector<>(0, 0, -2)), - ChCoordsys<>(ChVector<>(0, 0, -5))); + prismatic->Initialize(sphereBody, ground, false, ChFramed(ChVector3d(0, 0, -2)), + ChFramed(ChVector3d(0, 0, -5))); system.AddLink(prismatic); // Create the spring between body_1 and ground. The spring end points are @@ -102,8 +100,8 @@ int main(int argc, char* argv[]) { double spring_coef = 0.0; double damping_coef = 0.0; auto spring_1 = chrono_types::make_shared(); - spring_1->Initialize(sphereBody, ground, false, ChVector<>(0, 0, -2), - ChVector<>(0, 0, -5)); // false means positions are in global frame + spring_1->Initialize(sphereBody, ground, false, ChVector3d(0, 0, -2), + ChVector3d(0, 0, -5)); // false means positions are in global frame spring_1->SetSpringCoefficient(spring_coef); spring_1->SetDampingCoefficient(damping_coef); system.AddLink(spring_1); @@ -144,9 +142,9 @@ int main(int argc, char* argv[]) { std::cout << "Creating fse mesh..." << std::endl; // set up free surface from a mesh auto fse_plane = chrono_types::make_shared(); - fse_plane->SetPos(ChVector<>(0, 0, 0)); - fse_plane->SetBodyFixed(true); - fse_plane->SetCollide(false); + fse_plane->SetPos(ChVector3d(0, 0, 0)); + fse_plane->SetFixed(true); + fse_plane->EnableCollision(false); system.AddBody(fse_plane); //std::cout << "SetUpWaveMesh..." << std::endl; @@ -163,7 +161,7 @@ int main(int argc, char* argv[]) { //std::cout << "system.Add(fse_mesh)..." << std::endl; //system.Add(fse_mesh); //auto fse_prismatic = chrono_types::make_shared(); - //fse_prismatic->Initialize(fse_plane, fse_mesh, ChCoordsys<>(ChVector<>(1.0, 0.0, 0.0), Q_from_AngY(CH_C_PI_2))); + //fse_prismatic->Initialize(fse_plane, fse_mesh, ChFramed(ChVector3d(1.0, 0.0, 0.0), QuatFromAnglY(CH_PI_2))); //system.AddLink(fse_prismatic); //// Create a visualization material diff --git a/demos/sphere/demo_sphere_reg_waves.cpp b/demos/sphere/demo_sphere_reg_waves.cpp index 78e670d..2f2947c 100644 --- a/demos/sphere/demo_sphere_reg_waves.cpp +++ b/demos/sphere/demo_sphere_reg_waves.cpp @@ -11,7 +11,6 @@ // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; // usage: ./.exe [DATADIR] [--nogui] // @@ -33,7 +32,7 @@ int main(int argc, char* argv[]) { for (int reg_wave_num = 1; reg_wave_num <= reg_wave_num_max; ++reg_wave_num) { - GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; @@ -54,11 +53,10 @@ int main(int argc, char* argv[]) { // system/solver settings ChSystemNSC system; - system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.015; system.SetSolverType(ChSolver::Type::GMRES); - system.SetSolverMaxIterations(300); // the higher, the easier to keep the constraints satisfied. - system.SetStep(timestep); + system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulation_duration = 600.0; @@ -70,10 +68,10 @@ int main(int argc, char* argv[]) { // Setup Ground auto ground = chrono_types::make_shared(); system.AddBody(ground); - ground->SetPos(ChVector<>(0, 0, -5)); - ground->SetIdentifier(-1); - ground->SetBodyFixed(true); - ground->SetCollide(false); + ground->SetPos(ChVector3d(0, 0, -5)); + ground->SetTag(-1); + ground->SetFixed(true); + ground->EnableCollision(false); // some io/viz options bool profilingOn = true; @@ -95,8 +93,8 @@ int main(int argc, char* argv[]) { // define the body's initial conditions system.Add(sphereBody); - sphereBody->SetNameString("body1"); // must set body name correctly! (must match .h5 file) - sphereBody->SetPos(ChVector<>(0, 0, -2)); + sphereBody->SetName("body1"); // must set body name correctly! (must match .h5 file) + sphereBody->SetPos(ChVector3d(0, 0, -2)); sphereBody->SetMass(261.8e3); // Create a visualization material @@ -106,8 +104,8 @@ int main(int argc, char* argv[]) { // add prismatic joint between sphere and ground (limit to heave motion only) auto prismatic = chrono_types::make_shared(); - prismatic->Initialize(sphereBody, ground, false, ChCoordsys<>(ChVector<>(0, 0, -2)), - ChCoordsys<>(ChVector<>(0, 0, -5))); + prismatic->Initialize(sphereBody, ground, false, ChFramed(ChVector3d(0, 0, -2)), + ChFramed(ChVector3d(0, 0, -5))); system.AddLink(prismatic); // Create the spring between body_1 and ground. The spring end points are @@ -116,8 +114,8 @@ int main(int argc, char* argv[]) { double spring_coef = 0.0; double damping_coef = task10_damping_coeffs[reg_wave_num - 1]; auto spring_1 = chrono_types::make_shared(); - spring_1->Initialize(sphereBody, ground, false, ChVector<>(0, 0, -2), - ChVector<>(0, 0, -5)); // false means positions are in global frame + spring_1->Initialize(sphereBody, ground, false, ChVector3d(0, 0, -2), + ChVector3d(0, 0, -5)); // false means positions are in global frame // spring_1->SetRestLength(rest_length); // if not set, the rest length is calculated from initial position spring_1->SetSpringCoefficient(spring_coef); spring_1->SetDampingCoefficient(damping_coef); diff --git a/demos/sphere/sphere_irreg_waves.cpp b/demos/sphere/sphere_irreg_waves.cpp index 3c31f45..011af10 100644 --- a/demos/sphere/sphere_irreg_waves.cpp +++ b/demos/sphere/sphere_irreg_waves.cpp @@ -23,7 +23,6 @@ using namespace chrono::irrlicht; // Use the namespaces of Chrono using namespace chrono; -using namespace chrono::geometry; #ifdef HYDROCHRONO_HAVE_IRRLICHT class MyActionReceiver : public IEventReceiver { @@ -67,7 +66,7 @@ class MyActionReceiver : public IEventReceiver { #endif int main(int argc, char* argv[]) { - GetLog() << "Chrono version: " << CHRONO_VERSION << "\n\n"; + std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; @@ -81,21 +80,20 @@ int main(int argc, char* argv[]) { // system/solver settings ChSystemNSC system; - system.Set_G_acc(ChVector<>(0.0, 0.0, -9.81)); + system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.015; system.SetSolverType(ChSolver::Type::GMRES); - system.SetSolverMaxIterations(300); // the higher, the easier to keep the constraints satisfied. - system.SetStep(timestep); + system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 600.0; // Setup Ground auto ground = chrono_types::make_shared(); system.AddBody(ground); - ground->SetPos(ChVector<>(0, 0, -5)); - ground->SetIdentifier(-1); - ground->SetBodyFixed(true); - ground->SetCollide(false); + ground->SetPos(ChVector3d(0, 0, -5)); + ground->SetTag(-1); + ground->SetFixed(true); + ground->EnableCollision(false); // some io/viz options bool visualizationOn = true; @@ -116,14 +114,14 @@ int main(int argc, char* argv[]) { // define the body's initial conditions system.Add(sphereBody); - sphereBody->SetNameString("body1"); // must set body name correctly! (must match .h5 file) - sphereBody->SetPos(ChVector<>(0, 0, -2)); + sphereBody->SetName("body1"); // must set body name correctly! (must match .h5 file) + sphereBody->SetPos(ChVector3d(0, 0, -2)); sphereBody->SetMass(261.8e3); // add prismatic joint between sphere and ground (limit to heave motion only) auto prismatic = chrono_types::make_shared(); - prismatic->Initialize(sphereBody, ground, false, ChCoordsys<>(ChVector<>(0, 0, -2)), - ChCoordsys<>(ChVector<>(0, 0, -5))); + prismatic->Initialize(sphereBody, ground, false, ChFramed(ChVector3d(0, 0, -2)), + ChFramed(ChVector3d(0, 0, -5))); system.AddLink(prismatic); // Create the spring between body_1 and ground. The spring end points are @@ -132,8 +130,8 @@ int main(int argc, char* argv[]) { double spring_coef = 0.0; double damping_coef = 0.0; auto spring_1 = chrono_types::make_shared(); - spring_1->Initialize(sphereBody, ground, false, ChVector<>(0, 0, -2), - ChVector<>(0, 0, -5)); // false means positions are in global frame + spring_1->Initialize(sphereBody, ground, false, ChVector3d(0, 0, -2), + ChVector3d(0, 0, -5)); // false means positions are in global frame // spring_1->SetRestLength(rest_length); // if not set, the rest length is calculated from initial position spring_1->SetSpringCoefficient(spring_coef); spring_1->SetDampingCoefficient(damping_coef); @@ -164,9 +162,9 @@ int main(int argc, char* argv[]) { // set up free surface from a mesh auto fse_plane = chrono_types::make_shared(); - fse_plane->SetPos(ChVector<>(0, 0, 0)); - fse_plane->SetBodyFixed(true); - fse_plane->SetCollide(false); + fse_plane->SetPos(ChVector3d(0, 0, 0)); + fse_plane->SetFixed(true); + fse_plane->EnableCollision(false); system.AddBody(fse_plane); my_hydro_inputs->SetUpWaveMesh(); @@ -181,7 +179,7 @@ int main(int argc, char* argv[]) { fse_mesh->SetPos_dt(my_hydro_inputs->GetWaveMeshVelocity()); system.Add(fse_mesh); auto fse_prismatic = chrono_types::make_shared(); - fse_prismatic->Initialize(fse_plane, fse_mesh, ChCoordsys<>(ChVector<>(1.0, 0.0, 0.0), Q_from_AngY(CH_C_PI_2))); + fse_prismatic->Initialize(fse_plane, fse_mesh, ChFramed(ChVector3d(1.0, 0.0, 0.0), QuatFromAnglY(CH_PI_2))); system.AddLink(fse_prismatic); #ifdef HYDROCHRONO_HAVE_IRRLICHT @@ -208,7 +206,7 @@ int main(int argc, char* argv[]) { irrlichtVis->AddLogo(); irrlichtVis->AddSkyBox(); - irrlichtVis->AddCamera(ChVector<>(8, -25, 15), ChVector<>(0, 0, 0)); + irrlichtVis->AddCamera(ChVector3d(8, -25, 15), ChVector3d(0, 0, 0)); irrlichtVis->AddTypicalLights(); // add play/pause button @@ -224,7 +222,7 @@ int main(int argc, char* argv[]) { // Add grid to materialize horizontal plane tools::drawGrid(irrlichtVis.get(), 1, 1, 30, 30, - ChCoordsys<>(ChVector<>(0, 0.0, 0), Q_from_AngZ(CH_C_PI_2)), chrono::ChColor(.1f, .1f, .1f), + ChFramed(ChVector3d(0, 0.0, 0), Q_from_AngZ(CH_PI_2)), chrono::ChColor(.1f, .1f, .1f), true); if (buttonPressed) { diff --git a/include/hydroc/chloadaddedmass.h b/include/hydroc/chloadaddedmass.h index 9570141..2b67fbf 100644 --- a/include/hydroc/chloadaddedmass.h +++ b/include/hydroc/chloadaddedmass.h @@ -59,21 +59,14 @@ class ChLoadAddedMass : public chrono::ChLoadCustomMultiple { * @brief This is the function that sets the infinite added mass matrix every timestep. * * From Chrono docs: - * For efficiency reasons, do not let the parent class do automatic differentiation - * to compute the R, K matrices. Use analytic expressions instead. For example, R is - * the well known gyroscopic damping matrix. Also, compute the M matrix. + * Compute the K=-dQ/dx, R=-dQ/dv, M=-dQ/da Jacobians. + * Implementation in a derived class should load the Jacobian matrices K, R, M in the structure 'm_jacobians'. + * Note the sign that is flipped because we assume equations are written with Q moved to left-hand side. * * @param state_x state position to evaluate jacobians * @param state_w state speed to evaluate jacobians - * @param mK result -dQ/dx - * @param mR result -dQ/dv - * @param mM result -dQ/da */ - virtual void ComputeJacobian(ChState* state_x, - ChStateDelta* state_w, - ChMatrixRef mK, - ChMatrixRef mR, - ChMatrixRef mM) override; + virtual void ComputeJacobian(ChState* state_x, ChStateDelta* state_w) override; /** * @brief Computes LoadIntLoadResidual_Mv for vector w, const c, and vector R. Also carried over from chrono diff --git a/include/hydroc/hydro_forces.h b/include/hydroc/hydro_forces.h index 550cb05..0e69db6 100644 --- a/include/hydroc/hydro_forces.h +++ b/include/hydroc/hydro_forces.h @@ -78,7 +78,7 @@ class ComponentFunc : public ChFunction { * @param x Time from simulation. * @return Force on body in the specified degree of freedom at time x. */ - virtual double Get_y(double x) const override; + virtual double GetVal(double x) const override; private: ForceFunc6d* base_; ///< Pointer to the full 6D force on the body. diff --git a/src/chloadaddedmass.cpp b/src/chloadaddedmass.cpp index ca9bd1b..e8fa589 100644 --- a/src/chloadaddedmass.cpp +++ b/src/chloadaddedmass.cpp @@ -24,18 +24,15 @@ ChLoadAddedMass::ChLoadAddedMass(const std::vector& user_h5 infinite_added_mass_system = infinite_added_mass; } -void ChLoadAddedMass::ComputeJacobian(ChState* state_x, ///< state position to evaluate jacobians - ChStateDelta* state_w, ///< state speed to evaluate jacobians - ChMatrixRef mK, ///< result dQ/dx - ChMatrixRef mR, ///< result dQ/dv - ChMatrixRef mM ///< result dQ/da +void ChLoadAddedMass::ComputeJacobian(ChState* state_x, ///< state position to evaluate jacobians + ChStateDelta* state_w ///< state speed to evaluate jacobians ) { // The following ensures that the added mass matrix matches the size of the ChSystem mass matrix. It is necessary // for systems that have both hydro and non-hydro bodies when adding a system-wide load. // @todo if possible, remove hack by using initialiazer function called AFTER the ChSystem is assembled. // get mass matrix size - auto mmrows = system->GetNcoords_w(); // number of rows in system mass matrix + auto mmrows = system->GetNumCoordsVelLevel(); // number of rows in system mass matrix // check if ChSystem mass matrix size different from added mass matrix size if (mmrows != infinite_added_mass_system.rows() && mmrows > 0) { // initialize/update system matrix; @@ -44,19 +41,19 @@ void ChLoadAddedMass::ComputeJacobian(ChState* state_x, ///< state positio infinite_added_mass_system.block(0, 0, amrows, amrows) = infinite_added_mass; } // set mass matrix here - jacobians->M = infinite_added_mass_system; + m_jacobians->M = infinite_added_mass_system; // R gyroscopic damping matrix terms (6Nx6N) // 0 for added mass - jacobians->R.setZero(); + m_jacobians->R.setZero(); // K inertial stiffness matrix terms (6Nx6N) // 0 for added mass - jacobians->K.setZero(); + m_jacobians->K.setZero(); } void ChLoadAddedMass::LoadIntLoadResidual_Mv(ChVectorDynamic<>& R, const ChVectorDynamic<>& w, const double c) { - if (!this->jacobians) return; + if (!this->m_jacobians) return; // if (!loadable->IsSubBlockActive(0)) // return; @@ -70,5 +67,5 @@ void ChLoadAddedMass::LoadIntLoadResidual_Mv(ChVectorDynamic<>& R, const ChVecto // R.segment(loadable->GetSubBlockOffset(0) + 3, 3) += c * (this->mass * chrono::Vcross(this->c_m, a_x) + this->I * // a_w).eigen(); // since R is a vector, we can probably just do R += C*M*a with no need to separate w into a_x and a_w above - R += c * jacobians->M * w; + R += c * m_jacobians->M * w; } \ No newline at end of file diff --git a/src/gui/guihelper.cpp b/src/gui/guihelper.cpp index 707b9f4..9bfa4e9 100644 --- a/src/gui/guihelper.cpp +++ b/src/gui/guihelper.cpp @@ -10,9 +10,8 @@ using namespace hydroc::gui; #include #include - #include #include - #include + #include #include #include @@ -102,7 +101,7 @@ void GUIImpl::Init(UI& ui, chrono::ChSystem* system, const char* title) { pVis->AddLogo(); pVis->AddSkyBox(); - pVis->AddCamera(chrono::ChVector<>(8, -25, 15), chrono::ChVector<>(0, 0, 0)); + pVis->AddCamera(chrono::ChVector3d(8, -25, 15), chrono::ChVector3d(0, 0, 0)); pVis->AddTypicalLights(); } @@ -118,7 +117,7 @@ bool GUIImpl::IsRunning(double timestep) { // Add grid to materialize horizontal plane tools::drawGrid(pVis.get(), 1, 1, 30, 30, - chrono::ChCoordsys<>(chrono::ChVector<>(0, 0.0, 0), chrono::Q_from_AngZ(chrono::CH_C_PI_2)), + chrono::ChCoordsys<>(chrono::ChVector3d(0, 0.0, 0), chrono::QuatFromAngleZ(chrono::CH_PI_2)), chrono::ChColor(.1f, .1f, .1f), true); pVis->EndScene(); diff --git a/src/helper.cpp b/src/helper.cpp index 9ebc461..bc13083 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -30,11 +30,11 @@ int hydroc::SetInitialEnvironment(int argc, char* argv[]) noexcept { if (env_p == nullptr) { if (argc < 2) { - std::cerr << "Warning::Usage: .exe [] or set HYDROCHRONO_DATA_DIR environement variable" + std::cerr << "Warning::Usage: .exe [] or set HYDROCHRONO_DATA_DIR environment variable" << std::endl; DATADIR = absolute(path("..") / ".." / "demos"); - std::cerr << "Set default demos path to'" << getDataDir() << "'" << std::endl; + std::cerr << "Set default demos path to '" << getDataDir() << "'" << std::endl; return 0; } else { DATADIR = absolute(path(argv[1])); diff --git a/src/hydro_forces.cpp b/src/hydro_forces.cpp index 1a7cb05..ac8eb9d 100644 --- a/src/hydro_forces.cpp +++ b/src/hydro_forces.cpp @@ -69,7 +69,7 @@ ComponentFunc::ComponentFunc(const ComponentFunc& old) { index_ = old.index_; } -double ComponentFunc::Get_y(double x) const { +double ComponentFunc::GetVal(double x) const { if (base_ == NULL) { std::cout << "base == Null!" << std::endl; return 0; @@ -90,13 +90,13 @@ ForceFunc6d::ForceFunc6d() : forces_{{this, 0}, {this, 1}, {this, 2}, {this, 3}, chrono_torque_ = chrono_types::make_shared(); chrono_force_->SetAlign(ChForce::AlignmentFrame::WORLD_DIR); chrono_torque_->SetAlign(ChForce::AlignmentFrame::WORLD_DIR); - chrono_force_->SetNameString("hydroforce"); - chrono_torque_->SetNameString("hydrotorque"); + chrono_force_->SetName("hydroforce"); + chrono_torque_->SetName("hydrotorque"); } ForceFunc6d::ForceFunc6d(std::shared_ptr object, TestHydro* user_all_forces) : ForceFunc6d() { body_ = object; - std::string temp = body_->GetNameString(); // remove "body" from "bodyN", convert N to int, get body num + std::string temp = body_->GetName(); // remove "body" from "bodyN", convert N to int, get body num b_num_ = stoi(temp.erase(0, 4)); // 1 indexed TODO: fix b_num starting here to be 0 indexed all_hydro_forces_ = user_all_forces; // TODO switch to smart pointers? does this use = ? if (all_hydro_forces_ == NULL) { @@ -254,7 +254,7 @@ std::vector TestHydro::ComputeForceHydrostatics() { assert(num_bodies_ > 0); const double rho = file_info_.GetRhoVal(); - const auto g_acc = bodies_[0]->GetSystem()->Get_G_acc(); // assuming all bodies in same system + const auto g_acc = bodies_[0]->GetSystem()->GetGravitationalAcceleration(); // assuming all bodies in same system const double gg = g_acc.Length(); for (int b = 0; b < num_bodies_; b++) { @@ -266,7 +266,7 @@ std::vector TestHydro::ComputeForceHydrostatics() { // hydrostatic stiffness due to offset from equilibrium const auto body_position = body->GetPos(); - const auto body_rotation = body->GetRot().Q_to_Euler123(); + const auto body_rotation = body->GetRot().GetCardanAnglesXYZ(); chrono::ChVectorN body_displacement; for (int ii = 0; ii < kDofLinOrRot; ii++) { @@ -288,7 +288,7 @@ std::vector TestHydro::ComputeForceHydrostatics() { int r_offset = kDofLinOrRot * b; const auto cg2cb = - chrono::ChVector(cb_minus_cg_[r_offset], cb_minus_cg_[r_offset + 1], cb_minus_cg_[r_offset + 2]); + chrono::ChVector3d(cb_minus_cg_[r_offset], cb_minus_cg_[r_offset + 1], cb_minus_cg_[r_offset + 2]); const auto buoyancy2 = cg2cb % buoyancy; for (int ii = 0; ii < kDofLinOrRot; ii++) { @@ -319,8 +319,8 @@ std::vector TestHydro::ComputeForceRadiationDampingConv() { auto& body = bodies_[b]; auto& velocity_history_body = velocity_history_[b]; - auto vel = body->GetPos_dt(); - auto wvel = body->GetWvel_par(); + auto vel = body->GetPosDt(); + auto wvel = body->GetAngVelParent(); std::vector vel_vec = {vel[0], vel[1], vel[2], wvel[0], wvel[1], wvel[2]}; velocity_history_body.insert(velocity_history_body.begin(), vel_vec); } From 74ebcb63be5077d9a90da3db299ffeb82e9b04db Mon Sep 17 00:00:00 2001 From: DarioMangoni Date: Fri, 19 Apr 2024 12:00:00 +0200 Subject: [PATCH 2/5] Set CHRONO_DATA_DIR in demos --- demos/CMakeLists.txt | 12 +++++ demos/DeepCWind/demo_DeepCWind_decay.cpp | 15 +++--- demos/f3of/demo_F3OF_DT1.cpp | 9 ++-- demos/f3of/demo_F3OF_DT2.cpp | 9 ++-- demos/f3of/demo_F3OF_DT3.cpp | 11 ++-- demos/oswec/demo_oswec_decay.cpp | 15 +++--- demos/oswec/demo_oswec_reg_waves.cpp | 3 ++ demos/rm3/demo_rm3_decay.cpp | 13 +++-- demos/rm3/demo_rm3_reg_waves.cpp | 15 +++--- demos/sphere/demo_sphere_decay.cpp | 20 ++++---- demos/sphere/demo_sphere_irreg_waves.cpp | 15 +++--- .../demo_sphere_irreg_waves_eta_import.cpp | 51 ++++++++++--------- demos/sphere/demo_sphere_reg_waves.cpp | 12 +++-- src/hydro_forces.cpp | 2 +- 14 files changed, 121 insertions(+), 81 deletions(-) diff --git a/demos/CMakeLists.txt b/demos/CMakeLists.txt index 18717d5..d123bb4 100644 --- a/demos/CMakeLists.txt +++ b/demos/CMakeLists.txt @@ -14,6 +14,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT) target_compile_definitions(demo_sphere_decay PRIVATE HYDROCHRONO_HAVE_IRRLICHT=1 + "CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"" ) endif() @@ -49,6 +50,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT) target_compile_definitions(demo_sphere_reg_waves PRIVATE HYDROCHRONO_HAVE_IRRLICHT=1 + "CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"" ) endif() @@ -83,6 +85,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT) target_compile_definitions(demo_sphere_irreg_waves PRIVATE HYDROCHRONO_HAVE_IRRLICHT=1 + "CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"" ) endif() @@ -116,6 +119,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT) target_compile_definitions(demo_sphere_irreg_waves_eta_import PRIVATE HYDROCHRONO_HAVE_IRRLICHT=1 + "CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"" ) endif() @@ -148,6 +152,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT) target_compile_definitions(demo_rm3_decay PRIVATE HYDROCHRONO_HAVE_IRRLICHT=1 + "CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"" ) endif() @@ -182,6 +187,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT) target_compile_definitions(demo_rm3_reg_waves PRIVATE HYDROCHRONO_HAVE_IRRLICHT=1 + "CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"" ) endif() @@ -216,6 +222,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT) target_compile_definitions(demo_oswec_decay PRIVATE HYDROCHRONO_HAVE_IRRLICHT=1 + "CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"" ) endif() @@ -249,6 +256,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT) target_compile_definitions(demo_oswec_reg_waves PRIVATE HYDROCHRONO_HAVE_IRRLICHT=1 + "CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"" ) endif() @@ -282,6 +290,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT) target_compile_definitions(demo_f3of_DT1 PRIVATE HYDROCHRONO_HAVE_IRRLICHT=1 + "CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"" ) endif() @@ -315,6 +324,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT) target_compile_definitions(demo_f3of_DT2 PRIVATE HYDROCHRONO_HAVE_IRRLICHT=1 + "CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"" ) endif() @@ -347,6 +357,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT) target_compile_definitions(demo_f3of_DT3 PRIVATE HYDROCHRONO_HAVE_IRRLICHT=1 + "CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"" ) endif() @@ -380,6 +391,7 @@ if(HYDROCHRONO_ENABLE_IRRLICHT) target_compile_definitions(demo_DeepCWind_decay PRIVATE HYDROCHRONO_HAVE_IRRLICHT=1 + "CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\"" ) endif() diff --git a/demos/DeepCWind/demo_DeepCWind_decay.cpp b/demos/DeepCWind/demo_DeepCWind_decay.cpp index 13844b4..a99b1e0 100644 --- a/demos/DeepCWind/demo_DeepCWind_decay.cpp +++ b/demos/DeepCWind/demo_DeepCWind_decay.cpp @@ -20,6 +20,8 @@ int main(int argc, char* argv[]) { // auto start = std::chrono::high_resolution_clock::now(); std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; + SetChronoDataPath(CHRONO_DATA_DIR); + if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; } @@ -41,16 +43,17 @@ int main(int argc, char* argv[]) { double timestep = 0.08; system.SetTimestepperType(ChTimestepper::Type::HHT); system.SetSolverType(ChSolver::Type::GMRES); - system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. + system.GetSolver()->AsIterative()->SetMaxIterations( + 300); // the higher, the easier to keep the constraints satisfied. double simulationDuration = 1000.0; // Create user interface std::shared_ptr pui = hydroc::gui::CreateUI(visualizationOn); - hydroc::gui::UI& ui = *pui.get(); + hydroc::gui::UI& ui = *pui.get(); // some io/viz options - bool profilingOn = true; - bool saveDataOn = true; + bool profilingOn = true; + bool saveDataOn = true; std::vector time_vector; std::vector base_pitch; std::vector base_surge; @@ -150,8 +153,8 @@ int main(int argc, char* argv[]) { outputFile.open("./results/DeepCWind_decay.txt"); if (!outputFile.is_open()) { if (!std::filesystem::exists("./results")) { - std::cout << "Path " << std::filesystem::absolute("./results") - << " does not exist, creating it now..." << std::endl; + std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..." + << std::endl; std::filesystem::create_directory("./results"); outputFile.open("./results/DeepCWind_decay.txt"); if (!outputFile.is_open()) { diff --git a/demos/f3of/demo_F3OF_DT1.cpp b/demos/f3of/demo_F3OF_DT1.cpp index b575022..a7d0eb9 100644 --- a/demos/f3of/demo_F3OF_DT1.cpp +++ b/demos/f3of/demo_F3OF_DT1.cpp @@ -19,6 +19,8 @@ using namespace chrono; int main(int argc, char* argv[]) { std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; + SetChronoDataPath(CHRONO_DATA_DIR); + if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; } @@ -43,7 +45,8 @@ int main(int argc, char* argv[]) { system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.02; system.SetSolverType(ChSolver::Type::SPARSE_QR); - system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. + system.GetSolver()->AsIterative()->SetMaxIterations( + 300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 300.0; @@ -216,8 +219,8 @@ int main(int argc, char* argv[]) { outputFile.open("./results/CHRONO_F3OF_DT1_SURGE.txt"); if (!outputFile.is_open()) { if (!std::filesystem::exists("./results")) { - std::cout << "Path " << std::filesystem::absolute("./results") - << " does not exist, creating it now..." << std::endl; + std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..." + << std::endl; std::filesystem::create_directory("./results"); outputFile.open("./results/CHRONO_F3OF_DT1_SURGE.txt"); if (!outputFile.is_open()) { diff --git a/demos/f3of/demo_F3OF_DT2.cpp b/demos/f3of/demo_F3OF_DT2.cpp index 40a5e6a..8087360 100644 --- a/demos/f3of/demo_F3OF_DT2.cpp +++ b/demos/f3of/demo_F3OF_DT2.cpp @@ -19,6 +19,8 @@ using namespace chrono; int main(int argc, char* argv[]) { std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; + SetChronoDataPath(CHRONO_DATA_DIR); + if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; } @@ -43,7 +45,8 @@ int main(int argc, char* argv[]) { system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.02; system.SetSolverType(ChSolver::Type::SPARSE_QR); - system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. + system.GetSolver()->AsIterative()->SetMaxIterations( + 300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 300.0; @@ -222,8 +225,8 @@ int main(int argc, char* argv[]) { outputFile.open("./results/CHRONO_F3OF_DT2_PITCH.txt"); if (!outputFile.is_open()) { if (!std::filesystem::exists("./results")) { - std::cout << "Path " << std::filesystem::absolute("./results") - << " does not exist, creating it now..." << std::endl; + std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..." + << std::endl; std::filesystem::create_directory("./results"); outputFile.open("./results/CHRONO_F3OF_DT2_PITCH.txt"); if (!outputFile.is_open()) { diff --git a/demos/f3of/demo_F3OF_DT3.cpp b/demos/f3of/demo_F3OF_DT3.cpp index 3cfc828..ccefc19 100644 --- a/demos/f3of/demo_F3OF_DT3.cpp +++ b/demos/f3of/demo_F3OF_DT3.cpp @@ -3,7 +3,7 @@ #include #include -#include // fixed body uses link +#include // fixed body uses link #include // std::chrono::high_resolution_clock::now #include // std::setprecision @@ -20,6 +20,8 @@ using namespace chrono; int main(int argc, char* argv[]) { std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; + SetChronoDataPath(CHRONO_DATA_DIR); + if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; } @@ -44,7 +46,8 @@ int main(int argc, char* argv[]) { system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.02; system.SetSolverType(ChSolver::Type::SPARSE_QR); - system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. + system.GetSolver()->AsIterative()->SetMaxIterations( + 300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 300.0; @@ -213,8 +216,8 @@ int main(int argc, char* argv[]) { outputFile.open("./results/CHRONO_F3OF_DT3_PITCH.txt"); if (!outputFile.is_open()) { if (!std::filesystem::exists("./results")) { - std::cout << "Path " << std::filesystem::absolute("./results") - << " does not exist, creating it now..." << std::endl; + std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..." + << std::endl; std::filesystem::create_directory("./results"); outputFile.open("./results/CHRONO_F3OF_DT3_PITCH.txt"); if (!outputFile.is_open()) { diff --git a/demos/oswec/demo_oswec_decay.cpp b/demos/oswec/demo_oswec_decay.cpp index bbf574d..1a43348 100644 --- a/demos/oswec/demo_oswec_decay.cpp +++ b/demos/oswec/demo_oswec_decay.cpp @@ -58,10 +58,11 @@ std::array add_vectors(std::array v1, std::arrayAsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. + // system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints + // satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 400.0; @@ -115,7 +117,6 @@ int main(int argc, char* argv[]) { << rotated_hinge_to_cg[2] << "]" << std::endl; std::cout << "The rotated vector is [" << new_cg[0] << ", " << new_cg[1] << ", " << new_cg[2] << "]" << std::endl; - // set up body from a mesh std::cout << "Attempting to open mesh file: " << body1_meshfame << std::endl; std::shared_ptr flap_body = chrono_types::make_shared( // @@ -219,8 +220,8 @@ int main(int argc, char* argv[]) { profilingFile.open("./results/oswec_duration.txt"); if (!profilingFile.is_open()) { if (!std::filesystem::exists("./results")) { - std::cout << "Path " << std::filesystem::absolute("./results") - << " does not exist, creating it now..." << std::endl; + std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..." + << std::endl; std::filesystem::create_directory("./results/"); profilingFile.open("./results/oswec_duration.txt"); if (!profilingFile.is_open()) { @@ -238,8 +239,8 @@ int main(int argc, char* argv[]) { outputFile.open("./results/oswec_decay.txt"); if (!outputFile.is_open()) { if (!std::filesystem::exists("./results")) { - std::cout << "Path " << std::filesystem::absolute("./results") - << " does not exist, creating it now..." << std::endl; + std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..." + << std::endl; std::filesystem::create_directory("./results/"); outputFile.open("./results/oswec_decay.txt"); if (!outputFile.is_open()) { diff --git a/demos/oswec/demo_oswec_reg_waves.cpp b/demos/oswec/demo_oswec_reg_waves.cpp index ab14b69..dad714d 100644 --- a/demos/oswec/demo_oswec_reg_waves.cpp +++ b/demos/oswec/demo_oswec_reg_waves.cpp @@ -60,6 +60,9 @@ std::array add_vectors(std::array v1, std::array periods = {4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 18.5, 19.0, 19.25, 19.5, 20.0, 21.0, 22.0, 24.0}; int reg_wave_num_max = periods.size(); diff --git a/demos/rm3/demo_rm3_decay.cpp b/demos/rm3/demo_rm3_decay.cpp index 5cf1885..26f1889 100644 --- a/demos/rm3/demo_rm3_decay.cpp +++ b/demos/rm3/demo_rm3_decay.cpp @@ -19,6 +19,8 @@ using namespace chrono; int main(int argc, char* argv[]) { std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; + SetChronoDataPath(CHRONO_DATA_DIR); + if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; } @@ -44,7 +46,8 @@ int main(int argc, char* argv[]) { double timestep = 0.01; system.SetTimestepperType(ChTimestepper::Type::HHT); system.SetSolverType(ChSolver::Type::GMRES); - system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. + system.GetSolver()->AsIterative()->SetMaxIterations( + 300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 40.0; @@ -160,8 +163,8 @@ int main(int argc, char* argv[]) { profilingFile.open("./results/rm3_decay_duration_ms.txt"); if (!profilingFile.is_open()) { if (!std::filesystem::exists("./results")) { - std::cout << "Path " << std::filesystem::absolute("./results") - << " does not exist, creating it now..." << std::endl; + std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..." + << std::endl; std::filesystem::create_directory("./results"); profilingFile.open("./results/rm3_duration_ms.txt"); if (!profilingFile.is_open()) { @@ -179,8 +182,8 @@ int main(int argc, char* argv[]) { outputFile.open("./results/rm3_decay.txt"); if (!outputFile.is_open()) { if (!std::filesystem::exists("./results")) { - std::cout << "Path " << std::filesystem::absolute("./results") - << " does not exist, creating it now..." << std::endl; + std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..." + << std::endl; std::filesystem::create_directory("./results"); outputFile.open("./results/rm3_decay.txt"); if (!outputFile.is_open()) { diff --git a/demos/rm3/demo_rm3_reg_waves.cpp b/demos/rm3/demo_rm3_reg_waves.cpp index 70a9bdc..3e70470 100644 --- a/demos/rm3/demo_rm3_reg_waves.cpp +++ b/demos/rm3/demo_rm3_reg_waves.cpp @@ -19,6 +19,8 @@ using namespace chrono; int main(int argc, char* argv[]) { std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; + SetChronoDataPath(CHRONO_DATA_DIR); + if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; } @@ -43,7 +45,8 @@ int main(int argc, char* argv[]) { double timestep = 0.01; system.SetTimestepperType(ChTimestepper::Type::HHT); system.SetSolverType(ChSolver::Type::GMRES); - system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. + system.GetSolver()->AsIterative()->SetMaxIterations( + 300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 40.0; @@ -117,7 +120,7 @@ int main(int argc, char* argv[]) { system.AddLink(prismatic_pto); // define wave parameters - auto my_hydro_inputs = std::make_shared(); + auto my_hydro_inputs = std::make_shared(); my_hydro_inputs->regular_wave_amplitude_ = 1.0; my_hydro_inputs->regular_wave_omega_ = 2.10; @@ -158,8 +161,8 @@ int main(int argc, char* argv[]) { profilingFile.open("./results/rm3_reg_waves_duration.txt"); if (!profilingFile.is_open()) { if (!std::filesystem::exists("./results")) { - std::cout << "Path " << std::filesystem::absolute("./results") - << " does not exist, creating it now..." << std::endl; + std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..." + << std::endl; std::filesystem::create_directory("./results"); profilingFile.open("./results/rm3_reg_waves_duration.txt"); if (!profilingFile.is_open()) { @@ -177,8 +180,8 @@ int main(int argc, char* argv[]) { outputFile.open("./results/rm3_reg_waves.txt"); if (!outputFile.is_open()) { if (!std::filesystem::exists("./results")) { - std::cout << "Path " << std::filesystem::absolute("./results") - << " does not exist, creating it now..." << std::endl; + std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..." + << std::endl; std::filesystem::create_directory("./results"); outputFile.open("./results/rm3_decay.txt"); if (!outputFile.is_open()) { diff --git a/demos/sphere/demo_sphere_decay.cpp b/demos/sphere/demo_sphere_decay.cpp index ddb1da3..355cd3e 100644 --- a/demos/sphere/demo_sphere_decay.cpp +++ b/demos/sphere/demo_sphere_decay.cpp @@ -20,6 +20,8 @@ using namespace chrono; int main(int argc, char* argv[]) { std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; + SetChronoDataPath(CHRONO_DATA_DIR); + if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; } @@ -44,7 +46,8 @@ int main(int argc, char* argv[]) { double timestep = 0.015; system.SetSolverType(ChSolver::Type::GMRES); - system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. + system.GetSolver()->AsIterative()->SetMaxIterations( + 300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 40.0; @@ -84,8 +87,8 @@ int main(int argc, char* argv[]) { // define wave parameters (not used in this demo) // Todo define a way to use TestHydro without hydro_inputs/waves - //HydroInputs my_hydro_inputs; - //my_hydro_inputs.mode = WaveMode::noWaveCIC; + // HydroInputs my_hydro_inputs; + // my_hydro_inputs.mode = WaveMode::noWaveCIC; // my_hydro_inputs.regular_wave_amplitude = 0.022; // my_hydro_inputs.regular_wave_omega = 2.10; @@ -98,7 +101,6 @@ int main(int argc, char* argv[]) { TestHydro hydro_forces(bodies, h5fname); hydro_forces.AddWaves(default_dont_add_waves); - // for profilingvisualizationOn = false; auto start = std::chrono::high_resolution_clock::now(); @@ -126,12 +128,12 @@ int main(int argc, char* argv[]) { profilingFile.open("./results/sphere_decay_duration.txt"); if (!profilingFile.is_open()) { if (!std::filesystem::exists("./results")) { - std::cout << "Path " << std::filesystem::absolute("./results") - << " does not exist, creating it now..." << std::endl; + std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..." + << std::endl; std::filesystem::create_directory("./results"); profilingFile.open("./results/sphere_decay_duration.txt"); if (!profilingFile.is_open()) { - //TODO instead of ending program, skip to next saveDataOn if statment + // TODO instead of ending program, skip to next saveDataOn if statment std::cout << "Still cannot open file, ending program" << std::endl; return 0; } @@ -146,8 +148,8 @@ int main(int argc, char* argv[]) { outputFile.open("./results/sphere_decay.txt"); if (!outputFile.is_open()) { if (!std::filesystem::exists("./results")) { - std::cout << "Path " << std::filesystem::absolute("./results") - << " does not exist, creating it now..." << std::endl; + std::cout << "Path " << std::filesystem::absolute("./results") << " does not exist, creating it now..." + << std::endl; std::filesystem::create_directory("./results"); outputFile.open("./results/sphere_decay.txt"); if (!outputFile.is_open()) { diff --git a/demos/sphere/demo_sphere_irreg_waves.cpp b/demos/sphere/demo_sphere_irreg_waves.cpp index 8aeb20d..0804acf 100644 --- a/demos/sphere/demo_sphere_irreg_waves.cpp +++ b/demos/sphere/demo_sphere_irreg_waves.cpp @@ -21,6 +21,8 @@ using namespace chrono; int main(int argc, char* argv[]) { std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; + SetChronoDataPath(CHRONO_DATA_DIR); + if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; } @@ -37,7 +39,7 @@ int main(int argc, char* argv[]) { (DATADIR / "sphere" / "geometry" / "oes_task10_sphere.obj").lexically_normal().generic_string(); auto h5fname = (DATADIR / "sphere" / "hydroData" / "sphere.h5").lexically_normal().generic_string(); -// // system/solver settings + // // system/solver settings ChSystemNSC system; system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.015; @@ -60,11 +62,11 @@ int main(int argc, char* argv[]) { ground->EnableCollision(false); // some io/viz options - bool profilingOn = true; - bool saveDataOn = true; + bool profilingOn = true; + bool saveDataOn = true; std::vector time_vector; std::vector heave_position; -// + // // set up body from a mesh std::cout << "Attempting to open mesh file: " << body1_meshfame << std::endl; std::shared_ptr sphereBody = chrono_types::make_shared( // @@ -74,7 +76,7 @@ int main(int argc, char* argv[]) { true, // create visualization asset false // do not collide ); -// + // // define the body's initial conditions system.Add(sphereBody); sphereBody->SetName("body1"); // must set body name correctly! (must match .h5 file) @@ -90,8 +92,7 @@ int main(int argc, char* argv[]) { // add prismatic joint between sphere and ground (limit to heave motion only) auto prismatic = chrono_types::make_shared(); - prismatic->Initialize(sphereBody, ground, false, ChFramed(ChVector3d(0, 0, -2)), - ChFramed(ChVector3d(0, 0, -5))); + prismatic->Initialize(sphereBody, ground, false, ChFramed(ChVector3d(0, 0, -2)), ChFramed(ChVector3d(0, 0, -5))); system.AddLink(prismatic); // create the spring between body_1 and ground. The spring end points are diff --git a/demos/sphere/demo_sphere_irreg_waves_eta_import.cpp b/demos/sphere/demo_sphere_irreg_waves_eta_import.cpp index 32719eb..334093a 100644 --- a/demos/sphere/demo_sphere_irreg_waves_eta_import.cpp +++ b/demos/sphere/demo_sphere_irreg_waves_eta_import.cpp @@ -21,6 +21,8 @@ using namespace chrono; int main(int argc, char* argv[]) { std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; + SetChronoDataPath(CHRONO_DATA_DIR); + if (hydroc::SetInitialEnvironment(argc, argv) != 0) { return 1; } @@ -60,8 +62,8 @@ int main(int argc, char* argv[]) { ground->EnableCollision(false); // some io/viz options - bool profilingOn = true; - bool saveDataOn = true; + bool profilingOn = true; + bool saveDataOn = true; std::vector time_vector; std::vector heave_position; @@ -90,8 +92,7 @@ int main(int argc, char* argv[]) { // add prismatic joint between sphere and ground (limit to heave motion only) auto prismatic = chrono_types::make_shared(); - prismatic->Initialize(sphereBody, ground, false, ChFramed(ChVector3d(0, 0, -2)), - ChFramed(ChVector3d(0, 0, -5))); + prismatic->Initialize(sphereBody, ground, false, ChFramed(ChVector3d(0, 0, -2)), ChFramed(ChVector3d(0, 0, -5))); system.AddLink(prismatic); // Create the spring between body_1 and ground. The spring end points are @@ -132,7 +133,6 @@ int main(int argc, char* argv[]) { std::cerr << "Caught unknown exception.\n"; } - std::cout << "Creating TestHydro..." << std::endl; TestHydro hydro_forces(bodies, h5fname); @@ -147,29 +147,30 @@ int main(int argc, char* argv[]) { fse_plane->EnableCollision(false); system.AddBody(fse_plane); - //std::cout << "SetUpWaveMesh..." << std::endl; - //my_hydro_inputs->SetUpWaveMesh(); - //std::shared_ptr fse_mesh = chrono_types::make_shared( // - // my_hydro_inputs->GetMeshFile(), // file name - // 1000, // density - // false, // do not evaluate mass automatically - // true, // create visualization asset - // false // do not collide + // std::cout << "SetUpWaveMesh..." << std::endl; + // my_hydro_inputs->SetUpWaveMesh(); + // std::shared_ptr fse_mesh = chrono_types::make_shared( // + // my_hydro_inputs->GetMeshFile(), // file name + // 1000, // density + // false, // do not evaluate mass + // automatically true, // create + // visualization asset false // do not + // collide //); - //fse_mesh->SetMass(1.0); - //fse_mesh->SetPos_dt(my_hydro_inputs->GetWaveMeshVelocity()); - //std::cout << "system.Add(fse_mesh)..." << std::endl; - //system.Add(fse_mesh); - //auto fse_prismatic = chrono_types::make_shared(); - //fse_prismatic->Initialize(fse_plane, fse_mesh, ChFramed(ChVector3d(1.0, 0.0, 0.0), QuatFromAnglY(CH_PI_2))); - //system.AddLink(fse_prismatic); + // fse_mesh->SetMass(1.0); + // fse_mesh->SetPos_dt(my_hydro_inputs->GetWaveMeshVelocity()); + // std::cout << "system.Add(fse_mesh)..." << std::endl; + // system.Add(fse_mesh); + // auto fse_prismatic = chrono_types::make_shared(); + // fse_prismatic->Initialize(fse_plane, fse_mesh, ChFramed(ChVector3d(1.0, 0.0, 0.0), QuatFromAnglY(CH_PI_2))); + // system.AddLink(fse_prismatic); //// Create a visualization material - //std::cout << "Create a visualization material..." << std::endl; - //auto fse_texture = chrono_types::make_shared(); - //fse_texture->SetDiffuseColor(ChColor(0.026f, 0.084f, 0.168f)); - //fse_texture->SetOpacity(0.1); - //fse_mesh->GetVisualShape(0)->SetMaterial(0, fse_texture); + // std::cout << "Create a visualization material..." << std::endl; + // auto fse_texture = chrono_types::make_shared(); + // fse_texture->SetDiffuseColor(ChColor(0.026f, 0.084f, 0.168f)); + // fse_texture->SetOpacity(0.1); + // fse_mesh->GetVisualShape(0)->SetMaterial(0, fse_texture); // for profiling auto start = std::chrono::high_resolution_clock::now(); diff --git a/demos/sphere/demo_sphere_reg_waves.cpp b/demos/sphere/demo_sphere_reg_waves.cpp index 2f2947c..8c374f2 100644 --- a/demos/sphere/demo_sphere_reg_waves.cpp +++ b/demos/sphere/demo_sphere_reg_waves.cpp @@ -18,9 +18,11 @@ using namespace chrono; // environment variable to give the data_directory. // int main(int argc, char* argv[]) { + SetChronoDataPath(CHRONO_DATA_DIR); + std::vector task10_wave_amps_0005 = {0.044, 0.078, 0.095, 0.123, 0.177, 0.24, 0.314, 0.397, 0.491, 0.594}; std::vector task10_wave_amps_002 = {0.177, 0.314, 0.380, 0.491, 0.706, 0.961, 1.256, 1.589, 1.962, 2.374}; - std::vector task10_wave_amps = task10_wave_amps_002; + std::vector task10_wave_amps = task10_wave_amps_002; double task10_wave_omegas[] = {2.094395102, 1.570796327, 1.427996661, 1.256637061, 1.047197551, 0.897597901, 0.785398163, 0.698131701, 0.628318531, 0.571198664}; @@ -31,7 +33,6 @@ int main(int argc, char* argv[]) { std::cout << reg_wave_num_max; for (int reg_wave_num = 1; reg_wave_num <= reg_wave_num_max; ++reg_wave_num) { - std::cout << "Chrono version: " << CHRONO_VERSION << "\n\n"; if (hydroc::SetInitialEnvironment(argc, argv) != 0) { @@ -56,7 +57,8 @@ int main(int argc, char* argv[]) { system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.015; system.SetSolverType(ChSolver::Type::GMRES); - system.GetSolver()->AsIterative()->SetMaxIterations(300); // the higher, the easier to keep the constraints satisfied. + system.GetSolver()->AsIterative()->SetMaxIterations( + 300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulation_duration = 600.0; @@ -121,7 +123,7 @@ int main(int argc, char* argv[]) { spring_1->SetDampingCoefficient(damping_coef); system.AddLink(spring_1); - auto my_hydro_inputs = std::make_shared(1); + auto my_hydro_inputs = std::make_shared(1); my_hydro_inputs->regular_wave_amplitude_ = task10_wave_amps[reg_wave_num - 1]; // 0.095; my_hydro_inputs->regular_wave_omega_ = task10_wave_omegas[reg_wave_num - 1]; // 1.427996661; @@ -155,7 +157,7 @@ int main(int argc, char* argv[]) { if (profilingOn) { std::string out_file = "./results/sphere_reg_waves_" + std::to_string(reg_wave_num) + "_duration.txt"; std::ofstream outputFile(out_file); - //profilingFile.open("./results/sphere_reg_waves_duration.txt"); + // profilingFile.open("./results/sphere_reg_waves_duration.txt"); if (!outputFile.is_open()) { if (!std::filesystem::exists("./results")) { std::cout << "Path " << std::filesystem::absolute("./results") diff --git a/src/hydro_forces.cpp b/src/hydro_forces.cpp index ac8eb9d..315ee64 100644 --- a/src/hydro_forces.cpp +++ b/src/hydro_forces.cpp @@ -96,7 +96,7 @@ ForceFunc6d::ForceFunc6d() : forces_{{this, 0}, {this, 1}, {this, 2}, {this, 3}, ForceFunc6d::ForceFunc6d(std::shared_ptr object, TestHydro* user_all_forces) : ForceFunc6d() { body_ = object; - std::string temp = body_->GetName(); // remove "body" from "bodyN", convert N to int, get body num + std::string temp = body_->GetName(); // remove "body" from "bodyN", convert N to int, get body num b_num_ = stoi(temp.erase(0, 4)); // 1 indexed TODO: fix b_num starting here to be 0 indexed all_hydro_forces_ = user_all_forces; // TODO switch to smart pointers? does this use = ? if (all_hydro_forces_ == NULL) { From f298cae744094cb644c70f12fd17f127fc0a99a0 Mon Sep 17 00:00:00 2001 From: DarioMangoni Date: Fri, 19 Apr 2024 15:00:20 +0200 Subject: [PATCH 3/5] Fix sphere_decay test --- demos/sphere/compare.py | 5 +---- tests/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/demos/sphere/compare.py b/demos/sphere/compare.py index ad57485..e5a90ad 100644 --- a/demos/sphere/compare.py +++ b/demos/sphere/compare.py @@ -23,15 +23,12 @@ print(testData.shape) - - testData[:,1] += 2.0 # shift to recenter decay at sea level 0 - nval = testData.shape[0] # resample refData to testData sampling rate # Suppose dt is constant with same computation physical time x = np.linspace(testData[0, 0], testData[nval-1, 0], nval) - y1 = np.interp(x, refData[:,0], refData[:,6]) + y1 = np.interp(x, refData[:,0], refData[:,1]) y2 = np.interp(x, testData[:,0], testData[:,1]) yd = y1 - y2 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0328a42..5681d7c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -72,7 +72,7 @@ if(TARGET demo_sphere_decay) ) set(FILE_RST ${CMAKE_CURRENT_BINARY_DIR}/results/sphere_decay.txt) - set(FILE_REF ${HYDROCHRONO_DATA_DIR}/sphere/postprocessing/sphere_decay_comparison.txt) + set(FILE_REF ${HYDROCHRONO_DATA_DIR}/sphere/postprocessing/sphere_decay_hc_data.txt) add_test(NAME demo_sphere_decay_ref COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../demos/sphere/compare.py ${FILE_REF} ${FILE_RST} From 0fe5148b872509fc84324c6695e40ba7f7058c46 Mon Sep 17 00:00:00 2001 From: DarioMangoni Date: Fri, 19 Apr 2024 15:44:07 +0200 Subject: [PATCH 4/5] Remove set of max iterations for demos with direct solver --- demos/f3of/demo_F3OF_DT1.cpp | 2 -- demos/f3of/demo_F3OF_DT2.cpp | 2 -- demos/f3of/demo_F3OF_DT3.cpp | 2 -- 3 files changed, 6 deletions(-) diff --git a/demos/f3of/demo_F3OF_DT1.cpp b/demos/f3of/demo_F3OF_DT1.cpp index a7d0eb9..9b97cf7 100644 --- a/demos/f3of/demo_F3OF_DT1.cpp +++ b/demos/f3of/demo_F3OF_DT1.cpp @@ -45,8 +45,6 @@ int main(int argc, char* argv[]) { system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.02; system.SetSolverType(ChSolver::Type::SPARSE_QR); - system.GetSolver()->AsIterative()->SetMaxIterations( - 300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 300.0; diff --git a/demos/f3of/demo_F3OF_DT2.cpp b/demos/f3of/demo_F3OF_DT2.cpp index 8087360..829ce44 100644 --- a/demos/f3of/demo_F3OF_DT2.cpp +++ b/demos/f3of/demo_F3OF_DT2.cpp @@ -45,8 +45,6 @@ int main(int argc, char* argv[]) { system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.02; system.SetSolverType(ChSolver::Type::SPARSE_QR); - system.GetSolver()->AsIterative()->SetMaxIterations( - 300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 300.0; diff --git a/demos/f3of/demo_F3OF_DT3.cpp b/demos/f3of/demo_F3OF_DT3.cpp index ccefc19..dc08f58 100644 --- a/demos/f3of/demo_F3OF_DT3.cpp +++ b/demos/f3of/demo_F3OF_DT3.cpp @@ -46,8 +46,6 @@ int main(int argc, char* argv[]) { system.SetGravitationalAcceleration(ChVector3d(0.0, 0.0, -9.81)); double timestep = 0.02; system.SetSolverType(ChSolver::Type::SPARSE_QR); - system.GetSolver()->AsIterative()->SetMaxIterations( - 300); // the higher, the easier to keep the constraints satisfied. ChRealtimeStepTimer realtime_timer; double simulationDuration = 300.0; From 8c15805b5fe4d788bdad7741f7e6f46e7d9b8166 Mon Sep 17 00:00:00 2001 From: DarioMangoni Date: Mon, 22 Jul 2024 15:54:42 +0200 Subject: [PATCH 5/5] Properly export CHRONO_DATA_DIR definition --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 766a50c..31c03f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,9 +133,9 @@ target_include_directories( target_compile_definitions(HydroChrono PUBLIC - - PRIVATE CHRONO_DATA_DIR=\"${CHRONO_DATA_DIR}\" + PRIVATE + ) target_compile_options(HydroChrono BEFORE