/***************************************************************************** * * Copyright (c) 2000 - 2010, 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. * *****************************************************************************/ // ************************************************************************* // // avtCarpetN5FileFormat.h // // ************************************************************************* // #ifndef AVT_CarpetN5_FILE_FORMAT_H #define AVT_CarpetN5_FILE_FORMAT_H #include #include #include #include "CarpetN5.hh" #include using namespace std; using namespace Nirvana; class domain { public: domain() : _md(metadata()), _dim(0), _components(0), _ghosts(0), _npoints_ghosted(0), _origin_ghosted(0), _iorigin_ghosted(0), _npoints(0), _iorigin(0), _delta(0) { } domain(const metadata& md_) : _md(md_), _dim(3) { // extract metadata _comp = _md.QueryAttribute("comp").value(); _reflevel = _md.QueryAttribute("reflevel").value(); _npoints = _md.QueryAttribute >("lsh").value(); _iorigin = _md.QueryAttribute >("iorigin").value(); _delta = _md.QueryAttribute >("delta").value(); _origin = _md.QueryAttribute >("origin").value(); vector tmp = _md.QueryAttribute >("ghosts").value(); _ghosts = vector(_dim*2); for (int i=0; i < _dim; ++i) _ghosts[2*i] = _ghosts[2*i+1] = tmp[i]; // set nominal domain size _npoints_ghosted = vector(_dim); _iorigin_ghosted = vector(_dim); _origin_ghosted = vector(_dim); for (int d=0; d < _dim; d++) { if (_ghosts[2*d] > 0 || _ghosts[2*d+1] > 0) _npoints_ghosted[d] = _npoints[d] - _ghosts[2*d] - _ghosts[2*d+1] + 1; // adding a "1" assumes that we have a ghostzone from which we can take it! else _npoints_ghosted[d] = _npoints[d]; _iorigin_ghosted[d] = _iorigin[d] + _ghosts[2*d]; _origin_ghosted[d] = _origin[d] + _ghosts[2*d] * _delta[d]; if (_ghosts[2*d] > 0 || _ghosts[2*d+1] > 0) { if (_reflevel > 0 && _iorigin_ghosted[d] % int(pow(2, 1)) > 0) { _npoints_ghosted[d] += 1; _iorigin_ghosted[d] -= 1; _origin_ghosted[d] -= _delta[d]; _ghosts[2*d] -= 1; } if (_reflevel > 0 && _npoints_ghosted[d] % int(pow(2, 1)) == 0) { _npoints_ghosted[d] -= 1; } } } } virtual ~domain() { } int reflevel() const { return _reflevel; } int comp() const { return _reflevel; } int dim() const { return _dim; } vector iorigin() const { return _iorigin_ghosted; } vector npoints() const { return _npoints_ghosted; } vector ghosts() const { return _ghosts; } vector delta() const { return _delta; } vector origin() const { return _origin_ghosted; } double xmin() const { return origin()[0]; } double ymin() const { return origin()[1]; } double zmin() const { return origin()[2]; } double xmax() const { return origin()[0] + (npoints()[0]-1) * delta()[0]; } double ymax() const { return origin()[1] + (npoints()[1]-1) * delta()[1]; } double zmax() const { return origin()[2] + (npoints()[2]-1) * delta()[2]; } metadata md() const { return _md; } private: metadata _md; int _dim; // domain property specific to curvilinear domains vector _components; // domain property specific to AMR int _reflevel; int _comp; vector _npoints; vector _iorigin; vector _origin; vector _delta; vector _ghosts; // size = dim*2, we store here lower and upper GZ-width vector _npoints_ghosted; vector _origin_ghosted; vector _iorigin_ghosted; }; class variable { public : variable() : _md(metadata()), _components(0) { } variable(const metadata& md_, const vector& components_) : _md(md_), _components(components_) { } virtual ~variable() { } metadata md() const { return _md; } /// variabale names of the components if this is a vector vector components() const { return _components; } /// the dimension of the variable if this is a vectorvar int dim() const { return _components.size(); } private : metadata _md; // the variable names of the components // if this variable is a vector vector _components; }; // **************************************************************************** // Class: avtCarpetN5FileFormat // // Purpose: // Reads in CarpetN5 files as a plugin to VisIt. // // Programmer: reisswig -- generated by xml2avt // Creation: Fri Aug 27 06:08:45 PDT 2010 // // **************************************************************************** class avtCarpetN5FileFormat : public avtMTMDFileFormat { public: avtCarpetN5FileFormat(const char *); virtual ~avtCarpetN5FileFormat() {;}; // // 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 &); // virtual int GetNTimesteps(void); virtual const char *GetType(void) { return "CarpetN5"; }; 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 : // DATA MEMBERS virtual void PopulateDatabaseMetaData(avtDatabaseMetaData *, int); /// provide AMR info to the visit cache virtual void BuildDomainAuxiliaryInfo(int timeState); // // 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& c); virtual void GetTimes(std::vector& t); // // MetaData has to be read in for each new timestate virtual bool HasInvariantMetaData(void) const { return false; }; virtual bool HasInvariantSIL(void) const { return false; }; private: // metadata for the current timestep vector domainsAMR; vector domainsCurvilinear; // number of reflevels int nlevels; map vectorvars; map scalarvars; CarpetN5 File; }; #endif