1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-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/>.
24 \*---------------------------------------------------------------------------*/
26 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
28 inline Foam::pointConstraint::pointConstraint()
30 Tuple2<label, vector>(0, vector::zero)
34 inline Foam::pointConstraint::pointConstraint(Istream& is)
36 Tuple2<label, vector>(is)
40 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
42 void Foam::pointConstraint::applyConstraint(const vector& cd)
49 else if (first() == 1)
51 vector planeNormal = cd ^ second();
52 scalar magPlaneNormal = mag(planeNormal);
54 if (magPlaneNormal > 1e-3)
57 second() = planeNormal/magPlaneNormal;
60 else if (first() == 2)
62 if (mag(cd & second()) > 1e-3)
65 second() = vector::zero;
71 void Foam::pointConstraint::combine(const pointConstraint& pc)
77 else if (first() == 1)
81 // Apply to supplied point constaint
85 else if (first() == 2)
89 else if (pc.first() == 1)
91 applyConstraint(pc.second());
93 else if (pc.first() == 2)
95 // Both constrained to line. Same (+-)direction?
96 if (mag(second() & pc.second()) <= (1.0-1e-3))
98 // Different directions
100 second() = vector::zero;
106 second() = vector::zero;
112 Foam::tensor Foam::pointConstraint::constraintTransformation() const
118 else if (first() == 1)
120 return I - sqr(second());
122 else if (first() == 2)
124 return sqr(second());
133 // ************************************************************************* //