28 bgeot::multi_index tsize,
30 bgeot::multi_index actual_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);
37 set_actual_tensor_size(actual_tsize);
43 : im_(mim), region_(filtered_region_),
44 nb_int_pts_intern(0), nb_int_pts_onfaces(0),
45 nb_filtered_int_pts_intern(0), nb_filtered_int_pts_onfaces(0),
48 tensor_size_.resize(1);
50 actual_tensor_size_ = tensor_size_;
59 return nb_filtered_int_pts_intern + nb_filtered_int_pts_onfaces;
61 return nb_int_pts_intern + nb_int_pts_onfaces;
66 if (cv < convexes.size()) {
71 if (convexes[cv].first_int_pt_onface_fid[f] !=
size_type(-1))
72 nb_int_pts += convexes[cv].nb_int_pts_onface[f];
73 if (convexes[cv].first_int_pt_fid !=
size_type(-1))
74 nb_int_pts += convexes[cv].nb_int_pts;
77 for (
auto nb_pts : convexes[cv].nb_int_pts_onface)
79 if (nb_int_pts_intern > 0)
80 nb_int_pts += convexes[cv].nb_int_pts;
88 bool use_filter)
const {
90 if (cv < convexes.size()) {
92 if (!use_filter || convexes[cv].first_int_pt_fid !=
size_type(-1))
93 return convexes[cv].nb_int_pts;
95 else if (f < convexes[cv].nb_int_pts_onface.size()) {
96 if (!use_filter || convexes[cv].first_int_pt_onface_fid[f] !=
size_type(-1))
97 return convexes[cv].nb_int_pts_onface[f];
105 if (cv < convexes.size())
106 return short_type(convexes[cv].first_int_pt_onface_id.size());
111 bool use_filter)
const {
113 if (cv < convexes.size()) {
114 if (i < convexes[cv].nb_int_pts) {
115 size_type int_pt_id = use_filter ? convexes[cv].first_int_pt_fid
116 : convexes[cv].first_int_pt_id;
118 return int_pt_id + i;
121 const getfem::papprox_integration pim = approx_int_method_of_element(cv);
122 for (
short_type f=0, nb_faces=pim->nb_convex_faces();
124 if (i < pim->repart()[f+1]) {
125 size_type int_pt_id = use_filter ? convexes[cv].first_int_pt_onface_fid[f]
126 : convexes[cv].first_int_pt_onface_id[f];
128 return int_pt_id + i - pim->ind_first_point_on_face(f);
140 bool use_filter)
const {
142 if (cv < convexes.size()) {
144 return use_filter ? convexes[cv].first_int_pt_fid
145 : convexes[cv].first_int_pt_id;
148 return use_filter ? convexes[cv].first_int_pt_onface_fid[f]
149 : convexes[cv].first_int_pt_onface_id[f];
172 local_guard lock = locks_.get_lock();
182 convexes.resize(nb_cv);
184 for (dal::bv_visitor cv(im_.
convex_index()); !cv.finished(); ++cv)
185 convexes[cv].nb_int_pts
188 nb_int_pts_intern = 0;
189 nb_filtered_int_pts_intern = 0;
192 for (dal::bv_visitor cv(im_.
convex_index()); !cv.finished(); ++cv) {
193 convexes[cv].first_int_pt_id = nb_int_pts_intern;
194 nb_int_pts_intern += convexes[cv].nb_int_pts;
195 if (no_region || rg.is_in(cv)) {
196 convexes[cv].first_int_pt_fid = nb_filtered_int_pts_intern;
197 nb_filtered_int_pts_intern += convexes[cv].nb_int_pts;
201 nb_int_pts_onfaces = 0;
202 nb_filtered_int_pts_onfaces = 0;
204 for (dal::bv_visitor cv(im_.
convex_index()); !cv.finished(); ++cv) {
206 convexes[cv].first_int_pt_onface_id.assign(nb_faces,
size_type(-1));
207 convexes[cv].first_int_pt_onface_fid.assign(nb_faces,
size_type(-1));
208 convexes[cv].nb_int_pts_onface.assign(nb_faces,
size_type(-1));
209 const getfem::papprox_integration pim(approx_int_method_of_element(cv));
211 convexes[cv].first_int_pt_onface_id[f] = nb_int_pts_intern +
213 size_type nb_pts = pim->nb_points_on_face(f);
214 nb_int_pts_onfaces += nb_pts;
215 if (rg.is_in(cv, f)) {
216 convexes[cv].first_int_pt_onface_fid[f] = nb_filtered_int_pts_intern +
217 nb_filtered_int_pts_onfaces;
218 nb_filtered_int_pts_onfaces += nb_pts;
220 convexes[cv].nb_int_pts_onface[f] = nb_pts;
224 v_num_ = act_counter();
229 return nb_tensor_elem_;
232 void im_data::set_tensor_size(
const bgeot::multi_index& tsize) {
233 if (actual_tensor_size_ == tensor_size_) actual_tensor_size_ = tsize;
234 tensor_size_ = tsize;
235 nb_tensor_elem_ = tensor_size_.total_size();
238 void im_data::set_actual_tensor_size(
const bgeot::multi_index& tsize) {
239 actual_tensor_size_ = tsize.empty() ? tensor_size_ : tsize;
243 bool checked =
false;
245 for (
size_type i = 0; i < sizes.size(); ++i) {
246 if (sizes[i] > 1 && checked)
return false;
250 if (size != vector_size)
return false;
253 return (vector_size == size);
257 if (nrows == 1 || ncols == 1) {
262 bool first_checked =
false;
263 bool second_checked =
false;
264 for (
size_type i = 0; i < sizes.size(); ++i) {
265 if (sizes[i] > 1 && !first_checked) {
266 first_checked =
true;
267 tensor_row = sizes[i];
268 if (tensor_row != nrows)
return false;
269 }
else if (sizes[i] > 1 && !second_checked) {
270 second_checked =
true;
271 tensor_col = sizes[i];
272 if (tensor_col != ncols)
return false;
274 else if (sizes[i] > 1 && first_checked && second_checked)
return false;
276 return (nrows == tensor_row && ncols == tensor_col);
short_type nb_faces_of_convex(size_type ic) const
Return the number of faces of convex ic.
bool context_check() const
return true if update_from_context was called
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.
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.
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.
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_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.
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.
const dal::bit_vector & convex_index(void) const
Get the set of convexes where an integration method has been assigned.
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_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.
const dal::bit_vector & index() const
Index of the region convexes, or the convexes from the partition on the current thread.
const mesh_region region(size_type id) const
Return the region of index 'id'.
Provides indexing of integration points for mesh_im.
Tools for multithreaded, OpenMP and Boost based parallelization.
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