faFieldDecomposer.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2017 Wikki Ltd
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "faFieldDecomposer.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
38 (
39  const label sizeBeforeMapping,
40  const labelUList& addressingSlice,
41  const label addressingOffset
42 )
43 :
44  sizeBeforeMapping_(sizeBeforeMapping),
45  directAddressing_(addressingSlice)
46 {
47  forAll(directAddressing_, i)
48  {
49  // Subtract one to align addressing.
50  // directAddressing_[i] -= addressingOffset + 1;
51  // ZT, 12/Nov/2010
52  directAddressing_[i] -= addressingOffset;
53  }
54 }
55 
56 
59 (
60  const faMesh& mesh,
61  const labelUList& addressingSlice
62 )
63 :
64  sizeBeforeMapping_(mesh.nFaces()),
65  addressing_(addressingSlice.size()),
66  weights_(addressingSlice.size())
67 {
68  const scalarField& weights = mesh.weights().internalField();
69  const labelList& own = mesh.edgeOwner();
70  const labelList& neighb = mesh.edgeNeighbour();
71 
72  forAll(addressing_, i)
73  {
74  // Subtract one to align addressing.
75  label ai = addressingSlice[i];
76 // label ai = mag(addressingSlice[i]) - 1;
77 
78  if (ai < neighb.size())
79  {
80  // This is a regular edge. it has been an internal edge
81  // of the original mesh and now it has become a edge
82  // on the parallel boundary
83  addressing_[i].setSize(2);
84  weights_[i].setSize(2);
85 
86  addressing_[i][0] = own[ai];
87  addressing_[i][1] = neighb[ai];
88 
89  weights_[i][0] = weights[ai];
90  weights_[i][1] = 1.0 - weights[ai];
91  }
92  else
93  {
94  // This is a edge that used to be on a cyclic boundary
95  // but has now become a parallel patch edge. I cannot
96  // do the interpolation properly (I would need to look
97  // up the different (edge) list of data), so I will
98  // just grab the value from the owner face
99  //
100  addressing_[i].setSize(1);
101  weights_[i].setSize(1);
102 
103  addressing_[i][0] = own[ai];
104 
105  weights_[i][0] = 1.0;
106  }
107  }
108 }
109 
110 
113 (
114  label sizeBeforeMapping,
115  const labelUList& addressingSlice
116 )
117 :
118  sizeBeforeMapping_(sizeBeforeMapping),
119  addressing_(addressingSlice.size()),
120  weights_(addressingSlice.size())
121 {
122  forAll(addressing_, i)
123  {
124  addressing_[i].setSize(1);
125  weights_[i].setSize(1);
126 
127  addressing_[i][0] = mag(addressingSlice[i]) - 1;
128  weights_[i][0] = sign(addressingSlice[i]);
129  }
130 }
131 
132 
133 faFieldDecomposer::faFieldDecomposer
134 (
135  const faMesh& completeMesh,
136  const faMesh& procMesh,
137  const labelList& edgeAddressing,
138  const labelList& faceAddressing,
139  const labelList& boundaryAddressing
140 )
141 :
142  completeMesh_(completeMesh),
143  procMesh_(procMesh),
144  edgeAddressing_(edgeAddressing),
145  faceAddressing_(faceAddressing),
146  boundaryAddressing_(boundaryAddressing),
147  patchFieldDecomposerPtrs_
148  (
149  procMesh_.boundary().size(),
150  static_cast<patchFieldDecomposer*>(NULL)
151  ),
152  processorAreaPatchFieldDecomposerPtrs_
153  (
154  procMesh_.boundary().size(),
155  static_cast<processorAreaPatchFieldDecomposer*>(NULL)
156  ),
157  processorEdgePatchFieldDecomposerPtrs_
158  (
159  procMesh_.boundary().size(),
160  static_cast<processorEdgePatchFieldDecomposer*>(NULL)
161  )
162 {
163  forAll(boundaryAddressing_, patchi)
164  {
165  if (boundaryAddressing_[patchi] >= 0)
166  {
167  patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
168  (
169  completeMesh_.boundary()[boundaryAddressing_[patchi]].size(),
170  procMesh_.boundary()[patchi].patchSlice(edgeAddressing_),
171 // completeMesh_.boundaryMesh()
172  completeMesh_.boundary()
173  [
174  boundaryAddressing_[patchi]
175  ].start()
176  );
177  }
178  else
179  {
180  processorAreaPatchFieldDecomposerPtrs_[patchi] =
181  new processorAreaPatchFieldDecomposer
182  (
183  completeMesh_,
184  procMesh_.boundary()[patchi].patchSlice(edgeAddressing_)
185  );
186 
187  processorEdgePatchFieldDecomposerPtrs_[patchi] =
188  new processorEdgePatchFieldDecomposer
189  (
190  procMesh_.boundary()[patchi].size(),
191  static_cast<const labelUList&>
192  (
193  procMesh_.boundary()[patchi].patchSlice
194  (
195  edgeAddressing_
196  )
197  )
198  );
199  }
200  }
201 }
202 
203 
204 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
205 
207 {
208  forAll(patchFieldDecomposerPtrs_, patchi)
209  {
210  if (patchFieldDecomposerPtrs_[patchi])
211  {
212  delete patchFieldDecomposerPtrs_[patchi];
213  }
214  }
215 
216  forAll(processorAreaPatchFieldDecomposerPtrs_, patchi)
217  {
218  if (processorAreaPatchFieldDecomposerPtrs_[patchi])
219  {
220  delete processorAreaPatchFieldDecomposerPtrs_[patchi];
221  }
222  }
223 
224  forAll(processorEdgePatchFieldDecomposerPtrs_, patchi)
225  {
226  if (processorEdgePatchFieldDecomposerPtrs_[patchi])
227  {
228  delete processorEdgePatchFieldDecomposerPtrs_[patchi];
229  }
230  }
231 }
232 
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 } // End namespace Foam
237 
238 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::faFieldDecomposer::~faFieldDecomposer
~faFieldDecomposer()
Foam::sign
dimensionedScalar sign(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:166
Foam::faFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
patchFieldDecomposer(const label sizeBeforeMapping, const labelUList &addressingSlice, const label addressingOffset)
Construct given addressing.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::faFieldDecomposer::processorEdgePatchFieldDecomposer::processorEdgePatchFieldDecomposer
processorEdgePatchFieldDecomposer(label sizeBeforeMapping, const labelUList &addressingSlice)
Construct given addressing.
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::faFieldDecomposer::processorAreaPatchFieldDecomposer::processorAreaPatchFieldDecomposer
processorAreaPatchFieldDecomposer(const faMesh &mesh, const labelUList &addressingSlice)
Construct given addressing.
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::labelUList
UList< label > labelUList
A UList of labels.
Definition: UList.H:80
boundary
faceListList boundary
Definition: createBlockMesh.H:4
faFieldDecomposer.H