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