1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 \*---------------------------------------------------------------------------*/
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 //- Construct from components
34 Foam::coordSet::coordSet
43 refPoint_(vector::zero)
47 //- Construct from components
48 Foam::coordSet::coordSet
52 const List<point>& points,
63 //- Construct from components
64 Foam::coordSet::coordSet
68 const scalarField& points,
72 pointField(points.size(), point::zero),
75 refPoint_(point::zero)
77 if (axis_ == "x" || axis_ == "distance")
79 refPoint_.x() = refPoint;
80 replace(point::X, points);
82 else if (axis_ == "y")
84 replace(point::Y, points);
86 else if (axis_ == "z")
88 replace(point::Z, points);
94 "coordSet::coordSet(const word& name,"
95 "const word& axis, const List<scalar>& points,"
96 "const scalar refPoint)"
97 ) << "Illegal axis specification " << axis_
98 << " for sampling line " << name_
104 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 bool Foam::coordSet::hasVectorAxis() const
108 return axis_ == "xyz";
112 Foam::scalar Foam::coordSet::scalarCoord
117 const point& p = operator[](index);
123 else if (axis_ == "y")
127 else if (axis_ == "z")
131 else if (axis_ == "distance")
133 // Use distance to reference point
134 return mag(p - refPoint_);
140 "coordSet::scalarCoord(const label)"
141 ) << "Illegal axis specification " << axis_
142 << " for sampling line " << name_
150 Foam::point Foam::coordSet::vectorCoord(const label index) const
152 const point& p = operator[](index);
158 Foam::Ostream& Foam::coordSet::write(Ostream& os) const
160 os << "name:" << name_ << " axis:" << axis_ << " reference:" << refPoint_
162 << endl << "\t(coord)"
165 forAll(*this, sampleI)
167 os << '\t' << operator[](sampleI) << endl;
174 // ************************************************************************* //