27 void torus_fem::init(){
28 cvr = poriginal_fem_->ref_convex(0);
29 dim_ = cvr->structure()->dim();
30 is_standard_fem =
false;
31 is_equiv = real_element_defined =
true;
32 is_pol = poriginal_fem_->is_polynomial();
33 is_polycomp = poriginal_fem_->is_polynomialcomp();
34 is_lag = poriginal_fem_->is_lagrange();
35 es_degree = poriginal_fem_->estimated_degree();
39 nm <<
"FEM_TORUS(" << poriginal_fem_->debug_name() <<
")";
40 debug_name_ = nm.str();
43 GMM_ASSERT1(poriginal_fem_->target_dim() == 1,
"Vectorial fems not supported");
44 size_type nb_dof_origin = poriginal_fem_->nb_dof(0);
45 for (
size_type k = 0; k < nb_dof_origin; ++k)
49 poriginal_fem_->node_of_dof(0, k));
59 { GMM_ASSERT1(
false,
"No base values, real only element."); }
62 { GMM_ASSERT1(
false,
"No grad values, real only element."); }
65 GMM_ASSERT1(
false,
"No hess values, real only element.");
69 base_tensor &t,
bool)
const{
71 GMM_ASSERT1(!(poriginal_fem_->is_on_real_element()),
"Original FEM must not be real.");
74 poriginal_fem_->base_value(c.
xref(), u_orig);
75 if (!(poriginal_fem_->is_equivalent())){
76 base_tensor u_temp = u_orig;
77 u_orig.mat_transp_reduction(u_temp, c.
M(), 0);
87 bgeot::multi_index tensor_size(u_orig.sizes());
88 tensor_size[0] *= dim_;
89 tensor_size[1] = ntarget_dim;
90 t.adjust_sizes(tensor_size);
91 for (
size_type i = 0; i < u_orig.sizes()[0]; ++i) {
92 for (dim_type j = 0; j < dim_; ++j) {
93 t(i*dim_ + j, j) = u_orig(i, 0);
101 GMM_ASSERT1(!(poriginal_fem_->is_on_real_element()),
"Original FEM must not be real.");
103 bgeot::scalar_type radius = std::abs(c.
xreal()[0]);
105 bgeot::pstored_point_tab ppt = c.pgp()->get_ppoint_tab();
107 base_tensor u_origin = pfp->grad(c.ii());
109 GMM_ASSERT1(!u_origin.empty(),
"Original FEM is unable to provide grad base value!");
111 base_tensor n_origin = pfp->val(c.ii());
113 GMM_ASSERT1(!n_origin.empty(),
"Original FEM is unable to provide base value!");
117 const bgeot::multi_index &origin_size = u_origin.sizes();
118 bgeot::multi_index tensor_size(origin_size);
119 dim_type dim_size = is_scalar_ ? 1 : dim_;
120 tensor_size[0] *= dim_size;
121 tensor_size[1] = ntarget_dim;
122 tensor_size[2] = dim_ + 1;
123 u.adjust_sizes(tensor_size);
124 for (
size_type i = 0; i < origin_size[0]; ++i) {
125 for (dim_type j = 0; j < dim_size; ++j) {
126 for (dim_type k = 0; k < dim_; ++k) {
127 u(i*dim_size+j, j, k) = u_origin(i, 0, k);
132 t.mat_transp_reduction(u, c.B(), 2);
134 if(is_scalar_)
return;
136 for (
size_type i = 0; i < origin_size[0]; ++i) {
137 t(i*dim_size, dim_, dim_) = n_origin[i] / radius;
144 GMM_ASSERT1(
false,
"Hessian not yet implemented in torus fem.");
147 void torus_fem::set_to_scalar(
bool is_scalar){
148 if(is_scalar_ == is_scalar)
return;
150 is_scalar_ = is_scalar;
156 size_type nb_dof_origin = poriginal_fem_->nb_dof(0);
157 for (
size_type k = 0; k < nb_dof_origin; ++k){
158 add_node(poriginal_fem_->dof_types()[k], poriginal_fem_->node_of_dof(0, k));
164 size_type nb_dof_origin = poriginal_fem_->nb_dof(0);
165 for (
size_type k = 0; k < nb_dof_origin; ++k)
169 poriginal_fem_->node_of_dof(0, k));
175 pfem torus_fem::get_original_pfem()
const{
return poriginal_fem_;}
182 getfem::pfem pfem_torus = std::make_shared<torus_fem>(pf);
183 dal::pstatic_stored_object_key
184 pk = std::make_shared<torus_fem_key>(key_count);
190 const torus_fem *ptorus_fem =
dynamic_cast<const torus_fem*
>(pf.get());
194 void torus_mesh_fem::adapt_to_torus_(){
198 if(poriginal_fem == 0)
continue;
200 del_torus_fem(poriginal_fem);
202 pfem pf = new_torus_fem(poriginal_fem);
203 torus_fem *pf_torus =
dynamic_cast<torus_fem*
>(
const_cast<virtual_fem*
>(pf.get()));
204 pf_torus->set_to_scalar((Qdim != 3));
216 if(pf == 0)
continue;
218 if(pf_torus == 0)
continue;
219 pf_torus->set_to_scalar((Qdim != 3));
225 torus_mesh::torus_mesh(std::string name) :
mesh(std::move(name)){}
230 bgeot::vectors_to_base_matrix(G, points_of_convex(ic));
231 G.resize(2, G.ncols());
232 auto pgt_torus = std::dynamic_pointer_cast<const bgeot::torus_geom_trans>(trans_of_convex(ic));
233 GMM_ASSERT2(pgt_torus,
"Internal error, convex is not a torus transformation.");
237 void torus_mesh::adapt(
const getfem::mesh &original_mesh){
239 GMM_ASSERT1(original_mesh.dim() == 2,
"Adapting torus feature must be a 2d mesh");
244 void torus_mesh::adapt(){
248 for(
size_type pt = 0; pt < node_tab_copy.size(); ++pt){
249 node_tab_copy[pt].resize(3);
250 this->pts.add_node(node_tab_copy[pt]);
253 for(
size_type i = 0; i < this->convex_tab.size(); ++i){
255 = bgeot::torus_structure_descriptor(convex_tab[i].cstruct);
256 convex_tab[i].cstruct = pstructure;
259 for(
size_type i = 0; i < this->gtab.size(); ++i){
261 gtab[i] = pgeom_trans;
const base_node & xreal() const
coordinates of the current point, in the real convex.
const base_node & xref() const
coordinates of the current point, in the reference convex.
Store a set of points, identifying points that are nearer than a certain very small distance.
structure passed as the argument of fem interpolation functions.
virtual void enumerate_dof() const
Renumber the degrees of freedom.
const mesh & linked_mesh() const
Return a reference to the underlying mesh.
void set_finite_element(size_type cv, pfem pf)
Set the finite element method of a convex.
virtual pfem fem_of_element(size_type cv) const
Return the basic fem associated with an element (if no fem is associated, the function will crash!...
const dal::bit_vector & convex_index() const
Get the set of convexes where a finite element has been assigned.
Describe a mesh (collection of convexes (elements) and points).
void copy_from(const mesh &m)
Clone a mesh.
void clear()
Erase the mesh.
Torus fem, the real grad base value is modified to compute radial grad of F/R.
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_...
void hess_base_value(const base_node &, base_tensor &) const
Give the value of all hessians (on ref.
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...
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.
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...
void grad_base_value(const base_node &, base_tensor &) const
Give the value of all gradients (on ref.
Mesh fem object that adapts.
void enumerate_dof(void) const
Renumber the degrees of freedom.
virtual scalar_type convex_radius_estimate(size_type ic) const
Return an estimate of the convex largest dimension.
Base class for finite element description.
Provides mesh and mesh fem of torus.
pdof_description xfem_dof(pdof_description p, size_type ind)
Description of a special dof for Xfem.
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...
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.
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
const base_matrix & M() const
non tau-equivalent transformation matrix.
pfem_precomp fem_precomp(pfem pf, bgeot::pstored_point_tab pspt, dal::pstatic_stored_object dep)
Handles precomputations for FEM.
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
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation
void add_stored_object(pstatic_stored_object_key k, pstatic_stored_object o, permanence perm)
Add an object with two optional dependencies.
void del_stored_object(const pstatic_stored_object &o, bool ignore_unstored)
Delete an object and the object which depend on it.
GEneric Tool for Finite Element Methods.