8 #ifndef PORTAGE_INTERSECT_INTERSECT_R2D_H_ 9 #define PORTAGE_INTERSECT_INTERSECT_R2D_H_ 18 #include "wonton/intersect/r3d/r2d.h" 25 #include "tangram/driver/CellMatPoly.h" 26 #include "tangram/driver/driver.h" 27 #include "tangram/support/MatPoly.h" 30 #include "wonton/support/Point.h" 38 template <Entity_kind on_what,
class SourceMeshType,
39 class SourceStateType,
class TargetMeshType,
40 template<
class,
int,
class,
class>
class InterfaceReconstructorType =
41 DummyInterfaceReconstructor,
42 class Matpoly_Splitter = void,
43 class Matpoly_Clipper =
void>
47 using InterfaceReconstructor2D =
48 Tangram::Driver<InterfaceReconstructorType, 2, SourceMeshType,
49 Matpoly_Splitter, Matpoly_Clipper>;
58 SourceStateType
const & source_state,
59 TargetMeshType
const & target_mesh,
61 std::shared_ptr<InterfaceReconstructor2D> ir)
62 : sourceMeshWrapper(source_mesh), sourceStateWrapper(source_state),
63 targetMeshWrapper(target_mesh), interface_reconstructor(ir),
64 num_tols_(num_tols) {}
70 SourceStateType
const & source_state,
71 TargetMeshType
const & target_mesh,
73 : sourceMeshWrapper(source_mesh), sourceStateWrapper(source_state),
74 targetMeshWrapper(target_mesh), num_tols_(num_tols) {}
87 std::vector<Weights_t>
88 operator() (
const int tgt_entity, std::vector<int>
const& src_entities)
const {
89 std::cerr <<
"IntersectR3D not implemented for this entity type" << std::endl;
90 return std::vector<Weights_t>(0);
99 SourceMeshType
const & sourceMeshWrapper;
100 SourceStateType
const & sourceStateWrapper;
101 TargetMeshType
const & targetMeshWrapper;
104 std::shared_ptr<InterfaceReconstructor2D> interface_reconstructor;
114 template <
class SourceMeshType,
class SourceStateType,
115 class TargetMeshType,
116 template <
class,
int,
class,
class>
class InterfaceReconstructorType,
117 class Matpoly_Splitter,
class Matpoly_Clipper>
118 class IntersectR2D<Entity_kind::CELL, SourceMeshType, SourceStateType, TargetMeshType,
119 InterfaceReconstructorType, Matpoly_Splitter, Matpoly_Clipper> {
122 using InterfaceReconstructor2D =
123 Tangram::Driver<InterfaceReconstructorType, 2, SourceMeshType,
124 Matpoly_Splitter, Matpoly_Clipper>;
133 SourceStateType
const & source_state,
134 TargetMeshType
const & target_mesh,
136 std::shared_ptr<InterfaceReconstructor2D> ir)
137 : sourceMeshWrapper(source_mesh), sourceStateWrapper(source_state),
138 targetMeshWrapper(target_mesh), interface_reconstructor(ir),
139 num_tols_(num_tols) {}
145 SourceStateType
const & source_state,
146 TargetMeshType
const & target_mesh,
148 : sourceMeshWrapper(source_mesh), sourceStateWrapper(source_state),
149 targetMeshWrapper(target_mesh), num_tols_(num_tols) {}
162 std::vector<Weights_t>
operator() (
int tgt_cell, std::vector<int>
const& src_cells)
const {
163 std::vector<Wonton::Point<2>> target_poly;
164 targetMeshWrapper.cell_get_coordinates(tgt_cell, &target_poly);
166 int nsrc = src_cells.size();
167 std::vector<Weights_t> sources_and_weights(nsrc);
169 for (
int i = 0; i < nsrc; i++) {
170 int s = src_cells[i];
172 Weights_t & this_wt = sources_and_weights[ninserted];
173 this_wt.entityID = s;
176 int nmats = sourceStateWrapper.cell_get_num_mats(s);
177 std::vector<int> cellmats;
178 sourceStateWrapper.cell_get_mats(s, &cellmats);
180 if (!nmats || (matid_ == -1) || (nmats == 1 && cellmats[0] == matid_)) {
187 std::vector<Wonton::Point<2>> source_poly;
188 sourceMeshWrapper.cell_get_coordinates(s, &source_poly);
199 assert(interface_reconstructor !=
nullptr);
201 if (std::find(cellmats.begin(), cellmats.end(), matid_) !=
207 Tangram::CellMatPoly<2>
const& cellmatpoly =
208 interface_reconstructor->cell_matpoly_data(s);
209 std::vector<Tangram::MatPoly<2>> matpolys =
210 cellmatpoly.get_matpolys(matid_);
212 this_wt.weights.resize(3, 0.0);
213 for (
auto& matpoly : matpolys) {
214 std::vector<Wonton::Point<2>> tpnts = matpoly.points();
215 std::vector<Wonton::Point<2>> source_poly;
216 source_poly.reserve(tpnts.size());
217 for (
auto const & p : tpnts) source_poly.push_back(p);
220 target_poly, num_tols_);
221 for (
int k = 0; k < 3; k++)
222 this_wt.weights[k] += momvec[k];
227 std::vector<Wonton::Point<2>> source_poly;
228 sourceMeshWrapper.cell_get_coordinates(s, &source_poly);
235 if (!this_wt.weights.empty() && this_wt.weights[0] > 0.0)
239 sources_and_weights.resize(ninserted);
240 return sources_and_weights;
249 SourceMeshType
const & sourceMeshWrapper;
250 SourceStateType
const & sourceStateWrapper;
251 TargetMeshType
const & targetMeshWrapper;
254 std::shared_ptr<InterfaceReconstructor2D> interface_reconstructor;
265 template <
class SourceMeshType,
class SourceStateType,
266 class TargetMeshType,
267 template <
class,
int,
class,
class>
class InterfaceReconstructorType,
268 class Matpoly_Splitter,
class Matpoly_Clipper>
269 class IntersectR2D<Entity_kind::NODE, SourceMeshType, SourceStateType, TargetMeshType,
270 InterfaceReconstructorType, Matpoly_Splitter, Matpoly_Clipper> {
273 using InterfaceReconstructor2D =
274 Tangram::Driver<InterfaceReconstructorType, 2, SourceMeshType,
275 Matpoly_Splitter, Matpoly_Clipper>;
284 SourceStateType
const & source_state,
285 TargetMeshType
const & target_mesh,
287 std::shared_ptr<InterfaceReconstructor2D> ir)
288 : sourceMeshWrapper(source_mesh), sourceStateWrapper(source_state),
289 targetMeshWrapper(target_mesh), interface_reconstructor(ir),
290 num_tols_(num_tols) {}
297 SourceStateType
const & source_state,
298 TargetMeshType
const & target_mesh,
300 : sourceMeshWrapper(source_mesh), sourceStateWrapper(source_state),
301 targetMeshWrapper(target_mesh), num_tols_(num_tols) {}
315 std::vector<Weights_t>
operator() (
int tgt_node, std::vector<int>
const& src_nodes)
const {
316 std::vector<Wonton::Point<2>> target_poly;
317 targetMeshWrapper.dual_cell_get_coordinates(tgt_node, &target_poly);
319 int nsrc = src_nodes.size();
320 std::vector<Weights_t> sources_and_weights(nsrc);
322 for (
int i = 0; i < nsrc; i++) {
323 int s = src_nodes[i];
324 std::vector<Wonton::Point<2>> source_poly;
325 sourceMeshWrapper.dual_cell_get_coordinates(s, &source_poly);
327 Weights_t & this_wt = sources_and_weights[ninserted];
328 this_wt.entityID = s;
333 if (!this_wt.weights.empty() && this_wt.weights[0] > 0.0)
337 sources_and_weights.resize(ninserted);
338 return sources_and_weights;
348 SourceMeshType
const & sourceMeshWrapper;
349 SourceStateType
const & sourceStateWrapper;
350 TargetMeshType
const & targetMeshWrapper;
353 std::shared_ptr<InterfaceReconstructor2D> interface_reconstructor;
360 #endif // PORTAGE_INTERSECT_INTERSECT_R2D_H_ IntersectR2D(SourceMeshType const &source_mesh, SourceStateType const &source_state, TargetMeshType const &target_mesh, NumericTolerances_t num_tols)
Constructor WITHOUT interface reconstructor.
Definition: intersect_r2d.h:296
IntersectR2D(SourceMeshType const &source_mesh, SourceStateType const &source_state, TargetMeshType const &target_mesh, NumericTolerances_t num_tols)
Constructor WITHOUT interface reconstructor.
Definition: intersect_r2d.h:69
void set_material(int m)
Set the source mesh material that we have to intersect against.
Definition: intersect_r2d.h:78
algorithm
Definition: intersect_r2d.h:44
Intersection and other tolerances to handle tiny values.
Definition: portage.h:152
void set_material(int m)
Set the source mesh material that we have to intersect against.
Definition: intersect_r2d.h:153
std::vector< double > intersect_polys_r2d(std::vector< Wonton::Point< 2 >> const &source_poly, std::vector< Wonton::Point< 2 >> const &target_poly, NumericTolerances_t num_tols)
Definition: intersect_polys_r2d.h:29
void set_material(int m)
Set the source mesh material that we have to intersect against.
Definition: intersect_r2d.h:305
IntersectR2D(SourceMeshType const &source_mesh, SourceStateType const &source_state, TargetMeshType const &target_mesh, NumericTolerances_t num_tols)
Constructor WITHOUT interface reconstructor.
Definition: intersect_r2d.h:144
Definition: coredriver.h:42
IntersectR2D & operator=(const IntersectR2D &)=delete
Assignment operator (disabled)
std::vector< Weights_t > operator()(const int tgt_entity, std::vector< int > const &src_entities) const
Intersect control volume of a target entity with control volumes of a set of source entities...
Definition: intersect_r2d.h:88