Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes initialization location of fixed bodies #156

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 8 additions & 0 deletions source/MoorDyn2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ 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){
cout << "Body " << l << endl;
cout << BodyList[l]->body_r6 << endl;
BodyList[l]->initializeUnfreeBody(BodyList[l]->body_r6, Eigen::DenseBase<Eigen::Vector6d>::Zero());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small notes:

  1. Should those cout calls be LOGMSG or LOGDBG?
  2. Eigen::DenseBase<Eigen::Vector6d>::Zero() should be able to be replaced with vec6::Zero()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexWKinley good catch. The cout's were from debugging and thanks for the correction of the vector type.

}

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

Expand Down Expand Up @@ -1732,6 +1739,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