NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
NEM::MSH::inpGeoMesh Class Referenceabstract

Class representing meshes in CalculiX input deck (similar to ABAQUS) More...

Detailed Description

Currently supports the keywords ELEMENT ("C3D4", "C3D8", and "C3D6" types, ELSET parameter), ELSET, NSET, and SURFACE (TYPE=ELEMENT only). By default, physical groups with dimension equal to mesh dimension are turned into ELSETs, and NSETs and physical groups with dimension one less than mesh dimension are turned into SURFACEs and NSETs.

Definition at line 49 of file inpGeoMesh.H.

Classes

struct  InpSets
 

Public Member Functions

decltype(InpSets::nodeSets) & getNSets ()
 
decltype(InpSets::elSets) & getElSets ()
 
decltype(InpSets::surfaces) & getSurfaces ()
 
virtual void write (const std::string &fileName)=0
 Write mesh to file. More...
 
virtual void report (std::ostream &out) const =0
 Print a report about the mesh. More...
 
virtual void takeGeoMesh (geoMeshBase *otherGeoMesh)
 Take the GeoMesh of another geoMeshBase. More...
 
virtual void mergeGeoMesh (geoMeshBase *otherGeoMesh)
 Merge mesh data from a new geoMesh to an existing geoMesh. More...
 
const std::string & getGeoEntArrayName () const
 Get the name of the geometric entities array. More...
 
void setGeoEntArrayName (const std::string &geoEntArrayName)
 Set the name of the geometric entities array. More...
 
double getAngleThreshold () const
 Get the angle threshold used for surface classification. More...
 
void setAngleThreshold (double angleThreshold)
 Set the angle threshold used for surface classification. More...
 
nemId_t getNumberOfPoints () const
 Get the number of points in mesh. More...
 
nemId_t getNumberOfCells () const
 Get the number of cells in mesh. More...
 
void getPoint (nemId_t id, std::array< double, 3 > *x) const
 Get the coordinate of a point. More...
 
std::array< double, 3 > getPoint (nemId_t id) const
 Get the coordinate of a point. More...
 
void getCell (nemId_t cellId, vtkGenericCell *cell) const
 Get cell. More...
 
vtkCell * getCell (nemId_t cellId) const
 Get cell. More...
 
void getCellBounds (nemId_t cellId, std::array< double, 6 > *bounds) const
 Get cell bounds. More...
 
std::array< double, 6 > getCellBounds (nemId_t cellId) const
 Get cell bounds. More...
 
VTKCellType getCellType (nemId_t cellId) const
 Get VTK cell type. More...
 
void getCellPoints (nemId_t cellId, vtkIdList *ptIds) const
 Get list of point ids defining specified cell. More...
 
void getPointCells (nemId_t ptId, vtkIdList *cellIds) const
 Get list of cell ids using specified point. More...
 
void getCellNeighbors (nemId_t cellId, vtkIdList *ptIds, vtkIdList *cellIds) const
 Get list of cells sharing points ptIds excluding cellId. More...
 
int getNumberOfPointDataArrays () const
 Get number of arrays in the point data. More...
 
void getPointDataArrayCopy (const std::string &arrayName, vtkAbstractArray *array, int *arrayIdx=nullptr) const
 Get copy of point data array by name. More...
 
vtkSmartPointer< vtkAbstractArray > getPointDataArrayCopy (const std::string &arrayName, int *arrayIdx=nullptr) const
 Create and return a copy of point data array by name. More...
 
void getPointDataArrayCopy (int arrayIdx, vtkAbstractArray *array) const
 Get copy of point data array by index. More...
 
vtkSmartPointer< vtkAbstractArray > getPointDataArrayCopy (int arrayIdx) const
 Create and return a copy of point data array by index. More...
 
int getNumberOfCellDataArrays () const
 Get number of arrays in the cell data. More...
 
void getCellDataArrayCopy (const std::string &arrayName, vtkAbstractArray *array, int *arrayIdx=nullptr) const
 Get copy of cell data array by name. More...
 
vtkSmartPointer< vtkAbstractArray > getCellDataArrayCopy (const std::string &arrayName, int *arrayIdx=nullptr) const
 Create and return a copy of cell data array by name. More...
 
void getCellDataArrayCopy (int arrayIdx, vtkAbstractArray *array) const
 Get copy of cell data array by index. More...
 
vtkSmartPointer< vtkAbstractArray > getCellDataArrayCopy (int arrayIdx) const
 Create and return a copy of cell data array by index. More...
 
int getNumberOfFieldDataArrays () const
 Get number of arrays in the field data. More...
 
void getFieldDataArrayCopy (const std::string &arrayName, vtkAbstractArray *array, int *arrayIdx=nullptr) const
 Get copy of field data array by name. More...
 
vtkSmartPointer< vtkAbstractArray > getFieldDataArrayCopy (const std::string &arrayName, int *arrayIdx=nullptr) const
 Create and return a copy of field data array by name. More...
 
void getFieldDataArrayCopy (int arrayIdx, vtkAbstractArray *array) const
 Get copy of field data array by index. More...
 
vtkSmartPointer< vtkAbstractArray > getFieldDataArrayCopy (int arrayIdx) const
 Create and return a copy of field data array by index. More...
 

Static Public Member Functions

static inpGeoMeshNew ()
 
static inpGeoMeshRead (const std::string &fileName)
 

Protected Member Functions

 inpGeoMesh ()
 
 inpGeoMesh (const std::string &fileName)
 
void reconstructGeo () override
 Construct the geometry from the mesh alone. More...
 
int setPointDataArray (vtkAbstractArray *array)
 Set point data. More...
 
int setCellDataArray (vtkAbstractArray *array)
 Set cell data. More...
 
int setFieldDataArray (vtkAbstractArray *array)
 Set field data. More...
 
void unsetPointDataArray (int arrayIdx)
 Remove point data array by index. More...
 
void unsetPointDataArray (const std::string &arrayName)
 Remove point data array by name. More...
 
void unsetCellDataArray (int arrayIdx)
 Remove cell data array by index. More...
 
void unsetCellDataArray (const std::string &arrayName)
 Remove cell data array by name. More...
 
void unsetFieldDataArray (int arrayIdx)
 Remove field data array by index. More...
 
void unsetFieldDataArray (const std::string &arrayName)
 Remove field data array by name. More...
 
const GeoMeshgetGeoMesh () const
 Get the underlying geometry object. More...
 
void setGeoMesh (const geoMeshBase::GeoMesh &geoMesh)
 Set the underlying geometry object. More...
 

Static Protected Attributes

static constexpr auto GEO_ENT_DEFAULT_NAME = "GeoEnt"
 

Private Member Functions

 inpGeoMesh (std::pair< GeoMesh, InpSets > mesh)
 Ctor meant for ease of delegating to geoMeshBase ctor. More...
 
void resetNative () override
 

Static Private Member Functions

static std::pair< GeoMesh, InpSetsinp2GM (const std::string &fileName)
 

Private Attributes

InpSets inpSets_
 Holds data specific to inp format. More...
 

Inherits NEM::MSH::geoMeshBase.

Constructor & Destructor Documentation

◆ inpGeoMesh() [1/3]

◆ inpGeoMesh() [2/3]

NEM::MSH::inpGeoMesh::inpGeoMesh ( const std::string &  fileName)
explicitprotected

Definition at line 599 of file inpGeoMesh.C.

600  : inpGeoMesh(inp2GM(fileName)) {}
static std::pair< GeoMesh, InpSets > inp2GM(const std::string &fileName)
Definition: inpGeoMesh.C:719

◆ inpGeoMesh() [3/3]

NEM::MSH::inpGeoMesh::inpGeoMesh ( std::pair< GeoMesh, InpSets mesh)
explicitprivate
Parameters
meshfrom parsing a .inp mesh file

Definition at line 602 of file inpGeoMesh.C.

603  : geoMeshBase(std::move(mesh.first)), inpSets_(std::move(mesh.second)) {}
std::shared_ptr< meshBase > mesh
geoMeshBase()
Query for conversion from vtk to gmsh.
Definition: geoMeshBase.C:77
InpSets inpSets_
Holds data specific to inp format.
Definition: inpGeoMesh.H:96

Member Function Documentation

◆ getAngleThreshold()

double NEM::MSH::geoMeshBase::getAngleThreshold ( ) const
inlineinherited
Returns
angle threshold (in radians)

Definition at line 171 of file geoMeshBase.H.

171 { return _angleThreshold; }
double _angleThreshold
Dihedral angle threshold (in radians) to classify surfaces (Default: 30 degrees)
Definition: geoMeshBase.H:554

◆ getCell() [1/2]

void NEM::MSH::geoMeshBase::getCell ( nemId_t  cellId,
vtkGenericCell *  cell 
) const
inlineinherited
Parameters
cellIdcell id
cellcell

Definition at line 214 of file geoMeshBase.H.

Referenced by NEM::MSH::diffMesh().

