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

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