FreeFOAM The Cross-Platform CFD Toolkit
distributedTriSurfaceMeshTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
28 #include <OpenFOAM/mapDistribute.H>
29 
30 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31 
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;
41 //
42 //
43 // // Get query data (= local index of triangle)
44 // // ~~~~~~~~~~~~~~
45 //
46 // labelList triangleIndex(info.size());
47 // autoPtr<mapDistribute> mapPtr
48 // (
49 // calcLocalQueries
50 // (
51 // info,
52 // triangleIndex
53 // )
54 // );
55 // const mapDistribute& map = mapPtr();
56 //
57 //
58 // // Do my tests
59 // // ~~~~~~~~~~~
60 //
61 // const DimensionedSurfField& fld = lookupObject<DimensionedSurfField>
62 // (
63 // fieldName
64 // );
65 // const triSurface& s = static_cast<const triSurface&>(*this);
66 //
67 // values.setSize(triangleIndex.size());
68 //
69 // forAll(triangleIndex, i)
70 // {
71 // label triI = triangleIndex[i];
72 // values[i] = fld[triI];
73 // }
74 //
75 //
76 // // Send back results
77 // // ~~~~~~~~~~~~~~~~~
78 //
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 //}
89 
90 
91 template<class Type>
92 void Foam::distributedTriSurfaceMesh::distributeFields
93 (
94  const mapDistribute& map
95 )
96 {
97  typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
98 
99  HashTable<const DimensionedSurfField*> fields
100  (
102  <DimensionedSurfField >()
103  );
104 
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());
115 
116  label oldSize = field.size();
117 
118  map.distribute
119  (
121  List<labelPair>(0),
122  map.constructSize(),
123  map.subMap(),
124  map.constructMap(),
125  field
126  );
127 
128  if (debug)
129  {
130  Info<< "Mapped " << field.typeName << ' ' << field.name()
131  << " from size " << oldSize << " to size " << field.size()
132  << endl;
133  }
134  }
135 }
136 
137 
138 // ************************ vim: set sw=4 sts=4 et: ************************ //