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.
TransferBase.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_TRANSFERBASE_H_
30 #define NEMOSYS_TRANSFERBASE_H_
31 
32 #include "nemosys_export.h"
33 #include "Mesh/meshBase.H"
34 
35 #include <vtkStaticCellLocator.h>
36 #include <vtkStaticPointLocator.h>
37 
38 class NEMOSYS_EXPORT TransferBase {
39  public:
41  : source(nullptr),
42  target(nullptr),
43  checkQual(false),
44  continuous(false),
45  c2cTrnsDistTol(1.e-6) {
46  std::cout << "TransferBase constructed" << std::endl;
47  }
48 
49  virtual ~TransferBase() {
50  std::cout << "TransferBase destroyed" << std::endl;
51  }
52 
53  public:
54  /**
55  * @brief Transfer point data with given ids from source to target.
56  * @param arrayIDs array of array ids to specify which fields to transfer
57  * @param newnames optional array of names to be applied to transferred fields
58  * @return 0 upon completion
59  */
60  virtual int transferPointData(const std::vector<int> &arrayIDs,
61  const std::vector<std::string> &newnames =
62  std::vector<std::string>()) = 0;
63  /**
64  * @brief Transfer cell data with given ids from source to target.
65  * @param arrayIDs array of array ids to specify which fields to transfer
66  * @param newnames optional array of names to be applied to transferred fields
67  * @return 0 upon completion
68  */
69  virtual int transferCellData(const std::vector<int> &arrayIDs,
70  const std::vector<std::string> &newnames =
71  std::vector<std::string>()) = 0;
72  /**
73  * @brief Transfer point data with given field names from source to target.
74  * @param arrayIDs array of array names to specify which fields to transfer
75  * @param newnames optional array of names to be applied to transferred fields
76  * @return 0 upon completion
77  */
78  int transferPointData(
79  const std::vector<std::string> &arrayNames,
80  const std::vector<std::string> &newnames = std::vector<std::string>());
81 
82  /**
83  * @brief Transfer cell data with given field names from source to target.
84  * @param arrayIDs array of array names to specify which fields to transfer
85  * @param newnames optional array of names to be applied to transferred fields
86  * @return 0 upon completion
87  */
88  int transferCellData(
89  const std::vector<std::string> &arrayNames,
90  const std::vector<std::string> &newnames = std::vector<std::string>());
91 
92  /**
93  * @brief Transfer all fields.
94  * @param newnames optional array of names to be applied to transferred fields
95  * @return 0 upon completion
96  */
97  virtual int run(const std::vector<std::string> &newnames =
98  std::vector<std::string>()) = 0;
99 
100  void setCheckQual(bool x) { checkQual = x; }
101 
102  void setContBool(bool x) { continuous = x; }
103 
104  protected:
107 
108  vtkSmartPointer<vtkStaticCellLocator> srcCellLocator = nullptr;
109  vtkSmartPointer<vtkStaticCellLocator> trgCellLocator = nullptr;
110 
111  vtkSmartPointer<vtkStaticPointLocator> srcPointLocator = nullptr;
112  vtkSmartPointer<vtkStaticPointLocator> trgPointLocator = nullptr;
113 
114  bool checkQual;
115  bool continuous; // switch on / off weighted averaging for cell transfer
117 
118  private:
119  /**
120  * @brief given array names and field data, return vector of corresponding
121  * array ids in the field data
122  */
123  std::vector<int> getArrayIDs(const std::vector<std::string> &arrayNames,
124  vtkFieldData *fieldData);
125  /**
126  * @brief given array name and field data, returns index of array with given
127  * name (-1 if not found)
128  * @param arrayName name of array
129  * @param data mesh field data that includes the sought after arrays
130  * @return array id
131  */
132  int getDataArrayIndex(const std::string &arrayName, vtkFieldData *data);
133 };
134 
135 #endif // NEMOSYS_TRANSFERBASE_H_
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).
double c2cTrnsDistTol
Definition: TransferBase.H:116
A brief description of meshBase.
Definition: meshBase.H:64
void setContBool(bool x)
Definition: TransferBase.H:102
meshBase * target
Definition: TransferBase.H:106
void setCheckQual(bool x)
Definition: TransferBase.H:100
virtual ~TransferBase()
Definition: TransferBase.H:49
meshBase * source
Definition: TransferBase.H:105