1 #ifndef INTERSECT_BOXES_H 2 #define INTERSECT_BOXES_H 10 #include "wonton/support/CoordinateSystem.h" 11 #include "wonton/support/Point.h" 26 template <
int D,
typename SourceMeshType,
typename TargetMeshType,
27 class CoordSys = Wonton::DefaultCoordSys>
37 const TargetMeshType& target_mesh)
38 : sourceMeshWrapper(source_mesh),
39 targetMeshWrapper(target_mesh) {
57 const int tgt_cell,
const std::vector<int>& src_cells)
const;
62 const SourceMeshType& sourceMeshWrapper;
65 const TargetMeshType& targetMeshWrapper;
72 template <
int D,
typename SourceMeshType,
typename TargetMeshType,
74 std::vector<Portage::Weights_t>
76 const int tgt_cell,
const std::vector<int>& src_cells)
const {
79 Wonton::Point<D> tlo, thi;
80 targetMeshWrapper.cell_get_bounds(tgt_cell, &tlo, &thi);
83 int nsrc = src_cells.size();
84 std::vector<Portage::Weights_t> sources_and_weights(nsrc);
88 for (
int i = 0; i < nsrc; ++i) {
92 Wonton::Point<D> slo, shi;
93 sourceMeshWrapper.cell_get_bounds(s, &slo, &shi);
96 Wonton::Point<D> ilo, ihi;
98 for (
int d = 0; d < D; ++d) {
99 ilo[d] = std::max(slo[d], tlo[d]);
100 ihi[d] = std::min(shi[d], thi[d]);
101 double delta = std::max(ihi[d] - ilo[d], 0.);
108 if (volume <= 0.)
continue;
114 auto & this_wt = sources_and_weights[ninserted];
115 this_wt.entityID = s;
125 Wonton::Point<D> first_moments;
126 for (
int d = 0; d < D; ++d) {
127 const auto ibar = 0.5 * (ilo[d] + ihi[d]);
128 first_moments[d] = ibar * volume;
139 CoordSys::modify_volume(volume, ilo, ihi);
140 CoordSys::modify_first_moments(first_moments, ilo, ihi);
143 auto & weights = this_wt.weights;
146 for (
int d = 0; d < D; ++d) {
147 weights[1+d] = first_moments[d];
156 sources_and_weights.resize(ninserted);
158 return sources_and_weights;
165 #endif // INTERSECT_BOXES_H IntersectBoxes(const SourceMeshType &source_mesh, const TargetMeshType &target_mesh)
Constructor with meshes.
Definition: intersect_boxes.h:36
IntersectBoxes & operator=(const IntersectBoxes &)=delete
Assignment operator (disabled)
std::vector< Portage::Weights_t > operator()(const int tgt_cell, const std::vector< int > &src_cells) const
Intersect control volume of a target box with control volumes of a set of source boxes.
Definition: intersect_boxes.h:75
IntersectBoxes()=delete
Default constructor (disabled)
Definition: coredriver.h:42
Definition: intersect_boxes.h:28