parFvFieldReconstructor.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) 2015 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 
29 
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 void Foam::parFvFieldReconstructor::createPatchFaceMaps()
34 {
35  const fvBoundaryMesh& fvb = procMesh_.boundary();
36 
37  patchFaceMaps_.setSize(fvb.size());
38  forAll(fvb, patchI)
39  {
40  if (!isA<processorFvPatch>(fvb[patchI]))
41  {
42  // Create map for patch faces only
43 
44  // Mark all used elements (i.e. destination patch faces)
45  boolList faceIsUsed(distMap_.faceMap().constructSize(), false);
46  const polyPatch& basePatch = baseMesh_.boundaryMesh()[patchI];
47  forAll(basePatch, i)
48  {
49  faceIsUsed[basePatch.start()+i] = true;
50  }
51 
52  // Copy face map
53  patchFaceMaps_.set
54  (
55  patchI,
56  new mapDistributeBase(distMap_.faceMap())
57  );
58 
59  // Compact out unused elements
60  labelList oldToNewSub;
61  labelList oldToNewConstruct;
62  patchFaceMaps_[patchI].compact
63  (
64  faceIsUsed,
65  procMesh_.nFaces(), // maximum index of subMap
66  oldToNewSub,
67  oldToNewConstruct,
69  );
70  //Pout<< "patchMap:" << patchFaceMaps_[patchI] << endl;
71  }
72  }
73 }
74 
75 
76 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
77 
78 Foam::parFvFieldReconstructor::parFvFieldReconstructor
79 (
80  fvMesh& baseMesh,
81  const fvMesh& procMesh,
82  const mapDistributePolyMesh& distMap,
83  const bool isWriteProc
84 )
85 :
86  baseMesh_(baseMesh),
87  procMesh_(procMesh),
88  distMap_(distMap),
89  isWriteProc_(isWriteProc)
90 {
91  createPatchFaceMaps();
92 }
93 
94 
95 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 
98 {
99  // Reconstruct the points for moving mesh cases and write
100  // them out
101  distributedUnallocatedDirectFieldMapper mapper
102  (
104  distMap_.pointMap()
105  );
106  pointField basePoints(procMesh_.points(), mapper);
107  baseMesh_.movePoints(basePoints);
108  if (Pstream::master())
109  {
110  baseMesh_.write();
111  }
112 }
113 
114 
115 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::parFvFieldReconstructor::reconstructPoints
void reconstructPoints()
Helper: reconstruct and write mesh points.
Foam::UPstream::master
static bool master(const label communicator=worldComm)
Am I the master process.
Definition: UPstream.H:457
Foam::boolList
List< bool > boolList
A List of bools.
Definition: List.H:65
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:444
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::mapDistributePolyMesh::faceMap
const mapDistribute & faceMap() const
Face distribute map.
Definition: mapDistributePolyMesh.H:217
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:685
Foam::mapDistributeBase::constructSize
label constructSize() const
Constructed data size.
Definition: mapDistributeBase.H:277
Foam::UPstream::msgType
static int & msgType() noexcept
Message tag of standard messages.
Definition: UPstream.H:540
Foam::primitiveMesh::nFaces
label nFaces() const noexcept
Number of mesh faces.
Definition: primitiveMeshI.H:90
Foam::UList::null
static const UList< T > & null()
Return a UList reference to a nullObject.
Definition: UListI.H:53
parFvFieldReconstructor.H