|
Intrepid
|
00001 // @HEADER 00002 // ************************************************************************ 00003 // 00004 // Intrepid Package 00005 // Copyright (2007) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Pavel Bochev (pbboche@sandia.gov) or 00025 // Denis Ridzal (dridzal@sandia.gov). 00026 // 00027 // ************************************************************************ 00028 // @HEADER 00029 00035 #ifndef INTREPID_FIELDCONTAINER_HPP 00036 #define INTREPID_FIELDCONTAINER_HPP 00037 00038 #include "Intrepid_ConfigDefs.hpp" 00039 #include "Intrepid_Types.hpp" 00040 #include "Intrepid_Utils.hpp" 00041 #include "Teuchos_Array.hpp" 00042 #include "Teuchos_ArrayRCP.hpp" 00043 #include "Teuchos_ArrayView.hpp" 00044 #include "Shards_Array.hpp" 00045 #include "Teuchos_RCP.hpp" 00046 #include "Teuchos_BLAS.hpp" 00047 #include "Teuchos_oblackholestream.hpp" 00048 #include "Teuchos_TestForException.hpp" 00049 00050 namespace Intrepid { 00051 00063 template<class Scalar, int ArrayTypeId=0> 00064 class FieldContainer { 00065 protected: 00066 00069 Teuchos::ArrayRCP<Scalar> data_; 00070 00075 Teuchos::Array<int> dimensions_; 00076 00078 int dim0_; 00079 00081 int dim1_; 00082 00084 int dim2_; 00085 00087 int dim3_; 00088 00090 int dim4_; 00091 00092 public: 00093 00094 00097 ~FieldContainer() {}; 00098 00099 00102 FieldContainer() : dim0_(0), dim1_(0), dim2_(0), dim3_(0), dim4_(0) 00103 { 00104 data_.resize(0); 00105 dimensions_.resize(0); 00106 } ; 00107 00108 00111 FieldContainer(const FieldContainer& right); 00112 00113 00118 FieldContainer(const int dim0); 00119 00120 00126 FieldContainer(const int dim0, 00127 const int dim1); 00128 00129 00136 FieldContainer(const int dim0, 00137 const int dim1, 00138 const int dim2); 00139 00140 00148 FieldContainer(const int dim0, 00149 const int dim1, 00150 const int dim2, 00151 const int dim3); 00152 00153 00162 FieldContainer(const int dim0, 00163 const int dim1, 00164 const int dim2, 00165 const int dim3, 00166 const int dim4); 00167 00168 00175 FieldContainer(const Teuchos::Array<int>& dimensions); 00176 00177 00189 FieldContainer(const Teuchos::Array<int>& dimensions, 00190 const Teuchos::ArrayView<Scalar>& data); 00191 00192 00203 FieldContainer(const Teuchos::Array<int>& dimensions, 00204 const Teuchos::ArrayRCP<Scalar>& data); 00205 00206 00218 FieldContainer(const Teuchos::Array<int>& dimensions, 00219 Scalar* data, 00220 const bool deep_copy = false, 00221 const bool owns_mem = false); 00222 00223 00233 FieldContainer(const shards::Array<Scalar,shards::NaturalOrder>& data, 00234 const bool deep_copy = false, 00235 const bool owns_mem = false); 00236 00237 00238 00239 00240 //--------------------------------------------------------------------------------------------// 00241 // // 00242 // Access methods of FieldContainer class // 00243 // // 00244 //--------------------------------------------------------------------------------------------// 00245 00248 int rank() const; 00249 00250 00253 int size() const; 00254 00255 00258 template<class Vector> 00259 void dimensions(Vector& dimensions) const; 00260 00261 00266 int dimension(const int whichDim) const; 00267 00268 00274 int getEnumeration(const int i0) const; 00275 00276 00283 int getEnumeration(const int i0, 00284 const int i1) const; 00285 00286 00294 int getEnumeration(const int i0, 00295 const int i1, 00296 const int i2) const; 00297 00298 00307 int getEnumeration(const int i0, 00308 const int i1, 00309 const int i2, 00310 const int i3) const; 00311 00312 00322 int getEnumeration(const int i0, 00323 const int i1, 00324 const int i2, 00325 const int i3, 00326 const int i4) const; 00327 00328 00334 int getEnumeration(const Teuchos::Array<int>& multiIndex) const; 00335 00336 00343 void getMultiIndex(int & i0, 00344 const int valueEnum) const; 00345 00346 00354 void getMultiIndex(int & i0, 00355 int & i1, 00356 const int valueEnum) const; 00357 00358 00367 void getMultiIndex(int & i0, 00368 int & i1, 00369 int & i2, 00370 const int valueEnum) const; 00371 00372 00382 void getMultiIndex(int & i0, 00383 int & i1, 00384 int & i2, 00385 int & i3, 00386 const int valueEnum) const; 00387 00388 00399 void getMultiIndex(int & i0, 00400 int & i1, 00401 int & i2, 00402 int & i3, 00403 int & i4, 00404 const int valueEnum) const; 00405 00406 00417 template<class Vector> 00418 void getMultiIndex(Vector& multiIndex, 00419 const int valueEnum) const; 00420 00421 //--------------------------------------------------------------------------------------------// 00422 // // 00423 // Methods to shape (resize) a field container // 00424 // // 00425 //--------------------------------------------------------------------------------------------// 00426 00427 00430 void clear(); 00431 00432 00437 void resize(const int dim0); 00438 00439 00445 void resize(const int dim0, 00446 const int dim1); 00447 00448 00455 void resize(const int dim0, 00456 const int dim1, 00457 const int dim2); 00458 00459 00467 void resize(const int dim0, 00468 const int dim1, 00469 const int dim2, 00470 const int dim3); 00471 00472 00481 void resize(const int dim0, 00482 const int dim1, 00483 const int dim2, 00484 const int dim3, 00485 const int dim4); 00486 00487 00493 void resize(const Teuchos::Array<int>& newDimensions); 00494 00495 00501 void resize(const FieldContainer<Scalar, ArrayTypeId>& anotherContainer); 00502 00503 00542 void resize(const int numPoints, 00543 const int numFields, 00544 const EFunctionSpace spaceType, 00545 const EOperator operatorType, 00546 const int spaceDim); 00547 00548 //--------------------------------------------------------------------------------------------// 00549 // // 00550 // Methods to read and write values to FieldContainer // 00551 // // 00552 //--------------------------------------------------------------------------------------------// 00553 00554 00557 void initialize(const Scalar value = 0); 00558 00559 00564 Scalar getValue(const Teuchos::Array<int>& multiIndex) const; 00565 00566 00572 void setValue(const Scalar dataValue, 00573 const Teuchos::Array<int>& multiIndex); 00574 00575 00581 void setValue(const Scalar dataValue, 00582 const int order); 00583 00584 00590 void setValues(const Teuchos::ArrayView<Scalar>& dataArray); 00591 00592 00599 void setValues(const Scalar* dataPtr, 00600 const int numData); 00601 00602 00605 Teuchos::ArrayRCP<Scalar> getData() { 00606 return data_; 00607 } 00608 00609 00612 Teuchos::ArrayRCP<const Scalar> getData() const { 00613 return data_; 00614 } 00615 00616 00621 const Scalar& operator () (const int i0) const; 00622 00627 Scalar& operator () (const int i0); 00628 00629 00635 const Scalar& operator () (const int i0, 00636 const int i1) const; 00637 00643 Scalar& operator () (const int i0, 00644 const int i1); 00645 00646 00653 const Scalar& operator () (const int i0, 00654 const int i1, 00655 const int i2) const; 00656 00663 Scalar& operator () (const int i0, 00664 const int i1, 00665 const int i2); 00666 00667 00675 const Scalar& operator () (const int i0, 00676 const int i1, 00677 const int i2, 00678 const int i3) const; 00679 00687 Scalar& operator () (const int i0, 00688 const int i1, 00689 const int i2, 00690 const int i3); 00691 00692 00701 const Scalar& operator () (const int i0, 00702 const int i1, 00703 const int i2, 00704 const int i3, 00705 const int i4) const; 00706 00715 Scalar& operator () (const int i0, 00716 const int i1, 00717 const int i2, 00718 const int i3, 00719 const int i4); 00720 00721 00725 const Scalar & operator [] (const int address) const; 00726 00727 00731 Scalar & operator [] (const int address); 00732 00733 00736 FieldContainer& operator = (const FieldContainer& right); 00737 00738 }; // end class FieldContainer 00739 00740 00741 //--------------------------------------------------------------------------------------------// 00742 // // 00743 // Function declarations related to FieldContainer // 00744 // // 00745 //--------------------------------------------------------------------------------------------// 00746 00750 template<class Scalar, int ArrayTypeId> 00751 std::ostream& operator << (std::ostream& os, const FieldContainer<Scalar, ArrayTypeId>& container); 00752 00753 00754 } // end namespace Intrepid 00755 00756 // include templated definitions 00757 #include <Intrepid_FieldContainerDef.hpp> 00758 00759 #endif 00760
1.7.4