40 #ifndef GETFEM_IM_DATA_H__ 41 #define GETFEM_IM_DATA_H__ 47 using bgeot::scalar_type;
99 bool use_filter =
false)
const;
106 bool use_filter =
false)
const;
140 dal::bit_vector
convex_index(
bool use_filter=
false)
const;
153 inline operator const mesh_im &()
const {
return im_; }
158 getfem::papprox_integration approx_int_method_of_element(
size_type cv)
const 161 inline const bgeot::multi_index& tensor_size ()
const {
return tensor_size_;}
163 void set_tensor_size (
const bgeot::multi_index& tensor_size);
165 inline gmm::uint64_type version_number()
const {
context_check();
return v_num_; }
168 template <
typename VECT>
170 if (V1.size() == 0 && V2.size() == 0)
173 GMM_ASSERT2(V1.size() == nb_data*
nb_filtered_index(),
"Invalid size of vector V1");
174 GMM_ASSERT2(V2.size() == nb_data*
nb_index(),
"Invalid size of vector V2");
184 ? convexes[v.cv()].first_int_pt_id
185 : convexes[v.cv()].first_int_pt_onface_id[v.f()];
187 ? convexes[v.cv()].first_int_pt_fid
188 : convexes[v.cv()].first_int_pt_onface_fid[v.f()];
191 gmm::sub_vector(V1, gmm::sub_interval(first_fid*nb_data, nb_pts*nb_data)),
192 gmm::sub_vector(V2, gmm::sub_interval(first_id*nb_data, nb_pts*nb_data)));
197 template <
typename VECT>
199 if (V1.size() == 0 && V2.size() == 0)
202 GMM_ASSERT2(V1.size() == nb_data*
nb_index(),
"Invalid size of vector V1");
204 "Invalid size of vector V2");
214 ? convexes[v.cv()].first_int_pt_id
215 : convexes[v.cv()].first_int_pt_onface_id[v.f()];
217 ? convexes[v.cv()].first_int_pt_fid
218 : convexes[v.cv()].first_int_pt_onface_fid[v.f()];
221 gmm::sub_vector(V1, gmm::sub_interval(first_id*nb_data, nb_pts*nb_data)),
222 gmm::sub_vector(V2, gmm::sub_interval(first_fid*nb_data, nb_pts*nb_data)));
228 template <
typename VECT>
230 size_type i,
bool use_filter =
true)
const {
231 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
232 "Invalid tensorial size for vector V1");
233 GMM_ASSERT2(nb_tensor_elem_ == 1,
"im_data is not of scalar type");
235 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
241 template <
typename VECT1,
typename VECT2>
243 VECT2& V2,
bool use_filter =
true)
const {
244 if (V1.size() == 0 && V2.size() == 0)
246 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
247 "Invalid tensorial size for vector V1");
249 "V2 is incompatible with im_data tensor size");
251 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
252 gmm::copy(gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
259 template <
typename VECT,
typename MAT>
261 MAT& M,
bool use_filter =
true)
const {
262 if (V1.size() == 0 && M.size() == 0)
264 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
265 "Invalid tensorial size for vector V1");
267 "M is incompatible with im_data tensor size");
269 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
270 gmm::copy(gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
277 template <
typename VECT,
typename TENSOR>
279 TENSOR& T,
bool use_filter =
true)
const {
280 if (V1.size() == 0 && T.size() == 0)
282 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
283 "Invalid tensorial size for vector V1");
284 GMM_ASSERT2(tensor_size_ == T.sizes(),
285 "T is incompatible with im_data tensor size");
287 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
288 gmm::copy(gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
295 template <
typename VECT>
297 bool use_filter =
true)
const {
298 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
299 "Invalid tensorial size for vector V1");
300 GMM_ASSERT2(nb_tensor_elem_ == 1,
"im_data is not of scalar type");
302 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
308 template <
typename VECT1,
typename VECT2>
310 const VECT2& V2,
bool use_filter =
true)
const {
311 if (V1.size() == 0 && V2.size() == 0)
313 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
314 "Invalid tensorial size for vector V1");
316 "V2 is incompatible with im_data tensor size");
318 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
320 gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
326 template <
typename VECT,
typename MAT>
328 const MAT& M,
bool use_filter =
true)
const {
329 if (V1.size() == 0 && M.size() == 0)
331 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
332 "Invalid tensorial size for vector V1");
334 "M is incompatible with im_data tensor size");
336 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
337 gmm::copy(M.as_vector(),
338 gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
344 template <
typename VECT,
typename TENSOR>
346 const TENSOR& T,
bool use_filter =
true)
const {
347 if (V1.size() == 0 && T.size() == 0)
349 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
350 "Invalid tensorial size for vector V1");
351 GMM_ASSERT2(tensor_size_ == T.sizes(),
352 "T is incompatible with im_data tensor size");
354 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
355 gmm::copy(T.as_vector(),
356 gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
361 template <
typename VECT1,
typename VECT2>
363 GMM_ASSERT2(V1.size() != 0,
"V1 of zero size");
364 GMM_ASSERT2(V2.size() != 0,
"V2 of zero size");
366 "V2 is incompatible with im_data tensor size");
368 gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
372 template <
typename VECT1,
typename TENSOR>
374 GMM_ASSERT2(V1.size() != 0,
"V1 of zero size");
375 GMM_ASSERT2(T.size() != 0,
"V2 of zero size");
376 GMM_ASSERT2(tensor_size_ == T.sizes(),
377 "T is incompatible with im_data tensor size");
378 gmm::copy(T.as_vector(),
379 gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
390 mutable size_type nb_filtered_int_pts_intern;
391 mutable size_type nb_filtered_int_pts_onfaces;
397 std::vector<size_type> first_int_pt_onface_id;
398 std::vector<size_type> first_int_pt_onface_fid;
399 std::vector<size_type> nb_int_pts_onface;
402 : first_int_pt_id(-1), first_int_pt_fid(-1), nb_int_pts(0),
403 first_int_pt_onface_id(0), first_int_pt_onface_fid(0), nb_int_pts_onface(0)
407 mutable std::vector<convex_data> convexes;
409 mutable gmm::uint64_type v_num_;
411 bgeot::multi_index tensor_size_;
void update_from_context() const
called automatically when there is a change in dependencies
size_type index_of_point(size_type cv, size_type i, bool use_filter=false) const
Returns the index of an integration point with no filtering.
virtual pintegration_method int_method_of_element(size_type cv) const
return the integration method associated with an element (in no integration is associated, the function will crash! use the convex_index() of the mesh_im to check that a fem is associated to a given convex)
structure used to hold a set of convexes and/or convex faces.
void get_matrix(const VECT &V1, size_type cv, size_type i, MAT &M, bool use_filter=true) const
get a matrix of an integration point from a raw vector data, described by the tensor size...
void set_matrix(VECT &V1, size_type cv, size_type i, const MAT &M, bool use_filter=true) const
set a matrix of an integration point from a raw vector data, described by the tensor size...
base class for static stored objects
bool is_equivalent_with_vector(const bgeot::multi_index &sizes, size_type vector_size)
check if a given tensor size is equivalent to a vector
bool is_equivalent_with_matrix(const bgeot::multi_index &sizes, size_type nrows, size_type ncols)
check if a given tensor size is equivalent to a matrix
void extend_vector(const VECT &V1, VECT &V2) const
Extend a vector from filtered size to full size and copy the data to correct index.
void set_region(size_type region)
set filtered region id
short_type nb_faces_of_element(size_type cv) const
Number of (active) faces in element cv.
VECT::value_type get_value(const VECT &V1, size_type cv, size_type i, bool use_filter=true) const
get a scalar value of an integration point from a raw vector data, described by the tensor size...
void set_tensor(VECT &V1, size_type cv, size_type i, const TENSOR &T, bool use_filter=true) const
set a tensor of an integration point from a raw vector data, described by the tensor size...
Define the getfem::mesh_im class (integration of getfem::mesh_fem).
Describe a mesh (collection of convexes (elements) and points).
const mesh_im & linked_mesh_im() const
linked mesh im
Describe an integration method linked to a mesh.
void get_vector(const VECT1 &V1, size_type cv, size_type i, VECT2 &V2, bool use_filter=true) const
get a vector of an integration point from a raw vector data, described by the tensor size...
const mesh & linked_mesh() const
linked mesh
size_type nb_index(bool use_filter=false) const
Total numbers of index (integration points)
VECT::value_type & set_value(VECT &V1, size_type cv, size_type i, bool use_filter=true) const
set a value of an integration point from a raw vector data, described by the tensor size...
size_t size_type
used as the common size type in the library
void get_tensor(const VECT &V1, size_type cv, size_type i, TENSOR &T, bool use_filter=true) const
get a tensor of an integration point from a raw vector data, described by the tensor size...
"iterator" class for regions.
Deal with interdependencies of objects.
GEneric Tool for Finite Element Methods.
void set_vector(VECT1 &V1, size_type cv, size_type i, const VECT2 &V2, bool use_filter=true) const
set a vector of an integration point from a raw vector data, described by the tensor size...
gmm::uint16_type short_type
used as the common short type integer in the library
size_type nb_filtered_index() const
Total numbers of filtered index (integration points)
size_type nb_filtered_points_of_element(size_type cv, short_type f) const
Number of points in element cv, on face f (or in the interior), which lie in filtered_region() ...
size_type filtered_index_of_point(size_type cv, size_type i) const
Returns the index of an integration point with filtering.
size_type filtered_index_of_first_point(size_type cv, short_type f=short_type(-1)) const
Returns the index of the first integration point with filtering.
size_type filtered_region() const
return filtered region id
const mesh & linked_mesh() const
Give a reference to the linked mesh of type mesh.
bool context_check() const
return true if update_from_context was called
void reduce_vector(const VECT &V1, VECT &V2) const
Filter a vector from full size to filtered size and copy the data to correct index.
size_type nb_filtered_points_of_element(size_type cv) const
Total number of points in element cv, which lie in filtered_region()
im_data(const mesh_im &mim_, bgeot::multi_index tensor_size, size_type filtered_region_=size_type(-1))
Constructor.
dal::bit_vector convex_index(bool use_filter=false) const
List of convexes.
im_data provides indexing to the integration points of a mesh im object.
const mesh_region region(size_type id) const
Return the region of index 'id'.
dal::bit_vector filtered_convex_index() const
List of convex in filtered region.
size_type nb_tensor_elem() const
sum of tensor elements, M(3,3) will have 3*3=9 elements
size_type index_of_first_point(size_type cv, short_type f=short_type(-1), bool use_filter=false) const
Returns the index of the first integration point with no filtering.
size_type nb_points_of_element(size_type cv, bool use_filter=false) const
Total number of points in element cv.