ENH: patchCloud: return pTraits<Type>::max for unfound points
[OpenFOAM-1.7.x.git] / applications / test / directMappedPatch / testDirectMappedPatch.C
blob034e104d5fb1b21665a155e24643eba723d372cd
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
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     testDirectMappedPatch
27 Description
28     Test direct mapped b.c. by mapping face centres (mesh.C().boundaryField()).
30 \*---------------------------------------------------------------------------*/
33 #include "argList.H"
34 #include "fvMesh.H"
35 #include "volFields.H"
36 #include "meshTools.H"
37 #include "Time.H"
38 #include "OFstream.H"
39 #include "volFields.H"
40 #include "directMappedFixedValueFvPatchFields.H"
42 using namespace Foam;
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 // Main program:
49 int main(int argc, char *argv[])
51 #   include "addTimeOptions.H"
52 #   include "setRootCase.H"
53 #   include "createTime.H"
54 #   include "createMesh.H"
56     wordList patchFieldTypes
57     (
58         mesh.boundaryMesh().size(),
59         calculatedFvPatchVectorField::typeName
60     );
62     forAll(mesh.boundaryMesh(), patchI)
63     {
64         if (isA<directMappedPolyPatch>(mesh.boundaryMesh()[patchI]))
65         {
66             patchFieldTypes[patchI] =
67                 directMappedFixedValueFvPatchVectorField::typeName;
68         }
69     }
71     Pout<< "patchFieldTypes:" << patchFieldTypes << endl;
73     volVectorField cc
74     (
75         IOobject
76         (
77             "cc",
78             runTime.timeName(),
79             mesh,
80             IOobject::NO_READ,
81             IOobject::AUTO_WRITE
82         ),
83         mesh,
84         dimensionedVector("zero", dimLength, vector::zero),
85         patchFieldTypes
86     );
87     
88     cc.internalField() = mesh.C().internalField();
89     cc.boundaryField().updateCoeffs();
91     forAll(cc.boundaryField(), patchI)
92     {
93         if
94         (
95             isA<directMappedFixedValueFvPatchVectorField>
96             (
97                 cc.boundaryField()[patchI]
98             )
99         )
100         {
101             Pout<< "Detected a directMapped patch:" << patchI << endl;
103             OFstream str(mesh.boundaryMesh()[patchI].name() + ".obj");
104             Pout<< "Writing mapped values to " << str.name() << endl;
106             label vertI = 0;
107             const fvPatchVectorField& fvp = cc.boundaryField()[patchI];
109             forAll(fvp, i)
110             {
111                 meshTools::writeOBJ(str, fvp.patch().Cf()[i]);
112                 vertI++;
113                 meshTools::writeOBJ(str, fvp[i]);
114                 vertI++;
115                 str << "l " << vertI-1 << ' ' << vertI << nl;
116             }
117         }
118     }
120     Info<< "End\n" << endl;
122     return 0;
126 // ************************************************************************* //