FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "distributedTriSurfaceMesh.H"
00027 #include <triSurface/triSurfaceFields.H>
00028 #include <OpenFOAM/mapDistribute.H>
00029 
00030 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00031 
00032 //template<class Type>
00033 //void Foam::distributedTriSurfaceMesh::getField
00034 //(
00035 //    const word& fieldName,
00036 //    const List<pointIndexHit>& info,
00037 //    List<Type>& values
00038 //) const
00039 //{
00040 //    typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
00041 //
00042 //
00043 //    // Get query data (= local index of triangle)
00044 //    // ~~~~~~~~~~~~~~
00045 //
00046 //    labelList triangleIndex(info.size());
00047 //    autoPtr<mapDistribute> mapPtr
00048 //    (
00049 //        calcLocalQueries
00050 //        (
00051 //            info,
00052 //            triangleIndex
00053 //        )
00054 //    );
00055 //    const mapDistribute& map = mapPtr();
00056 //
00057 //
00058 //    // Do my tests
00059 //    // ~~~~~~~~~~~
00060 //
00061 //    const DimensionedSurfField& fld = lookupObject<DimensionedSurfField>
00062 //    (
00063 //        fieldName
00064 //    );
00065 //    const triSurface& s = static_cast<const triSurface&>(*this);
00066 //
00067 //    values.setSize(triangleIndex.size());
00068 //
00069 //    forAll(triangleIndex, i)
00070 //    {
00071 //        label triI = triangleIndex[i];
00072 //        values[i] = fld[triI];
00073 //    }
00074 //
00075 //
00076 //    // Send back results
00077 //    // ~~~~~~~~~~~~~~~~~
00078 //
00079 //    map.distribute
00080 //    (
00081 //        Pstream::nonBlocking,
00082 //        List<labelPair>(0),
00083 //        info.size(),
00084 //        map.constructMap(),     // what to send
00085 //        map.subMap(),           // what to receive
00086 //        values
00087 //    );
00088 //}
00089 
00090 
00091 template<class Type>
00092 void Foam::distributedTriSurfaceMesh::distributeFields
00093 (
00094     const mapDistribute& map
00095 )
00096 {
00097     typedef DimensionedField<Type, triSurfaceGeoMesh> DimensionedSurfField;
00098 
00099     HashTable<const DimensionedSurfField*> fields
00100     (
00101         objectRegistry::lookupClass
00102         <DimensionedSurfField >()
00103     );
00104 
00105     for
00106     (
00107         typename HashTable<const DimensionedSurfField*>::iterator fieldIter =
00108             fields.begin();
00109         fieldIter != fields.end();
00110         ++fieldIter
00111     )
00112     {
00113         DimensionedSurfField& field =
00114             const_cast<DimensionedSurfField&>(*fieldIter());
00115 
00116         label oldSize = field.size();
00117 
00118         map.distribute
00119         (
00120             Pstream::nonBlocking,
00121             List<labelPair>(0),
00122             map.constructSize(),
00123             map.subMap(),
00124             map.constructMap(),
00125             field
00126         );
00127 
00128         if (debug)
00129         {
00130             Info<< "Mapped " << field.typeName << ' ' << field.name()
00131                 << " from size " << oldSize << " to size " << field.size()
00132                 << endl;
00133         }
00134     }
00135 }
00136 
00137 
00138 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines