1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include "fvMeshAdder.H"
29 #include "faceCoupleInfo.H"
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 //- Calculate map from new patch faces to old patch faces. -1 where
36 Foam::labelList Foam::fvMeshAdder::calcPatchMap
40 const labelList& oldToNew,
41 const polyPatch& newPatch,
42 const label unmappedValue
45 labelList newToOld(newPatch.size(), unmappedValue);
47 label newStart = newPatch.start();
48 label newSize = newPatch.size();
50 for (label i = 0; i < oldSize; i++)
52 label newFaceI = oldToNew[oldStart+i];
54 if (newFaceI >= newStart && newFaceI < newStart+newSize)
56 newToOld[newFaceI-newStart] = i;
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65 // Inplace add mesh1 to mesh0
66 Foam::autoPtr<Foam::mapAddedPolyMesh> Foam::fvMeshAdder::add
70 const faceCoupleInfo& coupleInfo,
71 const bool validBoundary
76 // Resulting merged mesh (polyMesh only!)
77 autoPtr<mapAddedPolyMesh> mapPtr
88 // Adjust the fvMesh part.
89 const polyBoundaryMesh& patches = mesh0.boundaryMesh();
91 fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh0.boundary());
92 fvPatches.setSize(patches.size());
93 forAll(patches, patchI)
95 fvPatches.set(patchI, fvPatch::New(patches[patchI], fvPatches));
98 // Do the mapping of the stored fields
99 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100 fvMeshAdder::MapVolFields<scalar>(mapPtr, mesh0, mesh1);
101 fvMeshAdder::MapVolFields<vector>(mapPtr, mesh0, mesh1);
102 fvMeshAdder::MapVolFields<sphericalTensor>(mapPtr, mesh0, mesh1);
103 fvMeshAdder::MapVolFields<symmTensor>(mapPtr, mesh0, mesh1);
104 fvMeshAdder::MapVolFields<tensor>(mapPtr, mesh0, mesh1);
106 fvMeshAdder::MapSurfaceFields<scalar>(mapPtr, mesh0, mesh1);
107 fvMeshAdder::MapSurfaceFields<vector>(mapPtr, mesh0, mesh1);
108 fvMeshAdder::MapSurfaceFields<sphericalTensor>(mapPtr, mesh0, mesh1);
109 fvMeshAdder::MapSurfaceFields<symmTensor>(mapPtr, mesh0, mesh1);
110 fvMeshAdder::MapSurfaceFields<tensor>(mapPtr, mesh0, mesh1);
116 // ************************************************************************* //