Commit 8e3eae36 authored by Robert Maynard's avatar Robert Maynard
Browse files

Adding SAMRAI example

parent 1570d5ce
......@@ -204,6 +204,5 @@ add_subdirectory(common)
add_subdirectory(visit_vtk)
add_subdirectory(avt)
add_subdirectory(AvtAlgorithms)
add_subdirectory(VisItReader)
add_subdirectory(VisItFluentReader)
add_subdirectory(databases)
<ParaViewReaders>
<Reader name="VisItReader"
extensions="vis"
file_description="dummy file format for VisItReader Testing">
</Reader>
</ParaViewReaders>
\ No newline at end of file
/*****************************************************************************
*
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400124
* 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.
*
*****************************************************************************/
// ************************************************************************* //
// avtVisItReaderFileFormat.C //
// ************************************************************************* //
#include <avtVisItReaderFileFormat.h>
#include <string>
#include <vtkFloatArray.h>
#include <vtkPolyData.h>
#include <vtkCellArray.h>
#include <vtkPoints.h>
#include <vtkCubeSource.h>
#include <avtDatabaseMetaData.h>
#include <DBOptionsAttributes.h>
#include <Expression.h>
#include <InvalidVariableException.h>
// ****************************************************************************
// Method: avtVisItReaderFileFormat constructor
//
// Programmer: robert.maynard -- generated by xml2avt
// Creation: Thu May 20 13:42:07 PST 2010
//
// ****************************************************************************
avtVisItReaderFileFormat::avtVisItReaderFileFormat(const char *filename)
: avtSTSDFileFormat(filename)
{
//this 'reader' only generates a single triangle
}
// ****************************************************************************
// Method: avtVisItReaderFileFormat::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: robert.maynard -- generated by xml2avt
// Creation: Thu May 20 13:42:07 PST 2010
//
// ****************************************************************************
void
avtVisItReaderFileFormat::FreeUpResources(void)
{
}
// ****************************************************************************
// Method: avtVisItReaderFileFormat::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: robert.maynard -- generated by xml2avt
// Creation: Thu May 20 13:42:07 PST 2010
//
// ****************************************************************************
void
avtVisItReaderFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
{
avtMeshType mt = AVT_SURFACE_MESH;
std::string meshname = "mesh";
// Here's the call that tells the meta-data object that we have a mesh:
this->AddMeshToMetaData(md, meshname, mt);
//
// CODE TO ADD A SCALAR VARIABLE
//
// string mesh_for_this_var = meshname; // ??? -- could be multiple meshes
// string varname = ...
//
// AVT_NODECENT, AVT_ZONECENT, AVT_UNKNOWN_CENT
// avtCentering cent = AVT_NODECENT;
//
//
// Here's the call that tells the meta-data object that we have a var:
//
// AddScalarVarToMetaData(md, varname, mesh_for_this_var, cent);
//
//
// CODE TO ADD A VECTOR VARIABLE
//
// string mesh_for_this_var = meshname; // ??? -- could be multiple meshes
// string varname = ...
// int vector_dim = 2;
//
// AVT_NODECENT, AVT_ZONECENT, AVT_UNKNOWN_CENT
// avtCentering cent = AVT_NODECENT;
//
//
// Here's the call that tells the meta-data object that we have a var:
//
// AddVectorVarToMetaData(md, varname, mesh_for_this_var, cent,vector_dim);
//
//
// CODE TO ADD A TENSOR VARIABLE
//
// string mesh_for_this_var = meshname; // ??? -- could be multiple meshes
// string varname = ...
// int tensor_dim = 9;
//
// AVT_NODECENT, AVT_ZONECENT, AVT_UNKNOWN_CENT
// avtCentering cent = AVT_NODECENT;
//
//
// Here's the call that tells the meta-data object that we have a var:
//
// AddTensorVarToMetaData(md, varname, mesh_for_this_var, cent,tensor_dim);
//
//
// 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: avtVisItReaderFileFormat::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:
// meshname The name of the mesh of interest. This can be ignored if
// there is only one mesh.
//
// Programmer: robert.maynard -- generated by xml2avt
// Creation: Thu May 20 13:42:07 PST 2010
//
// ****************************************************************************
vtkDataSet *
avtVisItReaderFileFormat::GetMesh(const char *meshname)
{
if ( strcmp(meshname,"mesh") == 0 )
{
vtkCubeSource *cube = vtkCubeSource::New();
cube->SetXLength(1);
cube->SetYLength(10);
cube->SetZLength(4);
cube->Update();
vtkPolyData *mesh = vtkPolyData::New();
mesh->ShallowCopy( cube->GetOutput() );
cube->Delete();
return mesh;
}
else
{
EXCEPTION1(InvalidVariableException, meshname);
}
}
// ****************************************************************************
// Method: avtVisItReaderFileFormat::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:
// varname The name of the variable requested.
//
// Programmer: robert.maynard -- generated by xml2avt
// Creation: Thu May 20 13:42:07 PST 2010
//
// ****************************************************************************
vtkDataArray *
avtVisItReaderFileFormat::GetVar(const char *varname)
{
//
// 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 scalar variable, here is some code that may be helpful.
//
// int ntuples = XXX; // this is the number of entries in the variable.
// vtkFloatArray *rv = vtkFloatArray::New();
// rv->SetNumberOfTuples(ntuples);
// for (int i = 0 ; i < ntuples ; i++)
// {
// rv->SetTuple1(i, VAL); // you must determine value for ith entry.
// }
//
// return rv;
//
}
// ****************************************************************************
// Method: avtVisItReaderFileFormat::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:
// varname The name of the variable requested.
//
// Programmer: robert.maynard -- generated by xml2avt
// Creation: Thu May 20 13:42:07 PST 2010
//
// ****************************************************************************
vtkDataArray *
avtVisItReaderFileFormat::GetVectorVar(const char *varname)
{
//
// 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;
//
}
ADD_SUBDIRECTORY(Fluent)
#need HDF5 for SAMRAI
if (PARAVIEW_HDF5_LIBRARIES)
ADD_SUBDIRECTORY(SAMRAI)
endif(PARAVIEW_HDF5_LIBRARIES)
/*****************************************************************************
*
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400124
* 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.
*
*****************************************************************************/
template<class T>
class AutoArray
{
public:
AutoArray(int _size=1000, int _ainc=1000, bool _strict=false)
{ size = _size;
ainc = _ainc;
maxidx = -1;
strictSize = _strict;
dataRetrieved = false;
dummy = 0.0;
if (size <= 0)
size = 1000;
if (ainc <= 0)
ainc = 1000;
data = (T*) malloc(size * sizeof(T));
};
~AutoArray()
{
if (!dataRetrieved)
{
if (data != 0)
free(data);
}
};
int GetSize() const
{
if (dataRetrieved)
return size;
return -1;
};
T* GetData()
{
if (dataRetrieved)
return 0;
dataRetrieved = true;
if (strictSize || (maxidx+1 < size/2))
{
data = (T*) realloc((void*)data, (maxidx+1) * sizeof(T));
size = maxidx+1;
}
return data;
};
T& operator[](int idx)
{
if (dataRetrieved)
return dummy;
// check if we need to resize
if (idx >= size)
{
int newSize = size;
while (idx >= newSize)
newSize += ainc;
// do the resize
size = newSize;
data = (T*) realloc((void*)data, size * sizeof(T));
}
if (idx > maxidx)
maxidx = idx;
return data[idx];
}
private:
T* data;
int size;
int ainc;
int maxidx;
float dummy;
bool strictSize;
bool dataRetrieved;
};
PROJECT(VisItReader)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(VisItSAMRAIReader)
SET(SERVER_SOURCES
vtkVisItReader.h
vtkVisItReader.cxx
vtkVisItSAMRAIReader.h
vtkVisItSAMRAIReader.cxx
)
SET(EXTRA_SOURCES
avtVisItReaderFileFormat.h
avtVisItReaderFileFormat.C
VisItReaderCommonPluginInfo.C
VisItReaderEnginePluginInfo.C
VisItReaderMDServerPluginInfo.C
VisItReaderPluginInfo.h
VisItReaderPluginInfo.C
avtSAMRAIFileFormat.C
avtSAMRAIFileFormat.h
AutoArray.h
SAMRAIEnginePluginInfo.C
SAMRAIPluginInfo.C
SAMRAIPluginInfo.h
SAMRAICommonPluginInfo.C
SAMRAIMDServerPluginInfo.C
)
SET_SOURCE_FILES_PROPERTIES(
avtVisItReaderFileFormat.h
avtVisItReaderFileFormat.C
VisItReaderCommonPluginInfo.C
VisItReaderEnginePluginInfo.C
VisItReaderMDServerPluginInfo.C
VisItReaderPluginInfo.h
VisItReaderPluginInfo.C
WRAP_EXCLUDE)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${AVTALGORITHMS_BINARY_DIR}
${AVTALGORITHMS_SOURCE_DIR}
${VISIT_COMMON_INCLUDES}
${VISIT_SOURCE_DIR}/include
${AVT_DATABASE_SOURCE_DIR}/Database
${AVT_DATABASE_SOURCE_DIR}/Ghost
${AVT_DATABASE_SOURCE_DIR}/Formats
${VISIT_COMMON_INCLUDES}
${AVT_DBATTS_SOURCE_DIR}/MetaData
${AVT_DBATTS_SOURCE_DIR}/SIL
${VISIT_SOURCE_DIR}/avt/Math
......@@ -41,11 +36,12 @@ ${AVT_PIPELINE_SOURCE_DIR}/Pipeline
${AVT_PIPELINE_SOURCE_DIR}/Sinks
${AVT_PIPELINE_SOURCE_DIR}/Sources
${VTK_INCLUDE_DIRS}
)
ADD_PARAVIEW_PLUGIN(VisItReader "1.0"
)
ADD_PARAVIEW_PLUGIN(VisItSAMRAIReader "1.0"
SERVER_MANAGER_SOURCES ${SERVER_SOURCES}
SERVER_SOURCES ${EXTRA_SOURCES}
SERVER_MANAGER_XML VisItReader.xml
GUI_RESOURCE_FILES VisItReaderGUI.xml)
TARGET_LINK_LIBRARIES(VisItReader avtdatabase_ser visitcommon avtdbatts avtpipeline_ser visit_vtk)
SERVER_MANAGER_XML VisItSAMRAIReader.xml
GUI_RESOURCE_FILES VisItSAMRAIReaderGUI.xml)
TARGET_LINK_LIBRARIES(VisItSAMRAIReader ${PARAVIEW_HDF5_LIBRARIES} AVTAlgorithms)
......@@ -36,59 +36,54 @@
*
*****************************************************************************/
#include <VisItReaderPluginInfo.h>
#include <avtVisItReaderFileFormat.h>
#include <avtSTSDFileFormatInterface.h>
#include <SAMRAIPluginInfo.h>
#include <avtSAMRAIFileFormat.h>
#include <avtSTMDFileFormatInterface.h>
#include <avtGenericDatabase.h>
// ****************************************************************************
// Method: VisItReaderCommonPluginInfo::GetDatabaseType
// Method: SAMRAICommonPluginInfo::GetDatabaseType
//
// Purpose:
// Returns the type of a VisItReader database.
// Returns the type of a SAMRAI database.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// ****************************************************************************
DatabaseType
VisItReaderCommonPluginInfo::GetDatabaseType()
SAMRAICommonPluginInfo::GetDatabaseType()
{
return DB_TYPE_STSD;
return DB_TYPE_STMD;
}
// ****************************************************************************
// Method: VisItReaderCommonPluginInfo::SetupDatabase
// Method: SAMRAICommonPluginInfo::SetupDatabase
//
// Purpose:
// Sets up a VisItReader database.
// Sets up a SAMRAI database.
//
// Arguments: