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::smeshGeoMesh Class Referenceabstract

Detailed Description

Definition at line 43 of file smeshGeoMesh.H.

Public Member Functions

 smeshGeoMesh ()
 
 ~smeshGeoMesh () override
 
void setSMeshMesh (std::unique_ptr< SMESH_Mesh > &&mesh, std::shared_ptr< SMESH_Gen > gen)
 
const SMESH_Mesh & getSMESHMesh () const
 
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 reconstructGeo ()
 Construct the geometry from the mesh alone. 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 smeshGeoMeshNew ()
 

Protected Member Functions

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

void resetNative () override
 

Static Private Member Functions

static GeoMesh SmeshToGM (SMESH_Mesh &mesh)
 
static void GMToSMESH (const GeoMesh &geoMesh, SMESH_Mesh &outMesh)
 

Private Attributes

std::shared_ptr< SMESH_Gen > gen_
 
std::unique_ptr< SMESH_Mesh > mesh_
 

Inherits NEM::MSH::geoMeshBase.

Constructor & Destructor Documentation

◆ smeshGeoMesh()

NEM::MSH::smeshGeoMesh::smeshGeoMesh ( )

◆ ~smeshGeoMesh()

NEM::MSH::smeshGeoMesh::~smeshGeoMesh ( )
overridedefault

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

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

◆ 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()

◆ 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

◆ getSMESHMesh()

const SMESH_Mesh & NEM::MSH::smeshGeoMesh::getSMESHMesh ( ) const

Definition at line 149 of file smeshGeoMesh.C.

References mesh_.

149 { return *mesh_; }
std::unique_ptr< SMESH_Mesh > mesh_
Definition: smeshGeoMesh.H:64

◆ GMToSMESH()

void NEM::MSH::smeshGeoMesh::GMToSMESH ( const GeoMesh geoMesh,
SMESH_Mesh &  outMesh 
)
staticprivate

Definition at line 151 of file smeshGeoMesh.C.

References NEM::MSH::geoMeshBase::SideSet::getGeoEntArr(), NEM::MSH::geoMeshBase::SideSet::getSideSetNames(), NEM::MSH::geoMeshBase::GeoMesh::link, NEM::MSH::geoMeshBase::GeoMesh::mesh, points, NEM::MSH::geoMeshBase::SideSet::sides, and NEM::MSH::geoMeshBase::GeoMesh::sideSet.

Referenced by resetNative().

151  {
152  auto grid = geoMesh.mesh;
153  if (grid->GetNumberOfCells() == 0) { return; }
154  auto linkArr = grid->GetCellData()->GetArray(geoMesh.link.c_str());
155  auto points = grid->GetPoints();
156  auto meshDS = outMesh.GetMeshDS();
157  std::vector<SMDS_MeshNode *> smdsNodes; // indexed by geoMesh id
158  smdsNodes.reserve(points->GetNumberOfPoints());
159  {
160  std::array<double, 3> pointBuffer{};
161  for (vtkIdType i = 0; i < points->GetNumberOfPoints(); ++i) {
162  grid->GetPoint(i, pointBuffer.data());
163  smdsNodes.emplace_back(
164  meshDS->AddNode(pointBuffer[0], pointBuffer[1], pointBuffer[2]));
165  }
166  }
167  insertWithGroup(smdsNodes, meshDS, outMesh, grid, linkArr,
168  vtkStringArray::SafeDownCast(
169  grid->GetFieldData()->GetArray("Group Names")));
170  insertWithGroup(smdsNodes, meshDS, outMesh, geoMesh.sideSet.sides,
171  geoMesh.sideSet.getGeoEntArr(),
172  geoMesh.sideSet.getSideSetNames());
173 }
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 smeshGeoMesh* NEM::MSH::smeshGeoMesh::New ( )
static

◆ reconstructGeo()

void NEM::MSH::geoMeshBase::reconstructGeo ( )
virtualinherited

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

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

Definition at line 466 of file geoMeshBaseReconstructGeo.C.

References NEM::MSH::geoMeshBase::_angleThreshold, NEM::MSH::geoMeshBase::_geoMesh, NEM::MSH::geoMeshBase::GeoMesh::geo, NEM::MSH::geoMeshBase::GEO_ENT_DEFAULT_NAME, nemAux::getRandomString(), NEM::MSH::geoMeshBase::GeoMesh::link, NEM::MSH::geoMeshBase::GeoMesh::mesh, NEM::MSH::geoMeshBase::SideSet::sides, and NEM::MSH::geoMeshBase::GeoMesh::sideSet.

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

