FreeFOAM The Cross-Platform CFD Toolkit
setEdge.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25  from the list of curved edges creates a list
26  of edges that are not curved. It is assumed
27  that all other edges are straight lines
28 
29 \*---------------------------------------------------------------------------*/
30 
31 #include <OpenFOAM/error.H>
32 
33 #include "blockDescriptor.H"
34 #include "curvedEdges/lineEdge.H"
35 #include "curvedEdges/lineDivide.H"
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 scalar calcGexp(const scalar expRatio, const label dim)
45 {
46  if (dim == 1)
47  {
48  return 0.0;
49  }
50  else
51  {
52  return pow(expRatio, 1.0/(dim - 1));
53  }
54 }
55 
56 
57 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
58 
59 void blockDescriptor::setEdge(label edgeI, label start, label end, label dim)
60 {
61  // for all edges check the list of curved edges. If the edge is curved,
62  // add it to the list. If the edge is not found, create is as a line
63 
64  bool found = false;
65 
66  // set reference to the list of labels defining the block
67  const labelList& blockLabels = blockShape_;
68 
69  // set reference to global list of points
70  const pointField blockPoints = blockShape_.points(blockMeshPoints_);
71 
72  // x1
73  found = false;
74 
75  forAll (curvedEdges_, nCEI)
76  {
77  if (curvedEdges_[nCEI].compare(blockLabels[start], blockLabels[end]))
78  {
79  found = true;
80 
81  // check the orientation:
82  // if the starting point of the curve is the same as the starting
83  // point of the edge, do the parametrisation and pick up the points
84  if (blockLabels[start] == curvedEdges_[nCEI].start())
85  {
86  // calculate the geometric expension factor out of the
87  // expansion ratio
88  scalar gExp = calcGexp(expand_[edgeI], dim);
89 
90  // divide the line
91  lineDivide divEdge(curvedEdges_[nCEI], dim, gExp);
92 
93  edgePoints_[edgeI] = divEdge.points();
94  edgeWeights_[edgeI] = divEdge.lambdaDivisions();
95  }
96  else
97  {
98  // the curve has got the opposite orientation
99  scalar gExp = calcGexp(expand_[edgeI], dim);
100 
101  // divide the line
102  lineDivide divEdge(curvedEdges_[nCEI], dim, 1.0/(gExp+SMALL));
103 
104  pointField p = divEdge.points();
105  scalarList d = divEdge.lambdaDivisions();
106 
107  edgePoints_[edgeI].setSize(p.size());
108  edgeWeights_[edgeI].setSize(d.size());
109 
110  label pMax = p.size() - 1;
111  forAll (p, pI)
112  {
113  edgePoints_[edgeI][pI] = p[pMax - pI];
114  edgeWeights_[edgeI][pI] = 1.0 - d[pMax - pI];
115  }
116  }
117 
118  break;
119  }
120  }
121 
122  if (!found)
123  {
124  // edge is a straight line
125  scalar gExp = calcGexp(expand_[edgeI], dim);
126  lineEdge lE(blockPoints, start, end);
127  // divide the line
128  lineDivide divEdge
129  (
130  lE,
131  dim,
132  gExp
133  );
134 
135  edgePoints_[edgeI] = divEdge.points();
136  edgeWeights_[edgeI] = divEdge.lambdaDivisions();
137  }
138 }
139 
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 } // End namespace Foam
144 
145 // ************************ vim: set sw=4 sts=4 et: ************************ //