Forward compatibility: flex
[foam-extend-3.2.git] / src / mesh / cfMesh / utilities / anisotropicMeshing / edgeMeshGeometryModification / edgeMeshGeometryModification.C
bloba8ee5f89f39c76ba677c0568bcac89b4b445bb62
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | cfMesh: A library for mesh generation
4    \\    /   O peration     |
5     \\  /    A nd           | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6      \\/     M anipulation  | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9     This file is part of cfMesh.
11     cfMesh is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 3 of the License, or (at your
14     option) any later version.
16     cfMesh is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with cfMesh.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "edgeMeshGeometryModification.H"
27 #include "demandDrivenData.H"
28 #include "dictionary.H"
29 #include "edgeMesh.H"
31 namespace Foam
34 // * * * * * * * * * * * * * * Private member functions* * * * * * * * * * * //
36 void edgeMeshGeometryModification::checkModification()
38     if( meshDict_.found("anisotropicSources") )
39     {
40         modificationActive_ = true;
42         const dictionary& anisotropicDict =
43             meshDict_.subDict("anisotropicSources");
45         coordinateModifierPtr_ = new coordinateModifier(anisotropicDict);
46     }
49 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
51 edgeMeshGeometryModification::edgeMeshGeometryModification
53     const edgeMesh& em,
54     const dictionary& meshDict
57     edgeMesh_(em),
58     meshDict_(meshDict),
59     coordinateModifierPtr_(NULL),
60     modificationActive_(false)
62     checkModification();
65 edgeMeshGeometryModification::~edgeMeshGeometryModification()
67     deleteDemandDrivenData(coordinateModifierPtr_);
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 bool edgeMeshGeometryModification::activeModification() const
74     return modificationActive_;
77 const edgeMesh* edgeMeshGeometryModification::modifyGeometry() const
79     if( !modificationActive_ )
80     {
81         WarningIn
82         (
83             "const edgeMesh* edgeMeshGeometryModification"
84             "::modifyGeometry() const"
85         ) << "Modification is not active" << endl;
87         return NULL;
88     }
90     const pointField& pts = edgeMesh_.points();
92     pointField newPts(pts.size());
94     # ifdef USE_OMP
95     # pragma omp parallel for schedule(dynamic, 50)
96     # endif
97     forAll(pts, pointI)
98         newPts[pointI] = coordinateModifierPtr_->modifiedPoint(pts[pointI]);
100     const edgeMesh* newEdgeMesh = new edgeMesh(newPts, edgeMesh_.edges());
102     return newEdgeMesh;
105 const edgeMesh* edgeMeshGeometryModification::
106 revertGeometryModification() const
108     if( !modificationActive_ )
109     {
110         WarningIn
111         (
112             "const edgeMesh* edgeMeshGeometryModification"
113             "::revertGeometryModification() const"
114         ) << "Modification is not active" << endl;
116         return NULL;
117     }
119     const pointField& pts = edgeMesh_.points();
121     pointField newPts(pts.size());
123     # ifdef USE_OMP
124     # pragma omp parallel for schedule(dynamic, 50)
125     # endif
126     forAll(pts, pointI)
127     {
128         newPts[pointI] =
129             coordinateModifierPtr_->backwardModifiedPoint(pts[pointI]);
130     }
132     const edgeMesh* newEdgeMeshPtr = new edgeMesh(newPts, edgeMesh_.edges());
134     return newEdgeMeshPtr;
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 } // End namespace Foam
141 // ************************************************************************* //