Skip to content

Commit

Permalink
Allow managing assembly-wide (as opposed to system-wide only) state v…
Browse files Browse the repository at this point in the history
…ectors
  • Loading branch information
rserban committed Jul 2, 2024
1 parent eb53fc1 commit 2617649
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
44 changes: 22 additions & 22 deletions src/chrono/physics/ChAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,8 @@ void ChAssembly::IntStateGather(const unsigned int off_x,
const unsigned int off_v,
ChStateDelta& v,
double& T) {
unsigned int displ_x = off_x - this->offset_x;
unsigned int displ_v = off_v - this->offset_w;
int displ_x = off_x - this->offset_x;
int displ_v = off_v - this->offset_w;

for (auto& body : bodylist) {
if (body->IsActive())
Expand Down Expand Up @@ -730,8 +730,8 @@ void ChAssembly::IntStateScatter(const unsigned int off_x,
// - in particular, bodies and meshes must be processed *before* links, so that links can use
// up-to-date body and node information

unsigned int displ_x = off_x - this->offset_x;
unsigned int displ_v = off_v - this->offset_w;
int displ_x = off_x - this->offset_x;
int displ_v = off_v - this->offset_w;

for (auto& body : bodylist) {
if (body->IsActive())
Expand Down Expand Up @@ -770,7 +770,7 @@ void ChAssembly::IntStateScatter(const unsigned int off_x,
}

void ChAssembly::IntStateGatherAcceleration(const unsigned int off_a, ChStateDelta& a) {
unsigned int displ_a = off_a - this->offset_w;
int displ_a = off_a - this->offset_w;

for (auto& body : bodylist) {
if (body->IsActive())
Expand All @@ -795,7 +795,7 @@ void ChAssembly::IntStateGatherAcceleration(const unsigned int off_a, ChStateDel

// From state derivative (acceleration) to system, sometimes might be needed
void ChAssembly::IntStateScatterAcceleration(const unsigned int off_a, const ChStateDelta& a) {
unsigned int displ_a = off_a - this->offset_w;
int displ_a = off_a - this->offset_w;

for (auto& body : bodylist) {
if (body->IsActive())
Expand All @@ -820,7 +820,7 @@ void ChAssembly::IntStateScatterAcceleration(const unsigned int off_a, const ChS

// From system to reaction forces (last computed) - some timestepper might need this
void ChAssembly::IntStateGatherReactions(const unsigned int off_L, ChVectorDynamic<>& L) {
unsigned int displ_L = off_L - this->offset_L;
int displ_L = off_L - this->offset_L;

for (auto& body : bodylist) {
if (body->IsActive())
Expand All @@ -845,7 +845,7 @@ void ChAssembly::IntStateGatherReactions(const unsigned int off_L, ChVectorDynam

// From reaction forces to system, ex. store last computed reactions in ChLinkBase objects for plotting etc.
void ChAssembly::IntStateScatterReactions(const unsigned int off_L, const ChVectorDynamic<>& L) {
unsigned int displ_L = off_L - this->offset_L;
int displ_L = off_L - this->offset_L;

for (auto& body : bodylist) {
if (body->IsActive())
Expand Down Expand Up @@ -874,8 +874,8 @@ void ChAssembly::IntStateIncrement(const unsigned int off_x,
const ChState& x,
const unsigned int off_v,
const ChStateDelta& Dv) {
unsigned int displ_x = off_x - this->offset_x;
unsigned int displ_v = off_v - this->offset_w;
int displ_x = off_x - this->offset_x;
int displ_v = off_v - this->offset_w;

for (auto& body : bodylist) {
if (body->IsActive())
Expand Down Expand Up @@ -907,8 +907,8 @@ void ChAssembly::IntStateGetIncrement(const unsigned int off_x,
const ChState& x,
const unsigned int off_v,
ChStateDelta& Dv) {
unsigned int displ_x = off_x - this->offset_x;
unsigned int displ_v = off_v - this->offset_w;
int displ_x = off_x - this->offset_x;
int displ_v = off_v - this->offset_w;

for (auto& body : bodylist) {
if (body->IsActive())
Expand Down Expand Up @@ -939,7 +939,7 @@ void ChAssembly::IntLoadResidual_F(const unsigned int off, ///< offset in R res
ChVectorDynamic<>& R, ///< result: the R residual, R += c*F
const double c) ///< a scaling factor
{
unsigned int displ_v = off - this->offset_w;
int displ_v = off - this->offset_w;

for (auto& body : bodylist) {
if (body->IsActive())
Expand Down Expand Up @@ -967,7 +967,7 @@ void ChAssembly::IntLoadResidual_Mv(const unsigned int off, ///< offset in
const ChVectorDynamic<>& w, ///< the w vector
const double c ///< a scaling factor
) {
unsigned int displ_v = off - this->offset_w;
int displ_v = off - this->offset_w;

for (auto& body : bodylist) {
if (body->IsActive())
Expand All @@ -991,7 +991,7 @@ void ChAssembly::IntLoadResidual_Mv(const unsigned int off, ///< offset in
}

void ChAssembly::IntLoadLumpedMass_Md(const unsigned int off, ChVectorDynamic<>& Md, double& err, const double c) {
unsigned int displ_v = off - this->offset_w;
int displ_v = off - this->offset_w;

for (auto& body : bodylist) {
if (body->IsActive())
Expand Down Expand Up @@ -1019,7 +1019,7 @@ void ChAssembly::IntLoadResidual_CqL(const unsigned int off_L, ///< offset in
const ChVectorDynamic<>& L, ///< the L vector
const double c ///< a scaling factor
) {
unsigned int displ_L = off_L - this->offset_L;
int displ_L = off_L - this->offset_L;

for (auto& body : bodylist) {
if (body->IsActive())
Expand Down Expand Up @@ -1048,7 +1048,7 @@ void ChAssembly::IntLoadConstraint_C(const unsigned int off_L, ///< offset in Q
bool do_clamp, ///< apply clamping to c*C?
double recovery_clamp ///< value for min/max clamping of c*C
) {
unsigned int displ_L = off_L - this->offset_L;
int displ_L = off_L - this->offset_L;

for (auto& body : bodylist) {
if (body->IsActive())
Expand All @@ -1075,7 +1075,7 @@ void ChAssembly::IntLoadConstraint_Ct(const unsigned int off_L, ///< offset in
ChVectorDynamic<>& Qc, ///< result: the Qc residual, Qc += c*Ct
const double c ///< a scaling factor
) {
unsigned int displ_L = off_L - this->offset_L;
int displ_L = off_L - this->offset_L;

for (auto& body : bodylist) {
if (body->IsActive())
Expand Down Expand Up @@ -1104,8 +1104,8 @@ void ChAssembly::IntToDescriptor(const unsigned int off_v,
const unsigned int off_L,
const ChVectorDynamic<>& L,
const ChVectorDynamic<>& Qc) {
unsigned int displ_L = off_L - this->offset_L;
unsigned int displ_v = off_v - this->offset_w;
int displ_L = off_L - this->offset_L;
int displ_v = off_v - this->offset_w;

for (auto& body : bodylist) {
if (body->IsActive())
Expand Down Expand Up @@ -1136,8 +1136,8 @@ void ChAssembly::IntFromDescriptor(const unsigned int off_v,
ChStateDelta& v,
const unsigned int off_L,
ChVectorDynamic<>& L) {
unsigned int displ_L = off_L - this->offset_L;
unsigned int displ_v = off_v - this->offset_w;
int displ_L = off_L - this->offset_L;
int displ_v = off_v - this->offset_w;

for (auto& body : bodylist) {
if (body->IsActive())
Expand Down
8 changes: 4 additions & 4 deletions src/chrono/physics/ChSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,8 @@ void ChSystem::IntToDescriptor(const unsigned int off_v,
assembly.IntToDescriptor(off_v, v, R, off_L, L, Qc);

// Use also on contact container:
unsigned int displ_L = off_L - assembly.offset_L;
unsigned int displ_v = off_v - assembly.offset_w;
int displ_L = off_L - assembly.offset_L;
int displ_v = off_v - assembly.offset_w;
contact_container->IntToDescriptor(displ_v + contact_container->GetOffset_w(), v, R,
displ_L + contact_container->GetOffset_L(), L, Qc);
}
Expand All @@ -745,8 +745,8 @@ void ChSystem::IntFromDescriptor(const unsigned int off_v,
assembly.IntFromDescriptor(off_v, v, off_L, L);

// Use also on contact container:
unsigned int displ_L = off_L - assembly.offset_L;
unsigned int displ_v = off_v - assembly.offset_w;
int displ_L = off_L - assembly.offset_L;
int displ_v = off_v - assembly.offset_w;
contact_container->IntFromDescriptor(displ_v + contact_container->GetOffset_w(), v,
displ_L + contact_container->GetOffset_L(), L);
}
Expand Down

0 comments on commit 2617649

Please sign in to comment.