Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 24 additions & 0 deletions source/Line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,30 @@ MoorDyn_SetLineUnstretchedLengthVel(MoorDynLine l, double v)
return MOORDYN_SUCCESS;
}

int DECLDIR
MoorDyn_IsLineConstantEA(MoorDynLine l, int* b)
{
CHECK_LINE(l);
*b = (int)((moordyn::Line*)l)->isConstantEA();
return MOORDYN_SUCCESS;
}

int DECLDIR
MoorDyn_GetLineConstantEA(MoorDynLine l, double* EA)
{
CHECK_LINE(l);
*EA = ((moordyn::Line*)l)->getConstantEA();
return MOORDYN_SUCCESS;
}

int DECLDIR
MoorDyn_SetLineConstantEA(MoorDynLine l, double EA)
{
CHECK_LINE(l);
((moordyn::Line*)l)->setConstantEA(EA);
return MOORDYN_SUCCESS;
}

int DECLDIR
MoorDyn_GetLineNodePos(MoorDynLine l, unsigned int i, double pos[3])
{
Expand Down
36 changes: 36 additions & 0 deletions source/Line.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,42 @@ extern "C"
*/
int DECLDIR MoorDyn_SetLineUnstretchedLengthVel(MoorDynLine l, double v);

/** @brief Get whether the line is governed by a non-linear stiffness or a
* constant one
* @param l The Moordyn line
* @param b 1 if the stiffness of the line is constant, 0 if a
* non-linear stiffness has been set
* @return MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS
* otherwise
* @see MoorDyn_GetLineConstantEA()
* @see MoorDyn_SetLineConstantEA()
*/
int DECLDIR MoorDyn_IsLineConstantEA(MoorDynLine l, int* b);

/** @brief Get the constant stiffness of the line
*
* This value is useless if non-linear stiffness is considered
* @param l The Moordyn line
* @param EA The constant stiffness EA value
* @return MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS
* otherwise
* @see MoorDyn_IsLineConstantEA()
* @see MoorDyn_SetLineConstantEA()
*/
int DECLDIR MoorDyn_GetLineConstantEA(MoorDynLine l, double* EA);

/** @brief Set the constant stiffness of the line
*
* This value is useless if non-linear stiffness is considered
* @param l The Moordyn line
* @param EA The constant stiffness EA value
* @return MOORDYN_INVALID_VALUE if a NULL line is provided, MOORDYN_SUCCESS
* otherwise
* @see MoorDyn_IsLineConstantEA()
* @see MoorDyn_GetLineConstantEA()
*/
int DECLDIR MoorDyn_SetLineConstantEA(MoorDynLine l, double EA);

/** @brief Get a line node position
* @param l The Moordyn line
* @param i The node index
Expand Down
23 changes: 23 additions & 0 deletions source/Line.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,29 @@ class Line final : public io::IO
setUnstretchedLength(UnstrLen0 + dt * UnstrLend);
}

/** @brief Get whether the line is governed by a non-linear stiffness or a
* constant one
* @return true if the stiffness of the line is constant, false if a
* non-linear stiffness has been set
*/
inline bool isConstantEA() const { return nEApoints > 0; }

/** @brief Get the constant stiffness of the line
*
* This value is useless if non-linear stiffness is considered
* @return The constant stiffness EA value
* @see ::IsConstantEA()
*/
inline moordyn::real getConstantEA() const { return E * A; }

/** @brief Set the constant stiffness of the line
*
* This value is useless if non-linear stiffness is considered
* @param EA The constant stiffness EA value
* @see ::IsConstantEA()
*/
inline void setConstantEA(moordyn::real EA) { E = EA / A; }

/** @brief Get the position of a node
* @param i The line node index
* @return The position
Expand Down
4 changes: 3 additions & 1 deletion source/MoorDyn2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,11 @@ moordyn::MoorDyn::Step(const double* x,
double& dt)
{
// should check if wave kinematics have been set up if expected!
const auto default_precision{std::cout.precision()};
std::cout << std::fixed << setprecision(1);
LOGDBG << "t = " << t << "s \r";
std::cout << std::defaultfloat << setprecision(default_precision);

cout << fixed << setprecision(1);
cout << "\rt = " << t << " " << flush;

if (dt <= 0) {
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ set(CPP_TESTS
set(CATCH2_TESTS
math_tests
testDecomposeString
polyester
)

function(make_executable test_name, extension)
Expand Down
Loading