51 #ifndef BGEOT_GEOTRANS_INV_H__
52 #define BGEOT_GEOTRANS_INV_H__
65 base_matrix G, pc, K, B, CS;
71 bool has_linearized_approx =
false;
72 base_matrix K_ref_B_transp_lin;
76 const base_matrix &get_G()
const {
return G; }
79 : N(0), P(0), pgt(0), EPS(e) {}
84 : N(0), P(0), pgt(0), EPS(e)
86 init(cv.points(), pgt_);
92 : N(0), P(0), pgt(0), EPS(e)
115 scalar_type IN_EPS=1e-12,
bool project_into_element=
false);
136 scalar_type IN_EPS=1e-12,
bool project_into_element=
false);
140 scalar_type IN_EPS,
bool &converged,
bool throw_except,
141 bool project_into_element);
143 void update_linearization();
145 friend class geotrans_inv_convex_bfgs;
150 bool geotrans_changed = (pgt != pgt_);
if (geotrans_changed) pgt = pgt_;
151 GMM_ASSERT3(!nodes.empty(),
"empty points!");
152 if (N != nodes[0].size())
153 { N = nodes[0].size(); geotrans_changed =
true; }
154 if (geotrans_changed) {
155 P = pgt->structure()->dim();
156 pc.resize(pgt->nb_points() , P);
160 G.resize(N, pgt->nb_points());
162 vectors_to_base_matrix(G, nodes);
164 for (
size_type j = 0; j < G.ncols(); ++j)
165 gmm::add(gmm::scaled(mat_col(G, 0), -1.0), mat_col(Grel, j));
166 if (pgt->is_linear()) {
167 if (geotrans_changed) {
169 pgt->poly_vector_grad(Dummy, pc);
173 }
else if (pgt->complexity() > 1)
174 update_linearization();
189 void clear() { tree.
clear(); }
192 tree.reserve(std::distance(c.begin(),c.end()));
193 typename CONT::const_iterator it = c.begin(), ite = c.end();
194 for (; it != ite; ++it) tree.
add_point(*it);
208 tree.points_in_box(ipts, min, max);
234 template<
class TAB,
class CONT1,
class CONT2>
237 CONT1 &pftab, CONT2 &itab,
238 bool bruteforce=
false);
245 template<
class TAB,
class CONT1,
class CONT2>
248 CONT1 &pftab, CONT2 &itab,
253 bounding_box(min, max, cv.points(), pgt);
254 for (
size_type k=0; k < min.size(); ++k) { min[k] -= EPS; max[k] += EPS; }
255 gic.init(cv.points(),pgt);
258 else boxpts = tree.points();
261 for (
size_type l = 0; l < boxpts.size(); ++l) {
263 if (gic.
invert(boxpts[l].n, pftab[nbpt], EPS)) {
264 itab[nbpt++] = boxpts[l].i;
Geometric transformations on convexes.
Simple implementation of a KD-tree.
generic definition of a convex ( bgeot::convex_structure + vertices coordinates )
does the inversion of the geometric transformation for a given convex
bool invert(const base_node &x, base_node &xref, scalar_type IN_EPS=1e-12, bool project_into_element=false)
given the node on the real element, returns the node on the reference element (even if it is outside ...
handles the geometric inversion for a given (supposedly quite large) set of points
void add_points(const CONT &c)
Add the points contained in c to the list of points.
size_type points_in_box(kdtree_tab_type &ipts, const base_node &min, const base_node &max) const
Find all the points present in the box between min and max.
size_type nb_points() const
Number of points.
size_type add_point(base_node p)
Add point p to the list of points.
size_type points_in_convex(const convex< base_node, TAB > &cv, pgeometric_trans pgt, CONT1 &pftab, CONT2 &itab, bool bruteforce=false)
Search all the points in the convex cv, which is the transformation of the convex cref via the geomet...
Balanced tree over a set of points.
void add_point_with_id(const base_node &n, size_type i)
insert a new point, with an associated number.
size_type add_point(const base_node &n)
insert a new point
void clear()
reset the tree, remove all points
std::vector< index_node_pair > kdtree_tab_type
store a set of points with associated indexes.
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