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-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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  resultName_(name),
52  log_(true)
53 {
54  // Check if the available mesh is an fvMesh otherise deactivate
55  if (isA<fvMesh>(obr_))
56  {
57  read(dict);
58 
59  const fvMesh& mesh = refCast<const fvMesh>(obr_);
60 
61  volScalarField* procFieldPtr
62  (
63  new volScalarField
64  (
65  IOobject
66  (
67  resultName_,
68  mesh.time().timeName(),
69  mesh,
70  IOobject::NO_READ,
71  IOobject::NO_WRITE
72  ),
73  mesh,
74  dimensionedScalar("0", dimless, 0.0)
75  )
76  );
77 
78  mesh.objectRegistry::store(procFieldPtr);
79  }
80  else
81  {
82  active_ = false;
84  << "No fvMesh available, deactivating " << name_
85  << endl;
86  }
87 }
88 
89 
90 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
91 
93 {}
94 
95 
96 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97 
99 {
100  if (active_)
101  {
102  log_.readIfPresent("log", dict);
103  }
104 }
105 
106 
108 {
109  if (active_)
110  {
111  const volScalarField& procField =
112  obr_.lookupObject<volScalarField>(resultName_);
113 
114  const_cast<volScalarField&>(procField) ==
116  }
117 }
118 
119 
121 {
122  // Do nothing
123 }
124 
125 
127 {
128  // Do nothing
129 }
130 
131 
133 {
134  if (active_)
135  {
136  const volScalarField& procField =
137  obr_.lookupObject<volScalarField>(resultName_);
138 
139  if (log_) Info
140  << type() << " " << name_ << " output:" << nl
141  << " writing field " << procField.name() << nl
142  << endl;
143 
144  procField.write();
145  }
146 }
147 
148 
149 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::processorField::~processorField
virtual ~processorField()
Destructor.
Definition: processorField.C:92
Foam::processorField::processorField
processorField(const processorField &)
Disallow default bitwise copy construct.
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::processorField::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: processorField.C:126
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::processorField::read
virtual void read(const dictionary &)
Read the input data.
Definition: processorField.C:98
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
processorField.H
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::processorField::write
virtual void write()
Write.
Definition: processorField.C:132
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
Foam::processorField::execute
virtual void execute()
Execute, currently does nothing.
Definition: processorField.C:107
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Pstream.H
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:405
dictionary.H
Foam::processorField::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: processorField.C:120
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47