Skip to content

Commit 4a006b5

Browse files
committed
Fixed bug in copying rigid BC.
1 parent 30ca09f commit 4a006b5

File tree

4 files changed

+278
-547
lines changed

4 files changed

+278
-547
lines changed

FEBioStudio/ModelViewer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,7 @@ void CModelViewer::OnCopyRigidBC()
14481448
// add the load to the doc
14491449
FSStep* step = fem->GetStep(pc->GetStep());
14501450
// pdoc->DoCommand(new CCmdAddRC(step, pcCopy));
1451+
pcCopy->SetStep(step->GetID());
14511452
step->AddRigidBC(pcCopy);
14521453

14531454
// update the model viewer

MeshTools/FEBoundaryLayerMesher.cpp

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,21 @@ FSMesh* FEBoundaryLayerMesher::Apply(FSMesh* pm)
5151

5252
bool FEBoundaryLayerMesher::BoundaryLayer(FSMesh* pm)
5353
{
54+
if (pm == nullptr) return false;
55+
5456
// get the modifier's parameters
5557
double bias = GetFloatValue(0);
5658
int nseg = GetIntValue(1);
57-
58-
// tag elements for deletion
59-
int ne0 = pm->Elements();
60-
vector<bool> delem(ne0, false);
59+
if (nseg < 1) return false;
60+
if (nseg == 1) return true;
6161

6262
// store list of selected faces in fdata
63-
vector<FSFace> fdata;
63+
vector<int> fdata;
6464
for (int i = 0; i<pm->Faces(); ++i)
6565
{
66-
FSFace& face = pm->Face(i);
66+
const FSFace& face = pm->Face(i);
6767
if (face.IsSelected())
68-
fdata.push_back(face);
68+
fdata.push_back(i);
6969
}
7070

7171
// make sure we have work to do
@@ -82,26 +82,29 @@ bool FEBoundaryLayerMesher::BoundaryLayer(FSMesh* pm)
8282
std::map<int, vector<int>> efm;
8383
for (int i = 0; i<ne1; ++i)
8484
{
85-
FSFace face = fdata[i];
85+
FSFace& face = pm->Face(fdata[i]);
8686
// get element to which this face belongs
8787
int iel = face.m_elem[0].eid;
8888
// store faces that share this element
8989
efm[iel].push_back(i);
90-
pm->Element(iel).m_ntag = 1;
90+
pm->Element(iel).m_ntag = 1;
9191
}
9292

9393
// mark all nodes on the selected faces
9494
pm->TagAllNodes(-1);
95-
for (int i = 0; i<ne1; ++i)
96-
for (int j = 0; j<fdata[i].Nodes(); ++j)
97-
pm->Node(fdata[i].n[j]).m_ntag = 1;
95+
for (int i = 0; i < ne1; ++i)
96+
{
97+
const FSFace& face = pm->Face(fdata[i]);
98+
for (int j = 0; j < face.Nodes(); ++j)
99+
pm->Node(face.n[j]).m_ntag = 1;
100+
}
98101

99102
// find all elements that share nodes with these faces
100103
// fne key = non-face element
101104
// fne mapped values = vector of entries into fdata faces
102105
std::map<int, vector<int>> fne;
103106
for (int i = 0; i<pm->Elements(); ++i) {
104-
FSElement el = pm->Element(i);
107+
const FSElement& el = pm->Element(i);
105108
if (pm->Element(i).m_ntag == -1) {
106109
vector<int> shared_nodes;
107110
shared_nodes.reserve(el.Nodes());
@@ -114,6 +117,10 @@ bool FEBoundaryLayerMesher::BoundaryLayer(FSMesh* pm)
114117
}
115118
}
116119

120+
// tag elements for deletion
121+
int ne0 = pm->Elements();
122+
vector<bool> delem(ne0, false);
123+
117124
// create a domain from all selected elements
118125
FSDomain dom(pm);
119126
std::map<int, vector<int>>::iterator it;
@@ -124,7 +131,7 @@ bool FEBoundaryLayerMesher::BoundaryLayer(FSMesh* pm)
124131
// add element to domain
125132
dom.AddElement(iel);
126133
// set meshing parameters
127-
FSFace face = fdata[it->second[0]];
134+
const FSFace& face = pm->Face(fdata[it->second[0]]);
128135
FEElement_& el = pm->Element(iel);
129136
if (el.Type() == FE_HEX8) {
130137
// get the box from this domain
@@ -165,8 +172,8 @@ bool FEBoundaryLayerMesher::BoundaryLayer(FSMesh* pm)
165172
}
166173
else if (it->second.size() == 2) {
167174
// two faces connected to this element
168-
FSFace face0 = fdata[it->second[0]];
169-
FSFace face1 = fdata[it->second[1]];
175+
const FSFace& face0 = pm->Face(fdata[it->second[0]]);
176+
const FSFace& face1 = pm->Face(fdata[it->second[1]]);
170177
// check if they share common nodes
171178
vector<int> cn;
172179
for (int i = 0; i<face0.Nodes(); ++i)
@@ -221,10 +228,10 @@ bool FEBoundaryLayerMesher::BoundaryLayer(FSMesh* pm)
221228
}
222229
// for each of these other faces mesh the opposite element
223230
for (int i = 0; i<2; ++i) {
224-
// find the neihboring element
231+
// find the neighboring element
225232
int jel = -1;
226233
for (int k = 0; k<pm->Elements(); ++k) {
227-
FEElement_ oel = pm->Element(k);
234+
FEElement_& oel = pm->Element(k);
228235
if ((k != iel) && (oel.Type() == FE_TET4))
229236
if (oel.FindFace(opface[i]) != -1) {
230237
jel = k;

0 commit comments

Comments
 (0)