From 331ea24dae76b821551a0f84efa24527c904da1b Mon Sep 17 00:00:00 2001 From: Alho Markku J Date: Wed, 6 Dec 2023 15:06:13 +0200 Subject: [PATCH 1/7] Verbose outputs for ParallelReader::read --- vlsv_reader_parallel.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vlsv_reader_parallel.h b/vlsv_reader_parallel.h index 694ae74..a87cb94 100644 --- a/vlsv_reader_parallel.h +++ b/vlsv_reader_parallel.h @@ -81,15 +81,21 @@ namespace vlsv { const uint64_t& begin,const uint64_t& amount,T*& outBuffer,bool allocateMemory) { // Get array info to all processes: if (ParallelReader::getArrayInfo(tagName,attribs) == false) { + std::cerr << "Failure in ParallelReader::getArrayInfo\n"; return false; } // Check that requested read is inside the array: - if (begin > arrayOpen.arraySize || (begin+amount) > arrayOpen.arraySize) return false; + if (begin > arrayOpen.arraySize || (begin+amount) > arrayOpen.arraySize){ + std::cerr << "Failure in ParallelReader::read, trying to read out of bounds.\n"; + std::cerr << "begin: " << begin << ", amount " << amount <<", arrayOpen.arraySize " << arrayOpen.arraySize << "\n"; + return false; + } char* buffer = new char[amount*arrayOpen.vectorSize*arrayOpen.dataSize]; if (ParallelReader::readArray(tagName,attribs,begin,amount,buffer) == false) { delete [] buffer; buffer = NULL; + std::cerr << "Failure in ParallelReader::readArray\n"; return false; } From cfdd088924b01fd49f07b4c9adee6702b026abf9 Mon Sep 17 00:00:00 2001 From: Alho Markku J Date: Thu, 4 Jan 2024 11:01:46 +0200 Subject: [PATCH 2/7] Accurate time handling when requesting for "try harder to get accurate times and cycles" --- visit-plugin/avtVlsvFileFormat.C | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/visit-plugin/avtVlsvFileFormat.C b/visit-plugin/avtVlsvFileFormat.C index 514c79d..e82d0d9 100644 --- a/visit-plugin/avtVlsvFileFormat.C +++ b/visit-plugin/avtVlsvFileFormat.C @@ -266,17 +266,23 @@ void avtVlsvFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData* md) { debug2 << "VLSV\t file'" << inputFile << "' timestep: " << timestep << endl; debug3 << "VLSV\t object " << objectNumber << " / " << objectCounter << endl; + string dummy; // ActivateTimeStep should get called prior to this function. // Check that a VLSV file is open: if (vlsvReader == NULL) { debug2 << "VLSV\t VLSVReader in NULL, calling ActivateTimestep()." << endl; ActivateTimestep(); } - string dummy; - if (vlsvReader->getFileName(dummy) == false) { - debug2 << "VLSV\t ERROR: Input file has not been opened." << endl; - return; - } + // debug2 << "VLSV\t checking for VLSVReader filename mismatch." << endl; + // vlsvReader->getFileName(dummy); + // if (dummy.compare(inputFile) != 0) { + // debug2 << "VLSV\t VLSVReader filename mismatch, calling ActivateTimestep()." << endl; + // ActivateTimestep(); + // } + // if (vlsvReader->getFileName(dummy) == false) { + // debug2 << "VLSV\t ERROR: Input file has not been opened." << endl; + // return; + // } // Read simulation time and time step. // Add them to metadata if they were found: @@ -688,8 +694,10 @@ int avtVlsvFileFormat::GetCycle(void) { // Check that VLSVReader is not NULL: if (vlsvReader == NULL) { - debug1 << "VLSV\t ERROR: VLSVReader is NULL." << endl; - return INVALID_CYCLE; + // debug1 << "VLSV\t ERROR: VLSVReader is NULL." << endl; + // return INVALID_CYCLE; + debug2 << "VLSV\t VLSVReader in NULL, calling ActivateTimestep()." << endl; + ActivateTimestep(); } // Read simulation timestep: @@ -711,8 +719,10 @@ double avtVlsvFileFormat::GetTime(void) { // Check that VLSVReader is not NULL: if (vlsvReader == NULL) { - debug1 << "VLSV\t ERROR: VLSVReader is NULL." << endl; - return INVALID_TIME; + // debug1 << "VLSV\t ERROR: VLSVReader is NULL." << endl; + // return INVALID_TIME; + debug2 << "VLSV\t VLSVReader in NULL, calling ActivateTimestep()." << endl; + ActivateTimestep(); } // Read simulation time: From 9cefaa5b5929ec534c053573777a11be02c19e22 Mon Sep 17 00:00:00 2001 From: Alho Markku J Date: Thu, 4 Jan 2024 11:42:00 +0200 Subject: [PATCH 3/7] Add avtVlsvDatabase as a wrapper, but runtime symbol lookup error for now.. avtFileFormatInterface not found in avtVlsvDatabase for some reason. --- visit-plugin/VlsvCommonPluginInfo.C | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/visit-plugin/VlsvCommonPluginInfo.C b/visit-plugin/VlsvCommonPluginInfo.C index e5f09a6..1b76175 100644 --- a/visit-plugin/VlsvCommonPluginInfo.C +++ b/visit-plugin/VlsvCommonPluginInfo.C @@ -40,6 +40,7 @@ #include #include #include +#include // **************************************************************************** // Method: VlsvCommonPluginInfo::GetDatabaseType @@ -51,8 +52,7 @@ // Creation: omitted // // **************************************************************************** -DatabaseType -VlsvCommonPluginInfo::GetDatabaseType() +DatabaseType VlsvCommonPluginInfo::GetDatabaseType() { return DB_TYPE_STMD; } @@ -81,5 +81,5 @@ avtDatabase* VlsvCommonPluginInfo::SetupDatabase(const char *const *list,int nLi } avtSTMDFileFormatInterface *inter = new avtSTMDFileFormatInterface(ffl, nList); - return new avtGenericDatabase(inter); + return new avtVlsvDatabase(inter); } From 1732ae0ce4ec0e5efe1881151b1bd68b7f8ecf0a Mon Sep 17 00:00:00 2001 From: Alho Markku J Date: Thu, 4 Jan 2024 12:06:48 +0200 Subject: [PATCH 4/7] Build process needed updating. Now throws GetMetadataException when using avtVlsvDatabase. --- visit-plugin/VlsvCommonPluginInfo.C | 2 +- visit-plugin/vlsv.xml | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/visit-plugin/VlsvCommonPluginInfo.C b/visit-plugin/VlsvCommonPluginInfo.C index 1b76175..0a1fc5e 100644 --- a/visit-plugin/VlsvCommonPluginInfo.C +++ b/visit-plugin/VlsvCommonPluginInfo.C @@ -81,5 +81,5 @@ avtDatabase* VlsvCommonPluginInfo::SetupDatabase(const char *const *list,int nLi } avtSTMDFileFormatInterface *inter = new avtSTMDFileFormatInterface(ffl, nList); - return new avtVlsvDatabase(inter); + return new avtGenericDatabase(inter); } diff --git a/visit-plugin/vlsv.xml b/visit-plugin/vlsv.xml index e62970b..840b092 100644 --- a/visit-plugin/vlsv.xml +++ b/visit-plugin/vlsv.xml @@ -2,11 +2,11 @@ -std=c++0x - -I/home/sandroos/codes/vlsv + -I/home/mjalho/Vlasiator/lib/vlsv -DVTK_API=81 - -L/home/sandroos/codes/vlsv + -L/home/mjalho/Vlasiator/lib/vlsv -lvlsv @@ -19,6 +19,7 @@ duplicate_node_elimination.cpp + avtVlsvDatabase.cpp avtVlsvFileFormat.C mesh_metadata.cpp mesh_reader.cpp @@ -37,6 +38,7 @@ duplicate_node_elimination.cpp + avtVlsvDatabase.cpp avtVlsvFileFormat.C mesh_metadata.cpp mesh_reader.cpp From 391bf46318c185359c2dc5995959227ca5a06296 Mon Sep 17 00:00:00 2001 From: Alho Markku J Date: Thu, 4 Jan 2024 13:26:13 +0200 Subject: [PATCH 5/7] Cleanup, all times and cycles are now accurate --- visit-plugin/VlsvCommonPluginInfo.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/visit-plugin/VlsvCommonPluginInfo.C b/visit-plugin/VlsvCommonPluginInfo.C index 0a1fc5e..1b76175 100644 --- a/visit-plugin/VlsvCommonPluginInfo.C +++ b/visit-plugin/VlsvCommonPluginInfo.C @@ -81,5 +81,5 @@ avtDatabase* VlsvCommonPluginInfo::SetupDatabase(const char *const *list,int nLi } avtSTMDFileFormatInterface *inter = new avtSTMDFileFormatInterface(ffl, nList); - return new avtGenericDatabase(inter); + return new avtVlsvDatabase(inter); } From 633131719a54eac952848db0cc843176308fd6a0 Mon Sep 17 00:00:00 2001 From: Alho Markku J Date: Thu, 4 Jan 2024 13:47:14 +0200 Subject: [PATCH 6/7] Also add the new files --- visit-plugin/avtVlsvDatabase.cpp | 134 +++++++++++++++++++++++++++++++ visit-plugin/avtVlsvDatabase.h | 21 +++++ 2 files changed, 155 insertions(+) create mode 100644 visit-plugin/avtVlsvDatabase.cpp create mode 100644 visit-plugin/avtVlsvDatabase.h diff --git a/visit-plugin/avtVlsvDatabase.cpp b/visit-plugin/avtVlsvDatabase.cpp new file mode 100644 index 0000000..bc049bf --- /dev/null +++ b/visit-plugin/avtVlsvDatabase.cpp @@ -0,0 +1,134 @@ +#include + +#include +#include + +#ifdef PARALLEL +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + + +using std::string; +using std::vector; + +avtVlsvDatabase::avtVlsvDatabase(avtFileFormatInterface *inter) +: avtGenericDatabase(inter) +{ +} + +avtVlsvDatabase::~avtVlsvDatabase() +{ +} + +// **************************************************************************** +// Method: avtGenericDatabase::SetDatabaseMetaData +// +// Purpose: +// Sets the database meta-data using the file format interface. +// +// Arguments: +// md : The meta-data to set. +// timeState : The time state that we're interested in. +// +// Programmer: Hank Childs +// Creation: March 2, 2001 +// +// Modifications: +// Brad Whitlock, Wed May 14 09:15:18 PDT 2003 +// I added the optional timeState argument. +// +// Hank Childs, Tue Feb 15 07:21:10 PST 2005 +// Replace forbidden characters of expression language. +// +// Mark C. Miller, Tue May 17 18:48:38 PDT 2005 +// Added bool arg, forceReadAllCyclesTimes +// +// Jeremy Meredith, Fri Sep 2 15:03:06 PDT 2005 +// Removed most of the special character replacements, as the expression +// language scanner is now accepting most of them inside <>'s. Replaced +// the unacceptable [] <> () with the acceptable {}'s since it seems +// more natural than the former _ character used to replace them. +// +// Hank Childs, Sun Mar 16 07:10:49 PDT 2008 +// Change substitutions for (, }, [, ], <, and > to use an underscore, +// instead of { & }, since that was screwing up expressions. +// +// Dave Pugmire, Thu Mar 4 10:27:17 EST 2010 +// Ensure that naming collisions don't occur. Previously ()[]<> all mapped +// to '_'. +// +// Markku Alho: Force reading time & cycle from vlsv files +// **************************************************************************** + +void avtVlsvDatabase::SetDatabaseMetaData(avtDatabaseMetaData *md, int timeState, bool forceReadAllCyclesTimes) +{ + debug2 << "VLSV\t SetDataBaseMetaData called\n"; + int t0 = visitTimer->StartTimer(); + Interface->SetDatabaseMetaData(md, timeState, true); + md->ReplaceForbiddenCharacters(); + visitTimer->StopTimer(t0, "Getting database meta data"); +} \ No newline at end of file diff --git a/visit-plugin/avtVlsvDatabase.h b/visit-plugin/avtVlsvDatabase.h new file mode 100644 index 0000000..3820d7c --- /dev/null +++ b/visit-plugin/avtVlsvDatabase.h @@ -0,0 +1,21 @@ +#ifndef AVT_VLSV_DATABASE_H +#define AVT_VLSV_DATABASE_H + +#include +#include +#include +#include +#include +#include +#include + +class DATABASE_API avtVlsvDatabase : public avtGenericDatabase +{ + public: + avtVlsvDatabase(avtFileFormatInterface *); + virtual ~avtVlsvDatabase(); + protected: + virtual void SetDatabaseMetaData(avtDatabaseMetaData *md, int timeState, bool forceReadAllCyclesTimes = true); +}; + +#endif \ No newline at end of file From b8722a95170bd9bf6f3a65984de8a823eab0da1e Mon Sep 17 00:00:00 2001 From: Alho Markku J Date: Wed, 10 Jan 2024 11:13:26 +0200 Subject: [PATCH 7/7] Yup, reading file data at construction is bad. Adding some template functions for aux data. --- visit-plugin/avtVlsvDatabase.cpp | 3 ++- visit-plugin/avtVlsvFileFormat.C | 34 ++++++++++++++++++++++++++++++++ visit-plugin/avtVlsvFileFormat.h | 4 ++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/visit-plugin/avtVlsvDatabase.cpp b/visit-plugin/avtVlsvDatabase.cpp index bc049bf..a59e630 100644 --- a/visit-plugin/avtVlsvDatabase.cpp +++ b/visit-plugin/avtVlsvDatabase.cpp @@ -128,7 +128,8 @@ void avtVlsvDatabase::SetDatabaseMetaData(avtDatabaseMetaData *md, int timeState { debug2 << "VLSV\t SetDataBaseMetaData called\n"; int t0 = visitTimer->StartTimer(); - Interface->SetDatabaseMetaData(md, timeState, true); + // Interface->SetDatabaseMetaData(md, timeState, true); // This will force the read even when loading the database. Performance impact is significant, not worth it. + Interface->SetDatabaseMetaData(md, timeState, forceReadAllCyclesTimes); md->ReplaceForbiddenCharacters(); visitTimer->StopTimer(t0, "Getting database meta data"); } \ No newline at end of file diff --git a/visit-plugin/avtVlsvFileFormat.C b/visit-plugin/avtVlsvFileFormat.C index e82d0d9..2ae4d7a 100644 --- a/visit-plugin/avtVlsvFileFormat.C +++ b/visit-plugin/avtVlsvFileFormat.C @@ -41,6 +41,7 @@ // ************************************************************************* // #include +#include #include @@ -665,6 +666,39 @@ vtkDataArray* avtVlsvFileFormat::GetVar(int domain,const char* varname) { } + +// **************************************************************************** +// Method: avtSTMDFileFormat::GetAuxiliaryData +// +// Purpose: +// Gets the auxiliary data specified. +// +// Arguments: +// The variable of interest. +// The domain of interest. +// The type of auxiliary data. +// The arguments for that type. +// +// Returns: The auxiliary data. Throws an exception if this is not a +// supported data type. +// +// Programmer: Hank Childs +// Creation: February 23, 2001 +// +// **************************************************************************** + +void * +avtVlsvFileFormat::GetAuxiliaryData(const char *var, int domain, const char *type, + void *args, DestructorFunction &) +{ + // + // This is defined only so the simple file formats that have no auxiliary + // data don't have to define this. + // + return NULL; +} + + // **************************************************************************** // Method: avtVlsvFileFormat::GetVectorVar // diff --git a/visit-plugin/avtVlsvFileFormat.h b/visit-plugin/avtVlsvFileFormat.h index 04c364b..597ea21 100644 --- a/visit-plugin/avtVlsvFileFormat.h +++ b/visit-plugin/avtVlsvFileFormat.h @@ -72,8 +72,8 @@ class avtVlsvFileFormat: public avtSTMDFileFormat { // This is used to return unconvention data -- ranging from material // information to information about block connectivity. // - // virtual void *GetAuxiliaryData(const char *var, const char *type, - // void *args, DestructorFunction &); + virtual void *GetAuxiliaryData(const char *var, int someInt, const char *type, + void *args, DestructorFunction &); // //