29 #ifndef NEMOSYS_GEOMESHBASE_H_ 30 #define NEMOSYS_GEOMESHBASE_H_ 32 #include "nemosys_export.h" 40 #include <vtkAbstractArray.h> 41 #include <vtkCellData.h> 42 #include <vtkCellType.h> 43 #include <vtkDataObject.h> 44 #include <vtkFieldData.h> 45 #include <vtkGenericCell.h> 46 #include <vtkIdList.h> 47 #include <vtkPointData.h> 48 #include <vtkPolyData.h> 49 #include <vtkSmartPointer.h> 50 #include <vtkStringArray.h> 51 #include <vtkUnstructuredGrid.h> 81 static void Initialize();
85 static void Finalize();
91 static std::shared_ptr<GmshInterface>
instance;
111 static int getGmshTypeFromVTKType(
int vtkType);
123 virtual void write(
const std::string &fileName) = 0;
128 virtual void report(std::ostream &out)
const = 0;
138 virtual void takeGeoMesh(
geoMeshBase *otherGeoMesh);
143 virtual void reconstructGeo();
150 virtual void mergeGeoMesh(
geoMeshBase *otherGeoMesh);
163 auto a = _geoMesh.mesh->GetCellData()->GetArray(_geoMesh.link.c_str());
164 if (a) a->SetName(geoEntArrayName.c_str());
165 _geoMesh.link = geoEntArrayName;
177 _angleThreshold = angleThreshold;
184 return _geoMesh.mesh->GetNumberOfPoints();
197 _geoMesh.mesh->GetPoint(
id, x->data());
205 std::array<double, 3> x{};
215 _geoMesh.mesh->GetCell(cellId, cell);
223 return _geoMesh.mesh->GetCell(cellId);
231 _geoMesh.mesh->GetCellBounds(cellId, bounds->data());
239 std::array<double, 6> bounds{};
240 getCellBounds(cellId, &bounds);
249 return static_cast<VTKCellType
>(_geoMesh.mesh->GetCellType(cellId));
257 _geoMesh.mesh->GetCellPoints(cellId, ptIds);
265 _geoMesh.mesh->GetPointCells(ptId, cellIds);
274 vtkIdList *cellIds)
const {
275 _geoMesh.mesh->GetCellNeighbors(cellId, ptIds, cellIds);
282 return _geoMesh.mesh->GetPointData()->GetNumberOfArrays();
290 void getPointDataArrayCopy(
const std::string &arrayName,
291 vtkAbstractArray *array,
292 int *arrayIdx =
nullptr)
const;
300 vtkSmartPointer<vtkAbstractArray> getPointDataArrayCopy(
301 const std::string &arrayName,
int *arrayIdx =
nullptr)
const;
307 void getPointDataArrayCopy(
int arrayIdx, vtkAbstractArray *array)
const;
313 vtkSmartPointer<vtkAbstractArray> getPointDataArrayCopy(
int arrayIdx)
const;
319 return _geoMesh.mesh->GetCellData()->GetNumberOfArrays();
327 void getCellDataArrayCopy(
const std::string &arrayName,
328 vtkAbstractArray *array,
329 int *arrayIdx =
nullptr)
const;
337 vtkSmartPointer<vtkAbstractArray> getCellDataArrayCopy(
338 const std::string &arrayName,
int *arrayIdx =
nullptr)
const;
344 void getCellDataArrayCopy(
int arrayIdx, vtkAbstractArray *array)
const;
350 vtkSmartPointer<vtkAbstractArray> getCellDataArrayCopy(
int arrayIdx)
const;
356 return _geoMesh.mesh->GetFieldData()->GetNumberOfArrays();
364 void getFieldDataArrayCopy(
const std::string &arrayName,
365 vtkAbstractArray *array,
366 int *arrayIdx =
nullptr)
const;
374 vtkSmartPointer<vtkAbstractArray> getFieldDataArrayCopy(
375 const std::string &arrayName,
int *arrayIdx =
nullptr)
const;
381 void getFieldDataArrayCopy(
int arrayIdx, vtkAbstractArray *array)
const;
387 vtkSmartPointer<vtkAbstractArray> getFieldDataArrayCopy(
int arrayIdx)
const;
391 SideSet(vtkPolyData *sideSet, vtkIntArray *geoEnt,
392 vtkIdTypeArray *origCell =
nullptr, vtkIntArray *cellFace =
nullptr,
393 vtkStringArray *setNames =
nullptr);
395 explicit SideSet(vtkPolyData *
sides);
399 vtkSmartPointer<vtkPolyData> sides{
nullptr};
401 vtkSmartPointer<vtkIntArray> getGeoEntArr()
const;
402 void setGeoEntArr(vtkIntArray *arr);
403 vtkSmartPointer<vtkIdTypeArray> getOrigCellArr()
const;
404 void setOrigCellArr(vtkIdTypeArray *arr);
405 vtkSmartPointer<vtkIntArray> getCellFaceArr()
const;
406 void setCellFaceArr(vtkIntArray *arr);
407 vtkSmartPointer<vtkStringArray> getSideSetNames()
const;
408 void setSideSetNamesArr(vtkStringArray *arr);
411 static constexpr
auto GEO_ENT_NAME =
"GeoEnt";
413 static constexpr
auto ORIG_CELL_NAME =
"OrigCellIds";
414 static constexpr
auto CELL_FACE_NAME =
"CellFaceIds";
415 static constexpr
auto NAME_ARR_NAME =
"Side Set Names";
419 vtkSmartPointer<vtkUnstructuredGrid>
mesh;
437 void findSide2OrigCell();
443 int getDimension()
const;
446 static constexpr
auto GEO_ENT_DEFAULT_NAME =
"GeoEnt";
466 return _geoMesh.mesh->GetPointData()->AddArray(array);
474 return _geoMesh.mesh->GetCellData()->AddArray(array);
482 return _geoMesh.mesh->GetFieldData()->AddArray(array);
490 _geoMesh.mesh->GetPointData()->RemoveArray(arrayIdx);
497 _geoMesh.mesh->GetPointData()->RemoveArray(arrayName.c_str());
504 _geoMesh.mesh->GetCellData()->RemoveArray(arrayIdx);
511 _geoMesh.mesh->GetCellData()->RemoveArray(arrayName.c_str());
518 _geoMesh.mesh->GetFieldData()->RemoveArray(arrayIdx);
525 _geoMesh.mesh->GetFieldData()->RemoveArray(arrayName.c_str());
539 assert(geoMesh.
mesh->GetNumberOfCells() == 0 ||
540 geoMesh.
mesh->GetNumberOfPoints() == 0 ||
547 virtual void resetNative() = 0;
560 #endif // NEMOSYS_GEOMESHBASE_H_ VTKCellType getCellType(nemId_t cellId) const
Get VTK cell type.
virtual void report(std::ostream &out) const =0
Print a report about the mesh.
int getNumberOfCellDataArrays() const
Get number of arrays in the cell data.
void getPoint(nemId_t id, std::array< double, 3 > *x) const
Get the coordinate of a point.
int setPointDataArray(vtkAbstractArray *array)
Set point data.
void unsetFieldDataArray(int arrayIdx)
Remove field data array by index.
vtkSmartPointer< vtkUnstructuredGrid > mesh
void getCellNeighbors(nemId_t cellId, vtkIdList *ptIds, vtkIdList *cellIds) const
Get list of cells sharing points ptIds excluding cellId.
void unsetPointDataArray(const std::string &arrayName)
Remove point data array by name.
void unsetCellDataArray(const std::string &arrayName)
Remove cell data array by name.
nemId_t getNumberOfCells() const
Get the number of cells in mesh.
void setGeoMesh(const geoMeshBase::GeoMesh &geoMesh)
Set the underlying geometry object.
void getCellPoints(nemId_t cellId, vtkIdList *ptIds) const
Get list of point ids defining specified cell.
void unsetCellDataArray(int arrayIdx)
Remove cell data array by index.
vtkCell * getCell(nemId_t cellId) const
Get cell.
friend std::ostream & operator<<(std::ostream &os, const geoMeshBase &base)
std::array< double, 3 > getPoint(nemId_t id) const
Get the coordinate of a point.
double getAngleThreshold() const
Get the angle threshold used for surface classification.
std::array< double, 6 > getCellBounds(nemId_t cellId) const
Get cell bounds.
void getPointCells(nemId_t ptId, vtkIdList *cellIds) const
Get list of cell ids using specified point.
void unsetFieldDataArray(const std::string &arrayName)
Remove field data array by name.
vtkSmartPointer< vtkPolyData > sides
Cells represent edges/faces of some GeoMesh.
std::array< int, 2 > sides
nemId_t getNumberOfPoints() const
Get the number of points in mesh.
void setAngleThreshold(double angleThreshold)
Set the angle threshold used for surface classification.
const std::string & getGeoEntArrayName() const
Get the name of the geometric entities array.
management class for Gmsh interface
double _angleThreshold
Dihedral angle threshold (in radians) to classify surfaces (Default: 30 degrees)
int setCellDataArray(vtkAbstractArray *array)
Set cell data.
void setGeoEntArrayName(const std::string &geoEntArrayName)
Set the name of the geometric entities array.
void unsetPointDataArray(int arrayIdx)
Remove point data array by index.
static std::shared_ptr< GmshInterface > instance
int getNumberOfFieldDataArrays() const
Get number of arrays in the field data.
void getCellBounds(nemId_t cellId, std::array< double, 6 > *bounds) const
Get cell bounds.
abstract class to specify geometry and mesh data
int setFieldDataArray(vtkAbstractArray *array)
Set field data.
void getCell(nemId_t cellId, vtkGenericCell *cell) const
Get cell.
int getNumberOfPointDataArrays() const
Get number of arrays in the point data.
const GeoMesh & getGeoMesh() const
Get the underlying geometry object.