edgeMeshGeometryModification.C
Go to the documentation of this file.
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.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "demandDrivenData.H"
28 #include "dictionary.H"
29 #include "edgeMesh.H"
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * Private member functions* * * * * * * * * * * //
35 
37 {
38  if( meshDict_.found("anisotropicSources") )
39  {
40  modificationActive_ = true;
41 
42  const dictionary& anisotropicDict =
43  meshDict_.subDict("anisotropicSources");
44 
45  coordinateModifierPtr_ = new coordinateModifier(anisotropicDict);
46  }
47 }
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
52 (
53  const edgeMesh& em,
54  const dictionary& meshDict
55 )
56 :
57  edgeMesh_(em),
58  meshDict_(meshDict),
59  coordinateModifierPtr_(NULL),
60  modificationActive_(false)
61 {
62  checkModification();
63 }
64 
66 {
68 }
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
73 {
74  return modificationActive_;
75 }
76 
78 {
79  if( !modificationActive_ )
80  {
81  WarningIn
82  (
83  "const edgeMesh* edgeMeshGeometryModification"
84  "::modifyGeometry() const"
85  ) << "Modification is not active" << endl;
86 
87  return NULL;
88  }
89 
90  const pointField& pts = edgeMesh_.points();
91 
92  pointField newPts(pts.size());
93 
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]);
99 
100  const edgeMesh* newEdgeMesh = new edgeMesh(newPts, edgeMesh_.edges());
101 
102  return newEdgeMesh;
103 }
104 
107 {
108  if( !modificationActive_ )
109  {
110  WarningIn
111  (
112  "const edgeMesh* edgeMeshGeometryModification"
113  "::revertGeometryModification() const"
114  ) << "Modification is not active" << endl;
115 
116  return NULL;
117  }
118 
119  const pointField& pts = edgeMesh_.points();
120 
121  pointField newPts(pts.size());
122 
123  # ifdef USE_OMP
124  # pragma omp parallel for schedule(dynamic, 50)
125  # endif
126  forAll(pts, pointI)
127  {
128  newPts[pointI] =
130  }
131 
132  const edgeMesh* newEdgeMeshPtr = new edgeMesh(newPts, edgeMesh_.edges());
133 
134  return newEdgeMeshPtr;
135 }
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 } // End namespace Foam
140 
141 // ************************************************************************* //
Foam::edgeMeshGeometryModification::~edgeMeshGeometryModification
~edgeMeshGeometryModification()
Definition: edgeMeshGeometryModification.C:65
Foam::edgeMeshGeometryModification::modificationActive_
bool modificationActive_
is mofdification active
Definition: edgeMeshGeometryModification.H:68
Foam::edgeMeshGeometryModification::edgeMeshGeometryModification
edgeMeshGeometryModification(const edgeMeshGeometryModification &)
disallow bitwise copy construct
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::coordinateModifier::modifiedPoint
point modifiedPoint(const point &) const
calculate the modified coordinate of the point
Definition: coordinateModifier.C:193
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::edgeMeshGeometryModification::edgeMesh_
const edgeMesh & edgeMesh_
reference to edgeMesh
Definition: edgeMeshGeometryModification.H:59
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::edgeMeshGeometryModification::modifyGeometry
const edgeMesh * modifyGeometry() const
modify coordinates
Definition: edgeMeshGeometryModification.C:77
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:40
Foam::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::edgeMeshGeometryModification::meshDict_
const dictionary & meshDict_
length of box sides
Definition: edgeMeshGeometryModification.H:62
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
edgeMesh.H
Foam::edgeMeshGeometryModification::checkModification
void checkModification()
check existence of geometry modifiers
Definition: edgeMeshGeometryModification.C:36
Foam::edgeMesh::points
const pointField & points() const
Return points.
Definition: edgeMeshI.H:39
Foam::edgeMesh::edges
const edgeList & edges() const
Return edges.
Definition: edgeMeshI.H:45
Foam::edgeMeshGeometryModification::revertGeometryModification
const edgeMesh * revertGeometryModification() const
revert geometry modification
Definition: edgeMeshGeometryModification.C:106
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::edgeMeshGeometryModification::activeModification
bool activeModification() const
is geometry modification active
Definition: edgeMeshGeometryModification.C:72
dictionary.H
Foam::edgeMeshGeometryModification::coordinateModifierPtr_
coordinateModifier * coordinateModifierPtr_
contruct coordinate modification
Definition: edgeMeshGeometryModification.H:65
edgeMeshGeometryModification.H
WarningIn
#define WarningIn(functionName)
Report a warning using Foam::Warning.
Definition: messageStream.H:254
Foam::coordinateModifier
Definition: coordinateModifier.H:54
Foam::coordinateModifier::backwardModifiedPoint
point backwardModifiedPoint(const point &) const
calculate the displacement vector for the backward modification
Definition: coordinateModifier.C:205
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631
Foam::edgeMesh
Points connected by edges.
Definition: edgeMesh.H:69