From 47cf87995631b5fa84445abf1a78d985f8bf697d Mon Sep 17 00:00:00 2001 From: SteveMaas1978 Date: Tue, 3 Dec 2024 10:07:00 -0700 Subject: [PATCH] Fixed issue with the normal displacement constraint when node IDs don't start at 1. --- FEBioMech/FEFixedNormalDisplacement.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/FEBioMech/FEFixedNormalDisplacement.cpp b/FEBioMech/FEFixedNormalDisplacement.cpp index bcdbc1970..8a75c8265 100644 --- a/FEBioMech/FEFixedNormalDisplacement.cpp +++ b/FEBioMech/FEFixedNormalDisplacement.cpp @@ -70,13 +70,14 @@ void FEFixedNormalDisplacement::Activate() // nx*ux + ny*uy + nz*uz = 0 if (m_bshellb == false) { for (int i = 0; i < m_surf.Nodes(); ++i) { - FENode node = m_surf.Node(i); + FENode& node = m_surf.Node(i); if ((node.HasFlags(FENode::EXCLUDE) == false) && (node.m_rid == -1)) { + int nid = m_surf.NodeIndex(i) + 1; // NOTE: the linear constraint set still assumes 1-based indexing! vec3d nn = m_surf.NodeNormal(i); FEAugLagLinearConstraint* pLC = fecore_alloc(FEAugLagLinearConstraint, &fem); - pLC->AddDOF(node.GetID(), dofs.GetDOF("x"), nn.x); - pLC->AddDOF(node.GetID(), dofs.GetDOF("y"), nn.y); - pLC->AddDOF(node.GetID(), dofs.GetDOF("z"), nn.z); + pLC->AddDOF(nid, dofs.GetDOF("x"), nn.x); + pLC->AddDOF(nid, dofs.GetDOF("y"), nn.y); + pLC->AddDOF(nid, dofs.GetDOF("z"), nn.z); // add the linear constraint to the system m_lc.add(pLC); } @@ -84,13 +85,14 @@ void FEFixedNormalDisplacement::Activate() } else { for (int i = 0; i < m_surf.Nodes(); ++i) { - FENode node = m_surf.Node(i); + FENode& node = m_surf.Node(i); if ((node.HasFlags(FENode::EXCLUDE) == false) && (node.m_rid == -1)) { vec3d nn = m_surf.NodeNormal(i); - FEAugLagLinearConstraint* pLC = fecore_alloc(FEAugLagLinearConstraint, &fem); - pLC->AddDOF(node.GetID(), dofs.GetDOF("sx"), nn.x); - pLC->AddDOF(node.GetID(), dofs.GetDOF("sy"), nn.y); - pLC->AddDOF(node.GetID(), dofs.GetDOF("sz"), nn.z); + int nid = m_surf.NodeIndex(i) + 1; // NOTE: the linear constraint set still assumes 1-based indexing! + FEAugLagLinearConstraint* pLC = fecore_alloc(FEAugLagLinearConstraint, &fem); + pLC->AddDOF(nid, dofs.GetDOF("sx"), nn.x); + pLC->AddDOF(nid, dofs.GetDOF("sy"), nn.y); + pLC->AddDOF(nid, dofs.GetDOF("sz"), nn.z); // add the linear constraint to the system m_lc.add(pLC); }