Updating CMake files to remove option for visit plugin and force C++14 or newer

This commit is contained in:
Mark Berrill 2018-09-24 11:51:23 -04:00
parent 3c55966984
commit 078464151a
21 changed files with 17 additions and 1571 deletions

View File

@ -28,11 +28,13 @@ ENDIF()
SET( CMAKE_CXX_EXTENSIONS OFF )
IF ( NOT CMAKE_CXX_STANDARD )
IF ( CXX_STD )
MESSAGE( WARNING "CXX_STD is obsolete, please set CMAKE_CXX_STANDARD" )
SET( CMAKE_CXX_STANDARD ${CXX_STD} )
MESSAGE( FATAL_ERROR "CXX_STD is obsolete, please set CMAKE_CXX_STANDARD" )
ENDIF()
SET( CMAKE_CXX_STANDARD 14 )
ENDIF()
IF ( ( "${CMAKE_CXX_STANDARD}" GREATER "90" ) OR ( "${CMAKE_CXX_STANDARD}" LESS "14" ) )
MESSAGE( FATAL_ERROR "C++14 or newer required" )
ENDIF()
# Set source/install paths
@ -110,7 +112,7 @@ ENDIF()
ADD_CUSTOM_TARGET( build-test )
ADD_CUSTOM_TARGET( build-examples )
ADD_CUSTOM_TARGET( check COMMAND make test )
ADD_DISTCLEAN( analysis null_timer tests liblbpm-wia.* cpu gpu example common visit IO threadpool )
ADD_DISTCLEAN( analysis null_timer tests liblbpm-wia.* cpu gpu example common IO threadpool )
# Check for CUDA
@ -168,11 +170,3 @@ IF ( NOT ONLY_BUILD_DOCS )
INSTALL_PROJ_LIB()
ENDIF()
# Create the visit plugin
IF ( USE_VISIT )
INCLUDE( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindVisIt.cmake )
VISIT_PLUGIN( visit LBM )
ENDIF()

View File

@ -8,8 +8,8 @@ Lattice Boltzmann Methods for Porous Media
Notes on installation
* example configure scripts for cmake are in the sample_scripts directory
* required dependencies - MPI, HDF5, SILO, C++11
* optional dependencies - NetCDF, CUDA, TimerUtility, VisIT
* required dependencies - MPI, HDF5, SILO, C++14
* optional dependencies - NetCDF, CUDA, TimerUtility
Build dependencies (zlib, hdf5, silo) OR point to an existing installation

View File

@ -1,64 +0,0 @@
To compile the visit plug-in and run in parallel on computational back-end:
Checkout code and create a cmake script to compile plug-in.
Example commands for Rhea:
Load the proper modules
module unload intel gcc
module load gcc/4.8.2
module load cmake
Configure cmake to build the plug-in
cmake \
-D CMAKE_BUILD_TYPE:STRING=Release \
-D CMAKE_C_COMPILER:PATH=gcc \
-D CMAKE_CXX_COMPILER:PATH=g++ \
-D USE_MPI=false \
-D USE_CUDA=false \
-D USE_VISIT=true \
-D VISIT_ROOT_DIR=/sw/redhat6/visit \
-D USE_TIMER=false \
../../LBPM-WIA
Build the visit plug-in
make install -j 8
make visit
Check that the visit plug-in installed in ~/.visit/2.9.0/linux-x86_64/plugins/databases
where 2.9.0 is the current version of visit on rhea
It should have created several shared libraries:
libELBMDatabase_par.so libELBMDatabase_ser.so libILBMDatabase.so libMLBMDatabase.so
Install visit on local machine (2.9.0)
Start visit on local machine
First time:
Go to: Options - Host profiles
Click Remote Profiles - Update
After list populates, drag host_ornl_rhea.xml to Hosts
Select ORNL_Rhea from Hosts, click on Machines
Set account username
Click on Launch Profiles tab
Change profile name and timeout if desired
Click on Parallel tab
Add Default Bank / Account with project number, set default nodes/processors if desired
Click Apply, then close window
Go to: Options - Save Settings
Open remote file / launch parallel job
Click Open file
Change Host to ORNL_Rhea, enter passcode when prompted
Open visualization file
/lustre/atlas/proj-shared/geo106/vis_test/dumps.LBM
New window will open prompting for # of nodes, processors, Bank (project number) and time limit
Rhea as 16 physical-cores/node and 64 GB/node
for example file above I used 1 node, 16 cores
Visit will call qsub and submit a parallel job that will start when ready
Visualize desired quantities

View File

