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)