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

A concrete implementation of geoMeshBase representing a Omega_h::Mesh. More...

Detailed Description

Definition at line 79 of file oshGeoMesh.H.

Public Member Functions

 oshGeoMesh ()
 Create a oshGeoMesh from a file. More...
 
 oshGeoMesh (Omega_h::Mesh *oshMesh, Omega_h::Library *lib=nullptr)
 Construct a oshGeoMesh from an existing Omega_h::Mesh. More...
 
 ~oshGeoMesh () 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 takeGeoMesh (geoMeshBase *otherGeoMesh) override
 Take the GeoMesh of another geoMeshBase. More...
 
void reconstructGeo () override
 Construct the geometry from the mesh alone. More...
 
const Omega_h::Mesh & getOshMesh () const
 Get the Omega_h::Mesh. More...
 
void setOshMesh (Omega_h::Mesh *oshMesh)
 Set the mesh to an existing Omega_h::Mesh. 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 oshGeoMeshNew ()
 

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 osh2GM (Omega_h::Mesh *oshMesh, const std::string &geo="", const std::string &link="")
 
static Omega_h::Mesh * GM2osh (const GeoMesh &geoMesh, Omega_h::Library *lib=nullptr)
 

Private Attributes

std::unique_ptr< Omega_h::Mesh > _oshMesh
 

Inherits NEM::MSH::geoMeshBase.

Constructor & Destructor Documentation

◆ oshGeoMesh() [1/2]

NEM::MSH::oshGeoMesh::oshGeoMesh ( )
Parameters
fileNamename of file that Omega_h can read
liblibrary pointer; if nullptr, OmegaHInterface::GetLibrary() is used
Returns
new oshGeoMesh Construct a oshGeoMesh with an empty mesh

Definition at line 85 of file oshGeoMesh.C.

85 : oshGeoMesh(nullptr) {}
oshGeoMesh()
Create a oshGeoMesh from a file.
Definition: oshGeoMesh.C:85

◆ oshGeoMesh() [2/2]

NEM::MSH::oshGeoMesh::oshGeoMesh ( Omega_h::Mesh *  oshMesh,
Omega_h::Library *  lib = nullptr 
)
explicit
Parameters
oshMeshexisting Omega_h::Mesh; note the mesh is copied
liblibrary pointer; if nullptr, OmegaHInterface::GetLibrary() is used

Definition at line 87 of file oshGeoMesh.C.

References _oshMesh, and NEM::MSH::OmegaHInterface::GetLibrary().

88  : geoMeshBase(osh2GM(oshMesh)), _oshMesh() {
89  if (!lib) lib = OmegaHInterface::GetLibrary().get();
90  std::cout << "oshGeoMesh constructed" << std::endl;
91  _oshMesh = std::unique_ptr<Omega_h::Mesh>(
92  oshMesh ? new Omega_h::Mesh(*oshMesh) : new Omega_h::Mesh());
93  _oshMesh->set_library(lib);
94 }
static std::shared_ptr< Omega_h::Library > GetLibrary()
Initialize Omega_h.
Definition: oshGeoMesh.C:64
std::unique_ptr< Omega_h::Mesh > _oshMesh
Definition: oshGeoMesh.H:140
static GeoMesh osh2GM(Omega_h::Mesh *oshMesh, const std::string &geo="", const std::string &link="")
Definition: oshGeoMesh.C:328
geoMeshBase()
Query for conversion from vtk to gmsh.
Definition: geoMeshBase.C:77

◆ ~oshGeoMesh()

NEM::MSH::oshGeoMesh::~oshGeoMesh ( )
override

Definition at line 96 of file oshGeoMesh.C.

