VTK
dox/IO/vtkMPASReader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkPCosmoReader.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 /*=========================================================================
00016 
00017   Program:   VTK/ParaView Los Alamos National Laboratory Modules (PVLANL)
00018   Module:    vtkPCosmoReader.h
00019 
00020 Copyright (c) 2010 Los Alamos National Security, LLC
00021 
00022 All rights reserved.
00023 
00024 Copyright 2010. Los Alamos National Security, LLC.
00025 This software was produced under U.S. Government contract DE-AC52-06NA25396
00026 for Los Alamos National Laboratory (LANL), which is operated by
00027 Los Alamos National Security, LLC for the U.S. Department of Energy.
00028 The U.S. Government has rights to use, reproduce, and distribute this software.
00029 NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY,
00030 EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE.
00031 If software is modified to produce derivative works, such modified software
00032 should be clearly marked, so as not to confuse it with the version available
00033 from LANL.
00034 
00035 Additionally, redistribution and use in source and binary forms, with or
00036 without modification, are permitted provided that the following conditions
00037 are met:
00038 -   Redistributions of source code must retain the above copyright notice,
00039     this list of conditions and the following disclaimer.
00040 -   Redistributions in binary form must reproduce the above copyright notice,
00041     this list of conditions and the following disclaimer in the documentation
00042     and/or other materials provided with the distribution.
00043 -   Neither the name of Los Alamos National Security, LLC, Los Alamos National
00044     Laboratory, LANL, the U.S. Government, nor the names of its contributors
00045     may be used to endorse or promote products derived from this software
00046     without specific prior written permission.
00047 
00048 THIS SOFTWARE IS PROVIDED BY LOS ALAMOS NATIONAL SECURITY, LLC AND CONTRIBUTORS
00049 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00050 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00051 ARE DISCLAIMED. IN NO EVENT SHALL LOS ALAMOS NATIONAL SECURITY, LLC OR
00052 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00053 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00054 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00055 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00056 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00057 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00058 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00059 
00060 =========================================================================*/
00080 #ifndef __vtkMPASReader_h
00081 #define __vtkMPASReader_h
00082 
00083 #define MAX_VARS 100
00084 #define MAX_VAR_NAME 100
00085 
00086 #include "vtkUnstructuredGridAlgorithm.h"
00087 
00088 class vtkCallbackCommand;
00089 class vtkDataArraySelection;
00090 class vtkFloatArray;
00091 class vtkStdString;
00092 class vtkStringArray;
00093 
00094 class vtkInternals;
00095 
00096 class VTK_IO_EXPORT vtkMPASReader : public vtkUnstructuredGridAlgorithm
00097 {
00098  public:
00099   static vtkMPASReader *New();
00100   vtkTypeMacro(vtkMPASReader,vtkUnstructuredGridAlgorithm);
00101   void PrintSelf(ostream& os, vtkIndent indent);
00102 
00104 
00105   vtkSetStringMacro(FileName);
00106   vtkGetStringMacro(FileName);
00108 
00110 
00111   vtkGetMacro(NumberOfDualCells, int);
00113 
00115 
00116   vtkGetMacro(NumberOfDualPoints, int);
00118 
00120 
00121   vtkGetMacro(NumberOfVariables, int);
00123 
00125 
00126   vtkUnstructuredGrid *GetOutput();
00127   vtkUnstructuredGrid *GetOutput(int index);
00129 
00131 
00134   int GetNumberOfPointArrays();
00135   const char* GetPointArrayName(int index);
00136   int GetPointArrayStatus(const char* name);
00137   void SetPointArrayStatus(const char* name, int status);
00138   void DisableAllPointArrays();
00139   void EnableAllPointArrays();
00141 
00142   int GetNumberOfCellArrays();
00143   const char* GetCellArrayName(int index);
00144   int GetCellArrayStatus(const char* name);
00145   void SetCellArrayStatus(const char* name, int status);
00146   void DisableAllCellArrays();
00147   void EnableAllCellArrays();
00148   void SetVerticalLevel(int level);
00149   vtkGetVector2Macro(VerticalLevelRange, int);
00150 
00152   static int CanReadFile(const char *filename);
00153 
00154  protected:
00155   vtkMPASReader();
00156   ~vtkMPASReader();
00157 
00158   char *FileName;         // First field part file giving path
00159   /*
00160     int Rank;               // Number of this processor
00161     int TotalRank;          // Number of processors
00162   */
00163 
00164   //  int NumberOfPieces;         // Number of files in dataset
00165   vtkIdType NumberOfDualPoints;       // Number of points in grid
00166   vtkIdType NumberOfDualCells;        // Number of cells in grid
00167   // vtkIdType NumberOfTuples;        // Number of tuples in sub extent
00168 
00169   int NumberOfVariables;      // Number of variables to display
00170   vtkStdString* VariableName;     // Names of each variable
00171   int* VariableType;          // Scalar, vector or tensor
00172 
00173   int NumberOfTimeSteps;      // Temporal domain
00174   double* TimeSteps;          // Times available for request
00175   double dTime;
00176 
00177   vtkFloatArray** dualCellVarData;    // Actual data arrays
00178   vtkFloatArray** dualPointVarData;   // Actual data arrays
00179 
00180   // Selected field of interest
00181   vtkDataArraySelection* PointDataArraySelection;
00182   vtkDataArraySelection* CellDataArraySelection;
00183 
00184   int VerticalLevelSelected;
00185   int VerticalLevelRange[2];
00186 
00187   // Observer to modify this object when array selections are modified
00188   vtkCallbackCommand* SelectionObserver;
00189 
00190   int RequestData(vtkInformation *, vtkInformationVector **,
00191                   vtkInformationVector *);
00192   int RequestInformation(vtkInformation *, vtkInformationVector **,
00193                          vtkInformationVector *);
00194 
00195   void LoadGeometryData(int var, double dTime);
00196   void LoadPointData(int var);
00197   void LoadCellData(int var);
00198 
00199   static void SelectionCallback(vtkObject* caller, unsigned long eid,
00200                                 void* clientdata, void* calldata);
00201 
00202   bool infoRequested;
00203   bool dataRequested;
00204 
00205   vtkInternals *Internals;
00206 
00207   char tracerNames[MAX_VAR_NAME][MAX_VARS];
00208   int numDualCellVars;
00209   int numDualPointVars;
00210   double* primalPointVarData;
00211   double* primalCellVarData;
00212   int ReadAndOutputDualGrid();
00213   int ReadAndOutputVariableData();
00214   int LoadPointVarData(int variable, double dTime);
00215   int LoadCellVarData(int variable, double dTime);
00216   int BuildVarArrays();
00217 
00218  private:
00219   vtkMPASReader(const vtkMPASReader&);    // Not implemented.
00220   void operator=(const vtkMPASReader&); // Not implemented.
00221 
00222 };
00223 
00224 #endif