| 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 <gtest/gtest.h> |
| 36 |
#include <stk_mesh/base/Ngp.hpp> |
| 37 |
#include <stk_unit_test_utils/getOption.h> |
| 38 |
#include <stk_unit_test_utils/MeshFixture.hpp> |
| 39 |
#include <stk_unit_test_utils/GetMeshSpec.hpp> |
| 40 |
#include <stk_unit_test_utils/PerformanceTester.hpp> |
| 41 |
#include <stk_mesh/base/MetaData.hpp> |
| 42 |
#include <stk_mesh/base/BulkData.hpp> |
| 43 |
#include <stk_mesh/base/Bucket.hpp> |
| 44 |
#include <stk_mesh/base/Field.hpp> |
| 45 |
#include <stk_mesh/base/Entity.hpp> |
| 46 |
#include <stk_mesh/base/GetEntities.hpp> |
| 47 |
#include <stk_mesh/base/GetNgpField.hpp> |
| 48 |
#include <stk_mesh/base/FEMHelpers.hpp> |
| 49 |
#include <stk_mesh/base/Comm.hpp> |
| 50 |
#include <stk_mesh/base/NgpFieldSyncDebugger.hpp> |
| 51 |
#include <stk_util/stk_config.h> |
| 52 |
#include "NgpDebugFieldSync_Fixtures.hpp" |
| 53 |
#include <string> |
| 54 |
#include <sstream> |
| 55 |
#include <vector> |
| 56 |
#include <numeric> |
| 57 |
|
| 58 |
namespace { |
| 59 |
|
| 60 |
class NgpDebugFieldSync_AccessDuringMeshModification : public NgpDebugFieldSyncFixture |
| 61 |
{ |
| 62 |
public: |
| 63 |
template <typename T> |
| 64 |
void write_scalar_field_on_host_using_entity_vector(stk::mesh::Field<T> & stkField, stk::mesh::EntityVector entities, T value) |
| 65 |
{ |
| 66 |
for (const stk::mesh::Entity & entity : entities) { |
| 67 |
if (get_bulk().is_valid(entity)) { |
| 68 |
const stk::mesh::MeshIndex & meshIndex = get_bulk().mesh_index(entity); |
| 69 |
const unsigned bucketId = meshIndex.bucket->bucket_id(); |
| 70 |
const stk::mesh::Bucket::size_type bucketOrd = meshIndex.bucket_ordinal; |
| 71 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, bucketId, bucketOrd); |
| 72 |
fieldData[0] = value; |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
template <typename T> |
| 78 |
void write_vector_field_on_host_using_bucket(stk::mesh::Field<T> & stkField, T value) |
| 79 |
{ |
| 80 |
const stk::mesh::BucketVector& buckets = get_bulk().buckets(stkField.entity_rank()); |
| 81 |
for (stk::mesh::Bucket * bucket : buckets) { |
| 82 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, *bucket); |
| 83 |
for(size_t iEntity = 0; iEntity < bucket->size(); ++iEntity) { |
| 84 |
const size_t yComponent = iEntity*3 + 1; |
| 85 |
fieldData[yComponent] = value; |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
template <typename T> |
| 91 |
void read_vector_field_on_host_using_bucket(stk::mesh::Field<T> & stkField) |
| 92 |
{ |
| 93 |
const stk::mesh::BucketVector& buckets = get_bulk().buckets(stkField.entity_rank()); |
| 94 |
for (stk::mesh::Bucket * bucket : buckets) { |
| 95 |
const T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, *bucket); |
| 96 |
access_for_memory_checking_tool(fieldData, bucket->size()*3); |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
template <typename T> |
| 101 |
void read_vector_field_on_device(stk::mesh::Field<T> & stkField) |
| 102 |
{ |
| 103 |
stk::mesh::NgpMesh & ngpMesh = stk::mesh::get_updated_ngp_mesh(get_bulk()); |
| 104 |
const stk::mesh::MetaData & meta = get_bulk().mesh_meta_data(); |
| 105 |
stk::mesh::NgpField<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<T, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 106 |
stk::NgpVector<unsigned> bucketIds = ngpMesh.get_bucket_ids(stkField.entity_rank(), meta.locally_owned_part()); |
| 107 |
stk::mesh::EntityRank rank = ngpField.get_rank(); |
| 108 |
|
| 109 |
Kokkos::parallel_for(stk::ngp::DeviceRangePolicy(0, 1), KOKKOS_LAMBDA(unsigned ) { |
| 110 |
for (unsigned i = 0; i < bucketIds.size(); ++i) { |
| 111 |
const stk::mesh::NgpMesh::BucketType & bucket = ngpMesh.get_bucket(rank, bucketIds.device_get(i)); |
| 112 |
for (unsigned j = 0; j < bucket.size(); ++j) { |
| 113 |
stk::mesh::FastMeshIndex index = ngpMesh.fast_mesh_index(bucket[j]); |
| 114 |
unsigned numComponents = ngpField.get_num_components_per_entity(index); |
| 115 |
for (unsigned component = 0; component < numComponents; ++component) { |
| 116 |
#if defined(DEVICE_USE_LOCATION_BUILTINS) |
| 117 |
access_for_memory_checking_tool(&ngpField(index, component)); |
| 118 |
#else |
| 119 |
access_for_memory_checking_tool(&ngpField(index, component, __FILE__, __LINE__)); |
| 120 |
#endif |
| 121 |
} |
| 122 |
} |
| 123 |
} |
| 124 |
}); |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
template <typename T> |
| 129 |
void create_element_with_scalar_field_write_using_entity( |
| 130 |
const std::vector<std::pair<stk::mesh::EntityId, std::string>> & elemParts, |
| 131 |
stk::mesh::Field<T> & stkField, T value) |
| 132 |
{ |
| 133 |
std::vector<size_t> counts; |
| 134 |
stk::mesh::comm_mesh_counts(get_bulk(), counts); |
| 135 |
|
| 136 |
get_bulk().modification_begin(); |
| 137 |
|
| 138 |
write_scalar_field_on_host_using_entity(stkField, value); |
| 139 |
|
| 140 |
for (const auto & elemPart : elemParts) { |
| 141 |
stk::mesh::PartVector parts {get_meta().get_part(elemPart.second), get_meta().get_part("block_1")}; |
| 142 |
stk::mesh::EntityIdVector nodeIds; |
| 143 |
stk::mesh::EntityId nodeId = counts[stk::topology::ELEM_RANK] * 4 + 1; |
| 144 |
for (unsigned i = 0; i < 8; ++i) { |
| 145 |
nodeIds.push_back(nodeId++); |
| 146 |
} |
| 147 |
|
| 148 |
stk::mesh::Entity newElem = stk::mesh::declare_element(get_bulk(), parts, elemPart.first, nodeIds); |
| 149 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, newElem); |
| 150 |
fieldData[0] = value; |
| 151 |
} |
| 152 |
|
| 153 |
get_bulk().modification_end(); |
| 154 |
} |
| 155 |
|
| 156 |
template <typename T> |
| 157 |
void create_element_with_scalar_field_write_using_bucket( |
| 158 |
const std::vector<std::pair<stk::mesh::EntityId, std::string>> & elemParts, |
| 159 |
stk::mesh::Field<T> & stkField, T value) |
| 160 |
{ |
| 161 |
std::vector<size_t> counts; |
| 162 |
stk::mesh::comm_mesh_counts(get_bulk(), counts); |
| 163 |
|
| 164 |
get_bulk().modification_begin(); |
| 165 |
|
| 166 |
write_scalar_field_on_host_using_bucket(stkField, value); |
| 167 |
|
| 168 |
for (const auto & elemPart : elemParts) { |
| 169 |
stk::mesh::PartVector parts {get_meta().get_part(elemPart.second), get_meta().get_part("block_1")}; |
| 170 |
stk::mesh::EntityIdVector nodeIds; |
| 171 |
stk::mesh::EntityId nodeId = counts[stk::topology::ELEM_RANK] * 4 + 1; |
| 172 |
for (unsigned i = 0; i < 8; ++i) { |
| 173 |
nodeIds.push_back(nodeId++); |
| 174 |
} |
| 175 |
|
| 176 |
stk::mesh::Entity newElem = stk::mesh::declare_element(get_bulk(), parts, elemPart.first, nodeIds); |
| 177 |
|
| 178 |
const stk::mesh::Bucket & bucket = get_bulk().bucket(newElem); |
| 179 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, bucket); |
| 180 |
for(size_t iEntity = 0; iEntity < bucket.size(); ++iEntity) { |
| 181 |
fieldData[iEntity] = value; |
| 182 |
} |
| 183 |
} |
| 184 |
|
| 185 |
get_bulk().modification_end(); |
| 186 |
} |
| 187 |
|
| 188 |
template <typename T> |
| 189 |
void create_element_with_scalar_field_write_using_bucket_id( |
| 190 |
const std::vector<std::pair<stk::mesh::EntityId, std::string>> & elemParts, |
| 191 |
stk::mesh::Field<T> & stkField, T value) |
| 192 |
{ |
| 193 |
std::vector<size_t> counts; |
| 194 |
stk::mesh::comm_mesh_counts(get_bulk(), counts); |
| 195 |
|
| 196 |
get_bulk().modification_begin(); |
| 197 |
|
| 198 |
write_scalar_field_on_host_using_bucket_id(stkField, value); |
| 199 |
|
| 200 |
for (const auto & elemPart : elemParts) { |
| 201 |
stk::mesh::PartVector parts {get_meta().get_part(elemPart.second), get_meta().get_part("block_1")}; |
| 202 |
stk::mesh::EntityIdVector nodeIds; |
| 203 |
stk::mesh::EntityId nodeId = counts[stk::topology::ELEM_RANK] * 4 + 1; |
| 204 |
for (unsigned i = 0; i < 8; ++i) { |
| 205 |
nodeIds.push_back(nodeId++); |
| 206 |
} |
| 207 |
|
| 208 |
stk::mesh::Entity newElem = stk::mesh::declare_element(get_bulk(), parts, elemPart.first, nodeIds); |
| 209 |
|
| 210 |
const stk::mesh::Bucket & bucket = get_bulk().bucket(newElem); |
| 211 |
const unsigned bucketId = bucket.bucket_id(); |
| 212 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, bucketId); |
| 213 |
for(size_t iEntity = 0; iEntity < bucket.size(); ++iEntity) { |
| 214 |
fieldData[iEntity] = value; |
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
get_bulk().modification_end(); |
| 219 |
} |
| 220 |
|
| 221 |
template <typename T> |
| 222 |
void create_element_with_scalar_field_write_using_bucket_id_and_ordinal( |
| 223 |
const std::vector<std::pair<stk::mesh::EntityId, std::string>> & elemParts, |
| 224 |
stk::mesh::Field<T> & stkField, T value) |
| 225 |
{ |
| 226 |
std::vector<size_t> counts; |
| 227 |
stk::mesh::comm_mesh_counts(get_bulk(), counts); |
| 228 |
|
| 229 |
get_bulk().modification_begin(); |
| 230 |
|
| 231 |
write_scalar_field_on_host_using_bucket_id_and_ordinal(stkField, value); |
| 232 |
|
| 233 |
for (const auto & elemPart : elemParts) { |
| 234 |
stk::mesh::PartVector parts {get_meta().get_part(elemPart.second), get_meta().get_part("block_1")}; |
| 235 |
stk::mesh::EntityIdVector nodeIds; |
| 236 |
stk::mesh::EntityId nodeId = counts[stk::topology::ELEM_RANK] * 4 + 1; |
| 237 |
for (unsigned i = 0; i < 8; ++i) { |
| 238 |
nodeIds.push_back(nodeId++); |
| 239 |
} |
| 240 |
|
| 241 |
stk::mesh::Entity newElem = stk::mesh::declare_element(get_bulk(), parts, elemPart.first, nodeIds); |
| 242 |
|
| 243 |
const stk::mesh::MeshIndex & meshIndex = get_bulk().mesh_index(newElem); |
| 244 |
const unsigned bucketId = meshIndex.bucket->bucket_id(); |
| 245 |
const stk::mesh::Bucket::size_type bucketOrd = meshIndex.bucket_ordinal; |
| 246 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, bucketId, bucketOrd); |
| 247 |
fieldData[0] = value; |
| 248 |
} |
| 249 |
|
| 250 |
get_bulk().modification_end(); |
| 251 |
} |
| 252 |
|
| 253 |
template <typename T> |
| 254 |
void create_element_with_vector_field_write_using_entity( |
| 255 |
const std::vector<std::pair<stk::mesh::EntityId, std::string>> & elemParts, |
| 256 |
stk::mesh::Field<T> & stkField, T value) |
| 257 |
{ |
| 258 |
std::vector<size_t> counts; |
| 259 |
stk::mesh::comm_mesh_counts(get_bulk(), counts); |
| 260 |
|
| 261 |
get_bulk().modification_begin(); |
| 262 |
|
| 263 |
write_vector_field_on_host_using_entity(stkField, value); |
| 264 |
|
| 265 |
for (const auto & elemPart : elemParts) { |
| 266 |
stk::mesh::PartVector parts {get_meta().get_part(elemPart.second), get_meta().get_part("block_1")}; |
| 267 |
stk::mesh::EntityIdVector nodeIds; |
| 268 |
stk::mesh::EntityId nodeId = counts[stk::topology::ELEM_RANK] * 4 + 1; |
| 269 |
for (unsigned i = 0; i < 8; ++i) { |
| 270 |
nodeIds.push_back(nodeId++); |
| 271 |
} |
| 272 |
|
| 273 |
stk::mesh::Entity newElem = stk::mesh::declare_element(get_bulk(), parts, elemPart.first, nodeIds); |
| 274 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, newElem); |
| 275 |
fieldData[1] = value; |
| 276 |
} |
| 277 |
|
| 278 |
get_bulk().modification_end(); |
| 279 |
} |
| 280 |
|
| 281 |
template <typename T> |
| 282 |
void create_element_with_vector_field_write_using_bucket( |
| 283 |
const std::vector<std::pair<stk::mesh::EntityId, std::string>> & elemParts, |
| 284 |
stk::mesh::Field<T> & stkField, T value) |
| 285 |
{ |
| 286 |
std::vector<size_t> counts; |
| 287 |
stk::mesh::comm_mesh_counts(get_bulk(), counts); |
| 288 |
|
| 289 |
get_bulk().modification_begin(); |
| 290 |
|
| 291 |
write_vector_field_on_host_using_bucket(stkField, value); |
| 292 |
|
| 293 |
for (const auto & elemPart : elemParts) { |
| 294 |
stk::mesh::PartVector parts {get_meta().get_part(elemPart.second), get_meta().get_part("block_1")}; |
| 295 |
stk::mesh::EntityIdVector nodeIds; |
| 296 |
stk::mesh::EntityId nodeId = counts[stk::topology::ELEM_RANK] * 4 + 1; |
| 297 |
for (unsigned i = 0; i < 8; ++i) { |
| 298 |
nodeIds.push_back(nodeId++); |
| 299 |
} |
| 300 |
|
| 301 |
stk::mesh::Entity newElem = stk::mesh::declare_element(get_bulk(), parts, elemPart.first, nodeIds); |
| 302 |
|
| 303 |
const stk::mesh::Bucket & bucket = get_bulk().bucket(newElem); |
| 304 |
T * fieldData = stk::mesh::field_data<stk::mesh::Field<T>, StkDebugger<T>>(stkField, bucket); |
| 305 |
for(size_t iEntity = 0; iEntity < bucket.size(); ++iEntity) { |
| 306 |
const size_t yComponent = iEntity*3 + 1; |
| 307 |
fieldData[yComponent] = value; |
| 308 |
} |
| 309 |
} |
| 310 |
|
| 311 |
get_bulk().modification_end(); |
| 312 |
} |
| 313 |
|
| 314 |
template <typename T> |
| 315 |
void create_element_with_scalar_field_read_using_entity( |
| 316 |
const std::vector<std::pair<stk::mesh::EntityId, std::string>> & elemParts, |
| 317 |
stk::mesh::Field<T> & stkField) |
| 318 |
{ |
| 319 |
std::vector<size_t> counts; |
| 320 |
stk::mesh::comm_mesh_counts(get_bulk(), counts); |
| 321 |
|
| 322 |
get_bulk().modification_begin(); |
| 323 |
|
| 324 |
for (const auto & elemPart : elemParts) { |
| 325 |
stk::mesh::PartVector parts {get_meta().get_part(elemPart.second), get_meta().get_part("block_1")}; |
| 326 |
stk::mesh::EntityIdVector nodeIds; |
| 327 |
stk::mesh::EntityId nodeId = counts[stk::topology::ELEM_RANK] * 4 + 1; |
| 328 |
for (unsigned i = 0; i < 8; ++i) { |
| 329 |
nodeIds.push_back(nodeId++); |
| 330 |
} |
| 331 |
|
| 332 |
stk::mesh::declare_element(get_bulk(), parts, elemPart.first, nodeIds); |
| 333 |
} |
| 334 |
|
| 335 |
read_scalar_field_on_host_using_entity(stkField); |
| 336 |
|
| 337 |
get_bulk().modification_end(); |
| 338 |
} |
| 339 |
|
| 340 |
template <typename T> |
| 341 |
void create_element_with_scalar_field_read_using_bucket( |
| 342 |
const std::vector<std::pair<stk::mesh::EntityId, std::string>> & elemParts, |
| 343 |
stk::mesh::Field<T> & stkField) |
| 344 |
{ |
| 345 |
std::vector<size_t> counts; |
| 346 |
stk::mesh::comm_mesh_counts(get_bulk(), counts); |
| 347 |
|
| 348 |
get_bulk().modification_begin(); |
| 349 |
|
| 350 |
for (const auto & elemPart : elemParts) { |
| 351 |
stk::mesh::PartVector parts {get_meta().get_part(elemPart.second), get_meta().get_part("block_1")}; |
| 352 |
stk::mesh::EntityIdVector nodeIds; |
| 353 |
stk::mesh::EntityId nodeId = counts[stk::topology::ELEM_RANK] * 4 + 1; |
| 354 |
for (unsigned i = 0; i < 8; ++i) { |
| 355 |
nodeIds.push_back(nodeId++); |
| 356 |
} |
| 357 |
|
| 358 |
stk::mesh::declare_element(get_bulk(), parts, elemPart.first, nodeIds); |
| 359 |
} |
| 360 |
|
| 361 |
read_scalar_field_on_host_using_bucket(stkField); |
| 362 |
|
| 363 |
get_bulk().modification_end(); |
| 364 |
} |
| 365 |
|
| 366 |
template <typename T> |
| 367 |
void create_element_with_vector_field_read_using_entity( |
| 368 |
const std::vector<std::pair<stk::mesh::EntityId, std::string>> & elemParts, |
| 369 |
stk::mesh::Field<T> & stkField) |
| 370 |
{ |
| 371 |
std::vector<size_t> counts; |
| 372 |
stk::mesh::comm_mesh_counts(get_bulk(), counts); |
| 373 |
|
| 374 |
get_bulk().modification_begin(); |
| 375 |
|
| 376 |
for (const auto & elemPart : elemParts) { |
| 377 |
stk::mesh::PartVector parts {get_meta().get_part(elemPart.second), get_meta().get_part("block_1")}; |
| 378 |
stk::mesh::EntityIdVector nodeIds; |
| 379 |
stk::mesh::EntityId nodeId = counts[stk::topology::ELEM_RANK] * 4 + 1; |
| 380 |
for (unsigned i = 0; i < 8; ++i) { |
| 381 |
nodeIds.push_back(nodeId++); |
| 382 |
} |
| 383 |
|
| 384 |
stk::mesh::declare_element(get_bulk(), parts, elemPart.first, nodeIds); |
| 385 |
} |
| 386 |
|
| 387 |
read_vector_field_on_host_using_entity<T>(stkField); |
| 388 |
|
| 389 |
get_bulk().modification_end(); |
| 390 |
} |
| 391 |
|
| 392 |
template <typename T> |
| 393 |
void create_element_with_vector_field_read_using_bucket( |
| 394 |
const std::vector<std::pair<stk::mesh::EntityId, std::string>> & elemParts, |
| 395 |
stk::mesh::Field<T> & stkField) |
| 396 |
{ |
| 397 |
std::vector<size_t> counts; |
| 398 |
stk::mesh::comm_mesh_counts(get_bulk(), counts); |
| 399 |
|
| 400 |
get_bulk().modification_begin(); |
| 401 |
|
| 402 |
for (const auto & elemPart : elemParts) { |
| 403 |
stk::mesh::PartVector parts {get_meta().get_part(elemPart.second), get_meta().get_part("block_1")}; |
| 404 |
stk::mesh::EntityIdVector nodeIds; |
| 405 |
stk::mesh::EntityId nodeId = counts[stk::topology::ELEM_RANK] * 4 + 1; |
| 406 |
for (unsigned i = 0; i < 8; ++i) { |
| 407 |
nodeIds.push_back(nodeId++); |
| 408 |
} |
| 409 |
|
| 410 |
stk::mesh::declare_element(get_bulk(), parts, elemPart.first, nodeIds); |
| 411 |
} |
| 412 |
|
| 413 |
read_vector_field_on_host_using_bucket(stkField); |
| 414 |
|
| 415 |
get_bulk().modification_end(); |
| 416 |
} |
| 417 |
|
| 418 |
|
| 419 |
template <typename T> |
| 420 |
void delete_element_with_scalar_field_write_using_entity(const std::vector<stk::mesh::EntityId> & elemIds, |
| 421 |
stk::mesh::Field<T> & stkField, T value) |
| 422 |
{ |
| 423 |
get_bulk().modification_begin(); |
| 424 |
|
| 425 |
write_scalar_field_on_host_using_entity(stkField, value); |
| 426 |
|
| 427 |
for (const stk::mesh::EntityId & elemId : elemIds) { |
| 428 |
get_bulk().destroy_entity(get_bulk().get_entity(stk::topology::ELEM_RANK, elemId)); |
| 429 |
} |
| 430 |
|
| 431 |
get_bulk().modification_end(); |
| 432 |
} |
| 433 |
|
| 434 |
template <typename T> |
| 435 |
void delete_element_with_scalar_field_write_using_bucket(const std::vector<stk::mesh::EntityId> & elemIds, |
| 436 |
stk::mesh::Field<T> & stkField, T value) |
| 437 |
{ |
| 438 |
get_bulk().modification_begin(); |
| 439 |
|
| 440 |
write_scalar_field_on_host_using_bucket(stkField, value); |
| 441 |
|
| 442 |
for (const stk::mesh::EntityId & elemId : elemIds) { |
| 443 |
get_bulk().destroy_entity(get_bulk().get_entity(stk::topology::ELEM_RANK, elemId)); |
| 444 |
} |
| 445 |
|
| 446 |
get_bulk().modification_end(); |
| 447 |
} |
| 448 |
|
| 449 |
template <typename T> |
| 450 |
void delete_element_with_scalar_field_write_using_bucket_id(const std::vector<stk::mesh::EntityId> & elemIds, |
| 451 |
stk::mesh::Field<T> & stkField, T value) |
| 452 |
{ |
| 453 |
get_bulk().modification_begin(); |
| 454 |
|
| 455 |
write_scalar_field_on_host_using_bucket_id(stkField, value); |
| 456 |
|
| 457 |
for (const stk::mesh::EntityId & elemId : elemIds) { |
| 458 |
get_bulk().destroy_entity(get_bulk().get_entity(stk::topology::ELEM_RANK, elemId)); |
| 459 |
} |
| 460 |
|
| 461 |
get_bulk().modification_end(); |
| 462 |
} |
| 463 |
|
| 464 |
template <typename T> |
| 465 |
void delete_element_with_scalar_field_write_using_bucket_id_and_ordinal(const std::vector<stk::mesh::EntityId> & elemIds, |
| 466 |
stk::mesh::Field<T> & stkField, T value) |
| 467 |
{ |
| 468 |
get_bulk().modification_begin(); |
| 469 |
|
| 470 |
stk::mesh::EntityVector processedEntities = write_scalar_field_on_host_using_bucket_id_and_ordinal(stkField, value); |
| 471 |
|
| 472 |
for (const stk::mesh::EntityId & elemId : elemIds) { |
| 473 |
get_bulk().destroy_entity(get_bulk().get_entity(stk::topology::ELEM_RANK, elemId)); |
| 474 |
} |
| 475 |
|
| 476 |
write_scalar_field_on_host_using_entity_vector(stkField, processedEntities, value); |
| 477 |
|
| 478 |
|
| 479 |
get_bulk().modification_end(); |
| 480 |
} |
| 481 |
|
| 482 |
template <typename T> |
| 483 |
void delete_element_with_vector_field_write_using_entity(const std::vector<stk::mesh::EntityId> & elemIds, |
| 484 |
stk::mesh::Field<T> & stkField, T value) |
| 485 |
{ |
| 486 |
get_bulk().modification_begin(); |
| 487 |
|
| 488 |
write_vector_field_on_host_using_entity(stkField, value); |
| 489 |
|
| 490 |
for (const stk::mesh::EntityId & elemId : elemIds) { |
| 491 |
get_bulk().destroy_entity(get_bulk().get_entity(stk::topology::ELEM_RANK, elemId)); |
| 492 |
} |
| 493 |
|
| 494 |
get_bulk().modification_end(); |
| 495 |
} |
| 496 |
|
| 497 |
template <typename T> |
| 498 |
void delete_element_with_vector_field_write_using_bucket(const std::vector<stk::mesh::EntityId> & elemIds, |
| 499 |
stk::mesh::Field<T> & stkField, T value) |
| 500 |
{ |
| 501 |
get_bulk().modification_begin(); |
| 502 |
|
| 503 |
write_vector_field_on_host_using_bucket(stkField, value); |
| 504 |
|
| 505 |
for (const stk::mesh::EntityId & elemId : elemIds) { |
| 506 |
get_bulk().destroy_entity(get_bulk().get_entity(stk::topology::ELEM_RANK, elemId)); |
| 507 |
} |
| 508 |
|
| 509 |
get_bulk().modification_end(); |
| 510 |
} |
| 511 |
|
| 512 |
template <typename T> |
| 513 |
void delete_element_with_scalar_field_read_using_entity(const std::vector<stk::mesh::EntityId> & elemIds, |
| 514 |
stk::mesh::Field<T> & stkField) |
| 515 |
{ |
| 516 |
get_bulk().modification_begin(); |
| 517 |
|
| 518 |
for (const stk::mesh::EntityId & elemId : elemIds) { |
| 519 |
get_bulk().destroy_entity(get_bulk().get_entity(stk::topology::ELEM_RANK, elemId)); |
| 520 |
} |
| 521 |
|
| 522 |
read_scalar_field_on_host_using_entity(stkField); |
| 523 |
|
| 524 |
get_bulk().modification_end(); |
| 525 |
} |
| 526 |
|
| 527 |
template <typename T> |
| 528 |
void delete_element_with_scalar_field_read_using_bucket(const std::vector<stk::mesh::EntityId> & elemIds, |
| 529 |
stk::mesh::Field<T> & stkField) |
| 530 |
{ |
| 531 |
get_bulk().modification_begin(); |
| 532 |
|
| 533 |
for (const stk::mesh::EntityId & elemId : elemIds) { |
| 534 |
get_bulk().destroy_entity(get_bulk().get_entity(stk::topology::ELEM_RANK, elemId)); |
| 535 |
} |
| 536 |
|
| 537 |
read_scalar_field_on_host_using_bucket(stkField); |
| 538 |
|
| 539 |
get_bulk().modification_end(); |
| 540 |
} |
| 541 |
|
| 542 |
template <typename T> |
| 543 |
void delete_element_with_vector_field_read_using_entity(const std::vector<stk::mesh::EntityId> & elemIds, |
| 544 |
stk::mesh::Field<T> & stkField) |
| 545 |
{ |
| 546 |
get_bulk().modification_begin(); |
| 547 |
|
| 548 |
for (const stk::mesh::EntityId & elemId : elemIds) { |
| 549 |
get_bulk().destroy_entity(get_bulk().get_entity(stk::topology::ELEM_RANK, elemId)); |
| 550 |
} |
| 551 |
|
| 552 |
read_vector_field_on_host_using_entity<T>(stkField); |
| 553 |
|
| 554 |
get_bulk().modification_end(); |
| 555 |
} |
| 556 |
|
| 557 |
template <typename T> |
| 558 |
void delete_element_with_vector_field_read_using_bucket(const std::vector<stk::mesh::EntityId> & elemIds, |
| 559 |
stk::mesh::Field<T> & stkField) |
| 560 |
{ |
| 561 |
get_bulk().modification_begin(); |
| 562 |
|
| 563 |
for (const stk::mesh::EntityId & elemId : elemIds) { |
| 564 |
get_bulk().destroy_entity(get_bulk().get_entity(stk::topology::ELEM_RANK, elemId)); |
| 565 |
} |
| 566 |
|
| 567 |
read_vector_field_on_host_using_bucket(stkField); |
| 568 |
|
| 569 |
get_bulk().modification_end(); |
| 570 |
} |
| 571 |
|
| 572 |
|
| 573 |
template <typename T> |
| 574 |
void modify_element_part_membership_with_scalar_field_write_using_bucket_id_and_ordinal( |
| 575 |
const std::vector<EntityIdAddRemovePart> & elemAddRemoveParts, |
| 576 |
stk::mesh::Field<T> & stkField, T value) |
| 577 |
{ |
| 578 |
get_bulk().modification_begin(); |
| 579 |
|
| 580 |
stk::mesh::EntityVector processedEntities = write_scalar_field_on_host_using_bucket_id_and_ordinal(stkField, value); |
| 581 |
|
| 582 |
for (const auto & elemAddRemovePart : elemAddRemoveParts) { |
| 583 |
stk::mesh::EntityVector elemsToChange {get_bulk().get_entity(stk::topology::ELEM_RANK, elemAddRemovePart.id)}; |
| 584 |
stk::mesh::PartVector addParts {get_meta().get_part(elemAddRemovePart.addPart)}; |
| 585 |
stk::mesh::PartVector removeParts {get_meta().get_part(elemAddRemovePart.removePart)}; |
| 586 |
get_bulk().change_entity_parts(elemsToChange, addParts, removeParts); |
| 587 |
} |
| 588 |
|
| 589 |
write_scalar_field_on_host_using_entity_vector(stkField, processedEntities, value); |
| 590 |
|
| 591 |
get_bulk().modification_end(); |
| 592 |
} |
| 593 |
|
| 594 |
template <typename T> |
| 595 |
void modify_element_part_membership_with_scalar_field_write_using_bucket( |
| 596 |
const std::vector<EntityIdAddRemovePart> & elemAddRemoveParts, |
| 597 |
stk::mesh::Field<T> & stkField, T value) |
| 598 |
{ |
| 599 |
get_bulk().modification_begin(); |
| 600 |
|
| 601 |
write_scalar_field_on_host_using_bucket(stkField, value); |
| 602 |
|
| 603 |
for (const auto & elemAddRemovePart : elemAddRemoveParts) { |
| 604 |
stk::mesh::EntityVector elemsToChange {get_bulk().get_entity(stk::topology::ELEM_RANK, elemAddRemovePart.id)}; |
| 605 |
stk::mesh::PartVector addParts {get_meta().get_part(elemAddRemovePart.addPart)}; |
| 606 |
stk::mesh::PartVector removeParts {get_meta().get_part(elemAddRemovePart.removePart)}; |
| 607 |
get_bulk().change_entity_parts(elemsToChange, addParts, removeParts); |
| 608 |
} |
| 609 |
|
| 610 |
get_bulk().modification_end(); |
| 611 |
} |
| 612 |
|
| 613 |
template <typename T> |
| 614 |
void modify_element_part_membership_with_scalar_field_write_using_bucket_id( |
| 615 |
const std::vector<EntityIdAddRemovePart> & elemAddRemoveParts, |
| 616 |
stk::mesh::Field<T> & stkField, T value) |
| 617 |
{ |
| 618 |
get_bulk().modification_begin(); |
| 619 |
|
| 620 |
write_scalar_field_on_host_using_bucket_id(stkField, value); |
| 621 |
|
| 622 |
for (const auto & elemAddRemovePart : elemAddRemoveParts) { |
| 623 |
stk::mesh::EntityVector elemsToChange {get_bulk().get_entity(stk::topology::ELEM_RANK, elemAddRemovePart.id)}; |
| 624 |
stk::mesh::PartVector addParts {get_meta().get_part(elemAddRemovePart.addPart)}; |
| 625 |
stk::mesh::PartVector removeParts {get_meta().get_part(elemAddRemovePart.removePart)}; |
| 626 |
get_bulk().change_entity_parts(elemsToChange, addParts, removeParts); |
| 627 |
} |
| 628 |
|
| 629 |
get_bulk().modification_end(); |
| 630 |
} |
| 631 |
|
| 632 |
template <typename T> |
| 633 |
void modify_element_part_membership_with_vector_field_write_using_entity( |
| 634 |
const std::vector<EntityIdAddRemovePart> & elemAddRemoveParts, |
| 635 |
stk::mesh::Field<T> & stkField, T value) |
| 636 |
{ |
| 637 |
get_bulk().modification_begin(); |
| 638 |
|
| 639 |
write_vector_field_on_host_using_entity(stkField, value); |
| 640 |
|
| 641 |
for (const auto & elemAddRemovePart : elemAddRemoveParts) { |
| 642 |
stk::mesh::EntityVector elemsToChange {get_bulk().get_entity(stk::topology::ELEM_RANK, elemAddRemovePart.id)}; |
| 643 |
stk::mesh::PartVector addParts {get_meta().get_part(elemAddRemovePart.addPart)}; |
| 644 |
stk::mesh::PartVector removeParts {get_meta().get_part(elemAddRemovePart.removePart)}; |
| 645 |
get_bulk().change_entity_parts(elemsToChange, addParts, removeParts); |
| 646 |
} |
| 647 |
|
| 648 |
get_bulk().modification_end(); |
| 649 |
} |
| 650 |
|
| 651 |
template <typename T> |
| 652 |
void modify_element_part_membership_with_vector_field_write_using_bucket( |
| 653 |
const std::vector<EntityIdAddRemovePart> & elemAddRemoveParts, |
| 654 |
stk::mesh::Field<T> & stkField, T value) |
| 655 |
{ |
| 656 |
get_bulk().modification_begin(); |
| 657 |
|
| 658 |
write_vector_field_on_host_using_bucket(stkField, value); |
| 659 |
|
| 660 |
for (const auto & elemAddRemovePart : elemAddRemoveParts) { |
| 661 |
stk::mesh::EntityVector elemsToChange {get_bulk().get_entity(stk::topology::ELEM_RANK, elemAddRemovePart.id)}; |
| 662 |
stk::mesh::PartVector addParts {get_meta().get_part(elemAddRemovePart.addPart)}; |
| 663 |
stk::mesh::PartVector removeParts {get_meta().get_part(elemAddRemovePart.removePart)}; |
| 664 |
get_bulk().change_entity_parts(elemsToChange, addParts, removeParts); |
| 665 |
} |
| 666 |
|
| 667 |
get_bulk().modification_end(); |
| 668 |
} |
| 669 |
|
| 670 |
template <typename T> |
| 671 |
void modify_element_part_membership_with_scalar_field_read_using_entity( |
| 672 |
const std::vector<EntityIdAddRemovePart> & elemAddRemoveParts, |
| 673 |
stk::mesh::Field<T> & stkField) |
| 674 |
{ |
| 675 |
get_bulk().modification_begin(); |
| 676 |
|
| 677 |
for (const auto & elemAddRemovePart : elemAddRemoveParts) { |
| 678 |
stk::mesh::EntityVector elemsToChange {get_bulk().get_entity(stk::topology::ELEM_RANK, elemAddRemovePart.id)}; |
| 679 |
stk::mesh::PartVector addParts {get_meta().get_part(elemAddRemovePart.addPart)}; |
| 680 |
stk::mesh::PartVector removeParts {get_meta().get_part(elemAddRemovePart.removePart)}; |
| 681 |
get_bulk().change_entity_parts(elemsToChange, addParts, removeParts); |
| 682 |
} |
| 683 |
|
| 684 |
read_scalar_field_on_host_using_entity(stkField); |
| 685 |
|
| 686 |
get_bulk().modification_end(); |
| 687 |
} |
| 688 |
|
| 689 |
template <typename T> |
| 690 |
void modify_element_part_membership_with_scalar_field_read_using_bucket( |
| 691 |
const std::vector<EntityIdAddRemovePart> & elemAddRemoveParts, |
| 692 |
stk::mesh::Field<T> & stkField) |
| 693 |
{ |
| 694 |
get_bulk().modification_begin(); |
| 695 |
|
| 696 |
for (const auto & elemAddRemovePart : elemAddRemoveParts) { |
| 697 |
stk::mesh::EntityVector elemsToChange {get_bulk().get_entity(stk::topology::ELEM_RANK, elemAddRemovePart.id)}; |
| 698 |
stk::mesh::PartVector addParts {get_meta().get_part(elemAddRemovePart.addPart)}; |
| 699 |
stk::mesh::PartVector removeParts {get_meta().get_part(elemAddRemovePart.removePart)}; |
| 700 |
get_bulk().change_entity_parts(elemsToChange, addParts, removeParts); |
| 701 |
} |
| 702 |
|
| 703 |
read_scalar_field_on_host_using_bucket(stkField); |
| 704 |
|
| 705 |
get_bulk().modification_end(); |
| 706 |
} |
| 707 |
|
| 708 |
template <typename T> |
| 709 |
void modify_element_part_membership_with_vector_field_read_using_entity( |
| 710 |
const std::vector<EntityIdAddRemovePart> & elemAddRemoveParts, |
| 711 |
stk::mesh::Field<T> & stkField) |
| 712 |
{ |
| 713 |
get_bulk().modification_begin(); |
| 714 |
|
| 715 |
for (const auto & elemAddRemovePart : elemAddRemoveParts) { |
| 716 |
stk::mesh::EntityVector elemsToChange {get_bulk().get_entity(stk::topology::ELEM_RANK, elemAddRemovePart.id)}; |
| 717 |
stk::mesh::PartVector addParts {get_meta().get_part(elemAddRemovePart.addPart)}; |
| 718 |
stk::mesh::PartVector removeParts {get_meta().get_part(elemAddRemovePart.removePart)}; |
| 719 |
get_bulk().change_entity_parts(elemsToChange, addParts, removeParts); |
| 720 |
} |
| 721 |
|
| 722 |
read_vector_field_on_host_using_entity<T>(stkField); |
| 723 |
|
| 724 |
get_bulk().modification_end(); |
| 725 |
} |
| 726 |
|
| 727 |
template <typename T> |
| 728 |
void modify_element_part_membership_with_vector_field_read_using_bucket( |
| 729 |
const std::vector<EntityIdAddRemovePart> & elemAddRemoveParts, |
| 730 |
stk::mesh::Field<T> & stkField) |
| 731 |
{ |
| 732 |
get_bulk().modification_begin(); |
| 733 |
|
| 734 |
for (const auto & elemAddRemovePart : elemAddRemoveParts) { |
| 735 |
stk::mesh::EntityVector elemsToChange {get_bulk().get_entity(stk::topology::ELEM_RANK, elemAddRemovePart.id)}; |
| 736 |
stk::mesh::PartVector addParts {get_meta().get_part(elemAddRemovePart.addPart)}; |
| 737 |
stk::mesh::PartVector removeParts {get_meta().get_part(elemAddRemovePart.removePart)}; |
| 738 |
get_bulk().change_entity_parts(elemsToChange, addParts, removeParts); |
| 739 |
} |
| 740 |
|
| 741 |
read_vector_field_on_host_using_bucket(stkField); |
| 742 |
|
| 743 |
get_bulk().modification_end(); |
| 744 |
} |
| 745 |
}; |
| 746 |
|
| 747 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_ChangeBucket_ProperlySyncToDevice_NoWarning) |
| 748 |
{ |
| 749 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 750 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 751 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 752 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 753 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 754 |
|
| 755 |
testing::internal::CaptureStdout(); |
| 756 |
modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 757 |
stkField.modify_on_host(); |
| 758 |
stkField.sync_to_device(); |
| 759 |
|
| 760 |
read_scalar_field_on_device(stkField); |
| 761 |
|
| 762 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 763 |
check_no_warnings(stdoutString); |
| 764 |
} |
| 765 |
|
| 766 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_CreateBucket_ProperlySyncToDevice_NoWarning) |
| 767 |
{ |
| 768 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 769 |
const unsigned bucketCapacity = 1; |
| 770 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 771 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 772 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 773 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 774 |
|
| 775 |
testing::internal::CaptureStdout(); |
| 776 |
create_element_with_scalar_field_write_using_entity({{3, "Part1"}}, stkField, 3.14); |
| 777 |
stkField.modify_on_host(); |
| 778 |
stkField.sync_to_device(); |
| 779 |
|
| 780 |
read_scalar_field_on_device(stkField); |
| 781 |
|
| 782 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 783 |
check_no_warnings(stdoutString); |
| 784 |
} |
| 785 |
|
| 786 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_DeleteBucket_ProperlySyncToDevice_NoWarning) |
| 787 |
{ |
| 788 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 789 |
const unsigned bucketCapacity = 1; |
| 790 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 791 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 792 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 793 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 794 |
|
| 795 |
testing::internal::CaptureStdout(); |
| 796 |
delete_element_with_scalar_field_write_using_entity({2}, stkField, 3.14); |
| 797 |
stkField.modify_on_host(); |
| 798 |
stkField.sync_to_device(); |
| 799 |
|
| 800 |
read_scalar_field_on_device(stkField); |
| 801 |
|
| 802 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 803 |
check_no_warnings(stdoutString); |
| 804 |
} |
| 805 |
|
| 806 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucketIdAndOrdinal_ChangeBucket_ProperlySyncToDevice_NoWarning) |
| 807 |
{ |
| 808 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 809 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 810 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 811 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 812 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 813 |
|
| 814 |
testing::internal::CaptureStdout(); |
| 815 |
modify_element_part_membership_with_scalar_field_write_using_bucket_id_and_ordinal({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 816 |
stkField.modify_on_host(); |
| 817 |
stkField.sync_to_device(); |
| 818 |
|
| 819 |
read_scalar_field_on_device(stkField); |
| 820 |
|
| 821 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 822 |
check_no_warnings(stdoutString); |
| 823 |
} |
| 824 |
|
| 825 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucketIdAndOrdinal_CreateBucket_ProperlySyncToDevice_NoWarning) |
| 826 |
{ |
| 827 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 828 |
const unsigned bucketCapacity = 1; |
| 829 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 830 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 831 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 832 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 833 |
|
| 834 |
testing::internal::CaptureStdout(); |
| 835 |
create_element_with_scalar_field_write_using_bucket_id_and_ordinal({{3, "Part1"}}, stkField, 3.14); |
| 836 |
stkField.modify_on_host(); |
| 837 |
stkField.sync_to_device(); |
| 838 |
|
| 839 |
read_scalar_field_on_device(stkField); |
| 840 |
|
| 841 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 842 |
check_no_warnings(stdoutString); |
| 843 |
} |
| 844 |
|
| 845 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucketIdAndOrdinal_DeleteBucket_ProperlySyncToDevice_NoWarning) |
| 846 |
{ |
| 847 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 848 |
const unsigned bucketCapacity = 1; |
| 849 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 850 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 851 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 852 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 853 |
|
| 854 |
testing::internal::CaptureStdout(); |
| 855 |
delete_element_with_scalar_field_write_using_bucket_id_and_ordinal({2}, stkField, 3.14); |
| 856 |
stkField.modify_on_host(); |
| 857 |
stkField.sync_to_device(); |
| 858 |
|
| 859 |
read_scalar_field_on_device(stkField); |
| 860 |
|
| 861 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 862 |
check_no_warnings(stdoutString); |
| 863 |
} |
| 864 |
|
| 865 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingEntity_ChangeBucket_ProperlySyncToDevice_NoWarning) |
| 866 |
{ |
| 867 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 868 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 869 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 870 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 871 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 872 |
|
| 873 |
testing::internal::CaptureStdout(); |
| 874 |
modify_element_part_membership_with_vector_field_write_using_entity({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 875 |
stkField.modify_on_host(); |
| 876 |
stkField.sync_to_device(); |
| 877 |
|
| 878 |
read_vector_field_on_device(stkField); |
| 879 |
|
| 880 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 881 |
check_no_warnings(stdoutString); |
| 882 |
} |
| 883 |
|
| 884 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingEntity_CreateBucket_ProperlySyncToDevice_NoWarning) |
| 885 |
{ |
| 886 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 887 |
const unsigned bucketCapacity = 1; |
| 888 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 889 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 890 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 891 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 892 |
|
| 893 |
testing::internal::CaptureStdout(); |
| 894 |
create_element_with_vector_field_write_using_entity({{3, "Part1"}}, stkField, 3.14); |
| 895 |
stkField.modify_on_host(); |
| 896 |
stkField.sync_to_device(); |
| 897 |
|
| 898 |
read_vector_field_on_device(stkField); |
| 899 |
|
| 900 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 901 |
check_no_warnings(stdoutString); |
| 902 |
} |
| 903 |
|
| 904 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingEntity_DeleteBucket_ProperlySyncToDevice_NoWarning) |
| 905 |
{ |
| 906 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 907 |
const unsigned bucketCapacity = 1; |
| 908 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 909 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 910 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 911 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 912 |
|
| 913 |
testing::internal::CaptureStdout(); |
| 914 |
delete_element_with_vector_field_write_using_entity({2}, stkField, 3.14); |
| 915 |
stkField.modify_on_host(); |
| 916 |
stkField.sync_to_device(); |
| 917 |
|
| 918 |
read_vector_field_on_device(stkField); |
| 919 |
|
| 920 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 921 |
check_no_warnings(stdoutString); |
| 922 |
} |
| 923 |
|
| 924 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucket_ChangeBucket_ProperlySyncToDevice_NoWarning) |
| 925 |
{ |
| 926 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 927 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 928 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 929 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 930 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 931 |
|
| 932 |
testing::internal::CaptureStdout(); |
| 933 |
modify_element_part_membership_with_scalar_field_write_using_bucket({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 934 |
stkField.modify_on_host(); |
| 935 |
stkField.sync_to_device(); |
| 936 |
|
| 937 |
read_scalar_field_on_device(stkField); |
| 938 |
|
| 939 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 940 |
check_no_warnings(stdoutString); |
| 941 |
} |
| 942 |
|
| 943 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucket_CreateBucket_ProperlySyncToDevice_NoWarning) |
| 944 |
{ |
| 945 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 946 |
const unsigned bucketCapacity = 1; |
| 947 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 948 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 949 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 950 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 951 |
|
| 952 |
testing::internal::CaptureStdout(); |
| 953 |
create_element_with_scalar_field_write_using_bucket({{3, "Part1"}}, stkField, 3.14); |
| 954 |
stkField.modify_on_host(); |
| 955 |
stkField.sync_to_device(); |
| 956 |
|
| 957 |
read_scalar_field_on_device(stkField); |
| 958 |
|
| 959 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 960 |
check_no_warnings(stdoutString); |
| 961 |
} |
| 962 |
|
| 963 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucket_DeleteBucket_ProperlySyncToDevice_NoWarning) |
| 964 |
{ |
| 965 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 966 |
const unsigned bucketCapacity = 1; |
| 967 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 968 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 969 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 970 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 971 |
|
| 972 |
testing::internal::CaptureStdout(); |
| 973 |
delete_element_with_scalar_field_write_using_bucket({2}, stkField, 3.14); |
| 974 |
stkField.modify_on_host(); |
| 975 |
stkField.sync_to_device(); |
| 976 |
|
| 977 |
read_scalar_field_on_device(stkField); |
| 978 |
|
| 979 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 980 |
check_no_warnings(stdoutString); |
| 981 |
} |
| 982 |
|
| 983 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucketId_ChangeBucket_ProperlySyncToDevice_NoWarning) |
| 984 |
{ |
| 985 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 986 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 987 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 988 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 989 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 990 |
|
| 991 |
testing::internal::CaptureStdout(); |
| 992 |
modify_element_part_membership_with_scalar_field_write_using_bucket_id({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 993 |
stkField.modify_on_host(); |
| 994 |
stkField.sync_to_device(); |
| 995 |
|
| 996 |
read_scalar_field_on_device(stkField); |
| 997 |
|
| 998 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 999 |
check_no_warnings(stdoutString); |
| 1000 |
} |
| 1001 |
|
| 1002 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucketId_CreateBucket_ProperlySyncToDevice_NoWarning) |
| 1003 |
{ |
| 1004 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1005 |
const unsigned bucketCapacity = 1; |
| 1006 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1007 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1008 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1009 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1010 |
|
| 1011 |
testing::internal::CaptureStdout(); |
| 1012 |
create_element_with_scalar_field_write_using_bucket_id({{3, "Part1"}}, stkField, 3.14); |
| 1013 |
stkField.modify_on_host(); |
| 1014 |
stkField.sync_to_device(); |
| 1015 |
|
| 1016 |
read_scalar_field_on_device(stkField); |
| 1017 |
|
| 1018 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1019 |
check_no_warnings(stdoutString); |
| 1020 |
} |
| 1021 |
|
| 1022 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucketId_DeleteBucket_ProperlySyncToDevice_NoWarning) |
| 1023 |
{ |
| 1024 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1025 |
const unsigned bucketCapacity = 1; |
| 1026 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1027 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1028 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1029 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1030 |
|
| 1031 |
testing::internal::CaptureStdout(); |
| 1032 |
delete_element_with_scalar_field_write_using_bucket_id({2}, stkField, 3.14); |
| 1033 |
stkField.modify_on_host(); |
| 1034 |
stkField.sync_to_device(); |
| 1035 |
|
| 1036 |
read_scalar_field_on_device(stkField); |
| 1037 |
|
| 1038 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1039 |
check_no_warnings(stdoutString); |
| 1040 |
} |
| 1041 |
|
| 1042 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingBucket_ChangeBucket_ProperlySyncToDevice_NoWarning) |
| 1043 |
{ |
| 1044 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1045 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1046 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1047 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1048 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1049 |
|
| 1050 |
testing::internal::CaptureStdout(); |
| 1051 |
modify_element_part_membership_with_vector_field_write_using_bucket({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 1052 |
stkField.modify_on_host(); |
| 1053 |
stkField.sync_to_device(); |
| 1054 |
|
| 1055 |
read_vector_field_on_device(stkField); |
| 1056 |
|
| 1057 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1058 |
check_no_warnings(stdoutString); |
| 1059 |
} |
| 1060 |
|
| 1061 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingBucket_CreateBucket_ProperlySyncToDevice_NoWarning) |
| 1062 |
{ |
| 1063 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1064 |
const unsigned bucketCapacity = 1; |
| 1065 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1066 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1067 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1068 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1069 |
|
| 1070 |
testing::internal::CaptureStdout(); |
| 1071 |
create_element_with_vector_field_write_using_bucket({{3, "Part1"}}, stkField, 3.14); |
| 1072 |
stkField.modify_on_host(); |
| 1073 |
stkField.sync_to_device(); |
| 1074 |
|
| 1075 |
read_vector_field_on_device(stkField); |
| 1076 |
|
| 1077 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1078 |
check_no_warnings(stdoutString); |
| 1079 |
} |
| 1080 |
|
| 1081 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingBucket_DeleteBucket_ProperlySyncToDevice_NoWarning) |
| 1082 |
{ |
| 1083 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1084 |
const unsigned bucketCapacity = 1; |
| 1085 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1086 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1087 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1088 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1089 |
|
| 1090 |
testing::internal::CaptureStdout(); |
| 1091 |
delete_element_with_vector_field_write_using_bucket({2}, stkField, 3.14); |
| 1092 |
stkField.modify_on_host(); |
| 1093 |
stkField.sync_to_device(); |
| 1094 |
|
| 1095 |
read_vector_field_on_device(stkField); |
| 1096 |
|
| 1097 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1098 |
check_no_warnings(stdoutString); |
| 1099 |
} |
| 1100 |
|
| 1101 |
|
| 1102 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_ChangeBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1103 |
{ |
| 1104 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1105 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1106 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1107 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1108 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1109 |
|
| 1110 |
testing::internal::CaptureStdout(); |
| 1111 |
|
| 1112 |
modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 1113 |
read_scalar_field_on_device(stkField); |
| 1114 |
|
| 1115 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1116 |
check_no_warnings(stdoutString); |
| 1117 |
} |
| 1118 |
|
| 1119 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_CreateBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1120 |
{ |
| 1121 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1122 |
const unsigned bucketCapacity = 1; |
| 1123 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1124 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1125 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1126 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1127 |
|
| 1128 |
testing::internal::CaptureStdout(); |
| 1129 |
|
| 1130 |
create_element_with_scalar_field_write_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 1131 |
read_scalar_field_on_device(stkField); |
| 1132 |
|
| 1133 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1134 |
check_no_warnings(stdoutString); |
| 1135 |
} |
| 1136 |
|
| 1137 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_DeleteBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1138 |
{ |
| 1139 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1140 |
const unsigned bucketCapacity = 1; |
| 1141 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1142 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1143 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1144 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1145 |
|
| 1146 |
testing::internal::CaptureStdout(); |
| 1147 |
|
| 1148 |
delete_element_with_scalar_field_write_using_entity({2}, stkField, 3.14); |
| 1149 |
read_scalar_field_on_device(stkField); |
| 1150 |
|
| 1151 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1152 |
check_no_warnings(stdoutString); |
| 1153 |
} |
| 1154 |
|
| 1155 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingEntity_ChangeBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1156 |
{ |
| 1157 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1158 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1159 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1160 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1161 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1162 |
|
| 1163 |
testing::internal::CaptureStdout(); |
| 1164 |
|
| 1165 |
modify_element_part_membership_with_vector_field_write_using_entity({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 1166 |
read_vector_field_on_device(stkField); |
| 1167 |
|
| 1168 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1169 |
check_no_warnings(stdoutString); |
| 1170 |
} |
| 1171 |
|
| 1172 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingEntity_CreateBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1173 |
{ |
| 1174 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1175 |
const unsigned bucketCapacity = 1; |
| 1176 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1177 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1178 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1179 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1180 |
|
| 1181 |
testing::internal::CaptureStdout(); |
| 1182 |
|
| 1183 |
create_element_with_vector_field_write_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 1184 |
read_vector_field_on_device(stkField); |
| 1185 |
|
| 1186 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1187 |
check_no_warnings(stdoutString); |
| 1188 |
} |
| 1189 |
|
| 1190 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingEntity_DeleteBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1191 |
{ |
| 1192 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1193 |
const unsigned bucketCapacity = 1; |
| 1194 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1195 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1196 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1197 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1198 |
|
| 1199 |
testing::internal::CaptureStdout(); |
| 1200 |
|
| 1201 |
delete_element_with_vector_field_write_using_entity({2}, stkField, 3.14); |
| 1202 |
read_vector_field_on_device(stkField); |
| 1203 |
|
| 1204 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1205 |
check_no_warnings(stdoutString); |
| 1206 |
} |
| 1207 |
|
| 1208 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucket_ChangeBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1209 |
{ |
| 1210 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1211 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1212 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1213 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1214 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1215 |
|
| 1216 |
testing::internal::CaptureStdout(); |
| 1217 |
|
| 1218 |
modify_element_part_membership_with_scalar_field_write_using_bucket({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 1219 |
read_scalar_field_on_device(stkField); |
| 1220 |
|
| 1221 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1222 |
check_no_warnings(stdoutString); |
| 1223 |
} |
| 1224 |
|
| 1225 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucket_CreateBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1226 |
{ |
| 1227 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1228 |
const unsigned bucketCapacity = 1; |
| 1229 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1230 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1231 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1232 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1233 |
|
| 1234 |
testing::internal::CaptureStdout(); |
| 1235 |
|
| 1236 |
create_element_with_scalar_field_write_using_bucket({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 1237 |
read_scalar_field_on_device(stkField); |
| 1238 |
|
| 1239 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1240 |
check_no_warnings(stdoutString); |
| 1241 |
} |
| 1242 |
|
| 1243 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucket_DeleteBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1244 |
{ |
| 1245 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1246 |
const unsigned bucketCapacity = 1; |
| 1247 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1248 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1249 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1250 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1251 |
|
| 1252 |
testing::internal::CaptureStdout(); |
| 1253 |
|
| 1254 |
delete_element_with_scalar_field_write_using_bucket({2}, stkField, 3.14); |
| 1255 |
read_scalar_field_on_device(stkField); |
| 1256 |
|
| 1257 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1258 |
check_no_warnings(stdoutString); |
| 1259 |
} |
| 1260 |
|
| 1261 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucketId_ChangeBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1262 |
{ |
| 1263 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1264 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1265 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1266 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1267 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1268 |
|
| 1269 |
testing::internal::CaptureStdout(); |
| 1270 |
|
| 1271 |
modify_element_part_membership_with_scalar_field_write_using_bucket_id({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 1272 |
read_scalar_field_on_device(stkField); |
| 1273 |
|
| 1274 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1275 |
check_no_warnings(stdoutString); |
| 1276 |
} |
| 1277 |
|
| 1278 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucketId_CreateBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1279 |
{ |
| 1280 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1281 |
const unsigned bucketCapacity = 1; |
| 1282 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1283 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1284 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1285 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1286 |
|
| 1287 |
testing::internal::CaptureStdout(); |
| 1288 |
|
| 1289 |
create_element_with_scalar_field_write_using_bucket_id({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 1290 |
read_scalar_field_on_device(stkField); |
| 1291 |
|
| 1292 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1293 |
check_no_warnings(stdoutString); |
| 1294 |
} |
| 1295 |
|
| 1296 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucketId_DeleteBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1297 |
{ |
| 1298 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1299 |
const unsigned bucketCapacity = 1; |
| 1300 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1301 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1302 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1303 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1304 |
|
| 1305 |
testing::internal::CaptureStdout(); |
| 1306 |
|
| 1307 |
delete_element_with_scalar_field_write_using_bucket_id({2}, stkField, 3.14); |
| 1308 |
read_scalar_field_on_device(stkField); |
| 1309 |
|
| 1310 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1311 |
check_no_warnings(stdoutString); |
| 1312 |
} |
| 1313 |
|
| 1314 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingBucket_ChangeBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1315 |
{ |
| 1316 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1317 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1318 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1319 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1320 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1321 |
|
| 1322 |
testing::internal::CaptureStdout(); |
| 1323 |
|
| 1324 |
modify_element_part_membership_with_vector_field_write_using_bucket({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 1325 |
read_vector_field_on_device(stkField); |
| 1326 |
|
| 1327 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1328 |
check_no_warnings(stdoutString); |
| 1329 |
} |
| 1330 |
|
| 1331 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingBucket_CreateBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1332 |
{ |
| 1333 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1334 |
const unsigned bucketCapacity = 1; |
| 1335 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1336 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1337 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1338 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1339 |
|
| 1340 |
testing::internal::CaptureStdout(); |
| 1341 |
|
| 1342 |
create_element_with_vector_field_write_using_bucket({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 1343 |
read_vector_field_on_device(stkField); |
| 1344 |
|
| 1345 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1346 |
check_no_warnings(stdoutString); |
| 1347 |
} |
| 1348 |
|
| 1349 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingBucket_DeleteBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 1350 |
{ |
| 1351 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1352 |
const unsigned bucketCapacity = 1; |
| 1353 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1354 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1355 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1356 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1357 |
|
| 1358 |
testing::internal::CaptureStdout(); |
| 1359 |
|
| 1360 |
delete_element_with_vector_field_write_using_bucket({2}, stkField, 3.14); |
| 1361 |
read_vector_field_on_device(stkField); |
| 1362 |
|
| 1363 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1364 |
check_no_warnings(stdoutString); |
| 1365 |
} |
| 1366 |
|
| 1367 |
|
| 1368 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_ChangeBucket_MissingDeviceFieldUpdate_AccessOnDevice_Warning) |
| 1369 |
{ |
| 1370 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1371 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1372 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1373 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1374 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1375 |
stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 1376 |
|
| 1377 |
testing::internal::CaptureStdout(); |
| 1378 |
modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 1379 |
|
| 1380 |
read_old_scalar_field_on_device(stkField, ngpField); |
| 1381 |
|
| 1382 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1383 |
extract_warning(stdoutString, 3, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification"); |
| 1384 |
check_no_warnings(stdoutString); |
| 1385 |
} |
| 1386 |
|
| 1387 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_CreateBucket_MissingDeviceFieldUpdate_AccessOnDevice_Warning) |
| 1388 |
{ |
| 1389 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1390 |
const unsigned bucketCapacity = 1; |
| 1391 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1392 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1393 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1394 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1395 |
stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 1396 |
|
| 1397 |
testing::internal::CaptureStdout(); |
| 1398 |
create_element_with_scalar_field_write_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 1399 |
|
| 1400 |
const stk::mesh::EntityId maxEntityIdInOldField = 1; |
| 1401 |
read_old_scalar_field_on_device(stkField, ngpField, maxEntityIdInOldField); |
| 1402 |
|
| 1403 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1404 |
extract_warning(stdoutString, 1, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification"); |
| 1405 |
check_no_warnings(stdoutString); |
| 1406 |
} |
| 1407 |
|
| 1408 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_DeleteBucket_MissingDeviceFieldUpdate_AccessOnDevice_Warning) |
| 1409 |
{ |
| 1410 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1411 |
const unsigned bucketCapacity = 1; |
| 1412 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1413 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1414 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1415 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1416 |
stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 1417 |
|
| 1418 |
testing::internal::CaptureStdout(); |
| 1419 |
delete_element_with_scalar_field_write_using_entity({2}, stkField, 3.14); |
| 1420 |
|
| 1421 |
read_old_scalar_field_on_device(stkField, ngpField); |
| 1422 |
|
| 1423 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1424 |
extract_warning(stdoutString, 2, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification"); |
| 1425 |
check_no_warnings(stdoutString); |
| 1426 |
} |
| 1427 |
|
| 1428 |
|
| 1429 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_ModifyBucket_StaleDeviceFieldCopy_AccessOnDevice_Warning) |
| 1430 |
{ |
| 1431 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1432 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1433 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1434 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1435 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1436 |
stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> ngpFieldCopy = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 1437 |
|
| 1438 |
testing::internal::CaptureStdout(); |
| 1439 |
modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part2", "Part1"}}, stkField, 3.14); |
| 1440 |
|
| 1441 |
// The device Field is currently out-of-date, so our debugging code on the host side needs to not |
| 1442 |
// mysteriously seg-fault before the user does the read on the Device side, where they will get |
| 1443 |
// a useful warning. Do a host-side write to confirm that we skip over dangerous code properly. |
| 1444 |
stkField.modify_on_host(); |
| 1445 |
stkField.sync_to_device(); |
| 1446 |
|
| 1447 |
read_old_scalar_field_on_device(stkField, ngpFieldCopy); |
| 1448 |
|
| 1449 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1450 |
extract_warning(stdoutString, 3, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification"); |
| 1451 |
check_no_warnings(stdoutString); |
| 1452 |
} |
| 1453 |
|
| 1454 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_CreateBucket_StaleDeviceFieldCopy_AccessOnDevice_Warning) |
| 1455 |
{ |
| 1456 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1457 |
const unsigned bucketCapacity = 1; |
| 1458 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1459 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1460 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1461 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1462 |
stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> ngpFieldCopy = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 1463 |
|
| 1464 |
testing::internal::CaptureStdout(); |
| 1465 |
create_element_with_scalar_field_write_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 1466 |
|
| 1467 |
// The device Field is currently out-of-date, so our debugging code on the host side needs to not |
| 1468 |
// mysteriously seg-fault before the user does the read on the Device side, where they will get |
| 1469 |
// a useful warning. Do a host-side write to confirm that we skip over dangerous code properly. |
| 1470 |
stkField.modify_on_host(); |
| 1471 |
stkField.sync_to_device(); |
| 1472 |
|
| 1473 |
const stk::mesh::EntityId maxIdToRead = 1; // Avoid memory corruption due to accessing old Field after new bucket allocation |
| 1474 |
read_old_scalar_field_on_device(stkField, ngpFieldCopy, maxIdToRead); |
| 1475 |
|
| 1476 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1477 |
extract_warning(stdoutString, 1, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification"); |
| 1478 |
check_no_warnings(stdoutString); |
| 1479 |
} |
| 1480 |
|
| 1481 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_DeleteBucket_StaleDeviceFieldCopy_AccessOnDevice_Warning) |
| 1482 |
{ |
| 1483 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1484 |
const unsigned bucketCapacity = 1; |
| 1485 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1486 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1487 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1488 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1489 |
stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> ngpFieldCopy = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 1490 |
|
| 1491 |
testing::internal::CaptureStdout(); |
| 1492 |
delete_element_with_scalar_field_write_using_entity({2}, stkField, 3.14); |
| 1493 |
|
| 1494 |
// The device Field is currently out-of-date, so our debugging code on the host side needs to not |
| 1495 |
// mysteriously seg-fault before the user does the read on the Device side, where they will get |
| 1496 |
// a useful warning. Do a host-side write to confirm that we skip over dangerous code properly. |
| 1497 |
stkField.modify_on_host(); |
| 1498 |
stkField.sync_to_device(); |
| 1499 |
|
| 1500 |
read_old_scalar_field_on_device(stkField, ngpFieldCopy); |
| 1501 |
|
| 1502 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1503 |
extract_warning(stdoutString, 2, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification"); |
| 1504 |
check_no_warnings(stdoutString); |
| 1505 |
} |
| 1506 |
|
| 1507 |
|
| 1508 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_ChangeBucket_ProperlySyncToHost_NoWarning) |
| 1509 |
{ |
| 1510 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1511 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1512 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1513 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1514 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1515 |
|
| 1516 |
testing::internal::CaptureStdout(); |
| 1517 |
|
| 1518 |
write_scalar_field_on_device(stkField, 3.14); |
| 1519 |
stkField.modify_on_device(); |
| 1520 |
stkField.sync_to_host(); |
| 1521 |
|
| 1522 |
modify_element_part_membership_with_scalar_field_read_using_entity({{2, "Part2", "Part1"}}, stkField); |
| 1523 |
|
| 1524 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1525 |
check_no_warnings(stdoutString); |
| 1526 |
} |
| 1527 |
|
| 1528 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_CreateBucket_ProperlySyncToHost_NoWarning) |
| 1529 |
{ |
| 1530 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1531 |
const unsigned bucketCapacity = 1; |
| 1532 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1533 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1534 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1535 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1536 |
|
| 1537 |
testing::internal::CaptureStdout(); |
| 1538 |
|
| 1539 |
write_scalar_field_on_device(stkField, 3.14); |
| 1540 |
stkField.modify_on_device(); |
| 1541 |
stkField.sync_to_host(); |
| 1542 |
|
| 1543 |
create_element_with_scalar_field_read_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField); |
| 1544 |
|
| 1545 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1546 |
check_no_warnings(stdoutString); |
| 1547 |
} |
| 1548 |
|
| 1549 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_DeleteBucket_ProperlySyncToHost_NoWarning) |
| 1550 |
{ |
| 1551 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1552 |
const unsigned bucketCapacity = 1; |
| 1553 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1554 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1555 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1556 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1557 |
|
| 1558 |
testing::internal::CaptureStdout(); |
| 1559 |
|
| 1560 |
write_scalar_field_on_device(stkField, 3.14); |
| 1561 |
stkField.modify_on_device(); |
| 1562 |
stkField.sync_to_host(); |
| 1563 |
|
| 1564 |
delete_element_with_scalar_field_read_using_entity({2}, stkField); |
| 1565 |
|
| 1566 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1567 |
check_no_warnings(stdoutString); |
| 1568 |
} |
| 1569 |
|
| 1570 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingEntity_ChangeBucket_ProperlySyncToHost_NoWarning) |
| 1571 |
{ |
| 1572 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1573 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1574 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1575 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1576 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1577 |
|
| 1578 |
testing::internal::CaptureStdout(); |
| 1579 |
|
| 1580 |
write_vector_field_on_device(stkField, 3.14); |
| 1581 |
stkField.modify_on_device(); |
| 1582 |
stkField.sync_to_host(); |
| 1583 |
|
| 1584 |
modify_element_part_membership_with_vector_field_read_using_entity({{2, "Part2", "Part1"}}, stkField); |
| 1585 |
|
| 1586 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1587 |
check_no_warnings(stdoutString); |
| 1588 |
} |
| 1589 |
|
| 1590 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingEntity_CreateBucket_ProperlySyncToHost_NoWarning) |
| 1591 |
{ |
| 1592 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1593 |
const unsigned bucketCapacity = 1; |
| 1594 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1595 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1596 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1597 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1598 |
|
| 1599 |
testing::internal::CaptureStdout(); |
| 1600 |
|
| 1601 |
write_vector_field_on_device(stkField, 3.14); |
| 1602 |
stkField.modify_on_device(); |
| 1603 |
stkField.sync_to_host(); |
| 1604 |
|
| 1605 |
create_element_with_vector_field_read_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField); |
| 1606 |
|
| 1607 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1608 |
check_no_warnings(stdoutString); |
| 1609 |
} |
| 1610 |
|
| 1611 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingEntity_DeleteBucket_ProperlySyncToHost_NoWarning) |
| 1612 |
{ |
| 1613 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1614 |
const unsigned bucketCapacity = 1; |
| 1615 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1616 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1617 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1618 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1619 |
|
| 1620 |
testing::internal::CaptureStdout(); |
| 1621 |
|
| 1622 |
write_vector_field_on_device(stkField, 3.14); |
| 1623 |
stkField.modify_on_device(); |
| 1624 |
stkField.sync_to_host(); |
| 1625 |
|
| 1626 |
delete_element_with_vector_field_read_using_entity({2}, stkField); |
| 1627 |
|
| 1628 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1629 |
check_no_warnings(stdoutString); |
| 1630 |
} |
| 1631 |
|
| 1632 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucket_ChangeBucket_ProperlySyncToHost_NoWarning) |
| 1633 |
{ |
| 1634 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1635 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1636 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1637 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1638 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1639 |
|
| 1640 |
testing::internal::CaptureStdout(); |
| 1641 |
|
| 1642 |
write_scalar_field_on_device(stkField, 3.14); |
| 1643 |
stkField.modify_on_device(); |
| 1644 |
stkField.sync_to_host(); |
| 1645 |
|
| 1646 |
modify_element_part_membership_with_scalar_field_read_using_bucket({{2, "Part2", "Part1"}}, stkField); |
| 1647 |
|
| 1648 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1649 |
check_no_warnings(stdoutString); |
| 1650 |
} |
| 1651 |
|
| 1652 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucket_CreateBucket_ProperlySyncToHost_NoWarning) |
| 1653 |
{ |
| 1654 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1655 |
const unsigned bucketCapacity = 1; |
| 1656 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1657 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1658 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1659 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1660 |
|
| 1661 |
testing::internal::CaptureStdout(); |
| 1662 |
|
| 1663 |
write_scalar_field_on_device(stkField, 3.14); |
| 1664 |
stkField.modify_on_device(); |
| 1665 |
stkField.sync_to_host(); |
| 1666 |
|
| 1667 |
create_element_with_scalar_field_read_using_bucket({{3, "Part1"}, {4, "Part1"}}, stkField); |
| 1668 |
|
| 1669 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1670 |
check_no_warnings(stdoutString); |
| 1671 |
} |
| 1672 |
|
| 1673 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucket_DeleteBucket_ProperlySyncToHost_NoWarning) |
| 1674 |
{ |
| 1675 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1676 |
const unsigned bucketCapacity = 1; |
| 1677 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1678 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1679 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1680 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1681 |
|
| 1682 |
testing::internal::CaptureStdout(); |
| 1683 |
|
| 1684 |
write_scalar_field_on_device(stkField, 3.14); |
| 1685 |
stkField.modify_on_device(); |
| 1686 |
stkField.sync_to_host(); |
| 1687 |
|
| 1688 |
delete_element_with_scalar_field_read_using_bucket({2}, stkField); |
| 1689 |
|
| 1690 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1691 |
check_no_warnings(stdoutString); |
| 1692 |
} |
| 1693 |
|
| 1694 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingBucket_ChangeBucket_ProperlySyncToHost_NoWarning) |
| 1695 |
{ |
| 1696 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1697 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1698 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1699 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1700 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1701 |
|
| 1702 |
testing::internal::CaptureStdout(); |
| 1703 |
|
| 1704 |
write_vector_field_on_device(stkField, 3.14); |
| 1705 |
stkField.modify_on_device(); |
| 1706 |
stkField.sync_to_host(); |
| 1707 |
|
| 1708 |
modify_element_part_membership_with_vector_field_read_using_bucket({{2, "Part2", "Part1"}}, stkField); |
| 1709 |
|
| 1710 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1711 |
check_no_warnings(stdoutString); |
| 1712 |
} |
| 1713 |
|
| 1714 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingBucket_CreateBucket_ProperlySyncToHost_NoWarning) |
| 1715 |
{ |
| 1716 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1717 |
const unsigned bucketCapacity = 1; |
| 1718 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1719 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1720 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1721 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1722 |
|
| 1723 |
testing::internal::CaptureStdout(); |
| 1724 |
|
| 1725 |
write_vector_field_on_device(stkField, 3.14); |
| 1726 |
stkField.modify_on_device(); |
| 1727 |
stkField.sync_to_host(); |
| 1728 |
|
| 1729 |
create_element_with_vector_field_read_using_bucket({{3, "Part1"}, {4, "Part1"}}, stkField); |
| 1730 |
|
| 1731 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1732 |
check_no_warnings(stdoutString); |
| 1733 |
} |
| 1734 |
|
| 1735 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingBucket_DeleteBucket_ProperlySyncToHost_NoWarning) |
| 1736 |
{ |
| 1737 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1738 |
const unsigned bucketCapacity = 1; |
| 1739 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1740 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1741 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1742 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1743 |
|
| 1744 |
testing::internal::CaptureStdout(); |
| 1745 |
|
| 1746 |
write_vector_field_on_device(stkField, 3.14); |
| 1747 |
stkField.modify_on_device(); |
| 1748 |
stkField.sync_to_host(); |
| 1749 |
|
| 1750 |
delete_element_with_vector_field_read_using_bucket({2}, stkField); |
| 1751 |
|
| 1752 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1753 |
check_no_warnings(stdoutString); |
| 1754 |
} |
| 1755 |
|
| 1756 |
|
| 1757 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_ChangeBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1758 |
{ |
| 1759 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1760 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1761 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1762 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1763 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1764 |
|
| 1765 |
testing::internal::CaptureStdout(); |
| 1766 |
|
| 1767 |
write_scalar_field_on_device(stkField, 3.14); |
| 1768 |
modify_element_part_membership_with_scalar_field_read_using_entity({{2, "Part2", "Part1"}}, stkField); |
| 1769 |
|
| 1770 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1771 |
extract_warning(stdoutString, 3, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host"); |
| 1772 |
check_no_warnings(stdoutString); |
| 1773 |
} |
| 1774 |
|
| 1775 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_CreateBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1776 |
{ |
| 1777 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1778 |
const unsigned bucketCapacity = 1; |
| 1779 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1780 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1781 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1782 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1783 |
|
| 1784 |
testing::internal::CaptureStdout(); |
| 1785 |
|
| 1786 |
write_scalar_field_on_device(stkField, 3.14); |
| 1787 |
create_element_with_scalar_field_read_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField); |
| 1788 |
|
| 1789 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1790 |
extract_warning(stdoutString, 4, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host"); |
| 1791 |
check_no_warnings(stdoutString); |
| 1792 |
} |
| 1793 |
|
| 1794 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_DeleteBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1795 |
{ |
| 1796 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1797 |
const unsigned bucketCapacity = 1; |
| 1798 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1799 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1800 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1801 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1802 |
|
| 1803 |
testing::internal::CaptureStdout(); |
| 1804 |
|
| 1805 |
write_scalar_field_on_device(stkField, 3.14); |
| 1806 |
delete_element_with_scalar_field_read_using_entity({2}, stkField); |
| 1807 |
|
| 1808 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1809 |
extract_warning(stdoutString, 2, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host"); |
| 1810 |
check_no_warnings(stdoutString); |
| 1811 |
} |
| 1812 |
|
| 1813 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingEntity_ChangeBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1814 |
{ |
| 1815 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1816 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1817 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1818 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1819 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1820 |
|
| 1821 |
testing::internal::CaptureStdout(); |
| 1822 |
|
| 1823 |
write_vector_field_on_device(stkField, 3.14); |
| 1824 |
modify_element_part_membership_with_vector_field_read_using_entity({{2, "Part2", "Part1"}}, stkField); |
| 1825 |
|
| 1826 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1827 |
extract_warning(stdoutString, 3, "WARNING: Lost Device values for Field doubleVectorField due to a mesh modification before a sync to Host"); |
| 1828 |
check_no_warnings(stdoutString); |
| 1829 |
} |
| 1830 |
|
| 1831 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingEntity_CreateBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1832 |
{ |
| 1833 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1834 |
const unsigned bucketCapacity = 1; |
| 1835 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1836 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1837 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1838 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1839 |
|
| 1840 |
testing::internal::CaptureStdout(); |
| 1841 |
|
| 1842 |
write_vector_field_on_device(stkField, 3.14); |
| 1843 |
create_element_with_vector_field_read_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField); |
| 1844 |
|
| 1845 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1846 |
extract_warning(stdoutString, 4, "WARNING: Lost Device values for Field doubleVectorField due to a mesh modification before a sync to Host"); |
| 1847 |
check_no_warnings(stdoutString); |
| 1848 |
} |
| 1849 |
|
| 1850 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingEntity_DeleteBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1851 |
{ |
| 1852 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1853 |
const unsigned bucketCapacity = 1; |
| 1854 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1855 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1856 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1857 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1858 |
|
| 1859 |
testing::internal::CaptureStdout(); |
| 1860 |
|
| 1861 |
write_vector_field_on_device(stkField, 3.14); |
| 1862 |
delete_element_with_vector_field_read_using_entity({2}, stkField); |
| 1863 |
|
| 1864 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1865 |
extract_warning(stdoutString, 2, "WARNING: Lost Device values for Field doubleVectorField due to a mesh modification before a sync to Host"); |
| 1866 |
check_no_warnings(stdoutString); |
| 1867 |
} |
| 1868 |
|
| 1869 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucket_ChangeBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1870 |
{ |
| 1871 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1872 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1873 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1874 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1875 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1876 |
|
| 1877 |
testing::internal::CaptureStdout(); |
| 1878 |
|
| 1879 |
write_scalar_field_on_device(stkField, 3.14); |
| 1880 |
modify_element_part_membership_with_scalar_field_read_using_bucket({{2, "Part2", "Part1"}}, stkField); |
| 1881 |
|
| 1882 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1883 |
extract_warning(stdoutString, 3, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host"); |
| 1884 |
check_no_warnings(stdoutString); |
| 1885 |
} |
| 1886 |
|
| 1887 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucket_CreateBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1888 |
{ |
| 1889 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1890 |
const unsigned bucketCapacity = 1; |
| 1891 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1892 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1893 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1894 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1895 |
|
| 1896 |
testing::internal::CaptureStdout(); |
| 1897 |
|
| 1898 |
write_scalar_field_on_device(stkField, 3.14); |
| 1899 |
create_element_with_scalar_field_read_using_bucket({{3, "Part1"}, {4, "Part1"}}, stkField); |
| 1900 |
|
| 1901 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1902 |
extract_warning(stdoutString, 4, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host"); |
| 1903 |
check_no_warnings(stdoutString); |
| 1904 |
} |
| 1905 |
|
| 1906 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingBucket_DeleteBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1907 |
{ |
| 1908 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1909 |
const unsigned bucketCapacity = 1; |
| 1910 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1911 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1912 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1913 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1914 |
|
| 1915 |
testing::internal::CaptureStdout(); |
| 1916 |
|
| 1917 |
write_scalar_field_on_device(stkField, 3.14); |
| 1918 |
delete_element_with_scalar_field_read_using_bucket({2}, stkField); |
| 1919 |
|
| 1920 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1921 |
extract_warning(stdoutString, 2, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host"); |
| 1922 |
check_no_warnings(stdoutString); |
| 1923 |
} |
| 1924 |
|
| 1925 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingBucket_ChangeBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1926 |
{ |
| 1927 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1928 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1929 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1930 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1931 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1932 |
|
| 1933 |
testing::internal::CaptureStdout(); |
| 1934 |
|
| 1935 |
write_vector_field_on_device(stkField, 3.14); |
| 1936 |
modify_element_part_membership_with_vector_field_read_using_bucket({{2, "Part2", "Part1"}}, stkField); |
| 1937 |
|
| 1938 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1939 |
extract_warning(stdoutString, 3, "WARNING: Lost Device values for Field doubleVectorField due to a mesh modification before a sync to Host"); |
| 1940 |
check_no_warnings(stdoutString); |
| 1941 |
} |
| 1942 |
|
| 1943 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingBucket_CreateBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1944 |
{ |
| 1945 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1946 |
const unsigned bucketCapacity = 1; |
| 1947 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1948 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1949 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 1950 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1951 |
|
| 1952 |
testing::internal::CaptureStdout(); |
| 1953 |
|
| 1954 |
write_vector_field_on_device(stkField, 3.14); |
| 1955 |
create_element_with_vector_field_read_using_bucket({{3, "Part1"}, {4, "Part1"}}, stkField); |
| 1956 |
|
| 1957 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1958 |
extract_warning(stdoutString, 4, "WARNING: Lost Device values for Field doubleVectorField due to a mesh modification before a sync to Host"); |
| 1959 |
check_no_warnings(stdoutString); |
| 1960 |
} |
| 1961 |
|
| 1962 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, VectorAccessUsingBucket_DeleteBucket_MissingAllModifySyncCallsToHost_Warning) |
| 1963 |
{ |
| 1964 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1965 |
const unsigned bucketCapacity = 1; |
| 1966 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 1967 |
declare_vector_field<double>("doubleVectorField", 3, {"Part1", "Part2"}); |
| 1968 |
build_mesh({{"Part1", 2}, {"Part2", 1}}); |
| 1969 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleVectorField"); |
| 1970 |
|
| 1971 |
testing::internal::CaptureStdout(); |
| 1972 |
|
| 1973 |
write_vector_field_on_device(stkField, 3.14); |
| 1974 |
delete_element_with_vector_field_read_using_bucket({2}, stkField); |
| 1975 |
|
| 1976 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 1977 |
extract_warning(stdoutString, 2, "WARNING: Lost Device values for Field doubleVectorField due to a mesh modification before a sync to Host"); |
| 1978 |
check_no_warnings(stdoutString); |
| 1979 |
} |
| 1980 |
|
| 1981 |
|
| 1982 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_ChangeBucket_ChangeBucket_ProperlySyncToDevice_NoWarning) |
| 1983 |
{ |
| 1984 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 1985 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 1986 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 1987 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 1988 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 1989 |
|
| 1990 |
testing::internal::CaptureStdout(); |
| 1991 |
|
| 1992 |
modify_element_part_membership_with_scalar_field_write_using_entity({{3, "Part2", "Part1"}}, stkField, 3.14); |
| 1993 |
modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part2", "Part1"}}, stkField, 2.18); |
| 1994 |
|
| 1995 |
stkField.modify_on_host(); |
| 1996 |
stkField.sync_to_device(); |
| 1997 |
|
| 1998 |
read_scalar_field_on_device(stkField); |
| 1999 |
|
| 2000 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2001 |
check_no_warnings(stdoutString); |
| 2002 |
} |
| 2003 |
|
| 2004 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_CreateBucket_CreateBucket_ProperlySyncToDevice_NoWarning) |
| 2005 |
{ |
| 2006 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2007 |
const unsigned bucketCapacity = 1; |
| 2008 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2009 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2010 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 2011 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2012 |
|
| 2013 |
testing::internal::CaptureStdout(); |
| 2014 |
create_element_with_scalar_field_write_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 2015 |
create_element_with_scalar_field_write_using_entity({{5, "Part1"}, {6, "Part1"}}, stkField, 2.18); |
| 2016 |
|
| 2017 |
stkField.modify_on_host(); |
| 2018 |
stkField.sync_to_device(); |
| 2019 |
|
| 2020 |
read_scalar_field_on_device(stkField); |
| 2021 |
|
| 2022 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2023 |
check_no_warnings(stdoutString); |
| 2024 |
} |
| 2025 |
|
| 2026 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_DeleteBucket_DeleteBucket_ProperlySyncToDevice_NoWarning) |
| 2027 |
{ |
| 2028 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2029 |
const unsigned bucketCapacity = 1; |
| 2030 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2031 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2032 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2033 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2034 |
|
| 2035 |
testing::internal::CaptureStdout(); |
| 2036 |
delete_element_with_scalar_field_write_using_entity({2}, stkField, 3.14); |
| 2037 |
delete_element_with_scalar_field_write_using_entity({3}, stkField, 2.18); |
| 2038 |
|
| 2039 |
stkField.modify_on_host(); |
| 2040 |
stkField.sync_to_device(); |
| 2041 |
|
| 2042 |
read_scalar_field_on_device(stkField); |
| 2043 |
|
| 2044 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2045 |
check_no_warnings(stdoutString); |
| 2046 |
} |
| 2047 |
|
| 2048 |
|
| 2049 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_ChangeBucket_ChangeBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 2050 |
{ |
| 2051 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2052 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 2053 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2054 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2055 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2056 |
|
| 2057 |
testing::internal::CaptureStdout(); |
| 2058 |
|
| 2059 |
modify_element_part_membership_with_scalar_field_write_using_entity({{3, "Part2", "Part1"}}, stkField, 3.14); |
| 2060 |
modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part2", "Part1"}}, stkField, 2.18); |
| 2061 |
|
| 2062 |
read_scalar_field_on_device(stkField); |
| 2063 |
|
| 2064 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2065 |
check_no_warnings(stdoutString); |
| 2066 |
} |
| 2067 |
|
| 2068 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_CreateBucket_CreateBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 2069 |
{ |
| 2070 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2071 |
const unsigned bucketCapacity = 1; |
| 2072 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2073 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2074 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 2075 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2076 |
|
| 2077 |
testing::internal::CaptureStdout(); |
| 2078 |
create_element_with_scalar_field_write_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 2079 |
create_element_with_scalar_field_write_using_entity({{5, "Part1"}, {6, "Part1"}}, stkField, 2.18); |
| 2080 |
|
| 2081 |
read_scalar_field_on_device(stkField); |
| 2082 |
|
| 2083 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2084 |
check_no_warnings(stdoutString); |
| 2085 |
} |
| 2086 |
|
| 2087 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_DeleteBucket_DeleteBucket_MissingAllModifySyncCalls_NoWarning) |
| 2088 |
{ |
| 2089 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2090 |
const unsigned bucketCapacity = 1; |
| 2091 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2092 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2093 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2094 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2095 |
|
| 2096 |
testing::internal::CaptureStdout(); |
| 2097 |
delete_element_with_scalar_field_write_using_entity({2}, stkField, 3.14); |
| 2098 |
delete_element_with_scalar_field_write_using_entity({3}, stkField, 2.18); |
| 2099 |
|
| 2100 |
read_scalar_field_on_device(stkField); |
| 2101 |
|
| 2102 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2103 |
check_no_warnings(stdoutString); |
| 2104 |
} |
| 2105 |
|
| 2106 |
|
| 2107 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_ChangeBucket_ChangeBucket_MissingDeviceFieldUpdate_Warning) |
| 2108 |
{ |
| 2109 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2110 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 2111 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2112 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2113 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2114 |
stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 2115 |
|
| 2116 |
testing::internal::CaptureStdout(); |
| 2117 |
|
| 2118 |
modify_element_part_membership_with_scalar_field_write_using_entity({{3, "Part2", "Part1"}}, stkField, 3.14); |
| 2119 |
modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part2", "Part1"}}, stkField, 2.18); |
| 2120 |
|
| 2121 |
read_old_scalar_field_on_device(stkField, ngpField); |
| 2122 |
|
| 2123 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2124 |
extract_warning(stdoutString, 4, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification"); |
| 2125 |
check_no_warnings(stdoutString); |
| 2126 |
} |
| 2127 |
|
| 2128 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_CreateBucket_CreateBucket_MissingDeviceFieldUpdate_Warning) |
| 2129 |
{ |
| 2130 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2131 |
const unsigned bucketCapacity = 1; |
| 2132 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2133 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2134 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 2135 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2136 |
stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 2137 |
|
| 2138 |
testing::internal::CaptureStdout(); |
| 2139 |
create_element_with_scalar_field_write_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 2140 |
create_element_with_scalar_field_write_using_entity({{5, "Part1"}, {6, "Part1"}}, stkField, 2.18); |
| 2141 |
|
| 2142 |
const stk::mesh::EntityId maxIdToRead = 1; // Avoid memory corruption due to accessing old Field after new bucket allocation |
| 2143 |
read_old_scalar_field_on_device(stkField, ngpField, maxIdToRead); |
| 2144 |
|
| 2145 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2146 |
extract_warning(stdoutString, 1, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification"); |
| 2147 |
check_no_warnings(stdoutString); |
| 2148 |
} |
| 2149 |
|
| 2150 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_DeleteBucket_DeleteBucket_MissingDeviceFieldUpdate_Warning) |
| 2151 |
{ |
| 2152 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2153 |
const unsigned bucketCapacity = 1; |
| 2154 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2155 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2156 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2157 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2158 |
stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 2159 |
|
| 2160 |
testing::internal::CaptureStdout(); |
| 2161 |
delete_element_with_scalar_field_write_using_entity({2}, stkField, 3.14); |
| 2162 |
delete_element_with_scalar_field_write_using_entity({3}, stkField, 2.18); |
| 2163 |
|
| 2164 |
read_old_scalar_field_on_device(stkField, ngpField); |
| 2165 |
|
| 2166 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2167 |
extract_warning(stdoutString, 2, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification"); |
| 2168 |
check_no_warnings(stdoutString); |
| 2169 |
} |
| 2170 |
|
| 2171 |
|
| 2172 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_ChangeBucket_ChangeBucket_ProperlySyncToHost_NoWarning) |
| 2173 |
{ |
| 2174 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2175 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 2176 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2177 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2178 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2179 |
|
| 2180 |
testing::internal::CaptureStdout(); |
| 2181 |
|
| 2182 |
write_scalar_field_on_device(stkField, 3.14); |
| 2183 |
stkField.modify_on_device(); |
| 2184 |
stkField.sync_to_host(); |
| 2185 |
|
| 2186 |
modify_element_part_membership_with_scalar_field_read_using_entity({{3, "Part2", "Part1"}}, stkField); |
| 2187 |
modify_element_part_membership_with_scalar_field_read_using_entity({{2, "Part2", "Part1"}}, stkField); |
| 2188 |
|
| 2189 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2190 |
check_no_warnings(stdoutString); |
| 2191 |
} |
| 2192 |
|
| 2193 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_CreateBucket_CreateBucket_ProperlySyncToHost_NoWarning) |
| 2194 |
{ |
| 2195 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2196 |
const unsigned bucketCapacity = 1; |
| 2197 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2198 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2199 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 2200 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2201 |
|
| 2202 |
testing::internal::CaptureStdout(); |
| 2203 |
|
| 2204 |
write_scalar_field_on_device(stkField, 3.14); |
| 2205 |
stkField.modify_on_device(); |
| 2206 |
stkField.sync_to_host(); |
| 2207 |
|
| 2208 |
create_element_with_scalar_field_read_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField); |
| 2209 |
create_element_with_scalar_field_read_using_entity({{5, "Part1"}, {6, "Part1"}}, stkField); |
| 2210 |
|
| 2211 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2212 |
check_no_warnings(stdoutString); |
| 2213 |
} |
| 2214 |
|
| 2215 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_DeleteBucket_DeleteBucket_ProperlySyncToHost_NoWarning) |
| 2216 |
{ |
| 2217 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2218 |
const unsigned bucketCapacity = 1; |
| 2219 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2220 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2221 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2222 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2223 |
|
| 2224 |
testing::internal::CaptureStdout(); |
| 2225 |
|
| 2226 |
write_scalar_field_on_device(stkField, 3.14); |
| 2227 |
stkField.modify_on_device(); |
| 2228 |
stkField.sync_to_host(); |
| 2229 |
|
| 2230 |
delete_element_with_scalar_field_read_using_entity({2}, stkField); |
| 2231 |
delete_element_with_scalar_field_read_using_entity({3}, stkField); |
| 2232 |
|
| 2233 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2234 |
check_no_warnings(stdoutString); |
| 2235 |
} |
| 2236 |
|
| 2237 |
|
| 2238 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_ChangeBucket_ChangeBucket_MissingAllModifySyncCallsToHost_Warning) |
| 2239 |
{ |
| 2240 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2241 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 2242 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2243 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2244 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2245 |
|
| 2246 |
testing::internal::CaptureStdout(); |
| 2247 |
|
| 2248 |
write_scalar_field_on_device(stkField, 3.14); |
| 2249 |
|
| 2250 |
modify_element_part_membership_with_scalar_field_read_using_entity({{3, "Part2", "Part1"}}, stkField); |
| 2251 |
modify_element_part_membership_with_scalar_field_read_using_entity({{2, "Part2", "Part1"}}, stkField); |
| 2252 |
|
| 2253 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2254 |
extract_warning(stdoutString, 8, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host"); |
| 2255 |
check_no_warnings(stdoutString); |
| 2256 |
} |
| 2257 |
|
| 2258 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_CreateBucket_CreateBucket_MissingAllModifySyncCallsToHost_Warning) |
| 2259 |
{ |
| 2260 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2261 |
const unsigned bucketCapacity = 1; |
| 2262 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2263 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2264 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 2265 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2266 |
|
| 2267 |
testing::internal::CaptureStdout(); |
| 2268 |
|
| 2269 |
write_scalar_field_on_device(stkField, 3.14); |
| 2270 |
|
| 2271 |
create_element_with_scalar_field_read_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField); |
| 2272 |
create_element_with_scalar_field_read_using_entity({{5, "Part1"}, {6, "Part1"}}, stkField); |
| 2273 |
|
| 2274 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2275 |
extract_warning(stdoutString, 10, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host"); |
| 2276 |
check_no_warnings(stdoutString); |
| 2277 |
} |
| 2278 |
|
| 2279 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoConsecutiveMods_DeleteBucket_DeleteBucket_MissingAllModifySyncCallsToHost_Warning) |
| 2280 |
{ |
| 2281 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2282 |
const unsigned bucketCapacity = 1; |
| 2283 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2284 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2285 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2286 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2287 |
|
| 2288 |
testing::internal::CaptureStdout(); |
| 2289 |
|
| 2290 |
write_scalar_field_on_device(stkField, 3.14); |
| 2291 |
|
| 2292 |
delete_element_with_scalar_field_read_using_entity({2}, stkField); |
| 2293 |
delete_element_with_scalar_field_read_using_entity({3}, stkField); |
| 2294 |
|
| 2295 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2296 |
extract_warning(stdoutString, 5, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host"); |
| 2297 |
check_no_warnings(stdoutString); |
| 2298 |
} |
| 2299 |
|
| 2300 |
|
| 2301 |
|
| 2302 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoMods_ChangeBucket_ChangeBucket_ProperlySyncToDevice_NoWarning) |
| 2303 |
{ |
| 2304 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2305 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 2306 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2307 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2308 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2309 |
|
| 2310 |
testing::internal::CaptureStdout(); |
| 2311 |
|
| 2312 |
modify_element_part_membership_with_scalar_field_write_using_entity({{3, "Part2", "Part1"}}, stkField, 3.14); |
| 2313 |
stkField.modify_on_host(); |
| 2314 |
stkField.sync_to_device(); |
| 2315 |
read_scalar_field_on_device(stkField); |
| 2316 |
|
| 2317 |
modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part2", "Part1"}}, stkField, 2.18); |
| 2318 |
stkField.modify_on_host(); |
| 2319 |
stkField.sync_to_device(); |
| 2320 |
read_scalar_field_on_device(stkField); |
| 2321 |
|
| 2322 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2323 |
check_no_warnings(stdoutString); |
| 2324 |
} |
| 2325 |
|
| 2326 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoMods_CreateBucket_CreateBucket_ProperlySyncToDevice_NoWarning) |
| 2327 |
{ |
| 2328 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2329 |
const unsigned bucketCapacity = 1; |
| 2330 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2331 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2332 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 2333 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2334 |
|
| 2335 |
testing::internal::CaptureStdout(); |
| 2336 |
|
| 2337 |
create_element_with_scalar_field_write_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 2338 |
stkField.modify_on_host(); |
| 2339 |
stkField.sync_to_device(); |
| 2340 |
read_scalar_field_on_device(stkField); |
| 2341 |
|
| 2342 |
create_element_with_scalar_field_write_using_entity({{5, "Part1"}, {6, "Part1"}}, stkField, 2.18); |
| 2343 |
stkField.modify_on_host(); |
| 2344 |
stkField.sync_to_device(); |
| 2345 |
read_scalar_field_on_device(stkField); |
| 2346 |
|
| 2347 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2348 |
check_no_warnings(stdoutString); |
| 2349 |
} |
| 2350 |
|
| 2351 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, TwoMods_DeleteBucket_DeleteBucket_ProperlySyncToDevice_NoWarning) |
| 2352 |
{ |
| 2353 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2354 |
const unsigned bucketCapacity = 1; |
| 2355 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2356 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2357 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2358 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2359 |
|
| 2360 |
testing::internal::CaptureStdout(); |
| 2361 |
|
| 2362 |
delete_element_with_scalar_field_write_using_entity({2}, stkField, 3.14); |
| 2363 |
stkField.modify_on_host(); |
| 2364 |
stkField.sync_to_device(); |
| 2365 |
read_scalar_field_on_device(stkField); |
| 2366 |
|
| 2367 |
delete_element_with_scalar_field_write_using_entity({3}, stkField, 2.18); |
| 2368 |
stkField.modify_on_host(); |
| 2369 |
stkField.sync_to_device(); |
| 2370 |
read_scalar_field_on_device(stkField); |
| 2371 |
|
| 2372 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2373 |
check_no_warnings(stdoutString); |
| 2374 |
} |
| 2375 |
|
| 2376 |
|
| 2377 |
|
| 2378 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_TwoMods_ChangeBucket_ChangeBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 2379 |
{ |
| 2380 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2381 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 2382 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2383 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2384 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2385 |
|
| 2386 |
testing::internal::CaptureStdout(); |
| 2387 |
|
| 2388 |
modify_element_part_membership_with_scalar_field_write_using_entity({{3, "Part2", "Part1"}}, stkField, 3.14); |
| 2389 |
read_scalar_field_on_device(stkField); |
| 2390 |
|
| 2391 |
modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part2", "Part1"}}, stkField, 2.18); |
| 2392 |
read_scalar_field_on_device(stkField); |
| 2393 |
|
| 2394 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2395 |
check_no_warnings(stdoutString); |
| 2396 |
} |
| 2397 |
|
| 2398 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_TwoMods_CreateBucket_CreateBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 2399 |
{ |
| 2400 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2401 |
const unsigned bucketCapacity = 1; |
| 2402 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2403 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2404 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 2405 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2406 |
|
| 2407 |
testing::internal::CaptureStdout(); |
| 2408 |
|
| 2409 |
create_element_with_scalar_field_write_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 2410 |
read_scalar_field_on_device(stkField); |
| 2411 |
|
| 2412 |
create_element_with_scalar_field_write_using_entity({{5, "Part1"}, {6, "Part1"}}, stkField, 2.18); |
| 2413 |
read_scalar_field_on_device(stkField); |
| 2414 |
|
| 2415 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2416 |
check_no_warnings(stdoutString); |
| 2417 |
} |
| 2418 |
|
| 2419 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_TwoMods_DeleteBucket_DeleteBucket_MissingAllModifySyncCallsToDevice_NoWarning) |
| 2420 |
{ |
| 2421 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2422 |
const unsigned bucketCapacity = 1; |
| 2423 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2424 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2425 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2426 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2427 |
|
| 2428 |
testing::internal::CaptureStdout(); |
| 2429 |
|
| 2430 |
delete_element_with_scalar_field_write_using_entity({2}, stkField, 3.14); |
| 2431 |
read_scalar_field_on_device(stkField); |
| 2432 |
|
| 2433 |
delete_element_with_scalar_field_write_using_entity({3}, stkField, 2.18); |
| 2434 |
read_scalar_field_on_device(stkField); |
| 2435 |
|
| 2436 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2437 |
check_no_warnings(stdoutString); |
| 2438 |
} |
| 2439 |
|
| 2440 |
|
| 2441 |
|
| 2442 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_TwoMods_ChangeBucket_ChangeBucket_MissingDeviceFieldUpdate_Warning) |
| 2443 |
{ |
| 2444 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2445 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 2446 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2447 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2448 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2449 |
stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 2450 |
|
| 2451 |
testing::internal::CaptureStdout(); |
| 2452 |
|
| 2453 |
modify_element_part_membership_with_scalar_field_write_using_entity({{3, "Part2", "Part1"}}, stkField, 3.14); |
| 2454 |
read_old_scalar_field_on_device(stkField, ngpField); |
| 2455 |
|
| 2456 |
modify_element_part_membership_with_scalar_field_write_using_entity({{2, "Part2", "Part1"}}, stkField, 2.18); |
| 2457 |
read_old_scalar_field_on_device(stkField, ngpField); |
| 2458 |
|
| 2459 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2460 |
extract_warning(stdoutString, 8, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification"); |
| 2461 |
check_no_warnings(stdoutString); |
| 2462 |
} |
| 2463 |
|
| 2464 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_TwoMods_CreateBucket_CreateBucket_MissingDeviceFieldUpdate_Warning) |
| 2465 |
{ |
| 2466 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2467 |
const unsigned bucketCapacity = 1; |
| 2468 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2469 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2470 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 2471 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2472 |
stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 2473 |
|
| 2474 |
testing::internal::CaptureStdout(); |
| 2475 |
const stk::mesh::EntityId maxIdToRead = 1; // Avoid memory corruption due to accessing old Field after new bucket allocation |
| 2476 |
|
| 2477 |
create_element_with_scalar_field_write_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField, 3.14); |
| 2478 |
read_old_scalar_field_on_device(stkField, ngpField, maxIdToRead); |
| 2479 |
|
| 2480 |
create_element_with_scalar_field_write_using_entity({{5, "Part1"}, {6, "Part1"}}, stkField, 2.18); |
| 2481 |
read_old_scalar_field_on_device(stkField, ngpField, maxIdToRead); |
| 2482 |
|
| 2483 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2484 |
extract_warning(stdoutString, 2, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification"); |
| 2485 |
check_no_warnings(stdoutString); |
| 2486 |
} |
| 2487 |
|
| 2488 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_TwoMods_DeleteBucket_DeleteBucket_MissingDeviceFieldUpdate_Warning) |
| 2489 |
{ |
| 2490 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2491 |
const unsigned bucketCapacity = 1; |
| 2492 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2493 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2494 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2495 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2496 |
stk::mesh::NgpField<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger> & ngpField = stk::mesh::get_updated_ngp_field<double, stk::mesh::NgpMeshDefaultMemSpace, NgpDebugger>(stkField); |
| 2497 |
|
| 2498 |
testing::internal::CaptureStdout(); |
| 2499 |
|
| 2500 |
delete_element_with_scalar_field_write_using_entity({2}, stkField, 3.14); |
| 2501 |
read_old_scalar_field_on_device(stkField, ngpField); |
| 2502 |
|
| 2503 |
delete_element_with_scalar_field_write_using_entity({3}, stkField, 2.18); |
| 2504 |
read_old_scalar_field_on_device(stkField, ngpField); |
| 2505 |
|
| 2506 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2507 |
extract_warning(stdoutString, 5, "WARNING: Accessing un-updated Field doubleScalarField on Device after mesh modification"); |
| 2508 |
check_no_warnings(stdoutString); |
| 2509 |
} |
| 2510 |
|
| 2511 |
|
| 2512 |
|
| 2513 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_TwoMods_ChangeBucket_ChangeBucket_ProperlySyncToHost_NoWarning) |
| 2514 |
{ |
| 2515 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2516 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 2517 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2518 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2519 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2520 |
|
| 2521 |
testing::internal::CaptureStdout(); |
| 2522 |
|
| 2523 |
write_scalar_field_on_device(stkField, 3.14); |
| 2524 |
stkField.modify_on_device(); |
| 2525 |
stkField.sync_to_host(); |
| 2526 |
modify_element_part_membership_with_scalar_field_read_using_entity({{3, "Part2", "Part1"}}, stkField); |
| 2527 |
|
| 2528 |
write_scalar_field_on_device(stkField, 2.18); |
| 2529 |
stkField.modify_on_device(); |
| 2530 |
stkField.sync_to_host(); |
| 2531 |
modify_element_part_membership_with_scalar_field_read_using_entity({{2, "Part2", "Part1"}}, stkField); |
| 2532 |
|
| 2533 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2534 |
check_no_warnings(stdoutString); |
| 2535 |
} |
| 2536 |
|
| 2537 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_TwoMods_CreateBucket_CreateBucket_ProperlySyncToHost_NoWarning) |
| 2538 |
{ |
| 2539 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2540 |
const unsigned bucketCapacity = 1; |
| 2541 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2542 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2543 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 2544 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2545 |
|
| 2546 |
testing::internal::CaptureStdout(); |
| 2547 |
|
| 2548 |
write_scalar_field_on_device(stkField, 3.14); |
| 2549 |
stkField.modify_on_device(); |
| 2550 |
stkField.sync_to_host(); |
| 2551 |
create_element_with_scalar_field_read_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField); |
| 2552 |
|
| 2553 |
write_scalar_field_on_device(stkField, 2.18); |
| 2554 |
stkField.modify_on_device(); |
| 2555 |
stkField.sync_to_host(); |
| 2556 |
create_element_with_scalar_field_read_using_entity({{5, "Part1"}, {6, "Part1"}}, stkField); |
| 2557 |
|
| 2558 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2559 |
check_no_warnings(stdoutString); |
| 2560 |
} |
| 2561 |
|
| 2562 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_TwoMods_DeleteBucket_DeleteBucket_ProperlySyncToHost_NoWarning) |
| 2563 |
{ |
| 2564 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2565 |
const unsigned bucketCapacity = 1; |
| 2566 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2567 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2568 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2569 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2570 |
|
| 2571 |
testing::internal::CaptureStdout(); |
| 2572 |
|
| 2573 |
write_scalar_field_on_device(stkField, 3.14); |
| 2574 |
stkField.modify_on_device(); |
| 2575 |
stkField.sync_to_host(); |
| 2576 |
delete_element_with_scalar_field_read_using_entity({2}, stkField); |
| 2577 |
|
| 2578 |
write_scalar_field_on_device(stkField, 2.18); |
| 2579 |
stkField.modify_on_device(); |
| 2580 |
stkField.sync_to_host(); |
| 2581 |
delete_element_with_scalar_field_read_using_entity({3}, stkField); |
| 2582 |
|
| 2583 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2584 |
check_no_warnings(stdoutString); |
| 2585 |
} |
| 2586 |
|
| 2587 |
|
| 2588 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_TwoMods_ChangeBucket_ChangeBucket_MissingAllModifySyncCallsToHost_Warning) |
| 2589 |
{ |
| 2590 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2591 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA); |
| 2592 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2593 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2594 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2595 |
|
| 2596 |
testing::internal::CaptureStdout(); |
| 2597 |
|
| 2598 |
write_scalar_field_on_device(stkField, 3.14); |
| 2599 |
modify_element_part_membership_with_scalar_field_read_using_entity({{3, "Part2", "Part1"}}, stkField); |
| 2600 |
|
| 2601 |
write_scalar_field_on_device(stkField, 2.18); |
| 2602 |
modify_element_part_membership_with_scalar_field_read_using_entity({{2, "Part2", "Part1"}}, stkField); |
| 2603 |
|
| 2604 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2605 |
extract_warning(stdoutString, 8, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host"); |
| 2606 |
check_no_warnings(stdoutString); |
| 2607 |
} |
| 2608 |
|
| 2609 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_TwoMods_CreateBucket_CreateBucket_MissingAllModifySyncCallsToHost_Warning) |
| 2610 |
{ |
| 2611 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2612 |
const unsigned bucketCapacity = 1; |
| 2613 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2614 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2615 |
build_mesh({{"Part1", 1}, {"Part2", 1}}); |
| 2616 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2617 |
|
| 2618 |
testing::internal::CaptureStdout(); |
| 2619 |
|
| 2620 |
write_scalar_field_on_device(stkField, 3.14); |
| 2621 |
create_element_with_scalar_field_read_using_entity({{3, "Part1"}, {4, "Part1"}}, stkField); |
| 2622 |
|
| 2623 |
write_scalar_field_on_device(stkField, 2.18); |
| 2624 |
create_element_with_scalar_field_read_using_entity({{5, "Part1"}, {6, "Part1"}}, stkField); |
| 2625 |
|
| 2626 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2627 |
extract_warning(stdoutString, 10, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host"); |
| 2628 |
check_no_warnings(stdoutString); |
| 2629 |
} |
| 2630 |
|
| 2631 |
TEST_F(NgpDebugFieldSync_AccessDuringMeshModification, ScalarAccessUsingEntity_TwoMods_DeleteBucket_DeleteBucket_MissingAllModifySyncCallsToHost_Warning) |
| 2632 |
{ |
| 2633 |
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 1) return; |
| 2634 |
const unsigned bucketCapacity = 1; |
| 2635 |
setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA, bucketCapacity, bucketCapacity); |
| 2636 |
declare_scalar_field<double>("doubleScalarField", {"Part1", "Part2"}); |
| 2637 |
build_mesh({{"Part1", 3}, {"Part2", 1}}); |
| 2638 |
stk::mesh::Field<double> & stkField = initialized_field<double>("doubleScalarField"); |
| 2639 |
|
| 2640 |
testing::internal::CaptureStdout(); |
| 2641 |
|
| 2642 |
write_scalar_field_on_device(stkField, 3.14); |
| 2643 |
delete_element_with_scalar_field_read_using_entity({2}, stkField); |
| 2644 |
|
| 2645 |
write_scalar_field_on_device(stkField, 2.18); |
| 2646 |
delete_element_with_scalar_field_read_using_entity({3}, stkField); |
| 2647 |
|
| 2648 |
std::string stdoutString = testing::internal::GetCapturedStdout(); |
| 2649 |
extract_warning(stdoutString, 5, "WARNING: Lost Device values for Field doubleScalarField due to a mesh modification before a sync to Host"); |
| 2650 |
check_no_warnings(stdoutString); |
| 2651 |
} |
| 2652 |
|
| 2653 |
} |