96 { std::cout << "oshGeoMesh 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

◆ getOshMesh()

const Omega_h::Mesh& NEM::MSH::oshGeoMesh::getOshMesh ( ) const
inline
Returns
reference to the Omega_h::Mesh

Definition at line 128 of file oshGeoMesh.H.

Referenced by NEM::SRV::omegahRefineSrv::RequestData().

128 { return *_oshMesh; }
std::unique_ptr< Omega_h::Mesh > _oshMesh
Definition: oshGeoMesh.H:140

◆ 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

◆ GM2osh()

Omega_h::Mesh * NEM::MSH::oshGeoMesh::GM2osh ( const GeoMesh geoMesh,
Omega_h::Library *  lib = nullptr 
)
staticprivate

Definition at line 635 of file oshGeoMesh.C.

References NEM::MSH::geoMeshBase::SideSet::getGeoEntArr(), NEM::MSH::OmegaHInterface::GetLibrary(), NEM::MSH::getOmega_hArrayFromVtkDataArray(), NEM::MSH::getOmega_hDimFromVTKType(), NEM::MSH::getOmega_hFamilyFromVTKType(), NEM::MSH::geoMeshBase::GeoMesh::link, NEM::MSH::geoMeshBase::GeoMesh::mesh, NEM::MSH::New(), and NEM::MSH::geoMeshBase::GeoMesh::sideSet.

Referenced by resetNative().

636  {
637  if (!lib) {
638  lib = OmegaHInterface::GetLibrary().get();
639  }
640  auto *oshMesh = new Omega_h::Mesh(lib);
641 
642  auto vtkMesh = geoMesh.mesh;
643  if (vtkMesh->GetNumberOfCells() == 0) {
644  return oshMesh;
645  }
646  auto link = geoMesh.link;
647  auto sideSet = geoMesh.sideSet;
648  vtkSmartPointer<vtkCellTypes> ct = vtkSmartPointer<vtkCellTypes>::New();
649  vtkMesh->GetCellTypes(ct);
650  if (ct->GetNumberOfTypes() != 1) {
651  std::cerr << "Error: Omega_h mesh does not support mixed meshes. Received "
652  "mesh with "
653  << ct->GetNumberOfTypes() << " different cell types."
654  << std::endl;
655  exit(1);
656  }
657  Omega_h_Family oshFamily =
658  getOmega_hFamilyFromVTKType(static_cast<VTKCellType>(ct->GetCellType(0)));
659  Omega_h::Int oshDim =
660  getOmega_hDimFromVTKType(static_cast<VTKCellType>(ct->GetCellType(0)));
661 
662  { // Add points and cells (needs both for build_from_elems_and_coords)
663  // Add points
664  Omega_h::HostWrite<Omega_h::Real> h_oshCoords(oshDim *
665  vtkMesh->GetNumberOfPoints());
666  vtkSmartPointer<vtkPoints> vtkPoints = vtkMesh->GetPoints();
667 
668  std::array<double, 3> point{};
669  for (vtkIdType i = 0; i < vtkPoints->GetNumberOfPoints(); ++i) {
670  vtkPoints->GetPoint(i, point.data());
671 
672  h_oshCoords[i * oshDim] = point[0];
673  h_oshCoords[i * oshDim + 1] = point[1];
674  if (oshDim >= 3) h_oshCoords[i * oshDim + 2] = point[2];
675  }
676 
677  Omega_h::Reals oshCoords(h_oshCoords);
678 
679  { // Add cells of dimension oshDim
680  auto it = vtkMesh->NewCellIterator();
681  auto numNodes = Omega_h::element_degree(oshFamily, oshDim, Omega_h::VERT);
682  Omega_h::HostWrite<Omega_h::LO> ev2v(numNodes *
683  vtkMesh->GetNumberOfCells());
684  int i = 0;
685  for (it->InitTraversal(); !it->IsDoneWithTraversal();
686  it->GoToNextCell()) {
687  auto ids = it->GetPointIds();
688  for (Omega_h::Int d = 0; d < numNodes; ++d) {
689  ev2v[numNodes * i + d] = ids->GetId(d);
690  }
691  ++i;
692  }
693  it->Delete();
694  Omega_h::LOs eqv2v(ev2v);
695  Omega_h::build_from_elems_and_coords(oshMesh, oshFamily, oshDim, eqv2v,
696  Omega_h::Reals(h_oshCoords));
697  if (!link.empty()) {
698  Omega_h::HostWrite<Omega_h::ClassId> h_class_id(
699  vtkMesh->GetNumberOfCells());
700  auto linkArr = vtkMesh->GetCellData()->GetArray(link.c_str());
701  if (linkArr) {
702  for (i = 0; i < h_class_id.size(); ++i) {
703  h_class_id[i] =
704  static_cast<Omega_h::ClassId>(linkArr->GetComponent(i, 0));
705  }
706  Omega_h::classify_equal_order(oshMesh, oshDim, eqv2v,
707  h_class_id.write());
708  }
709  }
710  }
711  // Add cells of dimension oshDim - 1 from the sideSet
712  if (sideSet.sides && sideSet.sides->GetNumberOfCells() > 0) {
713  auto it = sideSet.sides->NewCellIterator();
714  auto numNodes =
715  Omega_h::element_degree(oshFamily, oshDim - 1, Omega_h::VERT);
716  Omega_h::HostWrite<Omega_h::LO> ev2v(numNodes *
717  sideSet.sides->GetNumberOfCells());
718  int i = 0;
719  for (it->InitTraversal(); !it->IsDoneWithTraversal();
720  it->GoToNextCell()) {
721  auto ids = it->GetPointIds();
722  for (Omega_h::Int d = 0; d < numNodes; ++d) {
723  ev2v[numNodes * i + d] = ids->GetId(d);
724  }
725  ++i;
726  }
727  it->Delete();
728  Omega_h::LOs eqv2v(ev2v);
729  // If we have a non-empty sideSet, we should have a non-empty geo ent
730  // array
731  Omega_h::HostWrite<Omega_h::LO> h_class_id(
732  sideSet.sides->GetNumberOfCells());
733  auto geoEntArr = geoMesh.sideSet.getGeoEntArr();
734  for (i = 0; i < h_class_id.size(); ++i) {
735  h_class_id[i] = geoEntArr->GetValue(i);
736  }
737  Omega_h::classify_equal_order(oshMesh, oshDim - 1, eqv2v,
738  h_class_id.write());
739  }
740  }
741 
742  { // Add point data
743  for (int a = 0; a < vtkMesh->GetPointData()->GetNumberOfArrays(); ++a) {
744  vtkSmartPointer<vtkDataArray> da = vtkMesh->GetPointData()->GetArray(a);
745  if (da) {
746  getOmega_hArrayFromVtkDataArray(oshMesh, da, Omega_h::VERT);
747  }
748  }
749  }
750 
751  { // Add cell data
752  for (int a = 0; a < vtkMesh->GetCellData()->GetNumberOfArrays(); ++a) {
753  vtkSmartPointer<vtkDataArray> da = vtkMesh->GetCellData()->GetArray(a);
754  if (da && strcmp(da->GetName(), link.c_str()) != 0) {
755  getOmega_hArrayFromVtkDataArray(oshMesh, da, oshDim);
756  }
757  }
758  }
759  Omega_h::finalize_classification(oshMesh);
760  return oshMesh;
761 }
static std::shared_ptr< Omega_h::Library > GetLibrary()
Initialize Omega_h.
Definition: oshGeoMesh.C:64
Omega_h_Family getOmega_hFamilyFromVTKType(VTKCellType vtkCellType)
Definition: oshGeoMesh.C:217
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
void getOmega_hArrayFromVtkDataArray(Omega_h::Mesh *oshMesh, vtkSmartPointer< vtkDataArray > &vtkArray, Omega_h::Int oshDim)
Definition: oshGeoMesh.C:544
Omega_h::Int getOmega_hDimFromVTKType(VTKCellType vtkCellType)
Definition: oshGeoMesh.C:237

◆ 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 oshGeoMesh* NEM::MSH::oshGeoMesh::New ( )
static

◆ osh2GM()

geoMeshBase::GeoMesh NEM::MSH::oshGeoMesh::osh2GM ( Omega_h::Mesh *  oshMesh,
const std::string &  geo = "",
const std::string &  link = "" 
)
staticprivate

Definition at line 328 of file oshGeoMesh.C.

References NEM::MSH::geoMeshBase::GEO_ENT_DEFAULT_NAME, NEM::MSH::getVtkDataArrayFromOmega_hTag(), NEM::MSH::getVTKTypeFromOmega_hFamilyDim(), NEM::MSH::New(), nodes, NEM::MSH::oshFace2vtkFace(), and points.

Referenced by setOshMesh().

330  {
332 
333  if (!oshMesh || !oshMesh->is_valid()) return {vtkMesh, "", "", {}};
334  // Omega_h dimension is important to read its data.
335  //
336  // It stores 2D mesh without a z-coordinate while VTK always requires 3D. A
337  // "2D mesh" in VTK will have z-coordinates set to zero.
338  //
339  // Also, an Omega_h mesh contains the main element and all its lower-dimension
340  // constituents. E.g., a 3D mesh containing tetrahedrons will also contain the
341  // four triangles, six edges, and four vertices. When converting to VTK, we
342  // will only add the lower-dimensional elements if the classification of
343  // elements appears valid.
344  Omega_h::Int dim = oshMesh->dim();
345 
346  // An Omega_h mesh cannot have mixed elements. The family determines if the
347  // mesh is composed of simplices (tetrahedrons and triangles) or hypercubes
348  // (hexahedrons and quadrangles).
349  Omega_h_Family family = oshMesh->family();
350  VTKCellType vtk_type = getVTKTypeFromOmega_hFamilyDim(family, dim);
351 
352  auto linkName = link;
353  if (link.empty()) {
354  linkName = GEO_ENT_DEFAULT_NAME;
355  }
356  bool validSideSet = true;
357 
358  { // Add points
359  vtkSmartPointer<vtkPoints> points =
360  vtkSmartPointer<vtkPoints>::Take(vtkPoints::New(VTK_DOUBLE));
361  points->Allocate(oshMesh->nverts());
362  std::vector<double> nodes;
363 
364  Omega_h::HostRead<Omega_h::Real> h_coord(oshMesh->coords());
365 
366  for (Omega_h::LO i = 0; i < oshMesh->nverts(); ++i) {
367  points->InsertNextPoint(h_coord[i * dim + 0], h_coord[i * dim + 1],
368  dim == 2 ? 0 : h_coord[i * dim + 2]);
369  }
370  // Because we add them in order, the indices should be the same.
371  vtkMesh->SetPoints(points);
372  std::vector<size_t> nodeTags;
373  }
374 
375  { // Add cells
376  Omega_h::Int deg = Omega_h::element_degree(family, dim, OMEGA_H_VERT);
377  Omega_h::HostRead<Omega_h::LO> h_ev2v(oshMesh->ask_elem_verts());
378 
379  vtkMesh->Allocate(oshMesh->nelems());
380 
381  for (Omega_h::LO nelem = 0; nelem < oshMesh->nelems(); ++nelem) {
382  vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New();
383  ptIds->Allocate(deg);
384 
385  for (Omega_h::Int nvert = 0; nvert < deg; ++nvert)
386  ptIds->InsertNextId(h_ev2v[nelem * deg + nvert]);
387 
388  vtkMesh->InsertNextCell(vtk_type, ptIds);
389  }
390  }
391 
392  { // Add point data
393  for (Omega_h::Int itag = 0; itag < oshMesh->ntags(Omega_h::VERT); ++itag) {
394  vtkSmartPointer<vtkDataArray> vtkArray;
395  auto oshTagName = oshMesh->get_tag(Omega_h::VERT, itag)->name();
396  if (oshTagName != "class_dim" && oshTagName != "class_id" &&
397  oshTagName != "coordinates" && oshTagName != "global" &&
398  oshTagName != "local") {
399  getVtkDataArrayFromOmega_hTag(oshMesh->get_tag(Omega_h::VERT, itag),
400  vtkArray);
401  }
402 
403  vtkMesh->GetPointData()->AddArray(vtkArray);
404  }
405  }
406 
407  { // Add cell data
408  for (Omega_h::Int itag = 0; itag < oshMesh->ntags(dim); ++itag) {
409  vtkSmartPointer<vtkDataArray> vtkArray;
410  auto oshTagName = oshMesh->get_tag(dim, itag)->name();
411  if (oshTagName != "class_dim" && oshTagName != "class_id" &&
412  oshTagName != "global" && oshTagName != "local") {
413  getVtkDataArrayFromOmega_hTag(oshMesh->get_tag(dim, itag), vtkArray);
414  vtkMesh->GetCellData()->AddArray(vtkArray);
415  }
416  }
417  }
418 
419  // Add boundary elements (of one lower dimension), if they exist, so we don't
420  // have to reconstruct geometry.
421  auto sideSetPD = vtkSmartPointer<vtkPolyData>::New();
422  sideSetPD->SetPoints(vtkMesh->GetPoints());
423  sideSetPD->Allocate();
424  auto sideSetEntities = vtkSmartPointer<vtkIntArray>::New();
425  auto sideSetOrigCellId = vtkSmartPointer<vtkIdTypeArray>::New();
426  sideSetOrigCellId->SetNumberOfComponents(2);
427  auto sideSetCellFaceId = vtkSmartPointer<vtkIntArray>::New();
428  sideSetCellFaceId->SetNumberOfComponents(2);
429  // Map from highest dimensional entities to bounding entities of one lower
430  // dimension (by "class_id").
431  std::map<Omega_h::ClassId, std::set<Omega_h::ClassId>> entities;
432  // List of bounding entities of one lower dimension (by "class_id").
433  std::vector<Omega_h::ClassId> entities_boundary;
434  Omega_h::HostRead<Omega_h::ClassId> arr_id;
435  { // Add all entities of max dimension
436  if (oshMesh->has_tag(dim, "class_id")) {
437  arr_id = oshMesh->get_array<Omega_h::ClassId>(dim, "class_id");
438  } else {
439  validSideSet = false;
440  }
441  }
442  // Find boundary elements of dimension dim - 1. Also recover the bounding
443  // entities (of dimension dim - 1) for the entities of highest dimension
444  if (validSideSet && oshMesh->has_tag(dim - 1, "class_id") &&
445  oshMesh->has_tag(dim - 1, "class_dim")) {
446  Omega_h::HostRead<Omega_h::ClassId> arr_id_boundary =
447  oshMesh->get_array<Omega_h::ClassId>(dim - 1, "class_id");
448  Omega_h::HostRead<Omega_h::I8> arr_dim =
449  oshMesh->get_array<Omega_h::I8>(dim - 1, "class_dim");
450  auto parent = oshMesh->ask_up(dim - 1, dim);
451  Omega_h::HostRead<Omega_h::LO> parent_a2ab = parent.a2ab;
452  Omega_h::HostRead<Omega_h::LO> parent_ab2b = parent.ab2b;
453  Omega_h::HostRead<Omega_h::I8> parent_codes = parent.codes;
454  for (Omega_h::LO i = 0; i < arr_dim.size(); ++i) {
455  if (arr_dim[i] == dim - 1) {
456  bool newEntityBoundary = false;
457  auto oshEntity = arr_id_boundary[i];
458  auto entityIter = std::find(entities_boundary.begin(),
459  entities_boundary.end(), oshEntity);
460  if (entityIter == entities_boundary.end()) {
461  entities_boundary.emplace_back(oshEntity);
462  newEntityBoundary = true;
463  }
464  std::array<vtkIdType, 2> origCell{-1, -1};
465  std::array<int, 2> cellFace{-1, -1};
466  Omega_h::ClassId firstParentEnt = -1;
467  for (int j = 0; j < parent_a2ab[i + 1] - parent_a2ab[i]; ++j) {
468  auto ab = parent_ab2b[i + j];
469  auto b = parent_ab2b[ab];
470  if (j == 0) {
471  firstParentEnt = arr_id[b];
472  }
473  if (newEntityBoundary) {
474  entities[arr_id[b]].emplace(oshEntity);
475  }
476  auto code = parent_codes[ab];
477  auto oshFace = Omega_h::code_which_down(code);
478  if (j == 0 || (j == 1 && arr_id[b] < firstParentEnt)) {
479  origCell[1] = origCell[0];
480  cellFace[1] = cellFace[0];
481  origCell[0] = b;
482  cellFace[0] = oshFace2vtkFace(oshFace, family, dim);
483  } else {
484  origCell[1] = b;
485  cellFace[1] = oshFace2vtkFace(oshFace, family, dim);
486  }
487  }
488  auto side = dim == 2
489  ? vtkMesh->GetCell(origCell[0])->GetEdge(cellFace[0])
490  : vtkMesh->GetCell(origCell[0])->GetFace(cellFace[0]);
491  sideSetPD->InsertNextCell(side->GetCellType(), side->GetPointIds());
492  sideSetOrigCellId->InsertNextTypedTuple(origCell.data());
493  sideSetCellFaceId->InsertNextTypedTuple(cellFace.data());
494  sideSetEntities->InsertNextValue(oshEntity);
495  }
496  }
497  Omega_h::HostRead<Omega_h::LO> point_id = oshMesh->ask_verts_of(dim - 1);
498  // It might be more efficient to get the underlying array pointer
499  // and use std::copy.
500  auto vtkEntities = vtkSmartPointer<vtkIntArray>::New();
501  vtkEntities->SetName(linkName.c_str());
502  vtkEntities->SetNumberOfValues(vtkMesh->GetNumberOfCells());
503  for (vtkIdType i = 0; i < vtkMesh->GetNumberOfCells(); ++i) {
504  // The physical group name matches the class_id
505  vtkEntities->SetValue(i, arr_id[i]);
506  }
507  vtkMesh->GetCellData()->AddArray(vtkEntities);
508  return {vtkMesh,
509  {},
510  linkName,
511  {sideSetPD, sideSetEntities, sideSetOrigCellId, sideSetCellFaceId}};
512  } else {
513  return {vtkMesh, {}, "", {}};
514  }
515 }
int oshFace2vtkFace(int oshFace, Omega_h_Family oshFamily, Omega_h::Int oshDim)
Definition: oshGeoMesh.C:306
std::vector< std::pair< vtkIdType, std::vector< double > > > nodes
Each entry stores (node ID in .inp file, coordinates)
Definition: inpGeoMesh.C:139
static constexpr auto GEO_ENT_DEFAULT_NAME
Definition: geoMeshBase.H:446
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
void getVtkDataArrayFromOmega_hTag(const Omega_h::TagBase *tagBase, vtkSmartPointer< vtkDataArray > &vtkArray)
Definition: oshGeoMesh.C:272
VTKCellType getVTKTypeFromOmega_hFamilyDim(Omega_h_Family family, Omega_h::Int dim)
Definition: oshGeoMesh.C:201
std::vector< vtkIdType > points
points given by id in .inp file
Definition: inpGeoMesh.C:133

◆ reconstructGeo()

void NEM::MSH::oshGeoMesh::reconstructGeo ( )
overridevirtual

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

Reimplemented from NEM::MSH::geoMeshBase.

Definition at line 136 of file oshGeoMesh.C.

References _oshMesh, NEM::MSH::geoMeshBase::getGeoMesh(), NEM::MSH::geoMeshBase::GeoMesh::link, mesh, NEM::MSH::geoMeshBase::GeoMesh::mesh, NEM::MSH::geoMeshBase::reconstructGeo(), and NEM::MSH::geoMeshBase::GeoMesh::sideSet.

136  {
138  auto mesh = getGeoMesh().mesh;
139  auto link = getGeoMesh().link;
140  auto sideSet = getGeoMesh().sideSet;
141  auto oshFamily = _oshMesh->family();
142  auto oshDim = _oshMesh->dim();
143  if (sideSet.sides && sideSet.sides->GetNumberOfCells() > 0) {
144  for (int i = 0; i <= oshDim; ++i) {
145  if (_oshMesh->has_tag(i, "class_dim")) {
146  _oshMesh->remove_tag(i, "class_dim");
147  }
148  if (_oshMesh->has_tag(i, "class_id")) {
149  _oshMesh->remove_tag(i, "class_id");
150  }
151  }
152  { // Set class_dim and class_id for dimension oshDim
153  Omega_h::HostWrite<Omega_h::ClassId> h_class_id(mesh->GetNumberOfCells());
154  auto linkArr = mesh->GetCellData()->GetArray(link.c_str());
155  if (linkArr) {
156  for (Omega_h::LO i = 0; i < h_class_id.size(); ++i) {
157  h_class_id[i] =
158  static_cast<Omega_h::ClassId>(linkArr->GetComponent(i, 0));
159  }
160  // Note we pass dummy because classify_equal_order just assumes that
161  // we pass in h_class_id in same order that we create cells.
162  // This is fine because reconstructGeo doesn't change the mesh.
163  auto dummyEqv2v = Omega_h::LOs(
164  mesh->GetNumberOfCells() *
165  Omega_h::element_degree(oshFamily, oshDim, Omega_h::VERT),
166  0);
167  Omega_h::classify_equal_order(_oshMesh.get(), oshDim, dummyEqv2v,
168  h_class_id.write());
169  }
170  }
171  { // Set class_dim and class_id for dimension oshDim - 1
172  auto it = vtkSmartPointer<vtkCellIterator>::Take(
173  sideSet.sides->NewCellIterator());
174  auto numNodes =
175  Omega_h::element_degree(oshFamily, oshDim - 1, Omega_h::VERT);
176  Omega_h::HostWrite<Omega_h::LO> ev2v(numNodes *
177  sideSet.sides->GetNumberOfCells());
178  for (int i = (it->InitTraversal(), 0); !it->IsDoneWithTraversal();
179  it->GoToNextCell(), ++i) {
180  auto ids = it->GetPointIds();
181  for (Omega_h::Int d = 0; d < numNodes; ++d) {
182  ev2v[numNodes * i + d] = ids->GetId(d);
183  }
184  }
185  Omega_h::LOs eqv2v(ev2v);
186  // If we have a non-empty sideSet, we should have a non-empty geo ent
187  // array
188  Omega_h::HostWrite<Omega_h::LO> h_class_id(
189  sideSet.sides->GetNumberOfCells());
190  auto geoEntArr = sideSet.getGeoEntArr();
191  for (Omega_h::LO i = 0; i < h_class_id.size(); ++i) {
192  h_class_id[i] = geoEntArr->GetValue(i);
193  }
194  Omega_h::classify_equal_order(_oshMesh.get(), oshDim - 1, eqv2v,
195  h_class_id.write());
196  }
197  }
198  Omega_h::finalize_classification(_oshMesh.get());
199 }
vtkSmartPointer< vtkUnstructuredGrid > mesh
Definition: geoMeshBase.H:419
std::unique_ptr< Omega_h::Mesh > _oshMesh
Definition: oshGeoMesh.H:140
virtual void reconstructGeo()
Construct the geometry from the mesh alone.
std::shared_ptr< meshBase > mesh
const GeoMesh & getGeoMesh() const
Get the underlying geometry object.
Definition: geoMeshBase.H:533

◆ report()

void NEM::MSH::oshGeoMesh::report ( std::ostream &  out) const
overridevirtual
Parameters
outstream

Implements NEM::MSH::geoMeshBase.

Definition at line 115 of file oshGeoMesh.C.

References _oshMesh, and NEM::MSH::geoMeshBase::report().

115  {
116  geoMeshBase::report(out);
117  out << "Family:\t"
118  << (_oshMesh->family() == OMEGA_H_SIMPLEX ? "SIMPLEX" : "HYPERCUBE")
119  << '\n';
120  out << "Dim:\t" << _oshMesh->dim() << '\n';
121 }
virtual void report(std::ostream &out) const =0
Print a report about the mesh.
Definition: geoMeshBase.C:97
std::unique_ptr< Omega_h::Mesh > _oshMesh
Definition: oshGeoMesh.H:140

◆ resetNative()

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

Implements NEM::MSH::geoMeshBase.

Definition at line 768 of file oshGeoMesh.C.

References _oshMesh, NEM::MSH::geoMeshBase::getGeoMesh(), and GM2osh().

768  {
769  _oshMesh = std::unique_ptr<Omega_h::Mesh>(GM2osh(getGeoMesh()));
770 }
std::unique_ptr< Omega_h::Mesh > _oshMesh
Definition: oshGeoMesh.H:140
static Omega_h::Mesh * GM2osh(const GeoMesh &geoMesh, Omega_h::Library *lib=nullptr)
Definition: oshGeoMesh.C:635
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

◆ setOshMesh()

void NEM::MSH::oshGeoMesh::setOshMesh ( Omega_h::Mesh *  oshMesh)
Parameters
oshMeshan existing Omega_h::Mesh; note the mesh is actually copied

Definition at line 763 of file oshGeoMesh.C.

References _oshMesh, NEM::MSH::geoMeshBase::getGeoMesh(), osh2GM(), and NEM::MSH::geoMeshBase::setGeoMesh().

763  {
764  this->setGeoMesh(osh2GM(oshMesh, getGeoMesh().geo, getGeoMesh().link));
765  _oshMesh = std::unique_ptr<Omega_h::Mesh>(new Omega_h::Mesh(*oshMesh));
766 }
std::unique_ptr< Omega_h::Mesh > _oshMesh
Definition: oshGeoMesh.H:140
static GeoMesh osh2GM(Omega_h::Mesh *oshMesh, const std::string &geo="", const std::string &link="")
Definition: oshGeoMesh.C:328
void setGeoMesh(const geoMeshBase::GeoMesh &geoMesh)
Set the underlying geometry object.
Definition: geoMeshBase.H:538
const GeoMesh & getGeoMesh() const
Get the underlying geometry object.
Definition: geoMeshBase.H:533

◆ 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::oshGeoMesh::takeGeoMesh ( geoMeshBase otherGeoMesh)
overridevirtual

Note that otherGeoMesh will be left with an empty mesh.

Parameters
otherGeoMeshother geoMeshBase object; mesh will be left empty

Reimplemented from NEM::MSH::geoMeshBase.

Definition at line 123 of file oshGeoMesh.C.

References _oshMesh, NEM::MSH::New(), NEM::MSH::geoMeshBase::setGeoMesh(), and NEM::MSH::geoMeshBase::takeGeoMesh().

123  {
124  auto otherOshGM = dynamic_cast<oshGeoMesh *>(otherGeoMesh);
125  if (otherOshGM) {
126  setGeoMesh(otherOshGM->getGeoMesh());
127  otherOshGM->setGeoMesh(
129  _oshMesh = std::move(otherOshGM->_oshMesh);
130  otherOshGM->resetNative();
131  } else {
132  geoMeshBase::takeGeoMesh(otherGeoMesh);
133  }
134 }
std::unique_ptr< Omega_h::Mesh > _oshMesh
Definition: oshGeoMesh.H:140
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
void setGeoMesh(const geoMeshBase::GeoMesh &geoMesh)
Set the underlying geometry object.
Definition: geoMeshBase.H:538
oshGeoMesh()
Create a oshGeoMesh from a file.
Definition: oshGeoMesh.C:85
virtual void takeGeoMesh(geoMeshBase *otherGeoMesh)
Take the GeoMesh of another geoMeshBase.
Definition: geoMeshBase.C:104

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

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

Implements NEM::MSH::geoMeshBase.

Definition at line 98 of file oshGeoMesh.C.

References _oshMesh, and nemAux::find_ext().

98  {
99  std::string fileExt = nemAux::find_ext(fileName);
100 
101  if (fileExt == ".osh") {
102  Omega_h::binary::write(fileName, _oshMesh.get());
103  } else if (fileExt == ".msh") {
104  Omega_h::gmsh::write(fileName, _oshMesh.get());
105  } else if (fileExt == ".pvtu") {
106  Omega_h::vtk::write_parallel(fileName, _oshMesh.get());
107  } else if (fileExt == ".vtu") {
108  Omega_h::vtk::write_vtu(fileName, _oshMesh.get());
109  } else {
110  std::cerr << "Omega_h library does not support writing " << fileExt
111  << " format." << std::endl;
112  }
113 }
std::unique_ptr< Omega_h::Mesh > _oshMesh
Definition: oshGeoMesh.H:140
std::string find_ext(const std::string &fname)

Member Data Documentation

◆ _oshMesh

std::unique_ptr<Omega_h::Mesh> NEM::MSH::oshGeoMesh::_oshMesh
private

◆ 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: