29 #ifndef NEMOSYS_MESHBASE_H_ 30 #define NEMOSYS_MESHBASE_H_ 38 #include <vtkCellLocator.h> 39 #include <vtkDataSet.h> 40 #include <vtkDataSetTriangleFilter.h> 41 #include <vtkIdList.h> 42 #include <vtkIdTypeArray.h> 43 #include <vtkModelMetadata.h> 44 #include <vtkSmartPointer.h> 45 #include <vtkStaticCellLocator.h> 46 #include <vtkStaticPointLocator.h> 47 #include <vtkUnstructuredGrid.h> 49 #include "nemosys_export.h" 74 std::cout <<
"meshBase constructed" << std::endl;
95 virtual ~meshBase() { std::cout <<
"meshBase destroyed" << std::endl; }
103 static meshBase *Create(
const std::string &fname);
111 static meshBase *Create(vtkSmartPointer<vtkDataSet> other,
112 const std::string &newname);
124 static meshBase *Create(
const std::vector<double> &xCrds,
125 const std::vector<double> &yCrds,
126 const std::vector<double> &zCrds,
127 const std::vector<nemId_t> &elmConn,
128 const int cellType,
const std::string &newname);
134 static std::shared_ptr<meshBase> CreateShared(
const std::string &fname);
140 static std::shared_ptr<meshBase> CreateShared(
meshBase *
mesh);
148 static std::shared_ptr<meshBase> CreateShared(
149 vtkSmartPointer<vtkDataSet> other,
const std::string &newname);
162 static std::shared_ptr<meshBase> CreateShared(
163 const std::vector<double> &xCrds,
const std::vector<double> &yCrds,
164 const std::vector<double> &zCrds,
const std::vector<nemId_t> &elmConn,
165 int cellType,
const std::string &newname);
171 static std::unique_ptr<meshBase> CreateUnique(
const std::string &fname);
184 static std::unique_ptr<meshBase> CreateUnique(
185 const std::vector<double> &xCrds,
const std::vector<double> &yCrds,
186 const std::vector<double> &zCrds,
const std::vector<nemId_t> &elmConn,
187 int cellType,
const std::string &newname);
193 static std::unique_ptr<meshBase> CreateUnique(
194 vtkSmartPointer<vtkDataSet> other,
const std::string &newname);
199 static std::unique_ptr<meshBase> CreateUnique(
meshBase *mesh);
205 static meshBase *exportGmshToVtk(
const std::string &fname);
211 static meshBase *exportVolToVtk(
const std::string &fname);
217 static meshBase *exportPntToVtk(
const std::string &fname);
223 static meshBase *exportExoToVtk(
const std::string &fname);
235 static meshBase *stitchMB(
const std::vector<meshBase *> &mbObjs);
241 static std::shared_ptr<meshBase> stitchMB(
242 const std::vector<std::shared_ptr<meshBase>> &_mbObjs);
249 static std::vector<std::shared_ptr<meshBase>> partition(
const meshBase *mbObj,
259 const std::vector<nemId_t> &cellIds);
266 static meshBase *extractSelectedCells(
267 vtkSmartPointer<vtkDataSet> mesh,
268 vtkSmartPointer<vtkIdTypeArray> cellIds);
275 virtual void read(
const std::string &fname) = 0;
281 virtual std::vector<double> getPoint(
nemId_t id)
const = 0;
286 virtual std::vector<std::vector<double>> getVertCrds()
const = 0;
292 virtual std::map<nemId_t, std::vector<double>> getCell(
nemId_t id)
const = 0;
298 virtual std::vector<std::vector<double>> getCellVec(
nemId_t id)
const = 0;
303 virtual void inspectEdges(
const std::string &ofname)
const = 0;
308 vtkSmartPointer<vtkDataSet>
getDataSet()
const {
return dataSet; }
313 virtual vtkSmartPointer<vtkDataSet> extractSurface() = 0;
320 const std::vector<std::vector<double>> &
data) {
328 const std::vector<double> &
data) {}
335 const std::vector<std::vector<double>> &
data) {}
342 const std::vector<double> &
data) {}
350 std::vector<double> &
data) {}
370 std::vector<double> &
data) {}
406 virtual std::vector<double> getCellLengths()
const = 0;
412 virtual std::vector<double> getCellCenter(
nemId_t cellID)
const = 0;
417 vtkSmartPointer<vtkStaticCellLocator> buildStaticCellLocator();
422 vtkSmartPointer<vtkStaticPointLocator> buildStaticPointLocator();
428 virtual int getCellType()
const = 0;
438 virtual std::vector<nemId_t> getConnectivities()
const = 0;
441 metadata = _metadata;
443 vtkSmartPointer<vtkModelMetadata>
getMetadata() {
return metadata; }
451 std::vector<std::vector<double>> integrateOverMesh(
452 const std::vector<int> &arrayIDs);
464 void generateSizeField(
const std::string &method,
int arrayID,
double dev_mlt,
465 bool maxIsmin,
double sizeFactor = 1.0,
int order = 1);
472 int IsArrayName(
const std::string &name,
bool pointOrCell =
false)
const;
486 void refineMesh(
const std::string &method,
int arrayID,
double dev_mult,
487 bool maxIsmin,
double edge_scale,
const std::string &ofname,
488 bool transferData,
double sizeFactor = 1.,
489 bool constrainBoundary =
false);
501 void refineMesh(
const std::string &method,
const std::string &arrayName,
502 double dev_mult,
bool maxIsmin,
double edge_scale,
503 const std::string &ofname,
bool transferData,
504 double sizeFactor = 1.);
512 void refineMesh(
const std::string &method,
double edge_scale,
513 const std::string &ofname,
bool transferData,
514 bool constrainBoundary =
false);
523 void refineMesh(
const std::string &method,
int arrayID,
int order,
524 const std::string &ofname,
bool transferData);
533 void refineMesh(
const std::string &method,
const std::string &arrayName,
534 int order,
const std::string &ofname,
bool transferData);
555 void checkMesh(
const std::string &ofname)
const;
603 virtual void write(
const std::string &fname)
const = 0;
608 void writeMSH(std::ofstream &outputStream);
613 void writeMSH(
const std::string &fname);
620 void writeMSH(std::ofstream &outputStream,
const std::string &pointOrCell,
628 void writeMSH(
const std::string &fname,
const std::string &pointOrCell,
638 void writeMSH(std::ofstream &outputStream,
const std::string &pointOrCell,
649 void writeMSH(
const std::string &fname,
const std::string &pointOrCell,
650 int arrayID,
bool onlyVol);
657 void writeCobalt(
meshBase *surfWithPatch,
const std::string &mapFile,
658 std::ofstream &outputStream);
665 void writeCobalt(
meshBase *surfWithPatch,
const std::string &mapFile,
666 const std::string &ofname);
702 std::vector<int> getArrayIDs(std::vector<std::string> arrayNames,
703 bool fromPointArrays =
false);
709 void convertHexToTetVTK(vtkSmartPointer<vtkDataSet> meshdataSet);
769 bool operator()(std::vector<nemId_t> lhs, std::vector<nemId_t> rhs)
const;
783 NEMOSYS_EXPORT
void writePatchMap(
const std::string &mapFile,
784 const std::map<int, int> &patchMap);
790 NEMOSYS_EXPORT
void writePatchMap(std::ofstream &outputStream,
791 const std::map<int, int> &patchMap);
793 #endif // NEMOSYS_MESHBASE_H_ virtual void unsetCellDataArray(const std::string &name)
<>
std::vector< std::map< nemId_t, nemId_t > > partToGlobCellMap
std::map< nemId_t, nemId_t > globToPartCellMap
map between global and local cell idx in partition
data_type data
Edge/face with sorted point ids (a, b, c, ...) is located at some index i in data[b], with data[b][i].first == [a, c] (for edges, third point id treated as -1).
nemId_t numPoints
number of points in mesh
virtual void setCellDataArray(const std::string &name, const std::vector< double > &data)
register data to dataSet's cell data
std::map< nemId_t, nemId_t > getGlobToPartCellMap()
global to local mapping of cells
void setContBool(bool x)
set weighted averaging/smoothing for cell data transfer (default is off)
bool checkQuality
check transfer quality when on
void setFileName(const std::string &fname)
set the file name.
virtual void getPointDataArray(const std::string &name, std::vector< double > &data)
get scalar point or cell data array.
virtual void setPointDataArray(const std::string &name, const std::vector< std::vector< double >> &data)
register data to dataSet's point data
std::vector< std::map< nemId_t, nemId_t > > globToPartCellMap
vtkSmartPointer< vtkDataSet > dataSet
mesh points, topology and data
std::vector< std::map< nemId_t, nemId_t > > partToGlobNodeMap
A brief description of meshBase.
virtual void setCellDataArray(const std::string &name, const std::vector< std::vector< double >> &data)
register data to dataSet's cell data
virtual void setPointDataArray(const std::string &name, const std::vector< double > &data)
register data to dataSet's point data
std::map< nemId_t, nemId_t > getPartToGlobNodeMap()
local to global mapping of nodes
nemId_t numCells
number of cells in mesh
NEMOSYS_EXPORT int diffMesh(meshBase *mesh1, meshBase *mesh2)
compares two meshBase classes.
vtkSmartPointer< vtkModelMetadata > getMetadata()
NEMOSYS_EXPORT void writePatchMap(const std::string &mapFile, const std::map< int, int > &patchMap)
write patch map file for roc prep (trivial identity mapping)
void setCheckQuality(bool x)
set whether to check quality of transfer by back-transfer and rmse
virtual int getCellDataIdx(const std::string &name)
<>
std::map< nemId_t, nemId_t > getGlobToPartNodeMap()
global to local mapping of nodes
vtkSmartPointer< vtkDataSet > getDataSet() const
get this meshes' dataSet
const std::string & getFileName() const
get the current file name
virtual void unsetPointDataArray(int arrayID)
delete array with id from dataSet's point data
nemId_t getNumberOfPoints() const
return the number of points
std::map< nemId_t, nemId_t > partToGlobNodeMap
map between local and global node idx in partition
sum comparison for vectors representing faces inserted into map
virtual void write() const
write the mesh to file named after the private var 'filename'.
vtkSmartPointer< vtkModelMetadata > metadata
std::shared_ptr< meshBase > mesh
std::map< nemId_t, nemId_t > partToGlobCellMap
map between local and global cell idx in partition
virtual void unsetCellDataArray(int arrayID)
delete array with id from dataSet's cell data
std::string filename
name of mesh file
std::vector< std::map< nemId_t, nemId_t > > globToPartNodeMap
std::map< nemId_t, nemId_t > getPartToGlobCellMap()
local to global mapping of cells
virtual void report() const
generate a report of the mesh
virtual void getCellDataArray(const std::string &name, std::vector< double > &data)
<>
std::vector< std::string > getNewArrayNames()
get new array names for use in transfer
bool continuous
switch on / off weighted averaging for cell data transfer (default is off)
void setMetadata(vtkSmartPointer< vtkModelMetadata > _metadata)
virtual void getCellDataArray(int arrayId, std::vector< double > &data)
<>
nemId_t getNumberOfCells() const
return the number of cells
virtual void unsetPointDataArray(const std::string &name)
<>
std::map< nemId_t, nemId_t > globToPartNodeMap
map between global and local node idx in partition for distributed data sets
std::vector< std::string > newArrayNames
new names to set for transferred data
virtual void unsetFieldDataArray(const std::string &name)
delete array with id from dataSet's field data
virtual void getPointDataArray(int arrayId, std::vector< double > &data)
get scalar point or cell data array.