Skip to content

Commit 2c67eff

Browse files
committed
Fixed: Deleting elements when extra visualization points
1 parent d1303d6 commit 2c67eff

2 files changed

Lines changed: 39 additions & 32 deletions

File tree

src/Utility/ElementBlock.C

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020

2121
double ElementBlock::eps = 0.0;
2222

23-
//! \brief List of supported number of element nodes.
24-
static const std::array<size_t,7> legalNENs = { 2, 3, 4, 6, 8, 9, 27 };
23+
24+
namespace
25+
{
26+
//! \brief List of supported number of element nodes.
27+
const std::array<size_t,7> legalNENs = { 2, 3, 4, 6, 8, 9, 27 };
28+
}
2529

2630

2731
ElementBlock::ElementBlock (size_t nenod)
@@ -299,29 +303,32 @@ utl::Point ElementBlock::getCenter (size_t i) const
299303
}
300304

301305

302-
void ElementBlock::removeElement (size_t i)
306+
void ElementBlock::removeElement (int iel)
303307
{
304-
if (i < 1 || i > MINEX.size())
305-
return;
306-
307-
std::vector<int>::iterator it1 = MMNPC.end(), it2 = MMNPC.end();
308-
if (nen > 0)
309-
{
310-
it2 = MMNPC.begin()+nen*i;
311-
it1 = it2 - nen;
312-
}
313-
else
314-
{
315-
size_t elm = 0;
316-
for (size_t ip = 0; ip < MMNPC.size() && it2 == MMNPC.end(); ip++)
317-
if (MMNPC[ip] < 0 && ++elm == i)
318-
it2 = MMNPC.begin() + ip+1;
319-
else if (elm == i-1 && it1 == MMNPC.end())
320-
it1 = MMNPC.begin() + ip;
321-
}
308+
for (size_t i = 0; i < MINEX.size();)
309+
if (MINEX[i] == iel)
310+
{
311+
std::vector<int>::iterator it1 = MMNPC.end(), it2 = MMNPC.end();
312+
if (nen > 0)
313+
{
314+
it1 = MMNPC.begin()+nen*i;
315+
it2 = it1 + nen;
316+
}
317+
else
318+
{
319+
size_t elm = 0;
320+
for (size_t ip = 0; ip < MMNPC.size() && it2 == MMNPC.end(); ip++)
321+
if (MMNPC[ip] < 0 && ++elm == i+1)
322+
it2 = MMNPC.begin() + ip+1;
323+
else if (elm == i && it1 == MMNPC.end())
324+
it1 = MMNPC.begin() + ip;
325+
}
322326

323-
MMNPC.erase(it1,it2);
324-
MINEX.erase(MINEX.begin()+i-1);
327+
MMNPC.erase(it1,it2);
328+
MINEX.erase(MINEX.begin()+i);
329+
}
330+
else
331+
++i;
325332
}
326333

327334

src/Utility/ElementBlock.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ class ElementBlock
6666
//! \param[in] elmId External element ID (generate if negative)
6767
size_t addLine(size_t i1, const Vec3& X2, int elmId = -1);
6868

69-
//! \brief Assigns an external id to an element.
69+
//! \brief Assigns an external ID to an element.
7070
void setElmId(size_t i, int iel) { MINEX[i-1] = iel; }
71-
//! \brief Returns the external id of an element.
71+
//! \brief Returns the external ID of an element.
7272
int getElmId(size_t i) const { return MINEX[i-1]; }
7373
//! \brief Returns the internal index of an element in case of mixed types.
7474
size_t getElmIndex(size_t i) const { return i < elmIdx.size() ? elmIdx[i]:i; }
@@ -108,8 +108,8 @@ class ElementBlock
108108

109109
//! \brief Returns the coordinates of the center of the given element.
110110
utl::Point getCenter(size_t i) const;
111-
//! \brief Removes the given element.
112-
void removeElement(size_t i);
111+
//! \brief Removes all elements with the specified external ID.
112+
void removeElement(int iel);
113113

114114
protected:
115115
using Prm3 = std::array<Real,3>; //!< Convenience type
@@ -136,7 +136,7 @@ class ElementBlock
136136
class PlaneBlock : public ElementBlock
137137
{
138138
public:
139-
//! \brief Constructor defining a plane from three points.
139+
//! \brief The constructor defines a plane from three points.
140140
//! \param[in] X0 First corner
141141
//! \param[in] X1 Second corner
142142
//! \param[in] X2 Third corner
@@ -153,7 +153,7 @@ class PlaneBlock : public ElementBlock
153153
class CubeBlock : public ElementBlock
154154
{
155155
public:
156-
//! \brief The constructor defines a cube centred at specified point.
156+
//! \brief The constructor defines a cube centered at the specified point.
157157
//! \param[in] X0 Center of the cube
158158
//! \param[in] dX Length of each cube edge
159159
CubeBlock(const Vec3& X0, double dX);
@@ -169,7 +169,7 @@ class CubeBlock : public ElementBlock
169169
class SphereBlock : public ElementBlock
170170
{
171171
public:
172-
//! \brief The constructor defines a sphere centred at specified point.
172+
//! \brief The constructor defines a sphere centered at the specified point.
173173
//! \param[in] X0 Center of the sphere
174174
//! \param[in] R Sphere diameter
175175
//! \param[in] nTheta Number of elements around equator
@@ -181,13 +181,13 @@ class SphereBlock : public ElementBlock
181181
/*!
182182
\brief Class for cylinder geometries.
183183
\details This class is used to create cylinder shapes in the model,
184-
for visualization of rigid contect objects, etc.
184+
for visualization of rigid contact objects, etc.
185185
*/
186186

187187
class CylinderBlock : public ElementBlock
188188
{
189189
public:
190-
//! \brief The constructor defines a sphere centred at specified point.
190+
//! \brief The constructor defines a cylinder along an axis through 2 points.
191191
//! \param[in] X0 First end point
192192
//! \param[in] X1 Second end point
193193
//! \param[in] R Cylinder diameter

0 commit comments

Comments
 (0)