38 #ifndef BGEOT_GEOMETRIC_TRANSFORMATION_H__
39 #define BGEOT_GEOMETRIC_TRANSFORMATION_H__
110 std::vector<size_type> vertices_;
115 void fill_standard_vertices();
119 dim_type
dim()
const {
return cvr->structure()->dim(); }
135 base_vector &val)
const = 0;
140 base_matrix &val)
const = 0;
144 virtual void compute_K_matrix(
const base_matrix &G,
const base_matrix &pc, base_matrix &K)
const;
148 const std::vector<size_type> &
vertices()
const {
return vertices_; }
151 {
return cvr->points(); }
154 {
return cvr->pspt(); }
156 const std::vector<base_small_vector> &
normals()
const
157 {
return cvr->normals(); }
161 const CONT &PTAB)
const;
163 void set_name(
const std::string &name){name_ = name;}
164 const std::string& debug_name()
const {
return name_;}
165 virtual void project_into_reference_convex(base_node &pt)
const
166 { cvr->project_into(pt); }
167 size_type complexity()
const {
return complexity_; }
168 virtual ~geometric_trans()
169 { DAL_STORED_OBJECT_DEBUG_DESTROYED(
this,
"Geometric transformation"); }
171 { DAL_STORED_OBJECT_DEBUG_CREATED(
this,
"Geometric transformation"); }
176 const CONT &ptab)
const {
181 for (
size_type l = 0; l < k; ++l) gmm::add(gmm::scaled(ptab[l], val[l]),P);
192 typename CONT::const_iterator it = ptab.begin();
193 min = max = *it;
size_type P = min.size();
194 base_node::iterator itmin = min.begin(), itmax = max.begin();
195 for ( ++it; it != ptab.end(); ++it) {
199 base_node::const_iterator it2 = pt.begin();
201 itmin[i] = std::min(itmin[i], it2[i]);
202 itmax[i] = std::max(itmax[i], it2[i]);
206 if (pgt && !pgt->is_linear())
208 scalar_type e = (itmax[i]-itmin[i]) * 0.2;
209 itmin[i] -= e; itmax[i] += e;
230 pyramid_geotrans(
short_type k) {
return pyramid_QK_geotrans(k); }
268 base_small_vector APIDECL
284 class geotrans_precomp_;
285 typedef std::shared_ptr<const geotrans_precomp_> pgeotrans_precomp;
296 pstored_point_tab pspt;
297 mutable std::vector<base_vector> c;
299 mutable std::vector<base_matrix> pc;
301 mutable std::vector<base_matrix> hpc;
304 inline const base_vector &val(
size_type i)
const
305 {
if (c.empty()) init_val();
return c[i]; }
306 inline const base_matrix &grad(
size_type i)
const
307 {
if (pc.empty()) init_grad();
return pc[i]; }
308 inline const base_matrix &hessian(
size_type i)
const
309 {
if (hpc.empty()) init_hess();
return hpc[i]; }
319 template <
typename CONT>
320 void transform(
const CONT& G,
322 template <
typename CONT,
typename VEC>
323 void transform(
const CONT& G,
size_type ii, VEC& pt)
const;
328 inline pstored_point_tab get_ppoint_tab()
const {
return pspt; }
331 { DAL_STORED_OBJECT_DEBUG_DESTROYED(
this,
"Geotrans precomp"); }
334 void init_val()
const;
335 void init_grad()
const;
336 void init_hess()
const;
342 friend pgeotrans_precomp
344 dal::pstatic_stored_object dep);
351 dal::pstatic_stored_object dep);
353 template <
typename CONT,
typename VEC>
358 if (c.empty()) init_val();
359 for (
typename CONT::const_iterator itk = G.begin();
360 itk != G.end(); ++itk, ++k)
361 gmm::add(gmm::scaled(*itk, c[j][k]), pt);
362 GMM_ASSERT1(k == pgt->nb_points(),
363 "Wrong number of points in transformation");
366 template <
typename CONT>
369 if (c.empty()) init_val();
370 pt_tab.clear(); pt_tab.resize(c.size(),
base_node(G[0].size()));
371 for (
size_type j = 0; j < c.size(); ++j) {
376 void APIDECL delete_geotrans_precomp(pgeotrans_precomp pgp);
384 std::set<pgeotrans_precomp> precomps;
389 pstored_point_tab pspt) {
390 pgeotrans_precomp p = geotrans_precomp(pg, pspt, 0);
395 for (std::set<pgeotrans_precomp>::iterator it = precomps.begin();
396 it != precomps.end(); ++it)
397 delete_geotrans_precomp(*it);
415 const base_matrix *
G_;
417 mutable base_matrix
K_, B_, B3_, B32_;
419 pgeotrans_precomp pgp_;
420 pstored_point_tab pspt_;
422 mutable scalar_type J_=0, J__=0;
423 mutable base_matrix
PC, B_factors;
424 mutable base_vector aux1, aux2;
425 mutable std::vector<long> ipvt;
426 mutable bool have_J_, have_B_, have_B3_, have_B32_, have_K_, have_cv_center_;
427 void compute_J()
const;
429 bool have_xref()
const {
return !xref_.empty(); }
430 bool have_xreal()
const {
return !xreal_.empty(); }
431 bool have_G()
const {
return G_ != 0; }
432 bool have_K()
const {
return have_K_; }
433 bool have_B()
const {
return have_B_; }
434 bool have_B3()
const {
return have_B3_; }
435 bool have_B32()
const {
return have_B32_; }
436 bool have_pgt()
const {
return pgt_ != 0; }
437 bool have_pgp()
const {
return pgp_ != 0; }
439 const base_node& xref()
const;
441 const base_node& xreal()
const;
443 const base_node& cv_center()
const;
445 const base_matrix& K()
const;
446 const base_matrix& B()
const;
447 const base_matrix& B3()
const;
448 const base_matrix& B32()
const;
451 const base_matrix&
G()
const {
return *G_; }
453 scalar_type
J()
const {
if (!have_J_) compute_J();
return J_; }
455 if (have_G())
return G().nrows();
456 else if (have_xreal())
return xreal_.size();
457 else GMM_ASSERT2(
false,
"cannot get N");
461 bgeot::pgeotrans_precomp pgp()
const {
return pgp_; }
465 if (pgt_ && !pgt()->is_linear())
466 { have_K_ = have_B_ = have_B3_ = have_B32_ = have_J_ =
false; }
467 xref_.resize(0); xreal_.resize(0);
473 void change(bgeot::pgeotrans_precomp pgp__,
475 const base_matrix& G__) {
476 G_ = &G__; pgt_ = pgp__->get_trans(); pgp_ = pgp__;
477 pspt_ = pgp__->get_ppoint_tab(); ii_ = ii__;
478 have_J_ = have_B_ = have_B3_ = have_B32_ = have_K_ =
false;
479 have_cv_center_ =
false;
480 xref_.resize(0); xreal_.resize(0); cv_center_.resize(0);
483 bgeot::pstored_point_tab pspt__,
485 const base_matrix& G__) {
486 G_ = &G__; pgt_ = pgt__; pgp_ = 0; pspt_ = pspt__; ii_ = ii__;
487 have_J_ = have_B_ = have_B3_ = have_B32_ = have_K_ =
false;
488 have_cv_center_ =
false;
489 xref_.resize(0); xreal_.resize(0); cv_center_.resize(0);
492 const base_node& xref__,
493 const base_matrix& G__) {
494 xref_ = xref__; G_ = &G__; pgt_ = pgt__; pgp_ = 0; pspt_ = 0;
496 have_J_ = have_B_ = have_B3_ = have_B32_ = have_K_ =
false;
497 have_cv_center_ =
false;
498 xreal_.resize(0); cv_center_.resize(0);
501 geotrans_interpolation_context()
502 : G_(0), pgt_(0), pgp_(0), pspt_(0), ii_(
size_type(-1)),
503 have_J_(false), have_B_(false), have_B3_(false), have_B32_(false),
504 have_K_(false), have_cv_center_(false) {}
505 geotrans_interpolation_context(bgeot::pgeotrans_precomp pgp__,
507 const base_matrix& G__)
508 : G_(&G__), pgt_(pgp__->get_trans()), pgp_(pgp__),
509 pspt_(pgp__->get_ppoint_tab()), ii_(ii__), have_J_(false), have_B_(false),
510 have_B3_(false), have_B32_(false), have_K_(false), have_cv_center_(false) {}
512 bgeot::pstored_point_tab pspt__,
514 const base_matrix& G__)
515 : G_(&G__), pgt_(pgt__), pgp_(0),
516 pspt_(pspt__), ii_(ii__), have_J_(false), have_B_(false), have_B3_(false),
517 have_B32_(false), have_K_(false), have_cv_center_(false) {}
519 const base_node& xref__,
520 const base_matrix& G__)
521 : xref_(xref__), G_(&G__), pgt_(pgt__), pgp_(0), pspt_(0),
522 ii_(
size_type(-1)), have_J_(false), have_B_(false), have_B3_(false),
523 have_B32_(false), have_K_(false), have_cv_center_(false) {}
529 typedef dal::naming_system<geometric_trans>::param_list gt_param_list;
531 void APIDECL add_geometric_trans_name
536 scalar_type lu_det(
const scalar_type *A,
size_type N);
537 scalar_type lu_inverse(scalar_type *A,
size_type N,
bool doassert =
true);
538 inline scalar_type lu_det(
const base_matrix &A)
539 {
return lu_det(&(*(A.begin())), A.nrows()); }
540 inline scalar_type lu_inverse(base_matrix &A,
bool doassert =
true)
541 {
return lu_inverse(&(*(A.begin())), A.nrows(), doassert); }
544 void mat_mult(
const scalar_type *A,
const scalar_type *B, scalar_type *C,
549 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