topoDistanceData.H 7.23 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
    Copyright (C) 2019-2020 OpenCFD Ltd.
10 11 12 13
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

Andrew Heather's avatar
Andrew Heather committed
14 15 16 17
    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.
18 19 20 21 22 23 24

    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
Andrew Heather's avatar
Andrew Heather committed
25
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
26 27 28 29 30

Class
    Foam::topoDistanceData

Description
31 32
    For use with FaceCellWave. Determines topological distance to starting
    faces. Templated on passive transported data.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

SourceFiles
    topoDistanceDataI.H
    topoDistanceData.C

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

#ifndef topoDistanceData_H
#define topoDistanceData_H

#include "point.H"
#include "tensor.H"

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

namespace Foam
{

51
// Forward Declarations
52 53
class polyPatch;
class polyMesh;
54
template<class Type> class topoDistanceData;
55

56 57 58 59
template<class Type>
Istream& operator>>(Istream&, topoDistanceData<Type>&);
template<class Type>
Ostream& operator<<(Ostream&, const topoDistanceData<Type>&);
60

61
/*---------------------------------------------------------------------------*\
62
                      Class topoDistanceData Declaration
63 64
\*---------------------------------------------------------------------------*/

65
template<class Type>
66 67
class topoDistanceData
{
68
    // Private Data
69 70 71 72

        //- Distance
        label distance_;

73 74 75
        //- Starting data
        Type data_;

76 77 78 79 80

public:

    // Constructors

81 82
        //- Construct null with invalid (-1) for distance, null constructor
        //  for data
83 84
        inline topoDistanceData();

85
        //- Construct from components
86 87
        inline topoDistanceData
        (
88 89
            const label distance,
            const Type& data
90 91 92 93 94 95 96
        );


    // Member Functions

        // Access

97
            inline label distance() const
98
            {
99
                return distance_;
100
            }
101

102
            inline const Type& data() const
103
            {
104
                return data_;
105 106 107 108 109
            }


        // Needed by FaceCellWave

110
            //- Changed or contains original (invalid) value
111 112
            template<class TrackingData>
            inline bool valid(TrackingData& td) const;
113

114
            //- Check for identical geometrical data (eg, cyclics checking)
115
            template<class TrackingData>
116 117 118
            inline bool sameGeometry
            (
                const polyMesh&,
119
                const topoDistanceData<Type>&,
120 121
                const scalar,
                TrackingData& td
122 123 124 125
            ) const;

            //- Convert any absolute coordinates into relative to (patch)face
            //  centre
126
            template<class TrackingData>
127 128 129 130
            inline void leaveDomain
            (
                const polyMesh&,
                const polyPatch&,
131
                const label patchFacei,
132 133
                const point& faceCentre,
                TrackingData& td
134 135 136
            );

            //- Reverse of leaveDomain
137
            template<class TrackingData>
138 139 140 141
            inline void enterDomain
            (
                const polyMesh&,
                const polyPatch&,
142
                const label patchFacei,
143 144
                const point& faceCentre,
                TrackingData& td
145 146 147
            );

            //- Apply rotation matrix to any coordinates
148
            template<class TrackingData>
149 150 151
            inline void transform
            (
                const polyMesh&,
152 153
                const tensor&,
                TrackingData& td
154 155 156
            );

            //- Influence of neighbouring face.
157
            template<class TrackingData>
158 159 160
            inline bool updateCell
            (
                const polyMesh&,
161 162
                const label thisCelli,
                const label neighbourFacei,
163
                const topoDistanceData<Type>& neighbourInfo,
164 165
                const scalar tol,
                TrackingData& td
166 167 168
            );

            //- Influence of neighbouring cell.
169
            template<class TrackingData>
170 171 172
            inline bool updateFace
            (
                const polyMesh&,
173 174
                const label thisFacei,
                const label neighbourCelli,
175
                const topoDistanceData<Type>& neighbourInfo,
176 177
                const scalar tol,
                TrackingData& td
178 179 180
            );

            //- Influence of different value on same face.
181
            template<class TrackingData>
182 183 184
            inline bool updateFace
            (
                const polyMesh&,
185
                const label thisFacei,
186
                const topoDistanceData<Type>& neighbourInfo,
187 188
                const scalar tol,
                TrackingData& td
189 190
            );

191
            //- Test for equality, with TrackingData
192
            template<class TrackingData>
193 194 195 196 197
            inline bool equal
            (
                const topoDistanceData<Type>&,
                TrackingData& td
            ) const;
198

199

200 201
    // Member Operators

202 203
        // Needed for List IO
        inline bool operator==(const topoDistanceData<Type>&) const;
204

205
        inline bool operator!=(const topoDistanceData<Type>&) const;
206 207 208 209


    // IOstream Operators

210 211 212 213 214 215 216 217 218 219
        friend Ostream& operator<< <Type>
        (
            Ostream&,
            const topoDistanceData<Type>&
        );
        friend Istream& operator>> <Type>
        (
            Istream&,
            topoDistanceData<Type>&
        );
220 221 222
};


223 224
// * * * * * * * * * * * * * * * * * Traits  * * * * * * * * * * * * * * * * //

225 226 227
//- Data are contiguous if data type is contiguous
template<class Type>
struct is_contiguous<topoDistanceData<Type>> : is_contiguous<Type> {};
228

229 230 231 232
//- Data are contiguous label if data type is label
template<class Type>
struct is_contiguous_label<topoDistanceData<Type>> :
    is_contiguous_label<Type> {};
233

234 235 236 237
//- Data are contiguous scalar if data type is scalar
template<class Type>
struct is_contiguous_scalar<topoDistanceData<Type>> :
    is_contiguous_scalar<Type>{};
238

239 240 241 242 243 244
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

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

245 246 247 248 249 250
#ifdef NoRepository
    #include "topoDistanceData.C"
#endif

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

251 252 253 254 255 256 257
#include "topoDistanceDataI.H"

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

#endif

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