Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "SundanceFunctionIdentifier.hpp"
00043 #include "SundanceOrderedTuple.hpp"
00044
00045 using namespace Sundance;
00046 using namespace Sundance;
00047
00048 FunctionIdentifier::FunctionIdentifier()
00049 : dofID_(-1), algSpec_(ScalarAT)
00050 {}
00051
00052 FunctionIdentifier::FunctionIdentifier(
00053 const AlgebraSpecifier& algSpec)
00054 : dofID_(nextID()), algSpec_(algSpec)
00055 {}
00056
00057 FunctionIdentifier::FunctionIdentifier(
00058 const FunctionIdentifier* parent,
00059 const AlgebraSpecifier& algSpec)
00060 : dofID_(-1), algSpec_(algSpec)
00061 {
00062
00063 TEUCHOS_TEST_FOR_EXCEPT(parent==0);
00064 dofID_ = parent->dofID();
00065
00066
00067 TEUCHOS_TEST_FOR_EXCEPTION(!parent->algSpec_.isVector(), std::logic_error,
00068 "attempted to form a function ID for a component of a non-vector object:"
00069 "parent=" << parent->toString() << " component spec=" << algSpec);
00070 TEUCHOS_TEST_FOR_EXCEPTION(algSpec.isVector() || algSpec.isScalar(), std::runtime_error,
00071 "attempted to define a vector or scalar as a component of another object."
00072 "parent=" << parent->toString() << " component spec=" << algSpec);
00073 }
00074
00075
00076
00077 int FunctionIdentifier::componentIndex() const
00078 {
00079 TEUCHOS_TEST_FOR_EXCEPTION(!(algSpec_.isCoordinateComponent() || algSpec_.isScalar()), std::logic_error,
00080 "attempted to find component index for a FID that is not a "
00081 "scalar or a coordinate component of a vector");
00082 if (algSpec_.isScalar()) return 0;
00083 return algSpec_.direction();
00084 }
00085
00086 string FunctionIdentifier::toString() const
00087 {
00088 TeuchosOStringStream os;
00089 os << *this;
00090 return os.str();
00091 }
00092
00093 FunctionIdentifier FunctionIdentifier::createNormal() const
00094 {
00095 TEUCHOS_TEST_FOR_EXCEPTION(!isVector(), std::logic_error,
00096 "attempted to find normal component of a FID that is not a vector");
00097
00098 return FunctionIdentifier(this, normalAlgebraSpec());
00099 }
00100
00101 bool FunctionIdentifier::operator<(const FunctionIdentifier& other) const
00102 {
00103 OrderedPair<int, AlgebraSpecifier> me(dofID_, algSpec_);
00104 OrderedPair<int, AlgebraSpecifier> you(other.dofID_, other.algSpec_);
00105 return me < you;
00106 }
00107
00108 FunctionIdentifier FunctionIdentifier::createComponent(int d) const
00109 {
00110 TEUCHOS_TEST_FOR_EXCEPTION(!isVector(), std::logic_error,
00111 "attempted to find component of a FID that is not a vector");
00112
00113 return FunctionIdentifier(this, coordAlgebraSpec(d));
00114 }
00115
00116 namespace Sundance
00117 {
00118
00119 FunctionIdentifier makeFuncID(int tensorOrder)
00120 {
00121 if (tensorOrder==0)
00122 return FunctionIdentifier(scalarAlgebraSpec());
00123 else if (tensorOrder==1)
00124 return FunctionIdentifier(vectorAlgebraSpec());
00125 else
00126 TEUCHOS_TEST_FOR_EXCEPT(true);
00127 return FunctionIdentifier(scalarAlgebraSpec());
00128 }
00129
00130 }
00131
00132
00133 namespace std
00134 {
00135
00136 ostream& operator<<(std::ostream& os,
00137 const Sundance::FunctionIdentifier& fid)
00138 {
00139 os << "FuncID(dofID=" << fid.dofID() << ", component type=" << fid.algSpec() << ")";
00140 return os;
00141 }
00142
00143 }
00144