|
|
|
pointConstraintI.HGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 \*---------------------------------------------------------------------------*/ 00026 00027 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 00028 00029 inline Foam::pointConstraint::pointConstraint() 00030 : 00031 Tuple2<label, vector>(0, vector::zero) 00032 {} 00033 00034 00035 inline Foam::pointConstraint::pointConstraint(Istream& is) 00036 : 00037 Tuple2<label, vector>(is) 00038 {} 00039 00040 00041 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 00042 00043 void Foam::pointConstraint::applyConstraint(const vector& cd) 00044 { 00045 if (first() == 0) 00046 { 00047 first() = 1; 00048 second() = cd; 00049 } 00050 else if (first() == 1) 00051 { 00052 vector planeNormal = cd ^ second(); 00053 scalar magPlaneNormal = mag(planeNormal); 00054 00055 if (magPlaneNormal > 1e-3) 00056 { 00057 first() = 2; 00058 second() = planeNormal/magPlaneNormal; 00059 } 00060 } 00061 else if (first() == 2) 00062 { 00063 if (mag(cd & second()) > 1e-3) 00064 { 00065 first() = 3; 00066 second() = vector::zero; 00067 } 00068 } 00069 } 00070 00071 00072 Foam::tensor Foam::pointConstraint::constraintTransformation() const 00073 { 00074 if (first() == 0) 00075 { 00076 return I; 00077 } 00078 else if (first() == 1) 00079 { 00080 return I - sqr(second()); 00081 } 00082 else if (first() == 2) 00083 { 00084 return sqr(second()); 00085 } 00086 else 00087 { 00088 return tensor::zero; 00089 } 00090 } 00091 00092 00093 // ************************************************************************* // |