fieldCoordinateSystemTransformTemplates.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-2013 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 
27 #include "volFields.H"
28 #include "surfaceFields.H"
29 #include "Time.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const Type& field
38 ) const
39 {
40  const word& fieldName = field.name() + ":Transformed";
41 
42  if (!obr_.foundObject<Type>(fieldName))
43  {
44  obr_.store
45  (
46  new Type
47  (
48  IOobject
49  (
50  fieldName,
51  obr_.time().timeName(),
52  obr_,
53  IOobject::READ_IF_PRESENT,
54  IOobject::NO_WRITE
55  ),
56  field
57  )
58  );
59  }
60 
61  Type& transField =
62  const_cast<Type&>(obr_.lookupObject<Type>(fieldName));
63 
64  transField == field;
65 
66  dimensionedTensor R("R", field.dimensions(), coordSys_.R().R());
67 
68  Foam::transform(transField, R, transField);
69 
70  if (log_) Info<< " writing field " << transField.name() << nl << endl;
71 
72  transField.write();
73 }
74 
75 
76 template<class Type>
78 (
79  const word& fieldName
80 ) const
81 {
84 
85  if (obr_.foundObject<vfType>(fieldName))
86  {
87  if (debug)
88  {
89  Info<< type() << ": Field " << fieldName << " already in database"
90  << endl;
91  }
92 
93  transformField<vfType>(obr_.lookupObject<vfType>(fieldName));
94  }
95  else if (obr_.foundObject<sfType>(fieldName))
96  {
97  if (debug)
98  {
99  Info<< type() << ": Field " << fieldName << " already in database"
100  << endl;
101  }
102 
103  transformField<sfType>(obr_.lookupObject<sfType>(fieldName));
104  }
105  else
106  {
107  IOobject fieldHeader
108  (
109  fieldName,
110  obr_.time().timeName(),
111  obr_,
112  IOobject::MUST_READ,
113  IOobject::NO_WRITE
114  );
115 
116  if
117  (
118  fieldHeader.headerOk()
119  && fieldHeader.headerClassName() == vfType::typeName
120  )
121  {
122  if (debug)
123  {
124  Info<< type() << ": Field " << fieldName << " read from file"
125  << endl;
126  }
127 
128  transformField<vfType>(obr_.lookupObject<vfType>(fieldName));
129  }
130  else if
131  (
132  fieldHeader.headerOk()
133  && fieldHeader.headerClassName() == sfType::typeName
134  )
135  {
136  if (debug)
137  {
138  Info<< type() << ": Field " << fieldName << " read from file"
139  << endl;
140  }
141 
142  transformField<sfType>(obr_.lookupObject<sfType>(fieldName));
143  }
144  }
145 }
146 
147 
148 // ************************************************************************* //
volFields.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
fieldCoordinateSystemTransform.H
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
transformGeometricField.H
Spatial transformation functions for FieldFields.
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
surfaceFields.H
Foam::surfaceFields.
Foam::transform
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
Foam::IOobject::headerOk
bool headerOk()
Read and check header info.
Definition: IOobject.C:439
R
#define R(A, B, C, D, E, F, K, M)
Foam::IOobject::headerClassName
const word & headerClassName() const
Return name of the class name read from header.
Definition: IOobject.H:279
Foam::Ostream::write
virtual Ostream & write(const token &)=0
Write next token to stream.
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::fieldCoordinateSystemTransform::transformField
void transformField(const Type &field) const
Definition: fieldCoordinateSystemTransformTemplates.C:36
Foam::fieldCoordinateSystemTransform::transform
void transform(const word &fieldName) const
Definition: fieldCoordinateSystemTransformTemplates.C:78
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