29 bgeot::multi_index tsize,
31 : im_(mim), region_(filtered_region_),
32 nb_int_pts_intern(0), nb_int_pts_onfaces(0),
33 nb_filtered_int_pts_intern(0), nb_filtered_int_pts_onfaces(0),
36 set_tensor_size(tsize);
42 : im_(mim), region_(filtered_region_),
43 nb_int_pts_intern(0), nb_int_pts_onfaces(0),
44 nb_filtered_int_pts_intern(0), nb_filtered_int_pts_onfaces(0),
47 tensor_size_.resize(1);
57 return nb_filtered_int_pts_intern + nb_filtered_int_pts_onfaces;
59 return nb_int_pts_intern + nb_int_pts_onfaces;
64 if (cv < convexes.size()) {
69 if (convexes[cv].first_int_pt_onface_fid[f] !=
size_type(-1))
70 nb_int_pts += convexes[cv].nb_int_pts_onface[f];
71 if (convexes[cv].first_int_pt_fid !=
size_type(-1))
72 nb_int_pts += convexes[cv].nb_int_pts;
75 for (
auto nb_pts : convexes[cv].nb_int_pts_onface)
77 if (nb_int_pts_intern > 0)
78 nb_int_pts += convexes[cv].nb_int_pts;
86 bool use_filter)
const {
88 if (cv < convexes.size()) {
90 if (!use_filter || convexes[cv].first_int_pt_fid !=
size_type(-1))
91 return convexes[cv].nb_int_pts;
93 else if (f < convexes[cv].nb_int_pts_onface.size()) {
94 if (!use_filter || convexes[cv].first_int_pt_onface_fid[f] !=
size_type(-1))
95 return convexes[cv].nb_int_pts_onface[f];
103 if (cv < convexes.size())
104 return short_type(convexes[cv].first_int_pt_onface_id.size());
109 bool use_filter)
const {
111 if (cv < convexes.size()) {
112 if (i < convexes[cv].nb_int_pts) {
113 size_type int_pt_id = use_filter ? convexes[cv].first_int_pt_fid
114 : convexes[cv].first_int_pt_id;
116 return int_pt_id + i;
119 const getfem::papprox_integration pim = approx_int_method_of_element(cv);
120 for (
short_type f=0, nb_faces=pim->nb_convex_faces();
122 if (i < pim->repart()[f+1]) {
123 size_type int_pt_id = use_filter ? convexes[cv].first_int_pt_onface_fid[f]
124 : convexes[cv].first_int_pt_onface_id[f];
126 return int_pt_id + i - pim->ind_first_point_on_face(f);
138 bool use_filter)
const {
140 if (cv < convexes.size()) {
142 return use_filter ? convexes[cv].first_int_pt_fid
143 : convexes[cv].first_int_pt_id;
146 return use_filter ? convexes[cv].first_int_pt_onface_fid[f]
147 : convexes[cv].first_int_pt_onface_id[f];
170 local_guard lock = locks_.get_lock();
180 convexes.resize(nb_cv);
182 for (dal::bv_visitor cv(im_.
convex_index()); !cv.finished(); ++cv)
183 convexes[cv].nb_int_pts
186 nb_int_pts_intern = 0;
187 nb_filtered_int_pts_intern = 0;
190 for (dal::bv_visitor cv(im_.
convex_index()); !cv.finished(); ++cv) {
191 convexes[cv].first_int_pt_id = nb_int_pts_intern;
192 nb_int_pts_intern += convexes[cv].nb_int_pts;
193 if (no_region || rg.is_in(cv)) {
194 convexes[cv].first_int_pt_fid = nb_filtered_int_pts_intern;
195 nb_filtered_int_pts_intern += convexes[cv].nb_int_pts;
199 nb_int_pts_onfaces = 0;
200 nb_filtered_int_pts_onfaces = 0;
202 for (dal::bv_visitor cv(im_.
convex_index()); !cv.finished(); ++cv) {
204 convexes[cv].first_int_pt_onface_id.assign(nb_faces,
size_type(-1));
205 convexes[cv].first_int_pt_onface_fid.assign(nb_faces,
size_type(-1));
206 convexes[cv].nb_int_pts_onface.assign(nb_faces,
size_type(-1));
207 const getfem::papprox_integration pim(approx_int_method_of_element(cv));
209 convexes[cv].first_int_pt_onface_id[f] = nb_int_pts_intern +
211 size_type nb_pts = pim->nb_points_on_face(f);
212 nb_int_pts_onfaces += nb_pts;
213 if (rg.is_in(cv, f)) {
214 convexes[cv].first_int_pt_onface_fid[f] = nb_filtered_int_pts_intern +
215 nb_filtered_int_pts_onfaces;
216 nb_filtered_int_pts_onfaces += nb_pts;
218 convexes[cv].nb_int_pts_onface[f] = nb_pts;
222 v_num_ = act_counter();
227 return nb_tensor_elem_;
230 void im_data::set_tensor_size(
const bgeot::multi_index& tsize) {
231 tensor_size_ = tsize;
232 nb_tensor_elem_ = tensor_size_.total_size();
236 bool checked =
false;
238 for (
size_type i = 0; i < sizes.size(); ++i) {
239 if (sizes[i] > 1 && checked)
return false;
243 if (size != vector_size)
return false;
246 return (vector_size == size);
250 if (nrows == 1 || ncols == 1) {
255 bool first_checked =
false;
256 bool second_checked =
false;
257 for (
size_type i = 0; i < sizes.size(); ++i) {
258 if (sizes[i] > 1 && !first_checked) {
259 first_checked =
true;
260 tensor_row = sizes[i];
261 if (tensor_row != nrows)
return false;
262 }
else if (sizes[i] > 1 && !second_checked) {
263 second_checked =
true;
264 tensor_col = sizes[i];
265 if (tensor_col != ncols)
return false;
267 else if (sizes[i] > 1 && first_checked && second_checked)
return false;
269 return (nrows == tensor_row && ncols == tensor_col);
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.
static mesh_region all_convexes()
provide a default value for the mesh_region parameters of assembly procedures etc.
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
Provides indexing of integration points for mesh_im.
const dal::bit_vector & index() const
Index of the region convexes, or the convexes from the partition on the current thread.
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.
Describe an integration method linked to a mesh.
Tools for multithreaded, OpenMP and Boost based parallelization.
const mesh & linked_mesh() const
linked mesh
size_type nb_index(bool use_filter=false) const
Total numbers of index (integration points)
size_t size_type
used as the common size type in the library
bool is_only_faces() const
Return true if the region do contain only convex faces.
bool is_only_convexes() const
Return true if the region do not contain any convex face.
GEneric Tool for Finite Element Methods.
gmm::uint16_type short_type
used as the common short type integer in the library
size_type filtered_index_of_point(size_type cv, size_type i) const
Returns the index of an integration point with filtering.
const dal::bit_vector & convex_index(void) const
Get the set of convexes where an integration method has been assigned.
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
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.
short_type nb_faces_of_convex(size_type ic) const
Return the number of faces of convex ic.
const mesh_region region(size_type id) const
Return the region of index 'id'.
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.