38 #ifndef BGEOT_GEOMETRIC_TRANSFORMATION_H__ 39 #define BGEOT_GEOMETRIC_TRANSFORMATION_H__ 110 std::vector<size_type> vertices_;
114 void fill_standard_vertices();
118 dim_type
dim()
const {
return cvr->structure()->dim(); }
131 virtual void poly_vector_val(
const base_node &pt, base_vector &val)
const = 0;
133 virtual void poly_vector_val(
const base_node &pt,
const convex_ind_ct &ind_ct,
134 base_vector &val)
const = 0;
136 virtual void poly_vector_grad(
const base_node &pt, base_matrix &val)
const = 0;
138 virtual void poly_vector_grad(
const base_node &pt,
const convex_ind_ct &ind_ct,
139 base_matrix &val)
const = 0;
141 virtual void poly_vector_hess(
const base_node &pt, base_matrix &val)
const = 0;
143 virtual void compute_K_matrix(
const base_matrix &G,
const base_matrix &pc, base_matrix &K)
const;
147 const std::vector<size_type> &
vertices()
const {
return vertices_; }
150 {
return cvr->points(); }
153 {
return cvr->pspt(); }
155 const std::vector<base_small_vector> &
normals()
const 156 {
return cvr->normals(); }
160 const CONT &PTAB)
const;
166 { DAL_STORED_OBJECT_DEBUG_DESTROYED(
this,
"Geometric transformation"); }
168 { DAL_STORED_OBJECT_DEBUG_CREATED(
this,
"Geometric transformation"); }
173 const CONT &ptab)
const {
177 poly_vector_val(pt, val);
178 for (
size_type l = 0; l < k; ++l) gmm::add(gmm::scaled(ptab[l], val[l]),P);
188 const CONT &ptab, pgeometric_trans pgt = 0) {
189 typename CONT::const_iterator it = ptab.begin();
190 min = max = *it;
size_type P = min.size();
191 base_node::iterator itmin = min.begin(), itmax = max.begin();
192 for ( ++it; it != ptab.end(); ++it) {
196 base_node::const_iterator it2 = pt.begin();
198 itmin[i] = std::min(itmin[i], it2[i]);
199 itmax[i] = std::max(itmax[i], it2[i]);
203 if (pgt && !pgt->is_linear())
205 scalar_type e = (itmax[i]-itmin[i]) * 0.2;
206 itmin[i] -= e; itmax[i] += e;
216 pgeometric_trans APIDECL parallelepiped_linear_geotrans(
size_type n);
218 pgeometric_trans APIDECL prism_linear_geotrans(
size_type n);
219 pgeometric_trans APIDECL product_geotrans(pgeometric_trans pg1,
220 pgeometric_trans pg2);
221 pgeometric_trans APIDECL linear_product_geotrans(pgeometric_trans pg1,
222 pgeometric_trans pg2);
223 pgeometric_trans APIDECL Q2_incomplete_geotrans(dim_type nc);
224 pgeometric_trans APIDECL prism_incomplete_P2_geotrans();
225 pgeometric_trans APIDECL pyramid_QK_geotrans(
short_type k);
226 IS_DEPRECATED
inline pgeometric_trans APIDECL
227 pyramid_geotrans(
short_type k) {
return pyramid_QK_geotrans(k); }
228 pgeometric_trans APIDECL pyramid_Q2_incomplete_geotrans();
280 typedef std::shared_ptr<const geotrans_precomp_> pgeotrans_precomp;
290 pgeometric_trans pgt;
291 pstored_point_tab pspt;
292 mutable std::vector<base_vector> c;
294 mutable std::vector<base_matrix> pc;
296 mutable std::vector<base_matrix> hpc;
299 inline const base_vector &val(
size_type i)
const 300 {
if (c.empty()) init_val();
return c[i]; }
301 inline const base_matrix &grad(
size_type i)
const 302 {
if (pc.empty()) init_grad();
return pc[i]; }
303 inline const base_matrix &hessian(
size_type i)
const 304 {
if (hpc.empty()) init_hess();
return hpc[i]; }
314 template <
typename CONT>
315 void transform(
const CONT& G,
317 template <
typename CONT,
typename VEC>
318 void transform(
const CONT& G,
size_type ii, VEC& pt)
const;
321 pgeometric_trans get_trans()
const {
return pgt; }
323 inline pstored_point_tab get_ppoint_tab()
const {
return pspt; }
326 { DAL_STORED_OBJECT_DEBUG_DESTROYED(
this,
"Geotrans precomp"); }
329 void init_val()
const;
330 void init_grad()
const;
331 void init_hess()
const;
337 friend pgeotrans_precomp
338 geotrans_precomp(pgeometric_trans pg, pstored_point_tab ps,
339 dal::pstatic_stored_object dep);
345 geotrans_precomp(pgeometric_trans pg, pstored_point_tab ps,
346 dal::pstatic_stored_object dep);
348 template <
typename CONT,
typename VEC>
353 if (c.empty()) init_val();
354 for (
typename CONT::const_iterator itk = G.begin();
355 itk != G.end(); ++itk, ++k)
356 gmm::add(gmm::scaled(*itk, c[j][k]), pt);
357 GMM_ASSERT1(k == pgt->nb_points(),
358 "Wrong number of points in transformation");
361 template <
typename CONT>
364 if (c.empty()) init_val();
365 pt_tab.clear(); pt_tab.resize(c.size(),
base_node(G[0].size()));
366 for (
size_type j = 0; j < c.size(); ++j) {
367 transform(G, j, pt_tab[j]);
371 void APIDECL delete_geotrans_precomp(pgeotrans_precomp pgp);
379 std::set<pgeotrans_precomp> precomps;
383 pgeotrans_precomp operator()(pgeometric_trans pg,
384 pstored_point_tab pspt) {
385 pgeotrans_precomp p = geotrans_precomp(pg, pspt, 0);
390 for (std::set<pgeotrans_precomp>::iterator it = precomps.begin();
391 it != precomps.end(); ++it)
392 delete_geotrans_precomp(*it);
410 const base_matrix *
G_;
412 mutable base_matrix
K_, B_, B3_, B32_;
414 pgeotrans_precomp pgp_;
415 pstored_point_tab pspt_;
417 mutable scalar_type
J_, J__;
418 mutable base_matrix
PC, B_factors;
419 mutable base_vector aux1, aux2;
420 mutable std::vector<long> ipvt;
421 mutable bool have_J_, have_B_, have_B3_, have_B32_, have_K_, have_cv_center_;
422 void compute_J()
const;
424 bool have_xref()
const {
return !xref_.empty(); }
425 bool have_xreal()
const {
return !xreal_.empty(); }
426 bool have_G()
const {
return G_ != 0; }
427 bool have_K()
const {
return have_K_; }
428 bool have_B()
const {
return have_B_; }
429 bool have_B3()
const {
return have_B3_; }
430 bool have_B32()
const {
return have_B32_; }
431 bool have_pgt()
const {
return pgt_ != 0; }
432 bool have_pgp()
const {
return pgp_ != 0; }
440 const base_matrix& K()
const;
441 const base_matrix& B()
const;
442 const base_matrix& B3()
const;
443 const base_matrix& B32()
const;
446 const base_matrix&
G()
const {
return *G_; }
448 scalar_type
J()
const {
if (!have_J_) compute_J();
return J_; }
450 if (have_G())
return G().nrows();
451 else if (have_xreal())
return xreal_.size();
452 else GMM_ASSERT2(
false,
"cannot get N");
456 bgeot::pgeotrans_precomp pgp()
const {
return pgp_; }
460 if (pgt_ && !pgt()->is_linear())
461 { have_K_ = have_B_ = have_B3_ = have_B32_ = have_J_ =
false; }
462 xref_.resize(0); xreal_.resize(0);
468 void change(bgeot::pgeotrans_precomp pgp__,
470 const base_matrix& G__) {
471 G_ = &G__; pgt_ = pgp__->get_trans(); pgp_ = pgp__;
472 pspt_ = pgp__->get_ppoint_tab(); ii_ = ii__;
473 have_J_ = have_B_ = have_B3_ = have_B32_ = have_K_ =
false;
474 have_cv_center_ =
false;
475 xref_.resize(0); xreal_.resize(0); cv_center_.resize(0);
478 bgeot::pstored_point_tab pspt__,
480 const base_matrix& G__) {
481 G_ = &G__; pgt_ = pgt__; pgp_ = 0; pspt_ = pspt__; ii_ = ii__;
482 have_J_ = have_B_ = have_B3_ = have_B32_ = have_K_ =
false;
483 have_cv_center_ =
false;
484 xref_.resize(0); xreal_.resize(0); cv_center_.resize(0);
488 const base_matrix& G__) {
489 xref_ = xref__; G_ = &G__; pgt_ = pgt__; pgp_ = 0; pspt_ = 0;
491 have_J_ = have_B_ = have_B3_ = have_B32_ = have_K_ =
false;
492 have_cv_center_ =
false;
493 xreal_.resize(0); cv_center_.resize(0);
497 : G_(0), pgt_(0), pgp_(0), pspt_(0), ii_(
size_type(-1)),
498 have_J_(
false), have_B_(
false), have_B3_(
false), have_B32_(
false),
499 have_K_(
false), have_cv_center_(
false) {}
502 const base_matrix& G__)
503 : G_(&G__), pgt_(pgp__->get_trans()), pgp_(pgp__),
504 pspt_(pgp__->get_ppoint_tab()), ii_(ii__), have_J_(
false), have_B_(
false),
505 have_B3_(
false), have_B32_(
false), have_K_(
false), have_cv_center_(
false) {}
507 bgeot::pstored_point_tab pspt__,
509 const base_matrix& G__)
510 : G_(&G__), pgt_(pgt__), pgp_(0),
511 pspt_(pspt__), ii_(ii__), have_J_(
false), have_B_(
false), have_B3_(
false),
512 have_B32_(
false), have_K_(
false), have_cv_center_(
false) {}
515 const base_matrix& G__)
516 : xref_(xref__), G_(&G__), pgt_(pgt__), pgp_(0), pspt_(0),
517 ii_(
size_type(-1)),have_J_(
false), have_B_(
false), have_B3_(
false),
518 have_B32_(
false), have_K_(
false), have_cv_center_(
false) {}
524 typedef dal::naming_system<geometric_trans>::param_list gt_param_list;
526 void APIDECL add_geometric_trans_name
531 scalar_type lu_det(
const scalar_type *A,
size_type N);
532 scalar_type lu_inverse(scalar_type *A,
size_type N,
bool doassert =
true);
533 inline scalar_type lu_det(
const base_matrix &A)
534 {
return lu_det(&(*(A.begin())), A.nrows()); }
535 inline scalar_type lu_inverse(base_matrix &A,
bool doassert =
true)
536 {
return lu_inverse(&(*(A.begin())), A.nrows(), doassert); }
539 void mat_mult(
const scalar_type *A,
const scalar_type *B, scalar_type *C,
544 void mat_tmult(
const scalar_type *A,
const scalar_type *B, scalar_type *C,
base_matrix compute_local_basis(const geotrans_interpolation_context &c, size_type face)
return the local basis (i.e.
const base_matrix * G_
transformed point
scalar_type J_
index of current point in the pgp
base class for static stored objects
The object geotrans_precomp_pool Allow to allocate a certain number of geotrans_precomp and automatic...
Description of a geometric transformation between a reference element and a real element.
size_type nb_vertices() const
Gives the number of vertices.
size_type complexity() const
Compute the gradient at point x, pc is resized to [nb_points() x dim()] if the transformation is line...
pgeometric_trans pgt_
see documentation (getfem kernel doc) for more details
const std::vector< base_small_vector > & normals() const
Gives the array of the normals to faces (on reference convex)
the geotrans_interpolation_context structure is passed as the argument of geometric transformation in...
pgeometric_trans geometric_trans_descriptor(std::string name)
Get the geometric transformation from its string name.
base_node transform(const base_node &pt, const CONT &PTAB) const
Apply the geometric transformation to point pt, PTAB contains the points of the real convex...
pstored_point_tab pgeometric_nodes() const
Gives the array of geometric nodes (on reference convex)
scalar_type J() const
get the Jacobian of the geometric trans (taken at point xref() )
Associate a name to a method descriptor and store method descriptors.
std::shared_ptr< const convex_structure > pconvex_structure
Pointer on a convex structure description.
size_t size_type
used as the common size type in the library
precomputed geometric transformation operations use this for repetitive evaluation of a geometric tra...
bool is_linear() const
True if the transformation is linear (affine in fact).
size_type nb_points() const
Number of geometric nodes.
base_node cv_center_
pointer to the matrix of real nodes of the convex
size_type ii_
if pgp != 0, it is the same as pgp's one
base_matrix K_
real center of convex (average of columns of G)
const stored_point_tab & geometric_nodes() const
Gives the array of geometric nodes (on reference convex)
pconvex_structure basic_structure() const
Basic structure of the reference element.
gmm::uint16_type short_type
used as the common short type integer in the library
std::string name_of_geometric_trans(pgeometric_trans p)
Get the string name of a geometric transformation.
base_node xreal_
reference point
pconvex_ref convex_ref() const
Pointer on the convex of reference.
base_small_vector compute_normal(const geotrans_interpolation_context &c, size_type face)
norm of returned vector is the ratio between the face surface on the real element and the face surfac...
void transform(const CONT &G, stored_point_tab &pt_tab) const
Apply the geometric transformation from the reference convex to the convex whose vertices are stored ...
const std::vector< size_type > & vertices() const
Gives the indices of vertices between the nodes.
pconvex_structure basic_structure(pconvex_structure cv)
Original structure (if concerned)
const base_matrix & G() const
matrix whose columns are the vertices of the convex
pconvex_structure structure() const
Structure of the reference element.
defines and typedefs for namespace bgeot
dim_type dim() const
Dimension of the reference element.
void set_ii(size_type ii__)
change the current point (assuming a geotrans_precomp_ is used)
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation