Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / meshTools / searchableSurface / distributedTriSurfaceMeshTemplates.C
blob96b92597977eaff9f51b9fd755027cda24f51fcc
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "distributedTriSurfaceMesh.H"
27 #include "triSurfaceFields.H"
28 #include "mapDistribute.H"
30 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
32 //template<class Type>
33 //void Foam::distributedTriSurfaceMesh::getField
34 //(
35 //    const word& fieldName,
36 //    const List<pointIndexHit>& info,
37 //    List<Type>& values
38 //) const
39 //{
40 //    typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
43 //    // Get query data (= local index of triangle)
44 //    // ~~~~~~~~~~~~~~
46 //    labelList triangleIndex(info.size());
47 //    autoPtr<mapDistribute> mapPtr
48 //    (
49 //        calcLocalQueries
50 //        (
51 //            info,
52 //            triangleIndex
53 //        )
54 //    );
55 //    const mapDistribute& map = mapPtr();
58 //    // Do my tests
59 //    // ~~~~~~~~~~~
61 //    const DimensionedSurfField& fld = lookupObject<DimensionedSurfField>
62 //    (
63 //        fieldName
64 //    );
65 //    const triSurface& s = static_cast<const triSurface&>(*this);
67 //    values.setSize(triangleIndex.size());
69 //    forAll(triangleIndex, i)
70 //    {
71 //        label triI = triangleIndex[i];
72 //        values[i] = fld[triI];
73 //    }
76 //    // Send back results
77 //    // ~~~~~~~~~~~~~~~~~
79 //    map.distribute
80 //    (
81 //        Pstream::nonBlocking,
82 //        List<labelPair>(0),
83 //        info.size(),
84 //        map.constructMap(),     // what to send
85 //        map.subMap(),           // what to receive
86 //        values
87 //    );
88 //}
91 template<class Type>
92 void Foam::distributedTriSurfaceMesh::distributeFields
94     const mapDistribute& map
97     typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
99     HashTable<const DimensionedSurfField*> fields
100     (
101         objectRegistry::lookupClass
102         <DimensionedSurfField >()
103     );
105     for
106     (
107         typename HashTable<const DimensionedSurfField*>::iterator fieldIter =
108             fields.begin();
109         fieldIter != fields.end();
110         ++fieldIter
111     )
112     {
113         DimensionedSurfField& field =
114             const_cast<DimensionedSurfField&>(*fieldIter());
116         label oldSize = field.size();
118         map.distribute
119         (
120             Pstream::nonBlocking,
121             List<labelPair>(0),
122             map.constructSize(),
123             map.subMap(),
124             map.constructMap(),
125             field
126         );
128         if (debug)
129         {
130             Info<< "Mapped " << field.typeName << ' ' << field.name()
131                 << " from size " << oldSize << " to size " << field.size()
132                 << endl;
133         }
134     }
138 // ************************************************************************* //