36 #ifndef GETFEM_CONVECT_H__
37 #define GETFEM_CONVECT_H__
45 enum convect_boundary_option { CONVECT_EXTRAPOLATION, CONVECT_UNCHANGED, CONVECT_PERIODICITY };
57 template<
class VECT1,
class VECT2>
59 const VECT2 &V, scalar_type dt,
size_type nt,
60 convect_boundary_option option = CONVECT_EXTRAPOLATION,
61 const base_node &per_min = base_node(),
62 const base_node &per_max = base_node()) {
71 typedef typename gmm::linalg_traits<VECT1>::value_type T;
72 int extra = (option == CONVECT_EXTRAPOLATION) ? 2 : 0;
77 "This convection algorithm work only on pure Lagrange fems");
79 for (dal::bv_visitor cv(mf.
convex_index()); !cv.finished();++cv) {
81 GMM_ASSERT1(pf_t->target_dim() == 1 && pf_t->is_lagrange(),
82 "This convection algorithm work only on pure Lagrange fems");
88 if (option == CONVECT_PERIODICITY)
89 GMM_ASSERT1(per_min.size() == N && per_max.size() == N,
90 "Wrong size of box extremity for PERIODICITY option");
92 getfem::mesh_trans_inv mti(msh, 1E-10);
95 std::vector<base_node> nodes(nbpts);
101 GMM_ASSERT1(qqdimt == N,
"The velocity field should be a vector field "
102 "of the same dimension as the mesh");
103 std::vector<T> VI(nbpts*N);
107 scalar_type ddt = dt / scalar_type(nt);
111 mti.add_points(nodes);
113 dal::bit_vector dof_untouched;
115 for (dal::bv_visitor j(dof_untouched); !j.finished();++j)
120 gmm::add(gmm::scaled(gmm::sub_vector(VI, gmm::sub_interval(N*j, N)),
122 if (option == CONVECT_PERIODICITY) {
124 if (per_max[k] > per_min[k]) {
125 while (nodes[j][k] > per_max[k]) nodes[j][k] -= per_max[k];
126 while (nodes[j][k] < per_min[k]) nodes[j][k] += per_max[k];
133 std::vector<T> UI(nbpts*qdim);
135 mti.add_points(nodes);
136 dal::bit_vector dof_untouched;
138 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.