blockDescriptorEdges.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) 2011-2015 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
25 
26 #include "blockDescriptor.H"
27 #include "lineEdge.H"
28 #include "lineDivide.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 void Foam::blockDescriptor::makeBlockEdges()
33 {
34  const label ni = meshDensity_.x();
35  const label nj = meshDensity_.y();
36  const label nk = meshDensity_.z();
37 
38  // These edges correspond to the "hex" cellModel
39 
40  // X-direction
41  setEdge(0, 0, 1, ni);
42  setEdge(1, 3, 2, ni);
43  setEdge(2, 7, 6, ni);
44  setEdge(3, 4, 5, ni);
45 
46  // Y-direction
47  setEdge(4, 0, 3, nj);
48  setEdge(5, 1, 2, nj);
49  setEdge(6, 5, 6, nj);
50  setEdge(7, 4, 7, nj);
51 
52  // Z-direction
53  setEdge(8, 0, 4, nk);
54  setEdge(9, 1, 5, nk);
55  setEdge(10, 2, 6, nk);
56  setEdge(11, 3, 7, nk);
57 }
58 
59 
60 void Foam::blockDescriptor::setEdge
61 (
62  label edgeI,
63  label start,
64  label end,
65  label nDiv
66 )
67 {
68  // Set reference to the list of labels defining the block
69  const labelList& blockLabels = blockShape_;
70 
71  // Get list of points for this block
72  const pointField blockPoints = blockShape_.points(blockPointField_);
73 
74  // Set the edge points/weights
75  // The edge is a straight-line if it is not in the list of curvedEdges
76 
77  forAll(curvedEdges_, cedgeI)
78  {
79  const curvedEdge& cedge = curvedEdges_[cedgeI];
80 
81  int cmp = cedge.compare(blockLabels[start], blockLabels[end]);
82 
83  if (cmp)
84  {
85  if (cmp > 0)
86  {
87  // Curve has the same orientation
88 
89  // Divide the line
90  lineDivide divEdge(cedge, nDiv, expand_[edgeI]);
91 
92  edgePoints_[edgeI] = divEdge.points();
93  edgeWeights_[edgeI] = divEdge.lambdaDivisions();
94  }
95  else
96  {
97  // Curve has the opposite orientation
98 
99  // Divide the line
100  lineDivide divEdge(cedge, nDiv, expand_[edgeI].inv());
101 
102  const pointField& p = divEdge.points();
103  const scalarList& d = divEdge.lambdaDivisions();
104 
105  edgePoints_[edgeI].setSize(p.size());
106  edgeWeights_[edgeI].setSize(d.size());
107 
108  label pMax = p.size() - 1;
109  forAll(p, pI)
110  {
111  edgePoints_[edgeI][pI] = p[pMax - pI];
112  edgeWeights_[edgeI][pI] = 1.0 - d[pMax - pI];
113  }
114  }
115 
116  // Found curved-edge: done
117  return;
118  }
119  }
120 
121 
122  // Not curved-edge: divide the edge as a straight line
123  lineDivide divEdge
124  (
125  lineEdge(blockPoints, start, end),
126  nDiv,
127  expand_[edgeI]
128  );
129 
130  edgePoints_[edgeI] = divEdge.points();
131  edgeWeights_[edgeI] = divEdge.lambdaDivisions();
132 }
133 
134 
135 // ************************************************************************* //
const Cmpt & z() const
Definition: VectorI.H:87
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
const Cmpt & x() const
Definition: VectorI.H:75
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:50
const Cmpt & y() const
Definition: VectorI.H:81
pointField points(const pointField &meshPoints) const
Return the points corresponding to this cellShape.
Definition: cellShapeI.H:69
List< label > labelList
A List of labels.
Definition: labelList.H:56
void setSize(const label)
Reset size of List.
Definition: List.C:295