29 bgeot::multi_index tsize,
31 bgeot::multi_index actual_tsize)
32 : im_(mim), region_(filtered_region_),
33 nb_int_pts_intern(0), nb_int_pts_onfaces(0),
34 nb_filtered_int_pts_intern(0), nb_filtered_int_pts_onfaces(0),
37 set_tensor_size(tsize);
38 set_actual_tensor_size(actual_tsize);
44 : im_(mim), region_(filtered_region_),
45 nb_int_pts_intern(0), nb_int_pts_onfaces(0),
46 nb_filtered_int_pts_intern(0), nb_filtered_int_pts_onfaces(0),
49 tensor_size_.resize(1);
51 actual_tensor_size_ = tensor_size_;
60 return nb_filtered_int_pts_intern + nb_filtered_int_pts_onfaces;
62 return nb_int_pts_intern + nb_int_pts_onfaces;
67 if (cv < convexes.size()) {
72 if (convexes[cv].first_int_pt_onface_fid[f] !=
size_type(-1))
73 nb_int_pts += convexes[cv].nb_int_pts_onface[f];
74 if (convexes[cv].first_int_pt_fid !=
size_type(-1))
75 nb_int_pts += convexes[cv].nb_int_pts;
78 for (
auto nb_pts : convexes[cv].nb_int_pts_onface)
80 if (nb_int_pts_intern > 0)
81 nb_int_pts += convexes[cv].nb_int_pts;
89 bool use_filter)
const {
91 if (cv < convexes.size()) {
93 if (!use_filter || convexes[cv].first_int_pt_fid !=
size_type(-1))
94 return convexes[cv].nb_int_pts;
96 else if (f < convexes[cv].nb_int_pts_onface.size()) {
97 if (!use_filter || convexes[cv].first_int_pt_onface_fid[f] !=
size_type(-1))
98 return convexes[cv].nb_int_pts_onface[f];
106 if (cv < convexes.size())
107 return short_type(convexes[cv].first_int_pt_onface_id.size());
112 bool use_filter)
const {
114 if (cv < convexes.size()) {
115 if (i < convexes[cv].nb_int_pts) {
116 size_type int_pt_id = use_filter ? convexes[cv].first_int_pt_fid
117 : convexes[cv].first_int_pt_id;
119 return int_pt_id + i;
122 const getfem::papprox_integration pim = approx_int_method_of_element(cv);
123 for (
short_type f=0, nb_faces=pim->nb_convex_faces();
125 if (i < pim->repart()[f+1]) {
126 size_type int_pt_id = use_filter ? convexes[cv].first_int_pt_onface_fid[f]
127 : convexes[cv].first_int_pt_onface_id[f];
129 return int_pt_id + i - pim->ind_first_point_on_face(f);
141 bool use_filter)
const {
143 if (cv < convexes.size()) {
145 return use_filter ? convexes[cv].first_int_pt_fid
146 : convexes[cv].first_int_pt_id;
149 return use_filter ? convexes[cv].first_int_pt_onface_fid[f]
150 : convexes[cv].first_int_pt_onface_id[f];
173 local_guard lock = locks_.get_lock();
183 convexes.resize(nb_cv);
185 for (dal::bv_visitor cv(im_.
convex_index()); !cv.finished(); ++cv)
186 convexes[cv].nb_int_pts
189 nb_int_pts_intern = 0;
190 nb_filtered_int_pts_intern = 0;
193 for (dal::bv_visitor cv(im_.
convex_index()); !cv.finished(); ++cv) {
194 convexes[cv].first_int_pt_id = nb_int_pts_intern;
195 nb_int_pts_intern += convexes[cv].nb_int_pts;
196 if (no_region || rg.is_in(cv)) {
197 convexes[cv].first_int_pt_fid = nb_filtered_int_pts_intern;
198 nb_filtered_int_pts_intern += convexes[cv].nb_int_pts;
202 nb_int_pts_onfaces = 0;
203 nb_filtered_int_pts_onfaces = 0;
205 for (dal::bv_visitor cv(im_.
convex_index()); !cv.finished(); ++cv) {
207 convexes[cv].first_int_pt_onface_id.assign(nb_faces,
size_type(-1));
208 convexes[cv].first_int_pt_onface_fid.assign(nb_faces,
size_type(-1));
209 convexes[cv].nb_int_pts_onface.assign(nb_faces,
size_type(-1));
210 const getfem::papprox_integration pim(approx_int_method_of_element(cv));
212 convexes[cv].first_int_pt_onface_id[f] = nb_int_pts_intern +
214 size_type nb_pts = pim->nb_points_on_face(f);
215 nb_int_pts_onfaces += nb_pts;
216 if (rg.is_in(cv, f)) {
217 convexes[cv].first_int_pt_onface_fid[f] = nb_filtered_int_pts_intern +
218 nb_filtered_int_pts_onfaces;
219 nb_filtered_int_pts_onfaces += nb_pts;
221 convexes[cv].nb_int_pts_onface[f] = nb_pts;
225 v_num_ = act_counter();
230 return nb_tensor_elem_;
233 void im_data::set_tensor_size(
const bgeot::multi_index& tsize) {
234 if (actual_tensor_size_ == tensor_size_) actual_tensor_size_ = tsize;
235 tensor_size_ = tsize;
236 nb_tensor_elem_ = tensor_size_.total_size();
239 void im_data::set_actual_tensor_size(
const bgeot::multi_index& tsize) {
240 actual_tensor_size_ = tsize.empty() ? tensor_size_ : tsize;
244 bool checked =
false;
246 for (
size_type i = 0; i < sizes.size(); ++i) {
247 if (sizes[i] > 1 && checked)
return false;
251 if (size != vector_size)
return false;
254 return (vector_size == size);
258 if (nrows == 1 || ncols == 1) {
263 bool first_checked =
false;
264 bool second_checked =
false;
265 for (
size_type i = 0; i < sizes.size(); ++i) {
266 if (sizes[i] > 1 && !first_checked) {
267 first_checked =
true;
268 tensor_row = sizes[i];
269 if (tensor_row != nrows)
return false;
270 }
else if (sizes[i] > 1 && !second_checked) {
271 second_checked =
true;
272 tensor_col = sizes[i];
273 if (tensor_col != ncols)
return false;
275 else if (sizes[i] > 1 && first_checked && second_checked)
return false;
277 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