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 #include <sampling/coordSet.H>
00029
00030
00031
00032
00033 Foam::coordSet::coordSet
00034 (
00035 const word& name,
00036 const word& axis
00037 )
00038 :
00039 pointField(0),
00040 name_(name),
00041 axis_(axis),
00042 refPoint_(vector::zero)
00043 {}
00044
00045
00046
00047 Foam::coordSet::coordSet
00048 (
00049 const word& name,
00050 const word& axis,
00051 const List<point>& points,
00052 const point& refPoint
00053 )
00054 :
00055 pointField(points),
00056 name_(name),
00057 axis_(axis),
00058 refPoint_(refPoint)
00059 {}
00060
00061
00062
00063 Foam::coordSet::coordSet
00064 (
00065 const word& name,
00066 const word& axis,
00067 const scalarField& points,
00068 const scalar refPoint
00069 )
00070 :
00071 pointField(points.size(), point::zero),
00072 name_(name),
00073 axis_(axis),
00074 refPoint_(point::zero)
00075 {
00076 if (axis_ == "x" || axis_ == "distance")
00077 {
00078 refPoint_.x() = refPoint;
00079 replace(point::X, points);
00080 }
00081 else if (axis_ == "y")
00082 {
00083 replace(point::Y, points);
00084 }
00085 else if (axis_ == "z")
00086 {
00087 replace(point::Z, points);
00088 }
00089 else
00090 {
00091 FatalErrorIn
00092 (
00093 "coordSet::coordSet(const word& name,"
00094 "const word& axis, const List<scalar>& points,"
00095 "const scalar refPoint)"
00096 ) << "Illegal axis specification " << axis_
00097 << " for sampling line " << name_
00098 << exit(FatalError);
00099 }
00100 }
00101
00102
00103
00104
00105 bool Foam::coordSet::hasVectorAxis() const
00106 {
00107 return axis_ == "xyz";
00108 }
00109
00110
00111 Foam::scalar Foam::coordSet::scalarCoord
00112 (
00113 const label index
00114 ) const
00115 {
00116 const point& p = operator[](index);
00117
00118 if (axis_ == "x")
00119 {
00120 return p.x();
00121 }
00122 else if (axis_ == "y")
00123 {
00124 return p.y();
00125 }
00126 else if (axis_ == "z")
00127 {
00128 return p.z();
00129 }
00130 else if (axis_ == "distance")
00131 {
00132
00133 return mag(p - refPoint_);
00134 }
00135 else
00136 {
00137 FatalErrorIn
00138 (
00139 "coordSet::scalarCoord(const label)"
00140 ) << "Illegal axis specification " << axis_
00141 << " for sampling line " << name_
00142 << exit(FatalError);
00143
00144 return 0;
00145 }
00146 }
00147
00148
00149 Foam::point Foam::coordSet::vectorCoord(const label index) const
00150 {
00151 const point& p = operator[](index);
00152
00153 return p;
00154 }
00155
00156
00157 Foam::Ostream& Foam::coordSet::write(Ostream& os) const
00158 {
00159 os << "name:" << name_ << " axis:" << axis_ << " reference:" << refPoint_
00160 << endl
00161 << endl << "\t(coord)"
00162 << endl;
00163
00164 forAll(*this, sampleI)
00165 {
00166 os << '\t' << operator[](sampleI) << endl;
00167 }
00168
00169 return os;
00170 }
00171
00172
00173