fvFieldDecomposer.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) 2011-2016 OpenFOAM Foundation
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 "fvFieldDecomposer.H"
29 
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 (
35  const labelUList& addressingSlice,
36  const label addressingOffset
37 )
38 :
39  directAddressing_(addressingSlice)
40 {
41  forAll(directAddressing_, i)
42  {
43  // Subtract one to align addressing.
44  directAddressing_[i] -= addressingOffset + 1;
45  }
46 }
47 
48 
51 (
52  const fvMesh& mesh,
53  const labelUList& addressingSlice
54 )
55 :
56  directAddressing_(addressingSlice.size())
57 {
58  const labelList& own = mesh.faceOwner();
59  const labelList& neighb = mesh.faceNeighbour();
60 
61  forAll(directAddressing_, i)
62  {
63  // Subtract one to align addressing.
64  label ai = mag(addressingSlice[i]) - 1;
65 
66  if (ai < neighb.size())
67  {
68  // This is a regular face. it has been an internal face
69  // of the original mesh and now it has become a face
70  // on the parallel boundary.
71  // Give face the value of the neighbour.
72 
73  if (addressingSlice[i] >= 0)
74  {
75  // I have the owner so use the neighbour value
76  directAddressing_[i] = neighb[ai];
77  }
78  else
79  {
80  directAddressing_[i] = own[ai];
81  }
82  }
83  else
84  {
85  // This is a face that used to be on a cyclic boundary
86  // but has now become a parallel patch face. I cannot
87  // do the interpolation properly (I would need to look
88  // up the different (face) list of data), so I will
89  // just grab the value from the owner cell
90 
91  directAddressing_[i] = own[ai];
92  }
93  }
94 }
95 
96 
99 (
100  const labelUList& addressingSlice
101 )
102 :
103  addressing_(addressingSlice.size()),
104  weights_(addressingSlice.size())
105 {
106  forAll(addressing_, i)
107  {
108  addressing_[i].setSize(1);
109  weights_[i].setSize(1);
110 
111  addressing_[i][0] = mag(addressingSlice[i]) - 1;
112  weights_[i][0] = 1;
113  }
114 }
115 
116 
117 Foam::fvFieldDecomposer::fvFieldDecomposer
118 (
119  const fvMesh& completeMesh,
120  const fvMesh& procMesh,
121  const labelList& faceAddressing,
122  const labelList& cellAddressing,
123  const labelList& boundaryAddressing
124 )
125 :
126  completeMesh_(completeMesh),
127  procMesh_(procMesh),
128  faceAddressing_(faceAddressing),
129  cellAddressing_(cellAddressing),
130  boundaryAddressing_(boundaryAddressing),
131  patchFieldDecomposerPtrs_(procMesh_.boundary().size()),
132  processorVolPatchFieldDecomposerPtrs_(procMesh_.boundary().size()),
133  processorSurfacePatchFieldDecomposerPtrs_(procMesh_.boundary().size()),
134  faceSign_(procMesh_.boundary().size())
135 {
136  forAll(boundaryAddressing_, patchi)
137  {
138  const fvPatch& fvp = procMesh_.boundary()[patchi];
139 
140  if
141  (
142  boundaryAddressing_[patchi] >= 0
143  && !isA<processorLduInterface>(procMesh.boundary()[patchi])
144  )
145  {
146  patchFieldDecomposerPtrs_.set
147  (
148  patchi,
150  (
151  fvp.patchSlice(faceAddressing_),
152  completeMesh_.boundaryMesh()
153  [
154  boundaryAddressing_[patchi]
155  ].start()
156  )
157  );
158  }
159  else
160  {
161  processorVolPatchFieldDecomposerPtrs_.set
162  (
163  patchi,
165  (
166  completeMesh_,
167  fvp.patchSlice(faceAddressing_)
168  )
169  );
170 
171  processorSurfacePatchFieldDecomposerPtrs_.set
172  (
173  patchi,
175  (
176  static_cast<const labelUList&>
177  (
178  fvp.patchSlice
179  (
180  faceAddressing_
181  )
182  )
183  )
184  );
185 
186  faceSign_.set
187  (
188  patchi,
189  new scalarField(fvp.patchSlice(faceAddressing_).size())
190  );
191 
192  {
193  const SubList<label> fa = fvp.patchSlice(faceAddressing_);
194  scalarField& s = faceSign_[patchi];
195  forAll(s, i)
196  {
197  s[i] = sign(fa[i]);
198  }
199  }
200  }
201  }
202 }
203 
204 
205 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
206 
208 {}
209 
210 
211 // ************************************************************************* //
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputSpray.H:25
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
Foam::fvFieldDecomposer::processorSurfacePatchFieldDecomposer::processorSurfacePatchFieldDecomposer
processorSurfacePatchFieldDecomposer(const labelUList &addressingSlice)
Construct given addressing.
Definition: fvFieldDecomposer.C:99
Foam::sign
dimensionedScalar sign(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:166
Foam::fvPatch::patchSlice
const List< T >::subList patchSlice(const List< T > &l) const
Slice list to patch.
Definition: fvPatch.H:210
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::fvFieldDecomposer::~fvFieldDecomposer
~fvFieldDecomposer()
Destructor.
Definition: fvFieldDecomposer.C:207
Foam::fvFieldDecomposer::processorVolPatchFieldDecomposer
Processor patch field decomposer class. Maps either owner or.
Definition: fvFieldDecomposer.H:108
Foam::fvFieldDecomposer::patchFieldDecomposer
Patch field decomposer class.
Definition: fvFieldDecomposer.H:60
Foam::Field< scalar >
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvFieldDecomposer::processorVolPatchFieldDecomposer::processorVolPatchFieldDecomposer
processorVolPatchFieldDecomposer(const fvMesh &mesh, const labelUList &addressingSlice)
Construct given addressing.
Definition: fvFieldDecomposer.C:51
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
fvFieldDecomposer.H
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:679
Foam::fvFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
patchFieldDecomposer(const labelUList &addressingSlice, const label addressingOffset)
Construct given addressing.
Definition: fvFieldDecomposer.C:34
Foam::List< label >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::UList< label >
Foam::UList::size
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
Definition: UListI.H:360
Foam::fvFieldDecomposer::processorSurfacePatchFieldDecomposer
Processor patch field decomposer class. Surface field is assumed.
Definition: fvFieldDecomposer.H:153