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 | Copyright (C) 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 "parFvFieldReconstructor.H"
27 
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
32 {
33  const fvBoundaryMesh& fvb = procMesh_.boundary();
34 
35  patchFaceMaps_.setSize(fvb.size());
36  forAll(fvb, patchI)
37  {
38  if (!isA<processorFvPatch>(fvb[patchI]))
39  {
40  // Create map for patch faces only
41 
42  // Mark all used elements (i.e. destination patch faces)
43  boolList faceIsUsed(distMap_.faceMap().constructSize(), false);
44  const polyPatch& basePatch = baseMesh_.boundaryMesh()[patchI];
45  forAll(basePatch, i)
46  {
47  faceIsUsed[basePatch.start()+i] = true;
48  }
49 
50  // Copy face map
51  patchFaceMaps_.set
52  (
53  patchI,
54  new mapDistributeBase(distMap_.faceMap())
55  );
56 
57  // Compact out unused elements
58  labelList oldToNewSub;
59  labelList oldToNewConstruct;
60  patchFaceMaps_[patchI].compact
61  (
62  faceIsUsed,
63  procMesh_.nFaces(), // maximum index of subMap
64  oldToNewSub,
65  oldToNewConstruct,
67  );
68  //Pout<< "patchMap:" << patchFaceMaps_[patchI] << endl;
69  }
70  }
71 }
72 
73 
74 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
75 
77 (
78  fvMesh& baseMesh,
79  const fvMesh& procMesh,
80  const mapDistributePolyMesh& distMap,
81  const bool isWriteProc
82 )
83 :
84  baseMesh_(baseMesh),
85  procMesh_(procMesh),
86  distMap_(distMap),
87  isWriteProc_(isWriteProc)
88 {
89  createPatchFaceMaps();
90 }
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
96 {
97  // Reconstruct the points for moving mesh cases and write
98  // them out
99  distributedUnallocatedDirectFieldMapper mapper
100  (
103  );
104  pointField basePoints(procMesh_.points(), mapper);
105  baseMesh_.movePoints(basePoints);
106  if (Pstream::master())
107  {
108  baseMesh_.write();
109  }
110 }
111 
112 
113 // ************************************************************************* //
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:979
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::parFvFieldReconstructor::reconstructPoints
void reconstructPoints()
Helper: reconstruct and write mesh points.
Definition: parFvFieldReconstructor.C:95
Foam::fvMesh::movePoints
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Definition: fvMesh.C:726
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
Foam::parFvFieldReconstructor::baseMesh_
fvMesh & baseMesh_
Reconstructed mesh reference.
Definition: parFvFieldReconstructor.H:62
Foam::parFvFieldReconstructor::patchFaceMaps_
PtrList< mapDistributeBase > patchFaceMaps_
Patch mappers.
Definition: parFvFieldReconstructor.H:74
Foam::fvMesh::write
virtual bool write() const
Write mesh using IO settings from time.
Definition: fvMesh.C:873
Foam::parFvFieldReconstructor::procMesh_
const fvMesh & procMesh_
Processor mesh reference.
Definition: parFvFieldReconstructor.H:65
Foam::mapDistributePolyMesh::faceMap
const mapDistribute & faceMap() const
Face distribute map.
Definition: mapDistributePolyMesh.H:208
Foam::parFvFieldReconstructor::distMap_
const mapDistributePolyMesh & distMap_
Distribution map reference.
Definition: parFvFieldReconstructor.H:68
Foam::boolList
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
Foam::UPstream::master
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:399
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:550
Foam::mapDistributeBase::constructSize
label constructSize() const
Constructed data size.
Definition: mapDistributeBase.H:244
Foam::UPstream::msgType
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:452
Foam::primitiveMesh::nFaces
label nFaces() const
Definition: primitiveMeshI.H:58
Foam::parFvFieldReconstructor::parFvFieldReconstructor
parFvFieldReconstructor(const parFvFieldReconstructor &)
Disallow default bitwise copy construct.
Foam::mapDistributePolyMesh::pointMap
const mapDistribute & pointMap() const
Point distribute map.
Definition: mapDistributePolyMesh.H:202
Foam::UList::null
static const UList< T > & null()
Return a null UList.
Definition: UListI.H:51
Foam::parFvFieldReconstructor::createPatchFaceMaps
void createPatchFaceMaps()
Construct per-patch addressing.
Definition: parFvFieldReconstructor.C:31