466  {
467 #ifdef HAVE_GMSH
468  if (_geoMesh.geo.empty()) {
469  _geoMesh.geo = "geoMesh_" + nemAux::getRandomString(6);
470  } else {
471  gmsh::model::setCurrent(_geoMesh.geo);
472  gmsh::model::remove();
473  }
474  gmsh::model::add(_geoMesh.geo);
475  gmsh::model::setCurrent(_geoMesh.geo);
476 #endif
477  if (_geoMesh.link.empty()) {
479  }
480  _geoMesh.sideSet = SideSet{
481  computeDiscreteGeoFromMsh(_geoMesh.mesh, _geoMesh.link, _angleThreshold)};
482  assert(_geoMesh.mesh->GetPoints() == _geoMesh.sideSet.sides->GetPoints());
483 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419
static constexpr auto GEO_ENT_DEFAULT_NAME
Definition: geoMeshBase.H:446
std::string getRandomString(int length)
vtkSmartPointer< vtkPolyData > sides
Cells represent edges/faces of some GeoMesh.
Definition: geoMeshBase.H:399
double _angleThreshold
Dihedral angle threshold (in radians) to classify surfaces (Default: 30 degrees)
Definition: geoMeshBase.H:554

◆ 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 NEM::MSH::inpGeoMesh::inpGeoMesh(), NEM::MSH::mesh_(), NEM::MSH::gmshGeoMesh::report(), NEM::MSH::vtkGeoMesh::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::smeshGeoMesh::resetNative ( )
overrideprivatevirtual

Implements NEM::MSH::geoMeshBase.

Definition at line 134 of file smeshGeoMesh.C.

References gen_, NEM::MSH::geoMeshBase::getGeoMesh(), GMToSMESH(), and mesh_.

134  {
135  // Careful! Delete mesh before deleting gen!
136  mesh_.reset();
137  gen_.reset(new SMESH_Gen{});
138  mesh_.reset(gen_->CreateMesh(false));
140 }
static void GMToSMESH(const GeoMesh &geoMesh, SMESH_Mesh &outMesh)
Definition: smeshGeoMesh.C:151
std::unique_ptr< SMESH_Mesh > mesh_
Definition: smeshGeoMesh.H:64
std::shared_ptr< SMESH_Gen > gen_
Definition: smeshGeoMesh.H:63
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

◆ setSMeshMesh()

void NEM::MSH::smeshGeoMesh::setSMeshMesh ( std::unique_ptr< SMESH_Mesh > &&  mesh,
std::shared_ptr< SMESH_Gen >  gen 
)

Definition at line 142 of file smeshGeoMesh.C.

References gen_, mesh, mesh_, NEM::MSH::geoMeshBase::setGeoMesh(), and SmeshToGM().

Referenced by NEM::SRV::NucMeshSrv::FillOutputPortInformation().

143  {
144  mesh_ = std::move(mesh);
145  gen_ = std::move(gen);
147 }
static GeoMesh SmeshToGM(SMESH_Mesh &mesh)
Definition: smeshGeoMesh.C:176
void setGeoMesh(const geoMeshBase::GeoMesh &geoMesh)
Set the underlying geometry object.
Definition: geoMeshBase.H:538
std::unique_ptr< SMESH_Mesh > mesh_
Definition: smeshGeoMesh.H:64
std::shared_ptr< SMESH_Gen > gen_
Definition: smeshGeoMesh.H:63

◆ SmeshToGM()

geoMeshBase::GeoMesh NEM::MSH::smeshGeoMesh::SmeshToGM ( SMESH_Mesh &  mesh)
staticprivate

Definition at line 176 of file smeshGeoMesh.C.

References NEM::MSH::containerWrapper(), and maxDim.

Referenced by setSMeshMesh().

176  {
177  vtkNew<vtkUnstructuredGrid> gmGrid;
178  vtkNew<vtkPolyData> sideSetSides;
179  int numGMCells;
180  int maxDim;
181  if ((numGMCells = mesh.NbVolumes()) > 0) {
182  maxDim = 3;
183  } else if ((numGMCells = mesh.NbFaces()) > 0) {
184  maxDim = 2;
185  } else if ((numGMCells = mesh.NbEdges()) > 0) {
186  maxDim = 1;
187  } else {
188  return {gmGrid, {}, {}, {}};
189  }
190  auto smeshGrid = mesh.GetMeshDS()->GetGrid();
191  gmGrid->Allocate(numGMCells);
192  gmGrid->SetPoints(smeshGrid->GetPoints());
193  sideSetSides->Allocate();
194  sideSetSides->SetPoints(smeshGrid->GetPoints());
195  vtkNew<vtkStringArray> groupNamesGrid;
196  groupNamesGrid->SetName("Group Names");
197  vtkNew<vtkStringArray> groupNamesSides;
198  // indexed by vtkID on mesh.GetMeshDS()->GetGrid()
199  std::vector<int> groups(smeshGrid->GetNumberOfCells(), -1);
200  for (auto group : NEM::MSH::containerWrapper(mesh.GetGroups())) {
201  auto groupId = group->GetID();
202  if (groupId >= 0) {
203  for (auto elem :
204  NEM::MSH::containerWrapper(group->GetGroupDS()->GetElements())) {
205  auto vtkId = elem->GetVtkID();
206  if (vtkId >= 0) {
207  auto &cellGroup = groups[vtkId];
208  if (cellGroup >= 0) {
209  // For now, the behavior is to choose the "latest" group.
210  std::cerr << "Warning! SMESH Element found on multiple groups. "
211  "Behavior is undefined.\n";
212  }
213  cellGroup = groupId;
214  }
215  }
216  auto elemType = group->GetGroupDS()->GetType();
217  auto groupDim =
218  elemType == SMDSAbs_Volume ? 3
219  : elemType == SMDSAbs_Face ? 2
220  : (elemType == SMDSAbs_Node || elemType == SMDSAbs_0DElement) ? 1
221  : -1;
222  if (groupDim == maxDim || groupDim == -1) {
223  groupNamesGrid->InsertValue(groupId, group->GetName());
224  }
225  if (groupDim == maxDim - 1 || groupDim == -1) {
226  groupNamesSides->InsertValue(groupId, group->GetName());
227  }
228  }
229  }
230  vtkNew<vtkIntArray> groupsArr;
231  groupsArr->SetName("GeoEnt");
232  groupsArr->SetNumberOfComponents(1);
233  groupsArr->SetNumberOfTuples(numGMCells);
234  groupsArr->FillComponent(0, -1);
235  vtkNew<vtkIntArray> sideSetEntArr;
236  bool geoMeshHasLink;
237  for (auto cellIter =
238  vtkSmartPointer<vtkCellIterator>::Take(smeshGrid->NewCellIterator());
239  !cellIter->IsDoneWithTraversal(); cellIter->GoToNextCell()) {
240  auto cellDim = cellIter->GetCellDimension();
241  if (cellDim == maxDim) {
242  auto gmId = gmGrid->InsertNextCell(cellIter->GetCellType(),
243  cellIter->GetPointIds());
244  auto group = groups[cellIter->GetCellId()];
245  if (group >= 0) {
246  geoMeshHasLink = true;
247  groupsArr->SetComponent(gmId, 0, group);
248  }
249  } else if (cellDim == maxDim - 1) {
250  auto group = groups[cellIter->GetCellId()];
251  if (group >= 0) {
252  sideSetSides->InsertNextCell(cellIter->GetCellType(),
253  cellIter->GetPointIds());
254  sideSetEntArr->InsertNextValue(group);
255  }
256  }
257  }
258  std::string link;
259  if (geoMeshHasLink) {
260  gmGrid->GetCellData()->AddArray(groupsArr);
261  gmGrid->GetFieldData()->AddArray(groupNamesGrid);
262  link = groupsArr->GetName();
263  }
264  return {gmGrid,
265  {},
266  std::move(link),
267  sideSetSides->GetNumberOfCells() > 0
268  ? SideSet(sideSetSides, sideSetEntArr, nullptr, nullptr,
269  groupNamesSides)
270  : SideSet{}};
271 }
int maxDim
Definition: inpGeoMesh.C:135
std::shared_ptr< meshBase > mesh
SM_StdContainerWrapperFromIter< typename std::decay< PtrSMDSIterator >::type, VALUE, EqualVALUE > containerWrapper(PtrSMDSIterator &&iter)
Definition: smeshUtils.H:57

◆ 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

◆ gen_

std::shared_ptr<SMESH_Gen> NEM::MSH::smeshGeoMesh::gen_
private

Definition at line 63 of file smeshGeoMesh.H.

Referenced by resetNative(), and setSMeshMesh().

◆ GEO_ENT_DEFAULT_NAME

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

◆ mesh_

std::unique_ptr<SMESH_Mesh> NEM::MSH::smeshGeoMesh::mesh_
private

Definition at line 64 of file smeshGeoMesh.H.

Referenced by getSMESHMesh(), resetNative(), and setSMeshMesh().


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