59 template<
class Scalar,
int ArrayTypeId>
64 data_.assign(right.
data_.begin(),right.
data_.end());
70 data_ptr_ = data_.begin();
80 template<
class Scalar,
int ArrayTypeId>
84 using Teuchos::Ordinal;
85 #ifdef HAVE_INTREPID_DEBUG 86 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim0), std::invalid_argument,
87 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative dimension.");
92 data_.assign(as<Ordinal>(
dim0_), as<Scalar>(0));
93 data_ptr_ =
data_.begin();
98 template<
class Scalar,
int ArrayTypeId>
103 using Teuchos::Ordinal;
104 #ifdef HAVE_INTREPID_DEBUG 105 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim0), std::invalid_argument,
106 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 1st dimension.");
107 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim1), std::invalid_argument,
108 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 2nd dimension.");
115 data_ptr_ =
data_.begin();
120 template<
class Scalar,
int ArrayTypeId>
125 #ifdef HAVE_INTREPID_DEBUG 126 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim0), std::invalid_argument,
127 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 1st dimension.");
128 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim1), std::invalid_argument,
129 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 2nd dimension.");
130 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim2), std::invalid_argument,
131 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 3rd dimension.");
138 data_ptr_ =
data_.begin();
143 template<
class Scalar,
int ArrayTypeId>
149 #ifdef HAVE_INTREPID_DEBUG 150 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim0), std::invalid_argument,
151 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 1st dimension.");
152 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim1), std::invalid_argument,
153 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 2nd dimension.");
154 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim2), std::invalid_argument,
155 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 3rd dimension.");
156 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim3), std::invalid_argument,
157 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 4th dimension.");
165 data_ptr_ =
data_.begin();
170 template<
class Scalar,
int ArrayTypeId>
177 #ifdef HAVE_INTREPID_DEBUG 178 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim0), std::invalid_argument,
179 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 1st dimension.");
180 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim1), std::invalid_argument,
181 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 2nd dimension.");
182 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim2), std::invalid_argument,
183 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 3rd dimension.");
184 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim3), std::invalid_argument,
185 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 4th dimension.");
186 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim4), std::invalid_argument,
187 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 5th dimension.");
196 data_ptr_ =
data_.begin();
201 template<
class Scalar,
int ArrayTypeId>
204 #ifdef HAVE_INTREPID_DEBUG 207 for(
int dim = 0; dim < dimensions.size(); dim++) {
208 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dimensions[dim] ), std::invalid_argument,
209 ">>> ERROR (FieldContainer): One or more negative dimensions");
214 dimensions_.assign(dimensions.begin(),dimensions.end());
261 data_.assign(
this ->
size(), (Scalar)0);
262 data_ptr_ =
data_.begin();
268 template<
class Scalar,
int ArrayTypeId>
270 const Teuchos::ArrayView<Scalar>& data) {
273 dimensions_.assign(dimensions.begin(),dimensions.end());
328 #ifdef HAVE_INTREPID_DEBUG 329 TEUCHOS_TEST_FOR_EXCEPTION( ( (
int)data.size() !=
this ->
size() ),
330 std::invalid_argument,
331 ">>> ERROR (FieldContainer): Size of input data does not match size of this container.");
335 data_.assign(data.begin(),data.end());
336 data_ptr_ =
data_.begin();
341 template<
class Scalar,
int ArrayTypeId>
343 const Teuchos::ArrayRCP<Scalar>& data) {
346 dimensions_.assign(dimensions.begin(),dimensions.end());
401 #ifdef HAVE_INTREPID_DEBUG 402 TEUCHOS_TEST_FOR_EXCEPTION( ( (
int)data.size() !=
this ->
size() ),
403 std::invalid_argument,
404 ">>> ERROR (FieldContainer): Size of input data does not match size of this container.");
409 data_ptr_ =
data_.begin();
414 template<
class Scalar,
int ArrayTypeId>
417 const bool deep_copy,
418 const bool owns_mem) {
421 dimensions_.assign(dimensions.begin(),dimensions.end());
477 Teuchos::ArrayRCP<Scalar> arrayrcp = Teuchos::arcp<Scalar>(data, 0,
this ->
size(),
false);
478 data_.deepCopy(arrayrcp());
479 data_ptr_ =
data_.begin();
482 data_ = Teuchos::arcp<Scalar>(data, 0,
this ->
size(), owns_mem);
483 data_ptr_ =
data_.begin();
489 template<
class Scalar,
int ArrayTypeId>
491 const bool deep_copy,
492 const bool owns_mem) {
556 for (
int i=0; i<data.rank(); i++) {
568 Teuchos::ArrayRCP<Scalar> arrayrcp = Teuchos::arcp<Scalar>(data.contiguous_data(), 0,
this ->
size(),
false);
569 data_.deepCopy(arrayrcp());
570 data_ptr_ =
data_.begin();
573 data_ = Teuchos::arcp<Scalar>(data.contiguous_data(), 0,
this ->
size(), owns_mem);
574 data_ptr_ =
data_.begin();
587 template<
class Scalar,
int ArrayTypeId>
594 template<
class Scalar,
int ArrayTypeId>
633 for(
int r = 1; r <
rank ; r++){
643 template<
class Scalar,
int ArrayTypeId>
644 template<
class Vector>
651 template<
class Scalar,
int ArrayTypeId>
653 #ifdef HAVE_INTREPID_DEBUG 654 TEUCHOS_TEST_FOR_EXCEPTION( (0 > whichDim), std::invalid_argument,
655 ">>> ERROR (FieldContainer): dimension order cannot be negative");
656 TEUCHOS_TEST_FOR_EXCEPTION( (whichDim >=
this ->
rank() ), std::invalid_argument,
657 ">>> ERROR (FieldContainer): dimension order cannot exceed rank of the container");
664 template<
class Scalar,
int ArrayTypeId>
666 #ifdef HAVE_INTREPID_DEBUG 667 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 1), std::invalid_argument,
668 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
669 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || ( i0 >=
dim0_) ), std::invalid_argument,
670 ">>> ERROR (FieldContainer): index is out of range.");
677 template<
class Scalar,
int ArrayTypeId>
679 const int i1)
const {
680 #ifdef HAVE_INTREPID_DEBUG 681 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 2), std::invalid_argument,
682 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
683 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || ( i0 >=
dim0_) ), std::invalid_argument,
684 ">>> ERROR (FieldContainer): 1st index is out of range.");
685 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
686 ">>> ERROR (FieldContainer): 2nd index is out of range.");
688 return i0*
dim1_ + i1;
693 template<
class Scalar,
int ArrayTypeId>
696 const int i2)
const {
697 #ifdef HAVE_INTREPID_DEBUG 698 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 3), std::invalid_argument,
699 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
700 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || ( i0 >=
dim0_) ), std::invalid_argument,
701 ">>> ERROR (FieldContainer): 1st index is out of range.");
702 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
703 ">>> ERROR (FieldContainer): 2nd index is out of range.");
704 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
705 ">>> ERROR (FieldContainer): 3rd index is out of range.");
712 template<
class Scalar,
int ArrayTypeId>
716 const int i3)
const {
717 #ifdef HAVE_INTREPID_DEBUG 718 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 4), std::invalid_argument,
719 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
720 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || ( i0 >=
dim0_) ), std::invalid_argument,
721 ">>> ERROR (FieldContainer): 1st index is out of range.");
722 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
723 ">>> ERROR (FieldContainer): 2nd index is out of range.");
724 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
725 ">>> ERROR (FieldContainer): 3rd index is out of range.");
726 TEUCHOS_TEST_FOR_EXCEPTION( ( (i3 < 0) || (i3 >=
dim3_) ), std::invalid_argument,
727 ">>> ERROR (FieldContainer): 4th index is out of range.");
734 template<
class Scalar,
int ArrayTypeId>
739 const int i4)
const {
740 #ifdef HAVE_INTREPID_DEBUG 741 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 5), std::invalid_argument,
742 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
743 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || ( i0 >=
dim0_) ), std::invalid_argument,
744 ">>> ERROR (FieldContainer): 1st index is out of range.");
745 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
746 ">>> ERROR (FieldContainer): 2nd index is out of range.");
747 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
748 ">>> ERROR (FieldContainer): 3rd index is out of range.");
749 TEUCHOS_TEST_FOR_EXCEPTION( ( (i3 < 0) || (i3 >=
dim3_) ), std::invalid_argument,
750 ">>> ERROR (FieldContainer): 4th index is out of range.");
751 TEUCHOS_TEST_FOR_EXCEPTION( ( (i4 < 0) || (i4 >=
dim4_) ), std::invalid_argument,
752 ">>> ERROR (FieldContainer): 5th index is out of range.");
760 template<
class Scalar,
int ArrayTypeId>
763 #ifdef HAVE_INTREPID_DEBUG 765 TEUCHOS_TEST_FOR_EXCEPTION( ( multiIndex.size() !=
dimensions_.size() ),
766 std::invalid_argument,
767 ">>> ERROR (FieldContainer): Number of multi-indices does not match rank of container.");
768 TEUCHOS_TEST_FOR_EXCEPTION( ( ( multiIndex[0] < 0) || ( multiIndex[0] >=
dim0_) ),
769 std::invalid_argument,
770 ">>> ERROR (FieldContainer): 1st index is out of range.");
779 #ifdef HAVE_INTREPID_DEBUG 780 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[4] < 0) || (multiIndex[4] >=
dim4_) ),
781 std::invalid_argument,
782 ">>> ERROR (FieldContainer): 5th index is out of range.");
783 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[3] < 0) || (multiIndex[3] >=
dim3_) ),
784 std::invalid_argument,
785 ">>> ERROR (FieldContainer): 4th index is out of range.");
786 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[2] < 0) || (multiIndex[2] >=
dim2_) ),
787 std::invalid_argument,
788 ">>> ERROR (FieldContainer): 3rd index is out of range.");
789 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[1] < 0) || (multiIndex[1] >=
dim1_) ),
790 std::invalid_argument,
791 ">>> ERROR (FieldContainer): 2nd index is out of range.");
793 address = (((multiIndex[0]*
dim1_ + multiIndex[1])*
dim2_ + multiIndex[2])*
dim3_ + multiIndex[3])*
dim4_ + multiIndex[4];
797 #ifdef HAVE_INTREPID_DEBUG 798 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[3] < 0) || (multiIndex[3] >=
dim3_) ),
799 std::invalid_argument,
800 ">>> ERROR (FieldContainer): 4th index is out of range.");
801 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[2] < 0) || (multiIndex[2] >=
dim2_) ),
802 std::invalid_argument,
803 ">>> ERROR (FieldContainer): 3rd index is out of range.");
804 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[1] < 0) || (multiIndex[1] >=
dim1_) ),
805 std::invalid_argument,
806 ">>> ERROR (FieldContainer): 2nd index is out of range.");
808 address = ((multiIndex[0]*
dim1_ + multiIndex[1])*
dim2_ + multiIndex[2])*
dim3_ + multiIndex[3];
812 #ifdef HAVE_INTREPID_DEBUG 813 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[2] < 0) || (multiIndex[2] >=
dim2_) ),
814 std::invalid_argument,
815 ">>> ERROR (FieldContainer): 3rd index is out of range.");
816 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[1] < 0) || (multiIndex[1] >=
dim1_) ),
817 std::invalid_argument,
818 ">>> ERROR (FieldContainer): 2nd index is out of range.");
820 address = (multiIndex[0]*
dim1_ + multiIndex[1])*
dim2_ + multiIndex[2];
824 #ifdef HAVE_INTREPID_DEBUG 825 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[1] < 0) || (multiIndex[1] >=
dim1_) ),
826 std::invalid_argument,
827 ">>> ERROR (FieldContainer): 2nd index is out of range.");
829 address = multiIndex[0]*
dim1_ + multiIndex[1];
833 address = multiIndex[0];
839 address = multiIndex[0];
840 for (
int r = 0; r < rank - 1; r++){
841 #ifdef HAVE_INTREPID_DEBUG 842 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[r+1] < 0) || (multiIndex[r+1] >=
dimensions_[r+1]) ),
843 std::invalid_argument,
844 ">>> ERROR (FieldContainer): Multi-index component out of range.");
847 address = address*
dimensions_[r+1] + multiIndex[r+1];
856 template<
class Scalar,
int ArrayTypeId>
858 const int valueEnum)
const 860 #ifdef HAVE_INTREPID_DEBUG 861 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 1), std::invalid_argument,
862 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
863 TEUCHOS_TEST_FOR_EXCEPTION( ( (valueEnum < 0) || (valueEnum >= (
int)
data_.size()) ),
864 std::invalid_argument,
865 ">>> ERROR (FieldContainer): Value enumeration is out of range.");
872 template<
class Scalar,
int ArrayTypeId>
875 const int valueEnum)
const 877 #ifdef HAVE_INTREPID_DEBUG 878 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 2), std::invalid_argument,
879 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
880 TEUCHOS_TEST_FOR_EXCEPTION( ( (valueEnum < 0) || (valueEnum >= (
int)
data_.size()) ),
881 std::invalid_argument,
882 ">>> ERROR (FieldContainer): Value enumeration is out of range.");
885 i0 = valueEnum/
dim1_;
886 i1 = valueEnum - i0*
dim1_;
891 template<
class Scalar,
int ArrayTypeId>
895 const int valueEnum)
const 897 #ifdef HAVE_INTREPID_DEBUG 898 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 3), std::invalid_argument,
899 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
900 TEUCHOS_TEST_FOR_EXCEPTION( ( (valueEnum < 0) || (valueEnum >= (
int)
data_.size()) ),
901 std::invalid_argument,
902 ">>> ERROR (FieldContainer): Value enumeration is out of range.");
905 int tempEnu = valueEnum;
906 i0 = tempEnu/tempDim;
908 tempEnu -= i0*tempDim;
910 i1 = tempEnu/tempDim;
912 tempEnu -= i1*tempDim;
914 i2 = tempEnu/tempDim;
919 template<
class Scalar,
int ArrayTypeId>
924 const int valueEnum)
const 926 #ifdef HAVE_INTREPID_DEBUG 927 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 4), std::invalid_argument,
928 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
929 TEUCHOS_TEST_FOR_EXCEPTION( ( (valueEnum < 0) || (valueEnum >= (
int)
data_.size()) ),
930 std::invalid_argument,
931 ">>> ERROR (FieldContainer): Value enumeration is out of range.");
934 int tempEnu = valueEnum;
935 i0 = tempEnu/tempDim;
937 tempEnu -= i0*tempDim;
939 i1 = tempEnu/tempDim;
941 tempEnu -= i1*tempDim;
943 i2 = tempEnu/tempDim;
945 tempEnu -= i2*tempDim;
947 i3 = tempEnu/tempDim;
953 template<
class Scalar,
int ArrayTypeId>
959 const int valueEnum)
const 961 #ifdef HAVE_INTREPID_DEBUG 962 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 5), std::invalid_argument,
963 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
964 TEUCHOS_TEST_FOR_EXCEPTION( ( (valueEnum < 0) || (valueEnum >= (
int)
data_.size()) ),
965 std::invalid_argument,
966 ">>> ERROR (FieldContainer): Value enumeration is out of range.");
969 int tempEnu = valueEnum;
970 i0 = tempEnu/tempDim;
972 tempEnu -= i0*tempDim;
974 i1 = tempEnu/tempDim;
976 tempEnu -= i1*tempDim;
978 i2 = tempEnu/tempDim;
980 tempEnu -= i2*tempDim;
982 i3 = tempEnu/tempDim;
984 tempEnu -= i3*tempDim;
986 i4 = tempEnu/tempDim;
991 template<
class Scalar,
int ArrayTypeId>
992 template<
class Vector>
994 const int valueEnum)
const 998 #ifdef HAVE_INTREPID_DEBUG 999 TEUCHOS_TEST_FOR_EXCEPTION( ( (valueEnum < 0) || (valueEnum >= (
int)
data_.size()) ),
1000 std::invalid_argument,
1001 ">>> ERROR (FieldContainer): Value enumeration is out of range.");
1006 multiIndex.resize(rank);
1009 int temp_enum = valueEnum;
1013 for(
int r = 1; r <
rank ; r++){
1018 multiIndex[0] = temp_enum/temp_range;
1021 for(
int r = 1; r < rank - 1; r++){
1022 temp_enum -= multiIndex[r-1]*temp_range;
1024 multiIndex[r] = temp_enum/temp_range;
1029 multiIndex[rank - 1] = temp_enum - multiIndex[rank - 2]*temp_range;
1039 template<
class Scalar,
int ArrayTypeId>
1052 data_ptr_ =
data_.begin();
1057 template<
class Scalar,
int ArrayTypeId>
1061 if( newDimensions.size() == 0) {
1069 data_ptr_ =
data_.begin();
1074 dimensions_.assign(newDimensions.begin(),newDimensions.end());
1122 data_ptr_ =
data_.begin();
1128 template<
class Scalar,
int ArrayTypeId>
1138 data_ptr_ =
data_.begin();
1143 template<
class Scalar,
int ArrayTypeId>
1155 data_ptr_ =
data_.begin();
1160 template<
class Scalar,
int ArrayTypeId>
1174 data_ptr_ =
data_.begin();
1179 template<
class Scalar,
int ArrayTypeId>
1195 data_ptr_ =
data_.begin();
1200 template<
class Scalar,
int ArrayTypeId>
1218 data_ptr_ =
data_.begin();
1223 template<
class Scalar,
int ArrayTypeId>
1275 data_ptr_ =
data_.begin();
1279 template<
class Scalar,
int ArrayTypeId>
1281 const int numFields,
1282 const EFunctionSpace spaceType,
1284 const int spaceDim) {
1286 #ifdef HAVE_INTREPID_DEBUG 1287 TEUCHOS_TEST_FOR_EXCEPTION( ( numPoints < 0),
1288 std::invalid_argument,
1289 ">>> ERROR (FieldContainer): Number of points cannot be negative!");
1290 TEUCHOS_TEST_FOR_EXCEPTION( ( numFields < 0),
1291 std::invalid_argument,
1292 ">>> ERROR (FieldContainer): Number of fields cannot be negative!");
1293 TEUCHOS_TEST_FOR_EXCEPTION( !( (1 <= spaceDim ) && ( spaceDim <= 3 ) ),
1294 std::invalid_argument,
1295 ">>> ERROR (FieldContainer): Invalid space dimension.");
1303 int rank = 1 + 1 + fieldRank + operatorRank;
1306 Teuchos::Array<int> newDimensions(rank);
1309 newDimensions[0] = numPoints;
1310 newDimensions[1] = numFields;
1313 switch(operatorType) {
1315 case OPERATOR_VALUE:
1322 for(
int i = 0; i < fieldRank + operatorRank; i++){
1323 newDimensions[2 + i] = spaceDim;
1338 for(
int i = 0; i < fieldRank; i++){
1339 newDimensions[2 + i] = spaceDim;
1349 ">>> ERROR (FieldContainer): Invalid operator type");
1353 this ->
resize(newDimensions);
1364 template<
class Scalar,
int ArrayTypeId>
1366 for (
int i=0; i < this->
size(); i++) {
1373 template<
class Scalar,
int ArrayTypeId>
1380 template<
class Scalar,
int ArrayTypeId>
1382 const Teuchos::Array<int>& multiIndex) {
1388 template<
class Scalar,
int ArrayTypeId>
1391 data_[order] = dataValue;
1396 template<
class Scalar,
int ArrayTypeId>
1398 #ifdef HAVE_INTREPID_DEBUG 1399 TEUCHOS_TEST_FOR_EXCEPTION( (dataArray.size() != (
data_.size()) ),
1400 std::invalid_argument,
1401 ">>> ERROR (FieldContainer): Size of argument does not match the size of container.");
1403 data_.assign(dataArray.begin(),dataArray.end());
1404 data_ptr_ =
data_.begin();
1409 template<
class Scalar,
int ArrayTypeId>
1413 #ifdef HAVE_INTREPID_DEBUG 1414 TEUCHOS_TEST_FOR_EXCEPTION( (numData !=
this ->
size() ), std::invalid_argument,
1415 ">>> ERROR (FieldContainer): Number of data does not match the size of container.");
1418 data_.assign(dataPtr, dataPtr + numData);
1419 data_ptr_ =
data_.begin();
1424 template<
class Scalar,
int ArrayTypeId>
1427 #ifdef HAVE_INTREPID_DEBUG 1428 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 1), std::invalid_argument,
1429 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1430 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1431 ">>> ERROR (FieldContainer): index is out of range.");
1433 return data_ptr_[i0];
1437 template<
class Scalar,
int ArrayTypeId>
1440 #ifdef HAVE_INTREPID_DEBUG 1441 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 1), std::invalid_argument,
1442 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1443 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1444 ">>> ERROR (FieldContainer): index is out of range.");
1446 return data_ptr_[i0];
1451 template<
class Scalar,
int ArrayTypeId>
1455 #ifdef HAVE_INTREPID_DEBUG 1456 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 2), std::invalid_argument,
1457 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1458 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1459 ">>> ERROR (FieldContainer): 1st index is out of range.");
1460 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1461 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1463 return data_ptr_[i0*
dim1_ + i1];
1467 template<
class Scalar,
int ArrayTypeId>
1471 #ifdef HAVE_INTREPID_DEBUG 1472 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 2), std::invalid_argument,
1473 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1474 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1475 ">>> ERROR (FieldContainer): 1st index is out of range.");
1476 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1477 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1479 return data_ptr_[i0*
dim1_ + i1];
1484 template<
class Scalar,
int ArrayTypeId>
1489 #ifdef HAVE_INTREPID_DEBUG 1490 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 3), std::invalid_argument,
1491 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1492 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1493 ">>> ERROR (FieldContainer): 1st index is out of range.");
1494 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1495 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1496 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
1497 ">>> ERROR (FieldContainer): 3rd index is out of range.");
1499 return data_ptr_[(i0*
dim1_ + i1)*
dim2_ + i2];
1502 template<
class Scalar,
int ArrayTypeId>
1507 #ifdef HAVE_INTREPID_DEBUG 1508 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 3), std::invalid_argument,
1509 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1510 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1511 ">>> ERROR (FieldContainer): 1st index is out of range.");
1512 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1513 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1514 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
1515 ">>> ERROR (FieldContainer): 3rd index is out of range.");
1517 return data_ptr_[(i0*
dim1_ + i1)*
dim2_ + i2];
1522 template<
class Scalar,
int ArrayTypeId>
1526 const int i3)
const {
1527 #ifdef HAVE_INTREPID_DEBUG 1528 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 4), std::invalid_argument,
1529 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1530 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1531 ">>> ERROR (FieldContainer): 1st index is out of range.");
1532 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1533 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1534 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
1535 ">>> ERROR (FieldContainer): 3rd index is out of range.");
1536 TEUCHOS_TEST_FOR_EXCEPTION( ( (i3 < 0) || (i3 >=
dim3_) ), std::invalid_argument,
1537 ">>> ERROR (FieldContainer): 4th index is out of range.");
1543 template<
class Scalar,
int ArrayTypeId>
1548 #ifdef HAVE_INTREPID_DEBUG 1549 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 4), std::invalid_argument,
1550 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1551 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1552 ">>> ERROR (FieldContainer): 1st index is out of range.");
1553 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1554 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1555 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
1556 ">>> ERROR (FieldContainer): 3rd index is out of range.");
1557 TEUCHOS_TEST_FOR_EXCEPTION( ( (i3 < 0) || (i3 >=
dim3_) ), std::invalid_argument,
1558 ">>> ERROR (FieldContainer): 4th index is out of range.");
1565 template<
class Scalar,
int ArrayTypeId>
1570 const int i4)
const {
1571 #ifdef HAVE_INTREPID_DEBUG 1572 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 5), std::invalid_argument,
1573 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1574 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1575 ">>> ERROR (FieldContainer): 1st index is out of range.");
1576 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1577 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1578 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
1579 ">>> ERROR (FieldContainer): 3rd index is out of range.");
1580 TEUCHOS_TEST_FOR_EXCEPTION( ( (i3 < 0) || (i3 >=
dim3_) ), std::invalid_argument,
1581 ">>> ERROR (FieldContainer): 4th index is out of range.");
1582 TEUCHOS_TEST_FOR_EXCEPTION( ( (i4 < 0) || (i4 >=
dim4_) ), std::invalid_argument,
1583 ">>> ERROR (FieldContainer): 5th index is out of range.");
1588 template<
class Scalar,
int ArrayTypeId>
1594 #ifdef HAVE_INTREPID_DEBUG 1595 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 5), std::invalid_argument,
1596 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1597 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1598 ">>> ERROR (FieldContainer): 1st index is out of range.");
1599 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1600 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1601 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
1602 ">>> ERROR (FieldContainer): 3rd index is out of range.");
1603 TEUCHOS_TEST_FOR_EXCEPTION( ( (i3 < 0) || (i3 >=
dim3_) ), std::invalid_argument,
1604 ">>> ERROR (FieldContainer): 4th index is out of range.");
1605 TEUCHOS_TEST_FOR_EXCEPTION( ( (i4 < 0) || (i4 >=
dim4_) ), std::invalid_argument,
1606 ">>> ERROR (FieldContainer): 5th index is out of range.");
1613 template<
class Scalar,
int ArrayTypeId>
1615 #ifdef HAVE_INTREPID_DEBUG 1616 TEUCHOS_TEST_FOR_EXCEPTION( ( (address < 0) || (address >= (
int)
data_.size() ) ),
1617 std::invalid_argument,
1618 ">>> ERROR (FieldContainer): Specified address is out of range.");
1620 return data_ptr_[address];
1625 template<
class Scalar,
int ArrayTypeId>
1627 #ifdef HAVE_INTREPID_DEBUG 1628 TEUCHOS_TEST_FOR_EXCEPTION( ( (address < 0) || (address >= (
int)
data_.size() ) ),
1629 std::invalid_argument,
1630 ">>> ERROR (FieldContainer): Specified address is out of range.");
1632 return data_ptr_[address];
1637 template<
class Scalar,
int ArrayTypeId>
1640 #ifdef HAVE_INTREPID_DEBUG 1641 TEUCHOS_TEST_FOR_EXCEPTION( (
this == &right ),
1642 std::invalid_argument,
1643 ">>> ERROR (FieldContainer): Invalid right-hand side to '='. Self-assignment prohibited.");
1651 data_ptr_ =
data_.begin();
1664 template<
class Scalar,
int ArrayTypeId>
1665 std::ostream& operator << (std::ostream& os, const FieldContainer<Scalar, ArrayTypeId>& container) {
1668 Teuchos::oblackholestream oldFormatState;
1669 oldFormatState.copyfmt(os);
1671 os.setf(std::ios_base::scientific, std::ios_base::floatfield);
1672 os.setf(std::ios_base::right);
1673 int myprec = os.precision();
1675 int size = container.size();
1676 int rank = container.rank();
1677 Teuchos::Array<int> multiIndex(rank);
1679 container.dimensions(dimensions);
1681 os<<
"===============================================================================\n"\
1682 <<
"\t Container size = " << size <<
"\n" 1683 <<
"\t Container rank = " << rank <<
"\n" ;
1685 if( (rank == 0 ) && (size == 0) ) {
1686 os<<
"====================================================================================\n"\
1687 <<
"| *** This is an empty container **** |\n";
1690 os<<
"\t Dimensions = ";
1692 for(
int r = 0; r <
rank; r++){
1693 os <<
" (" << dimensions[r] <<
") ";
1697 os<<
"====================================================================================\n"\
1698 <<
"| Multi-index Enumeration Value |\n"\
1699 <<
"====================================================================================\n";
1702 for(
int address = 0; address <
size; address++){
1703 container.getMultiIndex(multiIndex,address);
1704 std::ostringstream mistring;
1705 for(
int r = 0; r <
rank; r++){
1706 mistring << multiIndex[r] << std::dec <<
" ";
1708 os.setf(std::ios::right, std::ios::adjustfield);
1709 os << std::setw(27) << mistring.str();
1710 os << std::setw(20) << address;
1712 os.setf(std::ios::left, std::ios::adjustfield);
1713 os << std::setw(myprec+8) << container[address] <<
"\n";
1716 os<<
"====================================================================================\n\n";
1719 os.copyfmt(oldFormatState);
int size() const
Returns size of the FieldContainer defined as the product of its dimensions.
const Scalar & operator[](const int address) const
Overloaded [] operator. Returns value based on its enumeration. Data cannot be modified.
FieldContainer & operator=(const FieldContainer &right)
Assignment operator *this = right.
int dim3_
4th dimension of the array
Teuchos::Array< int > dimensions_
Array to store dimensions (dimensions) for the multi-indices. Admissible range (dimension) for the k-...
void clear()
Clears FieldContainer to trivial container (one with rank = 0 and size = 0)
int dim1_
2nd dimension of the array
int dimension(const int whichDim) const
Returns the specified dimension.
int dim2_
3rd dimension of the array
Teuchos::ArrayRCP< Scalar > data_
Array to store the multi-indexed quantity.
void getMultiIndex(int &i0, const int valueEnum) const
Returns the multi-index of a value, based on its enumeration, as a list, for rank-1 containers...
int getOperatorRank(const EFunctionSpace spaceType, const EOperator operatorType, const int spaceDim)
Returns rank of an operator.
EOperator
Enumeration of primitive operators available in Intrepid. Primitive operators act on reconstructed fu...
int rank() const
Return rank of the FieldContainer = number of indices used to tag the multi-indexed value...
int getEnumeration(const int i0) const
Returns enumeration of a value (its order relative to the container), based on its multi-index...
const Scalar & operator()(const int i0) const
Overloaded () operators for rank-1 containers. Data cannot be modified.
void setValue(const Scalar dataValue, const Teuchos::Array< int > &multiIndex)
Assign value by its multi-index.
void setValues(const Teuchos::ArrayView< Scalar > &dataArray)
Fills an existing FieldContainer with Scalars stored in a Teuchos::Array without changing rank and di...
int getFieldRank(const EFunctionSpace spaceType)
Returns the rank of fields in a function space of the specified type.
Implementation of a templated lexicographical container for a multi-indexed scalar quantity...
int getDkCardinality(const EOperator operatorType, const int spaceDim)
Returns cardinality of Dk, i.e., the number of all derivatives of order k.
void resize(const int dim0)
Resizes FieldContainer to a rank-1 container with the specified dimension, initialized by 0...
FieldContainer()
Default constructor.
void initialize(const Scalar value=0)
Initializes a field container by assigning value to all its elements.
int isValidOperator(const EOperator operatorType)
Verifies validity of an operator enum.
int dim0_
1st dimension of the array
int dim4_
5th dimension of the array
Scalar getValue(const Teuchos::Array< int > &multiIndex) const
Retrieve value by its multi-index. To retrieve it by enumeration use the overloaded []...
void dimensions(Vector &dimensions) const
Returns array with the dimensions of the container.