pointEdgePoint.H 7.73 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.

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

Class
    Foam::pointEdgePoint

Description
31 32
    Holds information regarding nearest wall point. Used in PointEdgeWave.
    (so not standard FaceCellWave)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
    To be used in wall distance calculation.

SourceFiles
    pointEdgePointI.H
    pointEdgePoint.C

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

#ifndef pointEdgePoint_H
#define pointEdgePoint_H

#include "point.H"
#include "label.H"
#include "scalar.H"
#include "tensor.H"
#include "pTraits.H"

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

namespace Foam
{

55
// Forward Declarations
56 57
class polyPatch;
class polyMesh;
58 59 60 61 62
class pointEdgePoint;

Istream& operator>>(Istream&, pointEdgePoint&);
Ostream& operator<<(Ostream&, const pointEdgePoint&);

63
/*---------------------------------------------------------------------------*\
64
                       Class pointEdgePoint Declaration
65 66 67 68
\*---------------------------------------------------------------------------*/

class pointEdgePoint
{
69
    // Private Data
70

71
        //- Position of nearest wall center
72 73
        point origin_;

74
        //- Normal distance (squared) from point to origin
75 76
        scalar distSqr_;

Andrew Heather's avatar
Andrew Heather committed
77

78 79
    // Private Member Functions

80 81 82
        //- Evaluate distance to point.
        //  Update distSqr, origin from whomever is nearer pt.
        //  \return true if w2 is closer to point, false otherwise.
83
        template<class TrackingData>
84 85 86 87
        inline bool update
        (
            const point&,
            const pointEdgePoint& w2,
88 89
            const scalar tol,
            TrackingData& td
90 91 92 93
        );

        //- Combine current with w2. Update distSqr, origin if w2 has smaller
        //  quantities and returns true.
94
        template<class TrackingData>
95 96 97
        inline bool update
        (
            const pointEdgePoint& w2,
98 99
            const scalar tol,
            TrackingData& td
100 101
        );

Andrew Heather's avatar
Andrew Heather committed
102

103 104 105 106
public:

    // Constructors

107
        //- Default construct
108 109 110
        inline pointEdgePoint();

        //- Construct from origin, distance
111
        inline pointEdgePoint(const point& origin, const scalar distSqr);
112 113 114 115 116 117


    // Member Functions

        // Access

118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
            const point& origin() const
            {
                return origin_;
            }
            point& origin()
            {
                return origin_;
            }

            scalar distSqr() const
            {
                return distSqr_;
            }
            scalar& distSqr()
            {
                return distSqr_;
            }
135 136


137
        // Needed by PointEdgeWave
138

139
            //- Changed or contains original (invalid) value
140 141
            template<class TrackingData>
            inline bool valid(TrackingData& td) const;
142

143
            //- Check for identical geometrical data (eg, cyclics checking)
144 145 146 147 148 149 150
            template<class TrackingData>
            inline bool sameGeometry
            (
                const pointEdgePoint&,
                const scalar tol,
                TrackingData& td
            ) const;
151 152 153

            //- Convert origin to relative vector to leaving point
            //  (= point coordinate)
154
            template<class TrackingData>
155 156 157
            inline void leaveDomain
            (
                const polyPatch& patch,
158
                const label patchPointi,
159 160
                const point& pos,
                TrackingData& td
161 162 163
            );

            //- Convert relative origin to absolute by adding entering point
164
            template<class TrackingData>
165 166 167
            inline void enterDomain
            (
                const polyPatch& patch,
168
                const label patchPointi,
169 170
                const point& pos,
                TrackingData& td
171 172 173
            );

            //- Apply rotation matrix to origin
174 175 176 177 178 179
            template<class TrackingData>
            inline void transform
            (
                const tensor& rotTensor,
                TrackingData& td
            );
180 181

            //- Influence of edge on point
182
            template<class TrackingData>
183 184 185
            inline bool updatePoint
            (
                const polyMesh& mesh,
186
                const label pointi,
187 188
                const label edgeI,
                const pointEdgePoint& edgeInfo,
189 190
                const scalar tol,
                TrackingData& td
191 192 193 194
            );

            //- Influence of different value on same point.
            //  Merge new and old info.
195
            template<class TrackingData>
196 197 198
            inline bool updatePoint
            (
                const polyMesh& mesh,
199
                const label pointi,
200
                const pointEdgePoint& newPointInfo,
201 202
                const scalar tol,
                TrackingData& td
203 204 205 206
            );

            //- Influence of different value on same point.
            //  No information about current position whatsoever.
207
            template<class TrackingData>
208 209 210
            inline bool updatePoint
            (
                const pointEdgePoint& newPointInfo,
211 212
                const scalar tol,
                TrackingData& td
213 214 215
            );

            //- Influence of point on edge.
216
            template<class TrackingData>
217 218 219 220
            inline bool updateEdge
            (
                const polyMesh& mesh,
                const label edgeI,
221
                const label pointi,
222
                const pointEdgePoint& pointInfo,
223 224
                const scalar tol,
                TrackingData& td
225 226
            );

227
            //- Test for equality, with TrackingData
228 229 230
            template<class TrackingData>
            inline bool equal(const pointEdgePoint&, TrackingData& td) const;

231 232 233

    // Member Operators

234
        //- Test for equality
235
        inline bool operator==(const pointEdgePoint&) const;
236 237

        //- Test for inequality
238 239 240 241 242 243 244 245 246 247
        inline bool operator!=(const pointEdgePoint&) const;


    // IOstream Operators

        friend Ostream& operator<<(Ostream&, const pointEdgePoint&);
        friend Istream& operator>>(Istream&, pointEdgePoint&);
};


248 249 250 251 252 253 254
// * * * * * * * * * * * * * * * * * Traits  * * * * * * * * * * * * * * * * //

//- Contiguous data for pointEdgePoint
template<> struct is_contiguous<pointEdgePoint> : std::true_type {};

//- Contiguous scalar data for pointEdgePoint
template<> struct is_contiguous_scalar<pointEdgePoint> : std::true_type {};
255 256


257 258 259 260 261 262 263 264 265 266 267 268 269
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

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

#include "pointEdgePointI.H"

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

#endif

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