nonConformalMappedPolyFacesFvsPatchLabelField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2023-2024 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 
27 #include "fieldMapper.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
34 (
35  const fvPatch& p,
37 )
38 :
39  fvsPatchLabelField(p, iF),
40  procOffsets_(Pstream::nProcs(), 0)
41 {
42  if (p.size())
43  {
45  << "Default construction of a " << typeName << " field should "
46  << "only occur on a patch with no faces"
47  << exit(FatalError);
48  }
49 }
50 
51 
54 (
55  const fvPatch& p,
57  const dictionary& dict
58 )
59 :
60  fvsPatchLabelField(p, iF, dict, false),
61  procOffsets_
62  (
63  db().time().processorCase()
64  ? dict.lookup<labelList>("procOffsets")
65  : labelList(1, label(0))
66  )
67 {
69  (
70  labelField("value", dict, dict.lookup<label>("size"))
71  );
72 }
73 
74 
77 (
79  const fvPatch& p,
81  const fieldMapper& mapper
82 )
83 :
84  fvsPatchLabelField(ptf, p, iF, mapper),
85  procOffsets_(Pstream::nProcs(), 0)
86 {
87  if (p.size())
88  {
90  << "Mapped construction of a " << typeName << " field should "
91  << "only occur on a patch with no faces"
92  << exit(FatalError);
93  }
94 }
95 
96 
99 (
102 )
103 :
104  fvsPatchLabelField(ptf, iF),
105  procOffsets_(ptf.procOffsets_)
106 {}
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
112 (
113  const fvsPatchLabelField& plf
114 )
115 {
117 
119  refCast<const nonConformalMappedPolyFacesFvsPatchLabelField>(plf);
120 
121  procOffsets_ = ncmwpfplf.procOffsets_;
122 }
123 
124 
127 {
128  labelList result(procOffsets_.size(), -1);
129 
130  for (label proci = 0; proci < procOffsets_.size() - 1; ++ proci)
131  {
132  result[proci] = procOffsets_[proci + 1] - procOffsets_[proci];
133  }
134 
135  result.last() = size() - procOffsets_.last();
136 
137  return result;
138 }
139 
140 
142 (
143  Ostream& os
144 ) const
145 {
147  writeEntry(os, "size", this->size());
148  if (db().time().processorCase())
149  {
150  writeEntry(os, "procOffsets", procOffsets_);
151  }
152  writeEntry(os, "value", *this);
153 }
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 namespace Foam
159 {
161  (
164  );
165 }
166 
167 
168 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
friend Ostream & operator(Ostream &, const Field< label > &)
static const char *const typeName
Definition: Field.H:106
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Inter-processor communications stream.
Definition: Pstream.H:56
T & last()
Return the last element of the list.
Definition: UListI.H:128
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:83
virtual void write(Ostream &) const
Write.
virtual void reset(const fvsPatchField< Type > &)
Reset the fvsPatchField to the given fvsPatchField.
nonConformalMappedPolyFacesFvsPatchLabelField(const fvPatch &, const DimensionedField< label, surfaceMesh > &)
Construct from patch and internal field.
virtual void reset(const fvsPatchLabelField &)
Reset the fvPatchField to the given fvPatchField.
labelList procSizes() const
Return the sizes of the processor sub-ranges.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
Field< label > labelField
Specialisation of Field<T> for label.
Definition: labelField.H:49
error FatalError
makeFvsPatchTypeField(fvsPatchLabelField, nonConformalMappedPolyFacesFvsPatchLabelField)
dictionary dict
volScalarField & p