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/>.
25 Hrvoje Jasak, Wikki Ltd. All rights reserved.
27 \*---------------------------------------------------------------------------*/
29 #include "overlapGgiFvPatch.H"
30 #include "addToRunTimeSelectionTable.H"
31 #include "fvBoundaryMesh.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
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
50 if (overlapGgiPolyPatch_.master())
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
60 mag(n & (overlapGgiPolyPatch_.reconFaceCellCentres() - Cf()));
62 w = nfc/(mag(n & (Cf() - Cn())) + nfc);
66 // Pick up weights from the master side
67 scalarField masterWeights(shadow().size());
68 shadow().makeWeights(masterWeights);
70 w = interpolate(1 - masterWeights);
75 // Make patch face - neighbour cell distances
76 void Foam::overlapGgiFvPatch::makeDeltaCoeffs(scalarField& dc) const
78 if (overlapGgiPolyPatch_.master())
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));
87 scalarField masterDeltas(shadow().size());
88 shadow().makeDeltaCoeffs(masterDeltas);
89 dc = interpolate(masterDeltas);
94 void Foam::overlapGgiFvPatch::makeCorrVecs(vectorField& cv) const
96 // Non-orthogonality correction on a ggi interface
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
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())
122 return overlapGgiPolyPatch_.reconFaceCellCentres() - Cn();
126 // vectorField masterDelta = shadow().Cn()
127 // - overlapGgiPolyPatch_.shadow().reconFaceCellCentres();
129 // return interpolate(masterDelta);
134 - overlapGgiPolyPatch_.shadow().reconFaceCellCentres()
140 Foam::tmp<Foam::labelField> Foam::overlapGgiFvPatch::interfaceInternalField
142 const unallocLabelList& internalData
145 return patchInternalField(internalData);
149 Foam::tmp<Foam::labelField> Foam::overlapGgiFvPatch::transfer
151 const Pstream::commsTypes,
152 const unallocLabelList& interfaceData
157 "overlapGgiFvPatchField<Type>::"
158 "transfer(const unallocLabelList& interfaceData) const"
161 return labelField::null();
165 Foam::tmp<Foam::labelField> Foam::overlapGgiFvPatch::internalFieldTransfer
167 const Pstream::commsTypes,
168 const unallocLabelList& iF
171 return shadow().patchInternalField(iF);
175 // ************************************************************************* //