Skip to content

Commit

Permalink
Merge pull request #156 from RyanDavies19/dev_ryan
Browse files Browse the repository at this point in the history
Fixes initialization location of fixed bodies
  • Loading branch information
RyanDavies19 authored Oct 10, 2023
2 parents 0ca4656 + e53a833 commit 8bba8c0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docs/drivers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ library. Below is an example of this on MacOS with MoorDyn compiled as a
vector_size = 6 # 6DOF coupled object
size = (len(time), vector_size)
x = np.zeros(size)
xd = np.zeros(size)
#specifying correct dtypes for conversion to C types
x = np.zeros(size, dtype = float)
xd = np.zeros(size, dtype = float)
dylib_path = 'MoorDyn/compile/DYLIB/libmoordyn2.dylib'
filename = path+rootname+extension
Expand Down
15 changes: 12 additions & 3 deletions source/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ Body::setup(int number_in,
bodyI = I_in;
bodyCdA = CdA_in;
bodyCa = Ca_in;
} else // other types of bodies have no need for these variables...
} else if (type == FIXED){ // fixed bodies have no need for these variables other than position...
bodyM = 0.0;
bodyV = 0.0;
body_r6.head<3>() = r6_in.head<3>();
body_r6.tail<3>() = deg2rad * r6_in.tail<3>();
bodyI = vec::Zero();
bodyCdA = vec6::Zero();
bodyCa = vec6::Zero();
} else // coupled bodies have no need for these variables...
{
bodyM = 0.0;
bodyV = 0.0;
Expand Down Expand Up @@ -375,9 +383,10 @@ Body::initiateStep(vec6 r, vec6 rd)
rd_ves = rd;
return;
}
if (type == FIXED) // if the ground body, set the BCs to stationary
if (type == FIXED) // if fixed body, set the BCs to stationary
{
r_ves = vec6::Zero();
if (bodyId == 0) r_ves = vec6::Zero(); // special ground body case
else r_ves = r;
rd_ves = vec6::Zero();
return;
}
Expand Down
6 changes: 6 additions & 0 deletions source/MoorDyn2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ moordyn::MoorDyn::Init(const double* x, const double* xd, bool skip_ic)
// call ground body to update all the fixed things...
GroundBody->initializeUnfreeBody();

// intialize fixed bodies and attached objects
for (auto l : FixedBodyIs){
BodyList[l]->initializeUnfreeBody(BodyList[l]->body_r6, vec6::Zero());
}

// initialize coupled objects based on passed kinematics
int ix = 0;

Expand Down Expand Up @@ -1732,6 +1737,7 @@ moordyn::MoorDyn::readBody(string inputText)
// it is fixed (this would just be used if someone wanted
// to temporarly fix a body that things were attached to)
type = Body::FIXED;
FixedBodyIs.push_back(ui_size(BodyList));
} else if (str::isOneOf(let1, { "VESSEL", "VES", "COUPLED", "CPLD" })) {
// it is coupled - controlled from outside
type = Body::COUPLED;
Expand Down
2 changes: 2 additions & 0 deletions source/MoorDyn2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ class MoorDyn final : public io::IO

/// vector of free body indices in BodyList vector
vector<unsigned int> FreeBodyIs;
/// vector of fixed body indices in BodyList vector
vector<unsigned int> FixedBodyIs;
/// vector of coupled/fairlead body indices in BodyList vector
vector<unsigned int> CpldBodyIs;

Expand Down

0 comments on commit 8bba8c0

Please sign in to comment.