29 const auto it = ids.find(ipt);
37 void mesh_trans_inv::points_on_convex(
size_type cv,
38 std::vector<size_type> &itab)
const {
39 itab.resize(pts_in_cvx[cv].size());
size_type j = 0;
40 for (
auto it = pts_in_cvx[cv].cbegin(); it != pts_in_cvx[cv].cend(); ++it)
45 auto it = pts_in_cvx[cv].cbegin();
46 for (
size_type j = 0; it != pts_in_cvx[cv].cend() && j < i; ++it, ++j) {}
47 GMM_ASSERT1(it != pts_in_cvx[cv].cend(),
"internal error");
51 void mesh_trans_inv::distribute(
int extrapolation, mesh_region rg_source) {
55 rg_source.from_mesh(msh);
56 rg_source.error_if_not_convexes();
58 bool projection_into_element(extrapolation == 0);
61 size_type nbcvx = msh.nb_allocated_convex();
63 pts_in_cvx.resize(nbcvx);
64 ref_coords.resize(nbpts);
67 std::vector<size_type> cvx_of_pt(nbpts);
68 std::vector<double> dist(nbpts);
69 dal::bit_vector remaining_pts, cv_on_bound;
70 remaining_pts.add(0, nbpts);
72 bool identity_map = all_convexes && (nbpts == msh.nb_points());
75 dal::bv_visitor ip(msh.points_index());
79 GMM_ASSERT1(!ip.finished(),
"internal error, not enouph points in mesh?");
80 base_node diff(msh.points()[ip]);
81 gmm::add(gmm::scaled(ind_node.n, -1.0), diff);
82 if (gmm::vect_norm2(diff) < EPS) {
89 mesh_pt = msh.search_point(ind_node.n, 1e-6);
91 size_type cv = msh.first_convex_of_point(mesh_pt);
94 gic.init(msh.points_of_convex(cv), pgt);
97 if (gic.invert(ind_node.n, pt_ref, converged, EPS,
98 projection_into_element)) {
99 double isin = pgt->convex_ref()->is_in(pt_ref);
101 pts_in_cvx[cv].insert(ind);
102 ref_coords[ind] = pt_ref;
105 remaining_pts.sup(ind);
111 scalar_type
mult = scalar_type(1);
113 for (dal::bv_visitor j(rg_source.index()); !j.finished(); ++j) {
114 if (mult > scalar_type(1) && !(cv_on_bound.is_in(j)))
118 bounding_box(min, max, msh.points_of_convex(j), pgt);
119 for (
size_type k=0; k < min.size(); ++k) {
123 if (extrapolation == 2) {
124 if (mult == scalar_type(1))
125 for (
short_type f = 0; f < msh.nb_faces_of_convex(j); ++f) {
126 size_type neighbor_cv = msh.neighbor_of_convex(j, f);
127 if (!all_convexes && neighbor_cv !=
size_type(-1)) {
129 if (!rg_source.is_in(neighbor_cv))
134 if (cv_on_bound.is_in(j)) {
135 scalar_type h = scalar_type(0);
137 h = std::max(h, max[k] - min[k]);
138 for (
size_type k=0; k < min.size(); ++k) {
145 points_in_box(boxpts, min, max);
146 if (boxpts.size() > 0)
147 gic.init(msh.points_of_convex(j), pgt);
151 if (remaining_pts[ind] || dist[ind] > 0) {
154 bool gicisin = gic.invert(ind_node.n, pt_ref, converged, EPS,
155 projection_into_element);
156 bool toadd = extrapolation || gicisin;
157 double isin = pgt->convex_ref()->is_in(pt_ref);
159 if (toadd && !(remaining_pts[ind])) {
160 if (isin < dist[ind])
161 pts_in_cvx[cvx_of_pt[ind]].erase(ind);
170 pts_in_cvx[j].insert(ind);
171 ref_coords[ind] = pt_ref;
174 remaining_pts.sup(ind);
179 mult *= scalar_type(2);
180 }
while (remaining_pts.card() > 0 && extrapolation == 2);
static mesh_region all_convexes()
provide a default value for the mesh_region parameters of assembly procedures etc.
Interpolation of fields from a mesh_fem onto another.
void mult(const L1 &l1, const L2 &l2, L3 &l3)
*/
void add(const L1 &l1, L2 &l2)
*/
std::vector< index_node_pair > kdtree_tab_type
store a set of points with associated indexes.
gmm::uint16_type short_type
used as the common short type integer in the library
size_t size_type
used as the common size type in the library
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation
GEneric Tool for Finite Element Methods.
store a point and the associated index for the kdtree.