Debian Codegraph @

packages/stk/stk_unit_tests/stk_mesh/UnitTestFieldQueryFunctions.cpp

raw
1 // Copyright 2002 - 2008, 2010, 2011 National Technology Engineering
2 // Solutions of Sandia, LLC (NTESS). Under the terms of Contract
3 // DE-NA0003525 with NTESS, the U.S. Government retains certain rights
4 // in this software.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following
15 // disclaimer in the documentation and/or other materials provided
16 // with the distribution.
17 //
18 // * Neither the name of NTESS nor the names of its contributors
19 // may be used to endorse or promote products derived from this
20 // software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 //
34
35 #include "stk_mesh/base/Bucket.hpp" // for Bucket
36 #include "stk_mesh/base/Field.hpp" // for Field
37 #include "stk_mesh/base/FieldBase.hpp" // for field_bytes_per_entity, etc
38 #include "stk_mesh/base/Part.hpp" // for Part
39 #include "stk_mesh/base/Types.hpp" // for BucketVector, PartVector, etc
40 #include "stk_mesh/base/MeshBuilder.hpp"
41 #include "stk_topology/topology.hpp" // for topology, etc
42 #include <stk_mesh/base/BulkData.hpp> // for BulkData
43 #include <stk_mesh/base/MetaData.hpp> // for MetaData, put_field, etc
44 #include <stk_unit_test_utils/MeshFixture.hpp>
45 #include <stk_unit_test_utils/TextMesh.hpp>
46 #include <stk_util/parallel/Parallel.hpp> // for ParallelMachine
47 #include <gtest/gtest.h> // for AssertHelper, EXPECT_EQ, etc
48 #include <string> // for string, operator==, etc
49
50 namespace {
51
52 class FieldQueryFunctions : public stk::unit_test_util::MeshFixture
53 {
54 public:
55 FieldQueryFunctions()
56 : MeshFixture(),
57 m_doubleField(nullptr),
58 m_intField(nullptr),
59 m_block1Part(nullptr),
60 m_block2Part(nullptr)
61 {}
62
63 void setup_mesh_scalar_fields_one_block() {
64 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
65
66 m_block1Part = &get_meta().declare_part_with_topology("block_1", stk::topology::HEX_8);
67 m_doubleField = &get_meta().declare_field<double>(stk::topology::ELEMENT_RANK, "double_field");
68 m_intField = &get_meta().declare_field<int>(stk::topology::ELEMENT_RANK, "int_field");
69 stk::mesh::put_field_on_mesh(*m_doubleField, *m_block1Part, nullptr);
70 stk::mesh::put_field_on_mesh(*m_intField, *m_block1Part, nullptr);
71
72 const std::string meshDesc = "0,1,HEX_8,1,2,3,4,5,6,7,8,block_1\n"
73 "0,2,HEX_8,5,6,7,8,9,10,11,12,block_1\n";
74
75 stk::unit_test_util::setup_text_mesh(get_bulk(), meshDesc);
76 }
77
78 void setup_mesh_vector_fields_one_block() {
79 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
80
81 m_block1Part = &get_meta().declare_part_with_topology("block_1", stk::topology::HEX_8);
82 m_doubleField = &get_meta().declare_field<double>(stk::topology::ELEMENT_RANK, "double_field");
83 m_intField = &get_meta().declare_field<int>(stk::topology::ELEMENT_RANK, "int_field");
84 stk::mesh::put_field_on_mesh(*m_doubleField, *m_block1Part, 3, nullptr);
85 stk::mesh::put_field_on_mesh(*m_intField, *m_block1Part, 3, nullptr);
86
87 const std::string meshDesc = "0,1,HEX_8,1,2,3,4,5,6,7,8,block_1\n"
88 "0,2,HEX_8,5,6,7,8,9,10,11,12,block_1\n";
89
90 stk::unit_test_util::setup_text_mesh(get_bulk(), meshDesc);
91 }
92
93 void setup_mesh_vector_fields_four_copies_one_block() {
94 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
95
96 m_block1Part = &get_meta().declare_part_with_topology("block_1", stk::topology::HEX_8);
97 m_doubleField = &get_meta().declare_field<double>(stk::topology::ELEMENT_RANK, "double_field");
98 m_intField = &get_meta().declare_field<int>(stk::topology::ELEMENT_RANK, "int_field");
99 stk::mesh::put_field_on_mesh(*m_doubleField, *m_block1Part, 3, 4, nullptr);
100 stk::mesh::put_field_on_mesh(*m_intField, *m_block1Part, 3, 4, nullptr);
101
102 const std::string meshDesc = "0,1,HEX_8,1,2,3,4,5,6,7,8,block_1\n"
103 "0,2,HEX_8,5,6,7,8,9,10,11,12,block_1\n";
104
105 stk::unit_test_util::setup_text_mesh(get_bulk(), meshDesc);
106 }
107
108 void setup_mesh_vector_fields_not_on_all_blocks() {
109 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
110
111 m_block1Part = &get_meta().declare_part_with_topology("block_1", stk::topology::HEX_8);
112 m_block2Part = &get_meta().declare_part_with_topology("block_2", stk::topology::HEX_8);
113 m_doubleField = &get_meta().declare_field<double>(stk::topology::ELEMENT_RANK, "double_field");
114 m_intField = &get_meta().declare_field<int>(stk::topology::ELEMENT_RANK, "int_field");
115 stk::mesh::put_field_on_mesh(*m_doubleField, *m_block1Part, 3, nullptr);
116 stk::mesh::put_field_on_mesh(*m_intField, *m_block2Part, 3, nullptr);
117
118 const std::string meshDesc = "0,1,HEX_8,1,2,3,4,5,6,7,8,block_1\n"
119 "0,2,HEX_8,5,6,7,8,9,10,11,12,block_2\n";
120
121 stk::unit_test_util::setup_text_mesh(get_bulk(), meshDesc);
122 }
123
124 void setup_mesh_vector_fields_variable_num_copies() {
125 setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
126
127 m_block1Part = &get_meta().declare_part_with_topology("block_1", stk::topology::HEX_8);
128 m_block2Part = &get_meta().declare_part_with_topology("block_2", stk::topology::HEX_8);
129 m_doubleField = &get_meta().declare_field<double>(stk::topology::ELEMENT_RANK, "double_field");
130 m_intField = &get_meta().declare_field<int>(stk::topology::ELEMENT_RANK, "int_field");
131 stk::mesh::put_field_on_mesh(*m_doubleField, *m_block1Part, 3, 1, nullptr);
132 stk::mesh::put_field_on_mesh(*m_doubleField, *m_block2Part, 3, 2, nullptr);
133 stk::mesh::put_field_on_mesh(*m_intField, *m_block1Part, 3, 4, nullptr);
134 stk::mesh::put_field_on_mesh(*m_intField, *m_block2Part, 3, 1, nullptr);
135
136 const std::string meshDesc = "0,1,HEX_8,1,2,3,4,5,6,7,8,block_1\n"
137 "0,2,HEX_8,5,6,7,8,9,10,11,12,block_2\n";
138
139 stk::unit_test_util::setup_text_mesh(get_bulk(), meshDesc);
140 }
141
142 stk::mesh::Field<double> * m_doubleField;
143 stk::mesh::Field<int> * m_intField;
144 stk::mesh::Part * m_block1Part;
145 stk::mesh::Part * m_block2Part;
146 };
147
148
149 TEST_F(FieldQueryFunctions, fieldBytesPerEntity_scalarFields_singleBlock)
150 {
151 if (get_parallel_size() != 1) return;
152
153 setup_mesh_scalar_fields_one_block();
154
155 const unsigned expectedDoubleBytes = sizeof(double);
156 const unsigned expectedIntBytes = sizeof(int);
157
158 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
159 {
160 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, *bucket), expectedDoubleBytes);
161 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, *bucket), expectedIntBytes);
162
163 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, bucket->bucket_id()), expectedDoubleBytes);
164 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, bucket->bucket_id()), expectedIntBytes);
165
166 for (const stk::mesh::Entity element : *bucket) {
167 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, element), expectedDoubleBytes);
168 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, element), expectedIntBytes);
169 }
170 }
171 }
172
173 TEST_F(FieldQueryFunctions, fieldBytesPerEntity_vectorFields_singleBlock)
174 {
175 if (get_parallel_size() != 1) return;
176
177 setup_mesh_vector_fields_one_block();
178
179 const unsigned expectedDoubleBytes = 3 * sizeof(double);
180 const unsigned expectedIntBytes = 3 * sizeof(int);
181
182 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
183 {
184 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, *bucket), expectedDoubleBytes);
185 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, *bucket), expectedIntBytes);
186
187 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, bucket->bucket_id()), expectedDoubleBytes);
188 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, bucket->bucket_id()), expectedIntBytes);
189
190 for (const stk::mesh::Entity element : *bucket) {
191 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, element), expectedDoubleBytes);
192 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, element), expectedIntBytes);
193 }
194 }
195 }
196
197 TEST_F(FieldQueryFunctions, fieldBytesPerEntity_vectorFieldsFourCopies_singleBlock)
198 {
199 if (get_parallel_size() != 1) return;
200
201 setup_mesh_vector_fields_four_copies_one_block();
202
203 const unsigned expectedDoubleBytes = 3 * 4 * sizeof(double);
204 const unsigned expectedIntBytes = 3 * 4 * sizeof(int);
205
206 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
207 {
208 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, *bucket), expectedDoubleBytes);
209 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, *bucket), expectedIntBytes);
210
211 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, bucket->bucket_id()), expectedDoubleBytes);
212 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, bucket->bucket_id()), expectedIntBytes);
213
214 for (const stk::mesh::Entity element : *bucket) {
215 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, element), expectedDoubleBytes);
216 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, element), expectedIntBytes);
217 }
218 }
219 }
220
221 TEST_F(FieldQueryFunctions, fieldBytesPerEntity_vectorFields_notOnAllBlocks)
222 {
223 if (get_parallel_size() != 1) return;
224
225 setup_mesh_vector_fields_not_on_all_blocks();
226
227 unsigned expectedDoubleBytes = 0;
228 unsigned expectedIntBytes = 0;
229
230 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
231 {
232 if (bucket->member(*m_block1Part)) {
233 expectedDoubleBytes = 3 * sizeof(double);
234 expectedIntBytes = 0;
235 }
236 else if (bucket->member(*m_block2Part)) {
237 expectedDoubleBytes = 0;
238 expectedIntBytes = 3 * sizeof(int);
239 }
240
241 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, *bucket), expectedDoubleBytes);
242 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, *bucket), expectedIntBytes);
243
244 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, bucket->bucket_id()), expectedDoubleBytes);
245 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, bucket->bucket_id()), expectedIntBytes);
246
247 for (const stk::mesh::Entity element : *bucket) {
248 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, element), expectedDoubleBytes);
249 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, element), expectedIntBytes);
250 }
251 }
252 }
253
254 TEST_F(FieldQueryFunctions, fieldBytesPerEntity_vectorFields_variableNumCopies)
255 {
256 if (get_parallel_size() != 1) return;
257
258 setup_mesh_vector_fields_variable_num_copies();
259
260 unsigned expectedDoubleBytes = 0;
261 unsigned expectedIntBytes = 0;
262
263 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
264 {
265 if (bucket->member(*m_block1Part)) {
266 expectedDoubleBytes = 3 * 1 * sizeof(double);
267 expectedIntBytes = 3 * 4 * sizeof(int);
268 }
269 else if (bucket->member(*m_block2Part)) {
270 expectedDoubleBytes = 3 * 2 * sizeof(double);
271 expectedIntBytes = 3 * 1 * sizeof(int);
272 }
273
274 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, *bucket), expectedDoubleBytes);
275 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, *bucket), expectedIntBytes);
276
277 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, bucket->bucket_id()), expectedDoubleBytes);
278 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, bucket->bucket_id()), expectedIntBytes);
279
280 for (const stk::mesh::Entity element : *bucket) {
281 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_doubleField, element), expectedDoubleBytes);
282 EXPECT_EQ(stk::mesh::field_bytes_per_entity(*m_intField, element), expectedIntBytes);
283 }
284 }
285 }
286
287
288 TEST_F(FieldQueryFunctions, isMatchingRank_scalarFields_singleBlock)
289 {
290 if (get_parallel_size() != 1) return;
291
292 setup_mesh_scalar_fields_one_block();
293
294 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, stk::topology::ELEMENT_RANK), true);
295 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, stk::topology::ELEMENT_RANK), true);
296
297 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
298 {
299 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, *bucket), true);
300 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, *bucket), true);
301
302 for (const stk::mesh::Entity element : *bucket) {
303 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, element), true);
304 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, element), true);
305 }
306 }
307 }
308
309 TEST_F(FieldQueryFunctions, isMatchingRank_vectorFields_singleBlock)
310 {
311 if (get_parallel_size() != 1) return;
312
313 setup_mesh_vector_fields_one_block();
314
315 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, stk::topology::ELEMENT_RANK), true);
316 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, stk::topology::ELEMENT_RANK), true);
317
318 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
319 {
320 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, *bucket), true);
321 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, *bucket), true);
322
323 for (const stk::mesh::Entity element : *bucket) {
324 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, element), true);
325 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, element), true);
326 }
327 }
328 }
329
330 TEST_F(FieldQueryFunctions, isMatchingRank_vectorFieldsFourCopies_singleBlock)
331 {
332 if (get_parallel_size() != 1) return;
333
334 setup_mesh_vector_fields_four_copies_one_block();
335
336 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, stk::topology::ELEMENT_RANK), true);
337 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, stk::topology::ELEMENT_RANK), true);
338
339 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
340 {
341 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, *bucket), true);
342 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, *bucket), true);
343
344 for (const stk::mesh::Entity element : *bucket) {
345 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, element), true);
346 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, element), true);
347 }
348 }
349 }
350
351 TEST_F(FieldQueryFunctions, isMatchingRank_vectorFields_notOnAllBlocks)
352 {
353 if (get_parallel_size() != 1) return;
354
355 setup_mesh_vector_fields_not_on_all_blocks();
356
357 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, stk::topology::ELEMENT_RANK), true);
358 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, stk::topology::ELEMENT_RANK), true);
359
360 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
361 {
362 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, *bucket), true);
363 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, *bucket), true);
364
365 for (const stk::mesh::Entity element : *bucket) {
366 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, element), true);
367 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, element), true);
368 }
369 }
370 }
371
372 TEST_F(FieldQueryFunctions, isMatchingRank_vectorFields_variableNumCopies)
373 {
374 if (get_parallel_size() != 1) return;
375
376 setup_mesh_vector_fields_variable_num_copies();
377
378 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, stk::topology::ELEMENT_RANK), true);
379 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, stk::topology::ELEMENT_RANK), true);
380
381 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
382 {
383 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, *bucket), true);
384 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, *bucket), true);
385
386 for (const stk::mesh::Entity element : *bucket) {
387 EXPECT_EQ(stk::mesh::is_matching_rank(*m_doubleField, element), true);
388 EXPECT_EQ(stk::mesh::is_matching_rank(*m_intField, element), true);
389 }
390 }
391 }
392
393
394 TEST_F(FieldQueryFunctions, fieldScalarsPerEntity_scalarFields_singleBlock)
395 {
396 if (get_parallel_size() != 1) return;
397
398 setup_mesh_scalar_fields_one_block();
399
400 const unsigned expectedSize = 1;
401
402 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
403 {
404 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, *bucket), expectedSize);
405 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, *bucket), expectedSize);
406
407 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, bucket->bucket_id()), expectedSize);
408 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, bucket->bucket_id()), expectedSize);
409
410 for (const stk::mesh::Entity element : *bucket) {
411 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, element), expectedSize);
412 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, element), expectedSize);
413 }
414 }
415 }
416
417 TEST_F(FieldQueryFunctions, fieldScalarsPerEntity_vectorFields_singleBlock)
418 {
419 if (get_parallel_size() != 1) return;
420
421 setup_mesh_vector_fields_one_block();
422
423 const unsigned expectedSize = 3;
424
425 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
426 {
427 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, *bucket), expectedSize);
428 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, *bucket), expectedSize);
429
430 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, bucket->bucket_id()), expectedSize);
431 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, bucket->bucket_id()), expectedSize);
432
433 for (const stk::mesh::Entity element : *bucket) {
434 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, element), expectedSize);
435 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, element), expectedSize);
436 }
437 }
438 }
439
440 TEST_F(FieldQueryFunctions, fieldScalarsPerEntity_vectorFieldsFourCopies_singleBlock)
441 {
442 if (get_parallel_size() != 1) return;
443
444 setup_mesh_vector_fields_four_copies_one_block();
445
446 const unsigned expectedSize = 3 * 4;
447
448 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
449 {
450 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, *bucket), expectedSize);
451 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, *bucket), expectedSize);
452
453 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, bucket->bucket_id()), expectedSize);
454 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, bucket->bucket_id()), expectedSize);
455
456 for (const stk::mesh::Entity element : *bucket) {
457 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, element), expectedSize);
458 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, element), expectedSize);
459 }
460 }
461 }
462
463 TEST_F(FieldQueryFunctions, fieldScalarsPerEntity_vectorFields_notOnAllBlocks)
464 {
465 if (get_parallel_size() != 1) return;
466
467 setup_mesh_vector_fields_not_on_all_blocks();
468
469 unsigned expectedDoubleSize = 0;
470 unsigned expectedIntSize = 0;
471
472 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
473 {
474 if (bucket->member(*m_block1Part)) {
475 expectedDoubleSize = 3;
476 expectedIntSize = 0;
477 }
478 else if (bucket->member(*m_block2Part)) {
479 expectedDoubleSize = 0;
480 expectedIntSize = 3;
481 }
482
483 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, *bucket), expectedDoubleSize);
484 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, *bucket), expectedIntSize);
485
486 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, bucket->bucket_id()), expectedDoubleSize);
487 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, bucket->bucket_id()), expectedIntSize);
488
489 for (const stk::mesh::Entity element : *bucket) {
490 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, element), expectedDoubleSize);
491 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, element), expectedIntSize);
492 }
493 }
494 }
495
496 TEST_F(FieldQueryFunctions, fieldScalarsPerEntity_vectorFields_variableNumCopies)
497 {
498 if (get_parallel_size() != 1) return;
499
500 setup_mesh_vector_fields_variable_num_copies();
501
502 unsigned expectedDoubleSize = 0;
503 unsigned expectedIntSize = 0;
504
505 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
506 {
507 if (bucket->member(*m_block1Part)) {
508 expectedDoubleSize = 3 * 1;
509 expectedIntSize = 3 * 4;
510 }
511 else if (bucket->member(*m_block2Part)) {
512 expectedDoubleSize = 3 * 2;
513 expectedIntSize = 3 * 1;
514 }
515
516 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, *bucket), expectedDoubleSize);
517 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, *bucket), expectedIntSize);
518
519 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, bucket->bucket_id()), expectedDoubleSize);
520 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, bucket->bucket_id()), expectedIntSize);
521
522 for (const stk::mesh::Entity element : *bucket) {
523 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_doubleField, element), expectedDoubleSize);
524 EXPECT_EQ(stk::mesh::field_scalars_per_entity(*m_intField, element), expectedIntSize);
525 }
526 }
527 }
528
529
530 TEST_F(FieldQueryFunctions, fieldExtentPerEntity_scalarFields_singleBlock)
531 {
532 if (get_parallel_size() != 1) return;
533
534 setup_mesh_scalar_fields_one_block();
535
536 const unsigned expectedSize = 1;
537
538 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
539 {
540 {
541 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, *bucket), expectedSize);
542 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, *bucket), expectedSize);
543
544 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, *bucket), expectedSize);
545 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, *bucket), expectedSize);
546
547 for (unsigned i = 0; i < 5; ++i) {
548 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, *bucket), expectedSize);
549 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, *bucket), expectedSize);
550 }
551 }
552
553 {
554 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, bucket->bucket_id()), expectedSize);
555 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, bucket->bucket_id()), expectedSize);
556
557 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, bucket->bucket_id()), expectedSize);
558 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, bucket->bucket_id()), expectedSize);
559
560 for (unsigned i = 0; i < 5; ++i) {
561 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, bucket->bucket_id()), expectedSize);
562 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, bucket->bucket_id()), expectedSize);
563 }
564 }
565
566 for (const stk::mesh::Entity element : *bucket) {
567 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, element), expectedSize);
568 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, element), expectedSize);
569
570 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, element), expectedSize);
571 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, element), expectedSize);
572
573 for (unsigned i = 0; i < 5; ++i) {
574 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, element), expectedSize);
575 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, element), expectedSize);
576 }
577 }
578 }
579 }
580
581 TEST_F(FieldQueryFunctions, fieldExtentPerEntity_vectorFields_singleBlock)
582 {
583 if (get_parallel_size() != 1) return;
584
585 setup_mesh_vector_fields_one_block();
586
587 const unsigned expectedFirstExtent = 3;
588 const unsigned expectedRemainingExtents = 1;
589
590 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
591 {
592 {
593 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, *bucket), expectedFirstExtent);
594 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, *bucket), expectedFirstExtent);
595
596 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, *bucket), expectedRemainingExtents);
597 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, *bucket), expectedRemainingExtents);
598
599 for (unsigned i = 0; i < 5; ++i) {
600 const unsigned expected = (i == 0) ? expectedFirstExtent : expectedRemainingExtents;
601 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, *bucket), expected);
602 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, *bucket), expected);
603 }
604 }
605
606 {
607 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, bucket->bucket_id()), expectedFirstExtent);
608 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, bucket->bucket_id()), expectedFirstExtent);
609
610 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, bucket->bucket_id()), expectedRemainingExtents);
611 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, bucket->bucket_id()), expectedRemainingExtents);
612
613 for (unsigned i = 0; i < 5; ++i) {
614 const unsigned expected = (i == 0) ? expectedFirstExtent : expectedRemainingExtents;
615 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, bucket->bucket_id()), expected);
616 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, bucket->bucket_id()), expected);
617 }
618 }
619
620 for (const stk::mesh::Entity element : *bucket) {
621 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, element), expectedFirstExtent);
622 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, element), expectedFirstExtent);
623
624 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, element), expectedRemainingExtents);
625 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, element), expectedRemainingExtents);
626
627 for (unsigned i = 0; i < 5; ++i) {
628 const unsigned expected = (i == 0) ? expectedFirstExtent : expectedRemainingExtents;
629 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, element), expected);
630 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, element), expected);
631 }
632 }
633 }
634 }
635
636 TEST_F(FieldQueryFunctions, fieldExtentPerEntity_vectorFieldsFourCopies_singleBlock)
637 {
638 if (get_parallel_size() != 1) return;
639
640 setup_mesh_vector_fields_four_copies_one_block();
641
642 const unsigned expectedFirstExtent = 3;
643 const unsigned expectedSecondExtent = 4;
644 const unsigned expectedRemainingExtents = 1;
645
646 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
647 {
648 {
649 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, *bucket), expectedFirstExtent);
650 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, *bucket), expectedFirstExtent);
651
652 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, *bucket), expectedSecondExtent);
653 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, *bucket), expectedSecondExtent);
654
655 for (unsigned i = 0; i < 5; ++i) {
656 const unsigned expected = (i == 0) ? expectedFirstExtent
657 : (i == 1) ? expectedSecondExtent : expectedRemainingExtents;
658 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, *bucket), expected);
659 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, *bucket), expected);
660 }
661 }
662
663 {
664 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, bucket->bucket_id()), expectedFirstExtent);
665 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, bucket->bucket_id()), expectedFirstExtent);
666
667 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, bucket->bucket_id()), expectedSecondExtent);
668 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, bucket->bucket_id()), expectedSecondExtent);
669
670 for (unsigned i = 0; i < 5; ++i) {
671 const unsigned expected = (i == 0) ? expectedFirstExtent
672 : (i == 1) ? expectedSecondExtent : expectedRemainingExtents;
673 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, bucket->bucket_id()), expected);
674 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, bucket->bucket_id()), expected);
675 }
676 }
677
678 for (const stk::mesh::Entity element : *bucket) {
679 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, element), expectedFirstExtent);
680 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, element), expectedFirstExtent);
681
682 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, element), expectedSecondExtent);
683 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, element), expectedSecondExtent);
684
685 for (unsigned i = 0; i < 5; ++i) {
686 const unsigned expected = (i == 0) ? expectedFirstExtent
687 : (i == 1) ? expectedSecondExtent : expectedRemainingExtents;
688 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, element), expected);
689 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, element), expected);
690 }
691 }
692 }
693 }
694
695 TEST_F(FieldQueryFunctions, fieldExtentPerEntity_vectorFields_notOnAllBlocks)
696 {
697 if (get_parallel_size() != 1) return;
698
699 setup_mesh_vector_fields_not_on_all_blocks();
700
701 unsigned expectedDoubleFirstExtent = 0;
702 unsigned expectedIntFirstExtent = 0;
703 unsigned expectedDoubleSecondExtent = 0;
704 unsigned expectedIntSecondExtent = 0;
705 unsigned expectedDoubleRemainingExtents = 0;
706 unsigned expectedIntRemainingExtents = 0;
707
708 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
709 {
710 if (bucket->member(*m_block1Part)) {
711 expectedDoubleFirstExtent = 3;
712 expectedIntFirstExtent = 0;
713 expectedDoubleSecondExtent = 1;
714 expectedIntSecondExtent = 0;
715 expectedDoubleRemainingExtents = 1;
716 expectedIntRemainingExtents = 0;
717 }
718 else if (bucket->member(*m_block2Part)) {
719 expectedDoubleFirstExtent = 0;
720 expectedIntFirstExtent = 3;
721 expectedDoubleSecondExtent = 0;
722 expectedIntSecondExtent = 1;
723 expectedDoubleRemainingExtents = 0;
724 expectedIntRemainingExtents = 1;
725 }
726
727 {
728 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, *bucket), expectedDoubleFirstExtent);
729 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, *bucket), expectedIntFirstExtent);
730
731 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, *bucket), expectedDoubleSecondExtent);
732 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, *bucket), expectedIntSecondExtent);
733
734 for (unsigned i = 0; i < 5; ++i) {
735 const unsigned expectedDouble = (i == 0) ? expectedDoubleFirstExtent
736 : (i == 1) ? expectedDoubleSecondExtent : expectedDoubleRemainingExtents;
737 const unsigned expectedInt = (i == 0) ? expectedIntFirstExtent
738 : (i == 1) ? expectedIntSecondExtent : expectedIntRemainingExtents;
739 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, *bucket), expectedDouble);
740 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, *bucket), expectedInt);
741 }
742 }
743
744 {
745 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, bucket->bucket_id()), expectedDoubleFirstExtent);
746 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, bucket->bucket_id()), expectedIntFirstExtent);
747
748 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, bucket->bucket_id()), expectedDoubleSecondExtent);
749 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, bucket->bucket_id()), expectedIntSecondExtent);
750
751 for (unsigned i = 0; i < 5; ++i) {
752 const unsigned expectedDouble = (i == 0) ? expectedDoubleFirstExtent
753 : (i == 1) ? expectedDoubleSecondExtent : expectedDoubleRemainingExtents;
754 const unsigned expectedInt = (i == 0) ? expectedIntFirstExtent
755 : (i == 1) ? expectedIntSecondExtent : expectedIntRemainingExtents;
756 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, bucket->bucket_id()), expectedDouble);
757 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, bucket->bucket_id()), expectedInt);
758 }
759 }
760
761 for (const stk::mesh::Entity element : *bucket) {
762 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, element), expectedDoubleFirstExtent);
763 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, element), expectedIntFirstExtent);
764
765 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, element), expectedDoubleSecondExtent);
766 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, element), expectedIntSecondExtent);
767
768 for (unsigned i = 0; i < 5; ++i) {
769 const unsigned expectedDouble = (i == 0) ? expectedDoubleFirstExtent
770 : (i == 1) ? expectedDoubleSecondExtent : expectedDoubleRemainingExtents;
771 const unsigned expectedInt = (i == 0) ? expectedIntFirstExtent
772 : (i == 1) ? expectedIntSecondExtent : expectedIntRemainingExtents;
773 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, element), expectedDouble);
774 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, element), expectedInt);
775 }
776 }
777 }
778 }
779
780 TEST_F(FieldQueryFunctions, fieldExtentPerEntity_vectorFields_variableNumCopies)
781 {
782 if (get_parallel_size() != 1) return;
783
784 setup_mesh_vector_fields_variable_num_copies();
785
786 unsigned expectedDoubleFirstExtent = 0;
787 unsigned expectedIntFirstExtent = 0;
788 unsigned expectedDoubleSecondExtent = 0;
789 unsigned expectedIntSecondExtent = 0;
790 unsigned expectedDoubleRemainingExtents = 0;
791 unsigned expectedIntRemainingExtents = 0;
792
793 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK))
794 {
795 if (bucket->member(*m_block1Part)) {
796 expectedDoubleFirstExtent = 3;
797 expectedIntFirstExtent = 3;
798 expectedDoubleSecondExtent = 1;
799 expectedIntSecondExtent = 4;
800 expectedDoubleRemainingExtents = 1;
801 expectedIntRemainingExtents = 1;
802 }
803 else if (bucket->member(*m_block2Part)) {
804 expectedDoubleFirstExtent = 3;
805 expectedIntFirstExtent = 3;
806 expectedDoubleSecondExtent = 2;
807 expectedIntSecondExtent = 1;
808 expectedDoubleRemainingExtents = 1;
809 expectedIntRemainingExtents = 1;
810 }
811
812 {
813 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, *bucket), expectedDoubleFirstExtent);
814 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, *bucket), expectedIntFirstExtent);
815
816 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, *bucket), expectedDoubleSecondExtent);
817 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, *bucket), expectedIntSecondExtent);
818
819 for (unsigned i = 0; i < 5; ++i) {
820 const unsigned expectedDouble = (i == 0) ? expectedDoubleFirstExtent
821 : (i == 1) ? expectedDoubleSecondExtent : expectedDoubleRemainingExtents;
822 const unsigned expectedInt = (i == 0) ? expectedIntFirstExtent
823 : (i == 1) ? expectedIntSecondExtent : expectedIntRemainingExtents;
824 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, *bucket), expectedDouble);
825 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, *bucket), expectedInt);
826 }
827 }
828
829 {
830 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, bucket->bucket_id()), expectedDoubleFirstExtent);
831 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, bucket->bucket_id()), expectedIntFirstExtent);
832
833 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, bucket->bucket_id()), expectedDoubleSecondExtent);
834 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, bucket->bucket_id()), expectedIntSecondExtent);
835
836 for (unsigned i = 0; i < 5; ++i) {
837 const unsigned expectedDouble = (i == 0) ? expectedDoubleFirstExtent
838 : (i == 1) ? expectedDoubleSecondExtent : expectedDoubleRemainingExtents;
839 const unsigned expectedInt = (i == 0) ? expectedIntFirstExtent
840 : (i == 1) ? expectedIntSecondExtent : expectedIntRemainingExtents;
841 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, bucket->bucket_id()), expectedDouble);
842 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, bucket->bucket_id()), expectedInt);
843 }
844 }
845
846 for (const stk::mesh::Entity element : *bucket) {
847 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_doubleField, element), expectedDoubleFirstExtent);
848 EXPECT_EQ(stk::mesh::field_extent0_per_entity(*m_intField, element), expectedIntFirstExtent);
849
850 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_doubleField, element), expectedDoubleSecondExtent);
851 EXPECT_EQ(stk::mesh::field_extent1_per_entity(*m_intField, element), expectedIntSecondExtent);
852
853 for (unsigned i = 0; i < 5; ++i) {
854 const unsigned expectedDouble = (i == 0) ? expectedDoubleFirstExtent
855 : (i == 1) ? expectedDoubleSecondExtent : expectedDoubleRemainingExtents;
856 const unsigned expectedInt = (i == 0) ? expectedIntFirstExtent
857 : (i == 1) ? expectedIntSecondExtent : expectedIntRemainingExtents;
858 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_doubleField, i, element), expectedDouble);
859 EXPECT_EQ(stk::mesh::field_extent_per_entity(*m_intField, i, element), expectedInt);
860 }
861 }
862 }
863 }
864
865
866 TEST_F(FieldQueryFunctions, fieldIsAllocatedForBucket_scalarFields_singleBlock)
867 {
868 if (get_parallel_size() != 1) return;
869
870 setup_mesh_scalar_fields_one_block();
871
872 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK)) {
873 EXPECT_EQ(stk::mesh::field_is_allocated_for_bucket(*m_doubleField, *bucket), true);
874 EXPECT_EQ(stk::mesh::field_is_allocated_for_bucket(*m_intField, *bucket), true);
875 }
876 }
877
878 TEST_F(FieldQueryFunctions, fieldIsAllocatedForBucket_vectorFields_singleBlock)
879 {
880 if (get_parallel_size() != 1) return;
881
882 setup_mesh_vector_fields_one_block();
883
884 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK)) {
885 EXPECT_EQ(stk::mesh::field_is_allocated_for_bucket(*m_doubleField, *bucket), true);
886 EXPECT_EQ(stk::mesh::field_is_allocated_for_bucket(*m_intField, *bucket), true);
887 }
888 }
889
890 TEST_F(FieldQueryFunctions, fieldIsAllocatedForBucket_vectorFieldsFourCopies_singleBlock)
891 {
892 if (get_parallel_size() != 1) return;
893
894 setup_mesh_vector_fields_four_copies_one_block();
895
896 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK)) {
897 EXPECT_EQ(stk::mesh::field_is_allocated_for_bucket(*m_doubleField, *bucket), true);
898 EXPECT_EQ(stk::mesh::field_is_allocated_for_bucket(*m_intField, *bucket), true);
899 }
900 }
901
902 TEST_F(FieldQueryFunctions, fieldIsAllocatedForBucket_vectorFields_notOnAllBlocks)
903 {
904 if (get_parallel_size() != 1) return;
905
906 setup_mesh_vector_fields_not_on_all_blocks();
907
908 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK)) {
909 if (bucket->member(*m_block1Part)) {
910 EXPECT_EQ(stk::mesh::field_is_allocated_for_bucket(*m_doubleField, *bucket), true);
911 EXPECT_EQ(stk::mesh::field_is_allocated_for_bucket(*m_intField, *bucket), false);
912 }
913 else if (bucket->member(*m_block2Part)) {
914 EXPECT_EQ(stk::mesh::field_is_allocated_for_bucket(*m_doubleField, *bucket), false);
915 EXPECT_EQ(stk::mesh::field_is_allocated_for_bucket(*m_intField, *bucket), true);
916 }
917 }
918 }
919
920 TEST_F(FieldQueryFunctions, fieldIsAllocatedForBucket_vectorFields_variableNumCopies)
921 {
922 if (get_parallel_size() != 1) return;
923
924 setup_mesh_vector_fields_variable_num_copies();
925
926 for (const stk::mesh::Bucket * bucket : get_bulk().buckets(stk::topology::ELEMENT_RANK)) {
927 EXPECT_EQ(stk::mesh::field_is_allocated_for_bucket(*m_doubleField, *bucket), true);
928 EXPECT_EQ(stk::mesh::field_is_allocated_for_bucket(*m_intField, *bucket), true);
929 }
930 }
931
932 }