59template<
class Scalar,
int ArrayTypeId>
70 data_ptr_ =
data_.begin();
80template<
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();
98template<
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();
120template<
class Scalar,
int ArrayTypeId>
126 using Teuchos::Ordinal;
127#ifdef HAVE_INTREPID_DEBUG
128 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim0), std::invalid_argument,
129 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 1st dimension.");
130 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim1), std::invalid_argument,
131 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 2nd dimension.");
132 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim2), std::invalid_argument,
133 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 3rd dimension.");
145template<
class Scalar,
int ArrayTypeId>
152 using Teuchos::Ordinal;
153#ifdef HAVE_INTREPID_DEBUG
154 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim0), std::invalid_argument,
155 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 1st dimension.");
156 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim1), std::invalid_argument,
157 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 2nd dimension.");
158 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim2), std::invalid_argument,
159 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 3rd dimension.");
160 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim3), std::invalid_argument,
161 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 4th dimension.");
169 data_ptr_ =
data_.begin();
174template<
class Scalar,
int ArrayTypeId>
182 using Teuchos::Ordinal;
183#ifdef HAVE_INTREPID_DEBUG
184 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim0), std::invalid_argument,
185 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 1st dimension.");
186 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim1), std::invalid_argument,
187 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 2nd dimension.");
188 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim2), std::invalid_argument,
189 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 3rd dimension.");
190 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim3), std::invalid_argument,
191 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 4th dimension.");
192 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dim4), std::invalid_argument,
193 ">>> ERROR (FieldContainer): FieldContainer cannot have a negative 5th dimension.");
202 data_ptr_ =
data_.begin();
207template<
class Scalar,
int ArrayTypeId>
210#ifdef HAVE_INTREPID_DEBUG
213 for(
int dim = 0; dim < dimensionsArray.size(); dim++) {
214 TEUCHOS_TEST_FOR_EXCEPTION( (0 > dimensionsArray[dim] ), std::invalid_argument,
215 ">>> ERROR (FieldContainer): One or more negative dimensions");
220 dimensions_.assign(dimensionsArray.begin(),dimensionsArray.end());
223 unsigned int theRank = dimensions_.size();
267 data_.assign(
this -> size(), (Scalar)0);
268 data_ptr_ = data_.begin();
274template<
class Scalar,
int ArrayTypeId>
276 const Teuchos::ArrayView<Scalar>& data) {
279 dimensions_.assign(dimensionsArray.begin(),dimensionsArray.end());
334#ifdef HAVE_INTREPID_DEBUG
335 TEUCHOS_TEST_FOR_EXCEPTION( ( (
int)data.size() != this -> size() ),
336 std::invalid_argument,
337 ">>> ERROR (FieldContainer): Size of input data does not match size of this container.");
341 data_.assign(data.begin(),data.end());
342 data_ptr_ = data_.begin();
347template<
class Scalar,
int ArrayTypeId>
349 const Teuchos::ArrayRCP<Scalar>& data) {
352 dimensions_.assign(dimensionsArray.begin(),dimensionsArray.end());
407#ifdef HAVE_INTREPID_DEBUG
408 TEUCHOS_TEST_FOR_EXCEPTION( ( (
int)data.size() != this -> size() ),
409 std::invalid_argument,
410 ">>> ERROR (FieldContainer): Size of input data does not match size of this container.");
415 data_ptr_ = data_.begin();
420template<
class Scalar,
int ArrayTypeId>
423 const bool deep_copy,
424 const bool owns_mem) {
427 dimensions_.assign(dimensionsArray.begin(),dimensionsArray.end());
483 Teuchos::ArrayRCP<Scalar> arrayrcp = Teuchos::arcp<Scalar>(data, 0,
this -> size(),
false);
484 data_.deepCopy(arrayrcp());
485 data_ptr_ = data_.begin();
488 data_ = Teuchos::arcp<Scalar>(data, 0,
this -> size(), owns_mem);
495template<
class Scalar,
int ArrayTypeId>
497 const bool deep_copy,
498 const bool owns_mem) {
562 for (
int i=0; i<data.rank(); i++) {
565 dim0_ = dimensions_[0];
566 dim1_ = dimensions_[1];
567 dim2_ = dimensions_[2];
568 dim3_ = dimensions_[3];
569 dim4_ = dimensions_[4];
574 Teuchos::ArrayRCP<Scalar> arrayrcp = Teuchos::arcp<Scalar>(data.contiguous_data(), 0, this -> size(),
false);
575 data_.deepCopy(arrayrcp());
576 data_ptr_ = data_.begin();
579 data_ = Teuchos::arcp<Scalar>(data.contiguous_data(), 0, this ->
size(), owns_mem);
580 data_ptr_ =
data_.begin();
593template<
class Scalar,
int ArrayTypeId>
600template<
class Scalar,
int ArrayTypeId>
619 theSize *= dim1_*dim2_*dim3_*dim4_;
639 for (
int r = 1; r < theRank; ++r) {
649template<
class Scalar,
int ArrayTypeId>
650template<
class Vector>
657template<
class Scalar,
int ArrayTypeId>
659#ifdef HAVE_INTREPID_DEBUG
660 TEUCHOS_TEST_FOR_EXCEPTION( (0 > whichDim), std::invalid_argument,
661 ">>> ERROR (FieldContainer): dimension order cannot be negative");
662 TEUCHOS_TEST_FOR_EXCEPTION( (whichDim >=
this ->
rank() ), std::invalid_argument,
663 ">>> ERROR (FieldContainer): dimension order cannot exceed rank of the container");
670template<
class Scalar,
int ArrayTypeId>
672#ifdef HAVE_INTREPID_DEBUG
673 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 1), std::invalid_argument,
674 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
675 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || ( i0 >=
dim0_) ), std::invalid_argument,
676 ">>> ERROR (FieldContainer): index is out of range.");
683template<
class Scalar,
int ArrayTypeId>
685 const int i1)
const {
686#ifdef HAVE_INTREPID_DEBUG
687 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 2), std::invalid_argument,
688 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
689 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || ( i0 >=
dim0_) ), std::invalid_argument,
690 ">>> ERROR (FieldContainer): 1st index is out of range.");
691 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
692 ">>> ERROR (FieldContainer): 2nd index is out of range.");
694 return i0*
dim1_ + i1;
699template<
class Scalar,
int ArrayTypeId>
702 const int i2)
const {
703#ifdef HAVE_INTREPID_DEBUG
704 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 3), std::invalid_argument,
705 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
706 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || ( i0 >=
dim0_) ), std::invalid_argument,
707 ">>> ERROR (FieldContainer): 1st index is out of range.");
708 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
709 ">>> ERROR (FieldContainer): 2nd index is out of range.");
710 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
711 ">>> ERROR (FieldContainer): 3rd index is out of range.");
718template<
class Scalar,
int ArrayTypeId>
722 const int i3)
const {
723#ifdef HAVE_INTREPID_DEBUG
724 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 4), std::invalid_argument,
725 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
726 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || ( i0 >=
dim0_) ), std::invalid_argument,
727 ">>> ERROR (FieldContainer): 1st index is out of range.");
728 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
729 ">>> ERROR (FieldContainer): 2nd index is out of range.");
730 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
731 ">>> ERROR (FieldContainer): 3rd index is out of range.");
732 TEUCHOS_TEST_FOR_EXCEPTION( ( (i3 < 0) || (i3 >=
dim3_) ), std::invalid_argument,
733 ">>> ERROR (FieldContainer): 4th index is out of range.");
740template<
class Scalar,
int ArrayTypeId>
745 const int i4)
const {
746#ifdef HAVE_INTREPID_DEBUG
747 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 5), std::invalid_argument,
748 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
749 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || ( i0 >=
dim0_) ), std::invalid_argument,
750 ">>> ERROR (FieldContainer): 1st index is out of range.");
751 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
752 ">>> ERROR (FieldContainer): 2nd index is out of range.");
753 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
754 ">>> ERROR (FieldContainer): 3rd index is out of range.");
755 TEUCHOS_TEST_FOR_EXCEPTION( ( (i3 < 0) || (i3 >=
dim3_) ), std::invalid_argument,
756 ">>> ERROR (FieldContainer): 4th index is out of range.");
757 TEUCHOS_TEST_FOR_EXCEPTION( ( (i4 < 0) || (i4 >=
dim4_) ), std::invalid_argument,
758 ">>> ERROR (FieldContainer): 5th index is out of range.");
766template<
class Scalar,
int ArrayTypeId>
769#ifdef HAVE_INTREPID_DEBUG
771 TEUCHOS_TEST_FOR_EXCEPTION( ( multiIndex.size() !=
dimensions_.size() ),
772 std::invalid_argument,
773 ">>> ERROR (FieldContainer): Number of multi-indices does not match rank of container.");
774 TEUCHOS_TEST_FOR_EXCEPTION( ( ( multiIndex[0] < 0) || ( multiIndex[0] >=
dim0_) ),
775 std::invalid_argument,
776 ">>> ERROR (FieldContainer): 1st index is out of range.");
785#ifdef HAVE_INTREPID_DEBUG
786 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[4] < 0) || (multiIndex[4] >=
dim4_) ),
787 std::invalid_argument,
788 ">>> ERROR (FieldContainer): 5th index is out of range.");
789 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[3] < 0) || (multiIndex[3] >=
dim3_) ),
790 std::invalid_argument,
791 ">>> ERROR (FieldContainer): 4th index is out of range.");
792 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[2] < 0) || (multiIndex[2] >=
dim2_) ),
793 std::invalid_argument,
794 ">>> ERROR (FieldContainer): 3rd index is out of range.");
795 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[1] < 0) || (multiIndex[1] >=
dim1_) ),
796 std::invalid_argument,
797 ">>> ERROR (FieldContainer): 2nd index is out of range.");
799 address = (((multiIndex[0]*
dim1_ + multiIndex[1])*
dim2_ + multiIndex[2])*
dim3_ + multiIndex[3])*
dim4_ + multiIndex[4];
803#ifdef HAVE_INTREPID_DEBUG
804 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[3] < 0) || (multiIndex[3] >=
dim3_) ),
805 std::invalid_argument,
806 ">>> ERROR (FieldContainer): 4th index is out of range.");
807 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[2] < 0) || (multiIndex[2] >=
dim2_) ),
808 std::invalid_argument,
809 ">>> ERROR (FieldContainer): 3rd index is out of range.");
810 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[1] < 0) || (multiIndex[1] >=
dim1_) ),
811 std::invalid_argument,
812 ">>> ERROR (FieldContainer): 2nd index is out of range.");
814 address = ((multiIndex[0]*
dim1_ + multiIndex[1])*
dim2_ + multiIndex[2])*
dim3_ + multiIndex[3];
818#ifdef HAVE_INTREPID_DEBUG
819 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[2] < 0) || (multiIndex[2] >=
dim2_) ),
820 std::invalid_argument,
821 ">>> ERROR (FieldContainer): 3rd index is out of range.");
822 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[1] < 0) || (multiIndex[1] >=
dim1_) ),
823 std::invalid_argument,
824 ">>> ERROR (FieldContainer): 2nd index is out of range.");
826 address = (multiIndex[0]*
dim1_ + multiIndex[1])*
dim2_ + multiIndex[2];
830#ifdef HAVE_INTREPID_DEBUG
831 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[1] < 0) || (multiIndex[1] >=
dim1_) ),
832 std::invalid_argument,
833 ">>> ERROR (FieldContainer): 2nd index is out of range.");
835 address = multiIndex[0]*
dim1_ + multiIndex[1];
839 address = multiIndex[0];
845 address = multiIndex[0];
846 for (
int r = 0; r < theRank - 1; r++){
847#ifdef HAVE_INTREPID_DEBUG
848 TEUCHOS_TEST_FOR_EXCEPTION( ( (multiIndex[r+1] < 0) || (multiIndex[r+1] >=
dimensions_[r+1]) ),
849 std::invalid_argument,
850 ">>> ERROR (FieldContainer): Multi-index component out of range.");
853 address = address*
dimensions_[r+1] + multiIndex[r+1];
862template<
class Scalar,
int ArrayTypeId>
864 const int valueEnum)
const
866#ifdef HAVE_INTREPID_DEBUG
867 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 1), std::invalid_argument,
868 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
869 TEUCHOS_TEST_FOR_EXCEPTION( ( (valueEnum < 0) || (valueEnum >= (
int)
data_.size()) ),
870 std::invalid_argument,
871 ">>> ERROR (FieldContainer): Value enumeration is out of range.");
878template<
class Scalar,
int ArrayTypeId>
881 const int valueEnum)
const
883#ifdef HAVE_INTREPID_DEBUG
884 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 2), std::invalid_argument,
885 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
886 TEUCHOS_TEST_FOR_EXCEPTION( ( (valueEnum < 0) || (valueEnum >= (
int)
data_.size()) ),
887 std::invalid_argument,
888 ">>> ERROR (FieldContainer): Value enumeration is out of range.");
891 i0 = valueEnum/
dim1_;
892 i1 = valueEnum - i0*
dim1_;
897template<
class Scalar,
int ArrayTypeId>
901 const int valueEnum)
const
903#ifdef HAVE_INTREPID_DEBUG
904 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 3), std::invalid_argument,
905 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
906 TEUCHOS_TEST_FOR_EXCEPTION( ( (valueEnum < 0) || (valueEnum >= (
int)
data_.size()) ),
907 std::invalid_argument,
908 ">>> ERROR (FieldContainer): Value enumeration is out of range.");
911 int tempEnu = valueEnum;
912 i0 = tempEnu/tempDim;
914 tempEnu -= i0*tempDim;
916 i1 = tempEnu/tempDim;
918 tempEnu -= i1*tempDim;
920 i2 = tempEnu/tempDim;
925template<
class Scalar,
int ArrayTypeId>
930 const int valueEnum)
const
932#ifdef HAVE_INTREPID_DEBUG
933 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 4), std::invalid_argument,
934 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
935 TEUCHOS_TEST_FOR_EXCEPTION( ( (valueEnum < 0) || (valueEnum >= (
int)
data_.size()) ),
936 std::invalid_argument,
937 ">>> ERROR (FieldContainer): Value enumeration is out of range.");
940 int tempEnu = valueEnum;
941 i0 = tempEnu/tempDim;
943 tempEnu -= i0*tempDim;
945 i1 = tempEnu/tempDim;
947 tempEnu -= i1*tempDim;
949 i2 = tempEnu/tempDim;
951 tempEnu -= i2*tempDim;
953 i3 = tempEnu/tempDim;
959template<
class Scalar,
int ArrayTypeId>
965 const int valueEnum)
const
967#ifdef HAVE_INTREPID_DEBUG
968 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 5), std::invalid_argument,
969 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
970 TEUCHOS_TEST_FOR_EXCEPTION( ( (valueEnum < 0) || (valueEnum >= (
int)
data_.size()) ),
971 std::invalid_argument,
972 ">>> ERROR (FieldContainer): Value enumeration is out of range.");
975 int tempEnu = valueEnum;
976 i0 = tempEnu/tempDim;
978 tempEnu -= i0*tempDim;
980 i1 = tempEnu/tempDim;
982 tempEnu -= i1*tempDim;
984 i2 = tempEnu/tempDim;
986 tempEnu -= i2*tempDim;
988 i3 = tempEnu/tempDim;
990 tempEnu -= i3*tempDim;
992 i4 = tempEnu/tempDim;
997template<
class Scalar,
int ArrayTypeId>
998template<
class Vector>
1000 const int valueEnum)
const
1004#ifdef HAVE_INTREPID_DEBUG
1005 TEUCHOS_TEST_FOR_EXCEPTION( ( (valueEnum < 0) || (valueEnum >= (
int)
data_.size()) ),
1006 std::invalid_argument,
1007 ">>> ERROR (FieldContainer): Value enumeration is out of range.");
1012 multiIndex.resize (theRank);
1015 int temp_enum = valueEnum;
1019 for (
int r = 1; r < theRank; ++r) {
1024 multiIndex[0] = temp_enum/temp_range;
1028 for (
int r = 1; r < theRank - 1; ++r) {
1029 temp_enum -= multiIndex[r-1]*temp_range;
1031 multiIndex[r] = temp_enum/temp_range;
1037 multiIndex[theRank - 1] = temp_enum - multiIndex[theRank - 2] * temp_range;
1047template<
class Scalar,
int ArrayTypeId>
1060 data_ptr_ =
data_.begin();
1065template<
class Scalar,
int ArrayTypeId>
1069 if( newDimensions.size() == 0) {
1077 data_ptr_ =
data_.begin();
1082 dimensions_.assign(newDimensions.begin(),newDimensions.end());
1130 data_ptr_ =
data_.begin();
1136template<
class Scalar,
int ArrayTypeId>
1146 data_ptr_ =
data_.begin();
1151template<
class Scalar,
int ArrayTypeId>
1163 data_ptr_ =
data_.begin();
1168template<
class Scalar,
int ArrayTypeId>
1182 data_ptr_ =
data_.begin();
1187template<
class Scalar,
int ArrayTypeId>
1203 data_ptr_ =
data_.begin();
1208template<
class Scalar,
int ArrayTypeId>
1226 data_ptr_ =
data_.begin();
1231template<
class Scalar,
int ArrayTypeId>
1283 data_ptr_ =
data_.begin();
1287template<
class Scalar,
int ArrayTypeId>
1289 const int numFields,
1290 const EFunctionSpace spaceType,
1291 const EOperator operatorType,
1292 const int spaceDim) {
1294#ifdef HAVE_INTREPID_DEBUG
1295 TEUCHOS_TEST_FOR_EXCEPTION( ( numPoints < 0),
1296 std::invalid_argument,
1297 ">>> ERROR (FieldContainer): Number of points cannot be negative!");
1298 TEUCHOS_TEST_FOR_EXCEPTION( ( numFields < 0),
1299 std::invalid_argument,
1300 ">>> ERROR (FieldContainer): Number of fields cannot be negative!");
1301 TEUCHOS_TEST_FOR_EXCEPTION( !( (1 <= spaceDim ) && ( spaceDim <= 3 ) ),
1302 std::invalid_argument,
1303 ">>> ERROR (FieldContainer): Invalid space dimension.");
1308 const int operatorRank =
getOperatorRank(spaceType,operatorType,spaceDim);
1311 const int theRank = 1 + 1 + fieldRank + operatorRank;
1314 Teuchos::Array<int> newDimensions (theRank);
1317 newDimensions[0] = numPoints;
1318 newDimensions[1] = numFields;
1321 switch (operatorType) {
1323 case OPERATOR_VALUE:
1330 for (
int i = 0; i < fieldRank + operatorRank; ++i) {
1331 newDimensions[2 + i] = spaceDim;
1346 for(
int i = 0; i < fieldRank; i++){
1347 newDimensions[2 + i] = spaceDim;
1356 TEUCHOS_TEST_FOR_EXCEPTION(
1358 ">>> ERROR (FieldContainer): Invalid operator type");
1362 this->
resize (newDimensions);
1373template<
class Scalar,
int ArrayTypeId>
1375 for (
int i=0; i < this->
size(); i++) {
1382template<
class Scalar,
int ArrayTypeId>
1389template<
class Scalar,
int ArrayTypeId>
1391 const Teuchos::Array<int>& multiIndex) {
1397template<
class Scalar,
int ArrayTypeId>
1400 data_[order] = dataValue;
1405template<
class Scalar,
int ArrayTypeId>
1407#ifdef HAVE_INTREPID_DEBUG
1408 TEUCHOS_TEST_FOR_EXCEPTION( (dataArray.size() != (
data_.size()) ),
1409 std::invalid_argument,
1410 ">>> ERROR (FieldContainer): Size of argument does not match the size of container.");
1412 data_.assign(dataArray.begin(),dataArray.end());
1413 data_ptr_ =
data_.begin();
1418template<
class Scalar,
int ArrayTypeId>
1422#ifdef HAVE_INTREPID_DEBUG
1423 TEUCHOS_TEST_FOR_EXCEPTION( (numData !=
this ->
size() ), std::invalid_argument,
1424 ">>> ERROR (FieldContainer): Number of data does not match the size of container.");
1427 data_.assign(dataPtr, dataPtr + numData);
1428 data_ptr_ =
data_.begin();
1433template<
class Scalar,
int ArrayTypeId>
1436#ifdef HAVE_INTREPID_DEBUG
1437 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 1), std::invalid_argument,
1438 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1439 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1440 ">>> ERROR (FieldContainer): index is out of range.");
1442 return data_ptr_[i0];
1446template<
class Scalar,
int ArrayTypeId>
1449#ifdef HAVE_INTREPID_DEBUG
1450 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 1), std::invalid_argument,
1451 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1452 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1453 ">>> ERROR (FieldContainer): index is out of range.");
1455 return data_ptr_[i0];
1460template<
class Scalar,
int ArrayTypeId>
1464#ifdef HAVE_INTREPID_DEBUG
1465 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 2), std::invalid_argument,
1466 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1467 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1468 ">>> ERROR (FieldContainer): 1st index is out of range.");
1469 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1470 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1472 return data_ptr_[i0*
dim1_ + i1];
1476template<
class Scalar,
int ArrayTypeId>
1480#ifdef HAVE_INTREPID_DEBUG
1481 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 2), std::invalid_argument,
1482 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1483 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1484 ">>> ERROR (FieldContainer): 1st index is out of range.");
1485 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1486 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1488 return data_ptr_[i0*
dim1_ + i1];
1493template<
class Scalar,
int ArrayTypeId>
1498#ifdef HAVE_INTREPID_DEBUG
1499 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 3), std::invalid_argument,
1500 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1501 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1502 ">>> ERROR (FieldContainer): 1st index is out of range.");
1503 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1504 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1505 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
1506 ">>> ERROR (FieldContainer): 3rd index is out of range.");
1508 return data_ptr_[(i0*
dim1_ + i1)*
dim2_ + i2];
1511template<
class Scalar,
int ArrayTypeId>
1516#ifdef HAVE_INTREPID_DEBUG
1517 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 3), std::invalid_argument,
1518 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1519 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1520 ">>> ERROR (FieldContainer): 1st index is out of range.");
1521 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1522 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1523 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
1524 ">>> ERROR (FieldContainer): 3rd index is out of range.");
1526 return data_ptr_[(i0*
dim1_ + i1)*
dim2_ + i2];
1531template<
class Scalar,
int ArrayTypeId>
1535 const int i3)
const {
1536#ifdef HAVE_INTREPID_DEBUG
1537 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 4), std::invalid_argument,
1538 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1539 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1540 ">>> ERROR (FieldContainer): 1st index is out of range.");
1541 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1542 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1543 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
1544 ">>> ERROR (FieldContainer): 3rd index is out of range.");
1545 TEUCHOS_TEST_FOR_EXCEPTION( ( (i3 < 0) || (i3 >=
dim3_) ), std::invalid_argument,
1546 ">>> ERROR (FieldContainer): 4th index is out of range.");
1552template<
class Scalar,
int ArrayTypeId>
1557#ifdef HAVE_INTREPID_DEBUG
1558 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 4), std::invalid_argument,
1559 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1560 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1561 ">>> ERROR (FieldContainer): 1st index is out of range.");
1562 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1563 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1564 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
1565 ">>> ERROR (FieldContainer): 3rd index is out of range.");
1566 TEUCHOS_TEST_FOR_EXCEPTION( ( (i3 < 0) || (i3 >=
dim3_) ), std::invalid_argument,
1567 ">>> ERROR (FieldContainer): 4th index is out of range.");
1574template<
class Scalar,
int ArrayTypeId>
1579 const int i4)
const {
1580#ifdef HAVE_INTREPID_DEBUG
1581 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 5), std::invalid_argument,
1582 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1583 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1584 ">>> ERROR (FieldContainer): 1st index is out of range.");
1585 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1586 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1587 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
1588 ">>> ERROR (FieldContainer): 3rd index is out of range.");
1589 TEUCHOS_TEST_FOR_EXCEPTION( ( (i3 < 0) || (i3 >=
dim3_) ), std::invalid_argument,
1590 ">>> ERROR (FieldContainer): 4th index is out of range.");
1591 TEUCHOS_TEST_FOR_EXCEPTION( ( (i4 < 0) || (i4 >=
dim4_) ), std::invalid_argument,
1592 ">>> ERROR (FieldContainer): 5th index is out of range.");
1597template<
class Scalar,
int ArrayTypeId>
1603#ifdef HAVE_INTREPID_DEBUG
1604 TEUCHOS_TEST_FOR_EXCEPTION( (
this ->
rank() != 5), std::invalid_argument,
1605 ">>> ERROR (FieldContainer): Number of indices does not match rank of the container.");
1606 TEUCHOS_TEST_FOR_EXCEPTION( ( (i0 < 0) || (i0 >=
dim0_) ), std::invalid_argument,
1607 ">>> ERROR (FieldContainer): 1st index is out of range.");
1608 TEUCHOS_TEST_FOR_EXCEPTION( ( (i1 < 0) || (i1 >=
dim1_) ), std::invalid_argument,
1609 ">>> ERROR (FieldContainer): 2nd index is out of range.");
1610 TEUCHOS_TEST_FOR_EXCEPTION( ( (i2 < 0) || (i2 >=
dim2_) ), std::invalid_argument,
1611 ">>> ERROR (FieldContainer): 3rd index is out of range.");
1612 TEUCHOS_TEST_FOR_EXCEPTION( ( (i3 < 0) || (i3 >=
dim3_) ), std::invalid_argument,
1613 ">>> ERROR (FieldContainer): 4th index is out of range.");
1614 TEUCHOS_TEST_FOR_EXCEPTION( ( (i4 < 0) || (i4 >=
dim4_) ), std::invalid_argument,
1615 ">>> ERROR (FieldContainer): 5th index is out of range.");
1622template<
class Scalar,
int ArrayTypeId>
1624#ifdef HAVE_INTREPID_DEBUG
1625 TEUCHOS_TEST_FOR_EXCEPTION( ( (address < 0) || (address >= (
int)
data_.size() ) ),
1626 std::invalid_argument,
1627 ">>> ERROR (FieldContainer): Specified address is out of range.");
1629 return data_ptr_[address];
1634template<
class Scalar,
int ArrayTypeId>
1636#ifdef HAVE_INTREPID_DEBUG
1637 TEUCHOS_TEST_FOR_EXCEPTION( ( (address < 0) || (address >= (
int)
data_.size() ) ),
1638 std::invalid_argument,
1639 ">>> ERROR (FieldContainer): Specified address is out of range.");
1641 return data_ptr_[address];
1646template<
class Scalar,
int ArrayTypeId>
1649#ifdef HAVE_INTREPID_DEBUG
1650 TEUCHOS_TEST_FOR_EXCEPTION( (
this == &right ),
1651 std::invalid_argument,
1652 ">>> ERROR (FieldContainer): Invalid right-hand side to '='. Self-assignment prohibited.");
1660 data_ptr_ =
data_.begin();
1673template<
class Scalar,
int ArrayTypeId>
1677 Teuchos::oblackholestream oldFormatState;
1678 oldFormatState.copyfmt(os);
1680 os.setf(std::ios_base::scientific, std::ios_base::floatfield);
1681 os.setf(std::ios_base::right);
1682 int myprec = os.precision();
1686 Teuchos::Array<int> multiIndex(
rank);
1690 os<<
"===============================================================================\n"\
1691 <<
"\t Container size = " <<
size <<
"\n"
1692 <<
"\t Container rank = " <<
rank <<
"\n" ;
1694 if( (
rank == 0 ) && (
size == 0) ) {
1695 os<<
"====================================================================================\n"\
1696 <<
"| *** This is an empty container **** |\n";
1699 os<<
"\t Dimensions = ";
1701 for(
int r = 0; r <
rank; r++){
1706 os<<
"====================================================================================\n"\
1707 <<
"| Multi-index Enumeration Value |\n"\
1708 <<
"====================================================================================\n";
1711 for(
int address = 0; address <
size; address++){
1713 std::ostringstream mistring;
1714 for(
int r = 0; r <
rank; r++){
1715 mistring << multiIndex[r] << std::dec <<
" ";
1717 os.setf(std::ios::right, std::ios::adjustfield);
1718 os << std::setw(27) << mistring.str();
1719 os << std::setw(20) << address;
1721 os.setf(std::ios::left, std::ios::adjustfield);
1722 os << std::setw(myprec+8) << container[address] <<
"\n";
1725 os<<
"====================================================================================\n\n";
1728 os.copyfmt(oldFormatState);
1736#if defined(Intrepid_SHOW_DEPRECATED_WARNINGS)
1738#warning "The Intrepid package is deprecated"
int isValidOperator(const EOperator operatorType)
Verifies validity of an operator enum.
int getFieldRank(const EFunctionSpace spaceType)
Returns the rank of fields in a function space of the specified type.
int getOperatorRank(const EFunctionSpace spaceType, const EOperator operatorType, const int spaceDim)
Returns rank of an operator.
int getDkCardinality(const EOperator operatorType, const int spaceDim)
Returns cardinality of Dk, i.e., the number of all derivatives of order k.
Teuchos::Array< int > dimensions_
Array to store dimensions (dimensions) for the multi-indices. Admissible range (dimension) for the k-...
int dim3_
4th dimension of the array
const Scalar & operator()(const int i0) const
Overloaded () operators for rank-1 containers. Data cannot be modified.
void dimensions(Vector &dimensions) const
Returns array with the dimensions of the container.
void resize(const int dim0)
Resizes FieldContainer to a rank-1 container with the specified dimension, initialized by 0.
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.
Teuchos::ArrayRCP< Scalar > data_
Array to store the multi-indexed quantity.
void clear()
Clears FieldContainer to trivial container (one with rank = 0 and size = 0).
void setValue(const Scalar dataValue, const Teuchos::Array< int > &multiIndex)
Assign value by its multi-index.
int dim0_
1st dimension of the array
int getEnumeration(const int i0) const
Returns enumeration of a value (its order relative to the container), based on its multi-index,...
int rank() const
Return rank of the FieldContainer = number of indices used to tag the multi-indexed value.
int dim4_
5th dimension of the array
FieldContainer & operator=(const FieldContainer &right)
Assignment operator *this = right.
const Scalar & operator[](const int address) const
Overloaded [] operator. Returns value based on its enumeration. Data cannot be modified.
void setValues(const Teuchos::ArrayView< Scalar > &dataArray)
Fills an existing FieldContainer with Scalars stored in a Teuchos::Array without changing rank and di...
void initialize(const Scalar value=0)
Initializes a field container by assigning value to all its elements.
int dimension(const int whichDim) const
Returns the specified dimension.
FieldContainer()
Default constructor.
int dim1_
2nd dimension of the array
int dim2_
3rd 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 [].