Commit 30c9b13b authored by cyrush's avatar cyrush

add initial MFEM db plugin

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@23703 18c085ea-50e0-402c-830e-de6fd14e8384
parent 4293ee0e
......@@ -177,6 +177,11 @@ ITAPS_LINK_DIRECTORIES(GRUMMP ${VISITHOME}/itaps/1.4/GRUMMP/0.6.5/${VISITARCH}/l
##
#VISIT_OPTION_DEFAULT(VISIT_MANTA_DIR ${VISITHOME}/manta/2540/${VISITARCH})
##
## MFEM
##
VISIT_OPTION_DEFAULT(VISIT_MFEM_DIR ${VISITHOME}/mfem/68e941f8fe/${VISITARCH})
##
## Mili
##
......
......@@ -277,6 +277,7 @@ CHECK_THIRDPARTY_DEPENDENT_PLUGINS(HDF4 Cosmos ZeusMP)
CHECK_THIRDPARTY_DEPENDENT_PLUGINS(MDSPLUS MDSplus)
CHECK_THIRDPARTY_DEPENDENT_PLUGINS(MILI Mili)
CHECK_THIRDPARTY_DEPENDENT_PLUGINS(UINTAH Uintah)
CHECK_THIRDPARTY_DEPENDENT_PLUGINS(MFEM MFEM)
IF (WIN32)
CHECK_THIRDPARTY_DEPENDENT_PLUGINS(ZLIB VCellMTMD)
ENDIF (WIN32)
......
# DO NOT EDIT THIS FILE! THIS FILE IS AUTOMATICALLY GENERATED BY xml2cmake
PROJECT(MFEM)
INCLUDE(${VISIT_SOURCE_DIR}/CMake/PluginMacros.cmake)
SET(COMMON_SOURCES
MFEMPluginInfo.C
MFEMCommonPluginInfo.C
)
SET(LIBI_SOURCES
MFEMPluginInfo.C
)
SET(LIBM_SOURCES
MFEMMDServerPluginInfo.C
${COMMON_SOURCES}
avtMFEMFileFormat.C
JSONRoot.C
)
SET(LIBE_SOURCES
MFEMEnginePluginInfo.C
${COMMON_SOURCES}
avtMFEMFileFormat.C
JSONRoot.C
)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${MFEM_INCLUDE_DIR}
${VISIT_INCLUDE_DIR}/third_party_builtin
${VISIT_COMMON_INCLUDES}
${VISIT_INCLUDE_DIR}/avt/DBAtts/MetaData
${VISIT_INCLUDE_DIR}/avt/DBAtts/SIL
${VISIT_INCLUDE_DIR}/avt/Database/Database
${VISIT_INCLUDE_DIR}/avt/Database/Formats
${VISIT_INCLUDE_DIR}/avt/Database/Ghost
${VISIT_INCLUDE_DIR}/avt/FileWriter
${VISIT_INCLUDE_DIR}/avt/Filters
${VISIT_INCLUDE_DIR}/avt/MIR/Base
${VISIT_INCLUDE_DIR}/avt/MIR/Tet
${VISIT_INCLUDE_DIR}/avt/MIR/Zoo
${VISIT_INCLUDE_DIR}/avt/Math
${VISIT_INCLUDE_DIR}/avt/Pipeline/AbstractFilters
${VISIT_INCLUDE_DIR}/avt/Pipeline/Data
${VISIT_INCLUDE_DIR}/avt/Pipeline/Pipeline
${VISIT_INCLUDE_DIR}/avt/Pipeline/Sinks
${VISIT_INCLUDE_DIR}/avt/Pipeline/Sources
${VISIT_INCLUDE_DIR}/avt/VisWindow/VisWindow
${VISIT_INCLUDE_DIR}/visit_vtk/full
${VISIT_INCLUDE_DIR}/visit_vtk/lightweight
${EAVL_INCLUDE_DIR}
${VTK_INCLUDE_DIRS}
)
LINK_DIRECTORIES(${VISIT_LIBRARY_DIR} ${EAVL_LIBRARY_DIR} ${VTK_LIBRARY_DIRS} ${MFEM_LIBRARY_DIR} )
ADD_LIBRARY(IMFEMDatabase ${LIBI_SOURCES})
TARGET_LINK_LIBRARIES(IMFEMDatabase visitcommon)
SET(INSTALLTARGETS IMFEMDatabase)
IF(NOT VISIT_ENGINE_ONLY AND NOT VISIT_DBIO_ONLY)
ADD_LIBRARY(MMFEMDatabase ${LIBM_SOURCES} )
TARGET_LINK_LIBRARIES(MMFEMDatabase visitcommon avtdbatts avtdatabase_ser ${MFEM_LIB} )
ADD_TARGET_DEFINITIONS(MMFEMDatabase MDSERVER)
SET(INSTALLTARGETS ${INSTALLTARGETS} MMFEMDatabase)
ENDIF(NOT VISIT_ENGINE_ONLY AND NOT VISIT_DBIO_ONLY)
ADD_LIBRARY(EMFEMDatabase_ser ${LIBE_SOURCES})
TARGET_LINK_LIBRARIES(EMFEMDatabase_ser visitcommon avtdatabase_ser avtpipeline_ser ${MFEM_LIB} )
ADD_TARGET_DEFINITIONS(EMFEMDatabase_ser ENGINE)
SET(INSTALLTARGETS ${INSTALLTARGETS} EMFEMDatabase_ser)
IF(VISIT_PARALLEL)
ADD_PARALLEL_LIBRARY(EMFEMDatabase_par ${LIBE_SOURCES})
TARGET_LINK_LIBRARIES(EMFEMDatabase_par visitcommon avtdatabase_par avtpipeline_par ${MFEM_LIB} )
ADD_TARGET_DEFINITIONS(EMFEMDatabase_par ENGINE)
SET(INSTALLTARGETS ${INSTALLTARGETS} EMFEMDatabase_par)
ENDIF(VISIT_PARALLEL)
VISIT_INSTALL_DATABASE_PLUGINS(${INSTALLTARGETS})
VISIT_PLUGIN_TARGET_RTOD(databases ${INSTALLTARGETS})
VISIT_PLUGIN_TARGET_FOLDER(databases MFEM ${INSTALLTARGETS})
<
/*****************************************************************************
*
* Copyright (c) 2000 - 2014, 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.
*
*****************************************************************************/
// ************************************************************************* //
// JSONRoot.C //
// ************************************************************************* //
#include <fstream>
#include "rapidjson/document.h"
#include "JSONRoot.h"
#include <iostream>
using namespace std;
// ****************************************************************************
// Method: JSONRootPath Constructor
//
// Purpose: Inits an instance of a JSONRootPath object.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRootPath::JSONRootPath()
:path("")
{
}
// ****************************************************************************
// Method: JSONRootPath Destructor
//
// Purpose: Cleans up an instance of a JSONRootPath object.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRootPath::~JSONRootPath()
{
}
// ****************************************************************************
// Method: JSONRootPath::Expand
//
// Purpose: Maps a doman id to is file system or in db path.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
std::string
JSONRootPath::Expand(int domain) const
{
//
// TODO: handle domain id mapping (likley printf style expansion)
//
return path;
}
// ****************************************************************************
// Method: JSONRootPath::Set
//
// Purpose: Sets the base pattern for a path.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
void
JSONRootPath::Set(const string &path)
{
this->path = path;
}
// ****************************************************************************
// Method: JSONRootEntry Constructor
//
// Purpose: Inits an instance of a JSONRootEntry object.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRootEntry::JSONRootEntry()
{
}
// ****************************************************************************
// Method: JSONRootEntry Destructor
//
// Purpose: Cleans up an instance of a JSONRootEntry object.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRootEntry::~JSONRootEntry()
{
}
// ****************************************************************************
// Method: JSONRootEntry::Path
//
// Purpose: Returns the path object associated with this entry.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRootPath &
JSONRootEntry::Path()
{
return path;
}
// ****************************************************************************
// Method: JSONRootEntry::Tags
//
// Purpose: Returns the names of the tags associated with this entry.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
void
JSONRootEntry::Tags(std::vector<std::string> &tag_names) const
{
tag_names.clear();
for(map<string,string>::const_iterator itr = tags.begin();
itr!=tags.end();
itr++)
{
tag_names.push_back(itr->first);
}
}
// ****************************************************************************
// Method: JSONRootEntry::HasTag
//
// Purpose: Returns if this entry has a tag with the given name.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
bool
JSONRootEntry::HasTag(const std::string &tag_name) const
{
return (tags.find(tag_name) != tags.end());
}
// ****************************************************************************
// Method: JSONRootEntry::Tag
//
// Purpose:
// Returns the tag with the given name.
// The tag is created if it doesn't already exist.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
std::string &
JSONRootEntry::Tag(const std::string &tag_name)
{
return tags[tag_name];
}
// ****************************************************************************
// Method: JSONRootDataSet Constructor
//
// Purpose: Inits an instance of a JSONRootEntry object.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRootDataSet::JSONRootDataSet()
{};
// ****************************************************************************
// Method: JSONRootDataSet Destructor
//
// Purpose: Cleans up an instance of a JSONRootEntry object.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRootDataSet::~JSONRootDataSet()
{};
// ****************************************************************************
// Method: JSONRootDataSet::NumberOfDomains
//
// Purpose: Returns the number of domains in the dataset.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
int
JSONRootDataSet::NumberOfDomains() const
{
return ndomains;
}
// ****************************************************************************
// Method: JSONRootDataSet::SetNumberOfDomains
//
// Purpose: Sets the number of domains in the dataset.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
void
JSONRootDataSet::SetNumberOfDomains(int ndomains)
{
this->ndomains = ndomains;
}
// ****************************************************************************
// Method: JSONRootDataSet::Mesh
//
// Purpose: Returns the mesh entry associated with this mesh.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRootEntry &
JSONRootDataSet::Mesh()
{
return mesh;
}
// ****************************************************************************
// Method: JSONRootDataSet::Fields
//
// Purpose: Returns the names of the fields associated with this dataset.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
void
JSONRootDataSet::Fields(std::vector<std::string> &field_names) const
{
field_names.clear();
for(map<string,JSONRootEntry>::const_iterator itr = fields.begin();
itr!=fields.end();
itr++)
{
field_names.push_back(itr->first);
}
}
// ****************************************************************************
// Method: JSONRootDataSet::Field
//
// Purpose:
// Returns the field with the given name.
// The field is created if it doesn't already exist.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRootEntry &
JSONRootDataSet::Field(const std::string &field_name)
{
return fields[field_name];
}
// ****************************************************************************
// Method: JSONRoot Constructor
//
// Purpose: Inits an instance of a JSONRootEntry object.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRoot::JSONRoot()
{
}
// ****************************************************************************
// Method: JSONRoot Constructor
//
// Purpose: Inits a JSONRoot object using the ParseJSON() method.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRoot::JSONRoot(const std::string &json_root)
{
ParseJSON(json_root);
}
// ****************************************************************************
// Method: JSONRoot Destructor
//
// Purpose: Cleans up an instance of a JSONRootEntry object.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRoot::~JSONRoot()
{
}
// ****************************************************************************
// Method: JSONRootDataSet::DataSets
//
// Purpose: Returns the names of the datasets in this root file.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
void
JSONRoot::DataSets(vector<string> &dset_names) const
{
dset_names.clear();
for(map<string,JSONRootDataSet>::const_iterator itr = dsets.begin();
itr!=dsets.end();
itr++)
{
dset_names.push_back(itr->first);
}
}
// ****************************************************************************
// Method: JSONRootDataSet::DataSet
//
// Purpose:
// Returns the dataset with the given name.
// The dataset is created if it doesn't already exist.
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
JSONRootDataSet &
JSONRoot::DataSet(const std::string &dset_name)
{
return dsets[dset_name];
}
// ****************************************************************************
// Method: JSONRootDataSet::NumberOfDataSets
//
// Purpose: Returns the number of datasets described by this root file.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
int
JSONRoot::NumberOfDataSets() const
{
return dsets.size();
}
// ****************************************************************************
// Method: JSONRoot::ParseJSON
//
// Purpose: Parses a JSON string into this JSONRoot object.
//
//
// Programmer: Cyrus Harrison
// Creation: Thu Jun 12 16:02:35 PDT 2014
//
// ****************************************************************************
void
JSONRoot::ParseJSON(const std::string &json_root)
{
// clear existing structure
dsets.clear();
// open root file and read its contents
ifstream iroot;
iroot.open(json_root.c_str());
std::string json((std::istreambuf_iterator<char>(iroot)),
std::istreambuf_iterator<char>());
// parse with rapidjson
rapidjson::Document document;
if(document.Parse<0>(json.c_str()).HasParseError())
{
// TODO: Throw VisIt Exception
cout << "ERROR PARSING JSON DATA" <<endl;
}
if(document.IsObject())
{
// handle datasets
if (document.HasMember("dsets"))
{
const rapidjson::Value &json_dsets = document["dsets"];
for (rapidjson::Value::ConstMemberIterator dsets_itr = json_dsets.MemberBegin();
dsets_itr != json_dsets.MemberEnd(); ++dsets_itr)
{
string curr_dset_name = dsets_itr->name.GetString();
JSONRootDataSet &curr_dset = DataSet(curr_dset_name);
const rapidjson::Value &json_dset = dsets_itr->value;
// handle # of domains, meshes w/ tags
curr_dset.SetNumberOfDomains(json_dset["domains"].GetInt());
curr_dset.Mesh().Path().Set(json_dset["mesh"]["path"].GetString());
if(json_dset["mesh"].HasMember("tags"))
{
const rapidjson::Value &mesh_tags = json_dset["mesh"]["tags"];
for (rapidjson::Value::ConstMemberIterator tags_itr = mesh_tags.MemberBegin();
tags_itr != mesh_tags.MemberEnd(); ++tags_itr)
{
curr_dset.Mesh().Tag(tags_itr->name.GetString()) = tags_itr->value.GetString();
}
}
// handle fields
if(json_dset.HasMember("fields"))
{
const rapidjson::Value &json_fields =json_dset["fields"];
for (rapidjson::Value::ConstMemberIterator fields_itr = json_fields.MemberBegin();
fields_itr != json_fields.MemberEnd(); ++fields_itr)
{
const rapidjson::Value &json_field = fields_itr->value;
string curr_field_name = fields_itr->name.GetString();
JSONRootEntry &curr_field = curr_dset.Field(curr_field_name);
curr_field.Path().Set(json_field["path"].GetString());
const rapidjson::Value &json_tags = json_field["tags"];
for (rapidjson::Value::ConstMemberIterator tags_itr = json_tags.MemberBegin();
tags_itr != json_tags.MemberEnd(); ++tags_itr)
{
curr_field.Tag(tags_itr->name.GetString()) = tags_itr->value.GetString();
}
}
}
}
}
}
}
// ****************************************************************************
// Method: JSONRoot::ToJson
//
// Purpose: Constructs a std::string with JSON that represent the JSONRoot.
//
//