[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Markus Bürg |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Thu, 24 Aug 2017 14:00:56 -0400 (EDT) |
branch: mb-transInversion
commit acb242893041abbaf47c0543daba987c57eb902a
Author: mb <address@hidden>
Date: Thu Aug 24 20:00:20 2017 +0200
Move bgeot namespace into new file.
---
src/bgeot_geometric_trans.cc | 2 +-
src/bgeot_geotrans_inv.cc | 1 +
src/bgeot_torus.cc | 211 +++++++++++++++++++++++++++
src/getfem/{getfem_torus.h => bgeot_torus.h} | 164 +++++++--------------
src/getfem/getfem_interpolation.h | 2 +-
src/getfem/getfem_torus.h | 95 ++++--------
src/getfem_fem.cc | 1 +
src/getfem_integration.cc | 2 +-
src/getfem_torus.cc | 190 +-----------------------
9 files changed, 296 insertions(+), 372 deletions(-)
diff --git a/src/bgeot_geometric_trans.cc b/src/bgeot_geometric_trans.cc
index 954b6b2..18e4008 100644
--- a/src/bgeot_geometric_trans.cc
+++ b/src/bgeot_geometric_trans.cc
@@ -24,7 +24,7 @@
#include "getfem/dal_tree_sorted.h"
#include "getfem/bgeot_geometric_trans.h"
#include "getfem/bgeot_poly_composite.h"
-#include "getfem/getfem_torus.h"
+#include "getfem/bgeot_torus.h"
namespace bgeot {
diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc
index eddcff9..4fbe120 100644
--- a/src/bgeot_geotrans_inv.cc
+++ b/src/bgeot_geotrans_inv.cc
@@ -21,6 +21,7 @@
#include "getfem/bgeot_geotrans_inv.h"
#include "getfem/bgeot_mesh_structure.h"
+#include "getfem/bgeot_torus.h"
#include "gmm/gmm_solver_bfgs.h"
using namespace gmm;
diff --git a/src/bgeot_torus.cc b/src/bgeot_torus.cc
new file mode 100644
index 0000000..860453d
--- /dev/null
+++ b/src/bgeot_torus.cc
@@ -0,0 +1,211 @@
+/*===========================================================================
+
+ Copyright (C) 2014-2017 Liang Jin Lim
+
+ This file is a part of GetFEM++
+
+ GetFEM++ is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version along with the GCC Runtime Library
+ Exception either version 3.1 or (at your option) any later version.
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License and GCC Runtime Library Exception for more details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+===========================================================================*/
+#include "getfem/bgeot_torus.h"
+
+namespace bgeot{
+
+ /**torus_structure which extends a 2 dimensional structure with a radial
dimension*/
+ class torus_structure : public convex_structure{
+
+ friend pconvex_structure torus_structure_descriptor(pconvex_structure);
+ };
+
+ class torus_reference : public convex_of_reference{
+
+ public :
+ scalar_type is_in(const base_node& point) const{
+ GMM_ASSERT1(point.size() >= 2, "Invalid dimension of pt " << point);
+ base_node point_2d = point;
+ point_2d.resize(2);
+ return ori_ref_convex_->is_in(point_2d);
+ }
+
+ scalar_type is_in_face(bgeot::short_type f, const base_node& point) const{
+ GMM_ASSERT1(point.size() >= 2, "Invalid dimension of pt " << point);
+ base_node point2D = point;
+ point2D.resize(2);
+ return ori_ref_convex_->is_in_face(f, point2D);
+ }
+ torus_reference(bgeot::pconvex_ref ori_ref_convex){
+ ori_ref_convex_ = ori_ref_convex;
+ cvs = torus_structure_descriptor(ori_ref_convex->structure());
+ convex<base_node>::points().resize(cvs->nb_points());
+ normals_.resize(ori_ref_convex->normals().size());
+
+ const std::vector<base_small_vector> &ori_normals =
ori_ref_convex->normals();
+ const stored_point_tab &ori_points = ori_ref_convex->points();
+ for(size_type n = 0; n < ori_normals.size(); ++n){
+ normals_[n] = ori_normals[n];
+ normals_[n].resize(3);
+ }
+
+ std::copy(ori_points.begin(), ori_points.end(),
convex<base_node>::points().begin());
+ for(size_type pt = 0; pt < convex<base_node>::points().size(); ++pt){
+ convex<base_node>::points()[pt].resize(3);
+ }
+ ppoints = store_point_tab(convex<base_node>::points());
+ }
+
+ private:
+ bgeot::pconvex_ref ori_ref_convex_;
+ };
+
+ DAL_SIMPLE_KEY(torus_structure_key, pconvex_structure);
+
+ pconvex_structure torus_structure_descriptor(pconvex_structure
ori_structure){
+
+ dal::pstatic_stored_object_key
+ pk = std::make_shared<torus_structure_key>(ori_structure);
+ dal::pstatic_stored_object o = dal::search_stored_object(pk);
+ if (o) return std::dynamic_pointer_cast<const convex_structure>(o);
+
+ auto p = std::make_shared<torus_structure>();
+ pconvex_structure pcvs(p);
+ p->Nc = dim_type(ori_structure->dim() + 1);
+ p->nbpt = ori_structure->nb_points();
+ p->nbf = ori_structure->nb_faces();
+
+ p->faces_struct.resize(p->nbf);
+ p->faces.resize(p->nbf);
+
+ for (short_type j = 0; j < p->nbf; ++j){
+ p->faces_struct[j] = ori_structure->faces_structure()[j];
+ short_type nbIndex = ori_structure->nb_points_of_face(j);
+ p->faces[j].resize(nbIndex);
+ p->faces[j] = ori_structure->ind_points_of_face(j);
+ }
+
+ p->dir_points_.resize(ori_structure->ind_dir_points().size());
+ p->dir_points_ = ori_structure->ind_dir_points();
+
+ p->basic_pcvs = basic_structure(ori_structure);
+
+ dal::add_stored_object(pk, pcvs, dal::PERMANENT_STATIC_OBJECT);
+ return pcvs;
+ }
+
+ DAL_SIMPLE_KEY(torus_reference_key, pconvex_ref);
+
+ pconvex_ref ptorus_reference(pconvex_ref ori_convex_reference)
+ {
+ dal::pstatic_stored_object_key
+ pk = std::make_shared<torus_reference_key>(ori_convex_reference);
+ dal::pstatic_stored_object o = dal::search_stored_object(pk);
+
+ if (o) return std::dynamic_pointer_cast<const
bgeot::convex_of_reference>(o);
+ pconvex_ref p = std::make_shared<torus_reference>(ori_convex_reference);
+ dal::add_stored_object(pk, p, p->structure(), p->pspt(),
+ dal::PERMANENT_STATIC_OBJECT);
+ return p;
+ }
+
+ void torus_geom_trans::poly_vector_val(const base_node &pt,
bgeot::base_vector &val) const{
+ base_node pt_2d(pt);
+ pt_2d.resize(2);
+ poriginal_trans_->poly_vector_val(pt_2d, val);
+ }
+
+ void torus_geom_trans::poly_vector_val(const base_node &pt, const
bgeot::convex_ind_ct &ind_ct,
+ bgeot::base_vector &val) const{
+ base_node pt_2d(pt);
+ pt_2d.resize(2);
+ poriginal_trans_->poly_vector_val(pt_2d, ind_ct, val);
+ }
+
+ void torus_geom_trans::poly_vector_grad(const base_node &pt,
bgeot::base_matrix &pc) const{
+ base_node pt2D(pt);
+ pt2D.resize(2);
+ bgeot::base_matrix pc2D(nb_points(), 2);
+ poriginal_trans_->poly_vector_grad(pt2D, pc2D);
+
+ bgeot::base_vector base_value;
+ poriginal_trans_->poly_vector_val(pt2D, base_value);
+
+ pc.resize(nb_points(), 3);
+
+ for (size_type i = 0; i < nb_points(); ++i){
+ for (bgeot::dim_type n = 0; n < 2; ++n) pc(i, n) = pc2D(i, n);
+ pc(i, 2) = base_value[i]; // radial direction, pc = base_x;
+ }
+ }
+
+ void torus_geom_trans::poly_vector_grad(const base_node &pt,
+ const bgeot::convex_ind_ct &ind_ct, bgeot::base_matrix &pc) const{
+ base_node pt2D(pt);
+ pt2D.resize(2);
+ bgeot::base_matrix pc2D(ind_ct.size(), 2);
+ poriginal_trans_->poly_vector_grad(pt2D, pc2D);
+ pc.resize(ind_ct.size(), dim());
+ for (size_type i = 0; i < ind_ct.size(); ++i){
+ for (bgeot::dim_type n = 0; n < 2; ++n) pc(i, n) = pc2D(i, n);
+ }
+ }
+
+ void torus_geom_trans::compute_K_matrix
+ (const bgeot::base_matrix &G, const bgeot::base_matrix &pc,
bgeot::base_matrix &K) const{
+ bgeot::geometric_trans::compute_K_matrix(G, pc, K);
+ K(2, 2) = 0.0;
+ for (short_type j = 0; j < nb_points(); ++ j) K(2, 2) += G(0, j) * pc(j,
2);
+ for (short_type i = 0; i < 2; ++i) K(2, i) = K(i, 2) = 0;
+ }
+
+ void torus_geom_trans::poly_vector_hess(const base_node & /*pt*/,
+ bgeot::base_matrix & /*pc*/) const{
+ GMM_ASSERT1(false, "Sorry, Hessian is not supported in axisymmetric
transformation.");
+ }
+
+ torus_geom_trans::torus_geom_trans(pgeometric_trans poriginal_trans)
+ : poriginal_trans_(poriginal_trans){
+ geometric_trans::is_lin = poriginal_trans_->is_linear();
+ geometric_trans::cvr = ptorus_reference(poriginal_trans_->convex_ref());
+ complexity_ = poriginal_trans_->complexity();
+ fill_standard_vertices();
+ }
+
+ pgeometric_trans torus_geom_trans::get_original_transformation() const{
+ return poriginal_trans_;
+ }
+
+ bool is_torus_structure(pconvex_structure cvs){
+ const torus_structure *cvs_torus = dynamic_cast<const torus_structure
*>(cvs.get());
+ return cvs_torus != NULL;
+ }
+
+ DAL_SIMPLE_KEY(torus_geom_trans_key, pgeometric_trans);
+
+ pgeometric_trans torus_geom_trans_descriptor(pgeometric_trans
poriginal_trans){
+ dal::pstatic_stored_object_key
+ pk = std::make_shared<torus_geom_trans_key>(poriginal_trans);
+ dal::pstatic_stored_object o = dal::search_stored_object(pk);
+
+ if (o) return std::dynamic_pointer_cast<const torus_geom_trans>(o);
+
+ bgeot::pgeometric_trans p =
std::make_shared<torus_geom_trans>(poriginal_trans);
+ dal::add_stored_object(pk, p, dal::PERMANENT_STATIC_OBJECT);
+ return p;
+ }
+
+ bool is_torus_geom_trans(pgeometric_trans pgt){
+ const torus_geom_trans *pgt_torus = dynamic_cast<const torus_geom_trans
*>(pgt.get());
+ return pgt_torus != NULL;
+ }
+
+}
\ No newline at end of file
diff --git a/src/getfem/getfem_torus.h b/src/getfem/bgeot_torus.h
similarity index 57%
copy from src/getfem/getfem_torus.h
copy to src/getfem/bgeot_torus.h
index dcfe562..1228792 100644
--- a/src/getfem/getfem_torus.h
+++ b/src/getfem/bgeot_torus.h
@@ -28,118 +28,52 @@
might be covered by the GNU Lesser General Public License.
===========================================================================*/
-/**
address@hidden getfem_torus.h
address@hidden Provides mesh and mesh fem of torus.
address@hidden May 2014
address@hidden Liang Jin Lim
-*/
-
-#pragma once
-
-#ifndef GETFEM_TORUS_H__
-#define GETFEM_TORUS_H__
-
-#include "getfem/getfem_mesh_fem.h"
-
-
-namespace bgeot{
-
-/**An adaptor that adapts a two dimensional geometric_trans to include radial
dimension.*/
-struct torus_geom_trans : public geometric_trans{
-
- virtual void poly_vector_val(const base_node &, bgeot::base_vector &) const;
- virtual void poly_vector_val(const base_node &, const bgeot::convex_ind_ct &,
- bgeot::base_vector &) const;
- virtual void poly_vector_grad(const base_node &, bgeot::base_matrix &) const;
- inline virtual void poly_vector_grad(const base_node &,
- const bgeot::convex_ind_ct &, bgeot::base_matrix &) const;
- inline virtual void compute_K_matrix
- (const bgeot::base_matrix &, const bgeot::base_matrix &,
bgeot::base_matrix &) const;
-
- virtual void poly_vector_hess(const base_node &, bgeot::base_matrix &) const;
-
- torus_geom_trans(bgeot::pgeometric_trans poriginal_trans);
-
- pgeometric_trans get_original_transformation() const;
-
-private:
- pgeometric_trans poriginal_trans_;
-};
-
-pconvex_structure torus_structure_descriptor(pconvex_structure ori_structure);
-
-bool is_torus_structure(pconvex_structure cvs);
-
-pgeometric_trans torus_geom_trans_descriptor(pgeometric_trans poriginal_trans);
-
-bool is_torus_geom_trans(pgeometric_trans pgt);
-
-}
-
-namespace getfem
-{
- /**Torus fem, the real grad base value is modified to compute radial grad of
F/R.
- It stores a reference to the original fem object. By default, torus_fem
is vectorial.
- There is an option to change it to a scalar form through
set_to_scalar(bool is_scalar).
- torus_mesh_fem will automatically check qdim of itself and set the form
accordingly.
- */
- class torus_fem : public virtual_fem{
-
- public :
- virtual size_type index_of_global_dof(size_type cv, size_type i) const;
- void base_value(const base_node &, base_tensor &) const;
- void grad_base_value(const base_node &, base_tensor &) const;
- void hess_base_value(const base_node &, base_tensor &) const;
- void real_base_value(const fem_interpolation_context& c,
- base_tensor &t, bool = true) const;
- void real_grad_base_value(const fem_interpolation_context& c,
- base_tensor &t, bool = true) const;
- void real_hess_base_value(const fem_interpolation_context&,
- base_tensor &, bool = true) const;
-
- pfem get_original_pfem() const;
-
- torus_fem(pfem pf) : virtual_fem(*pf), poriginal_fem_(pf),
is_scalar_(false){
- init();
- }
-
- void set_to_scalar(bool is_scalar);
-
- protected :
- void init();
-
- private :
- pfem poriginal_fem_;
- bool is_scalar_;
- };
-
- /**Copy an original 2D mesh to become a torus mesh with radial dimension.*/
- class torus_mesh : public mesh
- {
- private:
- bool is_adapted_;
-
- public:
- torus_mesh(std::string name = std::string());
- virtual scalar_type convex_radius_estimate(size_type ic) const;
-
- void adapt();
- void adapt(const getfem::mesh &original_mesh);
- };
-
- /**Mesh fem object that adapts */
- class torus_mesh_fem : public mesh_fem{
- public:
-
- torus_mesh_fem(const torus_mesh &mesh, bgeot::dim_type dim) :
mesh_fem(mesh, dim){}
- void enumerate_dof(void) const;
-
- private:
- void adapt_to_torus_();
- void del_torus_fem_();
- };
-
-}
-
-#endif /* GETFEM_TORUS_H__ */
+/**
address@hidden bgeot_torus.h
address@hidden Provides mesh of torus.
address@hidden May 2014
address@hidden Liang Jin Lim
+*/
+
+#pragma once
+
+#ifndef BGEOT_TORUS_H__
+#define BGEOT_TORUS_H__
+
+#include "getfem/bgeot_geometric_trans.h"
+
+namespace bgeot{
+
+/**An adaptor that adapts a two dimensional geometric_trans to include radial
dimension.*/
+struct torus_geom_trans : public geometric_trans{
+
+ virtual void poly_vector_val(const base_node &, bgeot::base_vector &) const;
+ virtual void poly_vector_val(const base_node &, const bgeot::convex_ind_ct &,
+ bgeot::base_vector &) const;
+ virtual void poly_vector_grad(const base_node &, bgeot::base_matrix &) const;
+ inline virtual void poly_vector_grad(const base_node &,
+ const bgeot::convex_ind_ct &, bgeot::base_matrix &) const;
+ inline virtual void compute_K_matrix
+ (const bgeot::base_matrix &, const bgeot::base_matrix &,
bgeot::base_matrix &) const;
+
+ virtual void poly_vector_hess(const base_node &, bgeot::base_matrix &) const;
+
+ torus_geom_trans(bgeot::pgeometric_trans poriginal_trans);
+
+ pgeometric_trans get_original_transformation() const;
+
+private:
+ pgeometric_trans poriginal_trans_;
+};
+
+pconvex_structure torus_structure_descriptor(pconvex_structure ori_structure);
+
+bool is_torus_structure(pconvex_structure cvs);
+
+pgeometric_trans torus_geom_trans_descriptor(pgeometric_trans poriginal_trans);
+
+bool is_torus_geom_trans(pgeometric_trans pgt);
+
+}
+
+#endif /* BGEOT_TORUS_H__ */
\ No newline at end of file
diff --git a/src/getfem/getfem_interpolation.h
b/src/getfem/getfem_interpolation.h
index 5ce875e..b23d132 100644
--- a/src/getfem/getfem_interpolation.h
+++ b/src/getfem/getfem_interpolation.h
@@ -40,7 +40,7 @@
#define GETFEM_INTERPOLATION_H__
#include "getfem_mesh_fem.h"
-#include "bgeot_geotrans_inv.h"
+#include "bgeot_torus.h"
#include "dal_tree_sorted.h"
#include "getfem_im_data.h"
#include "getfem_torus.h"
diff --git a/src/getfem/getfem_torus.h b/src/getfem/getfem_torus.h
index dcfe562..feeebf5 100644
--- a/src/getfem/getfem_torus.h
+++ b/src/getfem/getfem_torus.h
@@ -1,33 +1,33 @@
-/* -*- c++ -*- (enables emacs c++ mode) */
-/*===========================================================================
-
- Copyright (C) 2014-2017 Liang Jin Lim
-
- This file is a part of GetFEM++
-
- GetFEM++ is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version along with the GCC Runtime Library
- Exception either version 3.1 or (at your option) any later version.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- License and GCC Runtime Library Exception for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-
- As a special exception, you may use this file as it is a part of a free
- software library without restriction. Specifically, if other files
- instantiate templates or use macros or inline functions from this file,
- or you compile this file and link it with other files to produce an
- executable, this file does not by itself cause the resulting executable
- to be covered by the GNU Lesser General Public License. This exception
- does not however invalidate any other reasons why the executable file
- might be covered by the GNU Lesser General Public License.
-
-===========================================================================*/
+/* -*- c++ -*- (enables emacs c++ mode) */
+/*===========================================================================
+
+ Copyright (C) 2014-2017 Liang Jin Lim
+
+ This file is a part of GetFEM++
+
+ GetFEM++ is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version along with the GCC Runtime Library
+ Exception either version 3.1 or (at your option) any later version.
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License and GCC Runtime Library Exception for more details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, you may use this file as it is a part of a free
+ software library without restriction. Specifically, if other files
+ instantiate templates or use macros or inline functions from this file,
+ or you compile this file and link it with other files to produce an
+ executable, this file does not by itself cause the resulting executable
+ to be covered by the GNU Lesser General Public License. This exception
+ does not however invalidate any other reasons why the executable file
+ might be covered by the GNU Lesser General Public License.
+
+===========================================================================*/
/**
@file getfem_torus.h
@brief Provides mesh and mesh fem of torus.
@@ -42,41 +42,6 @@
#include "getfem/getfem_mesh_fem.h"
-
-namespace bgeot{
-
-/**An adaptor that adapts a two dimensional geometric_trans to include radial
dimension.*/
-struct torus_geom_trans : public geometric_trans{
-
- virtual void poly_vector_val(const base_node &, bgeot::base_vector &) const;
- virtual void poly_vector_val(const base_node &, const bgeot::convex_ind_ct &,
- bgeot::base_vector &) const;
- virtual void poly_vector_grad(const base_node &, bgeot::base_matrix &) const;
- inline virtual void poly_vector_grad(const base_node &,
- const bgeot::convex_ind_ct &, bgeot::base_matrix &) const;
- inline virtual void compute_K_matrix
- (const bgeot::base_matrix &, const bgeot::base_matrix &,
bgeot::base_matrix &) const;
-
- virtual void poly_vector_hess(const base_node &, bgeot::base_matrix &) const;
-
- torus_geom_trans(bgeot::pgeometric_trans poriginal_trans);
-
- pgeometric_trans get_original_transformation() const;
-
-private:
- pgeometric_trans poriginal_trans_;
-};
-
-pconvex_structure torus_structure_descriptor(pconvex_structure ori_structure);
-
-bool is_torus_structure(pconvex_structure cvs);
-
-pgeometric_trans torus_geom_trans_descriptor(pgeometric_trans poriginal_trans);
-
-bool is_torus_geom_trans(pgeometric_trans pgt);
-
-}
-
namespace getfem
{
/**Torus fem, the real grad base value is modified to compute radial grad of
F/R.
diff --git a/src/getfem_fem.cc b/src/getfem_fem.cc
index 8520a41..29e1665 100644
--- a/src/getfem_fem.cc
+++ b/src/getfem_fem.cc
@@ -25,6 +25,7 @@
@brief implementation of some finite elements.
*/
+#include "getfem/bgeot_torus.h"
#include "getfem/dal_singleton.h"
#include "getfem/dal_tree_sorted.h"
#include "gmm/gmm_algobase.h"
diff --git a/src/getfem_integration.cc b/src/getfem_integration.cc
index 1f5094a..a17a0ee 100644
--- a/src/getfem_integration.cc
+++ b/src/getfem_integration.cc
@@ -19,7 +19,7 @@
===========================================================================*/
-
+#include "getfem/bgeot_torus.h"
#include "getfem/dal_singleton.h"
#include "getfem/getfem_integration.h"
#include "gmm/gmm_dense_lu.h"
diff --git a/src/getfem_torus.cc b/src/getfem_torus.cc
index 8680d56..2cb8a1a 100644
--- a/src/getfem_torus.cc
+++ b/src/getfem_torus.cc
@@ -19,197 +19,9 @@
===========================================================================*/
+#include "getfem/bgeot_torus.h"
#include "getfem/getfem_torus.h"
-namespace bgeot{
-
- /**torus_structure which extends a 2 dimensional structure with a radial
dimension*/
- class torus_structure : public convex_structure{
-
- friend pconvex_structure torus_structure_descriptor(pconvex_structure);
- };
-
- class torus_reference : public convex_of_reference{
-
- public :
- scalar_type is_in(const base_node& point) const{
- GMM_ASSERT1(point.size() >= 2, "Invalid dimension of pt " << point);
- base_node point_2d = point;
- point_2d.resize(2);
- return ori_ref_convex_->is_in(point_2d);
- }
-
- scalar_type is_in_face(bgeot::short_type f, const base_node& point) const{
- GMM_ASSERT1(point.size() >= 2, "Invalid dimension of pt " << point);
- base_node point2D = point;
- point2D.resize(2);
- return ori_ref_convex_->is_in_face(f, point2D);
- }
- torus_reference(bgeot::pconvex_ref ori_ref_convex){
- ori_ref_convex_ = ori_ref_convex;
- cvs = torus_structure_descriptor(ori_ref_convex->structure());
- convex<base_node>::points().resize(cvs->nb_points());
- normals_.resize(ori_ref_convex->normals().size());
-
- const std::vector<base_small_vector> &ori_normals =
ori_ref_convex->normals();
- const stored_point_tab &ori_points = ori_ref_convex->points();
- for(size_type n = 0; n < ori_normals.size(); ++n){
- normals_[n] = ori_normals[n];
- normals_[n].resize(3);
- }
-
- std::copy(ori_points.begin(), ori_points.end(),
convex<base_node>::points().begin());
- for(size_type pt = 0; pt < convex<base_node>::points().size(); ++pt){
- convex<base_node>::points()[pt].resize(3);
- }
- ppoints = store_point_tab(convex<base_node>::points());
- }
-
- private:
- bgeot::pconvex_ref ori_ref_convex_;
- };
-
- DAL_SIMPLE_KEY(torus_structure_key, pconvex_structure);
-
- pconvex_structure torus_structure_descriptor(pconvex_structure
ori_structure){
-
- dal::pstatic_stored_object_key
- pk = std::make_shared<torus_structure_key>(ori_structure);
- dal::pstatic_stored_object o = dal::search_stored_object(pk);
- if (o) return std::dynamic_pointer_cast<const convex_structure>(o);
-
- auto p = std::make_shared<torus_structure>();
- pconvex_structure pcvs(p);
- p->Nc = dim_type(ori_structure->dim() + 1);
- p->nbpt = ori_structure->nb_points();
- p->nbf = ori_structure->nb_faces();
-
- p->faces_struct.resize(p->nbf);
- p->faces.resize(p->nbf);
-
- for (short_type j = 0; j < p->nbf; ++j){
- p->faces_struct[j] = ori_structure->faces_structure()[j];
- short_type nbIndex = ori_structure->nb_points_of_face(j);
- p->faces[j].resize(nbIndex);
- p->faces[j] = ori_structure->ind_points_of_face(j);
- }
-
- p->dir_points_.resize(ori_structure->ind_dir_points().size());
- p->dir_points_ = ori_structure->ind_dir_points();
-
- p->basic_pcvs = basic_structure(ori_structure);
-
- dal::add_stored_object(pk, pcvs, dal::PERMANENT_STATIC_OBJECT);
- return pcvs;
- }
-
- DAL_SIMPLE_KEY(torus_reference_key, pconvex_ref);
-
- pconvex_ref ptorus_reference(pconvex_ref ori_convex_reference)
- {
- dal::pstatic_stored_object_key
- pk = std::make_shared<torus_reference_key>(ori_convex_reference);
- dal::pstatic_stored_object o = dal::search_stored_object(pk);
-
- if (o) return std::dynamic_pointer_cast<const
bgeot::convex_of_reference>(o);
- pconvex_ref p = std::make_shared<torus_reference>(ori_convex_reference);
- dal::add_stored_object(pk, p, p->structure(), p->pspt(),
- dal::PERMANENT_STATIC_OBJECT);
- return p;
- }
-
- void torus_geom_trans::poly_vector_val(const base_node &pt,
bgeot::base_vector &val) const{
- base_node pt_2d(pt);
- pt_2d.resize(2);
- poriginal_trans_->poly_vector_val(pt_2d, val);
- }
-
- void torus_geom_trans::poly_vector_val(const base_node &pt, const
bgeot::convex_ind_ct &ind_ct,
- bgeot::base_vector &val) const{
- base_node pt_2d(pt);
- pt_2d.resize(2);
- poriginal_trans_->poly_vector_val(pt_2d, ind_ct, val);
- }
-
- void torus_geom_trans::poly_vector_grad(const base_node &pt,
bgeot::base_matrix &pc) const{
- base_node pt2D(pt);
- pt2D.resize(2);
- bgeot::base_matrix pc2D(nb_points(), 2);
- poriginal_trans_->poly_vector_grad(pt2D, pc2D);
-
- bgeot::base_vector base_value;
- poriginal_trans_->poly_vector_val(pt2D, base_value);
-
- pc.resize(nb_points(), 3);
-
- for (size_type i = 0; i < nb_points(); ++i){
- for (bgeot::dim_type n = 0; n < 2; ++n) pc(i, n) = pc2D(i, n);
- pc(i, 2) = base_value[i]; // radial direction, pc = base_x;
- }
- }
-
- void torus_geom_trans::poly_vector_grad(const base_node &pt,
- const bgeot::convex_ind_ct &ind_ct, bgeot::base_matrix &pc) const{
- base_node pt2D(pt);
- pt2D.resize(2);
- bgeot::base_matrix pc2D(ind_ct.size(), 2);
- poriginal_trans_->poly_vector_grad(pt2D, pc2D);
- pc.resize(ind_ct.size(), dim());
- for (size_type i = 0; i < ind_ct.size(); ++i){
- for (bgeot::dim_type n = 0; n < 2; ++n) pc(i, n) = pc2D(i, n);
- }
- }
-
- void torus_geom_trans::compute_K_matrix
- (const bgeot::base_matrix &G, const bgeot::base_matrix &pc,
bgeot::base_matrix &K) const{
- bgeot::geometric_trans::compute_K_matrix(G, pc, K);
- K(2, 2) = 0.0;
- for (short_type j = 0; j < nb_points(); ++ j) K(2, 2) += G(0, j) * pc(j,
2);
- for (short_type i = 0; i < 2; ++i) K(2, i) = K(i, 2) = 0;
- }
-
- void torus_geom_trans::poly_vector_hess(const base_node & /*pt*/,
- bgeot::base_matrix & /*pc*/) const{
- GMM_ASSERT1(false, "Sorry, Hessian is not supported in axisymmetric
transformation.");
- }
-
- torus_geom_trans::torus_geom_trans(pgeometric_trans poriginal_trans)
- : poriginal_trans_(poriginal_trans){
- geometric_trans::is_lin = poriginal_trans_->is_linear();
- geometric_trans::cvr = ptorus_reference(poriginal_trans_->convex_ref());
- complexity_ = poriginal_trans_->complexity();
- fill_standard_vertices();
- }
-
- pgeometric_trans torus_geom_trans::get_original_transformation() const{
- return poriginal_trans_;
- }
-
- bool is_torus_structure(pconvex_structure cvs){
- const torus_structure *cvs_torus = dynamic_cast<const torus_structure
*>(cvs.get());
- return cvs_torus != NULL;
- }
-
- DAL_SIMPLE_KEY(torus_geom_trans_key, pgeometric_trans);
-
- pgeometric_trans torus_geom_trans_descriptor(pgeometric_trans
poriginal_trans){
- dal::pstatic_stored_object_key
- pk = std::make_shared<torus_geom_trans_key>(poriginal_trans);
- dal::pstatic_stored_object o = dal::search_stored_object(pk);
-
- if (o) return std::dynamic_pointer_cast<const torus_geom_trans>(o);
-
- bgeot::pgeometric_trans p =
std::make_shared<torus_geom_trans>(poriginal_trans);
- dal::add_stored_object(pk, p, dal::PERMANENT_STATIC_OBJECT);
- return p;
- }
-
- bool is_torus_geom_trans(pgeometric_trans pgt){
- const torus_geom_trans *pgt_torus = dynamic_cast<const torus_geom_trans
*>(pgt.get());
- return pgt_torus != NULL;
- }
-}
-
namespace getfem
{