OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

createFields.H

Go to the documentation of this file.
00001 // Construct List of pointers to all vol fields
00002 int nFields = volScalarNames.size() + 3*volVectorNames.size();
00003 List<volScalarField*> volFieldPtrs
00004 (
00005     nFields,
00006     reinterpret_cast<volScalarField*>(0)
00007 );
00008 
00009 stringList volFieldNames(nFields);
00010 
00011 nFields = 0;
00012 {
00013     // Load all scalar fields and store ptr to it
00014     forAll(volScalarNames, fieldI)
00015     {
00016         word fieldName = volScalarNames[fieldI];
00017 
00018         // Check if present
00019         IOobject ioHeader
00020         (
00021             fieldName,
00022             runTime.timeName(),
00023             mesh,
00024             IOobject::MUST_READ,
00025             IOobject::NO_WRITE
00026         );
00027 
00028         if (ioHeader.headerOk())
00029         {
00030            volFieldPtrs[nFields] = new volScalarField
00031             (
00032                 ioHeader,
00033                 mesh
00034             );
00035         }
00036 
00037         fieldName = getFieldViewName(fieldName);
00038 
00039         volFieldNames[nFields] = fieldName;
00040 
00041         nFields++;
00042     }
00043 
00044 
00045     // Load all  (componenents of) vector fields
00046     forAll(volVectorNames, fieldI)
00047     {
00048         word fieldName = volVectorNames[fieldI];
00049 
00050         // Check if present
00051         IOobject ioHeader
00052         (
00053             fieldName,
00054             runTime.timeName(),
00055             mesh,
00056             IOobject::MUST_READ,
00057             IOobject::NO_WRITE
00058         );
00059 
00060         if (ioHeader.headerOk())
00061         {
00062             volVectorField vvf(ioHeader, mesh);
00063 
00064             // X component
00065             volFieldPtrs[nFields] =
00066                 new volScalarField
00067                 (
00068                     vvf.component(vector::X)
00069                 );
00070 
00071             // Y component
00072             volFieldPtrs[nFields+1] =
00073                 new volScalarField
00074                 (
00075                     vvf.component(vector::Y)
00076                 );
00077 
00078             // Z component
00079             volFieldPtrs[nFields+2] =
00080                 new volScalarField
00081                 (
00082                     vvf.component(vector::Z)
00083                 );
00084         }
00085 
00086         fieldName = getFieldViewName(fieldName);
00087 
00088         volFieldNames[nFields]   = fieldName + ("x;" +  fieldName);
00089         volFieldNames[nFields+1] = fieldName + "y";
00090         volFieldNames[nFields+2] = fieldName + "z";
00091 
00092         nFields += 3;
00093     }
00094 }
00095 
00096 
00097 
00098 //
00099 // Construct List of pointers to all surface fields
00100 //
00101 
00102 
00103 
00104 int nSurfFields = surfScalarNames.size() + 3*surfVectorNames.size();
00105 List<surfaceScalarField*> surfFieldPtrs
00106 (
00107     nSurfFields,
00108     reinterpret_cast<surfaceScalarField*>(0)
00109 );
00110 
00111 stringList surfFieldNames(nSurfFields);
00112 
00113 nSurfFields = 0;
00114 {
00115     // Load all scalar fields
00116     forAll(surfScalarNames, fieldI)
00117     {
00118         word fieldName = surfScalarNames[fieldI];
00119 
00120         // Check if present
00121         IOobject ioHeader
00122         (
00123             fieldName,
00124             runTime.timeName(),
00125             mesh,
00126             IOobject::MUST_READ,
00127             IOobject::NO_WRITE
00128         );
00129 
00130         if (ioHeader.headerOk())
00131         {
00132             surfFieldPtrs[nSurfFields] =
00133                 new surfaceScalarField
00134                 (
00135                     ioHeader,
00136                     mesh
00137                 );
00138         }
00139 
00140         fieldName = getFieldViewName(fieldName);
00141 
00142         surfFieldNames[nSurfFields] = fieldName;
00143 
00144         nSurfFields++;
00145     }
00146 
00147 
00148     // Set (componenents of) vector fields
00149     forAll(surfVectorNames, fieldI)
00150     {
00151         word fieldName = surfVectorNames[fieldI];
00152 
00153         // Check if present
00154         IOobject ioHeader
00155         (
00156             fieldName,
00157             runTime.timeName(),
00158             mesh,
00159             IOobject::MUST_READ,
00160             IOobject::NO_WRITE
00161         );
00162 
00163         if (ioHeader.headerOk())
00164         {
00165             surfaceVectorField svf(ioHeader, mesh);
00166 
00167             // X component
00168             surfFieldPtrs[nSurfFields] =
00169                 new surfaceScalarField
00170                 (
00171                     svf.component(vector::X)
00172                 );
00173 
00174             // Y component
00175             surfFieldPtrs[nSurfFields+1] =
00176                 new surfaceScalarField
00177                 (
00178                     svf.component(vector::Y)
00179                 );
00180 
00181             // Z component
00182             surfFieldPtrs[nSurfFields+2] =
00183                 new surfaceScalarField
00184                 (
00185                     svf.component(vector::Z)
00186                 );
00187         }
00188 
00189         fieldName = getFieldViewName(fieldName);
00190 
00191         surfFieldNames[nSurfFields]   = fieldName + ("x;" + fieldName);
00192         surfFieldNames[nSurfFields+1] = fieldName + "y";
00193         surfFieldNames[nSurfFields+2] = fieldName + "z";
00194 
00195         nSurfFields += 3;
00196     }
00197 }
Copyright © 2000-2009 OpenCFD Ltd