37 #ifndef BGEOT_GEOMETRIC_TRANSFORMATION_H__
38 #define BGEOT_GEOMETRIC_TRANSFORMATION_H__
109 std::vector<size_type> vertices_;
114 void fill_standard_vertices();
118 dim_type
dim()
const {
return cvr->structure()->dim(); }
134 base_vector &val)
const = 0;
139 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;
162 void set_name(
const std::string &name){name_ = name;}
163 const std::string& debug_name()
const {
return name_;}
164 virtual void project_into_reference_convex(base_node &pt)
const
165 { cvr->project_into(pt); }
166 size_type complexity()
const {
return complexity_; }
167 virtual ~geometric_trans()
168 { DAL_STORED_OBJECT_DEBUG_DESTROYED(
this,
"Geometric transformation"); }
170 { DAL_STORED_OBJECT_DEBUG_CREATED(
this,
"Geometric transformation"); }
175 const CONT &ptab)
const {
180 for (
size_type l = 0; l < k; ++l) gmm::add(gmm::scaled(ptab[l], val[l]),P);
191 typename CONT::const_iterator it = ptab.begin();
192 min = max = *it;
size_type P = min.size();
193 base_node::iterator itmin = min.begin(), itmax = max.begin();
194 for ( ++it; it != ptab.end(); ++it) {
198 base_node::const_iterator it2 = pt.begin();
200 itmin[i] = std::min(itmin[i], it2[i]);
201 itmax[i] = std::max(itmax[i], it2[i]);
205 if (pgt && !pgt->is_linear())
207 scalar_type e = (itmax[i]-itmin[i]) * 0.2;
208 itmin[i] -= e; itmax[i] += e;
229 pyramid_geotrans(
short_type k) {
return pyramid_QK_geotrans(k); }
267 base_small_vector APIDECL
276 base_small_vector APIDECL
292 class geotrans_precomp_;
293 typedef std::shared_ptr<const geotrans_precomp_> pgeotrans_precomp;
304 pstored_point_tab pspt;
305 mutable std::vector<base_vector> c;
307 mutable std::vector<base_matrix> pc;
309 mutable std::vector<base_matrix> hpc;
312 inline const base_vector &val(
size_type i)
const
313 {
if (c.empty()) init_val();
return c[i]; }
314 inline const base_matrix &grad(
size_type i)
const
315 {
if (pc.empty()) init_grad();
return pc[i]; }
316 inline const base_matrix &hessian(
size_type i)
const
317 {
if (hpc.empty()) init_hess();
return hpc[i]; }
327 template <
typename CONT>
328 void transform(
const CONT& G,
330 template <
typename CONT,
typename VEC>
331 void transform(
const CONT& G,
size_type ii, VEC& pt)
const;
336 inline pstored_point_tab get_ppoint_tab()
const {
return pspt; }
339 { DAL_STORED_OBJECT_DEBUG_DESTROYED(
this,
"Geotrans precomp"); }
342 void init_val()
const;
343 void init_grad()
const;
344 void init_hess()
const;
350 friend pgeotrans_precomp
352 dal::pstatic_stored_object dep);
359 dal::pstatic_stored_object dep);
361 template <
typename CONT,
typename VEC>
366 if (c.empty()) init_val();
367 for (
typename CONT::const_iterator itk = G.begin();
368 itk != G.end(); ++itk, ++k)
369 gmm::add(gmm::scaled(*itk, c[j][k]), pt);
370 GMM_ASSERT1(k == pgt->nb_points(),
371 "Wrong number of points in transformation");
374 template <
typename CONT>
377 if (c.empty()) init_val();
378 pt_tab.clear(); pt_tab.resize(c.size(),
base_node(G[0].size()));
379 for (
size_type j = 0; j < c.size(); ++j) {
384 void APIDECL delete_geotrans_precomp(pgeotrans_precomp pgp);
392 std::set<pgeotrans_precomp> precomps;
397 pstored_point_tab pspt) {
398 pgeotrans_precomp p = geotrans_precomp(pg, pspt, 0);
403 for (std::set<pgeotrans_precomp>::iterator it = precomps.begin();
404 it != precomps.end(); ++it)
405 delete_geotrans_precomp(*it);
423 const base_matrix *
G_;
425 mutable base_matrix
K_, B_, B3_, B32_;
427 pgeotrans_precomp pgp_;
428 pstored_point_tab pspt_;
430 mutable scalar_type J_=0, J__=0;
431 mutable base_matrix
PC, B_factors;
432 mutable base_vector aux1, aux2;
433 mutable std::vector<long> ipvt;
434 mutable bool have_J_, have_B_, have_B3_, have_B32_, have_K_, have_cv_center_;
435 void compute_J()
const;
437 bool have_xref()
const {
return !xref_.empty(); }
438 bool have_xreal()
const {
return !xreal_.empty(); }
439 bool have_G()
const {
return G_ != 0; }
440 bool have_K()
const {
return have_K_; }
441 bool have_B()
const {
return have_B_; }
442 bool have_B3()
const {
return have_B3_; }
443 bool have_B32()
const {
return have_B32_; }
444 bool have_pgt()
const {
return pgt_ != 0; }
445 bool have_pgp()
const {
return pgp_ != 0; }
447 const base_node& xref()
const;
449 const base_node& xreal()
const;
451 const base_node& cv_center()
const;
453 const base_matrix& K()
const;
454 const base_matrix& B()
const;
455 const base_matrix& B3()
const;
456 const base_matrix& B32()
const;
459 const base_matrix&
G()
const {
return *G_; }
461 scalar_type
J()
const {
if (!have_J_) compute_J();
return J_; }
463 if (have_G())
return G().nrows();
464 else if (have_xreal())
return xreal_.size();
465 else GMM_ASSERT2(
false,
"cannot get N");
469 bgeot::pgeotrans_precomp pgp()
const {
return pgp_; }
473 if (pgt_ && !pgt()->is_linear())
474 { have_K_ = have_B_ = have_B3_ = have_B32_ = have_J_ =
false; }
475 xref_.resize(0); xreal_.resize(0);
481 void change(bgeot::pgeotrans_precomp pgp__,
483 const base_matrix& G__) {
484 G_ = &G__; pgt_ = pgp__->get_trans(); pgp_ = pgp__;
485 pspt_ = pgp__->get_ppoint_tab(); ii_ = ii__;
486 have_J_ = have_B_ = have_B3_ = have_B32_ = have_K_ =
false;
487 have_cv_center_ =
false;
488 xref_.resize(0); xreal_.resize(0); cv_center_.resize(0);
491 bgeot::pstored_point_tab pspt__,
493 const base_matrix& G__) {
494 G_ = &G__; pgt_ = pgt__; pgp_ = 0; pspt_ = pspt__; ii_ = ii__;
495 have_J_ = have_B_ = have_B3_ = have_B32_ = have_K_ =
false;
496 have_cv_center_ =
false;
497 xref_.resize(0); xreal_.resize(0); cv_center_.resize(0);
500 const base_node& xref__,
501 const base_matrix& G__) {
502 xref_ = xref__; G_ = &G__; pgt_ = pgt__; pgp_ = 0; pspt_ = 0;
504 have_J_ = have_B_ = have_B3_ = have_B32_ = have_K_ =
false;
505 have_cv_center_ =
false;
506 xreal_.resize(0); cv_center_.resize(0);
509 geotrans_interpolation_context()
510 : G_(0), pgt_(0), pgp_(0), pspt_(0), ii_(
size_type(-1)),
511 have_J_(false), have_B_(false), have_B3_(false), have_B32_(false),
512 have_K_(false), have_cv_center_(false) {}
513 geotrans_interpolation_context(bgeot::pgeotrans_precomp pgp__,
515 const base_matrix& G__)
516 : G_(&G__), pgt_(pgp__->get_trans()), pgp_(pgp__),
517 pspt_(pgp__->get_ppoint_tab()), ii_(ii__), have_J_(false), have_B_(false),
518 have_B3_(false), have_B32_(false), have_K_(false), have_cv_center_(false) {}
520 bgeot::pstored_point_tab pspt__,
522 const base_matrix& G__)
523 : G_(&G__), pgt_(pgt__), pgp_(0),
524 pspt_(pspt__), ii_(ii__), have_J_(false), have_B_(false), have_B3_(false),
525 have_B32_(false), have_K_(false), have_cv_center_(false) {}
527 const base_node& xref__,
528 const base_matrix& G__)
529 : xref_(xref__), G_(&G__), pgt_(pgt__), pgp_(0), pspt_(0),
530 ii_(
size_type(-1)), have_J_(false), have_B_(false), have_B3_(false),
531 have_B32_(false), have_K_(false), have_cv_center_(false) {}
537 typedef dal::naming_system<geometric_trans>::param_list gt_param_list;
539 void APIDECL add_geometric_trans_name
544 scalar_type lu_det(
const scalar_type *A,
size_type N);
545 scalar_type lu_inverse(scalar_type *A,
size_type N,
bool doassert =
true);
546 inline scalar_type lu_det(
const base_matrix &A)
547 {
return lu_det(&(*(A.begin())), A.nrows()); }
548 inline scalar_type lu_inverse(base_matrix &A,
bool doassert =
true)
549 {
return lu_inverse(&(*(A.begin())), A.nrows(), doassert); }
552 void mat_mult(
const scalar_type *A,
const scalar_type *B, scalar_type *C,
557 void mat_tmult(
const scalar_type *A,
const scalar_type *B, scalar_type *C,
defines and typedefs for namespace bgeot
Description of a geometric transformation between a reference element and a real element.
const stored_point_tab & geometric_nodes() const
Gives the array of geometric nodes (on reference convex)
dim_type dim() const
Dimension of the reference element.
pconvex_structure structure() const
Structure of the reference element.
virtual void poly_vector_grad(const base_node &pt, base_matrix &val) const =0
Gives the gradient of the functions vector at a certain point.
virtual void poly_vector_grad(const base_node &pt, const convex_ind_ct &ind_ct, base_matrix &val) const =0
Gives the gradient of a subgroup of the functions vector at a certain point.
pconvex_ref convex_ref() const
Pointer on the convex of reference.
virtual void poly_vector_hess(const base_node &pt, base_matrix &val) const =0
Gives the hessian of the functions vector at a certain point.
size_type nb_points() const
Number of geometric nodes.
const std::vector< size_type > & vertices() const
Gives the indices of vertices between the nodes.
bool is_linear() const
True if the transformation is linear (affine in fact).
virtual void poly_vector_val(const base_node &pt, const convex_ind_ct &ind_ct, base_vector &val) const =0
Gives the value of a subgroup of the functions vector at a certain point.
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)
virtual void poly_vector_val(const base_node &pt, base_vector &val) const =0
Gives the value of the functions vector at a certain point.
pconvex_structure basic_structure() const
Basic structure of the reference element.
size_type nb_vertices() const
Gives the number of vertices.
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...
const base_matrix & G() const
matrix whose columns are the vertices of the convex
size_type ii_
if pgp != 0, it is the same as pgp's one
const base_matrix * G_
transformed point
pgeometric_trans pgt_
see documentation (getfem kernel doc) for more details
base_node cv_center_
pointer to the matrix of real nodes of the convex
void set_ii(size_type ii__)
change the current point (assuming a geotrans_precomp_ is used)
scalar_type J() const
get the Jacobian of the geometric trans (taken at point xref() )
base_matrix K_
real center of convex (average of columns of G)
base_node xreal_
reference point
precomputed geometric transformation operations use this for repetitive evaluation of a geometric tra...
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 ...
The object geotrans_precomp_pool Allow to allocate a certain number of geotrans_precomp and automatic...
Associate a name to a method descriptor and store method descriptors.
base class for static stored objects
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.
std::shared_ptr< const convex_structure > pconvex_structure
Pointer on a convex structure description.
base_small_vector compute_unit_element_normal(const geotrans_interpolation_context &c)
Unit normal vector to an element of dimension N-1 in dimension N (a curve in 2D or a surface in 3D),...
base_matrix compute_local_basis(const geotrans_interpolation_context &c, size_type face)
return the local basis (i.e.
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...
pgeometric_trans geometric_trans_descriptor(std::string name)
Get the geometric transformation from its string name.
size_t size_type
used as the common size type in the library
pconvex_structure basic_structure(pconvex_structure cv)
Original structure (if concerned)
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation