37 #ifndef GETFEM_CONVECT_H__
38 #define GETFEM_CONVECT_H__
46 enum convect_boundary_option { CONVECT_EXTRAPOLATION, CONVECT_UNCHANGED, CONVECT_PERIODICITY };
58 template<
class VECT1,
class VECT2>
60 const VECT2 &V, scalar_type dt,
size_type nt,
61 convect_boundary_option option = CONVECT_EXTRAPOLATION,
62 const base_node &per_min = base_node(),
63 const base_node &per_max = base_node()) {
72 typedef typename gmm::linalg_traits<VECT1>::value_type T;
73 int extra = (option == CONVECT_EXTRAPOLATION) ? 2 : 0;
78 "This convection algorithm work only on pure Lagrange fems");
80 for (dal::bv_visitor cv(mf.
convex_index()); !cv.finished();++cv) {
82 GMM_ASSERT1(pf_t->target_dim() == 1 && pf_t->is_lagrange(),
83 "This convection algorithm work only on pure Lagrange fems");
89 if (option == CONVECT_PERIODICITY)
90 GMM_ASSERT1(per_min.size() == N && per_max.size() == N,
91 "Wrong size of box extremity for PERIODICITY option");
93 getfem::mesh_trans_inv mti(msh, 1E-10);
96 std::vector<base_node> nodes(nbpts);
102 GMM_ASSERT1(qqdimt == N,
"The velocity field should be a vector field "
103 "of the same dimension as the mesh");
104 std::vector<T> VI(nbpts*N);
108 scalar_type ddt = dt / scalar_type(nt);
112 mti.add_points(nodes);
114 dal::bit_vector dof_untouched;
116 for (dal::bv_visitor j(dof_untouched); !j.finished();++j)
121 gmm::add(gmm::scaled(gmm::sub_vector(VI, gmm::sub_interval(N*j, N)),
123 if (option == CONVECT_PERIODICITY) {
125 if (per_max[k] > per_min[k]) {
126 while (nodes[j][k] > per_max[k]) nodes[j][k] -= per_max[k];
127 while (nodes[j][k] < per_min[k]) nodes[j][k] += per_max[k];
134 std::vector<T> UI(nbpts*qdim);
136 mti.add_points(nodes);
137 dal::bit_vector dof_untouched;
139 for (dal::bv_visitor i(dof_untouched); !i.finished();++i)
Describe a finite element method linked to a mesh.
virtual dim_type get_qdim() const
Return the Q dimension.
virtual size_type nb_dof() const
Return the total number of degrees of freedom.
const mesh & linked_mesh() const
Return a reference to the underlying mesh.
virtual size_type nb_basic_dof() const
Return the total number of basic degrees of freedom (before the optional reduction).
virtual base_node point_of_basic_dof(size_type cv, size_type i) const
Return the geometrical location of a degree of freedom.
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.
bool is_reduced() const
Return true if a reduction matrix is applied to the dofs.
Describe a mesh (collection of convexes (elements) and points).
Interpolation of fields from a mesh_fem onto another.
Define the getfem::mesh_fem class.
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
size_t size_type
used as the common size type in the library
GEneric Tool for Finite Element Methods.
void convect(const mesh_fem &mf, VECT1 &U, const mesh_fem &mf_v, const VECT2 &V, scalar_type dt, size_type nt, convect_boundary_option option=CONVECT_EXTRAPOLATION, const base_node &per_min=base_node(), const base_node &per_max=base_node())
Compute the convection of a quantity on a getfem::mesh_fem with respect to a velocity field.
void interpolation(const mesh_fem &mf_source, const mesh_fem &mf_target, const VECTU &U, VECTV &V, int extrapolation=0, double EPS=1E-10, mesh_region rg_source=mesh_region::all_convexes(), mesh_region rg_target=mesh_region::all_convexes())
interpolation/extrapolation of (mf_source, U) on mf_target.