Forward compatibility: flex
[foam-extend-3.2.git] / src / finiteVolume / fvMesh / fvPatches / constraint / overlapGgi / overlapGgiFvPatch.C
blob69b0fc9142010d6cfd15821239f299f3b49a6af6
1 /*---------------------------------------------------------------------------*\
2   =========                 |
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 -------------------------------------------------------------------------------
8 License
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 Author
25     Hrvoje Jasak, Wikki Ltd.  All rights reserved.
27 \*---------------------------------------------------------------------------*/
29 #include "overlapGgiFvPatch.H"
30 #include "addToRunTimeSelectionTable.H"
31 #include "fvBoundaryMesh.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
37     defineTypeNameAndDebug(overlapGgiFvPatch, 0);
38     addToRunTimeSelectionTable(fvPatch, overlapGgiFvPatch, polyPatch);
42 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
44 // Make patch weighting factors
45 void Foam::overlapGgiFvPatch::makeWeights(scalarField& w) const
47     // Calculation of weighting factors is performed from the master
48     // position, using reconstructed shadow cell centres
49     // HJ, 2/Aug/2007
50     if (overlapGgiPolyPatch_.master())
51     {
52         vectorField n = nf();
54         // Note: mag in the dot-product.
55         // For all valid meshes, the non-orthogonality will be less than
56         // 90 deg and the dot-product will be positive.  For invalid
57         // meshes (d & s <= 0), this will stabilise the calculation
58         // but the result will be poor.  HJ, 24/Aug/2011
59         scalarField nfc =
60             mag(n & (overlapGgiPolyPatch_.reconFaceCellCentres() - Cf()));
62         w = nfc/(mag(n & (Cf() - Cn())) + nfc);
63     }
64     else
65     {
66         // Pick up weights from the master side
67         scalarField masterWeights(shadow().size());
68         shadow().makeWeights(masterWeights);
70         w = interpolate(1 - masterWeights);
71     }
75 // Make patch face - neighbour cell distances
76 void Foam::overlapGgiFvPatch::makeDeltaCoeffs(scalarField& dc) const
78     if (overlapGgiPolyPatch_.master())
79     {
80         // Stabilised form for bad meshes.  HJ, 24/Aug/2011
81         vectorField d = delta();
83         dc = 1.0/max(nf() & d, 0.05*mag(d));
84     }
85     else
86     {
87         scalarField masterDeltas(shadow().size());
88         shadow().makeDeltaCoeffs(masterDeltas);
89         dc = interpolate(masterDeltas);
90     }
94 void Foam::overlapGgiFvPatch::makeCorrVecs(vectorField& cv) const
96     // Non-orthogonality correction on a ggi interface
97     // MB, 7/April/2009
99     // Calculate correction vectors on coupled patches
100     const scalarField& patchDeltaCoeffs = deltaCoeffs();
102     vectorField patchDeltas = delta();
103     vectorField n = nf();
104     cv = n - patchDeltas*patchDeltaCoeffs;
108 const Foam::overlapGgiFvPatch& Foam::overlapGgiFvPatch::shadow() const
110     const fvPatch& p =
111         this->boundaryMesh()[overlapGgiPolyPatch_.shadowIndex()];
113     return refCast<const overlapGgiFvPatch>(p);
117 // Return delta (P to N) vectors across coupled patch
118 Foam::tmp<Foam::vectorField> Foam::overlapGgiFvPatch::delta() const
120     if (overlapGgiPolyPatch_.master())
121     {
122         return overlapGgiPolyPatch_.reconFaceCellCentres() - Cn();
123     }
124     else
125     {
126 //         vectorField masterDelta = shadow().Cn()
127 //             - overlapGgiPolyPatch_.shadow().reconFaceCellCentres();
129 //         return interpolate(masterDelta);
131         return interpolate
132         (
133             shadow().Cn()
134           - overlapGgiPolyPatch_.shadow().reconFaceCellCentres()
135         );
136     }
140 Foam::tmp<Foam::labelField> Foam::overlapGgiFvPatch::interfaceInternalField
142     const unallocLabelList& internalData
143 ) const
145     return patchInternalField(internalData);
149 Foam::tmp<Foam::labelField> Foam::overlapGgiFvPatch::transfer
151     const Pstream::commsTypes,
152     const unallocLabelList& interfaceData
153 ) const
155     notImplemented
156     (
157         "overlapGgiFvPatchField<Type>::"
158         "transfer(const unallocLabelList& interfaceData) const"
159     );
161     return labelField::null();
165 Foam::tmp<Foam::labelField> Foam::overlapGgiFvPatch::internalFieldTransfer
167     const Pstream::commsTypes,
168     const unallocLabelList& iF
169 ) const
171     return shadow().patchInternalField(iF);
175 // ************************************************************************* //