initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / test / directMappedPatch / testDirectMappedPatch.C
blobdd27ff6955d92b5adf9023913b2966b0ee38f748
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2007 OpenCFD Ltd.
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 Application
26     testDirectMappedPatch
28 Description
29     Test direct mapped b.c. by mapping face centres (mesh.C().boundaryField()).
31 \*---------------------------------------------------------------------------*/
34 #include "argList.H"
35 #include "fvMesh.H"
36 #include "volFields.H"
37 #include "meshTools.H"
38 #include "Time.H"
39 #include "OFstream.H"
40 #include "volFields.H"
41 #include "directMappedFixedValueFvPatchFields.H"
43 using namespace Foam;
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 // Main program:
50 int main(int argc, char *argv[])
52 #   include "addTimeOptions.H"
53 #   include "setRootCase.H"
54 #   include "createTime.H"
55 #   include "createMesh.H"
57     wordList patchFieldTypes
58     (
59         mesh.boundaryMesh().size(),
60         calculatedFvPatchVectorField::typeName
61     );
63     forAll(mesh.boundaryMesh(), patchI)
64     {
65         if (isA<directMappedPolyPatch>(mesh.boundaryMesh()[patchI]))
66         {
67             patchFieldTypes[patchI] =
68                 directMappedFixedValueFvPatchVectorField::typeName;
69         }
70     }
72     Pout<< "patchFieldTypes:" << patchFieldTypes << endl;
74     volVectorField cc
75     (
76         IOobject
77         (
78             "cc",
79             runTime.timeName(),
80             mesh,
81             IOobject::NO_READ,
82             IOobject::AUTO_WRITE
83         ),
84         mesh,
85         dimensionedVector("zero", dimLength, vector::zero),
86         patchFieldTypes
87     );
88     
89     cc.internalField() = mesh.C().internalField();
90     cc.boundaryField().updateCoeffs();
92     forAll(cc.boundaryField(), patchI)
93     {
94         if
95         (
96             isA<directMappedFixedValueFvPatchVectorField>
97             (
98                 cc.boundaryField()[patchI]
99             )
100         )
101         {
102             Pout<< "Detected a directMapped patch:" << patchI << endl;
104             OFstream str(mesh.boundaryMesh()[patchI].name() + ".obj");
105             Pout<< "Writing mapped values to " << str.name() << endl;
107             label vertI = 0;
108             const fvPatchVectorField& fvp = cc.boundaryField()[patchI];
110             forAll(fvp, i)
111             {
112                 meshTools::writeOBJ(str, fvp.patch().Cf()[i]);
113                 vertI++;
114                 meshTools::writeOBJ(str, fvp[i]);
115                 vertI++;
116                 str << "l " << vertI-1 << ' ' << vertI << nl;
117             }
118         }
119     }
121     Info<< "End\n" << endl;
123     return 0;
127 // ************************************************************************* //