syncObjects.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) 2020 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::functionObjects::syncObjects
28 
29 Group
30  grpUtilitiesFunctionObjects
31 
32 Description
33  Copies content of local objectRegistry to all processors.
34 
35  Currently only supports IOFields. It is used to distribute IOFields
36  from different processors/regions/worlds
37  when doing loose coupling. To be used in combination with 'mapped'
38  boundary conditions.
39 
40 Usage
41  Example of function object specification:
42  \verbatim
43  syncObjects1
44  {
45  type syncObjects;
46  libs ("libutilityFunctionObjects.so");
47  ...
48 
49  // Where is data located relative to runTime. Given as a filename
50  // with every '/' indicating a sub-objectRegistry w.r.t. runTime.
51  // Local data is under <root>/send/processorXXX. After execution
52  // (potentially remote) data will be under the corresponding
53  // <root>/receive/processorYYY objectRegistry.
54  //root "level0/level1/level2";
55  }
56  \endverbatim
57 
58  Where the entries comprise:
59  \table
60  Property | Description | Required | Default value
61  type | type name: syncObjects | yes |
62  root | relative location of data | no | ""
63  \endtable
64 
65 See also
66  Foam::functionObject
67 
68 SourceFiles
69  syncObjects.C
70 
71 \*---------------------------------------------------------------------------*/
72 
73 #ifndef functionObjects_syncObjects_H
74 #define functionObjects_syncObjects_H
75 
76 #include "token.H"
77 #include "functionObject.H"
78 #include "IOField.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 
85 // Forward declaration of classes
86 class objectRegistry;
87 
88 namespace functionObjects
89 {
90 
91 /*---------------------------------------------------------------------------*\
92  Class functionObjects::syncObjects Declaration
93 \*---------------------------------------------------------------------------*/
94 
95 class syncObjects
96 :
97  public functionObject
98 {
99 private:
100 
101  // Private data
102 
103  //- Top-level registry
104  const objectRegistry& obr_;
105 
106  //- objectRegistry location relative to top-level
107  fileName root_;
108 
109 
110  // Private Member Functions
111 
112  //- No copy construct
113  syncObjects(const syncObjects&) = delete;
114 
115  //- No copy assignment
116  void operator=(const syncObjects&) = delete;
117 
118 
119 protected:
120 
121  //- Do all: synchronise all IOFields and objectRegistry
122  void sync();
123 
124 
125 public:
126 
127  //- Runtime type information
128  TypeName("syncObjects");
129 
130 
131  // Constructors
132 
133  //- Construct from Time and dictionary
135  (
136  const word& name,
137  const Time& runTime,
138  const dictionary& dict
139  );
140 
141 
142  //- Destructor
143  virtual ~syncObjects() = default;
144 
145 
146  // Member Functions
147 
148  const objectRegistry& obr() const
149  {
150  return obr_;
151  }
152 
153  const fileName& root() const
154  {
155  return root_;
156  }
157 
158  //- Read the syncObjects data
159  virtual bool read(const dictionary&);
160 
161  //- Do nothing
162  virtual bool execute();
163 
164  //- Write the registered objects
165  virtual bool write();
166 };
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace functionObjects
172 } // End namespace Foam
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
177 
178 // ************************************************************************* //
Foam::functionObjects::syncObjects::read
virtual bool read(const dictionary &)
Read the syncObjects data.
Definition: syncObjects.C:173
token.H
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::functionObjects::syncObjects
Copies content of local objectRegistry to all processors.
Definition: syncObjects.H:109
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::functionObjects::syncObjects::sync
void sync()
Do all: synchronise all IOFields and objectRegistry.
Definition: syncObjects.C:70
Foam::functionObject
Abstract base-class for Time/database function objects.
Definition: functionObject.H:332
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::functionObjects::syncObjects::~syncObjects
virtual ~syncObjects()=default
Destructor.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::syncObjects::root
const fileName & root() const
Definition: syncObjects.H:167
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
IOField.H
Foam::functionObjects::syncObjects::obr
const objectRegistry & obr() const
Definition: syncObjects.H:162
Foam::functionObjects::syncObjects::TypeName
TypeName("syncObjects")
Runtime type information.
functionObject.H
Foam::functionObjects::syncObjects::execute
virtual bool execute()
Do nothing.
Definition: syncObjects.C:196
Foam::functionObjects::syncObjects::write
virtual bool write()
Write the registered objects.
Definition: syncObjects.C:209