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::vtkGeoMesh Class Reference

A concrete implementation of geoMeshBase representing a mesh in a vtkUnstructuredGrid. More...

Detailed Description

Definition at line 42 of file vtkGeoMesh.H.

Public Member Functions

 vtkGeoMesh ()
 Create a vtkGeoMesh from a vtkUnstructuredGrid file. More...
 
 vtkGeoMesh (vtkUnstructuredGrid *inUnstructuredGrid, const std::string &phyGrpArrayName=std::string())
 Construct a vtkGeoMesh from an existing vtkUnstructuredGrid. More...
 
 ~vtkGeoMesh () override
 
void write (const std::string &fileName) override
 Write mesh to file. More...
 
void report (std::ostream &out) const override
 Print a report about the mesh. More...
 
void getVtkMesh (vtkUnstructuredGrid *dest)
 Copy the mesh. More...
 
void setVtkMesh (vtkUnstructuredGrid *vtkMesh)
 Set the vtkGeoMesh's mesh to vtkMesh. 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 vtkGeoMeshNew ()
 

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 vtk2GM (vtkUnstructuredGrid *vtkMesh, const std::string &phyGrpArrayName=std::string())
 Create a GeoMesh from a vtkUnstructuredGrid. More...
 

Inherits NEM::MSH::geoMeshBase.

Constructor & Destructor Documentation

◆ vtkGeoMesh() [1/2]

NEM::MSH::vtkGeoMesh::vtkGeoMesh ( )
Parameters
fileNamename of file
phyGrpArrayNamename of a vtkDataArray in the CellData defining the physical group of each cell
Returns
new vtkGeoMesh from file Construct a vtkGeoMesh with an empty mesh

Definition at line 99 of file vtkGeoMesh.C.

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

geoMeshBase * New(MeshType meshType)
Create a new mesh object.
vtkGeoMesh()
Create a vtkGeoMesh from a vtkUnstructuredGrid file.
Definition: vtkGeoMesh.C:99

◆ vtkGeoMesh() [2/2]

NEM::MSH::vtkGeoMesh::vtkGeoMesh ( vtkUnstructuredGrid *  inUnstructuredGrid,
const std::string &  phyGrpArrayName = std::string() 
)
explicit
Parameters
inUnstructuredGridexisting vtkUnstructuredGrid; it is used, not copied
phyGrpArrayNamename of a vtkDataArray in inUnstructuredGrid 's CellData defining the physical group of each cell

Definition at line 102 of file vtkGeoMesh.C.

104  : geoMeshBase(vtk2GM(inUnstructuredGrid, geoArrayName)) {
105  std::cout << "vtkGeoMesh constructed" << std::endl;
106 }
geoMeshBase()
Query for conversion from vtk to gmsh.
Definition: geoMeshBase.C:77
static GeoMesh vtk2GM(vtkUnstructuredGrid *vtkMesh, const std::string &phyGrpArrayName=std::string())
Create a GeoMesh from a vtkUnstructuredGrid.
Definition: vtkGeoMesh.C:143

◆ ~vtkGeoMesh()

NEM::MSH::vtkGeoMesh::~vtkGeoMesh ( )
override

Definition at line 112 of file vtkGeoMesh.C.

112 { std::cout << "vtkGeoMesh destructed" << std::endl; }

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

◆ getVtkMesh()

void NEM::MSH::vtkGeoMesh::getVtkMesh ( vtkUnstructuredGrid *  dest)
Parameters
destcopy the vtkUnstructuredGrid into dest

Definition at line 135 of file vtkGeoMesh.C.

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

135  {
136  dest->DeepCopy(getGeoMesh().mesh);
137 }
std::shared_ptr< meshBase > mesh
const GeoMesh & getGeoMesh() const
Get the underlying geometry object.
Definition: geoMeshBase.H:533

◆ 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 vtkGeoMesh* NEM::MSH::vtkGeoMesh::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::vtkGeoMesh::report ( std::ostream &  out) const
overridevirtual
Parameters
outstream

Implements NEM::MSH::geoMeshBase.

Definition at line 133 of file vtkGeoMesh.C.

References NEM::MSH::geoMeshBase::report().

133 { geoMeshBase::report(out); }
virtual void report(std::ostream &out) const =0
Print a report about the mesh.
Definition: geoMeshBase.C:97

◆ resetNative()

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

Implements NEM::MSH::geoMeshBase.

Definition at line 203 of file vtkGeoMesh.C.

203 {}

◆ 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

◆ setVtkMesh()

void NEM::MSH::vtkGeoMesh::setVtkMesh ( vtkUnstructuredGrid *  vtkMesh)
Parameters
vtkMeshexisting vtkUnstructured grid; note the pointer is used, the vtkUnstructuredGrid is not copied

Definition at line 139 of file vtkGeoMesh.C.

