Skip to content

Commit

Permalink
Merge pull request #580 from LLNL/feature/essman/file_info
Browse files Browse the repository at this point in the history
Prohibit saving of DataColl info to cwd, report output dirs to user
jamiebramwell authored Oct 27, 2021
2 parents 7fe0c7f + eabcdbe commit 10c22dd
Showing 16 changed files with 36 additions and 27 deletions.
2 changes: 1 addition & 1 deletion examples/simple_conduction/with_input_file.cpp
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ int main(int argc, char* argv[])

// _inlet_init_start
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "with_input_file_example");
auto inlet = serac::input::initialize(datastore, input_file);
// _inlet_init_end

2 changes: 1 addition & 1 deletion examples/simple_conduction/without_input_file.cpp
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ int main(int argc, char* argv[])
{
/*auto [num_procs, rank] = */serac::initialize(argc, argv);
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "without_input_file_example");
// _main_init_end
// _create_mesh_start
auto mesh = serac::mesh::refineAndDistribute(serac::buildRectangleMesh(10, 10));
2 changes: 1 addition & 1 deletion src/serac/coefficients/tests/serac_component_bc.cpp
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ TEST(solid_solver, qs_component_solve)

// Initialize Inlet and read input file
auto inlet = serac::input::initialize(datastore, input_file_path);
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "with_input_file_example");

test_utils::defineTestSchema<Solid>(inlet);

4 changes: 2 additions & 2 deletions src/serac/infrastructure/output.cpp
Original file line number Diff line number Diff line change
@@ -54,8 +54,6 @@ void outputSummary(const axom::sidre::DataStore& datastore, const std::string& d
void outputFields(const axom::sidre::DataStore& datastore, const std::string& data_collection_name,
const std::string& output_directory, double time, const FileFormat file_format)
{
SLIC_INFO_ROOT(fmt::format("Outputting field data at time: {}", time));

// Configure Ascent to extract data
ascent::Ascent ascent;
conduit::Node ascent_opts;
@@ -75,6 +73,8 @@ void outputFields(const axom::sidre::DataStore& datastore, const std::string& da
extracts["e1/params/path"] = path;
extracts["e1/params/protocol"] = file_format_string;

SLIC_INFO_ROOT(fmt::format("Outputting field data at time: {} to path: {}", time, path));

// Get domain Sidre group
const axom::sidre::Group* sidre_root = datastore.getRoot();
SLIC_ERROR_ROOT_IF(
2 changes: 1 addition & 1 deletion src/serac/infrastructure/tests/serac_error_handling.cpp
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ TEST(serac_error_handling, invalid_output_type)
{
// Create DataStore
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "invalid_output_type");
serac::StateManager::setMesh(mesh::refineAndDistribute(buildDiskMesh(1000)));
ThermalConduction physics(1, ThermalConduction::defaultQuasistaticOptions());
// Try a definitely wrong number to ensure that an invalid output type is detected
2 changes: 1 addition & 1 deletion src/serac/physics/tests/serac_dtor.cpp
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ TEST(serac_dtor, test1)

// Create DataStore
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "serac_dtor");

auto pmesh = mesh::refineAndDistribute(buildMeshFromFile(mesh_file), 1, 0);
serac::StateManager::setMesh(std::move(pmesh));
6 changes: 3 additions & 3 deletions src/serac/physics/tests/serac_newmark_test.cpp
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ TEST_F(NewmarkBetaTest, SimpleLua)
// Create DataStore
axom::sidre::DataStore datastore;
// Intialize MFEMSidreDataCollection
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "newmark_beta_simple");

// Initialize Inlet and read input file
std::string input_file = std::string(SERAC_REPO_DIR) + "/data/input_files/tests/solid/dyn_newmark_solve.lua";
@@ -188,7 +188,7 @@ TEST_F(NewmarkBetaTest, EquilbriumLua)
// Create DataStore
axom::sidre::DataStore datastore;
// Intialize MFEMSidreDataCollection
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "newmark_beta_equilibrium");

// Initialize Inlet and read input file
std::string input_file = std::string(SERAC_REPO_DIR) + "/data/input_files/tests/solid/dyn_newmark_solve_bending.lua";
@@ -230,7 +230,7 @@ TEST_F(NewmarkBetaTest, FirstOrderEquilbriumLua)
// Create DataStore
axom::sidre::DataStore datastore;
// Intialize MFEMSidreDataCollection
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "newmark_beta_first_order_equilibrium");

