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.
FETransfer.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_FETRANSFER_H_
30 #define NEMOSYS_FETRANSFER_H_
31 
32 #include "nemosys_export.h"
33 #include "Transfer/TransferBase.H"
34 
35 #include <vtkDoubleArray.h>
36 #include <vtkGenericCell.h>
37 
38 class NEMOSYS_EXPORT FETransfer : public TransferBase {
39  public:
40  FETransfer(meshBase *_source, meshBase *_target);
41 
42  ~FETransfer() override { std::cout << "FETransfer destroyed" << std::endl; }
43 
44  public:
45  static FETransfer *Create(meshBase *source, meshBase *target) {
46  return new FETransfer(source, target);
47  }
48 
49  static std::shared_ptr<FETransfer> CreateShared(meshBase *source,
50  meshBase *target) {
51  return std::shared_ptr<FETransfer>(FETransfer::Create(source, target));
52  }
53 
54  public:
55  /**
56  * @brief Transfers point data with arrayID from source mesh to target
57  * The algorithm is as follows;
58  * 1) For each point in the target mesh, find the cell of the source
59  * mesh in which it exists.
60  * - using a cell locator
61  * - if cell locator fails, find the nearest neighbor in the source mesh
62  * and all cells sharing this neighbor point. Check if the target point
63  * is in any of these neighboring cells 2) When the cell is identified,
64  * evaluate the weights for interpolation of the solution to the target point
65  * and perform the interpolation.
66  * @param arrayIDs array of array ids for transfer
67  * @param newnames optional array of names for transferred data:
68  * newnames[i] specifies the transferred array name in the target at
69  * arrayId[i]
70  */
71  int transferPointData(const std::vector<int> &arrayIDs,
72  const std::vector<std::string> &newnames =
73  std::vector<std::string>()) override;
74 
75  int transferPointData(int pointId,
76  vtkSmartPointer<vtkGenericCell> containingCell,
77  std::vector<vtkSmartPointer<vtkDoubleArray>> &dasSource,
78  std::vector<vtkSmartPointer<vtkDoubleArray>> &dasTarget,
79  bool flip);
80 
81  // cell data transfer
82  public:
83  /**
84  * @brief Transfer cell data from source mesh to target
85  * The algorithm is as follows:
86  * 1) Convert the cell data on the source mesh by inverse-distance
87  * weighted averaging of data at cells sharing given point
88  * - cell data is assumed to be prescribed at cell centers
89  * 2) Compute the centers of cell in the target mesh
90  * 3) Transfer the converted cell-point data from the source mesh
91  * to the cell centers of the target mesh using the runPD methods
92  * @param arrayIDs array of array ids for transfer
93  * @param newnames optional array of names for transferred data:
94  * newnames[i] specifies the transferred array name in the target at
95  * arrayId[i]
96  */
97  int transferCellData(const std::vector<int> &arrayIDs,
98  const std::vector<std::string> &newnames =
99  std::vector<std::string>()) override;
100 
101  int transferCellData(
102  int i, vtkSmartPointer<vtkGenericCell> genCell,
103  std::vector<vtkSmartPointer<vtkDoubleArray>> &dasSourceToPoint,
104  std::vector<vtkSmartPointer<vtkDoubleArray>> &dasTarget);
105 
106  /**
107  * @brief Transfer all cell and point data from source to target.
108  */
109  int run(const std::vector<std::string> &newnames =
110  std::vector<std::string>()) override;
111 
112  private:
113  /**
114  * @brief Thread safe implementation using static point locator.
115  */
116  void getClosestSourceCell(double x[3], bool flip, vtkIdType &id,
117  vtkSmartPointer<vtkGenericCell> closestCell,
118  double closestPoint[3], int &subId,
119  double &minDist2, double *&weights);
120 };
121 
122 #endif // NEMOSYS_FETRANSFER_H_
virtual int transferCellData(const std::vector< int > &arrayIDs, const std::vector< std::string > &newnames=std::vector< std::string >())=0
Transfer cell data with given ids from source to target.
A brief description of meshBase.
Definition: meshBase.H:64
static FETransfer * Create(meshBase *source, meshBase *target)
Definition: FETransfer.H:45
virtual int run(const std::vector< std::string > &newnames=std::vector< std::string >())=0
Transfer all fields.
virtual int transferPointData(const std::vector< int > &arrayIDs, const std::vector< std::string > &newnames=std::vector< std::string >())=0
Transfer point data with given ids from source to target.
static std::shared_ptr< FETransfer > CreateShared(meshBase *source, meshBase *target)
Definition: FETransfer.H:49
~FETransfer() override
Definition: FETransfer.H:42