1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "coupledPolyPatch.H"
28 #include "transform.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 defineTypeNameAndDebug(Foam::coupledPolyPatch, 0);
36 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
38 void Foam::coupledPolyPatch::calcTransformTensors
40 const vectorField& Cf,
41 const vectorField& Cr,
42 const vectorField& nf,
43 const vectorField& nr,
44 const scalarField& smallDist,
50 Pout<< "coupledPolyPatch::calcTransformTensors : " << name() << endl
51 << " (half)size:" << Cf.size() << nl
52 << " absTol:" << absTol << nl
53 << " sum(mag(nf & nr)):" << sum(mag(nf & nr)) << endl;
56 // Tolerance calculation.
57 // - normal calculation: assume absTol is the absolute error in a
58 // single normal/transformation calculation. Consists both of numerical
59 // precision (on the order of SMALL and of writing precision
60 // (from e.g. decomposition)
61 // Then the overall error of summing the normals is sqrt(size())*absTol
62 // - separation calculation: pass in from the outside an allowable error.
67 separation_.setSize(0);
73 scalar error = absTol*Foam::sqrt(1.0*Cf.size());
77 Pout<< " error:" << error << endl;
80 if (sum(mag(nf & nr)) < Cf.size() - error)
82 // Rotation, no separation
84 separation_.setSize(0);
86 forwardT_.setSize(Cf.size());
87 reverseT_.setSize(Cf.size());
89 forAll (forwardT_, facei)
91 forwardT_[facei] = rotationTensor(-nr[facei], nf[facei]);
92 reverseT_[facei] = rotationTensor(nf[facei], -nr[facei]);
97 Pout<< " sum(mag(forwardT_ - forwardT_[0])):"
98 << sum(mag(forwardT_ - forwardT_[0]))
102 if (sum(mag(forwardT_ - forwardT_[0])) < error)
104 forwardT_.setSize(1);
105 reverseT_.setSize(1);
109 Pout<< " difference in rotation less than"
110 << " local tolerance "
111 << error << ". Assuming uniform rotation." << endl;
117 forwardT_.setSize(0);
118 reverseT_.setSize(0);
120 separation_ = (nf & (Cr - Cf))*nf;
123 // - separation is zero. No separation.
124 // - separation is same. Single separation vector.
125 // - separation differs per face. Separation vectorField.
127 // Check for different separation per face
128 bool sameSeparation = true;
130 forAll(separation_, facei)
132 scalar smallSqr = sqr(smallDist[facei]);
134 if (magSqr(separation_[facei] - separation_[0]) > smallSqr)
138 Pout<< " separation " << separation_[facei]
140 << " differs from separation[0] " << separation_[0]
141 << " by more than local tolerance "
143 << ". Assuming non-uniform separation." << endl;
145 sameSeparation = false;
152 // Check for zero separation (at 0 so everywhere)
153 if (magSqr(separation_[0]) < sqr(smallDist[0]))
157 Pout<< " separation " << mag(separation_[0])
158 << " less than local tolerance " << smallDist[0]
159 << ". Assuming zero separation." << endl;
162 separation_.setSize(0);
168 Pout<< " separation " << mag(separation_[0])
169 << " more than local tolerance " << smallDist[0]
170 << ". Assuming uniform separation." << endl;
173 separation_.setSize(1);
181 Pout<< " separation_:" << separation_.size() << nl
182 << " forwardT size:" << forwardT_.size() << endl;
187 // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
189 Foam::coupledPolyPatch::coupledPolyPatch
195 const polyBoundaryMesh& bm
198 polyPatch(name, size, start, index, bm)
202 Foam::coupledPolyPatch::coupledPolyPatch
205 const dictionary& dict,
207 const polyBoundaryMesh& bm
210 polyPatch(name, dict, index, bm)
214 Foam::coupledPolyPatch::coupledPolyPatch
216 const coupledPolyPatch& pp,
217 const polyBoundaryMesh& bm
224 Foam::coupledPolyPatch::coupledPolyPatch
226 const coupledPolyPatch& pp,
227 const polyBoundaryMesh& bm,
233 polyPatch(pp, bm, index, newSize, newStart)
237 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
239 Foam::coupledPolyPatch::~coupledPolyPatch()
243 // ************************************************************************* //