// Initialize Inlet and read input file
std::string input_file =
2 changes: 1 addition & 1 deletion src/serac/physics/tests/serac_solid.cpp
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ TEST(solid_solver, qs_custom_solve)

// Initialize Inlet and read input file
auto inlet = serac::input::initialize(datastore, input_file_path);
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "solid_qs_custom_solve");

test_utils::defineTestSchema<Solid>(inlet);

2 changes: 1 addition & 1 deletion src/serac/physics/tests/serac_solid_adjoint.cpp
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ TEST(solid_solver, adjoint)
MPI_Barrier(MPI_COMM_WORLD);

axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "solid_adjoint");

// Open the mesh
std::string mesh_file = std::string(SERAC_REPO_DIR) + "/data/meshes/beam-hex.mesh";
2 changes: 1 addition & 1 deletion src/serac/physics/tests/serac_solid_reuse_mesh.cpp
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ TEST(solid_solver, reuse_mesh)
MPI_Barrier(MPI_COMM_WORLD);

axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "solid_reuse_mesh");

// Open the mesh
std::string mesh_file = std::string(SERAC_REPO_DIR) + "/data/meshes/beam-hex.mesh";
2 changes: 1 addition & 1 deletion src/serac/physics/tests/serac_thermal_expansion.cpp
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ TEST(solid_solver, thermal_expansion)

// Create DataStore
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "solid_thermal_expansion");

// Open the mesh
std::string mesh_file = std::string(SERAC_REPO_DIR) + "/data/meshes/onehex.mesh";
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ TEST(dynamic_solver, dyn_solve)

// Create DataStore
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "dynamic_solve");

