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.
meshBase.H
Go to the documentation of this file.
1 /*******************************************************************************
2 * Promesh *
3 * Copyright (C) 2022, IllinoisRocstar LLC. All rights reserved. *
4 * *
5 * Promesh is the property of IllinoisRocstar LLC. *
6 * *
7 * IllinoisRocstar LLC *
8 * Champaign, IL *
9 * www.illinoisrocstar.com *
10 * promesh@illinoisrocstar.com *
11 *******************************************************************************/
12 /*******************************************************************************
13 * This file is part of Promesh *
14 * *
15 * This version of Promesh is free software: you can redistribute it and/or *
16 * modify it under the terms of the GNU Lesser General Public License as *
17 * published by the Free Software Foundation, either version 3 of the License, *
18 * or (at your option) any later version. *
19 * *
20 * Promesh is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more *
23 * details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
27 * *
28 *******************************************************************************/
29 #ifndef NEMOSYS_MESHBASE_H_
30 #define NEMOSYS_MESHBASE_H_
31 
32 #include <iostream>
33 #include <map>
34 #include <memory>
35 #include <string>
36 #include <vector>
37 
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>
48 
49 #include "nemosys_export.h"
50 
51 using nemId_t = std::size_t;
52 
53 /** @brief A brief description of meshBase.
54  @note Virtual methods are usually implemented in vtkMesh.C. We use that
55  class for more VTK-specific functions that we want wrapped by meshBase
56  @note Try using smart pointer instances of meshBase in drivers and pass the
57  underlying raw pointer with the get member function of the smart
58  pointer when required (e.g., source->transfer(target.get(), ...))
59  for smart pointer instance of target. Ideally, driver classes should
60  have empty destructors, which can be realized by using smart pointers.
61  In general, smart pointer should be used and scoped when they can.
62 **/
63 
64 class NEMOSYS_DEPRECATED_EXPORT meshBase {
65  // --- constructors and destructors
66  public:
68  : numPoints(0),
69  numCells(0),
70  dataSet(nullptr),
71  checkQuality(false),
72  continuous(false),
73  metadata(nullptr) {
74  std::cout << "meshBase constructed" << std::endl;
75  }
76 
77  // meshBase(const meshBase &mb) = delete;
78  // meshBase &operator=(const meshBase &mb) = delete;
79  // meshBase(meshBase &&mb) = delete;
80  // meshBase &operator=(meshBase &&mb) = delete;
81 
82  // Dropping support for copy constructor
83  // meshBase(const meshBase& mb)
84  //{
85  // numPoints = mb.numPoints;
86  // numCells = mb.numCells;
87  // hasSizeField = mb.hasSizeField;
88  // dataSet = mb.dataSet;
89  // filename = mb.filename;
90  // checkQuality = mb.checkQuality;
91  // order = mb.order;
92  // newArrayNames = mb.newArrayNames;
93  //}
94 
95  virtual ~meshBase() { std::cout << "meshBase destroyed" << std::endl; }
96 
97  // --- meshBase factory methods
98  public:
99  /** @brief Construct vtkMesh from filename.
100  @param fname name of mesh file
101  @return <>
102  **/
103  static meshBase *Create(const std::string &fname);
104 
105  /** @brief Construct from existing vtkDataSet and assign newname as
106  filename.
107  @param other The vtkDataSet used to construct the mesh
108  @param fname name of mesh file
109  @return <>
110  **/
111  static meshBase *Create(vtkSmartPointer<vtkDataSet> other,
112  const std::string &newname);
113 
114  /** @brief create from coordinates and connectivities.
115  @param xCrds <>
116  @param yCrds <>
117  @param zCrds <>
118  @param elmConn <>
119  @param cellType one of the vtkCellType enums. Currently, only VTK_TETRA
120  and VTK_TRIANGLE are supported.
121  @param newname name of mesh file
122  @return <>
123  **/
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);
129 
130  /** @brief Create shared ptr from fname.
131  @param fname name of mesh file
132  @return <>
133  **/
134  static std::shared_ptr<meshBase> CreateShared(const std::string &fname);
135 
136  /** @brief Create shared ptr from existing meshbase.
137  @param mesh the existing meshbase
138  @return <>
139  **/
140  static std::shared_ptr<meshBase> CreateShared(meshBase *mesh);
141 
142  /** @brief Create shared ptr from existing vtkDataset and assign newname as
143  filename.
144  @param other The vtkDataSet used to construct the mesh
145  @param fname name of mesh file
146  @return <>
147  **/
148  static std::shared_ptr<meshBase> CreateShared(
149  vtkSmartPointer<vtkDataSet> other, const std::string &newname);
150 
151  /** @brief Version of raw data mesh creation for memory managed shared_ptr
152  instance.
153  @param xCrds <>
154  @param yCrds <>
155  @param zCrds <>
156  @param elmConn <>
157  @param cellType one of the vtkCellType enums. Currently, only
158  VTK_TETRA and VTK_TRIANGLE are supported.
159  @param fname name of mesh file
160  @return <>
161  **/
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);
166 
167  /** @brief create unique ptr from fname
168  @param fname name of mesh file
169  @return <>
170  **/
171  static std::unique_ptr<meshBase> CreateUnique(const std::string &fname);
172 
173  /** @brief version of raw data mesh creation for memory managed unique ptr
174  instance
175  @param xCrds <>
176  @param yCrds <>
177  @param zCrds <>
178  @param elmConn <>
179  @param cellType one of the vtkCellType enums. Currently, only VTK_TETRA
180  and VTK_TRIANGLE are supported.
181  @param fname name of mesh file
182  @return <>
183  **/
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);
188  /** @brief construct from existing vtkDataSet and assign newname as filename
189  @param other The vtkDataSet used to construct the mesh
190  @param fname name of mesh file
191  @return <>
192  **/
193  static std::unique_ptr<meshBase> CreateUnique(
194  vtkSmartPointer<vtkDataSet> other, const std::string &newname);
195  /** @brief construct from existing meshbase object
196  @param mesh the existing meshbase
197  @return <>
198  **/
199  static std::unique_ptr<meshBase> CreateUnique(meshBase *mesh);
200 
201  /** @brief construct vtkMesh from gmsh msh file (called in Create methods)
202  @param fname name of mesh file
203  @return <>
204  **/
205  static meshBase *exportGmshToVtk(const std::string &fname);
206 
207  /** @brief construct vtkMesh from netgen vol file (called in Create methods)
208  @param fname name of mesh file
209  @return <>
210  **/
211  static meshBase *exportVolToVtk(const std::string &fname);
212 
213  /** @brief construct vtkMesh from netgen vol file (called in Create methods)
214  @param fname name of mesh file
215  @return <>
216  **/
217  static meshBase *exportPntToVtk(const std::string &fname);
218 
219  /** @brief construct vtkMesh from exodusII files
220  @param fname name of mesh file
221  @return <>
222  **/
223  static meshBase *exportExoToVtk(const std::string &fname);
224 
225  /*
226  static meshBase *generateMesh(const std::string &fname,
227  const std::string &meshEngine,
228  meshingParams *params);
229  */
230 
231  /** @brief stitch together several meshBases
232  @param mbObjs a vector of meshBase objects to stich together
233  @return <>
234  **/
235  static meshBase *stitchMB(const std::vector<meshBase *> &mbObjs);
236 
237  /** @brief stitch together several meshBase
238  @param mbObjs a vector of meshBase objects to stich together
239  @return <>
240  **/
241  static std::shared_ptr<meshBase> stitchMB(
242  const std::vector<std::shared_ptr<meshBase>> &_mbObjs);
243 
244  /** @brief mesh partitioning (with METIS)
245  @param mbObj The meshBase object to partition.
246  @param numPartitions The number of partitions to partition the mesh into
247  @return <>
248  **/
249  static std::vector<std::shared_ptr<meshBase>> partition(const meshBase *mbObj,
250  int numPartitions);
251 
252  /** @brief extract subset of mesh given list of cell ids and return meshBase
253  obj
254  @param mesh The meshBase object to extract the subset from.
255  @param cellIds <>
256  @return meshBase object representing the subset
257  **/
258  static meshBase *extractSelectedCells(meshBase *mesh,
259  const std::vector<nemId_t> &cellIds);
260 
261  /** @brief helper wrapped by function above
262  @param mesh The meshBase object to extract the subset from.
263  @param cellIds <>
264  @return meshBase object representing the subset
265  **/
266  static meshBase *extractSelectedCells(
267  vtkSmartPointer<vtkDataSet> mesh,
268  vtkSmartPointer<vtkIdTypeArray> cellIds);
269 
270  // --- access
271  public:
272  /** @brief abstract read method reserved for derived classes
273  @param fname name of mesh file
274  **/
275  virtual void read(const std::string &fname) = 0;
276 
277  /** @brief get point with id
278  @param id The id of the point.
279  @return <>
280  **/
281  virtual std::vector<double> getPoint(nemId_t id) const = 0;
282 
283  /** @brief get 3 vecs with x,y and z coords
284  @return <>
285  **/
286  virtual std::vector<std::vector<double>> getVertCrds() const = 0;
287 
288  /** @brief get cell with id
289  @param id The id of the cell.
290  @return point indices and respective coordinates
291  **/
292  virtual std::map<nemId_t, std::vector<double>> getCell(nemId_t id) const = 0;
293 
294  /** @brief get vector of coords of cell with id
295  @param id The id of the cell.
296  @return vector of coords of cell
297  **/
298  virtual std::vector<std::vector<double>> getCellVec(nemId_t id) const = 0;
299 
300  /** @brief get edge lengths of dataSet
301  @param ofname <>
302  **/
303  virtual void inspectEdges(const std::string &ofname) const = 0;
304 
305  /** @brief get this meshes' dataSet
306  @return this mesh's dataSet
307  **/
308  vtkSmartPointer<vtkDataSet> getDataSet() const { return dataSet; }
309 
310  /** @brief extract the surface mesh
311  @return the surface mesh for this mesh.
312  **/
313  virtual vtkSmartPointer<vtkDataSet> extractSurface() = 0;
314 
315  /** @brief register data to dataSet's point data
316  @param name <>
317  @param data <>
318  **/
319  virtual void setPointDataArray(const std::string &name,
320  const std::vector<std::vector<double>> &data) {
321  }
322 
323  /** @brief register data to dataSet's point data
324  @param name <>
325  @param data <>
326  **/
327  virtual void setPointDataArray(const std::string &name,
328  const std::vector<double> &data) {}
329 
330  /** @brief register data to dataSet's cell data
331  @param name <>
332  @param data <>
333  **/
334  virtual void setCellDataArray(const std::string &name,
335  const std::vector<std::vector<double>> &data) {}
336 
337  /** @brief register data to dataSet's cell data
338  @param name <>
339  @param data <>
340  **/
341  virtual void setCellDataArray(const std::string &name,
342  const std::vector<double> &data) {}
343 
344  /** @brief get *scalar* point or cell data array.
345  assumes data is not allocated prior to calling
346  @param name <>
347  @param data <>
348  **/
349  virtual void getPointDataArray(const std::string &name,
350  std::vector<double> &data) {}
351 
352  /** @brief get *scalar* point or cell data array.
353  assumes data is not allocated prior to calling
354  @param arrayId <>
355  @param data <>
356  **/
357  virtual void getPointDataArray(int arrayId, std::vector<double> &data) {}
358 
359  /** @brief <>
360  @param name <>
361  @return <>
362  **/
363  virtual int getCellDataIdx(const std::string &name) { return 0; }
364 
365  /** @brief <>
366  @param name <>
367  @param data <>
368  **/
369  virtual void getCellDataArray(const std::string &name,
370  std::vector<double> &data) {}
371 
372  /** @brief <>
373  @param arrayId <>
374  @param data <>
375  **/
376  virtual void getCellDataArray(int arrayId, std::vector<double> &data) {}
377 
378  /** @brief delete array with id from dataSet's point data
379  @param arrayID <>
380  **/
381  virtual void unsetPointDataArray(int arrayID) {}
382 
383  /** @brief <>
384  @param name <>
385  **/
386  virtual void unsetPointDataArray(const std::string &name) {}
387 
388  /** @brief delete array with id from dataSet's cell data
389  @param arrayID <>
390  **/
391  virtual void unsetCellDataArray(int arrayID) {}
392 
393  /** @brief <>
394  @param name <>
395  **/
396  virtual void unsetCellDataArray(const std::string &name) {}
397 
398  /** @brief delete array with id from dataSet's field data
399  @param name <>
400  **/
401  virtual void unsetFieldDataArray(const std::string &name) {}
402 
403  /** @brief get diameter of circumsphere of each cell
404  @return <>
405  **/
406  virtual std::vector<double> getCellLengths() const = 0;
407 
408  /** @brief get center of a cell
409  @param cellID <>
410  @return <>
411  **/
412  virtual std::vector<double> getCellCenter(nemId_t cellID) const = 0;
413 
414  /** @brief build locators for efficient search operations
415  @return <>
416  **/
417  vtkSmartPointer<vtkStaticCellLocator> buildStaticCellLocator();
418 
419  /** @brief build thread-safe point locator for efficient search operations
420  * @return <>
421  */
422  vtkSmartPointer<vtkStaticPointLocator> buildStaticPointLocator();
423 
424  /** @brief get cell type as an integer
425  assumes all elements are the same type
426  @return <>
427  **/
428  virtual int getCellType() const = 0;
429 
430  /** @brief get connectivities.
431 
432  This is only safe to use if mesh has cells of the same type or you have
433  information on the number of cells of each type and
434  the order in which they appear (for look up in resulting vector)
435 
436  @return <>
437  **/
438  virtual std::vector<nemId_t> getConnectivities() const = 0;
439  // set metadata, including sidesets
440  void setMetadata(vtkSmartPointer<vtkModelMetadata> _metadata) {
441  metadata = _metadata;
442  }
443  vtkSmartPointer<vtkModelMetadata> getMetadata() { return metadata; }
444 
445  // --- integration
446  public:
447  /** @brief integrate arrays in arrayIDs over the mesh.
448  @param arrayIDs <>
449  @return total integral for each datum is returned
450  **/
451  std::vector<std::vector<double>> integrateOverMesh(
452  const std::vector<int> &arrayIDs);
453 
454  // --- size field generation
455  public:
456  /** @brief generate size field based on method and given a point data array.
457  @param method (e.g., "gradient", "value", "error estimator")
458  @param arrayID <>
459  @param dev_mlt used to determine which cells to consider for refinement
460  @param maxIsmin used to determine which cells to consider for refinement
461  @param sizeFactor <>
462  @param order <>
463  **/
464  void generateSizeField(const std::string &method, int arrayID, double dev_mlt,
465  bool maxIsmin, double sizeFactor = 1.0, int order = 1);
466 
467  /** @brief check for named array in vtk and return its integer id.
468  @param pointOrCell boolean that tells the method whether to transfer
469  point (False) or cell (True) data.
470  @return <>
471  **/
472  int IsArrayName(const std::string &name, bool pointOrCell = false) const;
473 
474  // --- adaptive mesh refinement
475  public:
476  /** @brief perform sizefield-based h-refinement.
477  @param method <>
478  @param arrayID <>
479  @param dev_mult <>
480  @param maxIsmin <>
481  @param edge_scale <>
482  @param ofname <>
483  @param transferData <>
484  @param sizeFactor <>
485  **/
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);
490 
491  /** @brief perform sizefield-based h-refinement.
492  @param method <>
493  @param arrayName <>
494  @param dev_mult <>
495  @param maxIsmin <>
496  @param edge_scale <>
497  @param ofname <>
498  @param transferData <>
499  @param sizeFactor <>
500  **/
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.);
505 
506  /** @brief added for uniform refinement by driver
507  @param method <>
508  @param edge_scale <>
509  @param ofname <>
510  @param transferData <>
511  **/
512  void refineMesh(const std::string &method, double edge_scale,
513  const std::string &ofname, bool transferData,
514  bool constrainBoundary = false);
515 
516  /** @brief <>
517  @param method <>
518  @param arrayID <>
519  @param order <>
520  @param ofname <>
521  @param transferData <>
522  **/
523  void refineMesh(const std::string &method, int arrayID, int order,
524  const std::string &ofname, bool transferData);
525 
526  /** @brief <>
527  @param method <>
528  @param arrayName <>
529  @param order <>
530  @param ofname <>
531  @param transferData <>
532  **/
533  void refineMesh(const std::string &method, const std::string &arrayName,
534  int order, const std::string &ofname, bool transferData);
535 
536  // --- diagnostics
537  public:
538  /** @brief generate a report of the mesh
539  **/
540  virtual void report() const {};
541 
542  /** @brief return the number of points
543  @return The number of points.
544  **/
545  nemId_t getNumberOfPoints() const { return numPoints; }
546 
547  /** @brief return the number of cells
548  @return The number of cells.
549  **/
550  nemId_t getNumberOfCells() const { return numCells; }
551 
552  /** @brief <>
553  @param ofname <>
554  **/
555  void checkMesh(const std::string &ofname) const;
556 
557  // --- for distributed data sets.
558  public:
559  /** @brief global to local mapping of nodes
560  @note These are only generated if mesh is one of the partitions returned
561  from a call to meshBase::partition
562  **/
563  std::map<nemId_t, nemId_t> getGlobToPartNodeMap() {
564  return globToPartNodeMap;
565  }
566 
567  /** @brief global to local mapping of cells
568  @note These are only generated if mesh is one of the partitions returned
569  from a call to meshBase::partition
570  **/
571  std::map<nemId_t, nemId_t> getGlobToPartCellMap() {
572  return globToPartCellMap;
573  }
574 
575  /** @brief local to global mapping of nodes
576  @note These are only generated if mesh is one of the partitions returned
577  from a call to meshBase::partition
578  **/
579  std::map<nemId_t, nemId_t> getPartToGlobNodeMap() {
580  return partToGlobNodeMap;
581  }
582 
583  /** @brief local to global mapping of cells
584  @note These are only generated if mesh is one of the partitions returned
585  from a call to meshBase::partition
586  **/
587  std::map<nemId_t, nemId_t> getPartToGlobCellMap() {
588  return partToGlobCellMap;
589  }
590 
591  // --- write and conversion
592  public:
593  /** @brief write the mesh to file named after the private var 'filename'.
594 
595  The file extension of the private var "filename" determines the format of
596  the output file
597  **/
598  virtual void write() const { write(filename); }
599 
600  /** @brief write the mesh to file named fname
601  @param fname The name of the file to write to
602  **/
603  virtual void write(const std::string &fname) const = 0;
604 
605  /** @brief convert to gmsh format without data
606  @param outputStream <>
607  **/
608  void writeMSH(std::ofstream &outputStream);
609 
610  /** @brief convert to gmsh format without data
611  @param fname The name of the file to write to
612  **/
613  void writeMSH(const std::string &fname);
614 
615  /** @brief convert to gmsh format with specified point or cell data
616  @param outputStream <>
617  @param pointOrCell <>
618  @param arrayID <>
619  **/
620  void writeMSH(std::ofstream &outputStream, const std::string &pointOrCell,
621  int arrayID);
622 
623  /** @brief convert to gmsh format without data
624  @param fname The name of the file to write to
625  @param pointOrCell <>
626  @param arrayID <>
627  **/
628  void writeMSH(const std::string &fname, const std::string &pointOrCell,
629  int arrayID);
630 
631  /** @brief convert to gmsh format with specified point or cell data for
632  only volume elements (USE ONLY FOR MADLIB STUFF)
633  @param outputStream <>
634  @param pointOrCell <>
635  @param arrayID <>
636  @param onlyVol <>
637  **/
638  void writeMSH(std::ofstream &outputStream, const std::string &pointOrCell,
639  int arrayID,
640  bool onlyVol); // added for overloading, doesn't do anything
641 
642  /** @brief convert to gmsh format with specified point or cell data for
643  only volume elements (USE ONLY FOR MADLIB STUFF)
644  @param fname The name of the file to write to
645  @param pointOrCell <>
646  @param arrayID <>
647  @param onlyVol <>
648  **/
649  void writeMSH(const std::string &fname, const std::string &pointOrCell,
650  int arrayID, bool onlyVol);
651 
652  /** @brief surfWithPatch must have patchNo array
653  @param surfWithPatch <>
654  @param mapFile <>
655  @param outputStream <>
656  **/
657  void writeCobalt(meshBase *surfWithPatch, const std::string &mapFile,
658  std::ofstream &outputStream);
659 
660  /** @brief surfWithPatch must have patchNo array
661  @param surfWithPatch <>
662  @param mapFile <>
663  @param ofname <>
664  **/
665  void writeCobalt(meshBase *surfWithPatch, const std::string &mapFile,
666  const std::string &ofname);
667 
668  /** @brief set the file name.
669 
670  This will allow vtk to dispatch appropriate writers
671  based on the extension and whether it is supported by vtk.
672 
673  @param fname The name to set the private variable "filename" to
674  **/
675  void setFileName(const std::string &fname) { filename = fname; }
676 
677  /** @brief get the current file name
678  @return The current value of the private variable "filename"
679  **/
680  const std::string &getFileName() const { return filename; }
681 
682  /** @brief set whether to check quality of transfer by back-transfer and rmse
683  @param x <>
684  **/
685  void setCheckQuality(bool x) { checkQuality = x; }
686 
687  /** @brief set weighted averaging/smoothing for cell data transfer
688  (default is off)
689  @param x <>
690  **/
691  void setContBool(bool x) { continuous = x; }
692 
693  // remove all quad elements by naive conversion to tris
694  meshBase *convertQuads();
695 
696  /** @brief get new array names for use in transfer
697  **/
698  std::vector<std::string> getNewArrayNames() { return newArrayNames; }
699 
700  /** @brief given array names, return corresponding ids
701  **/
702  std::vector<int> getArrayIDs(std::vector<std::string> arrayNames,
703  bool fromPointArrays = false);
704 
705  /** @brief Converts given hexahedral VTK dataset into tetrahedral mesh
706  and stores it into dataSet variable.
707  @param meshdataSet Input hexahedral mesh dataset
708  **/
709  void convertHexToTetVTK(vtkSmartPointer<vtkDataSet> meshdataSet);
710 
711  protected:
712  /** @brief number of points in mesh
713  **/
715 
716  /** @brief number of cells in mesh
717  **/
719 
720  /** @brief mesh points, topology and data
721  **/
722  vtkSmartPointer<vtkDataSet> dataSet;
723 
724  /** @brief name of mesh file
725  **/
726  std::string filename;
727 
728  /** @brief check transfer quality when on
729  **/
731 
732  /** @brief switch on / off weighted averaging for cell data transfer
733  (default is off)
734  **/
736 
737  /** @brief new names to set for transferred data
738  **/
739  std::vector<std::string> newArrayNames;
740 
741  /** @brief map between global and local node idx in partition
742  for distributed data sets
743 
744  Only populated for mesh resulting from call to meshBase::partition
745  **/
746  std::map<nemId_t, nemId_t> globToPartNodeMap;
747 
748  /** @brief map between global and local cell idx in partition
749  **/
750  std::map<nemId_t, nemId_t> globToPartCellMap;
751 
752  /** @brief map between local and global node idx in partition
753  **/
754  std::map<nemId_t, nemId_t> partToGlobNodeMap;
755 
756  /** @brief map between local and global cell idx in partition
757  **/
758  std::map<nemId_t, nemId_t> partToGlobCellMap;
759  // metadata
760  vtkSmartPointer<vtkModelMetadata> metadata;
761 };
762 
763 /** @brief sum comparison for vectors representing faces inserted into map
764  **/
765 struct NEMOSYS_EXPORT sortNemId_tVec_compare {
766  // TODO: This is a comparison operation making copies since passed by value!
767  // Should be pass by const-ref. If sorting is necessary, do it
768  // beforehand.
769  bool operator()(std::vector<nemId_t> lhs, std::vector<nemId_t> rhs) const;
770 };
771 
772 // --- auxiliary helpers
773 /** @brief compares two meshBase classes. used in testing
774  @param mesh1 <>
775  @param mesh2 <>
776 **/
777 NEMOSYS_EXPORT int diffMesh(meshBase *mesh1, meshBase *mesh2);
778 
779 /** @brief write patch map file for roc prep (trivial identity mapping)
780  @param mapFile <>
781  @param patchMap <>
782 **/
783 NEMOSYS_EXPORT void writePatchMap(const std::string &mapFile,
784  const std::map<int, int> &patchMap);
785 
786 /** @brief write patch map file for roc prep (trivial identity mapping)
787  @param outputStream <>
788  @param patchMap <>
789 **/
790 NEMOSYS_EXPORT void writePatchMap(std::ofstream &outputStream,
791  const std::map<int, int> &patchMap);
792 
793 #endif // NEMOSYS_MESHBASE_H_
virtual void unsetCellDataArray(const std::string &name)
<>
Definition: meshBase.H:396
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
Definition: meshBase.H:750
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
Definition: meshBase.H:714
virtual void setCellDataArray(const std::string &name, const std::vector< double > &data)
register data to dataSet&#39;s cell data
Definition: meshBase.H:341
std::map< nemId_t, nemId_t > getGlobToPartCellMap()
global to local mapping of cells
Definition: meshBase.H:571
void setContBool(bool x)
set weighted averaging/smoothing for cell data transfer (default is off)
Definition: meshBase.H:691
bool checkQuality
check transfer quality when on
Definition: meshBase.H:730
void setFileName(const std::string &fname)
set the file name.
Definition: meshBase.H:675
virtual void getPointDataArray(const std::string &name, std::vector< double > &data)
get scalar point or cell data array.
Definition: meshBase.H:349
virtual void setPointDataArray(const std::string &name, const std::vector< std::vector< double >> &data)
register data to dataSet&#39;s point data
Definition: meshBase.H:319
std::vector< std::map< nemId_t, nemId_t > > globToPartCellMap
vtkSmartPointer< vtkDataSet > dataSet
mesh points, topology and data
Definition: meshBase.H:722
std::vector< std::map< nemId_t, nemId_t > > partToGlobNodeMap
A brief description of meshBase.
Definition: meshBase.H:64
std::size_t nemId_t
Definition: meshBase.H:51
virtual void setCellDataArray(const std::string &name, const std::vector< std::vector< double >> &data)
register data to dataSet&#39;s cell data
Definition: meshBase.H:334
virtual void setPointDataArray(const std::string &name, const std::vector< double > &data)
register data to dataSet&#39;s point data
Definition: meshBase.H:327
std::map< nemId_t, nemId_t > getPartToGlobNodeMap()
local to global mapping of nodes
Definition: meshBase.H:579
nemId_t numCells
number of cells in mesh
Definition: meshBase.H:718
NEMOSYS_EXPORT int diffMesh(meshBase *mesh1, meshBase *mesh2)
compares two meshBase classes.
Definition: meshBase.C:1665
vtkSmartPointer< vtkModelMetadata > getMetadata()
Definition: meshBase.H:443
NEMOSYS_EXPORT void writePatchMap(const std::string &mapFile, const std::map< int, int > &patchMap)
write patch map file for roc prep (trivial identity mapping)
Definition: meshBase.C:1376
void setCheckQuality(bool x)
set whether to check quality of transfer by back-transfer and rmse
Definition: meshBase.H:685
virtual int getCellDataIdx(const std::string &name)
<>
Definition: meshBase.H:363
std::map< nemId_t, nemId_t > getGlobToPartNodeMap()
global to local mapping of nodes
Definition: meshBase.H:563
vtkSmartPointer< vtkDataSet > getDataSet() const
get this meshes&#39; dataSet
Definition: meshBase.H:308
const std::string & getFileName() const
get the current file name
Definition: meshBase.H:680
virtual void unsetPointDataArray(int arrayID)
delete array with id from dataSet&#39;s point data
Definition: meshBase.H:381
nemId_t getNumberOfPoints() const
return the number of points
Definition: meshBase.H:545
std::map< nemId_t, nemId_t > partToGlobNodeMap
map between local and global node idx in partition
Definition: meshBase.H:754
sum comparison for vectors representing faces inserted into map
Definition: meshBase.H:765
virtual void write() const
write the mesh to file named after the private var &#39;filename&#39;.
Definition: meshBase.H:598
VTKCellType cellType
Definition: inpGeoMesh.C:129
vtkSmartPointer< vtkModelMetadata > metadata
Definition: meshBase.H:760
std::shared_ptr< meshBase > mesh
std::map< nemId_t, nemId_t > partToGlobCellMap
map between local and global cell idx in partition
Definition: meshBase.H:758
virtual void unsetCellDataArray(int arrayID)
delete array with id from dataSet&#39;s cell data
Definition: meshBase.H:391
std::string filename
name of mesh file
Definition: meshBase.H:726
std::vector< std::map< nemId_t, nemId_t > > globToPartNodeMap
meshBase()
Definition: meshBase.H:67
std::map< nemId_t, nemId_t > getPartToGlobCellMap()
local to global mapping of cells
Definition: meshBase.H:587
virtual void report() const
generate a report of the mesh
Definition: meshBase.H:540
virtual ~meshBase()
Definition: meshBase.H:95
virtual void getCellDataArray(const std::string &name, std::vector< double > &data)
<>
Definition: meshBase.H:369
std::vector< std::string > getNewArrayNames()
get new array names for use in transfer
Definition: meshBase.H:698
bool continuous
switch on / off weighted averaging for cell data transfer (default is off)
Definition: meshBase.H:735
void setMetadata(vtkSmartPointer< vtkModelMetadata > _metadata)
Definition: meshBase.H:440
virtual void getCellDataArray(int arrayId, std::vector< double > &data)
<>
Definition: meshBase.H:376
nemId_t getNumberOfCells() const
return the number of cells
Definition: meshBase.H:550
virtual void unsetPointDataArray(const std::string &name)
<>
Definition: meshBase.H:386
std::map< nemId_t, nemId_t > globToPartNodeMap
map between global and local node idx in partition for distributed data sets
Definition: meshBase.H:746
std::vector< std::string > newArrayNames
new names to set for transferred data
Definition: meshBase.H:739
virtual void unsetFieldDataArray(const std::string &name)
delete array with id from dataSet&#39;s field data
Definition: meshBase.H:401
virtual void getPointDataArray(int arrayId, std::vector< double > &data)
get scalar point or cell data array.
Definition: meshBase.H:357