processorField.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 | Copyright (C) 2011-2014 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 "processorField.H"
27 #include "dictionary.H"
28 #include "Pstream.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 defineTypeNameAndDebug(processorField, 0);
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 (
42  const word& name,
43  const objectRegistry& obr,
44  const dictionary& dict,
45  const bool loadFromFiles
46 )
47 :
48  name_(name),
49  obr_(obr),
50  active_(true)
51 {
52  // Check if the available mesh is an fvMesh otherise deactivate
53  if (isA<fvMesh>(obr_))
54  {
55  read(dict);
56 
57  const fvMesh& mesh = refCast<const fvMesh>(obr_);
58 
59  volScalarField* procFieldPtr
60  (
61  new volScalarField
62  (
63  IOobject
64  (
65  "processorID",
66  mesh.time().timeName(),
67  mesh,
70  ),
71  mesh,
72  dimensionedScalar("0", dimless, 0.0)
73  )
74  );
75 
76  mesh.objectRegistry::store(procFieldPtr);
77  }
78  else
79  {
80  active_ = false;
81  WarningIn
82  (
83  "processorField::processorField"
84  "("
85  "const word&, "
86  "const objectRegistry&, "
87  "const dictionary&, "
88  "const bool"
89  ")"
90  ) << "No fvMesh available, deactivating " << name_
91  << endl;
92  }
93 }
94 
95 
96 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
97 
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
105 {
106  // do nothing
107 }
108 
109 
111 {
112  if (active_)
113  {
114  const volScalarField& procField =
115  obr_.lookupObject<volScalarField>("processorID");
116 
117  const_cast<volScalarField&>(procField) ==
119  }
120 }
121 
122 
124 {
125  if (active_)
126  {
127  execute();
128  }
129 }
130 
131 
133 {
134  // Do nothing
135 }
136 
137 
139 {
140  if (active_)
141  {
142  const volScalarField& procField =
143  obr_.lookupObject<volScalarField>("processorID");
144 
145  procField.write();
146  }
147 }
148 
149 
150 // ************************************************************************* //
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
A class for handling words, derived from string.
Definition: word.H:59
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:741
virtual void end()
Execute at the final time-loop, currently does nothing.
virtual void execute()
Execute, currently does nothing.
dynamicFvMesh & mesh
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual void write()
Write.
Namespace for OpenFOAM.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
virtual bool write() const
Write using setting from DB.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
virtual void read(const dictionary &)
Read the input data.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
#define WarningIn(functionName)
Report a warning using Foam::Warning.
processorField(const processorField &)
Disallow default bitwise copy construct.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:404
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
virtual ~processorField()
Destructor.
Registry of regIOobjects.
bool read(const char *, int32_t &)
Definition: int32IO.C:87
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
defineTypeNameAndDebug(combustionModel, 0)