Skip to content

Commit

Permalink
Add Pixie3D flavor of ADIOS2 (#19272)
Browse files Browse the repository at this point in the history
* Remove print statements and add expressions for Lat/Lon/Depth for SPECFEM3D data.

* Add Pixie3D ADIOS2 reader.

* Revert changes to avtIsovolumeFilter.

* Compile fixes for avtPixie3DFileFormat.

* Add spaces in debug5 statements (address @brugger1's comments in original PR)

* Change cout statements to debug5.

* whitespace cleanup

* Update Adios2.xml with new file.

* Remove unnecessary comments related to unused functions.

* Update release notes.

* Remove 'std::' from in front of 'debug5'.

---------

Co-authored-by: dpugmire <dpugmire@gmail.com>
  • Loading branch information
biagas and dpugmire committed Jan 31, 2024
1 parent 910ffa8 commit a14400c
Show file tree
Hide file tree
Showing 11 changed files with 933 additions and 99 deletions.
1 change: 1 addition & 0 deletions src/databases/ADIOS2/ADIOS2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
avtADIOS2FileFormat.C
avtMEUMMAPSFileFormat.C
avtGTCFileFormat.C
avtPixie3DFileFormat.C
avtADIOS2BaseFileFormat.C
avtADIOS2SSTFileFormat.C
avtLAMMPSFileFormat.C
Expand Down
2 changes: 2 additions & 0 deletions src/databases/ADIOS2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ${COMMON_SOURCES}
avtADIOS2FileFormat.C
avtMEUMMAPSFileFormat.C
avtGTCFileFormat.C
avtPixie3DFileFormat.C
avtADIOS2BaseFileFormat.C
avtADIOS2SSTFileFormat.C
avtLAMMPSFileFormat.C
Expand All @@ -31,6 +32,7 @@ ${COMMON_SOURCES}
avtADIOS2FileFormat.C
avtMEUMMAPSFileFormat.C
avtGTCFileFormat.C
avtPixie3DFileFormat.C
avtADIOS2BaseFileFormat.C
avtADIOS2SSTFileFormat.C
avtLAMMPSFileFormat.C
Expand Down
59 changes: 30 additions & 29 deletions src/databases/ADIOS2/avtADIOS2BaseFileFormat.C
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// details. No copyright assignment is required to contribute to VisIt.

// ************************************************************************* //
// avtADIOS2BaseFileFormat.C //
// avtADIOS2BaseFileFormat.C //
// ************************************************************************* //

#include <avtMTSDFileFormatInterface.h>
Expand All @@ -25,6 +25,7 @@

#include <InvalidVariableException.h>
#include <VisItStreamUtil.h>
#include <DebugStream.h>

using namespace std;

Expand Down Expand Up @@ -86,7 +87,7 @@ avtADIOS2BaseFileFormat::CreateInterfaceADIOS2(
int nList,
int nBlock,
std::shared_ptr<adios2::ADIOS> adios,
adios2::Engine &reader,
adios2::Engine &reader,
adios2::IO &io,
std::map<std::string, adios2::Params> &variables,
std::map<std::string, adios2::Params> &attributes
Expand All @@ -99,11 +100,11 @@ avtADIOS2BaseFileFormat::CreateInterfaceADIOS2(
ffl[i] = new avtMTSDFileFormat*[nBlock];
for (int j = 0; j < nBlock; j++)
{
cout << "----------- ADIOS Base create interface for "
<< list[i*nBlock +j]
debug5 << "----------- ADIOS Base create interface for "
<< list[i*nBlock +j]
<< " -----------------" << endl;

if (!i && !j)
if (!i && !j)
{
ffl[i][j] = new avtADIOS2BaseFileFormat(adios, reader, io, variables, attributes, list[i*nBlock +j]);
}
Expand All @@ -113,7 +114,7 @@ avtADIOS2BaseFileFormat::CreateInterfaceADIOS2(
}
}
}
cout << "----------- ADIOS Base return MTSD interface " << endl;
debug5 << "----------- ADIOS Base return MTSD interface " << endl;
return new avtMTSDFileFormatInterface(ffl, nTimestepGroups, nBlock);
}

Expand All @@ -123,10 +124,10 @@ avtADIOS2BaseFileFormat::CreateInterfaceADIOS2(
//
// Programmer: pugmire -- generated by xml2avt
// Creation: Thu Apr 12 08:39:47 PDT 2018
//
//
// Modifications:
// Justin Privitera, Thu Jan 18 09:56:51 PST 2024
// Removed adios2::DebugON since it is not present in newer versions of
// Removed adios2::DebugON since it is not present in newer versions of
// adios2.
//
// ****************************************************************************
Expand All @@ -149,7 +150,7 @@ avtADIOS2BaseFileFormat::avtADIOS2BaseFileFormat(const char *filename)
{
numTimeSteps = 100000;
}
else
else
{
map<string, adios2::Params> vars = io.AvailableVariables();
for (auto &v : vars)
Expand All @@ -166,9 +167,9 @@ avtADIOS2BaseFileFormat::avtADIOS2BaseFileFormat(const char *filename)

avtADIOS2BaseFileFormat::avtADIOS2BaseFileFormat(std::shared_ptr<adios2::ADIOS> adios,
adios2::Engine &reader,
adios2::IO &io,
adios2::IO &io,
std::map<std::string, adios2::Params> &variables,
std::map<std::string, adios2::Params> &attributes,
std::map<std::string, adios2::Params> &attributes,
const char *filename)
: adios(adios),
numTimeSteps(1),
Expand All @@ -185,7 +186,7 @@ avtADIOS2BaseFileFormat::avtADIOS2BaseFileFormat(std::shared_ptr<adios2::ADIOS>
{
numTimeSteps = 100000;
}
else
else
{
for (auto &v : variables)
{
Expand All @@ -197,21 +198,21 @@ avtADIOS2BaseFileFormat::avtADIOS2BaseFileFormat(std::shared_ptr<adios2::ADIOS>
}
}
}
cout << "----------- ADIOS Base reader for "
<< filename << " with " << numTimeSteps
debug5 << "----------- ADIOS Base reader for "
<< filename << " with " << numTimeSteps
<< "steps -----------------" << endl;
}

avtADIOS2BaseFileFormat::~avtADIOS2BaseFileFormat()
{
#if MDSERVER
cout << "-----------\nADIOS destructor called in MDSERVER \n-----------------\n" << endl;
debug5 << "-----------\nADIOS destructor called in MDSERVER \n-----------------\n" << endl;
#else
cout << "-----------\nADIOS destructor called in ENGINE \n-----------------\n" << endl;
debug5 << "-----------\nADIOS destructor called in ENGINE \n-----------------\n" << endl;
#endif
if (!isClosed)
{
cout << "-----------\nADIOS reader closes down stream \n-----------------\n" << endl;
debug5 << "-----------\nADIOS reader closes down stream \n-----------------\n" << endl;
reader.Close();
}
isClosed = true;
Expand Down Expand Up @@ -278,17 +279,17 @@ avtADIOS2BaseFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md, int t
if (status != adios2::StepStatus::OK)
return;
#if MDSERVER
cout<<" MDSERVER received streaming step = "<<reader.CurrentStep()<<endl;
debug5<<" MDSERVER received streaming step = "<<reader.CurrentStep()<<endl;
#else
cout<<" Server populates metadata from streaming step = "<<reader.CurrentStep()<<endl;
debug5<<" Server populates metadata from streaming step = "<<reader.CurrentStep()<<endl;
#endif
*/
}

meshInfo.clear();
variables = io.AvailableVariables();

cout<<" Server populates metadata with "<<variables.size() <<" variables."<<endl;
debug5<<" Server populates metadata with "<<variables.size() <<" variables."<<endl;

#if MDSERVER
if (stagingMode)
Expand Down Expand Up @@ -337,7 +338,7 @@ avtADIOS2BaseFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md, int t
#if MDSERVER
if (!isClosed)
{
cout << "-----------\nADIOS reader closes down stream in MDSERVER \n-----------------\n" << endl;
debug5 << "-----------\nADIOS reader closes down stream in MDSERVER \n-----------------\n" << endl;
reader.Close();
}
isClosed = true;
Expand Down Expand Up @@ -384,7 +385,7 @@ avtADIOS2BaseFileFormat::GetMesh(int timestate, const char *meshname)
if (shape.size() == 2)
shape.push_back(1);

//cout<<"********** SWAP DIMS"<<endl;
//debug5<<"********** SWAP DIMS"<<endl;
std::swap(shape[0], shape[1]);

int dims[3] = {shape[0], shape[1], shape[2]};
Expand Down Expand Up @@ -433,7 +434,7 @@ vtkDataArray *
avtADIOS2BaseFileFormat::GetVar(int timestate, const char *varname)
{
static int prev_timestate = 0;
cout<<"GetVar: "<<varname<<" ts= "<<timestate<<endl;
debug5<<"GetVar: "<<varname<<" ts= "<<timestate<<endl;

if (variables.find(varname) == variables.end())
return NULL;
Expand All @@ -445,14 +446,14 @@ avtADIOS2BaseFileFormat::GetVar(int timestate, const char *varname)
{
if (timestate != prev_timestate)
{
cout<<" release step = "<<reader.CurrentStep()<<endl;
debug5<<" release step = "<<reader.CurrentStep()<<endl;
reader.EndStep(); // release previous step
prev_timestate = timestate;
adios2::StepStatus status = adios2::StepStatus::NotReady;
while (status == adios2::StepStatus::NotReady)
while (status == adios2::StepStatus::NotReady)
{
status = reader.BeginStep(adios2::StepMode::Read, 10.0f);
if (status == adios2::StepStatus::EndOfStream ||
if (status == adios2::StepStatus::EndOfStream ||
status == adios2::StepStatus::OtherError)
{
reader.Close();
Expand All @@ -461,17 +462,17 @@ avtADIOS2BaseFileFormat::GetVar(int timestate, const char *varname)
}
else if (status == adios2::StepStatus::NotReady)
{
cout<<" still waiting for next step = "
debug5<<" still waiting for next step = "
<<reader.CurrentStep()<<endl;
}
}
cout<<" received streaming step = "<<reader.CurrentStep()<<endl;
debug5<<" received streaming step = "<<reader.CurrentStep()<<endl;
}
}


adios2::Variable<double> v = io.InquireVariable<double>(varname);
//cout<<"DIMS= "<<v.Shape()<<endl;
//debug5<<"DIMS= "<<v.Shape()<<endl;
if (!stagingMode)
v.SetStepSelection({timestate, 1});

Expand Down
41 changes: 24 additions & 17 deletions src/databases/ADIOS2/avtADIOS2FileFormat.C
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// details. No copyright assignment is required to contribute to VisIt.

// ************************************************************************* //
// avtADIOSFileFormat.C //
// avtADIOS2FileFormat.C //
// ************************************************************************* //

#include <avtFileFormatInterface.h>
Expand All @@ -13,6 +13,7 @@

#include <avtADIOS2BaseFileFormat.h>
#include <avtGTCFileFormat.h>
#include <avtPixie3DFileFormat.h>
#include <avtLAMMPSFileFormat.h>
#include <avtSpecFEMFileFormat.h>
#include <avtMEUMMAPSFileFormat.h>
Expand Down Expand Up @@ -47,9 +48,9 @@
//
// Dave Pugmire, Thu Oct 30 11:59:40 EDT 2014
// Added a LAMMPS reader. Modified the flavor flag to an enum for clarity.
//
//
// Justin Privitera, Thu Jan 18 09:56:51 PST 2024
// Removed adios2::DebugON since it is not present in newer versions of
// Removed adios2::DebugON since it is not present in newer versions of
// adios2.
// Added special logic for BP5 files.
//
Expand All @@ -59,15 +60,15 @@ avtFileFormatInterface *
ADIOS2_CreateFileFormatInterface(const char * const *list, int nList, int nBlock)
{
avtFileFormatInterface *ffi = NULL;
enum Flavor {GTC, BASIC, MEUMMAPS, LAMMPS, SPECFEM, FAIL};
enum Flavor {GTC, BASIC, MEUMMAPS, LAMMPS, SPECFEM, PIXIE3D, FAIL};
bool isSST = (std::string(list[0]).find(".sst") != std::string::npos);
bool isHDF5 = (std::string(list[0]).find(".h5") != std::string::npos);
bool isWDM = (std::string(list[0]).find(".ssc") != std::string::npos);
bool stagingMode = isSST || isWDM;

cout<<__FILE__<<" "<<__LINE__<<" isSST "<<isSST<<endl;
cout<<__FILE__<<" "<<__LINE__<<" isWDM "<<isWDM<<endl;
cout<<__FILE__<<" "<<__LINE__<<" isHDF5 "<<isHDF5<<endl;
debug5 << __FILE__ << " " << __LINE__ << " isSST " << isSST << endl;
debug5 << __FILE__ << " " << __LINE__ << " isWDM " << isWDM << endl;
debug5 << __FILE__ << " " << __LINE__ << " isHDF5 " << isHDF5 << endl;
Flavor flavor = FAIL;
if (list != NULL || nList > 0)
{
Expand All @@ -85,22 +86,22 @@ ADIOS2_CreateFileFormatInterface(const char * const *list, int nList, int nBlock
bool stagingMode = ADIOS2Helper_IsStagingEngine(engineName);

io.SetEngine(engineName);
//cout<<__FILE__<<" "<<__LINE__<<" Connect to stream "<<fileName<<" ..."
// <<" engine "<<engineName<<" ..."<<endl;
//debug5 << __FILE__ << " " << __LINE__ << " Connect to stream " << fileName << " ..."
// << " engine " << engineName << " ..." << endl;
if (engineName == "BP5")
reader = io.Open(fileName, adios2::Mode::ReadRandomAccess);
else
reader = io.Open(fileName, adios2::Mode::Read);

if (stagingMode)
{
cout<<__FILE__<<" "<<__LINE__<<" Get first step "<<endl;
debug5 << __FILE__ << " " << __LINE__ << " Get first step " << endl;
adios2::StepStatus status =
reader.BeginStep(adios2::StepMode::Read, -1.0f);
if (status == adios2::StepStatus::OK)
{
std::cout<<" Identifier received streaming step = "
<<reader.CurrentStep()<<endl;
debug5 << " Identifier received streaming step = "
<< reader.CurrentStep() << endl;
variables = io.AvailableVariables();
attributes = io.AvailableAttributes();

Expand All @@ -113,6 +114,8 @@ ADIOS2_CreateFileFormatInterface(const char * const *list, int nList, int nBlock
flavor = LAMMPS;
else if (avtMEUMMAPSFileFormat::IdentifyADIOS2(variables,attributes))
flavor = MEUMMAPS;
else if (avtPixie3DFileFormat::IdentifyADIOS2(variables,attributes))
flavor = PIXIE3D;

// generic with staging engines
else
Expand All @@ -126,9 +129,9 @@ ADIOS2_CreateFileFormatInterface(const char * const *list, int nList, int nBlock
variables = io.AvailableVariables();
attributes = io.AvailableAttributes();
#if MDSERVER
std::cout<<" MDSERVER Identifier has " << variables.size() << " variables"<<endl;
debug5 << " MDSERVER Identifier has " << variables.size() << " variables" << endl;
#else
std::cout<<" Identifier has " << variables.size() << " variables"<<endl;
debug5 << " Identifier has " << variables.size() << " variables" << endl;
#endif
// add formats here that support reading from HDF5
if (avtGTCFileFormat::Identify(fileName.c_str()))
Expand All @@ -139,6 +142,8 @@ ADIOS2_CreateFileFormatInterface(const char * const *list, int nList, int nBlock
flavor = MEUMMAPS;
else if (avtSpecFEMFileFormat::Identify(fileName.c_str()))
flavor = SPECFEM;
else if (avtPixie3DFileFormat::Identify(fileName.c_str()))
flavor = PIXIE3D;

// generic with HDF5 file
else if (isHDF5)
Expand All @@ -157,9 +162,13 @@ ADIOS2_CreateFileFormatInterface(const char * const *list, int nList, int nBlock
}
ENDTRY

cout<<"FLAVOR= "<<flavor<<endl;
debug5 << "FLAVOR= " << flavor << endl;
switch(flavor)
{
case PIXIE3D:
ffi = avtPixie3DFileFormat::CreateInterfaceADIOS2(
list, nList, nBlock, adios, reader, io, variables, attributes);
break;
case GTC:
ffi = avtGTCFileFormat::CreateInterfaceADIOS2(
list, nList, nBlock, adios, reader, io, variables, attributes);
Expand All @@ -178,7 +187,6 @@ ADIOS2_CreateFileFormatInterface(const char * const *list, int nList, int nBlock
list, nList, nBlock);
break;
case BASIC:
cout<<"OPEN A BASIC READER"<<endl;
ffi = avtADIOS2BaseFileFormat::CreateInterfaceADIOS2(
list, nList, nBlock, adios, reader, io, variables, attributes);
break;
Expand All @@ -187,6 +195,5 @@ ADIOS2_CreateFileFormatInterface(const char * const *list, int nList, int nBlock
}
}

//cout<<"RETURN ADIOS READER"<<endl;
return ffi;
}

0 comments on commit a14400c

Please sign in to comment.