1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
26 \*---------------------------------------------------------------------------*/
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 //- Construct from components
33 Foam::coordSet::coordSet
42 refPoint_(vector::zero)
46 //- Construct from components
47 Foam::coordSet::coordSet
51 const List<point>& points,
62 //- Construct from components
63 Foam::coordSet::coordSet
67 const scalarField& points,
71 pointField(points.size(), point::zero),
74 refPoint_(point::zero)
76 if (axis_ == "x" || axis_ == "distance")
78 refPoint_.x() = refPoint;
79 replace(point::X, points);
81 else if (axis_ == "y")
83 replace(point::Y, points);
85 else if (axis_ == "z")
87 replace(point::Z, points);
93 "coordSet::coordSet(const word& name,"
94 "const word& axis, const List<scalar>& points,"
95 "const scalar refPoint)"
96 ) << "Illegal axis specification " << axis_
97 << " for sampling line " << name_
103 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105 bool Foam::coordSet::hasVectorAxis() const
107 return axis_ == "xyz";
111 Foam::scalar Foam::coordSet::scalarCoord
116 const point& p = operator[](index);
122 else if (axis_ == "y")
126 else if (axis_ == "z")
130 else if (axis_ == "distance")
132 // Use distance to reference point
133 return mag(p - refPoint_);
139 "coordSet::scalarCoord(const label)"
140 ) << "Illegal axis specification " << axis_
141 << " for sampling line " << name_
149 Foam::point Foam::coordSet::vectorCoord(const label index) const
151 const point& p = operator[](index);
157 Foam::Ostream& Foam::coordSet::write(Ostream& os) const
159 os << "name:" << name_ << " axis:" << axis_ << " reference:" << refPoint_
161 << endl << "\t(coord)"
164 forAll(*this, sampleI)
166 os << '\t' << operator[](sampleI) << endl;
173 // ************************************************************************* //