ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / field / fieldCoordinateSystemTransform / fieldCoordinateSystemTransformTemplates.C
blobc1ecc72707bce985a0705929006be29edaf1a993
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "fieldCoordinateSystemTransform.H"
27 #include "volFields.H"
28 #include "surfaceFields.H"
29 #include "Time.H"
30 #include "transformGeometricField.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 template<class Type>
35 void Foam::fieldCoordinateSystemTransform::transformField
37     const Type& field
38 ) const
40     const word& fieldName = field.name() + "Transformed";
42     dimensionedTensor R("R", field.dimensions(), coordSys_.R());
44     if (obr_.foundObject<Type>(fieldName))
45     {
46         Type& transField =
47             const_cast<Type&>(obr_.lookupObject<Type>(fieldName));
49         transField == field;
51         forAll(field, i)
52         {
53             Foam::transform(transField, R, transField);
54         }
56         transField.write();
57     }
58     else
59     {
60         Type& transField = obr_.store
61         (
62             new Type
63             (
64                 IOobject
65                 (
66                     fieldName,
67                     obr_.time().timeName(),
68                     obr_,
69                     IOobject::READ_IF_PRESENT,
70                     IOobject::NO_WRITE
71                 ),
72                 field
73             )
74         );
76         forAll(field, i)
77         {
78             Foam::transform(transField, R, transField);
79         }
81         transField.write();
82     }
86 template<class Type>
87 void Foam::fieldCoordinateSystemTransform::transform
89     const word& fieldName
90 ) const
92     typedef GeometricField<Type, fvPatchField, volMesh> vfType;
93     typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfType;
95     if (obr_.foundObject<vfType>(fieldName))
96     {
97         if (debug)
98         {
99             Info<< type() << ": Field " << fieldName << " already in database"
100                 << endl;
101         }
103         transformField<vfType>(obr_.lookupObject<vfType>(fieldName));
104     }
105     else if (obr_.foundObject<sfType>(fieldName))
106     {
107         if (debug)
108         {
109             Info<< type() << ": Field " << fieldName << " already in database"
110                 << endl;
111         }
113         transformField<sfType>(obr_.lookupObject<sfType>(fieldName));
114     }
115     else
116     {
117         IOobject fieldHeader
118         (
119             fieldName,
120             obr_.time().timeName(),
121             obr_,
122             IOobject::MUST_READ,
123             IOobject::NO_WRITE
124         );
126         if
127         (
128             fieldHeader.headerOk()
129          && fieldHeader.headerClassName() == vfType::typeName
130         )
131         {
132             if (debug)
133             {
134                 Info<< type() << ": Field " << fieldName << " read from file"
135                     << endl;
136             }
138             transformField<vfType>(obr_.lookupObject<vfType>(fieldName));
139         }
140         else if
141         (
142             fieldHeader.headerOk()
143          && fieldHeader.headerClassName() == sfType::typeName
144         )
145         {
146             if (debug)
147             {
148                 Info<< type() << ": Field " << fieldName << " read from file"
149                     << endl;
150             }
152             transformField<sfType>(obr_.lookupObject<sfType>(fieldName));
153         }
154     }
158 // ************************************************************************* //