| 1 |
// Copyright(C) 1999-2020 National Technology & Engineering Solutions |
| 2 |
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 3 |
// NTESS, the U.S. Government retains certain rights in this software. |
| 4 |
// |
| 5 |
// See packages/seacas/LICENSE for details |
| 6 |
|
| 7 |
#pragma once |
| 8 |
|
| 9 |
#include "iocatalyst_export.h" |
| 10 |
|
| 11 |
#include "gtest/gtest.h" |
| 12 |
#include <catalyst_tests/Iocatalyst_BlockMeshSet.h> |
| 13 |
#include <cstddef> |
| 14 |
|
| 15 |
class IOCATALYST_EXPORT Iocatalyst_DatabaseIOTest : public ::testing::Test |
| 16 |
{ |
| 17 |
protected: |
| 18 |
Iocatalyst::BlockMeshSet bmSet; |
| 19 |
Iocatalyst::BlockMesh::Partition part; |
| 20 |
Iocatalyst::BlockMesh::Extent blockMeshSize; |
| 21 |
Iocatalyst::BlockMesh::Extent origin; |
| 22 |
Ioss::ParallelUtils putils; |
| 23 |
|
| 24 |
Iocatalyst_DatabaseIOTest(); |
| 25 |
|
| 26 |
bool regionsAreEqual(const std::string &fileName, const std::string &catFileName, |
| 27 |
const std::string &iossDatabaseType); |
| 28 |
|
| 29 |
bool regionsAreEqualCatalystAndIoss(const std::string &fileName, Ioss::DatabaseIO &cat_d, |
| 30 |
const std::string &iossDatabaseType); |
| 31 |
|
| 32 |
void runStructuredTest(const std::string &testName); |
| 33 |
|
| 34 |
void runUnstructuredTest(const std::string &testName); |
| 35 |
|
| 36 |
Ioss::DatabaseIO *writeAndGetExodusDatabaseOnRead(const std::string &testName, |
| 37 |
Ioss::PropertyManager dbProps = {}); |
| 38 |
|
| 39 |
Ioss::DatabaseIO *getExodusDatabaseFromFile(std::string &filename, |
| 40 |
Ioss::PropertyManager dbProps = {}); |
| 41 |
conduit_cpp::Node getConduitFromExodusFile(std::string &filename, |
| 42 |
Ioss::PropertyManager dbProps = {}); |
| 43 |
Ioss::DatabaseIO *getCatalystDatabaseFromConduit(conduit_cpp::Node &conduitNode, |
| 44 |
Ioss::PropertyManager dbProps = {}); |
| 45 |
|
| 46 |
Ioss::DatabaseIO *getDatabaseOnReadFromFileName(const std::string &fileName, |
| 47 |
const std::string &iossDatabaseType, |
| 48 |
Ioss::PropertyManager dbProps = {}); |
| 49 |
|
| 50 |
Ioss::DatabaseIO *getCatalystDatabaseFromConduitFiles(const std::string &dirName, |
| 51 |
Ioss::PropertyManager dbProps = {}); |
| 52 |
|
| 53 |
void checkZeroCopyFields(Iocatalyst::BlockMeshSet::IOSSparams &iop); |
| 54 |
|
| 55 |
template <typename EntityContainer> |
| 56 |
void checkEntityContainerZeroCopyFields(const EntityContainer &ge) |
| 57 |
{ |
| 58 |
for (auto g : ge) { |
| 59 |
auto nameList = g->field_describe(); |
| 60 |
for (auto name : nameList) { |
| 61 |
auto field = g->get_fieldref(name); |
| 62 |
if (field.zero_copy_enabled()) { |
| 63 |
std::vector<std::byte> dcBuffer(field.get_size()); |
| 64 |
g->get_field_data(name, Data(dcBuffer), dcBuffer.size()); |
| 65 |
void *data; |
| 66 |
size_t dataSize; |
| 67 |
g->get_field_data(name, &data, &dataSize); |
| 68 |
ASSERT_GT(dataSize, 0) << "DataSize is not greater than 0 for field " << name |
| 69 |
<< std::endl; |
| 70 |
std::byte *b = static_cast<std::byte *>(data); |
| 71 |
std::vector<std::byte> zcBuffer(b, b + field.get_size()); |
| 72 |
EXPECT_EQ(dcBuffer, zcBuffer); |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
void setBlockMeshSize(unsigned int i, unsigned int j, unsigned int k); |
| 79 |
void setOrigin(unsigned int i, unsigned int j, unsigned int k); |
| 80 |
void addBlockMesh(Iocatalyst::BlockMesh &blockMesh); |
| 81 |
|
| 82 |
const std::string CGNS_DATABASE_TYPE = "cgns"; |
| 83 |
const std::string CGNS_FILE_EXTENSION = ".cgns"; |
| 84 |
const std::string EXODUS_DATABASE_TYPE = "exodus"; |
| 85 |
const std::string EXODUS_FILE_EXTENSION = ".ex2"; |
| 86 |
const std::string CATALYST_TEST_FILE_PREFIX = "catalyst_"; |
| 87 |
const std::string CATALYST_TEST_FILE_NP = "_np_"; |
| 88 |
inline static const std::string CATALYST_DATABASE_TYPE = "catalyst"; |
| 89 |
inline static const std::string CATALYST_DUMMY_DATABASE = "dummy.db"; |
| 90 |
}; |