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

Albany_Catalyst_TeuchosArrayRCPDataArrayDecl.hpp

Go to the documentation of this file.
00001 //*****************************************************************//
00002 //    Albany 2.0:  Copyright 2013 Kitware Inc.                     //
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_CATALYST_TEUCHOSARRAYRCPDATAARRAY
00008 #define ALBANY_CATALYST_TEUCHOSARRAYRCPDATAARRAY
00009 
00010 #include "vtkObject.h"
00011 
00012 #include "vtkTypeTemplate.h"    // For templated vtkObject API
00013 #include "vtkMappedDataArray.h" // For mapped data array API/base.
00014 #include "Teuchos_ArrayRCP.hpp" // For wrapped container type.
00015 
00016 namespace Albany {
00017 namespace Catalyst {
00018 
00019 template <class Scalar>
00020 class TeuchosArrayRCPDataArray:
00021     public vtkTypeTemplate<TeuchosArrayRCPDataArray<Scalar>,
00022                            vtkMappedDataArray<Scalar> >
00023 {
00024 public:
00025   typedef Teuchos::ArrayRCP<Scalar> ContainerType;
00026   typedef Scalar ValueType;
00027 
00028   vtkMappedDataArrayNewInstanceMacro(TeuchosArrayRCPDataArray<Scalar>)
00029   static TeuchosArrayRCPDataArray *New();
00030   virtual void PrintSelf(ostream &os, vtkIndent indent);
00031 
00032   void SetArrayRCP(const Teuchos::ArrayRCP<Scalar> &array, int numComps);
00033 
00034   // Reimplemented virtuals -- see superclasses for descriptions:
00035   void Initialize();
00036   void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output);
00037   void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
00038   void Squeeze();
00039   vtkArrayIterator *NewIterator();
00040   vtkIdType LookupValue(vtkVariant value);
00041   void LookupValue(vtkVariant value, vtkIdList *ids);
00042   vtkVariant GetVariantValue(vtkIdType idx);
00043   void ClearLookup();
00044   double* GetTuple(vtkIdType i);
00045   void GetTuple(vtkIdType i, double *tuple);
00046   vtkIdType LookupTypedValue(ValueType value);
00047   void LookupTypedValue(ValueType value, vtkIdList *ids);
00048   ValueType GetValue(vtkIdType idx);
00049   ValueType& GetValueReference(vtkIdType idx);
00050   void GetTupleValue(vtkIdType idx, ValueType *t);
00051 
00052   // Description:
00053   // This container is read only -- this method does nothing but print a
00054   // warning.
00055   int Allocate(vtkIdType sz, vtkIdType ext);
00056   int Resize(vtkIdType numTuples);
00057   void SetNumberOfTuples(vtkIdType number);
00058   void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source);
00059   void SetTuple(vtkIdType i, const float *source);
00060   void SetTuple(vtkIdType i, const double *source);
00061   void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source);
00062   void InsertTuple(vtkIdType i, const float *source);
00063   void InsertTuple(vtkIdType i, const double *source);
00064   void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
00065                     vtkAbstractArray *source);
00066   vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source);
00067   vtkIdType InsertNextTuple(const float *source);
00068   vtkIdType InsertNextTuple(const double *source);
00069   void DeepCopy(vtkAbstractArray *aa);
00070   void DeepCopy(vtkDataArray *da);
00071   void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
00072                         vtkAbstractArray* source,  double* weights);
00073   void InterpolateTuple(vtkIdType i, vtkIdType id1, vtkAbstractArray *source1,
00074                         vtkIdType id2, vtkAbstractArray *source2, double t);
00075   void SetVariantValue(vtkIdType idx, vtkVariant value);
00076   void RemoveTuple(vtkIdType id);
00077   void RemoveFirstTuple();
00078   void RemoveLastTuple();
00079   void SetTupleValue(vtkIdType i, const ValueType *t);
00080   void InsertTupleValue(vtkIdType i, const ValueType *t);
00081   vtkIdType InsertNextTupleValue(const ValueType *t);
00082   void SetValue(vtkIdType idx, ValueType value);
00083   vtkIdType InsertNextValue(ValueType v);
00084   void InsertValue(vtkIdType idx, ValueType v);
00085 
00086 protected:
00087   TeuchosArrayRCPDataArray();
00088   ~TeuchosArrayRCPDataArray();
00089 
00090   Teuchos::ArrayRCP<Scalar> Data;
00091 
00092 private:
00093   TeuchosArrayRCPDataArray(const TeuchosArrayRCPDataArray&); // Not implemented.
00094   void operator=(const TeuchosArrayRCPDataArray &); // Not implemented.
00095 
00096   vtkIdType Lookup(double val, vtkIdType startIdx);
00097 
00098   Scalar *TmpArray; // length = number of components
00099 };
00100 
00101 template <typename Scalar> inline Scalar
00102 TeuchosArrayRCPDataArray<Scalar>::GetValue(vtkIdType idx)
00103 {
00104   return this->Data[idx];
00105 }
00106 
00107 template <typename Scalar> inline Scalar &
00108 TeuchosArrayRCPDataArray<Scalar>::GetValueReference(vtkIdType idx)
00109 {
00110   return this->Data[idx];
00111 }
00112 
00113 template <typename Scalar> inline void
00114 TeuchosArrayRCPDataArray<Scalar>::GetTupleValue(
00115     vtkIdType idx, TeuchosArrayRCPDataArray::ValueType *t)
00116 {
00117   int comps = this->NumberOfComponents;
00118   typename ContainerType::const_iterator tuple
00119       = this->Data.begin() + (idx * comps);
00120   while (comps-- > 0)
00121     *(t++) = *(tuple++);
00122 }
00123 
00124 } // end namespace Catalyst
00125 } // end namespace Albany
00126 
00127 #endif // ALBANY_CATALYST_TEUCHOSARRAYRCPDATAARRAY

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