@ -1,61 +0,0 @@
# Tool for building visit plugins
#
# The script will prompt the user to specify VISIT_ROOT_DIR if the prefix
# cannot be determined by the location of xml2cmake in the system path.
# Users can set the environment variable VISIT_BIN_PATH before running cmake
# (e.g. VISIT_BIN_PATH=/usr/local/bin instead of VISIT_ROOT_DIR)
# Find the xml2cmake executable and set VISIT_XML_CMAKE
SET( VISIT_XML_CMAKE )
FIND_PROGRAM( VISIT_XML_CMAKE
NAMES xml2cmake
PATHS
"${VISIT_ROOT_DIR}"
"${VISIT_BIN_PATH}"
"$ENV{VISIT_ROOT_DIR}"
"$ENV{VISIT_BIN_PATH}"
PATH_SUFFIXES bin bin64
NO_DEFAULT_PATH
)
IF( NOT VISIT_XML_CMAKE )
MESSAGE( FATAL_ERROR "xml2cmake not found in:\n"
"${VISIT_ROOT_DIR}/bin\n"
"${VISIT_BIN_PATH}\n"
"$ENV{VISIT_ROOT_DIR}/bin\n"
"$ENV{VISIT_BIN_PATH}\n"
)
ELSE()
MESSAGE( "VISIT_XML_CMAKE=${VISIT_XML_CMAKE}" )
ENDIF()
# Install plugin
MACRO( VISIT_PLUGIN SRC_DIR TARGET )
CONFIGURE_FILE( "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_DIR}/${TARGET}.xml" "${CMAKE_CURRENT_BINARY_DIR}/${SRC_DIR}/${TARGET}.xml" )
FILE( GLOB ConfigFiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/${SRC_DIR}/*.C" "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_DIR}/*.h" )
ADD_CUSTOM_TARGET(copy-${SRC_DIR})
FOREACH( ConfigFile ${ConfigFiles} )
ADD_CUSTOM_COMMAND(TARGET copy-${SRC_DIR} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_DIR}/${ConfigFile}"
"${CMAKE_CURRENT_BINARY_DIR}/${SRC_DIR}/${ConfigFile}"
)
ENDFOREACH()
ADD_CUSTOM_TARGET(
${SRC_DIR}
COMMAND ${VISIT_XML_CMAKE} -clobber ${TARGET}.xml
COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DVISIT_NOLINK_MPI_WITH_LIBRARIES=TRUE
.
COMMAND make
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${SRC_DIR}"
SOURCES ${SRC_DIR}
DEPENDS lbpm-wia copy-${SRC_DIR}
)
ENDMACRO()

View File

@ -48,8 +48,6 @@ SET( USE_MPI TRUE )
IF ( DEFINED ENV{USE_MPI} )
SET( USE_MPI $ENV{USE_MPI} )
ENDIF()
SET( USE_VISIT $ENV{USE_VISIT} )
SET( VISIT_ROOT_DIR $ENV{VISIT_ROOT_DIR} )
# Get the source directory based on the current directory
@ -106,9 +104,6 @@ ELSEIF( ${CTEST_SCRIPT_ARG} STREQUAL "valgrind-cuda" )
ELSE()
MESSAGE(FATAL_ERROR "Invalid build (${CTEST_SCRIPT_ARG}): ctest -S /path/to/script,build (debug/opt/valgrind")
ENDIF()
IF ( USE_VISIT )
STRING( REGEX REPLACE "LBPM-WIA-" "LBPM-WIA-visit-" CTEST_BUILD_NAME "${CTEST_BUILD_NAME}" )
ENDIF()
IF ( BUILDNAME_POSTFIX )
SET( CTEST_BUILD_NAME "${CTEST_BUILD_NAME}-${BUILDNAME_POSTFIX}" )
ENDIF()
@ -161,9 +156,6 @@ IF ( BUILD_SERIAL )
ELSE()
SET( CTEST_BUILD_COMMAND "${CMAKE_MAKE_PROGRAM} -i -j ${N_PROCS} install" )
ENDIF()
IF ( USE_VISIT )
SET( CTEST_BUILD_COMMAND "${CTEST_BUILD_COMMAND} visit" )
ENDIF()
SET( CTEST_CUSTOM_WARNING_EXCEPTION "has no symbols" )
@ -218,9 +210,6 @@ IF ( USE_TIMER )
ELSE()
SET( CTEST_OPTIONS "${CTEST_OPTIONS};-DUSE_TIMER:BOOL=false" )
ENDIF()
IF ( USE_VISIT )
SET( CTEST_OPTIONS "${CTEST_OPTIONS};-DUSE_VISIT:BOOL=true;-DVISIT_ROOT_DIR='${VISIT_ROOT_DIR}'" )
ENDIF()
IF ( USE_CUDA )
SET( CTEST_OPTIONS "${CTEST_OPTIONS};-DUSE_CUDA:BOOL=true;-DCMAKE_CUDA_FLAGS='${CUDA_FLAGS}';-DCMAKE_CUDA_HOST_COMPILER=${CUDA_HOST_COMPILER};-DLIB_TYPE=${LIB_TYPE}" )
ELSE()

View File

@ -225,12 +225,6 @@ MACRO( CONFIGURE_SYSTEM )
IF( NOT CMAKE_BUILD_TYPE )
MESSAGE(FATAL_ERROR "CMAKE_BUILD_TYPE is not set")
ENDIF()
# Disable gxx debug flags if we are building the visit plugin
# This is necessary to prvent segfaults caused by inconsistent object sizes
# caused by std::vector<std::string> in the avtMeshMetaData class
IF ( USE_VISIT )
SET( DISABLE_GXX_DEBUG 1 )
ENDIF()
# Remove extra library links
# Get the compiler
SET_COMPILER_FLAGS()

View File

@ -24,8 +24,5 @@ cmake \
-D USE_TIMER=0 \
${HOME}/Programs/LBPM-WIA
# -D SILO_LIB="/usr/local/visit/2.9.2/linux-x86_64/lib/libsiloh5.a" \
# -D SILO_DIRECTORY="/usr/local/visit/2.9.2/linux-x86_64/include/silo" \

View File

@ -25,9 +25,7 @@ i -D CMAKE_CXX_COMPILER:PATH=/home/christopher/openmpi/install_dir/bin/mpicxx
-D CUDA_HOST_COMPILER="/usr/bin/gcc-4.9" \
-D USE_CUDA=1 \
-D USE_TIMER=0 \
-D USE_VISIT=true \
-D VISIT_ROOT_DIR=/home/christopher/visit2_12_2.linux-x86_64/bin \
/home/christopher/repos/LBPM-WIA
make -j8 install
#make visit

View File

@ -121,7 +121,7 @@ int main(int argc, char **argv)
if (rank==0)
printf("Mean error %0.4f \n", err);
// Write the results to visit
// Write the results
Array<int> ID0(id.size());
ID0.copy( id );
Array<double> ID(Nx,Ny,Nz);

View File

@ -319,15 +319,15 @@ int main(int argc, char **argv)
}
// Write the results to visit
// Write the results
if (rank==0) printf("Writing output \n");
std::vector<IO::MeshDataStruct> meshData(N_levels);
for (size_t i=0; i<Nx.size(); i++) {
// Mesh
meshData[i].meshName = "Level " + std::to_string(i+1);
meshData[i].mesh = std::shared_ptr<IO::DomainMesh>( new IO::DomainMesh(Dm[i]->rank_info,Nx[i],Ny[i],Nz[i],Lx,Ly,Lz) );
meshData[i].mesh = std::make_shared<IO::DomainMesh>( Dm[i]->rank_info,Nx[i],Ny[i],Nz[i],Lx,Ly,Lz );
// Source data
std::shared_ptr<IO::Variable> OrigData( new IO::Variable() );
auto OrigData = std::make_shared<IO::Variable>();
OrigData->name = "Source Data";
OrigData->type = IO::VariableType::VolumeVariable;
OrigData->dim = 1;
@ -335,7 +335,7 @@ int main(int argc, char **argv)
meshData[i].vars.push_back(OrigData);
fillDouble[i]->copy( LOCVOL[i], OrigData->data );
// Non-Local Mean
std::shared_ptr<IO::Variable> NonLocMean( new IO::Variable() );
auto NonLocMean = std::make_shared<IO::Variable>();
NonLocMean->name = "Non-Local Mean";
NonLocMean->type = IO::VariableType::VolumeVariable;
NonLocMean->dim = 1;
@ -343,7 +343,7 @@ int main(int argc, char **argv)
meshData[i].vars.push_back(NonLocMean);
fillDouble[i]->copy( NonLocalMean[i], NonLocMean->data );
// Segmented Data
std::shared_ptr<IO::Variable> SegData( new IO::Variable() );
auto SegData = std::make_shared<IO::Variable>();
SegData->name = "Segmented Data";
SegData->type = IO::VariableType::VolumeVariable;
SegData->dim = 1;
@ -351,7 +351,7 @@ int main(int argc, char **argv)
meshData[i].vars.push_back(SegData);
fillDouble[i]->copy( ID[i], SegData->data );
// Signed Distance
std::shared_ptr<IO::Variable> DistData( new IO::Variable() );
auto DistData = std::make_shared<IO::Variable>();
DistData->name = "Signed Distance";
DistData->type = IO::VariableType::VolumeVariable;
DistData->dim = 1;
@ -359,7 +359,7 @@ int main(int argc, char **argv)
meshData[i].vars.push_back(DistData);
fillDouble[i]->copy( Dist[i], DistData->data );
// Smoothed Data
std::shared_ptr<IO::Variable> SmoothData( new IO::Variable() );
auto SmoothData = std::make_shared<IO::Variable>();
SmoothData->name = "Smoothed Data";
SmoothData->type = IO::VariableType::VolumeVariable;
SmoothData->dim = 1;

View File

@ -346,7 +346,7 @@ int main(int argc, char **argv)
*/
{
// Write the results to visit
// Write the results
if (rank==0) printf("Setting up visualization structure \n");
// std::vector<IO::MeshDataStruct> meshData(N_levels);
std::vector<IO::MeshDataStruct> meshData(1);

View File

@ -1,24 +0,0 @@
<?xml version="1.0"?>
<Plugin name="LBM" type="database" label="LBM" version="1.0" mdspecificcode="true" dbtype="MTMD">
<FilePatterns>
*.LBM
</FilePatterns>
<CXXFLAGS>
-I${LBPM_INSTALL_DIR}/include
-I${TIMER_INCLUDE}
${MPI_CXXFLAGS}
${TIMER_CXXFLAGS}
</CXXFLAGS>
<LDFLAGS>
-L${LBPM_INSTALL_DIR}/lib
-L${CMAKE_CURRENT_BINARY_DIR}/..
${TIMER_LDFLAGS}
${MPI_LINK_FLAGS}
</LDFLAGS>
<LIBS>
-llbpm-wia
${TIMER_LDLIBS}
${MPI_LIBRARIES}
</LIBS>
</Plugin>

View File

@ -1,92 +0,0 @@
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
#include <LBMPluginInfo.h>
#include <avtLBMFileFormat.h>
#include <avtMTMDFileFormatInterface.h>
#include <avtGenericDatabase.h>
// ****************************************************************************
// Method: LBMCommonPluginInfo::GetDatabaseType
//
// Purpose:
// Returns the type of a LBM database.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
DatabaseType
LBMCommonPluginInfo::GetDatabaseType()
{
return DB_TYPE_MTMD;
}
// ****************************************************************************
// Method: LBMCommonPluginInfo::SetupDatabase
//
// Purpose:
// Sets up a LBM database.
//
// Arguments:
// list A list of file names.
// nList The number of timesteps in list.
// nBlocks The number of blocks in the list.
//
// Returns: A LBM database from list.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
avtDatabase *
LBMCommonPluginInfo::SetupDatabase(const char *const *list,
int nList, int nBlock)
{
// ignore any nBlocks past 1
int nTimestepGroups = nList / nBlock;
avtMTMDFileFormat **ffl = new avtMTMDFileFormat*[nTimestepGroups];
for (int i = 0 ; i < nTimestepGroups ; i++)
{
ffl[i] = new avtLBMFileFormat(list[i*nBlock]);
}
avtMTMDFileFormatInterface *inter
= new avtMTMDFileFormatInterface(ffl, nTimestepGroups);
return new avtGenericDatabase(inter);
}

View File

@ -1,73 +0,0 @@
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
#include <LBMPluginInfo.h>
// ****************************************************************************
// Function: GetEngineInfo
//
// Purpose:
// Return a new EnginePluginInfo for the LBM database.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
extern "C" DBP_EXPORT EngineDatabasePluginInfo* LBM_GetEngineInfo()
{
return new LBMEnginePluginInfo;
}
// ****************************************************************************
// Method: LBMEnginePluginInfo::GetWriter
//
// Purpose:
// Sets up a LBM writer.
//
// Returns: A LBM writer.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
avtDatabaseWriter *
LBMEnginePluginInfo::GetWriter(void)
{
return NULL;
}

View File

@ -1,60 +0,0 @@
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
#include <LBMPluginInfo.h>
// ****************************************************************************
// Function: GetMDServerInfo
//
// Purpose:
// Return a new MDServerPluginInfo for the LBM database.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
extern "C" DBP_EXPORT MDServerDatabasePluginInfo* LBM_GetMDServerInfo()
{
return new LBMMDServerPluginInfo;
}
// this makes compilers happy... remove if we ever have functions here
void LBMMDServerPluginInfo::dummy()
{
}

View File

@ -1,206 +0,0 @@
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// File: LBMPluginInfo.C
// ************************************************************************* //
#include <LBMPluginInfo.h>
#include <visit-config.h>
VISIT_PLUGIN_VERSION(LBM,DBP_EXPORT)
// ****************************************************************************
// Function: GetGeneralInfo
//
// Purpose:
// Return a new GeneralPluginInfo for the LBM database.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
extern "C" DBP_EXPORT GeneralDatabasePluginInfo* LBM_GetGeneralInfo()
{
return new LBMGeneralPluginInfo;
}
// ****************************************************************************
// Method: LBMGeneralPluginInfo::GetName
//
// Purpose:
// Return the name of the database plugin.
//
// Returns: A pointer to the name of the database plugin.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
const char *
LBMGeneralPluginInfo::GetName() const
{
return "LBM";
}
// ****************************************************************************
// Method: LBMGeneralPluginInfo::GetVersion
//
// Purpose:
// Return the version of the database plugin.
//
// Returns: A pointer to the version of the database plugin.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
const char *
LBMGeneralPluginInfo::GetVersion() const
{
return "1.0";
}
// ****************************************************************************
// Method: LBMGeneralPluginInfo::GetID
//
// Purpose:
// Return the id of the database plugin.
//
// Returns: A pointer to the id of the database plugin.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
const char *
LBMGeneralPluginInfo::GetID() const
{
return "LBM_1.0";
}
// ****************************************************************************
// Method: LBMGeneralPluginInfo::EnabledByDefault
//
// Purpose:
// Return true if this plugin should be enabled by default; false otherwise.
//
// Returns: true/false
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
bool
LBMGeneralPluginInfo::EnabledByDefault() const
{
return true;
}
// ****************************************************************************
// Method: LBMGeneralPluginInfo::HasWriter
//
// Purpose:
// Return true if this plugin has a database writer.
//
// Returns: true/false
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
bool
LBMGeneralPluginInfo::HasWriter() const
{
return false;
}
// ****************************************************************************
// Method: LBMGeneralPluginInfo::GetDefaultFilePatterns
//
// Purpose:
// Returns the default patterns for a LBM database.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
std::vector<std::string>
LBMGeneralPluginInfo::GetDefaultFilePatterns() const
{
std::vector<std::string> defaultPatterns;
defaultPatterns.push_back("*.LBM");
return defaultPatterns;
}
// ****************************************************************************
// Method: LBMGeneralPluginInfo::AreDefaultFilePatternsStrict
//
// Purpose:
// Returns if the file patterns for a LBM database are
// intended to be interpreted strictly by default.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
bool
LBMGeneralPluginInfo::AreDefaultFilePatternsStrict() const
{
return false;
}
// ****************************************************************************
// Method: LBMGeneralPluginInfo::OpensWholeDirectory
//
// Purpose:
// Returns if the LBM plugin opens a whole directory name
// instead of a single file.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
bool
LBMGeneralPluginInfo::OpensWholeDirectory() const
{
return false;
}

View File

@ -1,100 +0,0 @@
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ****************************************************************************
// LBMPluginInfo.h
// ****************************************************************************
#ifndef LBM_PLUGIN_INFO_H
#define LBM_PLUGIN_INFO_H
#include <DatabasePluginInfo.h>
#include <database_plugin_exports.h>
class avtDatabase;
class avtDatabaseWriter;
// ****************************************************************************
// Class: LBMDatabasePluginInfo
//
// Purpose:
// Classes that provide all the information about the LBM plugin.
// Portions are separated into pieces relevant to the appropriate
// components of VisIt.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// Modifications:
//
// ****************************************************************************
class LBMGeneralPluginInfo : public virtual GeneralDatabasePluginInfo
{
public:
virtual const char *GetName() const;
virtual const char *GetVersion() const;
virtual const char *GetID() const;
virtual bool EnabledByDefault() const;
virtual bool HasWriter() const;
virtual std::vector<std::string> GetDefaultFilePatterns() const;
virtual bool AreDefaultFilePatternsStrict() const;
virtual bool OpensWholeDirectory() const;
};
class LBMCommonPluginInfo : public virtual CommonDatabasePluginInfo, public virtual LBMGeneralPluginInfo
{
public:
virtual DatabaseType GetDatabaseType();
virtual avtDatabase *SetupDatabase(const char * const *list,
int nList, int nBlock);
};
class LBMMDServerPluginInfo : public virtual MDServerDatabasePluginInfo, public virtual LBMCommonPluginInfo
{
public:
// this makes compilers happy... remove if we ever have functions here
virtual void dummy();
};
class LBMEnginePluginInfo : public virtual EngineDatabasePluginInfo, public virtual LBMCommonPluginInfo
{
public:
virtual avtDatabaseWriter *GetWriter(void);
};
#endif

View File

@ -1,498 +0,0 @@
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// avtLBMFileFormat.C //
// ************************************************************************* //
#include <avtLBMFileFormat.h>
#include <DebugStream.h>
#include <string>
// LBPM headers
#include "IO/Reader.h"
#include "IO/IOHelpers.h"
#include "IO/PIO.h"
#include "common/Utilities.h"
// vtk headers
#include <vtkFloatArray.h>
#include <vtkRectilinearGrid.h>
#include <vtkStructuredGrid.h>
#include <vtkUnstructuredGrid.h>
#include <vtkPointSet.h>
#include <vtkCellType.h>
#include <vtkPolyData.h>
#include <vtkCellArray.h>
#include <avtDatabaseMetaData.h>
#include <vtkHelpers.h>
#include <DBOptionsAttributes.h>
#include <Expression.h>
#include <InvalidVariableException.h>
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
#define USE_WINDOWS
#elif defined(__APPLE__)
#define USE_MAC
#else
#define USE_LINUX
#endif
#ifdef USE_WINDOWS
#include <windows.h>
#include <stdio.h>
#define TIME_TYPE LARGE_INTEGER
#define get_time(x) QueryPerformanceCounter(x)
#define get_frequency(f) QueryPerformanceFrequency(f)
#define get_diff(start,end,f) \
static_cast<double>(end.QuadPart-start.QuadPart)/static_cast<double>(f.QuadPart)
#elif defined(USE_LINUX) || defined(USE_MAX)
#include <sys/time.h>
#define TIME_TYPE timeval
#define get_time(x) gettimeofday(x,NULL);
#define get_frequency(f) (*f=timeval())
#define get_diff(start,end,f) 1e-6*static_cast<double>( \
0xF4240*(static_cast<int64_t>(end.tv_sec)-static_cast<int64_t>(start.tv_sec)) + \
(static_cast<int64_t>(end.tv_usec)-static_cast<int64_t>(start.tv_usec)) )
#else
#error Unknown OS
#endif
// Null stream buffer
class NullBufferClass : public std::streambuf {
public:
virtual std::streamsize xsputn(const char *s, std::streamsize n) { return n; }
virtual int overflow(int c) { return 1; }
virtual void setOutputStream( std::ostream* ) {}
};
// Output streams
#if 0
static IO::ParallelStreamBuffer DebugStreamBuffer1;
static IO::ParallelStreamBuffer DebugStreamBuffer2;
#else
static NullBufferClass DebugStreamBuffer1;
static NullBufferClass DebugStreamBuffer2;
#endif
std::ostream DebugStream1(&DebugStreamBuffer1);
std::ostream DebugStream2(&DebugStreamBuffer2);
// ****************************************************************************
// Method: avtLBMFileFormat constructor
//
// Programmer: mbt -- generated by xml2avt
// Creation: Wed Jul 9 10:59:08 PDT 2014
//
// ****************************************************************************
avtLBMFileFormat::avtLBMFileFormat(const char *filename)
: avtMTMDFileFormat(filename)
{
// Set abort behavior
Utilities::setAbortBehavior(true,true,true);
Utilities::setErrorHandlers();
// Set debug streams
DebugStreamBuffer1.setOutputStream( &DebugStream::Stream1() );
DebugStreamBuffer2.setOutputStream( &DebugStream::Stream2() );
DebugStreamBuffer1.setOutputStream( &std::cout );
// Get the path to the input file
std::string file(filename);
size_t k1 = file.rfind(47);
size_t k2 = file.rfind(92);
if ( k1==std::string::npos ) { k1=0; }
if ( k2==std::string::npos ) { k2=0; }
d_path = file.substr(0,std::max(k1,k2));
// Load the summary file
DebugStream1 << "Loading " << filename << std::endl;
d_timesteps = IO::readTimesteps(filename);
// Read the mesh dabases
d_database.clear();
d_database.resize(d_timesteps.size());
for (size_t i=0; i<d_timesteps.size(); i++)
d_database[i] = IO::getMeshList(d_path,d_timesteps[i]);
}
// ****************************************************************************
// Method: avtEMSTDFileFormat::GetNTimesteps
//
// Purpose:
// Tells the rest of the code how many timesteps there are in this file.
//
// Programmer: mbt -- generated by xml2avt
// Creation: Wed Jul 9 10:59:08 PDT 2014
//
// ****************************************************************************
int
avtLBMFileFormat::GetNTimesteps(void)
{
DebugStream2 << "avtLBMFileFormat::GetNTimesteps" << std::endl;
return static_cast<int>(d_timesteps.size());
}
// ****************************************************************************
// Method: avtLBMFileFormat::FreeUpResources
//
// Purpose:
// When VisIt is done focusing on a particular timestep, it asks that
// timestep to free up any resources (memory, file descriptors) that
// it has associated with it. This method is the mechanism for doing
// that.
//
// Programmer: mbt -- generated by xml2avt
// Creation: Wed Jul 9 10:59:08 PDT 2014
//
// ****************************************************************************
void
avtLBMFileFormat::FreeUpResources(void)
{
DebugStream1 << "avtLBMFileFormat::FreeUpResources" << std::endl;
std::map<std::string,vtkObjectBase*>::iterator it;
for ( it=d_meshcache.begin(); it!=d_meshcache.end(); ++it ) {
DebugStream2 << " deleting: " << it->first << std::endl;
vtkObjectBase* obj = it->second;
it->second = NULL;
if ( obj!=NULL )
obj->Delete();
}
DebugStream2 << " finished" << std::endl;
}
// ****************************************************************************
// Method: avtLBMFileFormat::PopulateDatabaseMetaData
//
// Purpose:
// This database meta-data object is like a table of contents for the
// file. By populating it, you are telling the rest of VisIt what
// information it can request from you.
//
// Programmer: mbt -- generated by xml2avt
// Creation: Wed Jul 9 10:59:08 PDT 2014
//
// ****************************************************************************
void
avtLBMFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md, int timestate)
{
DebugStream1 << "avtLBMFileFormat::PopulateDatabaseMetaData: " << timestate << std::endl;
// Add the mesh domains to the meta data
const std::vector<IO::MeshDatabase> database = d_database[timestate];
for (size_t i=0; i<database.size(); i++) {
DebugStream2 << " Adding " << database[i].name << std::endl;
avtMeshMetaData *mmd = new avtMeshMetaData;
mmd->name = database[i].name;
mmd->meshType = vtkMeshType(database[i].type);
mmd->spatialDimension = 3;
mmd->topologicalDimension = vtkTopDim(database[i].type);
if ( mmd->meshType==AVT_SURFACE_MESH )
mmd->topologicalDimension = 2;
mmd->numBlocks = database[i].domains.size();
mmd->blockNames.resize( mmd->numBlocks );
for (int j=0; j<mmd->numBlocks; j++)
mmd->blockNames[j] = database[i].domains[j].name;
md->Add(mmd);
// Add expressions for the coordinates
const char *xyz[3] = {"x","y","z"};
for(int j=0; j<3; j++) {
Expression expr;
char expdef[100], expname[100];
sprintf(expdef,"coord(<%s>)[%i]",mmd->name.c_str(),j);
sprintf(expname,"%s/%s",xyz[j],mmd->name.c_str());
expr.SetName(expname);
expr.SetDefinition(expdef);
md->AddExpression(&expr);
}
// Add the variables
for (size_t j=0; j<database[i].variables.size(); j++) {
IO::VariableDatabase variable = database[i].variables[j];
std::string varname = variable.name + "/" + mmd->name;
avtCentering center = AVT_UNKNOWN_CENT;
if ( variable.type==IO::VariableType::NodeVariable ) {
center = AVT_NODECENT;
} else if ( variable.type==IO::VariableType::SurfaceVariable ) {
center = AVT_ZONECENT;
} else if ( variable.type==IO::VariableType::VolumeVariable ) {
center = AVT_ZONECENT;
}
if ( variable.dim==1 ) {
AddScalarVarToMetaData( md, varname, mmd->name, center );
} else if ( variable.dim==3 ) {
AddVectorVarToMetaData( md, varname, mmd->name, center, variable.dim );
} else if ( variable.dim==9 ) {
AddTensorVarToMetaData( md, varname, mmd->name, center, variable.dim );
}
}
}
DebugStream2 << " Finished" << std::endl;
//
// CODE TO ADD A MATERIAL
//
// string mesh_for_mat = meshname; // ??? -- could be multiple meshes
// string matname = ...
// int nmats = ...;
// vector<string> mnames;
// for (int i = 0 ; i < nmats ; i++)
// {
// char str[32];
// sprintf(str, "mat%d", i);
// -- or --
// strcpy(str, "Aluminum");
// mnames.push_back(str);
// }
//
// Here's the call that tells the meta-data object that we have a mat:
//
// AddMaterialToMetaData(md, matname, mesh_for_mat, nmats, mnames);
//
//
// Here's the way to add expressions:
//Expression momentum_expr;
//momentum_expr.SetName("momentum");
//momentum_expr.SetDefinition("{u, v}");
//momentum_expr.SetType(Expression::VectorMeshVar);
//md->AddExpression(&momentum_expr);
//Expression KineticEnergy_expr;
//KineticEnergy_expr.SetName("KineticEnergy");
//KineticEnergy_expr.SetDefinition("0.5*(momentum*momentum)/(rho*rho)");
//KineticEnergy_expr.SetType(Expression::ScalarMeshVar);
//md->AddExpression(&KineticEnergy_expr);
//
}
// ****************************************************************************
// Method: avtLBMFileFormat::GetMesh
//
// Purpose:
// Gets the mesh associated with this file. The mesh is returned as a
// derived type of vtkDataSet (ie vtkRectilinearGrid, vtkStructuredGrid,
// vtkUnstructuredGrid, etc).
//
// Arguments:
// timestate The index of the timestate. If GetNTimesteps returned
// 'N' time steps, this is guaranteed to be between 0 and N-1.
// domain The index of the domain. If there are NDomains, this
// value is guaranteed to be between 0 and NDomains-1,
// regardless of block origin.
// meshname The name of the mesh of interest. This can be ignored if
// there is only one mesh.
//
// Programmer: mbt -- generated by xml2avt
// Creation: Wed Jul 9 10:59:08 PDT 2014
//
// ****************************************************************************
vtkDataSet *
avtLBMFileFormat::GetMesh(int timestate, int domain, const char *meshname)
{
DebugStream1 << "avtLBMFileFormat::GetMesh - " << meshname
<< "," << timestate << "," << domain << std::endl;
TIME_TYPE start, stop, freq;
get_frequency(&freq);
get_time(&start);
// Check if we have a cached copy of the mesh
char cache_name[1000];
sprintf(cache_name,"%i-%i-%s",timestate,domain,meshname);
if ( d_meshcache.find(cache_name)!=d_meshcache.end() )
return dynamic_cast<vtkDataSet*>(d_meshcache.find(cache_name)->second);
// Read the mesh
std::shared_ptr<IO::Mesh> mesh;
const std::vector<IO::MeshDatabase> database = d_database[timestate];
const std::string timestep = d_timesteps[timestate];
for (size_t i=0; i<database.size(); i++) {
if ( database[i].name==std::string(meshname) ) {
DebugStream2 << " calling getMesh" << std::endl;
try {
mesh = IO::getMesh(d_path,timestep,database[i],domain);
} catch (const std::exception &err) {
DebugStream1 << " Caught errror calling getMesh:" << std::endl;
DebugStream1 << err.what() << std::endl;
} catch (...) {
DebugStream1 << " Caught unknown errror calling getMesh" << std::endl;
return NULL;
}
}
}
if ( mesh==NULL ) {
DebugStream1 << " Error loading mesh" << std::endl;
return NULL;
}
// Create the mesh in vtk
vtkDataSet* vtkMesh = meshToVTK(mesh);
DebugStream2 << " mesh created:" << std::endl;
ASSERT(vtkMesh!=NULL);
DebugStream2 << " " << vtkMesh->GetNumberOfCells() << std::endl;
vtkMesh->PrintSelf(DebugStream2,vtkIndent(6));
// Cache the mesh and return
// meshcache[cache_name] = mesh;
get_time(&stop);
DebugStream2 << " Time required: " << get_diff(start,stop,freq) << std::endl;
return vtkMesh;
}
// ****************************************************************************
// Method: avtLBMFileFormat::GetVar
//
// Purpose:
// Gets a scalar variable associated with this file. Although VTK has
// support for many different types, the best bet is vtkFloatArray, since
// that is supported everywhere through VisIt.
//
// Arguments:
// timestate The index of the timestate. If GetNTimesteps returned
// 'N' time steps, this is guaranteed to be between 0 and N-1.
// domain The index of the domain. If there are NDomains, this
// value is guaranteed to be between 0 and NDomains-1,
// regardless of block origin.
// varname The name of the variable requested.
//
// Programmer: mbt -- generated by xml2avt
// Creation: Wed Jul 9 10:59:08 PDT 2014
//
// ****************************************************************************
vtkDataArray *
avtLBMFileFormat::GetVar(int timestate, int domain, const char *meshvarname)
{
DebugStream1 << "avtLBMFileFormat::GetVar: " << meshvarname
<< "," << timestate << "," << domain << std::endl;
std::vector<std::string> tmp = IO::splitList(meshvarname,'/');
ASSERT(tmp.size()==2);
std::string varname = tmp[0];
std::string meshname = tmp[1];
const std::vector<IO::MeshDatabase> database = d_database[timestate];
const std::string timestep = d_timesteps[timestate];
std::shared_ptr<const IO::Variable> variable;
for (size_t i=0; i<database.size(); i++) {
if ( database[i].name==std::string(meshname) ) {
DebugStream2 << " calling getVar" << std::endl;
try {
variable = IO::getVariable(d_path,timestep,database[i],domain,varname);
} catch (const std::exception &err) {
DebugStream1 << " Caught errror calling getVar:" << std::endl;
DebugStream1 << err.what() << std::endl;
} catch (...) {
DebugStream1 << " Caught unknown errror calling getVar" << std::endl;
return NULL;
}
}
}
if ( variable == NULL )
EXCEPTION1(InvalidVariableException, varname);
vtkDataArray* vtkVar = varToVTK(variable);
return vtkVar;
}
// ****************************************************************************
// Method: avtLBMFileFormat::GetVectorVar
//
// Purpose:
// Gets a vector variable associated with this file. Although VTK has
// support for many different types, the best bet is vtkFloatArray, since
// that is supported everywhere through VisIt.
//
// Arguments:
// timestate The index of the timestate. If GetNTimesteps returned
// 'N' time steps, this is guaranteed to be between 0 and N-1.
// domain The index of the domain. If there are NDomains, this
// value is guaranteed to be between 0 and NDomains-1,
// regardless of block origin.
// varname The name of the variable requested.
//
// Programmer: mbt -- generated by xml2avt
// Creation: Wed Jul 9 10:59:08 PDT 2014
//
// ****************************************************************************
vtkDataArray *
avtLBMFileFormat::GetVectorVar(int timestate, int domain, const char *varname)
{
cerr << "avtLBMFileFormat::GetVectorVar - " << varname
<< "," << timestate << "," << domain << std::endl;
DebugStream1 << "avtLBMFileFormat::GetVectorVar" << std::endl;
EXCEPTION1(InvalidVariableException, varname);
return NULL;
//
// If you have a file format where variables don't apply (for example a
// strictly polygonal format like the STL (Stereo Lithography) format,
// then uncomment the code below.
//
// EXCEPTION1(InvalidVariableException, varname);
//
//
// If you do have a vector variable, here is some code that may be helpful.
//
// int ncomps = YYY; // This is the rank of the vector - typically 2 or 3.
// int ntuples = XXX; // this is the number of entries in the variable.
// vtkFloatArray *rv = vtkFloatArray::New();
// int ucomps = (ncomps == 2 ? 3 : ncomps);
// rv->SetNumberOfComponents(ucomps);
// rv->SetNumberOfTuples(ntuples);
// float *one_entry = new float[ucomps];
// for (int i = 0 ; i < ntuples ; i++)
// {
// int j;
// for (j = 0 ; j < ncomps ; j++)
// one_entry[j] = ...
// for (j = ncomps ; j < ucomps ; j++)
// one_entry[j] = 0.;
// rv->SetTuple(i, one_entry);
// }
//
// delete [] one_entry;
// return rv;
//
}

