BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / applications / utilities / mesh / manipulation / singleCellMesh / singleCellMesh.C
blobe47e27461ba24212bfb1c6eb04901ff992d63d84
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 Application
25     singleCellMesh
27 Description
28     Removes all but one cells of the mesh. Used to generate mesh and fields
29     that can be used for boundary-only data.
30     Might easily result in illegal mesh though so only look at boundaries
31     in paraview.
33 \*---------------------------------------------------------------------------*/
36 #include "argList.H"
37 #include "fvMesh.H"
38 #include "volFields.H"
39 #include "Time.H"
40 #include "ReadFields.H"
41 #include "singleCellFvMesh.H"
43 using namespace Foam;
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 template<class GeoField>
48 void interpolateFields
50     const singleCellFvMesh& scMesh,
51     const PtrList<GeoField>& flds
54     forAll(flds, i)
55     {
56         tmp<GeoField> scFld = scMesh.interpolate(flds[i]);
57         GeoField* scFldPtr = scFld.ptr();
58         scFldPtr->writeOpt() = IOobject::AUTO_WRITE;
59         scFldPtr->store();
60     }
64 // Main program:
66 int main(int argc, char *argv[])
68 #   include "addOverwriteOption.H"
69 #   include "addTimeOptions.H"
71 #   include "setRootCase.H"
72 #   include "createTime.H"
73     // Get times list
74     instantList Times = runTime.times();
75 #   include "checkTimeOptions.H"
76     runTime.setTime(Times[startTime], startTime);
77 #   include "createMesh.H"
78     const word oldInstance = mesh.pointsInstance();
80     const bool overwrite = args.optionFound("overwrite");
83     // Read objects in time directory
84     IOobjectList objects(mesh, runTime.timeName());
86     // Read vol fields.
87     PtrList<volScalarField> vsFlds;
88     ReadFields(mesh, objects, vsFlds);
90     PtrList<volVectorField> vvFlds;
91     ReadFields(mesh, objects, vvFlds);
93     PtrList<volSphericalTensorField> vstFlds;
94     ReadFields(mesh, objects, vstFlds);
96     PtrList<volSymmTensorField> vsymtFlds;
97     ReadFields(mesh, objects, vsymtFlds);
99     PtrList<volTensorField> vtFlds;
100     ReadFields(mesh, objects, vtFlds);
103     if (!overwrite)
104     {
105         runTime++;
106     }
108     // Create the mesh
109     singleCellFvMesh scMesh
110     (
111         IOobject
112         (
113             mesh.name(),
114             mesh.polyMesh::instance(),
115             runTime,
116             IOobject::NO_READ,
117             IOobject::AUTO_WRITE
118         ),
119         mesh
120     );
123     // Map and store the fields on the scMesh.
124     interpolateFields(scMesh, vsFlds);
125     interpolateFields(scMesh, vvFlds);
126     interpolateFields(scMesh, vstFlds);
127     interpolateFields(scMesh, vsymtFlds);
128     interpolateFields(scMesh, vtFlds);
131     // Write
132     Info<< "Writing mesh to time " << runTime.timeName() << endl;
133     scMesh.write();
136     Info<< "End\n" << endl;
138     return 0;
142 // ************************************************************************* //