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 | Copyright (C) 2011-2014 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "fvMesh.H"
27 #include "fvMeshAdder.H"
28 #include "faceCoupleInfo.H"
29 #include "fvMesh.H"
30 
31 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
32 
33 namespace Foam
34 {
35 defineTypeNameAndDebug(fvMeshAdder, 0);
36 }
37 
38 
39 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 
41 //- Calculate map from new patch faces to old patch faces. -1 where
42 // could not map.
44 (
45  const label oldStart,
46  const label oldSize,
47  const labelList& oldToNew,
48  const polyPatch& newPatch,
49  const label unmappedValue
50 )
51 {
52  labelList newToOld(newPatch.size(), unmappedValue);
53 
54  label newStart = newPatch.start();
55  label newSize = newPatch.size();
56 
57  for (label i = 0; i < oldSize; i++)
58  {
59  label newFaceI = oldToNew[oldStart+i];
60 
61  if (newFaceI >= newStart && newFaceI < newStart+newSize)
62  {
63  newToOld[newFaceI-newStart] = i;
64  }
65  }
66  return newToOld;
67 }
68 
69 
70 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
71 
72 // Inplace add mesh1 to mesh0
74 (
75  fvMesh& mesh0,
76  const fvMesh& mesh1,
77  const faceCoupleInfo& coupleInfo,
78  const bool validBoundary
79 )
80 {
81  mesh0.clearOut();
82 
83  // Resulting merged mesh (polyMesh only!)
85  (
87  (
88  mesh0,
89  mesh1,
90  coupleInfo,
91  validBoundary
92  )
93  );
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>(mapPtr, mesh0, mesh1);
108  fvMeshAdder::MapVolFields<vector>(mapPtr, mesh0, mesh1);
109  fvMeshAdder::MapVolFields<sphericalTensor>(mapPtr, mesh0, mesh1);
110  fvMeshAdder::MapVolFields<symmTensor>(mapPtr, mesh0, mesh1);
111  fvMeshAdder::MapVolFields<tensor>(mapPtr, mesh0, mesh1);
112 
113  fvMeshAdder::MapSurfaceFields<scalar>(mapPtr, mesh0, mesh1);
114  fvMeshAdder::MapSurfaceFields<vector>(mapPtr, mesh0, mesh1);
115  fvMeshAdder::MapSurfaceFields<sphericalTensor>(mapPtr, mesh0, mesh1);
116  fvMeshAdder::MapSurfaceFields<symmTensor>(mapPtr, mesh0, mesh1);
117  fvMeshAdder::MapSurfaceFields<tensor>(mapPtr, mesh0, mesh1);
118 
119  fvMeshAdder::MapDimFields<scalar>(mapPtr, mesh0, mesh1);
120  fvMeshAdder::MapDimFields<vector>(mapPtr, mesh0, mesh1);
121  fvMeshAdder::MapDimFields<sphericalTensor>(mapPtr, mesh0, mesh1);
122  fvMeshAdder::MapDimFields<symmTensor>(mapPtr, mesh0, mesh1);
123  fvMeshAdder::MapDimFields<tensor>(mapPtr, mesh0, mesh1);
124 
125  return mapPtr;
126 }
127 
128 
129 // ************************************************************************* //
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::fvMeshAdder::add
static autoPtr< mapAddedPolyMesh > add(fvMesh &mesh0, const fvMesh &mesh1, const faceCoupleInfo &coupleInfo, const bool validBoundary=true)
Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
Definition: fvMeshAdder.C:74
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
fvMeshAdder.H
Foam::fvBoundaryMesh
Foam::fvBoundaryMesh.
Definition: fvBoundaryMesh.H:52
Foam::PtrList::set
bool set(const label) const
Is element set.
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
faceCoupleInfo.H
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:870
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::fvMeshAdder::calcPatchMap
static labelList calcPatchMap(const label oldStart, const label oldSize, const labelList &oldToNew, const polyPatch &newPatch, const label unmappedIndex)
Calculate map from new patch faces to old patch faces. -1 where.
Definition: fvMeshAdder.C:44
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:550
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::PtrList::setSize
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
Definition: PtrList.C:142
Foam::faceCoupleInfo
Container for information needed to couple to meshes. When constructed from two meshes and a geometri...
Definition: faceCoupleInfo.H:157
patches
patches[0]
Definition: createSingleCellMesh.H:36
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::fvMesh::clearOut
void clearOut()
Clear all geometry and addressing.
Definition: fvMesh.C:231