View File

@ -1,115 +0,0 @@
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// avtLBMFileFormat.h //
// ************************************************************************* //
#ifndef AVT_LBM_FILE_FORMAT_H
#define AVT_LBM_FILE_FORMAT_H
#include <vtkObjectBase.h>
#include <avtMTMDFileFormat.h>
#include <vector>
#include <map>
#include "IO/MeshDatabase.h"
// ****************************************************************************
// Class: avtLBMFileFormat
//
// Purpose:
// Reads in LBM files as a plugin to VisIt.
//
// Programmer: mbt -- generated by xml2avt
// Creation: Wed Jul 9 10:59:08 PDT 2014
//
// ****************************************************************************
class avtLBMFileFormat : public avtMTMDFileFormat
{
public:
avtLBMFileFormat(const char *);
virtual ~avtLBMFileFormat() {;};
//
// This is used to return unconvention data -- ranging from material
// information to information about block connectivity.
//
// virtual void *GetAuxiliaryData(const char *var, int timestep,
// int domain, const char *type, void *args,
// DestructorFunction &);
//
//
// If you know the times and cycle numbers, overload this function.
// Otherwise, VisIt will make up some reasonable ones for you.
//
// virtual void GetCycles(std::vector<int> &);
// virtual void GetTimes(std::vector<double> &);
//
virtual int GetNTimesteps(void);
virtual const char *GetType(void) { return "LBM"; };
virtual void FreeUpResources(void);
virtual vtkDataSet *GetMesh(int, int, const char *);
virtual vtkDataArray *GetVar(int, int, const char *);
virtual vtkDataArray *GetVectorVar(int, int, const char *);
protected:
// Populate the databes
virtual void PopulateDatabaseMetaData(avtDatabaseMetaData*, int);
// Helper typedefs
typedef std::pair<std::string,int> mesh_key;
// DATA MEMBERS
std::string d_path;
std::vector<std::string> d_timesteps;
std::vector<std::vector<IO::MeshDatabase> > d_database;
std::map<std::string,vtkObjectBase*> d_meshcache;
};
#endif

