OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

distributedTriSurfaceMeshTemplates.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "distributedTriSurfaceMesh.H"
00028 #include "triSurfaceFields.H"
00029 #include "mapDistribute.H"
00030 
00031 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00032 
00033 //template<class Type>
00034 //void Foam::distributedTriSurfaceMesh::getField
00035 //(
00036 //    const word& fieldName,
00037 //    const List<pointIndexHit>& info,
00038 //    List<Type>& values
00039 //) const
00040 //{
00041 //    typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
00042 //
00043 //
00044 //    // Get query data (= local index of triangle)
00045 //    // ~~~~~~~~~~~~~~
00046 //
00047 //    labelList triangleIndex(info.size());
00048 //    autoPtr<mapDistribute> mapPtr
00049 //    (
00050 //        calcLocalQueries
00051 //        (
00052 //            info,
00053 //            triangleIndex
00054 //        )
00055 //    );
00056 //    const mapDistribute& map = mapPtr();
00057 //
00058 //
00059 //    // Do my tests
00060 //    // ~~~~~~~~~~~
00061 //
00062 //    const DimensionedSurfField& fld = lookupObject<DimensionedSurfField>
00063 //    (
00064 //        fieldName
00065 //    );
00066 //    const triSurface& s = static_cast<const triSurface&>(*this);
00067 //
00068 //    values.setSize(triangleIndex.size());
00069 //
00070 //    forAll(triangleIndex, i)
00071 //    {
00072 //        label triI = triangleIndex[i];
00073 //        values[i] = fld[triI];
00074 //    }
00075 //
00076 //
00077 //    // Send back results
00078 //    // ~~~~~~~~~~~~~~~~~
00079 //
00080 //    map.distribute
00081 //    (
00082 //        Pstream::nonBlocking,
00083 //        List<labelPair>(0),
00084 //        info.size(),
00085 //        map.constructMap(),     // what to send
00086 //        map.subMap(),           // what to receive
00087 //        values
00088 //    );
00089 //}
00090 
00091 
00092 template<class Type>
00093 void Foam::distributedTriSurfaceMesh::distributeFields
00094 (
00095     const mapDistribute& map
00096 )
00097 {
00098     typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
00099 
00100     HashTable<const DimensionedSurfField*> fields
00101     (
00102         objectRegistry::lookupClass
00103         <DimensionedSurfField >()
00104     );
00105 
00106     for
00107     (
00108         typename HashTable<const DimensionedSurfField*>::iterator fieldIter =
00109             fields.begin();
00110         fieldIter != fields.end();
00111         ++fieldIter
00112     )
00113     {
00114         DimensionedSurfField& field =
00115             const_cast<DimensionedSurfField&>(*fieldIter());
00116 
00117         label oldSize = field.size();
00118 
00119         map.distribute
00120         (
00121             Pstream::nonBlocking,
00122             List<labelPair>(0),
00123             map.constructSize(),
00124             map.subMap(),
00125             map.constructMap(),
00126             field
00127         );
00128 
00129         if (debug)
00130         {
00131             Info<< "Mapped " << field.typeName << ' ' << field.name()
00132                 << " from size " << oldSize << " to size " << field.size()
00133                 << endl;
00134         }
00135     }
00136 }
00137 
00138 
00139 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd