Skip to content

Commit 8bba8c0

Browse files
authored
Merge pull request FloatingArrayDesign#156 from RyanDavies19/dev_ryan
Fixes initialization location of fixed bodies
2 parents 0ca4656 + e53a833 commit 8bba8c0

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

docs/drivers.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ library. Below is an example of this on MacOS with MoorDyn compiled as a
157157
vector_size = 6 # 6DOF coupled object
158158
size = (len(time), vector_size)
159159
160-
x = np.zeros(size)
161-
xd = np.zeros(size)
160+
#specifying correct dtypes for conversion to C types
161+
x = np.zeros(size, dtype = float)
162+
xd = np.zeros(size, dtype = float)
162163
163164
dylib_path = 'MoorDyn/compile/DYLIB/libmoordyn2.dylib'
164165
filename = path+rootname+extension

source/Body.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@ Body::setup(int number_in,
7777
bodyI = I_in;
7878
bodyCdA = CdA_in;
7979
bodyCa = Ca_in;
80-
} else // other types of bodies have no need for these variables...
80+
} else if (type == FIXED){ // fixed bodies have no need for these variables other than position...
81+
bodyM = 0.0;
82+
bodyV = 0.0;
83+
body_r6.head<3>() = r6_in.head<3>();
84+
body_r6.tail<3>() = deg2rad * r6_in.tail<3>();
85+
bodyI = vec::Zero();
86+
bodyCdA = vec6::Zero();
87+
bodyCa = vec6::Zero();
88+
} else // coupled bodies have no need for these variables...
8189
{
8290
bodyM = 0.0;
8391
bodyV = 0.0;
@@ -375,9 +383,10 @@ Body::initiateStep(vec6 r, vec6 rd)
375383
rd_ves = rd;
376384
return;
377385
}
378-
if (type == FIXED) // if the ground body, set the BCs to stationary
386+
if (type == FIXED) // if fixed body, set the BCs to stationary
379387
{
380-
r_ves = vec6::Zero();
388+
if (bodyId == 0) r_ves = vec6::Zero(); // special ground body case
389+
else r_ves = r;
381390
rd_ves = vec6::Zero();
382391
return;
383392
}

source/MoorDyn2.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ moordyn::MoorDyn::Init(const double* x, const double* xd, bool skip_ic)
205205
// call ground body to update all the fixed things...
206206
GroundBody->initializeUnfreeBody();
207207

208+
// intialize fixed bodies and attached objects
209+
for (auto l : FixedBodyIs){
210+
BodyList[l]->initializeUnfreeBody(BodyList[l]->body_r6, vec6::Zero());
211+
}
212+
208213
// initialize coupled objects based on passed kinematics
209214
int ix = 0;
210215

@@ -1732,6 +1737,7 @@ moordyn::MoorDyn::readBody(string inputText)
17321737
// it is fixed (this would just be used if someone wanted
17331738
// to temporarly fix a body that things were attached to)
17341739
type = Body::FIXED;
1740+
FixedBodyIs.push_back(ui_size(BodyList));
17351741
} else if (str::isOneOf(let1, { "VESSEL", "VES", "COUPLED", "CPLD" })) {
17361742
// it is coupled - controlled from outside
17371743
type = Body::COUPLED;

source/MoorDyn2.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ class MoorDyn final : public io::IO
475475

476476
/// vector of free body indices in BodyList vector
477477
vector<unsigned int> FreeBodyIs;
478+
/// vector of fixed body indices in BodyList vector
479+
vector<unsigned int> FixedBodyIs;
478480
/// vector of coupled/fairlead body indices in BodyList vector
479481
vector<unsigned int> CpldBodyIs;
480482

0 commit comments

Comments
 (0)