MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / setElements

Method setElements

SRC/domain/region/MeshRegion.cpp:181–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181int
182MeshRegion::setElements(const ID &theEles)
183{
184 // destroy the old lists
185 if (theNodes != 0)
186 delete theNodes;
187 if (theElements != 0)
188 delete theElements;
189
190 // create new element & node lists
191 int numEle = theEles.Size();
192
193 theElements = new ID(0, numEle); // don't copy yet .. make sure ele in domain
194 theNodes = new ID(0, numEle); // initial guess at size of ID
195 if (theElements == 0 || theNodes == 0) {
196 opserr << "MeshRegion::setElements() - ran out of memory\n";
197 return -1;
198 }
199
200 // now loop over the elements in ele ID passed in to create the node & ele list
201 // NOTE - only add those elements to the list that are in the domain
202 // NOTE - node added to region if any element has it as an external node
203 int locEle = 0;
204 int locNode = 0;
205
206 Domain *theDomain = this->getDomain();
207 if (theDomain == 0) {
208 opserr << "MeshRegion::setElements() - no domain yet set\n";
209 return -1;
210 }
211
212 Element *theEle;
213 for (int i=0; i<numEle; i++) {
214 int eleTag = theEles(i);
215 theEle = theDomain->getElement(eleTag);
216 if (theEle != 0) {
217
218 if (theElements->getLocation(eleTag) < 0)
219 (*theElements)[locEle++] = eleTag;
220
221 const ID &theEleNodes = theEle->getExternalNodes();
222
223 for (int i=0; i<theEleNodes.Size(); i++) {
224 int nodeTag = theEleNodes(i);
225 // add the node tag if not already there
226 if (theNodes->getLocation(nodeTag) < 0)
227 (*theNodes)[locNode++] = nodeTag;
228 }
229 }
230 }
231
232 return 0;
233}
234
235int
236MeshRegion::setElementsOnly(const ID &theEles)

Callers 3

OPS_MeshRegionFunction · 0.45
TclAddMeshRegionFunction · 0.45
TclCommand_addMeshRegionFunction · 0.45

Calls 4

SizeMethod · 0.45
getDomainMethod · 0.45
getElementMethod · 0.45
getLocationMethod · 0.45

Tested by

no test coverage detected