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);