// Open the mesh
std::string mesh_file = std::string(SERAC_REPO_DIR) + "/data/meshes/beam-hex.mesh";
Original file line number Diff line number Diff line change
@@ -206,7 +206,7 @@ TYPED_TEST(QuadratureDataStateManagerTest, basic_integrals_state_manager)
// then save it
{
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "qdata_restart");
// We need to use "this->" explicitly because we are in a derived class template
serac::StateManager::setMesh(std::move(this->default_mesh));
// Can't use auto& here because we're in a template context
@@ -235,7 +235,7 @@ TYPED_TEST(QuadratureDataStateManagerTest, basic_integrals_state_manager)
// Then reload the state to make sure it was synced correctly, and update it again before saving
{
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore, "serac", "", cycle);
serac::StateManager::initialize(datastore, "serac", "qdata_restart", cycle);
// Since the original mesh is dead, use the mesh recovered from the save file to build a new Functional
this->resetWithNewMesh(serac::StateManager::mesh());
serac::QuadratureData<typename TestFixture::value_type>& qdata =
@@ -269,7 +269,7 @@ TYPED_TEST(QuadratureDataStateManagerTest, basic_integrals_state_manager)
// is read in from a restart
{
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore, "serac", "", cycle + 1);
serac::StateManager::initialize(datastore, "serac", "qdata_restart", cycle + 1);
// Since the original mesh is dead, use the mesh recovered from the save file to build a new Functional
this->resetWithNewMesh(serac::StateManager::mesh());
serac::QuadratureData<typename TestFixture::value_type>& qdata =
@@ -299,7 +299,7 @@ TYPED_TEST(QuadratureDataStateManagerTest, basic_integrals_state_manager)
// included the distance of the quadrature point from the origin (which is unique)
{
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore, "serac", "", cycle + 2);
serac::StateManager::initialize(datastore, "serac", "qdata_restart", cycle + 2);
serac::QuadratureData<typename TestFixture::value_type>& qdata =
serac::StateManager::newQuadratureData<typename TestFixture::value_type>("test_data", this->p);
// Make sure the changes from the distance-specified increment were propagated through and in the correct order
Original file line number Diff line number Diff line change
@@ -298,7 +298,7 @@ TYPED_TEST(QuadratureDataGPUStateManagerTest, basic_integrals_state_manager)
// then save it
{
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore);
serac::StateManager::initialize(datastore, "serac", "qdata_gpu_restart");
// We need to use "this->" explicitly because we are in a derived class template
serac::StateManager::setMesh(std::move(this->default_mesh));
// Can't use auto& here because we're in a template context
@@ -322,7 +322,7 @@ TYPED_TEST(QuadratureDataGPUStateManagerTest, basic_integrals_state_manager)
// Then reload the state to make sure it was synced correctly, and update it again before saving
{
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore, "serac", "", cycle);
serac::StateManager::initialize(datastore, "serac", "qdata_gpu_restart", cycle);
// Since the original mesh is dead, use the mesh recovered from the save file to build a new Functional
this->resetWithNewMesh(serac::StateManager::mesh());
serac::QuadratureData<typename TestFixture::value_type>& qdata =
@@ -351,7 +351,7 @@ TYPED_TEST(QuadratureDataGPUStateManagerTest, basic_integrals_state_manager)
// is read in from a restart
{
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore, "serac", "", cycle + 1);
serac::StateManager::initialize(datastore, "serac", "qdata_gpu_restart", cycle + 1);
// Since the original mesh is dead, use the mesh recovered from the save file to build a new Functional
this->resetWithNewMesh(serac::StateManager::mesh());
serac::QuadratureData<typename TestFixture::value_type>& qdata =
@@ -378,7 +378,7 @@ TYPED_TEST(QuadratureDataGPUStateManagerTest, basic_integrals_state_manager)
// included the distance of the quadrature point from the origin (which is unique)
{
axom::sidre::DataStore datastore;
serac::StateManager::initialize(datastore, "serac", "", cycle + 2);
serac::StateManager::initialize(datastore, "serac", "qdata_gpu_restart", cycle + 2);
serac::QuadratureData<typename TestFixture::value_type>& qdata =
serac::StateManager::newQuadratureData<typename TestFixture::value_type>("test_data", this->p);
// Make sure the changes from the distance-specified increment were propagated through and in the correct order
11 changes: 10 additions & 1 deletion src/serac/physics/utilities/state_manager.cpp
Original file line number Diff line number Diff line change
@@ -45,7 +45,11 @@ void StateManager::initialize(axom::sidre::DataStore& ds, const std::string& col
datacoll_.emplace(collection_name_, bp_index_grp, domain_grp, owns_mesh_data);
datacoll_->SetComm(MPI_COMM_WORLD);

if (!output_directory.empty()) {
if (output_directory.empty()) {
SLIC_ERROR_ROOT(
"DataCollection output directory cannot be empty - this will result in problems if executables are run in "
"parallel");
} else {
datacoll_->SetPrefixPath(output_directory);
}

@@ -116,6 +120,11 @@ FiniteElementDual StateManager::newDual(FiniteElementVector::Options&& options)
void StateManager::save(const double t, const int cycle)
{
SLIC_ERROR_ROOT_IF(!datacoll_, "Serac's datacollection was not initialized - call StateManager::initialize first");

std::string file_path =
axom::utilities::filesystem::joinPath(datacoll_->GetPrefixPath(), datacoll_->GetCollectionName());
SLIC_INFO_ROOT(fmt::format("Saving data collection at time: {} to path: {}", t, file_path));

for (const auto& data : syncable_data_) {
data->sync();
}
6 changes: 3 additions & 3 deletions src/serac/physics/utilities/state_manager.hpp
Original file line number Diff line number Diff line change
@@ -34,11 +34,11 @@ class StateManager {
* @brief Initializes the StateManager with a sidre DataStore (into which state will be written/read)
* @param[in] ds The DataStore to use
* @param[in] collection_name_prefix The prefix for the name of the Sidre DataCollection to be created
* @param[in] output_directory The directory to output files to
* @param[in] output_directory The directory to output files to - cannot be empty
* @param[in] cycle_to_load The cycle to load - required for restarts
*/
static void initialize(axom::sidre::DataStore& ds, const std::string& collection_name_prefix = "serac",
const std::string output_directory = "", const std::optional<int> cycle_to_load = {});
static void initialize(axom::sidre::DataStore& ds, const std::string& collection_name_prefix,
const std::string output_directory, const std::optional<int> cycle_to_load = {});

/**
* @brief Factory method for creating a new FEState object, signature is identical to FEState constructor

0 comments on commit 10c22dd

Please sign in to comment.