@@ -795,6 +795,41 @@ moordyn::MoorDyn::Step(const double* x,
795795 return MOORDYN_SUCCESS ;
796796}
797797
798+ void
799+ MoorDyn::BreakLine (moordyn::Point* point, moordyn::Line* line)
800+ {
801+ // Detach the line from the point
802+ moordyn::EndPoints end_point;
803+ auto pt_attachments = point->getLines ();
804+ for (auto attachment : pt_attachments) {
805+ if (attachment.line == line) {
806+ end_point = attachment.end_point ;
807+ }
808+ }
809+ point->removeLine (line);
810+ // Create the new point
811+ moordyn::Point *pt = new Point (point, PointList.size ());
812+ PointList.push_back (pt);
813+ waves->addPoint (pt);
814+ _t_integrator->AddPoint (pt);
815+ // Set the state of the point
816+ auto state = _t_integrator->r (0 );
817+ pt->initialize (state->get (pt));
818+ for (unsigned int i = 1 ; i < _t_integrator->GetNState (); i++) {
819+ _t_integrator->r (i)->get (pt) = state->get (pt);
820+ }
821+ for (unsigned int i = 0 ; i < _t_integrator->GetNDeriv (); i++) {
822+ _t_integrator->rd (i)->get (pt).row (0 )(Eigen::seqN (0 , 3 )) =
823+ state->get (pt).row (0 )(Eigen::seqN (3 , 3 ));
824+ // NOTE: Although when cloning free points we can actually get the
825+ // acceleration, I (Jose Luis Cercos-Pita) do not think is worthy, so
826+ // I am simply setting no acceleration
827+ _t_integrator->rd (i)->get (pt).row (0 )(Eigen::seqN (3 , 3 )) = vec::Zero ();
828+ }
829+ // Attach the line to the point
830+ pt->addLine (line, end_point);
831+ }
832+
798833std::vector<uint64_t >
799834MoorDyn::Serialize (void )
800835{
@@ -1155,8 +1190,7 @@ moordyn::MoorDyn::ReadInFile()
11551190 env->WtrDpth = -r0[2 ];
11561191 LOGWRN << " \t Water depth set to point " << PointList.size () + 1
11571192 << " z position because point was specified below the "
1158- " seabed"
1159- << endl;
1193+ " seabed" << endl;
11601194 }
11611195
11621196 // Check point ID is sequential starting from 1
@@ -3137,6 +3171,28 @@ MoorDyn_GetFASTtens(MoorDyn system,
31373171 return MOORDYN_SUCCESS ;
31383172}
31393173
3174+ int DECLDIR
3175+ MoorDyn_BreakLine (MoorDyn system,
3176+ MoorDynPoint point,
3177+ MoorDynLine line)
3178+ {
3179+ CHECK_SYSTEM (system);
3180+
3181+ moordyn::error_id err = MOORDYN_SUCCESS ;
3182+ string err_msg;
3183+ try {
3184+ ((moordyn::MoorDyn*)system)->BreakLine ((moordyn::Point*)point,
3185+ (moordyn::Line*)line);
3186+ }
3187+ MOORDYN_CATCHER (err, err_msg);
3188+ if (err != MOORDYN_SUCCESS ) {
3189+ cerr << " Error (" << err << " ) at " << __FUNC_NAME__ << " ():" << endl
3190+ << err_msg << endl;
3191+ return err;
3192+ }
3193+ return MOORDYN_SUCCESS ;
3194+ }
3195+
31403196int DECLDIR
31413197MoorDyn_GetDt (MoorDyn system, double * dt)
31423198{
0 commit comments