partialWriteTemplates.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) 2013 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 "partialWrite.H"
27 #include "volFields.H"
28 #include "surfaceFields.H"
29 #include "Time.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const word& fieldName,
39 ) const
40 {
43 
44  if (obr_.foundObject<vfType>(fieldName))
45  {
46  if (debug)
47  {
48  Info<< "partialWrite : Field "
49  << fieldName << " found in database" << endl;
50  }
51 
52  vfType& vField =
53  const_cast<vfType&>
54  (
55  obr_.lookupObject<vfType>(fieldName)
56  );
57 
58 
59  const unsigned int sz = vflds.size();
60  vflds.setSize(sz + 1);
61  vflds.set(sz, &vField);
62  }
63  else if (obr_.foundObject<sfType>(fieldName))
64  {
65  if (debug)
66  {
67  Info<< "partialWrite : Field " << fieldName
68  << " found in database" << endl;
69  }
70 
71  sfType& sField =
72  const_cast<sfType&>
73  (
74  obr_.lookupObject<sfType>(fieldName)
75  );
76 
77 
78  const unsigned int sz = sflds.size();
79  sflds.setSize(sz + 1);
80  sflds.set(sz, &sField);
81  }
82 }
83 
84 
85 template<class Type>
87 (
90  const IOobject::writeOption wOption
91 ) const
92 {
93  forAll(vflds , i)
94  {
95  vflds[i].writeOpt() = wOption;
96  }
97 
98  forAll(sflds , i)
99  {
100  sflds[i].writeOpt() = wOption;
101  }
102 }
103 
104 
105 // ************************************************************************* //
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:52
Foam::surfaceFields.
void changeWriteOptions(UPtrList< GeometricField< Type, fvPatchField, volMesh > > &, UPtrList< GeometricField< Type, fvsPatchField, surfaceMesh > > &, const IOobject::writeOption) const
A class for handling words, derived from string.
Definition: word.H:59
messageStream Info
void loadField(const word &, UPtrList< GeometricField< Type, fvPatchField, volMesh > > &, UPtrList< GeometricField< Type, fvsPatchField, surfaceMesh > > &) const
Load objects in the objectNames.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
#define forAll(list, i)
Definition: UList.H:421
Generic GeometricField class.
writeOption
Enumeration defining the write options.
Definition: IOobject.H:115