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

AlbPUMI_NodeData.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 ALBPUMI_NODEDATA_HPP
00008 #define ALBPUMI_NODEDATA_HPP
00009 
00010 
00011 #include "Teuchos_RCP.hpp"
00012 #include "Teuchos_ParameterList.hpp"
00013 
00014 #include "PHAL_Dimension.hpp"
00015 #include "Albany_AbstractNodeFieldContainer.hpp"
00016 #include "Albany_StateInfoStruct.hpp"
00017 
00018 #include <apfNumbering.h>
00019 
00020 namespace AlbPUMI {
00021 
00022 class AbstractPUMINodeFieldContainer : public Albany::AbstractNodeFieldContainer {
00023 
00024   public:
00025 
00026     AbstractPUMINodeFieldContainer(){}
00027     virtual ~AbstractPUMINodeFieldContainer(){}
00028 
00029     virtual void saveField(const Teuchos::RCP<const Epetra_Vector>& block_mv,
00030             int offset, int blocksize = -1) = 0;
00031     virtual Albany::MDArray getMDA(const std::vector<apf::Node>& buck) = 0;
00032     virtual void resize(const Teuchos::RCP<const Epetra_Map>& local_node_map) = 0;
00033 
00034 };
00035 
00036 Teuchos::RCP<Albany::AbstractNodeFieldContainer>
00037 buildPUMINodeField(const std::string& name, const std::vector<int>& dim, const bool output);
00038 
00039 
00040   // Helper class for NodeData
00041   template<typename DataType, unsigned ArrayDim>
00042   struct NodeData_Traits { };
00043 
00044   template<typename DataType, unsigned ArrayDim, class traits = NodeData_Traits<DataType, ArrayDim> >
00045   class NodeData : public AbstractPUMINodeFieldContainer {
00046 
00047   public:
00048 
00049     NodeData(const std::string& name, const std::vector<int>& dim, const bool output = false);
00050     virtual ~NodeData(){}
00051 
00053     typedef traits traits_type;
00054 
00056     typedef typename traits_type::field_type field_type;
00057 
00058     void saveField(const Teuchos::RCP<const Epetra_Vector>& block_mv, int offset, int blocksize = -1);
00059     void resize(const Teuchos::RCP<const Epetra_Map>& local_node_map);
00060     Albany::MDArray getMDA(const std::vector<apf::Node>& buck);
00061 
00062   protected:
00063 
00064     const std::string name;      // Name of data field
00065     const bool output;           // Is field output to disk each time step (or at end of simulation)?
00066     std::vector<DataType>  buffer;        // 1D array storage -> numOwnedNodes * product of dims
00067     std::vector<int> dims;
00068     int nfield_dofs;                    // total number of dofs in this field
00069     std::size_t beginning_index;        // Buffer starting location for the next array allocation
00070 
00071     Teuchos::RCP<const Epetra_Map> local_node_map;
00072 
00073   };
00074 
00075 // Explicit template definitions in support of the above
00076 
00077   // NodeScalar
00078   template <typename T>
00079   struct NodeData_Traits<T, 1> {
00080 
00081     enum { size = 1 }; // One array dimension tags: number of nodes in workset
00082     typedef shards::Array<T, shards::NaturalOrder, Node> field_type ;
00083     static field_type buildArray(T *buf, unsigned nelems, std::vector<int>& dims){
00084 
00085       return field_type(buf, nelems);
00086 
00087     }
00088 
00089   };
00090 
00091   // NodeVector
00092   template <typename T>
00093   struct NodeData_Traits<T, 2> {
00094 
00095     enum { size = 2 }; // Two array dimension tags: Nodes and vec dim
00096     typedef shards::Array<T, shards::NaturalOrder, Node, Dim> field_type ;
00097     static field_type buildArray(T *buf, unsigned nelems, std::vector<int>& dims){
00098 
00099       return field_type(buf, nelems, dims[1]);
00100 
00101     }
00102 
00103   };
00104 
00105   // NodeTensor
00106   template <typename T>
00107   struct NodeData_Traits<T, 3> {
00108 
00109     enum { size = 3 }; // Three array dimension tags: Nodes, Dim and Dim
00110     typedef shards::Array<T, shards::NaturalOrder, Node, Dim, Dim> field_type ;
00111     static field_type buildArray(T *buf, unsigned nelems, std::vector<int>& dims){
00112 
00113       return field_type(buf, nelems, dims[1], dims[2]);
00114 
00115     }
00116 
00117   };
00118 
00119 }
00120 
00121 // Define macro for explicit template instantiation
00122 #define NODEDATA_INSTANTIATE_TEMPLATE_CLASS_SCAL(name, type) \
00123   template class name<type, 1>;
00124 #define NODEDATA_INSTANTIATE_TEMPLATE_CLASS_VEC(name, type) \
00125   template class name<type, 2>;
00126 #define NODEDATA_INSTANTIATE_TEMPLATE_CLASS_TENS(name, type) \
00127   template class name<type, 3>;
00128 
00129 #define NODEDATA_INSTANTIATE_TEMPLATE_CLASS(name) \
00130   NODEDATA_INSTANTIATE_TEMPLATE_CLASS_SCAL(name, double) \
00131   NODEDATA_INSTANTIATE_TEMPLATE_CLASS_VEC(name, double) \
00132   NODEDATA_INSTANTIATE_TEMPLATE_CLASS_TENS(name, double)
00133 
00134 #endif

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