• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Albany_StateInfoStruct.hpp

Go to the documentation of this file.
00001 //*****************************************************************//
00002 //    Albany 2.0:  Copyright 2012 Sandia Corporation               //
00003 //    This Software is released under the BSD license detailed     //
00004 //    in the file "license.txt" in the top-level Albany directory  //
00005 //*****************************************************************//
00006 
00007 #ifndef ALBANY_STATEINFOSTRUCT
00008 #define ALBANY_STATEINFOSTRUCT
00009 
00010 // THis file containts two structs that are containers for the
00011 // Albany::Problem to interface to STK::Mesh.
00012 // (1) The MeshSpecsStruct holds information that is loaded mostly
00013 //     from STK::metaData, which is needed to create an Albany::Problem.
00014 //     This includes worksetSize, CellTopologyData, etc.
00015 // (2) The StateInfoStruct contains information from the Problem
00016 //     (via the State Manager) that is used by STK to define Fields.
00017 //     This includes name, number of quantitites (scalar,vector,tensor),
00018 //     Element vs Node lcoation, etc.
00019 
00020 #include <string>
00021 #include <vector>
00022 #include "Shards_CellTopologyData.h"
00023 #include "Shards_Array.hpp"
00024 #include "Intrepid_Polylib.hpp"
00025 
00026 #include "Adapt_NodalDataBlock.hpp"
00027 
00029   //  construct an Albany Problem
00030 
00031 namespace Albany {
00032 
00033 typedef shards::Array<double, shards::NaturalOrder> MDArray;
00034 typedef std::map< std::string, MDArray > StateArray;
00035 typedef std::vector<StateArray> StateArrayVec;
00036 
00037   struct StateArrays {
00038     StateArrayVec elemStateArrays;
00039     StateArrayVec nodeStateArrays;
00040   };
00041 
00042   struct MeshSpecsStruct {
00043     MeshSpecsStruct(const CellTopologyData& ctd_, int numDim_, 
00044                     int cubatureDegree_, std::vector<std::string> nsNames_,
00045                     std::vector<std::string> ssNames_,
00046                     int worsetSize_, const std::string ebName_,
00047                     const std::map<std::string, int>& ebNameToIndex_, bool interleavedOrdering_,
00048                     const Intrepid::EIntrepidPLPoly cubatureRule_ = Intrepid::PL_GAUSS)
00049        :  ctd(ctd_), numDim(numDim_), cubatureDegree(cubatureDegree_),
00050           nsNames(nsNames_), ssNames(ssNames_), worksetSize(worsetSize_), 
00051           ebName(ebName_), ebNameToIndex(ebNameToIndex_),
00052           interleavedOrdering(interleavedOrdering_),
00053           cubatureRule(cubatureRule_) {}
00054     CellTopologyData ctd;  // nonconst to allow replacement when the mesh adapts
00055     int numDim;
00056     int cubatureDegree;
00057     std::vector<std::string> nsNames;  //Node Sets Names
00058     std::vector<std::string> ssNames;  //Side Sets Names
00059     int worksetSize;
00060     const std::string ebName;  //Element block name for the EB that this struct corresponds to
00061     const std::map<std::string, int>& ebNameToIndex;
00062     bool interleavedOrdering;
00063     const Intrepid::EIntrepidPLPoly cubatureRule;
00064   };
00065 
00067 //  the information can continue to evolve without changing the interfaces.
00068 
00069 struct StateStruct {
00070 
00071   enum MeshFieldEntity {WorksetValue, NodalData, ElemNode, QuadPoint};
00072   typedef std::vector<int> FieldDims;
00073 
00074   StateStruct (const std::string& name_, MeshFieldEntity ent): 
00075         name(name_), responseIDtoRequire(""), output(true), 
00076   restartDataAvailable(false), saveOldState(false), pParentStateStruct(NULL), entity(ent)
00077   {};
00078 
00079   StateStruct (const std::string& name_, MeshFieldEntity ent, const FieldDims& dims, const std::string& type): 
00080         name(name_), responseIDtoRequire(""), output(true), dim(dims), initType(type),
00081   restartDataAvailable(false), saveOldState(false), pParentStateStruct(NULL), entity(ent)
00082   {};
00083 
00084   void setInitType(const std::string& type) { initType = type; }
00085   void setInitValue(const double val) { initValue = val; }
00086   void setFieldDims(const FieldDims& dims) { dim = dims; }
00087 
00088   void print(){
00089 
00090     std::cout << "StateInfoStruct diagnostics for : " << name << std::endl;
00091     std::cout << "Dimensions : " << std::endl;
00092     for(unsigned int i = 0; i < dim.size(); i++)
00093        std::cout << "    " << i << " " << dim[i] << std::endl;
00094     std::cout << "Entity : " << entity << std::endl;
00095   }
00096 
00097   const std::string name;
00098   FieldDims dim;
00099   MeshFieldEntity entity;
00100   std::string initType;
00101   double initValue;
00102   std::map<std::string, std::string> nameMap;
00103 
00104   //For proper PHAL_SaveStateField functionality - maybe only needed temporarily?
00105   std::string responseIDtoRequire; //If nonzero length, the responseID for response 
00106                                    // field manager to require (assume dummy data layout)
00107   bool output;
00108   bool restartDataAvailable;
00109   bool saveOldState; // Bool that this state is to be copied into name+"_old"
00110   StateStruct *pParentStateStruct; // If this is a copy (name = parentName+"_old"), ptr to parent struct
00111 
00112   StateStruct ();
00113 
00114 };
00115 
00116 //typedef std::vector<Teuchos::RCP<StateStruct> >  StateInfoStruct;
00117 // New container class approach
00118 class StateInfoStruct {
00119 public:
00120 
00121    typedef std::vector<Teuchos::RCP<StateStruct> >::const_iterator const_iterator;
00122 
00123    Teuchos::RCP<StateStruct>& operator[](int index){ return sis[index]; }
00124    const Teuchos::RCP<StateStruct> operator[](int index) const { return sis[index]; }
00125    void push_back(const Teuchos::RCP<StateStruct>& ss){ sis.push_back(ss); }
00126    std::size_t size() const { return sis.size(); }
00127    Teuchos::RCP<StateStruct>& back(){ return sis.back(); }
00128    const_iterator begin() const { return sis.begin(); }
00129    const_iterator end() const { return sis.end(); }
00130 
00131 // Create storage on access - only if used
00132    Teuchos::RCP<Adapt::NodalDataBlock> getNodalDataBlock(){ return nodal_data_block; }
00133 
00134    Teuchos::RCP<Adapt::NodalDataBlock> createNodalDataBlock(){ 
00135         if(Teuchos::is_null(nodal_data_block))
00136             nodal_data_block = Teuchos::rcp(new Adapt::NodalDataBlock);
00137         return nodal_data_block; 
00138    }
00139 
00140 private:
00141 
00142    std::vector<Teuchos::RCP<StateStruct> > sis;
00143    Teuchos::RCP<Adapt::NodalDataBlock> nodal_data_block;
00144    
00145 };
00146 
00147 }
00148 #endif

Generated on Wed Mar 26 2014 18:36:36 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1