Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into zoltan-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Bettencourt committed Jul 19, 2021
2 parents ba2774f + 88a636e commit 6cee551
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/PyTrilinos/util/copyWithCMakeSubstitutions.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def main():
exit(-2)

# Obtain the dictionary of CMake cache variables
makefileVariables = MakefileVariables.processMakefile("Makefile")
cmakeBinaryDir = makefileVariables["CMAKE_BINARY_DIR"]
cmakeBinaryDir = "@CMAKE_BINARY_DIR@"
# Remove quotes from cmakeBinaryDir.
cmakeBinaryDir = cmakeBinaryDir.replace("\"", "").replace("'", "")
cmakeCacheFile = os.path.join(cmakeBinaryDir, "CMakeCache.txt")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ void STK_Interface::addMeshCoordFields(const std::string & blockId,
}
}

void STK_Interface::addInformationRecords(const std::vector<std::string> & info_records)
{
informationRecords_.insert(info_records.begin(), info_records.end());
}

void STK_Interface::initialize(stk::ParallelMachine parallelMach,bool setupIO,
const bool buildRefinementSupport)
{
Expand Down Expand Up @@ -711,6 +716,10 @@ setupExodusFile(const std::string& filename,
meshData_->add_field(meshIndex_, *fields[i]);
}
}

// convert the set to a vector
std::vector<std::string> deduped_info_records(informationRecords_.begin(),informationRecords_.end());
meshData_->add_info_records(meshIndex_, deduped_info_records);
#else
TEUCHOS_ASSERT(false)
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ class STK_Interface {
const std::vector<std::string> & coordField,
const std::string & dispPrefix);

/** Add a vector of strings to the Information Records block. Each string
* will be it's own record. The info records will be deduped before they
* are added to IOSS.
*/
void addInformationRecords(const std::vector<std::string> & info_records);

//////////////////////////////////////////

/** Initialize the mesh with the current dimension This also calls
Expand Down Expand Up @@ -1317,6 +1323,9 @@ class STK_Interface {
std::map<std::pair<std::string,std::string>,SolutionFieldType*> fieldNameToEdgeField_;
std::map<std::pair<std::string,std::string>,SolutionFieldType*> fieldNameToFaceField_;

// use a set to maintain a list of unique information records
std::set<std::string> informationRecords_;

unsigned dimension_;

bool initialized_;
Expand Down
85 changes: 85 additions & 0 deletions packages/panzer/adapters-stk/test/stk_interface_test/tSTK_IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,18 @@
#include "Panzer_STK_Version.hpp"
#include "PanzerAdaptersSTK_config.hpp"
#include "Panzer_STK_Interface.hpp"
#include "Panzer_STK_CubeHexMeshFactory.hpp"
#include "Panzer_STK_SquareQuadMeshFactory.hpp"
#include "Panzer_STK_ExodusReaderFactory.hpp"
#include "Kokkos_ViewFactory.hpp"

#include "Kokkos_DynRankView.hpp"

#include "Ioss_DatabaseIO.h"
#include "Ioss_IOFactory.h"
#include "Ioss_Region.h"


#ifdef PANZER_HAVE_IOSS

using Teuchos::RCP;
Expand Down Expand Up @@ -237,6 +243,85 @@ TEUCHOS_UNIT_TEST(tSTK_IO, transient_fields)
TEST_EQUALITY(mesh_read->getCurrentStateTime(),0.0); // writeToExodus has not yet been called
}

TEUCHOS_UNIT_TEST(tSTK_IO, addInformationRecords)
{
using Teuchos::RCP;

std::vector<std::string> info_records_1 = {
"DG::eblock-0_0_0::basis::Basis_HGRAD_HEX_C1_FEM",
"DG::eblock-0_0_0::field::Ex"
};
std::vector<std::string> info_records_2 = {
"DG::eblock-0_0_0::basis::Basis_HGRAD_HEX_C1_FEM",
"DG::eblock-0_0_0::field::Ey"
};
std::vector<std::string> info_records_3 = {
"DG::eblock-0_0_0::basis::Basis_HGRAD_HEX_C1_FEM",
"DG::eblock-0_0_0::field::Ez"
};
std::vector<std::string> info_records_4 = {
"DG::eblock-1_1_1::basis::Basis_HGRAD_HEX_C1_FEM",
"DG::eblock-1_1_1::field::Ex"
};
std::vector<std::string> info_records_5 = {
"DG::eblock-1_1_1::basis::Basis_HGRAD_HEX_C1_FEM",
"DG::eblock-1_1_1::field::Ey"
};
std::vector<std::string> info_records_6 = {
"DG::eblock-1_1_1::basis::Basis_HGRAD_HEX_C1_FEM",
"DG::eblock-1_1_1::field::Ez"
};

RCP<Teuchos::ParameterList> pl = rcp(new Teuchos::ParameterList);
pl->set("X Blocks",1);
pl->set("Y Blocks",1);
pl->set("Z Blocks",1);
pl->set("X Elements",2);
pl->set("Y Elements",4);
pl->set("Z Elements",5);

CubeHexMeshFactory factory;
factory.setParameterList(pl);
RCP<STK_Interface> mesh = factory.buildUncommitedMesh(MPI_COMM_WORLD);
mesh->addInformationRecords(info_records_1);
mesh->addInformationRecords(info_records_2);
mesh->addInformationRecords(info_records_3);
mesh->addInformationRecords(info_records_4);
mesh->addInformationRecords(info_records_5);
mesh->addInformationRecords(info_records_6);
factory.completeMeshConstruction(*mesh,MPI_COMM_WORLD);

TEST_ASSERT(mesh!=Teuchos::null);

mesh->writeToExodus("info_records.exo");

{
Ioss::DatabaseIO *db_io = Ioss::IOFactory::create("exodus",
"info_records.exo",
Ioss::READ_MODEL);
TEST_ASSERT(db_io);

Ioss::Region region(db_io);
TEST_ASSERT(db_io->ok() == true);

auto info_records_from_ioss = db_io->get_information_records();

// put all the info records in one vector to make them easier to iterate over
std::vector<std::string> all_expected_records;
all_expected_records.insert(all_expected_records.end(), info_records_1.begin(), info_records_1.end());
all_expected_records.insert(all_expected_records.end(), info_records_2.begin(), info_records_2.end());
all_expected_records.insert(all_expected_records.end(), info_records_3.begin(), info_records_3.end());
all_expected_records.insert(all_expected_records.end(), info_records_4.begin(), info_records_4.end());
all_expected_records.insert(all_expected_records.end(), info_records_5.begin(), info_records_5.end());
all_expected_records.insert(all_expected_records.end(), info_records_6.begin(), info_records_6.end());
// make sure all the input records appear in the results returned from IOSS
for ( auto r : all_expected_records ) {
auto iter = std::find(info_records_from_ioss.begin(), info_records_from_ioss.end(), r);
TEST_ASSERT(iter != info_records_from_ioss.end());
}
}
}

RCP<STK_Interface> buildMesh(int xElements,int yElements)
{
RCP<Teuchos::ParameterList> pl = rcp(new Teuchos::ParameterList);
Expand Down

0 comments on commit 6cee551

Please sign in to comment.