cyclicFvPatch.C 3.22 KB
Newer Older
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           | www.openfoam.com
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2016 OpenFOAM Foundation
9
10
11
12
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

13
14
15
16
    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
17
18
19
20
21
22
23

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
24
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
25
26
27
28
29
30

\*---------------------------------------------------------------------------*/

#include "cyclicFvPatch.H"
#include "addToRunTimeSelectionTable.H"
#include "fvMesh.H"
mattijs's avatar
mattijs committed
31
#include "transform.H"
32

33
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35
36

namespace Foam
{
37
38
39
    defineTypeNameAndDebug(cyclicFvPatch, 0);
    addToRunTimeSelectionTable(fvPatch, cyclicFvPatch, polyPatch);
}
40
41
42
43


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

44
void Foam::cyclicFvPatch::makeWeights(scalarField& w) const
45
{
mattijs's avatar
mattijs committed
46
47
    const cyclicFvPatch& nbrPatch = neighbFvPatch();

48
49
    const scalarField deltas(nf()&coupledFvPatch::delta());
    const scalarField nbrDeltas(nbrPatch.nf()&nbrPatch.coupledFvPatch::delta());
50

andy's avatar
andy committed
51
    forAll(deltas, facei)
52
53
    {
        scalar di = deltas[facei];
mattijs's avatar
mattijs committed
54
        scalar dni = nbrDeltas[facei];
55
56
57
58
59
60

        w[facei] = dni/(di + dni);
    }
}


61
Foam::tmp<Foam::vectorField> Foam::cyclicFvPatch::delta() const
62
{
63
64
    const vectorField patchD(coupledFvPatch::delta());
    const vectorField nbrPatchD(neighbFvPatch().coupledFvPatch::delta());
65
66

    tmp<vectorField> tpdv(new vectorField(patchD.size()));
67
    vectorField& pdv = tpdv.ref();
68
69
70
71

    // To the transformation if necessary
    if (parallel())
    {
mattijs's avatar
mattijs committed
72
        forAll(patchD, facei)
73
74
        {
            vector ddi = patchD[facei];
mattijs's avatar
mattijs committed
75
            vector dni = nbrPatchD[facei];
76
77
78
79
80
81

            pdv[facei] = ddi - dni;
        }
    }
    else
    {
mattijs's avatar
mattijs committed
82
        forAll(patchD, facei)
83
84
        {
            vector ddi = patchD[facei];
mattijs's avatar
mattijs committed
85
            vector dni = nbrPatchD[facei];
86
87
88
89
90
91
92
93
94

            pdv[facei] = ddi - transform(forwardT()[0], dni);
        }
    }

    return tpdv;
}


95
Foam::tmp<Foam::labelField> Foam::cyclicFvPatch::interfaceInternalField
96
(
97
    const labelUList& internalData
98
99
100
101
102
103
) const
{
    return patchInternalField(internalData);
}


104
Foam::tmp<Foam::labelField> Foam::cyclicFvPatch::internalFieldTransfer
105
106
(
    const Pstream::commsTypes commsType,
107
    const labelUList& iF
108
109
) const
{
110
    return neighbFvPatch().patchInternalField(iF);
111
112
113
114
}


// ************************************************************************* //