fvMeshAdder.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "fvMesh.H"
29 #include "fvMeshAdder.H"
30 #include "faceCoupleInfo.H"
31 
32 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
33 
34 namespace Foam
35 {
36 defineTypeNameAndDebug(fvMeshAdder, 0);
37 }
38 
39 
40 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
41 
42 Foam::labelList Foam::fvMeshAdder::calcPatchMap
43 (
44  const label oldStart,
45  const label oldSize,
46  const labelList& oldToNew,
47  const polyPatch& newPatch,
48  const label unmappedValue
49 )
50 {
51  labelList newToOld(newPatch.size(), unmappedValue);
52 
53  label newStart = newPatch.start();
54  label newSize = newPatch.size();
55 
56  for (label i = 0; i < oldSize; i++)
57  {
58  label newFacei = oldToNew[oldStart+i];
59 
60  if (newFacei >= newStart && newFacei < newStart+newSize)
61  {
62  newToOld[newFacei-newStart] = i;
63  }
64  }
65  return newToOld;
66 }
67 
68 
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
70 
72 (
73  fvMesh& mesh0,
74  const fvMesh& mesh1,
75  const faceCoupleInfo& coupleInfo,
76  const bool validBoundary,
77  const bool fullyMapped
78 )
79 {
80  mesh0.clearOut();
81 
82  // Resulting merged mesh (polyMesh only!)
84  (
86  (
87  mesh0,
88  mesh1,
89  coupleInfo,
90  validBoundary
91  )
92  );
93  mapAddedPolyMesh& map = *mapPtr;
94 
95  // Adjust the fvMesh part.
96  const polyBoundaryMesh& patches = mesh0.boundaryMesh();
97 
98  fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh0.boundary());
99  fvPatches.setSize(patches.size());
100  forAll(patches, patchi)
101  {
102  fvPatches.set(patchi, fvPatch::New(patches[patchi], fvPatches));
103  }
104 
105  // Do the mapping of the stored fields
106  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
107  fvMeshAdder::MapVolFields<scalar>(map, mesh0, mesh1, fullyMapped);
108  fvMeshAdder::MapVolFields<vector>(map, mesh0, mesh1, fullyMapped);
109  fvMeshAdder::MapVolFields<sphericalTensor>(map, mesh0, mesh1, fullyMapped);
110  fvMeshAdder::MapVolFields<symmTensor>(map, mesh0, mesh1, fullyMapped);
111  fvMeshAdder::MapVolFields<tensor>(map, mesh0, mesh1, fullyMapped);
112 
113  fvMeshAdder::MapSurfaceFields<scalar>(map, mesh0, mesh1, fullyMapped);
114  fvMeshAdder::MapSurfaceFields<vector>(map, mesh0, mesh1, fullyMapped);
115  fvMeshAdder::MapSurfaceFields<sphericalTensor>
116  (
117  map, mesh0, mesh1, fullyMapped
118  );
119  fvMeshAdder::MapSurfaceFields<symmTensor>(map, mesh0, mesh1, fullyMapped);
120  fvMeshAdder::MapSurfaceFields<tensor>(map, mesh0, mesh1, fullyMapped);
121 
122  fvMeshAdder::MapDimFields<scalar>(map, mesh0, mesh1);
123  fvMeshAdder::MapDimFields<vector>(map, mesh0, mesh1);
124  fvMeshAdder::MapDimFields<sphericalTensor>(map, mesh0, mesh1);
125  fvMeshAdder::MapDimFields<symmTensor>(map, mesh0, mesh1);
126  fvMeshAdder::MapDimFields<tensor>(map, mesh0, mesh1);
127 
128  return mapPtr;
129 }
130 
131 
132 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:62
Foam::fvPatch::New
static autoPtr< fvPatch > New(const polyPatch &, const fvBoundaryMesh &)
Return a pointer to a new patch created on freestore from polyPatch.
Definition: fvPatchNew.C:35
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:444
Foam::PtrList::set
const T * set(const label i) const
Return const pointer to element (can be nullptr),.
Definition: PtrList.H:138
fvMeshAdder.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::fvMeshAdder::add
static autoPtr< mapAddedPolyMesh > add(fvMesh &mesh0, const fvMesh &mesh1, const faceCoupleInfo &coupleInfo, const bool validBoundary=true, const bool fullyMapped=false)
Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
Definition: fvMeshAdder.C:72
Foam::fvBoundaryMesh
Foam::fvBoundaryMesh.
Definition: fvBoundaryMesh.H:56
Foam::PtrList::setSize
void setSize(const label newLen)
Same as resize()
Definition: PtrListI.H:105
faceCoupleInfo.H
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:679
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::polyMeshAdder::add
static autoPtr< polyMesh > add(const IOobject &io, const polyMesh &mesh0, const polyMesh &mesh1, const faceCoupleInfo &coupleInfo, autoPtr< mapAddedPolyMesh > &mapPtr)
Add two polyMeshes. Returns new polyMesh and map construct.
Definition: polyMeshAdder.C:1465
Foam::faceCoupleInfo
Container for information needed to couple to meshes. When constructed from two meshes and a geometri...
Definition: faceCoupleInfo.H:160
Foam::mapAddedPolyMesh
Class containing mesh-to-mesh mapping information after a mesh addition where we add a mesh ('added m...
Definition: mapAddedPolyMesh.H:58
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::fvMesh::clearOut
void clearOut()
Clear all geometry and addressing.
Definition: fvMesh.C:227