processorFvsPatchField.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) 2011-2021 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 "processorFvsPatchField.H"
27 #include "surfaceMesh.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  const fvPatch& p,
36 )
37 :
38  coupledFvsPatchField<Type>(p, iF),
39  procPatch_(refCast<const processorFvPatch>(p))
40 {}
41 
42 
43 template<class Type>
45 (
46  const fvPatch& p,
48  const Field<Type>& f
49 )
50 :
51  coupledFvsPatchField<Type>(p, iF, f),
52  procPatch_(refCast<const processorFvPatch>(p))
53 {}
54 
55 
56 template<class Type>
58 (
59  const fvPatch& p,
61  const dictionary& dict
62 )
63 :
64  coupledFvsPatchField<Type>(p, iF, dict),
65  procPatch_(refCast<const processorFvPatch>(p))
66 {
67  if (!isA<processorFvPatch>(p))
68  {
70  (
71  dict
72  ) << "patch " << this->patch().index() << " not processor type. "
73  << "Patch type = " << p.type()
74  << exit(FatalIOError);
75  }
76 }
77 
78 
79 template<class Type>
81 (
83  const fvPatch& p,
85  const fvPatchFieldMapper& mapper
86 )
87 :
88  coupledFvsPatchField<Type>(ptf, p, iF, mapper),
89  procPatch_(refCast<const processorFvPatch>(p))
90 {
91  if (!isA<processorFvPatch>(this->patch()))
92  {
94  << "Field type does not correspond to patch type for patch "
95  << this->patch().index() << "." << endl
96  << "Field type: " << typeName << endl
97  << "Patch type: " << this->patch().type()
98  << exit(FatalError);
99  }
100 }
101 
102 
103 template<class Type>
105 (
106  const processorFvsPatchField<Type>& ptf,
108 )
109 :
110  coupledFvsPatchField<Type>(ptf, iF),
111  procPatch_(refCast<const processorFvPatch>(ptf.patch()))
112 {}
113 
114 
115 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
116 
117 template<class Type>
119 {}
120 
121 
122 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
123 
124 template<class Type>
126 (
127  const Pstream::commsTypes commsType
128 ) const
129 {
130  if (Pstream::parRun())
131  {
132  if (commsType == Pstream::commsTypes::nonBlocking)
133  {
134  receiveBuf_.setSize(this->size());
135 
137  (
138  commsType,
139  procPatch_.neighbProcNo(),
140  reinterpret_cast<char*>(receiveBuf_.begin()),
141  receiveBuf_.byteSize(),
142  procPatch_.tag(),
143  procPatch_.comm()
144  );
145  }
146 
148  (
149  commsType,
150  procPatch_.neighbProcNo(),
151  reinterpret_cast<const char*>(this->begin()),
152  this->byteSize(),
153  procPatch_.tag(),
154  procPatch_.comm()
155  );
156  }
157 }
158 
159 
160 template<class Type>
163 (
164  const Pstream::commsTypes commsType
165 ) const
166 {
167  if (Pstream::parRun())
168  {
169  if (commsType != Pstream::commsTypes::nonBlocking)
170  {
171  receiveBuf_.setSize(this->size());
172 
174  (
175  commsType,
176  procPatch_.neighbProcNo(),
177  reinterpret_cast<char*>(receiveBuf_.begin()),
178  receiveBuf_.byteSize(),
179  procPatch_.tag(),
180  procPatch_.comm()
181  );
182  }
183 
184  procPatch_.transform().transform(receiveBuf_, receiveBuf_);
185 
186  return receiveBuf_;
187  }
188  else
189  {
190  return tmp<Field<Type>>(new Field<Type>());
191  }
192 }
193 
194 
195 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:82
static const char *const typeName
Definition: Field.H:105
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Read into given buffer from given processor and return the.
Definition: UIPread.C:79
static bool write(const commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Write given buffer to given processor.
Definition: UOPwrite.C:34
commsTypes
Types of communications.
Definition: UPstream.H:65
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
Foam::coupledFvsPatchField.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Foam::fvPatchFieldMapper.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
label index() const
Return the index of this patch in the fvBoundaryMesh.
Definition: fvPatch.H:175
const fvPatch & patch() const
Return patch.
Foam::processorFvsPatchField.
processorFvsPatchField(const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Construct from patch and internal field.
virtual tmp< Field< Type > > patchNeighbourField(const Pstream::commsTypes commsType) const
Return patchField on the opposite patch of a coupled patch.
virtual ~processorFvsPatchField()
Destructor.
virtual void initPatchNeighbourField(const Pstream::commsTypes commsType) const
Initialise return of the patchField on the opposite patch of a.
A class for managing temporary objects.
Definition: tmp.H:55
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:111
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOerror FatalIOError
error FatalError
labelList f(nPoints)
dictionary dict
volScalarField & p