1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "meshToMesh.H"
27 #include "processorFvPatch.H"
28 #include "demandDrivenData.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 defineTypeNameAndDebug(Foam::meshToMesh, 0);
34 const Foam::scalar Foam::meshToMesh::directHitTol = 1e-5;
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 Foam::meshToMesh::meshToMesh
40 const fvMesh& meshFrom,
42 const HashTable<word>& patchMap,
43 const wordList& cuttingPatchNames
49 cellAddressing_(toMesh_.nCells()),
50 boundaryAddressing_(toMesh_.boundaryMesh().size()),
51 inverseDistanceWeightsPtr_(NULL)
53 forAll(fromMesh_.boundaryMesh(), patchi)
55 fromMeshPatches_.insert
57 fromMesh_.boundaryMesh()[patchi].name(),
62 forAll(toMesh_.boundaryMesh(), patchi)
66 toMesh_.boundaryMesh()[patchi].name(),
71 forAll(cuttingPatchNames, i)
73 if (toMeshPatches_.found(cuttingPatchNames[i]))
75 cuttingPatches_.insert
78 toMeshPatches_.find(cuttingPatchNames[i])()
85 "meshToMesh::meshToMesh"
86 "(const fvMesh& meshFrom, const fvMesh& meshTo,"
87 "const HashTable<word>& patchMap,"
88 "const wordList& cuttingPatchNames)"
89 ) << "Cannot find cutting-patch " << cuttingPatchNames[i]
90 << " in destination mesh" << endl;
94 forAll(toMesh_.boundaryMesh(), patchi)
96 // Add the processor patches in the toMesh to the cuttingPatches list
97 if (isA<processorPolyPatch>(toMesh_.boundaryMesh()[patchi]))
99 cuttingPatches_.insert
101 toMesh_.boundaryMesh()[patchi].name(),
111 Foam::meshToMesh::meshToMesh
113 const fvMesh& meshFrom,
119 cellAddressing_(toMesh_.nCells()),
120 boundaryAddressing_(toMesh_.boundaryMesh().size()),
121 inverseDistanceWeightsPtr_(NULL)
123 // check whether both meshes have got the same number
124 // of boundary patches
125 if (fromMesh_.boundary().size() != toMesh_.boundary().size())
129 "meshToMesh::meshToMesh"
130 "(const fvMesh& meshFrom, const fvMesh& meshTo)"
131 ) << "Incompatible meshes: different number of patches, "
132 << "fromMesh = " << fromMesh_.boundary().size()
133 << ", toMesh = " << toMesh_.boundary().size()
137 forAll(fromMesh_.boundaryMesh(), patchi)
141 fromMesh_.boundaryMesh()[patchi].name()
142 != toMesh_.boundaryMesh()[patchi].name()
147 "meshToMesh::meshToMesh"
148 "(const fvMesh& meshFrom, const fvMesh& meshTo)"
149 ) << "Incompatible meshes: different patch names for patch "
151 << ", fromMesh = " << fromMesh_.boundary()[patchi].name()
152 << ", toMesh = " << toMesh_.boundary()[patchi].name()
158 fromMesh_.boundaryMesh()[patchi].type()
159 != toMesh_.boundaryMesh()[patchi].type()
164 "meshToMesh::meshToMesh"
165 "(const fvMesh& meshFrom, const fvMesh& meshTo)"
166 ) << "Incompatible meshes: different patch types for patch "
168 << ", fromMesh = " << fromMesh_.boundary()[patchi].type()
169 << ", toMesh = " << toMesh_.boundary()[patchi].type()
173 fromMeshPatches_.insert
175 fromMesh_.boundaryMesh()[patchi].name(),
179 toMeshPatches_.insert
181 toMesh_.boundaryMesh()[patchi].name(),
187 toMesh_.boundaryMesh()[patchi].name(),
188 fromMesh_.boundaryMesh()[patchi].name()
196 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
198 Foam::meshToMesh::~meshToMesh()
200 deleteDemandDrivenData(inverseDistanceWeightsPtr_);
204 // ************************************************************************* //