fieldValueTemplates.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) 2015-2022 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 "fieldValue.H"
30 #include "ListListOps.H"
31 #include "Pstream.H"
32 
33 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
34 
35 template<class Type>
37 {
38  if (Pstream::parRun())
39  {
40  List<Field<Type>> allValues(Pstream::nProcs());
41  allValues[Pstream::myProcNo()] = field;
42 
43  Pstream::allGatherList(allValues);
44 
45  field =
46  ListListOps::combine<Field<Type>>
47  (
48  allValues,
50  );
51  }
52 }
53 
54 
55 template<class Type>
57 {
58  combineFields(field.ref());
59 }
60 
61 
62 // ************************************************************************* //
rDeltaTY field()
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
Object access operator or list access operator (default is pass-through)
Definition: UList.H:1004
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1049
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
Definition: UPstream.H:1074
static void allGatherList(List< T > &values, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather data, but keep individual values separate. Uses linear/tree communication. ...
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
Definition: UPstream.H:1065
void combineFields(Field< Type > &field)
Combine fields from all processor domains into single field.
Generic templated field type.
Definition: Field.H:62
A class for managing temporary objects.
Definition: HashPtrTable.H:50