mappedPatchBaseI.H 4.66 KB
Newer Older
andy's avatar
andy committed
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
andy's avatar
andy committed
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2015 OpenFOAM Foundation
andy's avatar
andy committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    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.

    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
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

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

inline const Foam::mappedPatchBase::sampleMode&
Foam::mappedPatchBase::mode() const
{
    return mode_;
}


inline const Foam::word& Foam::mappedPatchBase::sampleRegion() const
{
37 38 39 40
    if (sampleRegion_.empty())
    {
        if (!coupleGroup_.valid())
        {
41
            FatalErrorInFunction
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
                << "Supply either a regionName or a coupleGroup"
                << " for patch " << patch_.name()
                << " in region " << patch_.boundaryMesh().mesh().name()
                << exit(FatalError);
        }

        // Try and use patchGroup to find samplePatch and sampleRegion
        label samplePatchID = coupleGroup_.findOtherPatchID
        (
            patch_,
            sampleRegion_
        );

        samplePatch_ = sampleMesh().boundaryMesh()[samplePatchID].name();
    }
andy's avatar
andy committed
57 58 59 60 61 62
    return sampleRegion_;
}


inline const Foam::word& Foam::mappedPatchBase::samplePatch() const
{
63 64 65 66
    if (samplePatch_.empty())
    {
        if (!coupleGroup_.valid())
        {
67
            FatalErrorInFunction
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
                << "Supply either a patchName or a coupleGroup"
                << " for patch " << patch_.name()
                << " in region " << patch_.boundaryMesh().mesh().name()
                << exit(FatalError);
        }

        // Try and use patchGroup to find samplePatch and sampleRegion
        label samplePatchID = coupleGroup_.findOtherPatchID
        (
            patch_,
            sampleRegion_
        );

        samplePatch_ = sampleMesh().boundaryMesh()[samplePatchID].name();
    }
andy's avatar
andy committed
83 84 85 86
    return samplePatch_;
}


87 88 89 90 91 92
inline const Foam::word& Foam::mappedPatchBase::coupleGroup() const
{
    return coupleGroup_.name();
}


93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
inline Foam::label Foam::mappedPatchBase::sampleSize() const
{
    switch (mode_)
    {
        case NEARESTPATCHFACEAMI:
        {
            return samplePolyPatch().size();
        }
        case NEARESTCELL:
        {
            return sampleMesh().nCells();
        }
        case NEARESTPATCHFACE:
        {
            return samplePolyPatch().size();
        }
109 110 111 112
        case NEARESTPATCHPOINT:
        {
            return samplePolyPatch().nPoints();
        }
113 114 115
        case NEARESTFACE:
        {
            const polyMesh& mesh = sampleMesh();
116
            return mesh.nBoundaryFaces();
117 118 119
        }
        default:
        {
120
            FatalErrorInFunction
121 122 123 124 125 126 127
                << "problem." << abort(FatalError);
            return -1;
        }
    }
}


andy's avatar
andy committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
inline const Foam::vector& Foam::mappedPatchBase::offset() const
{
    return offset_;
}


inline const Foam::vectorField& Foam::mappedPatchBase::offsets() const
{
    return offsets_;
}


inline bool Foam::mappedPatchBase::sameRegion() const
{
    return sameRegion_;
}


inline const Foam::mapDistribute& Foam::mappedPatchBase::map() const
{
148 149 150 151 152 153 154 155
    const polyMesh& thisMesh = patch_.boundaryMesh().mesh();
    bool topoChange = sampleMesh().topoChanging() || thisMesh.topoChanging();

    if (topoChange)
    {
        mapPtr_.clear();
    }

andy's avatar
andy committed
156 157 158 159 160
    if (mapPtr_.empty())
    {
        calcMapping();
    }

161
    return *mapPtr_;
andy's avatar
andy committed
162 163 164 165 166 167 168 169
}


inline const Foam::AMIPatchToPatchInterpolation& Foam::mappedPatchBase::AMI
(
    bool forceUpdate
) const
{
170 171 172 173 174
    const polyMesh& thisMesh = patch_.boundaryMesh().mesh();
    bool topoChange = sampleMesh().topoChanging() || thisMesh.topoChanging();

    if (topoChange || forceUpdate)
    {
175
        AMIPtr_->upToDate() = false;
176 177
    }

178
    calcAMI();
andy's avatar
andy committed
179

180
    return *AMIPtr_;
andy's avatar
andy committed
181 182 183 184
}


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