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 
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 
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 // ************************************************************************* //
Foam::lineDivide::points
const pointField & points() const
Return the points.
Definition: lineDivide.C:143
p
p
Definition: pEqn.H:62
Foam::blockDescriptor::makeBlockEdges
void makeBlockEdges()
Set the points/weights for all edges.
Definition: blockDescriptorEdges.C:32
Foam::blockDescriptor::setEdge
void setEdge(label edgeI, label start, label end, label dim)
Set the edge points/weights.
Definition: blockDescriptorEdges.C:61
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::lineDivide
Divides a line into segments.
Definition: lineDivide.H:52
blockDescriptor.H
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::inv
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:71
Foam::lineDivide::lambdaDivisions
const scalarList & lambdaDivisions() const
Return the list of lambda values.
Definition: lineDivide.C:149
Foam::lineEdge
A straight edge between the start point and the end point.
Definition: lineEdge.H:49
Foam::Vector::x
const Cmpt & x() const
Definition: VectorI.H:65
Foam::curvedEdge::compare
int compare(const curvedEdge &) const
Compare the given start and end points with this curve.
Definition: curvedEdgeI.H:57
Foam::Vector::z
const Cmpt & z() const
Definition: VectorI.H:77
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::blockDescriptor::meshDensity_
Vector< label > meshDensity_
The number of cells in the i,j,k directions.
Definition: blockDescriptor.H:75
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
lineEdge.H
lineDivide.H
Foam::Vector::y
const Cmpt & y() const
Definition: VectorI.H:71
Foam::curvedEdge
Define a curved edge that is parameterized for 0<lambda<1 between the start and end point.
Definition: curvedEdge.H:53
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.