changed isA<wallPolyPatch> & isA<wallFvPatch> almost everywhere
[openfoam-extend-OpenFOAM-1.6-ext.git] / src / turbulenceModels / incompressible / RAS / backwardsCompatibility / wallFunctions / backwardsCompatibilityWallFunctionsTemplates.C
blob9aea6430799016b91f47f4fe7d1ca64ace228448
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "backwardsCompatibilityWallFunctions.H"
28 #include "Time.H"
29 #include "OSspecific.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
35 namespace incompressible
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 template<class Type, class PatchType>
41 tmp<GeometricField<Type, fvPatchField, volMesh> >
42 autoCreateWallFunctionField
44     const word& fieldName,
45     const fvMesh& mesh
48     IOobject nutHeader
49     (
50         "nut",
51         mesh.time().timeName(),
52         mesh,
53         IOobject::MUST_READ
54     );
56     typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
58     if (nutHeader.headerOk())
59     {
60         return tmp<fieldType>
61         (
62             new fieldType
63             (
64                 IOobject
65                 (
66                     fieldName,
67                     mesh.time().timeName(),
68                     mesh,
69                     IOobject::MUST_READ,
70                     IOobject::NO_WRITE,
71                     false
72                 ),
73                 mesh
74             )
75         );
76     }
77     else
78     {
79         Info<< "--> Upgrading " << fieldName
80             << " to employ run-time selectable wall functions" << endl;
82         // Read existing field
83         IOobject ioObj
84         (
85             fieldName,
86             mesh.time().timeName(),
87             mesh,
88             IOobject::MUST_READ,
89             IOobject::NO_WRITE,
90             false
91         );
93         tmp<fieldType> fieldOrig
94         (
95             new fieldType
96             (
97                 ioObj,
98                 mesh
99             )
100         );
102         // rename file
103         Info<< "    Backup original " << fieldName << " to "
104             << fieldName << ".old" << endl;
105         mvBak(ioObj.objectPath(), "old");
108         PtrList<fvPatchField<Type> > newPatchFields(mesh.boundary().size());
110         forAll(newPatchFields, patchI)
111         {
112             if (mesh.boundary()[patchI].isWall())
113             {
114                 newPatchFields.set
115                 (
116                     patchI,
117                     new PatchType
118                     (
119                         mesh.boundary()[patchI],
120                         fieldOrig().dimensionedInternalField()
121                     )
122                 );
123                 newPatchFields[patchI] == fieldOrig().boundaryField()[patchI];
124             }
125             else
126             {
127                 newPatchFields.set
128                 (
129                     patchI,
130                     fieldOrig().boundaryField()[patchI].clone()
131                 );
132             }
133         }
135         tmp<fieldType> fieldNew
136         (
137             new fieldType
138             (
139                 IOobject
140                 (
141                     fieldName,
142                     mesh.time().timeName(),
143                     mesh,
144                     IOobject::NO_READ,
145                     IOobject::NO_WRITE,
146                     false
147                 ),
148                 mesh,
149                 fieldOrig().dimensions(),
150                 fieldOrig().internalField(),
151                 newPatchFields
152             )
153         );
155         Info<< "    Writing updated " << fieldName << endl;
156         fieldNew().write();
158         return fieldNew;
159     }
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 } // End namespace incompressible
166 } // End namespace Foam
168 // ************************************************************************* //