@@ -517,9 +517,8 @@ class SchemeBase : public Scheme
517517 }
518518
519519 /* * @brief Create an initial state for all the entities
520- * @note Just the first state is written. None of the following states are
521- * initialized in any way.
522- * @note All the derivatives are nullified
520+ * @note Just the first state is written. None of the following states nor
521+ * the derivatives are initialized in any way.
523522 * @note It is assumed that the coupled entities were already initialized
524523 */
525524 virtual void Init ()
@@ -534,18 +533,18 @@ class SchemeBase : public Scheme
534533 (bodies[i]->type != Body::CPLDPIN))
535534 continue ;
536535 auto [pos, vel] = bodies[i]->initialize ();
537- AS_STATE (_r[0 ])->get (bodies[i]).row (0 ).head <7 >() = pos.toVec7 ();
538- AS_STATE (_r[0 ])->get (bodies[i]).row (0 ).tail <6 >() = vel;
539- for (unsigned int j = 0 ; j < NDERIV; j++)
540- AS_STATE (_rd[j])->get (bodies[i]).setZero ();
536+ auto r = AS_STATE (_r[0 ])->get (bodies[i]);
537+ r.row (0 ).head (7 ) = pos.toVec7 ();
538+ r.row (0 ).tail (6 ) = vel;
541539 }
542540
543541 for (unsigned int i = 0 ; i < rods.size (); i++) {
544542 if ((rods[i]->type != Rod::FREE) && (rods[i]->type != Rod::PINNED))
545543 continue ;
546544 auto [pos, vel] = rods[i]->initialize ();
547- AS_STATE (_r[0 ])->get (rods[i]).row (0 ).head <7 >() = pos.toVec7 ();
548- AS_STATE (_r[0 ])->get (rods[i]).row (0 ).tail <6 >() = vel;
545+ auto r = AS_STATE (_r[0 ])->get (rods[i]);
546+ r.row (0 ).head (7 ) = pos.toVec7 ();
547+ r.row (0 ).tail (6 ) = vel;
549548 for (unsigned int j = 0 ; j < NDERIV; j++)
550549 AS_STATE (_rd[j])->get (rods[i]).setZero ();
551550 }
@@ -554,17 +553,19 @@ class SchemeBase : public Scheme
554553 if (points[i]->type != Point::FREE)
555554 continue ;
556555 auto [pos, vel] = points[i]->initialize ();
557- AS_STATE (_r[0 ])->get (points[i]).row (0 ).head <3 >() = pos;
558- AS_STATE (_r[0 ])->get (points[i]).row (0 ).tail <3 >() = vel;
556+ auto r = AS_STATE (_r[0 ])->get (points[i]);
557+ r.row (0 ).head (3 ) = pos;
558+ r.row (0 ).tail (3 ) = vel;
559559 for (unsigned int j = 0 ; j < NDERIV; j++)
560560 AS_STATE (_rd[j])->get (points[i]).setZero ();
561561 }
562562
563563 for (unsigned int i = 0 ; i < lines.size (); i++) {
564564 auto [pos, vel] = lines[i]->initialize ();
565+ auto r = AS_STATE (_r[0 ])->get (lines[i]);
565566 for (unsigned int j = 0 ; j < pos.size (); j++) {
566- AS_STATE (_r[ 0 ])-> get (lines[i]) .row (j).head < 3 >( ) = pos[j];
567- AS_STATE (_r[ 0 ])-> get (lines[i]) .row (j).segment < 3 >( 3 ) = vel[j];
567+ r .row (j).head ( 3 ) = pos[j];
568+ r .row (j).segment ( 3 , 3 ) = vel[j];
568569 }
569570 for (unsigned int j = 0 ; j < NDERIV; j++)
570571 AS_STATE (_rd[j])->get (lines[i]).setZero ();
@@ -616,7 +617,7 @@ class SchemeBase : public Scheme
616617 {
617618 if (i >= NSTATE) {
618619 LOGERR << " State " << i << " cannot be setted on a '" << name
619- << " ' scheme that has " << NSTATE << " states"
620+ << " ' scheme that has " << NSTATE << " states"
620621 << endl;
621622 throw moordyn::invalid_value_error (" Invalid state" );
622623 }
0 commit comments