Scalar.C
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 namespace Foam
00030 {
00031
00032
00033
00034 const char* const pTraits<Scalar>::typeName = "scalar";
00035 const Scalar pTraits<Scalar>::zero = 0.0;
00036 const Scalar pTraits<Scalar>::one = 1.0;
00037 const Scalar pTraits<Scalar>::min = -ScalarVGREAT;
00038 const Scalar pTraits<Scalar>::max = ScalarVGREAT;
00039
00040 const char* pTraits<Scalar>::componentNames[] = { "x" };
00041
00042 pTraits<Scalar>::pTraits(Istream& is)
00043 {
00044 is >> p_;
00045 }
00046
00047
00048
00049
00050 word name(const Scalar val)
00051 {
00052 std::ostringstream buf;
00053 buf << val;
00054 return buf.str();
00055 }
00056
00057
00058
00059
00060 Scalar readScalar(Istream& is)
00061 {
00062 Scalar rs;
00063 is >> rs;
00064
00065 return rs;
00066 }
00067
00068
00069 Istream& operator>>(Istream& is, Scalar& s)
00070 {
00071 token t(is);
00072
00073 if (!t.good())
00074 {
00075 is.setBad();
00076 return is;
00077 }
00078
00079 if (t.isNumber())
00080 {
00081 s = t.number();
00082 }
00083 else
00084 {
00085 is.setBad();
00086 FatalIOErrorIn("operator>>(Istream&, Scalar&)", is)
00087 << "wrong token type - expected Scalar found " << t.info()
00088 << exit(FatalIOError);
00089
00090 return is;
00091 }
00092
00093
00094 is.check("Istream& operator>>(Istream&, Scalar&)");
00095
00096 return is;
00097 }
00098
00099
00100 Ostream& operator<<(Ostream& os, const Scalar s)
00101 {
00102 os.write(s);
00103 os.check("Ostream& operator<<(Ostream&, const Scalar&)");
00104 return os;
00105 }
00106
00107
00108
00109
00110 }
00111
00112
Copyright © 2000-2009 OpenCFD Ltd