backwardsCompatibilityWallFunctionsTemplates.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "backwardsCompatibilityWallFunctions.H"
00028 #include "Time.H"
00029 #include "OSspecific.H"
00030
00031 #include "wallPolyPatch.H"
00032
00033
00034
00035 namespace Foam
00036 {
00037 namespace incompressible
00038 {
00039
00040
00041
00042 template<class Type, class PatchType>
00043 tmp<GeometricField<Type, fvPatchField, volMesh> >
00044 autoCreateWallFunctionField
00045 (
00046 const word& fieldName,
00047 const fvMesh& mesh
00048 )
00049 {
00050 IOobject nutHeader
00051 (
00052 "nut",
00053 mesh.time().timeName(),
00054 mesh,
00055 IOobject::MUST_READ
00056 );
00057
00058 typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
00059
00060 if (nutHeader.headerOk())
00061 {
00062 return tmp<fieldType>
00063 (
00064 new fieldType
00065 (
00066 IOobject
00067 (
00068 fieldName,
00069 mesh.time().timeName(),
00070 mesh,
00071 IOobject::MUST_READ,
00072 IOobject::NO_WRITE,
00073 false
00074 ),
00075 mesh
00076 )
00077 );
00078 }
00079 else
00080 {
00081 Info<< "--> Upgrading " << fieldName
00082 << " to employ run-time selectable wall functions" << endl;
00083
00084
00085 IOobject ioObj
00086 (
00087 fieldName,
00088 mesh.time().timeName(),
00089 mesh,
00090 IOobject::MUST_READ,
00091 IOobject::NO_WRITE,
00092 false
00093 );
00094
00095 tmp<fieldType> fieldOrig
00096 (
00097 new fieldType
00098 (
00099 ioObj,
00100 mesh
00101 )
00102 );
00103
00104
00105 Info<< " Backup original " << fieldName << " to "
00106 << fieldName << ".old" << endl;
00107 mvBak(ioObj.objectPath(), "old");
00108
00109
00110 PtrList<fvPatchField<Type> > newPatchFields(mesh.boundary().size());
00111
00112 forAll(newPatchFields, patchI)
00113 {
00114 if (isType<wallPolyPatch>(mesh.boundaryMesh()[patchI]))
00115 {
00116 newPatchFields.set
00117 (
00118 patchI,
00119 new PatchType
00120 (
00121 mesh.boundary()[patchI],
00122 fieldOrig().dimensionedInternalField()
00123 )
00124 );
00125 newPatchFields[patchI] == fieldOrig().boundaryField()[patchI];
00126 }
00127 else
00128 {
00129 newPatchFields.set
00130 (
00131 patchI,
00132 fieldOrig().boundaryField()[patchI].clone()
00133 );
00134 }
00135 }
00136
00137 tmp<fieldType> fieldNew
00138 (
00139 new fieldType
00140 (
00141 IOobject
00142 (
00143 fieldName,
00144 mesh.time().timeName(),
00145 mesh,
00146 IOobject::NO_READ,
00147 IOobject::NO_WRITE,
00148 false
00149 ),
00150 mesh,
00151 fieldOrig().dimensions(),
00152 fieldOrig().internalField(),
00153 newPatchFields
00154 )
00155 );
00156
00157 Info<< " Writing updated " << fieldName << endl;
00158 fieldNew().write();
00159
00160 return fieldNew;
00161 }
00162 }
00163
00164
00165
00166
00167 }
00168 }
00169
00170
Copyright © 2000-2009 OpenCFD Ltd