References NEM::MSH::geoMeshBase::setGeoMesh(), and vtk2GM().

139  {
141 }
void setGeoMesh(const geoMeshBase::GeoMesh &geoMesh)
Set the underlying geometry object.
Definition: geoMeshBase.H:538
static GeoMesh vtk2GM(vtkUnstructuredGrid *vtkMesh, const std::string &phyGrpArrayName=std::string())
Create a GeoMesh from a vtkUnstructuredGrid.
Definition: vtkGeoMesh.C:143

◆ 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

◆ vtk2GM()

geoMeshBase::GeoMesh NEM::MSH::vtkGeoMesh::vtk2GM ( vtkUnstructuredGrid *  vtkMesh,
const std::string &  phyGrpArrayName = std::string() 
)
staticprivate

Assumes gmsh has already been initialized.

Parameters
vtkMeshmesh
phyGrpArrayNamename of cell data array describing physical group of each cell
Returns
GeoMesh

Definition at line 143 of file vtkGeoMesh.C.

References nemAux::getRandomString(), NEM::MSH::GmshInterface::Initialize(), and NEM::MSH::New().

Referenced by setVtkMesh().

144  {
145  std::string gmshMesh = "vtkGeoMesh_" + nemAux::getRandomString(6);
146 #ifdef HAVE_GMSH
148  gmsh::model::add(gmshMesh);
149  gmsh::model::setCurrent(gmshMesh);
150 #endif
151 
152  if (!vtkMesh || // No mesh
153  vtkMesh->GetNumberOfPoints() == 0 || // No points
154  !vtkMesh->GetCellData()->HasArray(phyGrpArrayName.c_str()) // No geometry
155  )
156  return {vtkMesh, "", "", {}};
157 
158  { // Add geometric entities and physical groups
159  std::set<std::pair<int, int>> dim_phyGrp;
160  auto phyGrpArray = vtkArrayDownCast<vtkDataArray>(
161  vtkMesh->GetCellData()->GetArray(phyGrpArrayName.c_str()));
162  vtkSmartPointer<vtkGenericCell> vtkGC =
164 
165  // First sort
166  for (vtkIdType i = 0; i < vtkMesh->GetNumberOfCells(); ++i) {
167  vtkGC->SetCellType(vtkMesh->GetCellType(i));
168  int dim = vtkGC->GetCellDimension();
169  int phyGrp = static_cast<int>(phyGrpArray->GetComponent(i, 0));
170 
171  dim_phyGrp.insert({dim, phyGrp});
172  }
173 
174 #ifdef HAVE_GMSH
175  // then add. Each phyGrp gets its own geoEnt
176  for (const auto &dp : dim_phyGrp) {
177  gmsh::model::addDiscreteEntity(dp.first, dp.second);
178  gmsh::model::addPhysicalGroup(dp.first, {dp.second}, dp.second);
179  }
180 #endif
181  }
182 
183  /*
184  { // DEBUG
185  gmsh::vectorpair dimTags;
186  gmsh::model::getEntities(dimTags);
187  for (const auto &dimTag : dimTags) {
188  std::cout << "geoEnt dim: " << dimTag.first
189  << " tag: " << dimTag.second << std::endl;
190  }
191 
192  gmsh::model::getPhysicalGroups(dimTags);
193  for (const auto &dimTag : dimTags) {
194  std::cout << "phyGrp dim: " << dimTag.first
195  << " tag: " << dimTag.second << std::endl;
196  }
197  }
198  */
199 
200  return {vtkMesh, gmshMesh, phyGrpArrayName, {}};
201 }
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
static void Initialize()
Initialize Gmsh.
Definition: geoMeshBase.C:67
std::string getRandomString(int length)

◆ write()

void NEM::MSH::vtkGeoMesh::write ( const std::string &  fileName)
overridevirtual
Parameters
fileNamefile name

Implements NEM::MSH::geoMeshBase.

Definition at line 114 of file vtkGeoMesh.C.

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

114  {
115  auto mesh = getGeoMesh().mesh;
116 
117  std::string fileExt = nemAux::find_ext(fileName);
118  if (fileExt == ".vtk") { // Legacy type
119  vtkSmartPointer<vtkGenericDataObjectWriter> writer =
121  writer->SetFileName(fileName.c_str());
122  writer->SetInputData(mesh);
123  writer->Write();
124  } else { // XML type
125  vtkSmartPointer<vtkXMLDataSetWriter> writer =
127  writer->SetFileName(fileName.c_str());
128  writer->SetInputData(mesh);
129  writer->Write();
130  }
131 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
std::string find_ext(const std::string &fname)
std::shared_ptr< meshBase > mesh
const GeoMesh & getGeoMesh() const
Get the underlying geometry object.
Definition: geoMeshBase.H:533

Member Data Documentation

◆ GEO_ENT_DEFAULT_NAME

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

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