39 #ifndef GETFEM_IM_DATA_H__
40 #define GETFEM_IM_DATA_H__
46 using bgeot::scalar_type;
82 bgeot::multi_index actual_tensor_size = {});
101 bool use_filter =
false)
const;
108 bool use_filter =
false)
const;
142 dal::bit_vector
convex_index(
bool use_filter=
false)
const;
155 inline operator const mesh_im &()
const {
return im_; }
160 getfem::papprox_integration approx_int_method_of_element(
size_type cv)
const
163 inline const bgeot::multi_index& tensor_size()
const {
return tensor_size_; }
165 void set_tensor_size(
const bgeot::multi_index& tensor_size);
167 inline const bgeot::multi_index& actual_tensor_size()
const {
return actual_tensor_size_; }
169 void set_actual_tensor_size(
const bgeot::multi_index &tensor_size);
171 inline gmm::uint64_type version_number()
const {
context_check();
return v_num_; }
174 template <
typename VECT>
176 if (V1.size() == 0 && V2.size() == 0)
179 GMM_ASSERT2(V1.size() == nb_data*
nb_filtered_index(),
"Invalid size of vector V1");
180 GMM_ASSERT2(V2.size() == nb_data*
nb_index(),
"Invalid size of vector V2");
190 ? convexes[v.cv()].first_int_pt_id
191 : convexes[v.cv()].first_int_pt_onface_id[v.f()];
193 ? convexes[v.cv()].first_int_pt_fid
194 : convexes[v.cv()].first_int_pt_onface_fid[v.f()];
197 gmm::sub_vector(V1, gmm::sub_interval(first_fid*nb_data, nb_pts*nb_data)),
198 gmm::sub_vector(V2, gmm::sub_interval(first_id*nb_data, nb_pts*nb_data)));
203 template <
typename VECT>
205 if (V1.size() == 0 && V2.size() == 0)
208 GMM_ASSERT2(V1.size() == nb_data*
nb_index(),
"Invalid size of vector V1");
210 "Invalid size of vector V2");
220 ? convexes[v.cv()].first_int_pt_id
221 : convexes[v.cv()].first_int_pt_onface_id[v.f()];
223 ? convexes[v.cv()].first_int_pt_fid
224 : convexes[v.cv()].first_int_pt_onface_fid[v.f()];
227 gmm::sub_vector(V1, gmm::sub_interval(first_id*nb_data, nb_pts*nb_data)),
228 gmm::sub_vector(V2, gmm::sub_interval(first_fid*nb_data, nb_pts*nb_data)));
234 template <
typename VECT>
236 size_type i,
bool use_filter =
true)
const {
237 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
238 "Invalid tensorial size for vector V1");
239 GMM_ASSERT2(nb_tensor_elem_ == 1,
"im_data is not of scalar type");
241 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
247 template <
typename VECT1,
typename VECT2>
249 VECT2& V2,
bool use_filter =
true)
const {
250 if (V1.size() == 0 && V2.size() == 0)
252 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
253 "Invalid tensorial size for vector V1");
255 "V2 is incompatible with im_data tensor size");
257 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
258 gmm::copy(gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
265 template <
typename VECT,
typename MAT>
267 MAT& M,
bool use_filter =
true)
const {
268 if (V1.size() == 0 && M.size() == 0)
270 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
271 "Invalid tensorial size for vector V1");
273 "M is incompatible with im_data tensor size");
275 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
276 gmm::copy(gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
283 template <
typename VECT,
typename TENSOR>
285 TENSOR& T,
bool use_filter =
true)
const {
286 if (V1.size() == 0 && T.size() == 0)
288 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
289 "Invalid tensorial size for vector V1");
290 GMM_ASSERT2(tensor_size_ == T.sizes(),
291 "T is incompatible with im_data tensor size");
293 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
294 gmm::copy(gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
301 template <
typename VECT>
303 bool use_filter =
true)
const {
304 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
305 "Invalid tensorial size for vector V1");
306 GMM_ASSERT2(nb_tensor_elem_ == 1,
"im_data is not of scalar type");
308 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
314 template <
typename VECT1,
typename VECT2>
316 const VECT2& V2,
bool use_filter =
true)
const {
317 if (V1.size() == 0 && V2.size() == 0)
319 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
320 "Invalid tensorial size for vector V1");
322 "V2 is incompatible with im_data tensor size");
324 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
326 gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
332 template <
typename VECT,
typename MAT>
334 const MAT& M,
bool use_filter =
true)
const {
335 if (V1.size() == 0 && M.size() == 0)
337 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
338 "Invalid tensorial size for vector V1");
340 "M is incompatible with im_data tensor size");
342 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
343 gmm::copy(M.as_vector(),
344 gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
350 template <
typename VECT,
typename TENSOR>
352 const TENSOR& T,
bool use_filter =
true)
const {
353 if (V1.size() == 0 && T.size() == 0)
355 GMM_ASSERT2(nb_tensor_elem_*
nb_index(use_filter) == V1.size(),
356 "Invalid tensorial size for vector V1");
357 GMM_ASSERT2(tensor_size_ == T.sizes(),
358 "T is incompatible with im_data tensor size");
360 GMM_ASSERT2(ptid !=
size_type(-1),
"Point index of gauss point not found");
361 gmm::copy(T.as_vector(),
362 gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
367 template <
typename VECT1,
typename VECT2>
369 GMM_ASSERT2(V1.size() != 0,
"V1 of zero size");
370 GMM_ASSERT2(V2.size() != 0,
"V2 of zero size");
372 "V2 is incompatible with im_data tensor size");
374 gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
378 template <
typename VECT1,
typename TENSOR>
380 GMM_ASSERT2(V1.size() != 0,
"V1 of zero size");
381 GMM_ASSERT2(T.size() != 0,
"V2 of zero size");
382 GMM_ASSERT2(tensor_size_ == T.sizes(),
383 "T is incompatible with im_data tensor size");
384 gmm::copy(T.as_vector(),
385 gmm::sub_vector(V1, gmm::sub_interval(ptid*nb_tensor_elem_,
396 mutable size_type nb_filtered_int_pts_intern;
397 mutable size_type nb_filtered_int_pts_onfaces;
403 std::vector<size_type> first_int_pt_onface_id;
404 std::vector<size_type> first_int_pt_onface_fid;
405 std::vector<size_type> nb_int_pts_onface;
408 : first_int_pt_id(-1), first_int_pt_fid(-1), nb_int_pts(0),
409 first_int_pt_onface_id(0), first_int_pt_onface_fid(0), nb_int_pts_onface(0)
413 mutable std::vector<convex_data> convexes;
415 mutable gmm::uint64_type v_num_;
417 bgeot::multi_index tensor_size_;
418 bgeot::multi_index actual_tensor_size_;
base class for static stored objects
Deal with interdependencies of objects.
bool context_check() const
return true if update_from_context was called
im_data provides indexing to the integration points of a mesh im object.
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.
const mesh & linked_mesh() const
linked mesh
im_data(const mesh_im &mim_, bgeot::multi_index tensor_size, size_type filtered_region_=size_type(-1), bgeot::multi_index actual_tensor_size={})
Constructor.
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.
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.
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.
size_type filtered_region() const
return filtered region id
size_type nb_points_of_element(size_type cv, bool use_filter=false) const
Total number of points in element cv.
size_type nb_filtered_points_of_element(size_type cv) const
Total number of points in element cv, which lie in filtered_region()
dal::bit_vector filtered_convex_index() const
List of convex in filtered region.
void update_from_context() const
called automatically when there is a change in dependencies
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.
const mesh_im & linked_mesh_im() const
linked mesh im
size_type filtered_index_of_point(size_type cv, size_type i) const
Returns the index of an integration point with filtering.
void set_region(size_type region)
set filtered region id
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()
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.
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.
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.
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_index(bool use_filter=false) const
Total numbers of index (integration points)
short_type nb_faces_of_element(size_type cv) const
Number of (active) faces in element cv.
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.
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.
size_type nb_filtered_index() const
Total numbers of filtered index (integration points)
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.
size_type nb_tensor_elem() const
sum of tensor elements, M(3,3) will have 3*3=9 elements
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.
dal::bit_vector convex_index(bool use_filter=false) const
List of convexes.
Describe an integration method linked to a mesh.
virtual pintegration_method int_method_of_element(size_type cv) const
return the integration method associated with an element (in no integration is associated,...
const mesh & linked_mesh() const
Give a reference to the linked mesh of type mesh.
"iterator" class for regions.
structure used to hold a set of convexes and/or convex faces.
Describe a mesh (collection of convexes (elements) and points).
const mesh_region region(size_type id) const
Return the region of index 'id'.
Define the getfem::mesh_im class (integration of getfem::mesh_fem).
gmm::uint16_type short_type
used as the common short type integer in the library
size_t size_type
used as the common size type in the library
GEneric Tool for Finite Element Methods.
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
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