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
283 class geotrans_precomp_;
284 typedef std::shared_ptr<const geotrans_precomp_> pgeotrans_precomp;
295 pstored_point_tab pspt;
296 mutable std::vector<base_vector> c;
298 mutable std::vector<base_matrix> pc;
300 mutable std::vector<base_matrix> hpc;
303 inline const base_vector &val(
size_type i)
const
304 {
if (c.empty()) init_val();
return c[i]; }
305 inline const base_matrix &grad(
size_type i)
const
306 {
if (pc.empty()) init_grad();
return pc[i]; }
307 inline const base_matrix &hessian(
size_type i)
const
308 {
if (hpc.empty()) init_hess();
return hpc[i]; }
318 template <
typename CONT>
319 void transform(
const CONT& G,
321 template <
typename CONT,
typename VEC>
322 void transform(
const CONT& G,
size_type ii, VEC& pt)
const;
327 inline pstored_point_tab get_ppoint_tab()
const {
return pspt; }
330 { DAL_STORED_OBJECT_DEBUG_DESTROYED(
this,
"Geotrans precomp"); }
333 void init_val()
const;
334 void init_grad()
const;
335 void init_hess()
const;
341 friend pgeotrans_precomp
343 dal::pstatic_stored_object dep);
350 dal::pstatic_stored_object dep);
352 template <
typename CONT,
typename VEC>
357 if (c.empty()) init_val();
358 for (
typename CONT::const_iterator itk = G.begin();
359 itk != G.end(); ++itk, ++k)
360 gmm::add(gmm::scaled(*itk, c[j][k]), pt);
361 GMM_ASSERT1(k == pgt->nb_points(),
362 "Wrong number of points in transformation");
365 template <
typename CONT>
368 if (c.empty()) init_val();
369 pt_tab.clear(); pt_tab.resize(c.size(),
base_node(G[0].size()));
370 for (
size_type j = 0; j < c.size(); ++j) {
375 void APIDECL delete_geotrans_precomp(pgeotrans_precomp pgp);
383 std::set<pgeotrans_precomp> precomps;
388 pstored_point_tab pspt) {
389 pgeotrans_precomp p = geotrans_precomp(pg, pspt, 0);
394 for (std::set<pgeotrans_precomp>::iterator it = precomps.begin();
395 it != precomps.end(); ++it)
396 delete_geotrans_precomp(*it);
414 const base_matrix *
G_;
416 mutable base_matrix
K_, B_, B3_, B32_;
418 pgeotrans_precomp pgp_;
419 pstored_point_tab pspt_;
421 mutable scalar_type J_=0, J__=0;
422 mutable base_matrix
PC, B_factors;
423 mutable base_vector aux1, aux2;
424 mutable std::vector<long> ipvt;
425 mutable bool have_J_, have_B_, have_B3_, have_B32_, have_K_, have_cv_center_;
426 void compute_J()
const;
428 bool have_xref()
const {
return !xref_.empty(); }
429 bool have_xreal()
const {
return !xreal_.empty(); }
430 bool have_G()
const {
return G_ != 0; }
431 bool have_K()
const {
return have_K_; }
432 bool have_B()
const {
return have_B_; }
433 bool have_B3()
const {
return have_B3_; }
434 bool have_B32()
const {
return have_B32_; }
435 bool have_pgt()
const {
return pgt_ != 0; }
436 bool have_pgp()
const {
return pgp_ != 0; }
438 const base_node& xref()
const;
440 const base_node& xreal()
const;
442 const base_node& cv_center()
const;
444 const base_matrix& K()
const;
445 const base_matrix& B()
const;
446 const base_matrix& B3()
const;
447 const base_matrix& B32()
const;
450 const base_matrix&
G()
const {
return *G_; }
452 scalar_type
J()
const {
if (!have_J_) compute_J();
return J_; }
454 if (have_G())
return G().nrows();
455 else if (have_xreal())
return xreal_.size();
456 else GMM_ASSERT2(
false,
"cannot get N");
460 bgeot::pgeotrans_precomp pgp()
const {
return pgp_; }
464 if (pgt_ && !pgt()->is_linear())
465 { have_K_ = have_B_ = have_B3_ = have_B32_ = have_J_ =
false; }
466 xref_.resize(0); xreal_.resize(0);
472 void change(bgeot::pgeotrans_precomp pgp__,
474 const base_matrix& G__) {
475 G_ = &G__; pgt_ = pgp__->get_trans(); pgp_ = pgp__;
476 pspt_ = pgp__->get_ppoint_tab(); ii_ = ii__;
477 have_J_ = have_B_ = have_B3_ = have_B32_ = have_K_ =
false;
478 have_cv_center_ =
false;
479 xref_.resize(0); xreal_.resize(0); cv_center_.resize(0);
482 bgeot::pstored_point_tab pspt__,
484 const base_matrix& G__) {
485 G_ = &G__; pgt_ = pgt__; pgp_ = 0; pspt_ = pspt__; 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 const base_node& xref__,
492 const base_matrix& G__) {
493 xref_ = xref__; G_ = &G__; pgt_ = pgt__; pgp_ = 0; pspt_ = 0;
495 have_J_ = have_B_ = have_B3_ = have_B32_ = have_K_ =
false;
496 have_cv_center_ =
false;
497 xreal_.resize(0); cv_center_.resize(0);
500 geotrans_interpolation_context()
501 : G_(0), pgt_(0), pgp_(0), pspt_(0), ii_(
size_type(-1)),
502 have_J_(false), have_B_(false), have_B3_(false), have_B32_(false),
503 have_K_(false), have_cv_center_(false) {}
504 geotrans_interpolation_context(bgeot::pgeotrans_precomp pgp__,
506 const base_matrix& G__)
507 : G_(&G__), pgt_(pgp__->get_trans()), pgp_(pgp__),
508 pspt_(pgp__->get_ppoint_tab()), ii_(ii__), have_J_(false), have_B_(false),
509 have_B3_(false), have_B32_(false), have_K_(false), have_cv_center_(false) {}
511 bgeot::pstored_point_tab pspt__,
513 const base_matrix& G__)
514 : G_(&G__), pgt_(pgt__), pgp_(0),
515 pspt_(pspt__), ii_(ii__), have_J_(false), have_B_(false), have_B3_(false),
516 have_B32_(false), have_K_(false), have_cv_center_(false) {}
518 const base_node& xref__,
519 const base_matrix& G__)
520 : xref_(xref__), G_(&G__), pgt_(pgt__), pgp_(0), pspt_(0),
521 ii_(
size_type(-1)), have_J_(false), have_B_(false), have_B3_(false),
522 have_B32_(false), have_K_(false), have_cv_center_(false) {}
528 typedef dal::naming_system<geometric_trans>::param_list gt_param_list;
530 void APIDECL add_geometric_trans_name
535 scalar_type lu_det(
const scalar_type *A,
size_type N);
536 scalar_type lu_inverse(scalar_type *A,
size_type N,
bool doassert =
true);
537 inline scalar_type lu_det(
const base_matrix &A)
538 {
return lu_det(&(*(A.begin())), A.nrows()); }
539 inline scalar_type lu_inverse(base_matrix &A,
bool doassert =
true)
540 {
return lu_inverse(&(*(A.begin())), A.nrows(), doassert); }
543 void mat_mult(
const scalar_type *A,
const scalar_type *B, scalar_type *C,
548 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_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