View File

@ -1,10 +0,0 @@
# visit -debug 1 -valgrind engine_ser -cli -s /projects/JamesClure/LBPM-WIA/visit/testVisit.py
OpenDatabase("localhost:/projects/JamesClure/build/debug/tests/summary.LBM", 0)
#AddPlot("Mesh", "pointmesh", 1, 1)
AddPlot("Mesh", "trilist", 1, 1)
DrawPlots()
#quit()

View File

@ -1,223 +0,0 @@
// vtk headers
#include <vtkFloatArray.h>
#include <vtkRectilinearGrid.h>
#include <vtkStructuredGrid.h>
#include <vtkUnstructuredGrid.h>
#include <vtkPointSet.h>
#include <vtkCellType.h>
#include <vtkPolyData.h>
#include <vtkCellArray.h>
#include <vtkDoubleArray.h>
#include <vtkStructuredGrid.h>
// LBPM headers
#include "IO/Mesh.h"
#include "IO/MeshDatabase.h"
extern std::ostream DebugStream1;
extern std::ostream DebugStream2;
// Convert a point array to vtkFloatArray
inline vtkFloatArray* pointToVTK( const std::vector<Point>& points )
{
vtkFloatArray *coords = vtkFloatArray::New();
coords->SetNumberOfComponents(3);
coords->SetNumberOfTuples(points.size());
for (size_t i=0; i<points.size(); i++)
coords->SetTuple3(i,points[i].x,points[i].y,points[i].z);
return coords;
}
// Return the mesh type
inline avtMeshType vtkMeshType( IO::MeshType meshType )
{
avtMeshType vtkType = AVT_UNKNOWN_MESH;
if ( meshType==IO::PointMesh )
vtkType = AVT_POINT_MESH;
else if ( meshType==IO::SurfaceMesh )
vtkType = AVT_SURFACE_MESH;
else if ( meshType==IO::VolumeMesh )
vtkType = AVT_RECTILINEAR_MESH;
return vtkType;
}
// Return the topological dimension
inline int vtkTopDim( IO::MeshType meshType )
{
int dim = -1;
if ( meshType==IO::PointMesh )
dim = 1;
else if ( meshType==IO::SurfaceMesh )
dim = 2;
else if ( meshType==IO::VolumeMesh )
dim = 3;
return dim;
}
// Convert a PointList to vtkDataSet
inline vtkDataSet* PointListToVTK( std::shared_ptr<const IO::PointList> mesh )
{
vtkFloatArray *coords = pointToVTK(mesh->points);
vtkPoints *points = vtkPoints::New(VTK_FLOAT);
points->SetData(coords);
points->ComputeBounds();
size_t N = mesh->points.size();
vtkPolyData *vtkMesh = vtkPolyData::New();
vtkMesh->SetPoints(points);
vtkMesh->Allocate(N);
for (int i=0; i<(int)N; i++) {
vtkIdType ids[1] = {i};
vtkMesh->InsertNextCell(VTK_VERTEX,1,ids);
}
// vtkMesh->BuildCells();
vtkMesh->ComputeBounds();
points->Delete();
coords->Delete();
return vtkMesh;
}
// Convert a TriMesh to vtkDataSet
inline vtkDataSet* TriMeshToVTK( std::shared_ptr<const IO::TriMesh> mesh )
{
vtkFloatArray *coords = pointToVTK(mesh->vertices->points);
ASSERT(coords!=NULL);
vtkPoints *points = vtkPoints::New(VTK_FLOAT);
points->SetData(coords);
points->ComputeBounds();
const std::vector<int>& A = mesh->A;
const std::vector<int>& B = mesh->B;
const std::vector<int>& C = mesh->C;
size_t N_tri = A.size();
vtkPolyData *vtkMesh = vtkPolyData::New();
vtkMesh->SetPoints(points);
vtkMesh->Allocate(N_tri);
for (size_t i=0; i<N_tri; i++) {
vtkIdType ids[3] = {A[i],B[i],C[i]};
vtkMesh->InsertNextCell(VTK_TRIANGLE,3,ids);
}
vtkMesh->BuildCells();
vtkMesh->ComputeBounds();
points->Delete();
coords->Delete();
return vtkMesh;
}
// Convert a TriList to vtkDataSet
inline vtkDataSet* TriListToVTK( std::shared_ptr<const IO::TriList> mesh )
{
std::vector<LBPM_Point> point_set(3*mesh->A.size());
for (size_t i=0; i<mesh->A.size(); i++) {
point_set[3*i+0] = mesh->A[i];
point_set[3*i+1] = mesh->B[i];
point_set[3*i+2] = mesh->C[i];
}
vtkFloatArray *coords = pointToVTK(point_set);
ASSERT(coords!=NULL);
vtkPoints *points = vtkPoints::New(VTK_FLOAT);
points->SetData(coords);
points->ComputeBounds();
size_t N_tri = mesh->A.size();
vtkPolyData *vtkMesh = vtkPolyData::New();
vtkMesh->SetPoints(points);
vtkMesh->Allocate(N_tri);
for (int i=0; i<(int)N_tri; i++) {
vtkIdType ids[3] = {3*i+0,3*i+1,3*i+2};
vtkMesh->InsertNextCell(VTK_TRIANGLE,3,ids);
}
vtkMesh->BuildCells();
vtkMesh->ComputeBounds();
points->Delete();
coords->Delete();
return vtkMesh;
}
// Convert a DomainMesh to vtkDataSet
inline vtkDataSet* DomainToVTK( std::shared_ptr<const IO::DomainMesh> mesh )
{
int nx = mesh->nx;
int ny = mesh->ny;
int nz = mesh->nz;
if ( nx==0 || ny==0 || nz==0 ) {
DebugStream::Stream1() << " Domain mesh is empty" << std::endl;
return NULL;
}
RankInfoStruct rank_data(mesh->rank,mesh->nprocx,mesh->nprocy,mesh->nprocz);
vtkFloatArray *x = vtkFloatArray::New();
vtkFloatArray *y = vtkFloatArray::New();
vtkFloatArray *z = vtkFloatArray::New();
for(int i=0; i<=nx; i++)
x->InsertNextValue(static_cast<double>(nx*rank_data.ix+i)/static_cast<double>(nx*mesh->nprocx));
for(int j=0; j<=ny; j++)
y->InsertNextValue(static_cast<double>(ny*rank_data.jy+j)/static_cast<double>(ny*mesh->nprocy));
for(int k=0; k<=nz; k++)
z->InsertNextValue(static_cast<double>(nz*rank_data.kz+k)/static_cast<double>(nz*mesh->nprocz));
vtkRectilinearGrid *vtkMesh = vtkRectilinearGrid::New();
vtkMesh->SetDimensions(nx+1,ny+1,nz+1);
vtkMesh->SetXCoordinates(x);
vtkMesh->SetYCoordinates(y);
vtkMesh->SetZCoordinates(z);
vtkMesh->ComputeBounds();
x->Delete();
y->Delete();
z->Delete();
return vtkMesh;
}
// Convert a mesh to vtkDataSet
inline vtkDataSet* meshToVTK( std::shared_ptr<const IO::Mesh> mesh )
{
if ( mesh.get() == NULL ){
DebugStream::Stream1() << " Mesh is NULL" << std::endl;
return NULL;
}
vtkDataSet* mesh2 = NULL;
const std::string className = mesh->className();
if ( className == "PointList" ) {
// We are dealing with a point mesh
mesh2 = PointListToVTK( std::dynamic_pointer_cast<const IO::PointList>(mesh) );
DebugStream1 << " Point mesh created" << std::endl;
} else if ( className == "TriMesh" ) {
mesh2 = TriMeshToVTK( std::dynamic_pointer_cast<const IO::TriMesh>(mesh) );
DebugStream1 << " Surface mesh created" << std::endl;
} else if ( className == "TriList" ) {
mesh2 = TriListToVTK( std::dynamic_pointer_cast<const IO::TriList>(mesh) );
DebugStream1 << " Surface mesh created" << std::endl;
} else if ( className == "DomainMesh" ) {
mesh2 = DomainToVTK( std::dynamic_pointer_cast<const IO::DomainMesh>(mesh) );
DebugStream1 << " Volume mesh created" << std::endl;
} else {
//DebugStream1 << " Error, unknown mesh type" << std::endl;
return NULL;
}
return mesh2;
}
// Convert a variable to vtkDataSet
inline vtkDataArray* varToVTK( std::shared_ptr<const IO::Variable> var )
{
vtkFloatArray* var2 = NULL;
if ( var->dim==1 ) {
// Scalar variable
var2 = vtkFloatArray::New();
var2->SetNumberOfTuples(var->data.length());
for (size_t i=0; i<var->data.length(); i++)
var2->SetTuple1(i,var->data(i));
} else {
DebugStream::Stream1() << " Error, variable not yet supported" << std::endl;
return NULL;
}
return var2;
}