214  {
215  _geoMesh.mesh->GetCell(cellId, cell);
216  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getCell() [2/2]

vtkCell* NEM::MSH::geoMeshBase::getCell ( nemId_t  cellId) const
inlineinherited
Parameters
cellIdcell id
Returns
cell

Definition at line 222 of file geoMeshBase.H.

222  {
223  return _geoMesh.mesh->GetCell(cellId);
224  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getCellBounds() [1/2]

void NEM::MSH::geoMeshBase::getCellBounds ( nemId_t  cellId,
std::array< double, 6 > *  bounds 
) const
inlineinherited
Parameters
cellIdcell id
boundsarray of bounds as (x_min,x_max, y_min,y_max, z_min,z_max)

Definition at line 230 of file geoMeshBase.H.

230  {
231  _geoMesh.mesh->GetCellBounds(cellId, bounds->data());
232  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getCellBounds() [2/2]

std::array<double, 6> NEM::MSH::geoMeshBase::getCellBounds ( nemId_t  cellId) const
inlineinherited
Parameters
cellIdcell id
Returns
array of bounds as (x_min,x_max, y_min,y_max, z_min,z_max)

Definition at line 238 of file geoMeshBase.H.

238  {
239  std::array<double, 6> bounds{};
240  getCellBounds(cellId, &bounds);
241  return bounds;
242  }
void getCellBounds(nemId_t cellId, std::array< double, 6 > *bounds) const
Get cell bounds.
Definition: geoMeshBase.H:230

◆ getCellDataArrayCopy() [1/4]

void NEM::MSH::geoMeshBase::getCellDataArrayCopy ( const std::string &  arrayName,
vtkAbstractArray *  array,
int *  arrayIdx = nullptr 
) const
inherited

Optionally, get array index.

Parameters
arrayNamearray name
arraycell data array
arrayIdxarray index

Definition at line 180 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

Referenced by NEM::MSH::diffMesh().

182  {
183  getArrCopy(_geoMesh.mesh->GetCellData(), arrayName, arrayIdx, array);
184 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getCellDataArrayCopy() [2/4]

vtkSmartPointer< vtkAbstractArray > NEM::MSH::geoMeshBase::getCellDataArrayCopy ( const std::string &  arrayName,
int *  arrayIdx = nullptr 
) const
inherited

Optionally, get array index.

Parameters
arrayNamearray name
arrayIdxarray index
Returns
pointer to copy of array

Definition at line 186 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

187  {
188  return getArrCopy(_geoMesh.mesh->GetCellData(), arrayName, arrayIdx);
189 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getCellDataArrayCopy() [3/4]

void NEM::MSH::geoMeshBase::getCellDataArrayCopy ( int  arrayIdx,
vtkAbstractArray *  array 
) const
inherited
Parameters
arrayIdxarray index
arraycell data array

Definition at line 191 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

192  {
193  getArrCopy(_geoMesh.mesh->GetCellData(), arrayIdx, array);
194 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getCellDataArrayCopy() [4/4]

vtkSmartPointer< vtkAbstractArray > NEM::MSH::geoMeshBase::getCellDataArrayCopy ( int  arrayIdx) const
inherited
Parameters
arrayIdxarray index
Returns
pointer to copy of array

Definition at line 196 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

197  {
198  return getArrCopy(_geoMesh.mesh->GetCellData(), arrayIdx);
199 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getCellNeighbors()

void NEM::MSH::geoMeshBase::getCellNeighbors ( nemId_t  cellId,
vtkIdList *  ptIds,
vtkIdList *  cellIds 
) const
inlineinherited
Parameters
cellIdid of cell to exclude
ptIdspoint id
cellIdslist of cell ids

Definition at line 273 of file geoMeshBase.H.

274  {
275  _geoMesh.mesh->GetCellNeighbors(cellId, ptIds, cellIds);
276  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getCellPoints()

void NEM::MSH::geoMeshBase::getCellPoints ( nemId_t  cellId,
vtkIdList *  ptIds 
) const
inlineinherited
Parameters
cellIdcell id
ptIdslist of point ids

Definition at line 256 of file geoMeshBase.H.

256  {
257  _geoMesh.mesh->GetCellPoints(cellId, ptIds);
258  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getCellType()

VTKCellType NEM::MSH::geoMeshBase::getCellType ( nemId_t  cellId) const
inlineinherited
Parameters
cellIdcell id
Returns
VTK cell type (see vtk documentation for specifics)

Definition at line 248 of file geoMeshBase.H.

248  {
249  return static_cast<VTKCellType>(_geoMesh.mesh->GetCellType(cellId));
250  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getElSets()

decltype(InpSets::elSets) & NEM::MSH::inpGeoMesh::getElSets ( )
inline

Definition at line 75 of file inpGeoMesh.H.

75 { return inpSets_.elSets; }
std::map< std::string, std::set< vtkIdType > > elSets
ELSET keyword; indexing matches GeoMesh::mesh.
Definition: inpGeoMesh.H:59
InpSets inpSets_
Holds data specific to inp format.
Definition: inpGeoMesh.H:96

◆ getFieldDataArrayCopy() [1/4]

void NEM::MSH::geoMeshBase::getFieldDataArrayCopy ( const std::string &  arrayName,
vtkAbstractArray *  array,
int *  arrayIdx = nullptr 
) const
inherited

Optionally, get array index.

Parameters
arrayNamearray name
arrayfield data array
arrayIdxarray index

Definition at line 201 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

203  {
204  getArrCopy(_geoMesh.mesh->GetFieldData(), arrayName, arrayIdx, array);
205 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getFieldDataArrayCopy() [2/4]

vtkSmartPointer< vtkAbstractArray > NEM::MSH::geoMeshBase::getFieldDataArrayCopy ( const std::string &  arrayName,
int *  arrayIdx = nullptr 
) const
inherited

Optionally, get array index.

Parameters
arrayNamearray name
arrayIdxarray index
Returns
pointer to copy of array

Definition at line 207 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

208  {
209  return getArrCopy(_geoMesh.mesh->GetFieldData(), arrayName, arrayIdx);
210 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getFieldDataArrayCopy() [3/4]

void NEM::MSH::geoMeshBase::getFieldDataArrayCopy ( int  arrayIdx,
vtkAbstractArray *  array 
) const
inherited
Parameters
arrayIdxarray index
arrayfield data array

Definition at line 212 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

213  {
214  getArrCopy(_geoMesh.mesh->GetFieldData(), arrayIdx, array);
215 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getFieldDataArrayCopy() [4/4]

vtkSmartPointer< vtkAbstractArray > NEM::MSH::geoMeshBase::getFieldDataArrayCopy ( int  arrayIdx) const
inherited
Parameters
arrayIdxarray index
Returns
pointer to copy of array

Definition at line 217 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

218  {
219  return getArrCopy(_geoMesh.mesh->GetFieldData(), arrayIdx);
220 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getGeoEntArrayName()

const std::string& NEM::MSH::geoMeshBase::getGeoEntArrayName ( ) const
inlineinherited
Returns
name of geometric entities array

Definition at line 157 of file geoMeshBase.H.

Referenced by NEM::MSH::diffMesh().

157 { return _geoMesh.link; }

◆ getGeoMesh()

◆ getNSets()

decltype(InpSets::nodeSets) & NEM::MSH::inpGeoMesh::getNSets ( )
inline

Definition at line 74 of file inpGeoMesh.H.

74 { return inpSets_.nodeSets; }
std::map< std::string, std::set< vtkIdType > > nodeSets
NSET keyword; indexing matches GeoMesh::mesh.
Definition: inpGeoMesh.H:55
InpSets inpSets_
Holds data specific to inp format.
Definition: inpGeoMesh.H:96

◆ getNumberOfCellDataArrays()

int NEM::MSH::geoMeshBase::getNumberOfCellDataArrays ( ) const
inlineinherited
Returns
number of arrays in the cell data

Definition at line 318 of file geoMeshBase.H.

Referenced by NEM::MSH::diffMesh().

318  {
319  return _geoMesh.mesh->GetCellData()->GetNumberOfArrays();
320  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getNumberOfCells()

nemId_t NEM::MSH::geoMeshBase::getNumberOfCells ( ) const
inlineinherited
Returns
number of cells in mesh

Definition at line 190 of file geoMeshBase.H.

Referenced by NEM::MSH::diffMesh().

190 { return _geoMesh.mesh->GetNumberOfCells(); }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getNumberOfFieldDataArrays()

int NEM::MSH::geoMeshBase::getNumberOfFieldDataArrays ( ) const
inlineinherited
Returns
number of arrays in the field data

Definition at line 355 of file geoMeshBase.H.

355  {
356  return _geoMesh.mesh->GetFieldData()->GetNumberOfArrays();
357  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getNumberOfPointDataArrays()

int NEM::MSH::geoMeshBase::getNumberOfPointDataArrays ( ) const
inlineinherited
Returns
number of arrays in the point data

Definition at line 281 of file geoMeshBase.H.

Referenced by NEM::MSH::diffMesh().

281  {
282  return _geoMesh.mesh->GetPointData()->GetNumberOfArrays();
283  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getNumberOfPoints()

nemId_t NEM::MSH::geoMeshBase::getNumberOfPoints ( ) const
inlineinherited
Returns
number of points in mesh

Definition at line 183 of file geoMeshBase.H.

Referenced by NEM::MSH::diffMesh().

183  {
184  return _geoMesh.mesh->GetNumberOfPoints();
185  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getPoint() [1/2]

void NEM::MSH::geoMeshBase::getPoint ( nemId_t  id,
std::array< double, 3 > *  x 
) const
inlineinherited
Parameters
idpoint id
xarray of coordinates as (x,y,z)

Definition at line 196 of file geoMeshBase.H.

Referenced by NEM::MSH::diffMesh().

196  {
197  _geoMesh.mesh->GetPoint(id, x->data());
198  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getPoint() [2/2]

std::array<double, 3> NEM::MSH::geoMeshBase::getPoint ( nemId_t  id) const
inlineinherited
Parameters
idpoint id
Returns
array of coordinates as (x,y,z)

Definition at line 204 of file geoMeshBase.H.

204  {
205  std::array<double, 3> x{};
206  getPoint(id, &x);
207  return x;
208  }
void getPoint(nemId_t id, std::array< double, 3 > *x) const
Get the coordinate of a point.
Definition: geoMeshBase.H:196

◆ getPointCells()

void NEM::MSH::geoMeshBase::getPointCells ( nemId_t  ptId,
vtkIdList *  cellIds 
) const
inlineinherited
Parameters
ptIdpoint id
cellIdslist of cell ids

Definition at line 264 of file geoMeshBase.H.

264  {
265  _geoMesh.mesh->GetPointCells(ptId, cellIds);
266  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getPointDataArrayCopy() [1/4]

void NEM::MSH::geoMeshBase::getPointDataArrayCopy ( const std::string &  arrayName,
vtkAbstractArray *  array,
int *  arrayIdx = nullptr 
) const
inherited

Optionally, get array index.

Parameters
arrayNamearray name
arraypoint data array
arrayIdxarray index

Definition at line 159 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

Referenced by NEM::MSH::diffMesh().

161  {
162  getArrCopy(_geoMesh.mesh->GetPointData(), arrayName, arrayIdx, array);
163 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getPointDataArrayCopy() [2/4]

vtkSmartPointer< vtkAbstractArray > NEM::MSH::geoMeshBase::getPointDataArrayCopy ( const std::string &  arrayName,
int *  arrayIdx = nullptr 
) const
inherited

Optionally, get array index.

Parameters
arrayNamearray name
arrayIdxarray index
Returns
pointer to copy of array

Definition at line 165 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

166  {
167  return getArrCopy(_geoMesh.mesh->GetPointData(), arrayName, arrayIdx);
168 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getPointDataArrayCopy() [3/4]

void NEM::MSH::geoMeshBase::getPointDataArrayCopy ( int  arrayIdx,
vtkAbstractArray *  array 
) const
inherited
Parameters
arrayIdxarray index
arraypoint data array

Definition at line 170 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

171  {
172  getArrCopy(_geoMesh.mesh->GetPointData(), arrayIdx, array);
173 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getPointDataArrayCopy() [4/4]

vtkSmartPointer< vtkAbstractArray > NEM::MSH::geoMeshBase::getPointDataArrayCopy ( int  arrayIdx) const
inherited
Parameters
arrayIdxarray index
Returns
pointer to copy of array

Definition at line 175 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

176  {
177  return getArrCopy(_geoMesh.mesh->GetPointData(), arrayIdx);
178 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ getSurfaces()

decltype(InpSets::surfaces) & NEM::MSH::inpGeoMesh::getSurfaces ( )
inline

Definition at line 76 of file inpGeoMesh.H.

References mesh.

76 { return inpSets_.surfaces; }
std::map< std::string, std::set< vtkIdType > > surfaces
SURFACE keyword; indexing matches GeoMesh::sideSet.
Definition: inpGeoMesh.H:63
InpSets inpSets_
Holds data specific to inp format.
Definition: inpGeoMesh.H:96

◆ inp2GM()

std::pair< geoMeshBase::GeoMesh, inpGeoMesh::InpSets > NEM::MSH::inpGeoMesh::inp2GM ( const std::string &  fileName)
staticprivate

Definition at line 719 of file inpGeoMesh.C.

References NEM::MSH::geoMeshBase::GEO_ENT_DEFAULT_NAME, nemAux::getRandomString(), NEM::MSH::GmshInterface::Initialize(), mesh, NEM::MSH::New(), and points.

720  {
722  std::map<std::string, std::set<vtkIdType>> outNSets, outElSets, outSurfaces;
723  SideSet sideSet{};
724  std::string geoName{};
725  std::string linkName{};
726  if (fileName.empty()) { return {{mesh, {}, {}, {}}, {}}; }
727  std::ifstream inFile(fileName);
728  std::string line;
729  InpParser parser{};
730  while (std::getline(inFile, line)) { parser.parseLine(line); }
731  auto parserMesh = parser.getMesh();
732 
733  std::map<vtkIdType, vtkIdType> nodeInpId2GMIdx;
734  if (!parserMesh.nodes.empty()) {
735  vtkNew<vtkPoints> points;
736  points->Allocate(parserMesh.nodes.size());
737  for (const auto &parserNode : parserMesh.nodes) {
738  nodeInpId2GMIdx[parserNode.first] =
739  points->InsertNextPoint(parserNode.second.data());
740  }
741  mesh->SetPoints(points);
742  }
743  auto nodeMapper = [&nodeInpId2GMIdx](vtkIdType x) {
744  return nodeInpId2GMIdx.at(x);
745  };
746  for (const auto &nSet : parserMesh.nodeSets) {
747  auto &outNSet = outNSets[nSet.first];
748  std::transform(nSet.second.begin(), nSet.second.end(),
749  std::inserter(outNSet, outNSet.end()), nodeMapper);
750  }
751  std::map<vtkIdType, vtkIdType> inpId2GMIdx;
752  if (!parserMesh.elems.empty()) {
753  mesh->Allocate(parserMesh.elems.size());
754 #ifdef HAVE_GMSH
756  geoName = "geoMesh_" + nemAux::getRandomString(6);
757  gmsh::model::add(geoName);
758  gmsh::model::setCurrent(geoName);
759 #endif
760  linkName = GEO_ENT_DEFAULT_NAME;
761  vtkNew<vtkIntArray> geoEntArr;
762  geoEntArr->SetName(linkName.c_str());
763 #ifndef HAVE_GMSH
764  int entTag = 1;
765 #endif
766  for (const auto &elemSet : parserMesh.elems) {
767 #ifdef HAVE_GMSH
768  auto entTag = gmsh::model::addDiscreteEntity(parserMesh.maxDim);
769  gmsh::model::setEntityName(parserMesh.maxDim, entTag, elemSet.first);
770 #endif
771  for (const auto &elem : elemSet.second) {
772  auto points = elem.points;
773  std::transform(points.begin(), points.end(), points.begin(),
774  nodeMapper);
775  if (elem.cellType == VTK_WEDGE) {
776  std::swap(points.at(1), points.at(2));
777  std::swap(points.at(4), points.at(5));
778  }
779  inpId2GMIdx[elem.id] =
780  mesh->InsertNextCell(elem.cellType, points.size(), points.data());
781  geoEntArr->InsertNextValue(entTag);
782  }
783 #ifndef HAVE_GMSH
784  ++entTag;
785 #endif
786  }
787  mesh->GetCellData()->AddArray(geoEntArr);
788  }
789  for (const auto &elSet : parserMesh.elSets) {
790  auto &outElSet = outElSets[elSet.first];
791  for (const auto &elem : elSet.second) {
792  auto iterCellIdxMap = inpId2GMIdx.find(elem);
793  if (iterCellIdxMap != inpId2GMIdx.end()) {
794  outElSet.emplace(iterCellIdxMap->second);
795  }
796  }
797  }
798  if (!parserMesh.surfaces.empty()) {
799  auto sideSetPD = vtkSmartPointer<vtkPolyData>::New();
800  sideSetPD->SetPoints(mesh->GetPoints());
801  sideSetPD->Allocate();
802  vtkNew<vtkIntArray> entArr;
803  vtkNew<vtkIdTypeArray> origCellArr;
804  origCellArr->SetNumberOfComponents(2);
805  vtkNew<vtkIntArray> cellFaceArr;
806  cellFaceArr->SetNumberOfComponents(2);
807 #ifndef HAVE_GMSH
808  int entTag = 1;
809 #endif
810  for (const auto &surf : parserMesh.surfaces) {
811  auto &outSurface = outSurfaces[surf.first];
812 #ifdef HAVE_GMSH
813  auto entTag = gmsh::model::addDiscreteEntity(parserMesh.maxDim - 1);
814  auto phyGroupTag =
815  gmsh::model::addPhysicalGroup(parserMesh.maxDim - 1, {entTag});
816  gmsh::model::setPhysicalName(parserMesh.maxDim - 1, phyGroupTag,
817  surf.first);
818 #endif
819  for (const auto &side : surf.second) {
820  auto iterCellIdxMap = inpId2GMIdx.find(side.first);
821  if (iterCellIdxMap != inpId2GMIdx.end()) {
822  auto origCell = mesh->GetCell(iterCellIdxMap->second);
823  auto vtkSide = inpSide2vtkSide(
824  static_cast<VTKCellType>(origCell->GetCellType()), side.second);
825  auto sideCell = origCell->GetCellDimension() == 2
826  ? origCell->GetEdge(vtkSide)
827  : origCell->GetFace(vtkSide);
828  auto sideIdx = sideSetPD->InsertNextCell(sideCell->GetCellType(),
829  sideCell->GetPointIds());
830  entArr->InsertTypedComponent(sideIdx, 0, entTag);
831  origCellArr->InsertTuple2(sideIdx, iterCellIdxMap->second, -1);
832  cellFaceArr->InsertTuple2(sideIdx, vtkSide, -1);
833  outSurface.emplace(sideIdx);
834  }
835  }
836 #ifndef HAVE_GMSH
837  ++entTag;
838 #endif
839  }
840  sideSet = {sideSetPD, entArr, origCellArr, cellFaceArr};
841  }
842  return {{mesh, std::move(geoName), std::move(linkName), sideSet},
843  {std::move(outElSets), std::move(outNSets), std::move(outSurfaces)}};
844 }
static constexpr auto GEO_ENT_DEFAULT_NAME
Definition: geoMeshBase.H:446
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
static void Initialize()
Initialize Gmsh.
Definition: geoMeshBase.C:67
std::string getRandomString(int length)
std::shared_ptr< meshBase > mesh
std::vector< vtkIdType > points
points given by id in .inp file
Definition: inpGeoMesh.C:133

◆ mergeGeoMesh()

void NEM::MSH::geoMeshBase::mergeGeoMesh ( geoMeshBase otherGeoMesh)
virtualinherited

Deletes the data from the new geoMesh pointer

Parameters
otherGeoMeshA new geoMesh data to merge

Definition at line 113 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, NEM::MSH::geoMeshBase::GeoMesh::mesh, NEM::MSH::New(), and NEM::MSH::geoMeshBase::resetNative().

113  {
114  vtkSmartPointer<vtkAppendFilter> appendFilter =
116  appendFilter->AddInputData(_geoMesh.mesh);
117  appendFilter->AddInputData(otherGeoMesh->_geoMesh.mesh);
118  appendFilter->MergePointsOn();
119  appendFilter->Update();
120  _geoMesh.mesh = appendFilter->GetOutput();
121  otherGeoMesh->_geoMesh = {
123  otherGeoMesh->resetNative();
124 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
virtual void resetNative()=0

◆ New()

static inpGeoMesh* NEM::MSH::inpGeoMesh::New ( )
static

◆ Read()

static inpGeoMesh* NEM::MSH::inpGeoMesh::Read ( const std::string &  fileName)
static

Referenced by NEM::MSH::Read().

◆ reconstructGeo()

void NEM::MSH::inpGeoMesh::reconstructGeo ( )
overrideprotectedvirtual

Sets geometry, link, and side set. Does not alter the mesh.

Reimplemented from NEM::MSH::geoMeshBase.

Definition at line 673 of file inpGeoMesh.C.

References NEM::MSH::geoMeshBase::reconstructGeo(), and resetNative().

673  {
675  this->resetNative();
676 }
virtual void reconstructGeo()
Construct the geometry from the mesh alone.
void resetNative() override
Definition: inpGeoMesh.C:678

◆ report()

void NEM::MSH::geoMeshBase::report ( std::ostream &  out) const
pure virtualinherited
Parameters
outstream

Implemented in NEM::MSH::oshGeoMesh, NEM::MSH::exoGeoMesh, NEM::MSH::foamGeoMesh, NEM::MSH::gmshGeoMesh, and NEM::MSH::vtkGeoMesh.

Definition at line 97 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::getGeoMesh(), mesh, and NEM::MSH::geoMeshBase::GeoMesh::mesh.

Referenced by inpGeoMesh(), NEM::MSH::mesh_(), NEM::MSH::vtkGeoMesh::report(), NEM::MSH::gmshGeoMesh::report(), NEM::MSH::foamGeoMesh::report(), NEM::MSH::exoGeoMesh::report(), and NEM::MSH::oshGeoMesh::report().

97  {
98  out << this->GetClassName() << ":\n";
99  auto mesh = getGeoMesh().mesh;
100  out << "Nodes:\t" << mesh->GetNumberOfPoints() << '\n';
101  out << "Elements:\t" << mesh->GetNumberOfCells() << '\n';
102 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419
std::shared_ptr< meshBase > mesh
const GeoMesh & getGeoMesh() const
Get the underlying geometry object.
Definition: geoMeshBase.H:533

◆ resetNative()

void NEM::MSH::inpGeoMesh::resetNative ( )
overrideprivatevirtual

Implements NEM::MSH::geoMeshBase.

Definition at line 678 of file inpGeoMesh.C.

References NEM::MSH::inpGeoMesh::InpSets::elSets, NEM::MSH::geoMeshBase::getGeoMesh(), inpSets_, NEM::MSH::geoMeshBase::GeoMesh::mesh, NEM::MSH::inpGeoMesh::InpSets::nodeSets, NEM::MSH::geoMeshBase::SideSet::sides, NEM::MSH::geoMeshBase::GeoMesh::sideSet, and NEM::MSH::inpGeoMesh::InpSets::surfaces.

Referenced by reconstructGeo().

678  {
679  this->inpSets_.nodeSets.clear();
680  this->inpSets_.elSets.clear();
681  this->inpSets_.surfaces.clear();
682  // Default behavior:
683  // Convert mesh entities to element sets and mesh physical groups to element
684  // sets and node sets
685  // Convert sideSet physical groups to surfaces and node sets
686  auto gm = getGeoMesh();
687 #ifdef HAVE_GMSH
688  if (!gm.geo.empty()) {
689  gmsh::model::setCurrent(gm.geo);
690  if (!gm.link.empty() && gm.mesh->GetNumberOfCells() > 0) {
691  eachGmshPhyGroup(
692  gm.mesh, gm.mesh->GetCellData()->GetArray(gm.link.c_str()),
693  gm.mesh->GetCell(0)->GetCellDimension(),
694  [this](const std::string &phyGroup, vtkIdType cellIdx) {
695  this->inpSets_.elSets[phyGroup].emplace(cellIdx);
696  auto cell = this->getGeoMesh().mesh->GetCell(cellIdx);
697  for (vtkIdType i = 0; i < cell->GetNumberOfPoints(); ++i) {
698  this->inpSets_.nodeSets[phyGroup].emplace(cell->GetPointId(i));
699  }
700  });
701  }
702  if (gm.sideSet.sides && gm.sideSet.sides->GetNumberOfCells() > 0) {
703  gm.findSide2OrigCell();
704  eachGmshPhyGroup(
705  gm.sideSet.sides, gm.sideSet.getGeoEntArr(),
706  gm.sideSet.sides->GetCell(0)->GetCellDimension(),
707  [this](const std::string &phyGroup, vtkIdType cellIdx) {
708  this->inpSets_.surfaces[phyGroup].emplace(cellIdx);
709  auto cell = this->getGeoMesh().sideSet.sides->GetCell(cellIdx);
710  for (vtkIdType i = 0; i < cell->GetNumberOfPoints(); ++i) {
711  this->inpSets_.nodeSets[phyGroup].emplace(cell->GetPointId(i));
712  }
713  });
714  }
715  }
716 #endif
717 }
std::map< std::string, std::set< vtkIdType > > surfaces
SURFACE keyword; indexing matches GeoMesh::sideSet.
Definition: inpGeoMesh.H:63
std::map< std::string, std::set< vtkIdType > > nodeSets
NSET keyword; indexing matches GeoMesh::mesh.
Definition: inpGeoMesh.H:55
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419
std::map< std::string, std::set< vtkIdType > > elSets
ELSET keyword; indexing matches GeoMesh::mesh.
Definition: inpGeoMesh.H:59
vtkSmartPointer< vtkPolyData > sides
Cells represent edges/faces of some GeoMesh.
Definition: geoMeshBase.H:399
InpSets inpSets_
Holds data specific to inp format.
Definition: inpGeoMesh.H:96
const GeoMesh & getGeoMesh() const
Get the underlying geometry object.
Definition: geoMeshBase.H:533

◆ setAngleThreshold()

void NEM::MSH::geoMeshBase::setAngleThreshold ( double  angleThreshold)
inlineinherited
Parameters
angleThreshold(in radians)

Definition at line 176 of file geoMeshBase.H.

176  {
177  _angleThreshold = angleThreshold;
178  }
double _angleThreshold
Dihedral angle threshold (in radians) to classify surfaces (Default: 30 degrees)
Definition: geoMeshBase.H:554

◆ setCellDataArray()

int NEM::MSH::geoMeshBase::setCellDataArray ( vtkAbstractArray *  array)
inlineprotectedinherited
Parameters
arrayarray pointer
Returns
array index

Definition at line 473 of file geoMeshBase.H.

473  {
474  return _geoMesh.mesh->GetCellData()->AddArray(array);
475  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ setFieldDataArray()

int NEM::MSH::geoMeshBase::setFieldDataArray ( vtkAbstractArray *  array)
inlineprotectedinherited
Parameters
arrayarray pointer
Returns
array index

Definition at line 481 of file geoMeshBase.H.

481  {
482  return _geoMesh.mesh->GetFieldData()->AddArray(array);
483  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ setGeoEntArrayName()

void NEM::MSH::geoMeshBase::setGeoEntArrayName ( const std::string &  geoEntArrayName)
inlineinherited
Parameters
geoEntArrayNamename of geometric entities array

Definition at line 162 of file geoMeshBase.H.

162  {
163  auto a = _geoMesh.mesh->GetCellData()->GetArray(_geoMesh.link.c_str());
164  if (a) a->SetName(geoEntArrayName.c_str());
165  _geoMesh.link = geoEntArrayName;
166  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ setGeoMesh()

void NEM::MSH::geoMeshBase::setGeoMesh ( const geoMeshBase::GeoMesh geoMesh)
inlineprotectedinherited

◆ setPointDataArray()

int NEM::MSH::geoMeshBase::setPointDataArray ( vtkAbstractArray *  array)
inlineprotectedinherited
Parameters
arrayarray pointer
Returns
array index

Definition at line 465 of file geoMeshBase.H.

465  {
466  return _geoMesh.mesh->GetPointData()->AddArray(array);
467  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ takeGeoMesh()

void NEM::MSH::geoMeshBase::takeGeoMesh ( geoMeshBase otherGeoMesh)
virtualinherited

Note that otherGeoMesh will be left with an empty mesh.

Parameters
otherGeoMeshother geoMeshBase object; mesh will be left empty

Reimplemented in NEM::MSH::exoGeoMesh, and NEM::MSH::oshGeoMesh.

Definition at line 104 of file geoMeshBase.C.

References NEM::MSH::geoMeshBase::_geoMesh, NEM::MSH::New(), and NEM::MSH::geoMeshBase::resetNative().

Referenced by NEM::MSH::oshGeoMesh::takeGeoMesh(), and NEM::MSH::exoGeoMesh::takeGeoMesh().

104  {
105  _geoMesh = std::move(otherGeoMesh->_geoMesh);
106  otherGeoMesh->_geoMesh = {
108  otherGeoMesh->resetNative();
109  resetNative();
110 }
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
virtual void resetNative()=0

◆ unsetCellDataArray() [1/2]

void NEM::MSH::geoMeshBase::unsetCellDataArray ( int  arrayIdx)
inlineprotectedinherited
Parameters
arrayIdxarray index

Definition at line 503 of file geoMeshBase.H.

503  {
504  _geoMesh.mesh->GetCellData()->RemoveArray(arrayIdx);
505  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ unsetCellDataArray() [2/2]

void NEM::MSH::geoMeshBase::unsetCellDataArray ( const std::string &  arrayName)
inlineprotectedinherited
Parameters
arrayNamearray name

Definition at line 510 of file geoMeshBase.H.

510  {
511  _geoMesh.mesh->GetCellData()->RemoveArray(arrayName.c_str());
512  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ unsetFieldDataArray() [1/2]

void NEM::MSH::geoMeshBase::unsetFieldDataArray ( int  arrayIdx)
inlineprotectedinherited
Parameters
arrayIdxarray index

Definition at line 517 of file geoMeshBase.H.

517  {
518  _geoMesh.mesh->GetFieldData()->RemoveArray(arrayIdx);
519  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ unsetFieldDataArray() [2/2]

void NEM::MSH::geoMeshBase::unsetFieldDataArray ( const std::string &  arrayName)
inlineprotectedinherited
Parameters
arrayNamearray name

Definition at line 524 of file geoMeshBase.H.

524  {
525  _geoMesh.mesh->GetFieldData()->RemoveArray(arrayName.c_str());
526  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ unsetPointDataArray() [1/2]

void NEM::MSH::geoMeshBase::unsetPointDataArray ( int  arrayIdx)
inlineprotectedinherited
Parameters
arrayIdxarray index

Definition at line 489 of file geoMeshBase.H.

489  {
490  _geoMesh.mesh->GetPointData()->RemoveArray(arrayIdx);
491  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ unsetPointDataArray() [2/2]

void NEM::MSH::geoMeshBase::unsetPointDataArray ( const std::string &  arrayName)
inlineprotectedinherited
Parameters
arrayNamearray name

Definition at line 496 of file geoMeshBase.H.

496  {
497  _geoMesh.mesh->GetPointData()->RemoveArray(arrayName.c_str());
498  }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419

◆ write()

virtual void NEM::MSH::geoMeshBase::write ( const std::string &  fileName)
pure virtualinherited

Member Data Documentation

◆ GEO_ENT_DEFAULT_NAME

constexpr auto NEM::MSH::geoMeshBase::GEO_ENT_DEFAULT_NAME = "GeoEnt"
staticprotectedinherited

◆ inpSets_

InpSets NEM::MSH::inpGeoMesh::inpSets_
private

Definition at line 96 of file inpGeoMesh.H.

Referenced by inpGeoMesh(), and resetNative().


The documentation for this class was generated from the following files: