distributedFieldMapper.H
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) 2019-2022 OpenCFD 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 Class
27  Foam::DistributedFieldMapper
28 
29 Description
30  A templated field mapper
31  with direct mapping from local or remote quantities.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef Foam_distributedFieldMapper_H
36 #define Foam_distributedFieldMapper_H
37 
38 #include "directFieldMapper.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 // Forward Declarations
46 template<class DirectFieldMapperType> class DistributedFieldMapper;
47 
48 // Standard Types
49 
50 //- A directFieldMapper with distributed (with local or remote) quantities
52 
53 
54 /*---------------------------------------------------------------------------*\
55  Class DistributedFieldMapper Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class DirectFieldMapperType>
60 :
61  public DirectFieldMapperType
62 {
63  // Private Data
64 
65  //- The distributed map
66  const mapDistributeBase& distMap_;
67 
68 
69 public:
70 
71  // Public Types
72 
73  //- The base direct mapper type
74  typedef DirectFieldMapperType mapper_type;
75 
76 
77  // Constructors
78 
79  //- Construct with addressing and distribute map
81  (
82  const labelUList& directAddr,
83  const mapDistributeBase& distMap
84  )
85  :
86  DirectFieldMapperType(directAddr),
87  distMap_(distMap)
88  {}
89 
90 
91  //- Destructor
92  virtual ~DistributedFieldMapper() = default;
93 
94 
95  // Member Functions
96 
97  //- The mapper size is given by the direct addressing size (if valid)
98  //- or from the distributeMap construct size.
99  virtual label size() const
100  {
101  return
102  (
103  DirectFieldMapperType::hasDirectAddressing()
104  ? DirectFieldMapperType::size()
105  : distMap_.constructSize()
106  );
107  }
108 
109  //- It is a distributed mapper
110  virtual bool distributed() const
111  {
112  return true;
113  }
114 
115  //- Return the distribution map
116  virtual const mapDistributeBase& distributeMap() const
117  {
118  return distMap_;
119  }
120 };
121 
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 } // End namespace Foam
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 #endif
130 
131 // ************************************************************************* //
label constructSize() const noexcept
Constructed data size.
virtual const mapDistributeBase & distributeMap() const
Return the distribution map.
virtual bool distributed() const
It is a distributed mapper.
virtual ~DistributedFieldMapper()=default
Destructor.
DistributedFieldMapper(const labelUList &directAddr, const mapDistributeBase &distMap)
Construct with addressing and distribute map.
Class containing processor-to-processor mapping information.
DirectFieldMapperType mapper_type
The base direct mapper type.
A templated field mapper with direct mapping from local or remote quantities.
DistributedFieldMapper< directFieldMapper > distributedFieldMapper
A directFieldMapper with distributed (with local or remote) quantities.
virtual label size() const
The mapper size is given by the direct addressing size (if valid) or from the distributeMap construct...
Namespace for OpenFOAM.