28 void torus_fem::init(){
29 cvr = poriginal_fem_->ref_convex(0);
30 dim_ = cvr->structure()->dim();
31 is_standard_fem =
false;
32 is_equiv = real_element_defined =
true;
33 is_pol = poriginal_fem_->is_polynomial();
34 is_polycomp = poriginal_fem_->is_polynomialcomp();
35 is_lag = poriginal_fem_->is_lagrange();
36 es_degree = poriginal_fem_->estimated_degree();
40 nm <<
"FEM_TORUS(" << poriginal_fem_->debug_name() <<
")";
41 debug_name_ = nm.str();
44 GMM_ASSERT1(poriginal_fem_->target_dim() == 1,
"Vectorial fems not supported");
45 size_type nb_dof_origin = poriginal_fem_->nb_dof(0);
46 for (
size_type k = 0; k < nb_dof_origin; ++k)
50 poriginal_fem_->node_of_dof(0, k));
60 { GMM_ASSERT1(
false,
"No base values, real only element."); }
63 { GMM_ASSERT1(
false,
"No grad values, real only element."); }
66 GMM_ASSERT1(
false,
"No hess values, real only element.");
70 base_tensor &t,
bool)
const{
72 GMM_ASSERT1(!(poriginal_fem_->is_on_real_element()),
"Original FEM must not be real.");
75 poriginal_fem_->base_value(c.
xref(), u_orig);
76 if (!(poriginal_fem_->is_equivalent())){
77 base_tensor u_temp = u_orig;
78 u_orig.mat_transp_reduction(u_temp, c.
M(), 0);
88 bgeot::multi_index tensor_size(u_orig.sizes());
89 tensor_size[0] *= dim_;
90 tensor_size[1] = ntarget_dim;
91 t.adjust_sizes(tensor_size);
92 for (
size_type i = 0; i < u_orig.sizes()[0]; ++i) {
93 for (dim_type j = 0; j < dim_; ++j) {
94 t(i*dim_ + j, j) = u_orig(i, 0);
102 GMM_ASSERT1(!(poriginal_fem_->is_on_real_element()),
"Original FEM must not be real.");
104 bgeot::scalar_type radius = std::abs(c.
xreal()[0]);
106 bgeot::pstored_point_tab ppt = c.pgp()->get_ppoint_tab();
108 base_tensor u_origin = pfp->grad(c.ii());
110 GMM_ASSERT1(!u_origin.empty(),
"Original FEM is unable to provide grad base value!");
112 base_tensor n_origin = pfp->val(c.ii());
114 GMM_ASSERT1(!n_origin.empty(),
"Original FEM is unable to provide base value!");
118 const bgeot::multi_index &origin_size = u_origin.sizes();
119 bgeot::multi_index tensor_size(origin_size);
120 dim_type dim_size = is_scalar_ ? 1 : dim_;
121 tensor_size[0] *= dim_size;
122 tensor_size[1] = ntarget_dim;
123 tensor_size[2] = dim_ + 1;
124 u.adjust_sizes(tensor_size);
125 for (
size_type i = 0; i < origin_size[0]; ++i) {
126 for (dim_type j = 0; j < dim_size; ++j) {
127 for (dim_type k = 0; k < dim_; ++k) {
128 u(i*dim_size+j, j, k) = u_origin(i, 0, k);
133 t.mat_transp_reduction(u, c.B(), 2);
135 if(is_scalar_)
return;
137 for (
size_type i = 0; i < origin_size[0]; ++i) {
138 t(i*dim_size, dim_, dim_) = n_origin[i] / radius;
145 GMM_ASSERT1(
false,
"Hessian not yet implemented in torus fem.");
148 void torus_fem::set_to_scalar(
bool is_scalar){
149 if(is_scalar_ == is_scalar)
return;
151 is_scalar_ = is_scalar;
157 size_type nb_dof_origin = poriginal_fem_->nb_dof(0);
158 for (
size_type k = 0; k < nb_dof_origin; ++k){
159 add_node(poriginal_fem_->dof_types()[k], poriginal_fem_->node_of_dof(0, k));
165 size_type nb_dof_origin = poriginal_fem_->nb_dof(0);
166 for (
size_type k = 0; k < nb_dof_origin; ++k)
170 poriginal_fem_->node_of_dof(0, k));
176 pfem torus_fem::get_original_pfem()
const{
return poriginal_fem_;}
183 getfem::pfem pfem_torus = std::make_shared<torus_fem>(pf);
184 dal::pstatic_stored_object_key
185 pk = std::make_shared<torus_fem_key>(key_count);
195 void torus_mesh_fem::adapt_to_torus_(){
197 for (dal::bv_visitor cv(linked_mesh().convex_index()); !cv.finished(); ++cv){
198 pfem poriginal_fem = fem_of_element(cv);
199 if(poriginal_fem == 0)
continue;
201 del_torus_fem(poriginal_fem);
203 pfem pf = new_torus_fem(poriginal_fem);
205 pf_torus->set_to_scalar((Qdim != 3));
206 set_finite_element(cv, pf);
215 for (dal::bv_visitor cv(linked_mesh().convex_index()); !cv.finished(); ++cv){
216 pfem pf = fem_of_element(cv);
217 if(pf == 0)
continue;
219 if(pf_torus == 0)
continue;
220 pf_torus->set_to_scalar((Qdim != 3));
226 torus_mesh::torus_mesh(std::string name) :
mesh(std::move(name)){}
231 bgeot::vectors_to_base_matrix(G, points_of_convex(ic));
232 G.resize(2, G.ncols());
234 GMM_ASSERT2(pgt_torus,
"Internal error, convex is not a torus transformation.");
238 void torus_mesh::adapt(
const getfem::mesh &original_mesh){
240 GMM_ASSERT1(original_mesh.dim() == 2,
"Adapting torus feature must be a 2d mesh");
245 void torus_mesh::adapt(){
249 for(
size_type pt = 0; pt < node_tab_copy.size(); ++pt){
250 node_tab_copy[pt].resize(3);
251 this->pts.add_node(node_tab_copy[pt]);
254 for(
size_type i = 0; i < this->convex_tab.size(); ++i){
256 = bgeot::torus_structure_descriptor(convex_tab[i].cstruct);
257 convex_tab[i].cstruct = pstructure;
260 for(
size_type i = 0; i < this->gtab.size(); ++i){
262 gtab[i] = pgeom_trans;
Torus fem, the real grad base value is modified to compute radial grad of F/R.
void real_hess_base_value(const fem_interpolation_context &, base_tensor &, bool=true) const
Give the hessian of all components of the base functions at the current point of the fem_interpolatio...
Base class for finite element description.
Provides mesh and mesh fem of torus.
Describe a mesh (collection of convexes (elements) and points).
const base_matrix & M() const
non tau-equivalent transformation matrix.
void del_stored_object(const pstatic_stored_object &o, bool ignore_unstored)
Delete an object and the object which depend on it.
virtual scalar_type convex_radius_estimate(size_type ic) const
Return an estimate of the convex largest dimension.
const base_node & xreal() const
coordinates of the current point, in the real convex.
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
void copy_from(const mesh &m)
Clone a mesh.
void add_stored_object(pstatic_stored_object_key k, pstatic_stored_object o, permanence perm)
Add an object with two optional dependencies.
void hess_base_value(const base_node &, base_tensor &) const
Give the value of all hessians (on ref.
structure passed as the argument of fem interpolation functions.
void add_node(const pdof_description &d, const base_node &pt, const dal::bit_vector &faces)
internal function adding a node to an element for the creation of a finite element method...
GEneric Tool for Finite Element Methods.
void real_grad_base_value(const fem_interpolation_context &c, base_tensor &t, bool=true) const
Give the gradient of all components of the base functions at the current point of the fem_interpolati...
scalar_type APIDECL convex_radius_estimate(bgeot::pgeometric_trans pgt, const base_matrix &pts)
rough estimate of the radius of the convex using the largest eigenvalue of the jacobian of the geomet...
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
const base_node & xref() const
coordinates of the current point, in the reference convex.
void enumerate_dof(void) const
Renumber the degrees of freedom.
pfem_precomp fem_precomp(pfem pf, bgeot::pstored_point_tab pspt, dal::pstatic_stored_object dep)
Handles precomputations for FEM.
Store a set of points, identifying points that are nearer than a certain very small distance...
void real_base_value(const fem_interpolation_context &c, base_tensor &t, bool=true) const
Give the value of all components of the base functions at the current point of the fem_interpolation_...
Mesh fem object that adapts.
pdof_description xfem_dof(pdof_description p, size_type ind)
Description of a special dof for Xfem.
An adaptor that adapts a two dimensional geometric_trans to include radial dimension.
virtual void enumerate_dof() const
Renumber the degrees of freedom.
void grad_base_value(const base_node &, base_tensor &) const
Give the value of all gradients (on ref.
void base_value(const base_node &, base_tensor &) const
Give the value of all components of the base functions at the point x of the reference element...
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation