Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / meshTools / searchableSurface / distributedTriSurfaceMeshTemplates.C
blob79b8f5ce4c54a67b62dfd3058de9db5fd08fa54e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 \*---------------------------------------------------------------------------*/
27 #include "distributedTriSurfaceMesh.H"
28 #include "triSurfaceFields.H"
29 #include "mapDistribute.H"
31 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
33 //template<class Type>
34 //void Foam::distributedTriSurfaceMesh::getField
35 //(
36 //    const word& fieldName,
37 //    const List<pointIndexHit>& info,
38 //    List<Type>& values
39 //) const
40 //{
41 //    typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
44 //    // Get query data (= local index of triangle)
45 //    // ~~~~~~~~~~~~~~
47 //    labelList triangleIndex(info.size());
48 //    autoPtr<mapDistribute> mapPtr
49 //    (
50 //        calcLocalQueries
51 //        (
52 //            info,
53 //            triangleIndex
54 //        )
55 //    );
56 //    const mapDistribute& map = mapPtr();
59 //    // Do my tests
60 //    // ~~~~~~~~~~~
62 //    const DimensionedSurfField& fld = lookupObject<DimensionedSurfField>
63 //    (
64 //        fieldName
65 //    );
66 //    const triSurface& s = static_cast<const triSurface&>(*this);
68 //    values.setSize(triangleIndex.size());
70 //    forAll(triangleIndex, i)
71 //    {
72 //        label triI = triangleIndex[i];
73 //        values[i] = fld[triI];
74 //    }
77 //    // Send back results
78 //    // ~~~~~~~~~~~~~~~~~
80 //    map.distribute
81 //    (
82 //        Pstream::nonBlocking,
83 //        List<labelPair>(0),
84 //        info.size(),
85 //        map.constructMap(),     // what to send
86 //        map.subMap(),           // what to receive
87 //        values
88 //    );
89 //}
92 template<class Type>
93 void Foam::distributedTriSurfaceMesh::distributeFields
95     const mapDistribute& map
98     typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
100     HashTable<const DimensionedSurfField*> fields
101     (
102         objectRegistry::lookupClass
103         <DimensionedSurfField >()
104     );
106     for
107     (
108         typename HashTable<const DimensionedSurfField*>::iterator fieldIter =
109             fields.begin();
110         fieldIter != fields.end();
111         ++fieldIter
112     )
113     {
114         DimensionedSurfField& field =
115             const_cast<DimensionedSurfField&>(*fieldIter());
117         label oldSize = field.size();
119         map.distribute
120         (
121             Pstream::nonBlocking,
122             List<labelPair>(0),
123             map.constructSize(),
124             map.subMap(),
125             map.constructMap(),
126             field
127         );
129         if (debug)
130         {
131             Info<< "Mapped " << field.typeName << ' ' << field.name()
132                 << " from size " << oldSize << " to size " << field.size()
133                 << endl;
134         }
135     }
139 // ************************************************************************* //