BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / turbulenceModels / incompressible / RAS / backwardsCompatibility / wallFunctions / backwardsCompatibilityWallFunctionsTemplates.C
blobe414d8053d9885b6cc4edddc85e789b0a1eef176
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 "backwardsCompatibilityWallFunctions.H"
27 #include "Time.H"
28 #include "OSspecific.H"
30 #include "wallFvPatch.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
36 namespace incompressible
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 template<class Type, class PatchType>
42 tmp<GeometricField<Type, fvPatchField, volMesh> >
43 autoCreateWallFunctionField
45     const word& fieldName,
46     const fvMesh& mesh
49     IOobject nutHeader
50     (
51         "nut",
52         mesh.time().timeName(),
53         mesh,
54         IOobject::MUST_READ
55     );
57     typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
59     if (nutHeader.headerOk())
60     {
61         return tmp<fieldType>
62         (
63             new fieldType
64             (
65                 IOobject
66                 (
67                     fieldName,
68                     mesh.time().timeName(),
69                     mesh,
70                     IOobject::MUST_READ,
71                     IOobject::NO_WRITE,
72                     false
73                 ),
74                 mesh
75             )
76         );
77     }
78     else
79     {
80         Info<< "--> Upgrading " << fieldName
81             << " to employ run-time selectable wall functions" << endl;
83         // Read existing field
84         IOobject ioObj
85         (
86             fieldName,
87             mesh.time().timeName(),
88             mesh,
89             IOobject::MUST_READ,
90             IOobject::NO_WRITE,
91             false
92         );
94         tmp<fieldType> fieldOrig
95         (
96             new fieldType
97             (
98                 ioObj,
99                 mesh
100             )
101         );
103         // rename file
104         Info<< "    Backup original " << fieldName << " to "
105             << fieldName << ".old" << endl;
106         mvBak(ioObj.objectPath(), "old");
109         PtrList<fvPatchField<Type> > newPatchFields(mesh.boundary().size());
111         forAll(newPatchFields, patchI)
112         {
113             if (isA<wallFvPatch>(mesh.boundary()[patchI]))
114             {
115                 newPatchFields.set
116                 (
117                     patchI,
118                     new PatchType
119                     (
120                         mesh.boundary()[patchI],
121                         fieldOrig().dimensionedInternalField()
122                     )
123                 );
124                 newPatchFields[patchI] == fieldOrig().boundaryField()[patchI];
125             }
126             else
127             {
128                 newPatchFields.set
129                 (
130                     patchI,
131                     fieldOrig().boundaryField()[patchI].clone()
132                 );
133             }
134         }
136         tmp<fieldType> fieldNew
137         (
138             new fieldType
139             (
140                 IOobject
141                 (
142                     fieldName,
143                     mesh.time().timeName(),
144                     mesh,
145                     IOobject::NO_READ,
146                     IOobject::NO_WRITE,
147                     false
148                 ),
149                 mesh,
150                 fieldOrig().dimensions(),
151                 fieldOrig().internalField(),
152                 newPatchFields
153             )
154         );
156         Info<< "    Writing updated " << fieldName << endl;
157         fieldNew().write();
159         return fieldNew;
160     }
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 } // End namespace incompressible
167 } // End namespace Foam
169 // ************************************************************************* //