7 #ifndef PORTAGE_INTERSECT_INTERSECT_R3D_H_ 8 #define PORTAGE_INTERSECT_INTERSECT_R3D_H_ 17 #include "wonton/intersect/r3d/r3d.h" 24 #include "tangram/driver/CellMatPoly.h" 25 #include "tangram/driver/driver.h" 26 #include "tangram/support/MatPoly.h" 50 template <Entity_kind on_what,
class SourceMeshType,
51 class SourceStateType,
class TargetMeshType,
52 template <
class,
int,
class,
class>
class InterfaceReconstructorType =
53 DummyInterfaceReconstructor,
54 class Matpoly_Splitter = void,
55 class Matpoly_Clipper =
void>
59 using InterfaceReconstructor3D =
60 Tangram::Driver<InterfaceReconstructorType, 3, SourceMeshType,
61 Matpoly_Splitter, Matpoly_Clipper>;
69 SourceStateType
const & source_state,
70 TargetMeshType
const & target_mesh,
72 std::shared_ptr<InterfaceReconstructor3D> ir,
73 bool rectangular_mesh =
false)
74 : sourceMeshWrapper(source_mesh), sourceStateWrapper(source_state),
75 targetMeshWrapper(target_mesh), interface_reconstructor(ir),
76 rectangular_mesh_(rectangular_mesh), num_tols_(num_tols) {}
82 SourceStateType
const & source_state,
83 TargetMeshType
const & target_mesh,
85 bool rectangular_mesh =
false)
86 : sourceMeshWrapper(source_mesh), sourceStateWrapper(source_state),
87 targetMeshWrapper(target_mesh), rectangular_mesh_(rectangular_mesh),
88 num_tols_(num_tols) {}
102 std::vector<Weights_t>
operator() (
int tgt_entity, std::vector<int>
const& src_entities)
const {
103 throw std::runtime_error(
"not implemented for this entity type");
114 SourceMeshType
const & sourceMeshWrapper;
115 SourceStateType
const & sourceStateWrapper;
116 TargetMeshType
const & targetMeshWrapper;
118 std::shared_ptr<InterfaceReconstructor3D> interface_reconstructor;
120 bool rectangular_mesh_ =
false;
128 template <
class SourceMeshType,
class SourceStateType,
129 class TargetMeshType,
130 template <
class,
int,
class,
class>
class InterfaceReconstructorType,
131 class Matpoly_Splitter,
class Matpoly_Clipper>
132 class IntersectR3D<Entity_kind::CELL, SourceMeshType, SourceStateType, TargetMeshType,
133 InterfaceReconstructorType,
134 Matpoly_Splitter, Matpoly_Clipper> {
137 using InterfaceReconstructor3D =
138 Tangram::Driver<InterfaceReconstructorType, 3, SourceMeshType,
139 Matpoly_Splitter, Matpoly_Clipper>;
148 SourceStateType
const & source_state,
149 TargetMeshType
const & target_mesh,
151 std::shared_ptr<InterfaceReconstructor3D> ir,
152 bool rectangular_mesh =
false)
153 : sourceMeshWrapper(source_mesh), sourceStateWrapper(source_state),
154 targetMeshWrapper(target_mesh), interface_reconstructor(ir),
155 rectangular_mesh_(rectangular_mesh), num_tols_(num_tols) {}
161 SourceStateType
const & source_state,
162 TargetMeshType
const & target_mesh,
164 bool rectangular_mesh =
false)
165 : sourceMeshWrapper(source_mesh), sourceStateWrapper(source_state),
166 targetMeshWrapper(target_mesh), rectangular_mesh_(rectangular_mesh),
167 num_tols_(num_tols) {}
183 const std::vector<int>& src_cells)
const {
185 std::vector<std::array<Point<3>, 4>> target_tet_coords;
190 targetMeshWrapper.decompose_cell_into_tets(tgt_cell, &target_tet_coords,
194 int nsrc = src_cells.size();
195 std::vector<Weights_t> sources_and_weights(nsrc);
197 for (
int i = 0; i < nsrc; i++) {
198 int s = src_cells[i];
200 Weights_t & this_wt = sources_and_weights[ninserted];
201 this_wt.entityID = s;
204 int nmats = sourceStateWrapper.cell_get_num_mats(s);
205 std::vector<int> cellmats;
206 sourceStateWrapper.cell_get_mats(s, &cellmats);
208 if (!nmats || (matid_ == -1) || (nmats == 1 && cellmats[0] == matid_)) {
216 sourceMeshWrapper.cell_get_facetization(s, &srcpoly.
facetpoints,
222 }
else if (std::find(cellmats.begin(), cellmats.end(), matid_) !=
228 Tangram::CellMatPoly<3>
const& cellmatpoly =
229 interface_reconstructor->cell_matpoly_data(s);
230 std::vector<Tangram::MatPoly<3>> matpolys =
231 cellmatpoly.get_matpolys(matid_);
233 this_wt.weights.resize(4,0.0);
234 for (
const auto& matpoly : matpolys) {
238 target_tet_coords, num_tols_);
239 for (
int k = 0; k < 4; k++)
240 this_wt.weights[k] += momvec[k];
246 sourceMeshWrapper.cell_get_facetization(s, &srcpoly.
facetpoints,
253 if (!this_wt.weights.empty() && this_wt.weights[0] > 0.0)
257 sources_and_weights.resize(ninserted);
258 return sources_and_weights;
268 SourceMeshType
const & sourceMeshWrapper;
269 SourceStateType
const & sourceStateWrapper;
270 TargetMeshType
const & targetMeshWrapper;
272 std::shared_ptr<InterfaceReconstructor3D> interface_reconstructor;
274 bool rectangular_mesh_ =
false;
282 template <
class SourceMeshType,
class SourceStateType,
283 class TargetMeshType,
284 template <
class,
int,
class,
class>
class InterfaceReconstructorType,
285 class Matpoly_Splitter,
class Matpoly_Clipper>
286 class IntersectR3D<Entity_kind::NODE, SourceMeshType, SourceStateType, TargetMeshType,
287 InterfaceReconstructorType,
288 Matpoly_Splitter, Matpoly_Clipper> {
291 using InterfaceReconstructor3D =
292 Tangram::Driver<InterfaceReconstructorType, 3, SourceMeshType,
293 Matpoly_Splitter, Matpoly_Clipper>;
302 SourceStateType
const & source_state,
303 TargetMeshType
const & target_mesh,
305 std::shared_ptr<InterfaceReconstructor3D> ir,
306 bool rectangular_mesh =
false)
307 : sourceMeshWrapper(source_mesh), sourceStateWrapper(source_state),
308 targetMeshWrapper(target_mesh), interface_reconstructor(ir),
309 rectangular_mesh_(rectangular_mesh), num_tols_(num_tols) {}
315 SourceStateType
const & source_state,
316 TargetMeshType
const & target_mesh,
318 bool rectangular_mesh =
false)
319 : sourceMeshWrapper(source_mesh), sourceStateWrapper(source_state),
320 targetMeshWrapper(target_mesh), rectangular_mesh_(rectangular_mesh),
321 num_tols_(num_tols) {}
338 const std::vector<int>& src_nodes)
const {
342 targetMeshWrapper.node_get_coordinates(tgt_node, &tgtxyz);
344 std::vector<std::array<Point<3>, 4>> target_tet_coords;
350 targetMeshWrapper.dual_wedges_get_coordinates(tgt_node, &target_tet_coords);
354 int nsrc = src_nodes.size();
355 std::vector<Weights_t> sources_and_weights(nsrc);
357 for (
int i = 0; i < nsrc; i++) {
358 int s = src_nodes[i];
361 sourceMeshWrapper.dual_cell_get_facetization(s, &srcpoly.
facetpoints,
364 Weights_t & this_wt = sources_and_weights[ninserted];
365 this_wt.entityID = s;
370 if (!this_wt.weights.empty() && this_wt.weights[0] > 0.0)
374 sources_and_weights.resize(ninserted);
375 return sources_and_weights;
385 SourceMeshType
const & sourceMeshWrapper;
386 SourceStateType
const & sourceStateWrapper;
387 TargetMeshType
const & targetMeshWrapper;
389 std::shared_ptr<InterfaceReconstructor3D> interface_reconstructor;
391 bool rectangular_mesh_ =
false;
399 #endif // PORTAGE_INTERSECT_INTERSECT_R3D_H_ Intersection and other tolerances to handle tiny values.
Definition: portage.h:152
Definition: intersect_polys_r3d.h:34
std::vector< double > intersect_polys_r3d(const facetedpoly_t &srcpoly, const std::vector< std::array< Point< 3 >, 4 >> &target_tet_coords, NumericTolerances_t num_tols)
Definition: intersect_polys_r3d.h:72
IntersectR3D & operator=(const IntersectR3D &)=delete
Assignment operator (disabled)
Definition: intersect_r3d.h:56
void set_material(int m)
Set the source mesh material that we have to intersect against.
Definition: intersect_r3d.h:172
void set_material(int m)
Set the source mesh material that we have to intersect against.
Definition: intersect_r3d.h:92
IntersectR3D(SourceMeshType const &source_mesh, SourceStateType const &source_state, TargetMeshType const &target_mesh, NumericTolerances_t num_tols, bool rectangular_mesh=false)
Constructor WITHOUT interface reconstructor.
Definition: intersect_r3d.h:81
void set_material(int m)
Set the source mesh material that we have to intersect against.
Definition: intersect_r3d.h:325
Definition: coredriver.h:42
std::vector< Point< 3 > > points
Definition: intersect_polys_r3d.h:41
IntersectR3D(SourceMeshType const &source_mesh, SourceStateType const &source_state, TargetMeshType const &target_mesh, NumericTolerances_t num_tols, bool rectangular_mesh=false)
Constructor WITHOUT interface reconstructor.
Definition: intersect_r3d.h:314
std::vector< Weights_t > operator()(int tgt_entity, std::vector< int > const &src_entities) const
Intersect a control volume of a target_entity with control volumes of a set of source entities...
Definition: intersect_r3d.h:102
std::vector< std::vector< int > > facetpoints
Definition: intersect_polys_r3d.h:36
IntersectR3D(SourceMeshType const &source_mesh, SourceStateType const &source_state, TargetMeshType const &target_mesh, NumericTolerances_t num_tols, bool rectangular_mesh=false)
Constructor WITHOUT interface reconstructor.
Definition: intersect_r3d.h:160