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

fvMeshAdder.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 <finiteVolume/fvMesh.H>
00027 #include "fvMeshAdder.H"
00028 #include <dynamicMesh/faceCoupleInfo.H>
00029 #include <finiteVolume/fvMesh.H>
00030 
00031 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00032 
00033 //- Calculate map from new patch faces to old patch faces. -1 where
00034 //  could not map.
00035 Foam::labelList Foam::fvMeshAdder::calcPatchMap
00036 (
00037     const label oldStart,
00038     const label oldSize,
00039     const labelList& oldToNew,
00040     const polyPatch& newPatch,
00041     const label unmappedValue
00042 )
00043 {
00044     labelList newToOld(newPatch.size(), unmappedValue);
00045 
00046     label newStart = newPatch.start();
00047     label newSize = newPatch.size();
00048 
00049     for (label i = 0; i < oldSize; i++)
00050     {
00051         label newFaceI = oldToNew[oldStart+i];
00052 
00053         if (newFaceI >= newStart && newFaceI < newStart+newSize)
00054         {
00055             newToOld[newFaceI-newStart] = i;
00056         }
00057     }
00058     return newToOld;
00059 }
00060 
00061 
00062 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00063 
00064 // Inplace add mesh1 to mesh0
00065 Foam::autoPtr<Foam::mapAddedPolyMesh> Foam::fvMeshAdder::add
00066 (
00067     fvMesh& mesh0,
00068     const fvMesh& mesh1,
00069     const faceCoupleInfo& coupleInfo,
00070     const bool validBoundary
00071 )
00072 {
00073     mesh0.clearOut();
00074 
00075     // Resulting merged mesh (polyMesh only!)
00076     autoPtr<mapAddedPolyMesh> mapPtr
00077     (
00078         polyMeshAdder::add
00079         (
00080             mesh0,
00081             mesh1,
00082             coupleInfo,
00083             validBoundary
00084         )
00085     );
00086 
00087     // Adjust the fvMesh part.
00088     const polyBoundaryMesh& patches = mesh0.boundaryMesh();
00089 
00090     fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh0.boundary());
00091     fvPatches.setSize(patches.size());
00092     forAll(patches, patchI)
00093     {
00094         fvPatches.set(patchI, fvPatch::New(patches[patchI], fvPatches));
00095     }
00096 
00097     // Do the mapping of the stored fields
00098     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00099     fvMeshAdder::MapVolFields<scalar>(mapPtr, mesh0, mesh1);
00100     fvMeshAdder::MapVolFields<vector>(mapPtr, mesh0, mesh1);
00101     fvMeshAdder::MapVolFields<sphericalTensor>(mapPtr, mesh0, mesh1);
00102     fvMeshAdder::MapVolFields<symmTensor>(mapPtr, mesh0, mesh1);
00103     fvMeshAdder::MapVolFields<tensor>(mapPtr, mesh0, mesh1);
00104 
00105     fvMeshAdder::MapSurfaceFields<scalar>(mapPtr, mesh0, mesh1);
00106     fvMeshAdder::MapSurfaceFields<vector>(mapPtr, mesh0, mesh1);
00107     fvMeshAdder::MapSurfaceFields<sphericalTensor>(mapPtr, mesh0, mesh1);
00108     fvMeshAdder::MapSurfaceFields<symmTensor>(mapPtr, mesh0, mesh1);
00109     fvMeshAdder::MapSurfaceFields<tensor>(mapPtr, mesh0, mesh1);
00110 
00111     return mapPtr;
00112 }
00113 
00114 
00115 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines