pointFieldDecomposer.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  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "pointFieldDecomposer.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 (
35  const pointPatch& completeMeshPatch,
36  const pointPatch& procMeshPatch,
37  const labelList& directAddr
38 )
39 :
41  (
42  completeMeshPatch,
43  procMeshPatch
44  ),
45  directAddressing_(procMeshPatch.size(), -1),
46  hasUnmapped_(false)
47 {
48  // Create the inverse-addressing of the patch point labels.
49  labelList pointMap(completeMeshPatch.boundaryMesh().mesh().size(), -1);
50 
51  const labelList& completeMeshPatchPoints = completeMeshPatch.meshPoints();
52 
53  forAll(completeMeshPatchPoints, pointi)
54  {
55  pointMap[completeMeshPatchPoints[pointi]] = pointi;
56  }
57 
58  // Use the inverse point addressing to create the addressing table for this
59  // patch
60  const labelList& procMeshPatchPoints = procMeshPatch.meshPoints();
61 
62  forAll(procMeshPatchPoints, pointi)
63  {
64  directAddressing_[pointi] =
65  pointMap[directAddr[procMeshPatchPoints[pointi]]];
66  }
67 
68  // Check that all the patch point addresses are set
69  if (directAddressing_.size() && min(directAddressing_) < 0)
70  {
71  hasUnmapped_ = true;
72 
74  << "Incomplete patch point addressing"
75  << abort(FatalError);
76  }
77 }
78 
79 
81 (
82  const Foam::zero,
83  const pointMesh& procMesh,
84  const labelList& pointAddressing,
85  const labelList& boundaryAddressing
86 )
87 :
88  procMesh_(procMesh),
89  pointAddressing_(pointAddressing),
90  boundaryAddressing_(boundaryAddressing),
91  // Mappers
92  patchFieldDecomposerPtrs_()
93 {}
94 
95 
97 (
98  const pointMesh& completeMesh,
99  const pointMesh& procMesh,
100  const labelList& pointAddressing,
101  const labelList& boundaryAddressing
102 )
103 :
105  (
106  zero{},
107  procMesh,
108  pointAddressing,
109  boundaryAddressing
110  )
111 {
112  reset(completeMesh);
113 }
114 
115 
116 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117 
119 {
120  return patchFieldDecomposerPtrs_.empty();
121 }
122 
123 
125 {
126  patchFieldDecomposerPtrs_.clear();
127 }
128 
129 
131 (
132  const pointMesh& completeMesh
133 )
134 {
135  clear();
136  const label nMappers = procMesh_.boundary().size();
137  patchFieldDecomposerPtrs_.resize(nMappers);
138 
139  forAll(boundaryAddressing_, patchi)
140  {
141  const label oldPatchi = boundaryAddressing_[patchi];
142 
143  if (oldPatchi >= 0)
144  {
145  patchFieldDecomposerPtrs_.set
146  (
147  patchi,
149  (
150  completeMesh.boundary()[oldPatchi],
151  procMesh_.boundary()[patchi],
152  pointAddressing_
153  )
154  );
155  }
156  }
157 }
158 
159 
160 // ************************************************************************* //
Foam::pointFieldDecomposer::pointFieldDecomposer
pointFieldDecomposer(const pointFieldDecomposer &)=delete
No copy construct.
Foam::pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
patchFieldDecomposer(const pointPatch &completeMeshPatch, const pointPatch &procMeshPatch, const labelList &directAddr)
Construct given addressing.
Definition: pointFieldDecomposer.C:34
Foam::pointMesh::boundary
const pointBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: pointMesh.H:109
Foam::pointMesh::size
static label size(const Mesh &mesh)
Return size. Number of points.
Definition: pointMesh.H:97
Foam::pointFieldDecomposer::reset
void reset(const pointMesh &completeMesh)
Reset mappers using information from the complete mesh.
Definition: pointFieldDecomposer.C:131
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:58
Foam::pointBoundaryMesh::mesh
const pointMesh & mesh() const noexcept
Return the mesh reference.
Definition: pointBoundaryMesh.H:97
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::pointFieldDecomposer::clear
void clear()
Remove all mappers.
Definition: pointFieldDecomposer.C:124
Foam::FatalError
error FatalError
Foam::pointMesh
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:51
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::pointPatch::size
virtual label size() const =0
Return size.
reset
meshPtr reset(new Foam::fvMesh(Foam::IOobject(regionName, runTime.timeName(), runTime, Foam::IOobject::MUST_READ), false))
Foam::pointFieldDecomposer::patchFieldDecomposer
Point patch field decomposer class.
Definition: pointFieldDecomposer.H:59
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
clear
patchWriters clear()
Foam::pointPatch::meshPoints
virtual const labelList & meshPoints() const =0
Return mesh points.
Foam::List< label >
Foam::pointPatch::boundaryMesh
const pointBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: pointPatch.H:135
pointFieldDecomposer.H
Foam::pointPatchFieldMapperPatchRef
Foam::pointPatchFieldMapperPatchRef.
Definition: pointPatchFieldMapperPatchRef.H:47
Foam::pointFieldDecomposer::empty
bool empty() const
True if no mappers have been allocated.
Definition: pointFieldDecomposer.C:118
Foam::pointFieldDecomposer
Point field decomposer.
Definition: pointFieldDecomposer.H:54
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62