Skip to content

Commit

Permalink
Add support for GEOS data to vtk reader (#20141)
Browse files Browse the repository at this point in the history
* Update config-site for my system.

* Add support for GEOS flavor .pvd root files and .vtm timestate files.

Each .vtm file is considered as one mesh.
Blocks with 'Region' in the name that are Parent to 'Dataset' Blocks are considered groups.
Variables defined in the underlying .vtu files are tracked for which blocks they belong to, since they may not be defined in every group.
GetMesh and GetVar calls check the validity of the mesh/variable for a given block and  return nullptr when not considered valid.

* Fix bad logic, add a `return false` case.

* Set HasVarsDefinedOnSubMeshes for GEOS flavor.

* When checking if block is valid for mesh/var, use all registered variables.

* Change domains to blocks. fix ParticleRegion name.

* Add support for opening GEOS flavored single .vtm, or grouped .vtm files.

* Fix error creating subset plot of 'groups'

* Add tests and baselines for geos data.

* Update release notes.

* Flesh out FreeUpResources in GEOS reader.

* Fix per Review comment.

Co-authored-by: Mark C. Miller <[email protected]>

---------

Co-authored-by: Mark C. Miller <[email protected]>
  • Loading branch information
biagas and markcmiller86 authored Jan 9, 2025
1 parent 4da381a commit 9b3fbd1
Show file tree
Hide file tree
Showing 28 changed files with 2,119 additions and 523 deletions.
3 changes: 3 additions & 0 deletions data/geos_test_data.tar.xz
Git LFS file not shown
12 changes: 3 additions & 9 deletions src/config-site/WIN-5525018.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# a windows 11 system
set(CMAKE_CONFIGURATION_TYPES Release Debug)

include(config-site/windows.cmake)

# disable some warnings
# 4244 conversion double to float etc
Expand Down Expand Up @@ -44,15 +43,10 @@ if(USE_REDUCED_BUILD) # this is just a var I create when I need it
VISIT_OPTION_DEFAULT(VISIT_WINDOWS_APPLICATION OFF TYPE BOOL)

VISIT_OPTION_DEFAULT(VISIT_SELECTED_DATABASE_PLUGINS "VTK;Silo" TYPE STRING)
VISIT_OPTION_DEFAULT(VISIT_SELECTED_PLOT_PLUGINS "Pseudocolor;Curve" TYPE STRING)
VISIT_OPTION_DEFAULT(VISIT_SELECTED_PLOT_PLUGINS "Pseudocolor;Curve;Mesh;Subset" TYPE STRING)
VISIT_OPTION_DEFAULT(VISIT_SELECTED_OPERATOR_PLUGINS "Slice;Lineout" TYPE STRING)

endif()

if(USE_DEBUG_VTK) # this is a var I create when I need it
if(MSVC_TOOLSET_VERSION LESS "143")
VISIT_OPTION_DEFAULT(VISIT_VTK_DIR C:/A_VisIt/TPForDebugging/vtk-debug/8.1.0)
else()
VISIT_OPTION_DEFAULT(VISIT_VTK_DIR C:/A_VisIt/TPForDebugging/vtk-debug/9.2.6)
endif()
endif()
include(config-site/windows.cmake)

2 changes: 2 additions & 0 deletions src/databases/VTK/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ VTKPluginInfo.C
SET(LIBM_SOURCES
VTKMDServerPluginInfo.C
${COMMON_SOURCES}
avtGEOSFileReader.C
avtPVDFileReader.C
avtVTKFileFormat.C
avtVTKFileReader.C
Expand All @@ -27,6 +28,7 @@ VTMParser.C
SET(LIBE_SOURCES
VTKEnginePluginInfo.C
${COMMON_SOURCES}
avtGEOSFileReader.C
avtPVDFileReader.C
avtVTKFileFormat.C
avtVTKFileReader.C
Expand Down
118 changes: 118 additions & 0 deletions src/databases/VTK/VTK.code
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,134 @@ Definition:
// I changed the code so it switches the interface based on how many domains
// are present in the 1st file.
//
// Kathleen Biagas, Fri August 13, 2021
// Add MTMD for .pvd file types.
//
// Kathleen Biagas, Thu Dec 12, 2024
// Added tests to see if .pvd is GEOS flavor.
//
// ****************************************************************************

#include <FileFunctions.h>
#include <vtkNew.h>
#include <vtkXMLDataElement.h>
#include <vtkXMLDataParser.h>
using std::string;

bool
FindGEOSNestedElement(vtkXMLDataElement *el)
{
if (el->GetNumberOfNestedElements() == 0)
return false;

// check for Blocks with certain name attributes used by GEOS
if(el->FindNestedElementWithNameAndAttribute("Block", "name","CellElementRegion") ||
el->FindNestedElementWithNameAndAttribute("Block", "name","SurfaceElementRegion") ||
el->FindNestedElementWithNameAndAttribute("Block", "name","ParticleRegion") ||
el->FindNestedElementWithNameAndAttribute("Block", "name","WellElementRegion") )
{
return true;
}
for(int i = 0; i < el->GetNumberOfNestedElements(); ++i)
return FindGEOSNestedElement(el->GetNestedElement(i));

return false;
}


bool
CheckIfGEOSVTM(const string &vtmFile)
{
vtkNew<vtkXMLDataParser> vtmParser;
vtmParser->SetFileName(vtmFile.c_str());
if(!vtmParser->Parse())
return false;

vtkXMLDataElement *vtmRoot = vtmParser->GetRootElement();
return FindGEOSNestedElement(vtmRoot);
}


bool
CheckIfGEOSPVD(const string &rootFile)
{
vtkNew<vtkXMLDataParser> pvdParser;
pvdParser->SetFileName(rootFile.c_str());
if(pvdParser->Parse())
{
vtkXMLDataElement *root = pvdParser->GetRootElement();
if(root)
{
vtkXMLDataElement *datasetNode = root->LookupElementWithName("DataSet");
if(datasetNode)
{
string fileName = datasetNode->GetAttribute("file");
size_t pos1 = fileName.find_last_of('.');
string ext1 = fileName.substr(pos1 + 1);
if(ext1 == "vtm")
{
// extract dir from rootFile and prepend to fileName:
string dir = FileFunctions::Dirname(rootFile);
string file = dir + VISIT_SLASH_STRING + fileName;
return CheckIfGEOSVTM(file);
}
}
}
}
return false;
}


#include <avtSTSDFileFormatInterface.h>
#include <avtMTMDFileFormatInterface.h>

avtDatabase *
VTKCommonPluginInfo::SetupDatabase(const char *const *list,
int nList, int nBlock)
{
avtDatabase *db = NULL;

string fn(list[0]);
size_t pos = fn.find_last_of('.');
string ext = fn.substr(pos+1);
if (ext == "pvd")
{
dbType = DB_TYPE_MTMD;

// Only using 1 timestepgroup
avtMTMDFileFormat **ffl = new avtMTMDFileFormat*[1];
if(CheckIfGEOS(fn))
ffl[0] = new avtGEOSFileFormat(fn.c_str(), readOptions);
else
ffl[0] = new avtPVD_MTMDFileFormat(fn.c_str(), readOptions);
avtMTMDFileFormatInterface *inter = new avtMTMDFileFormatInterface(ffl, 1);
db = new avtGenericDatabase(inter);

return db;
}
else if (ext == "vtm")
{
if(CheckIfGEOSVTM(fn))
{
dbType = DB_TYPE_STMD;
avtSTMDFileFormat **ffl = new avtSTMDFileFormat*[nList];
avtGEOSFileReader *reader = new avtGEOSFileReader(list[0], readOptions);
for (int i = 0; i < nList; i++)
{
if(i == 0)
ffl[i] = new avtGEOS_STMDFileFormat(list[i], readOptions, reader);
else
ffl[i] = new avtGEOS_STMDFileFormat(list[i], readOptions);
}
avtSTMDFileFormatInterface *inter
= new avtSTMDFileFormatInterface(ffl, nList);
db = new avtGenericDatabase(inter);

return db;
}
}


// Figure out how many domains there are in the 1st file.
avtVTKFileReader *reader = new avtVTKFileReader(list[0], readOptions);
int nDomains = 1;
Expand Down
112 changes: 103 additions & 9 deletions src/databases/VTK/VTKCommonPluginInfo.C
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
// details. No copyright assignment is required to contribute to VisIt.

#include <VTKPluginInfo.h>

#include <avtVTKFileFormat.h>
#include <avtVTKOptions.h>

#include <avtSTSDFileFormatInterface.h>
#include <avtSTMDFileFormatInterface.h>
#include <avtMTMDFileFormatInterface.h>
#include <avtGenericDatabase.h>

using std::string;
#include <avtVTKOptions.h>

VTKCommonPluginInfo::VTKCommonPluginInfo() : CommonDatabasePluginInfo(), VTKGeneralPluginInfo()
{
Expand Down Expand Up @@ -58,11 +52,86 @@ VTKCommonPluginInfo::GetDatabaseType()
// I changed the code so it switches the interface based on how many domains
// are present in the 1st file.
//
// Kathleen Biagas, Fri Augus 13, 2021
// Kathleen Biagas, Fri August 13, 2021
// Add MTMD for .pvd file types.
//
// Kathleen Biagas, Thu Dec 12, 2024
// Added tests to see if .pvd is GEOS flavor.
//
// ****************************************************************************

#include <FileFunctions.h>
#include <vtkNew.h>
#include <vtkXMLDataElement.h>
#include <vtkXMLDataParser.h>
using std::string;

bool
FindGEOSNestedElement(vtkXMLDataElement *el)
{
if(el->GetNumberOfNestedElements() == 0)
return false;

// check for Blocks with certain name attributes used by GEOS
if(el->FindNestedElementWithNameAndAttribute("Block", "name","CellElementRegion") ||
el->FindNestedElementWithNameAndAttribute("Block", "name","SurfaceElementRegion") ||
el->FindNestedElementWithNameAndAttribute("Block", "name","ParticleRegion") ||
el->FindNestedElementWithNameAndAttribute("Block", "name","WellElementRegion") )
{
return true;
}
for(int i = 0; i < el->GetNumberOfNestedElements(); ++i)
return FindGEOSNestedElement(el->GetNestedElement(i));

return false;
}

bool
CheckIfGEOSVTM(const string &vtmFile)
{
vtkNew<vtkXMLDataParser> vtmParser;
vtmParser->SetFileName(vtmFile.c_str());
if(!vtmParser->Parse())
return false;

vtkXMLDataElement *vtmRoot = vtmParser->GetRootElement();
return FindGEOSNestedElement(vtmRoot);
}


bool
CheckIfGEOSPVD(const string &rootFile)
{
vtkNew<vtkXMLDataParser> pvdParser;
pvdParser->SetFileName(rootFile.c_str());
if(pvdParser->Parse())
{
vtkXMLDataElement *root = pvdParser->GetRootElement();
if(root)
{
vtkXMLDataElement *datasetNode = root->LookupElementWithName("DataSet");
if(datasetNode)
{
string fileName = datasetNode->GetAttribute("file");
size_t pos1 = fileName.find_last_of('.');
string ext1 = fileName.substr(pos1 + 1);
if(ext1 == "vtm")
{
// extract dir from rootFile and prepend to fileName:
string dir = FileFunctions::Dirname(rootFile);
string file = dir + VISIT_SLASH_STRING + fileName;
return CheckIfGEOSVTM(file);
}
}
}
}
return false;
}


#include <avtSTSDFileFormatInterface.h>
#include <avtMTMDFileFormatInterface.h>

avtDatabase *
VTKCommonPluginInfo::SetupDatabase(const char *const *list,
int nList, int nBlock)
Expand All @@ -78,12 +147,37 @@ VTKCommonPluginInfo::SetupDatabase(const char *const *list,

// Only using 1 timestepgroup
avtMTMDFileFormat **ffl = new avtMTMDFileFormat*[1];
ffl[0] = new avtPVD_MTMDFileFormat(fn.c_str(), readOptions);
if(CheckIfGEOSPVD(fn))
ffl[0] = new avtGEOSFileFormat(fn.c_str(), readOptions);
else
ffl[0] = new avtPVD_MTMDFileFormat(fn.c_str(), readOptions);
avtMTMDFileFormatInterface *inter = new avtMTMDFileFormatInterface(ffl, 1);
db = new avtGenericDatabase(inter);

return db;
}
else if (ext == "vtm")
{
if(CheckIfGEOSVTM(fn))
{
dbType = DB_TYPE_STMD;
avtSTMDFileFormat **ffl = new avtSTMDFileFormat*[nList];
avtGEOSFileReader *reader = new avtGEOSFileReader(list[0], readOptions);
for (int i = 0; i < nList; i++)
{
if(i == 0)
ffl[i] = new avtGEOS_STMDFileFormat(list[i], readOptions, reader);
else
ffl[i] = new avtGEOS_STMDFileFormat(list[i], readOptions);
}
avtSTMDFileFormatInterface *inter
= new avtSTMDFileFormatInterface(ffl, nList);
db = new avtGenericDatabase(inter);

return db;
}
}


// Figure out how many domains there are in the 1st file.
avtVTKFileReader *reader = new avtVTKFileReader(list[0], readOptions);
Expand Down
Loading

0 comments on commit 9b3fbd1

Please sign in to comment.