fvMeshTopoChangersRaw.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 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 "fvMeshTopoChangersRaw.H"
27 #include "polyTopoChangeMap.H"
28 #include "volFields.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace fvMeshTopoChangers
36 {
39 }
40 }
41 
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
46 :
47  fvMeshTopoChanger(mesh),
48  topoChanger_(mesh)
49 {}
50 
51 
52 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
53 
55 {}
56 
57 
58 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
59 
61 {
62  // Do mesh changes (use inflation - put new points in topoChangeMap)
63  Info<< "raw : Checking for topology changes..."
64  << endl;
65 
66  // Do any topology changes. Sets topoChanged (through polyTopoChange)
67  autoPtr<polyTopoChangeMap> topoChangeMap = topoChanger_.changeMesh(true);
68 
69  bool hasChanged = topoChangeMap.valid();
70 
71  if (hasChanged)
72  {
73  Info<< "raw : Done topology changes..."
74  << endl;
75 
76  // Temporary: fix fields on patch faces created out of nothing
77  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78 
79  // Two situations:
80  // - internal faces inflated out of nothing
81  // - patch faces created out of previously internal faces
82 
83  // Is face mapped in any way?
84  PackedBoolList mappedFace(mesh().nFaces());
85 
86  const label nOldInternal = topoChangeMap().oldPatchStarts()[0];
87 
88  const labelList& faceMap = topoChangeMap().faceMap();
89  for (label facei = 0; facei < mesh().nInternalFaces(); facei++)
90  {
91  if (faceMap[facei] >= 0)
92  {
93  mappedFace[facei] = 1;
94  }
95  }
96  for
97  (
98  label facei = mesh().nInternalFaces();
99  facei < mesh().nFaces();
100  facei++
101  )
102  {
103  if (faceMap[facei] >= 0 && faceMap[facei] >= nOldInternal)
104  {
105  mappedFace[facei] = 1;
106  }
107  }
108 
109  const List<objectMap>& fromFaces = topoChangeMap().facesFromFacesMap();
110 
111  forAll(fromFaces, i)
112  {
113  mappedFace[fromFaces[i].index()] = 1;
114  }
115 
116  const List<objectMap>& fromEdges = topoChangeMap().facesFromEdgesMap();
117 
118  forAll(fromEdges, i)
119  {
120  mappedFace[fromEdges[i].index()] = 1;
121  }
122 
123  const List<objectMap>& fromPts = topoChangeMap().facesFromPointsMap();
124 
125  forAll(fromPts, i)
126  {
127  mappedFace[fromPts[i].index()] = 1;
128  }
129 
130  // Set unmapped faces to zero
131  Info<< "fvMeshTopoChangers::raw :"
132  << " zeroing unmapped boundary values." << endl;
133  zeroUnmappedValues<scalar, fvPatchField, volMesh>(mappedFace);
134  zeroUnmappedValues<vector, fvPatchField, volMesh>(mappedFace);
135  zeroUnmappedValues<sphericalTensor, fvPatchField, volMesh>(mappedFace);
136  zeroUnmappedValues<symmTensor, fvPatchField, volMesh>(mappedFace);
137  zeroUnmappedValues<tensor, fvPatchField, volMesh>(mappedFace);
138 
139  if (topoChangeMap().hasMotionPoints())
140  {
141  pointField newPoints = topoChangeMap().preMotionPoints();
142 
143  // Give the meshModifiers opportunity to modify points
144  Info<< "fvMeshTopoChangers::raw :"
145  << " calling modifyMotionPoints." << endl;
146  topoChanger_.modifyMotionPoints(newPoints);
147 
148  // Actually move points
149  Info<< "fvMeshTopoChangers::raw :"
150  << " calling movePoints." << endl;
151 
152  mesh().movePoints(newPoints);
153  }
154  }
155  else
156  {
157  // Pout<< "fvMeshTopoChangers::raw :"
158  // << " no topology changes..." << endl;
159  }
160 
161  return hasChanged;
162 }
163 
164 
166 {}
167 
168 
170 {}
171 
172 
174 (
175  const polyDistributionMap& map
176 )
177 {}
178 
179 
180 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Macros for easy insertion into run-time selection tables.
A bit-packed bool list.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Abstract base class for fvMesh topology changers.
Prototype fvMeshTopoChanger without any added functionality.
virtual void topoChange(const polyTopoChangeMap &)
Update corresponding to the given map.
virtual void distribute(const polyDistributionMap &)
Update corresponding to the given distribution map.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual bool update()
Update the mesh for both mesh motion and topology change.
raw(fvMesh &mesh, const dictionary &dict)
Construct from fvMesh and dictionary.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
addToRunTimeSelectionTable(fvMeshTopoChanger, list, fvMesh)
Namespace for OpenFOAM.
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
messageStream Info
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
dictionary dict