boxScaling.H 5.12 KB
Newer Older
1 2 3 4 5 6 7 8
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | cfMesh: A library for mesh generation
   \\    /   O peration     |
    \\  /    A nd           | Author: Franjo Juretic (franjo.juretic@c-fields.com)
     \\/     M anipulation  | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
Andrew Heather's avatar
Andrew Heather committed
9
    This file is part of OpenFOAM.
10

Andrew Heather's avatar
Andrew Heather committed
11 12 13 14
    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.
15

Andrew Heather's avatar
Andrew Heather committed
16
    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 18 19 20 21
    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
22
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
23 24

Class
25
    Foam::Module::boxScaling
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

Description
    Checks if a box is contained inside the box object

SourceFiles
    boxScaling.C

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

#ifndef boxScaling_H
#define boxScaling_H

#include "coordinateModification.H"
#include "point.H"
#include "typeInfo.H"

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

namespace Foam
{
46 47
namespace Module
{
48

49 50 51 52
// Forward declarations
class boxScaling;
Ostream& operator<<(Ostream&, const boxScaling&);

53
/*---------------------------------------------------------------------------*\
Andrew Heather's avatar
Andrew Heather committed
54
                         Class boxScaling Declaration
55 56 57 58 59 60 61
\*---------------------------------------------------------------------------*/

class boxScaling
:
    public coordinateModification
{
    // Private data
Andrew Heather's avatar
Andrew Heather committed
62

63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
        //- centre of the box
        point centre_;

        //- length of box sides
        vector lengthVec_;

        //- scaling factors in all directions
        vector scaleVec_;

        //- min point
        point pMin_;

        //- max point
        point pMax_;

Andrew Heather's avatar
Andrew Heather committed
78

79
    // Private member functions
Andrew Heather's avatar
Andrew Heather committed
80

81 82 83
        //- calculate bounding box points
        void calculateBndBox();

Andrew Heather's avatar
Andrew Heather committed
84

85 86 87
public:

    //- Runtime type information
88
    TypeName("box");
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148


    // Constructors

        //- Null construct
        boxScaling();

        //- Construct from name, cell size, centre and sizes and scaling factors
        boxScaling
        (
            const word& name,
            const point& centre,
            const scalar lengthX,
            const scalar lengthY,
            const scalar lengthZ,
            const scalar scaleX = 1.0,
            const scalar scaleY = 1.0,
            const scalar scaleZ = 1.0
        );

        //- Construct from dictionary
        boxScaling(const word& name, const dictionary& dict);

        //- Construct and return a clone
        virtual autoPtr<coordinateModification> clone
        (
            const boxScaling& bs
        ) const
        {
            return autoPtr<coordinateModification>
            (
                new boxScaling
                (
                    bs.name(),
                    bs.centre_,
                    bs.lengthVec_.x(),
                    bs.lengthVec_.y(),
                    bs.lengthVec_.z(),
                    bs.scaleVec_.x(),
                    bs.scaleVec_.y(),
                    bs.scaleVec_.z()
                )
            );
        }

    // Member Functions

        //- return the centre of the box
        virtual point origin() const;

        //- translate the object to the modified coordinates
        //- this is needed for backward transformation
        virtual void translateAndModifyObject(const vector&);

        //- calculate the displacement vector for box scaling
        virtual vector displacement(const point&) const;

        //- calculate the displacement vector for box scaling
        virtual vector backwardDisplacement(const point&) const;

149 150 151 152 153 154 155
        //- can this modification object be combined with other ones
        virtual bool combiningPossible() const;

        //- return that "bounding planes" of the scaling region for
        //- the given object
        virtual void boundingPlanes(PtrList<plane>&) const;

Andrew Heather's avatar
Andrew Heather committed
156
        //- Return as dictionary of entries
157 158 159
        dictionary dict(bool ignoreType = false) const;


Andrew Heather's avatar
Andrew Heather committed
160 161 162 163 164 165 166
        // Write

            //- Write
            void write(Ostream&) const;

            //- Write dictionary
            void writeDict(Ostream&, bool subDict = true) const;
167 168 169 170 171 172 173


    // Member Operators

        //- assign from dictionary
        void operator=(const dictionary&);

Andrew Heather's avatar
Andrew Heather committed
174

175 176 177
    // IOstream Operators

        Ostream& operator<<(Ostream&) const;
178
        friend Ostream& operator<<(Ostream&, const boxScaling&);
179 180 181 182 183
};


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

184
} // End namespace Module
185 186 187 188 189 190 191
} // End namespace Foam

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

#endif

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