Loading...
Searching...
No Matches
rawTopoChangerFvMesh.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 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
30#include "mapPolyMesh.H"
32#include "volFields.H"
33#include "linear.H"
34
35// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36
37namespace Foam
38{
41 (
45 );
47 (
50 doInit
51 );
52}
53
54
55// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56
57// Construct from components
58Foam::rawTopoChangerFvMesh::rawTopoChangerFvMesh
59(
60 const IOobject& io,
61 const bool doInit
62)
64 topoChangerFvMesh(io, doInit)
65{}
66
67
68// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69
71{
72 // Do mesh changes (use inflation - put new points in topoChangeMap)
73 Info<< "rawTopoChangerFvMesh : Checking for topology changes..."
74 << endl;
75
76 // Mesh not moved/changed yet
77 moving(false);
78 topoChanging(false);
79
80 // Do any topology changes. Sets topoChanging (through polyTopoChange)
81 autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh(true);
82
83 const bool hasChanged = bool(topoChangeMap);
84
85 if (hasChanged)
86 {
87 Info<< "rawTopoChangerFvMesh : Done topology changes..."
88 << endl;
89
90 // Temporary: fix fields on patch faces created out of nothing
91 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92
93 // Two situations:
94 // - internal faces inflated out of nothing
95 // - patch faces created out of previously internal faces
96
97 // Is face mapped in any way?
98 bitSet mappedFace(nFaces());
99
100 const label nOldInternal = topoChangeMap().oldPatchStarts()[0];
101
102 const labelList& faceMap = topoChangeMap().faceMap();
103 for (label facei = 0; facei < nInternalFaces(); facei++)
104 {
105 if (faceMap[facei] >= 0)
106 {
107 mappedFace.set(facei);
108 }
109 }
110 for (label facei = nInternalFaces(); facei < nFaces(); facei++)
111 {
112 if (faceMap[facei] >= 0 && faceMap[facei] >= nOldInternal)
113 {
114 mappedFace.set(facei);
115 }
116 }
117
118 for (const auto& map : topoChangeMap().facesFromFacesMap())
119 {
120 mappedFace.set(map.index());
121 }
122
123 for (const auto& map : topoChangeMap().facesFromEdgesMap())
124 {
125 mappedFace.set(map.index());
126 }
127
128 for (const auto& map : topoChangeMap().facesFromPointsMap())
129 {
130 mappedFace.set(map.index());
131 }
132
133 // Set unmapped faces to zero
134 Info<< "rawTopoChangerFvMesh : zeroing unmapped boundary values." << nl;
135
136 zeroUnmappedValues<scalar, fvPatchField, volMesh>(mappedFace);
137 zeroUnmappedValues<vector, fvPatchField, volMesh>(mappedFace);
138 zeroUnmappedValues<sphericalTensor, fvPatchField, volMesh>(mappedFace);
139 zeroUnmappedValues<symmTensor, fvPatchField, volMesh>(mappedFace);
140 zeroUnmappedValues<tensor, fvPatchField, volMesh>(mappedFace);
141
142 // Special handling for phi: set unmapped faces to recreated phi
143 Info<< "rawTopoChangerFvMesh :"
144 << " recreating phi for unmapped boundary values." << endl;
145
146 const auto& U = lookupObject<volVectorField>("U");
148
149 setUnmappedValues
150 (
151 phi,
152 mappedFace,
153 (linearInterpolate(U) & Sf())()
154 );
155
156
157 if (topoChangeMap().hasMotionPoints())
158 {
159 pointField newPoints = topoChangeMap().preMotionPoints();
160
161 // Give the meshModifiers opportunity to modify points
162 Info<< "rawTopoChangerFvMesh :"
163 << " calling modifyMotionPoints." << endl;
164 topoChanger_.modifyMotionPoints(newPoints);
165
166 // Actually move points
167 Info<< "rawTopoChangerFvMesh :"
168 << " calling movePoints." << endl;
169
170 movePoints(newPoints);
171 }
172 }
173 else
174 {
175 //Pout<< "rawTopoChangerFvMesh :"
176 // << " no topology changes..." << endl;
177 }
178
179 return hasChanged;
180}
181
182
183// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition bitSetI.H:502
virtual bool movePoints()
Avoid masking surfaceInterpolation method.
const surfaceScalarField & phi() const
Return cell face motion fluxes.
const surfaceVectorField & Sf() const
Return cell face area vectors.
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Definition fvMesh.C:884
Type & lookupObjectRef(const word &name, const bool recursive=false) const
Lookup and return non-const reference to the object of the given Type. Fatal if not found or the wron...
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
bool moving() const noexcept
Is mesh moving.
Definition polyMesh.H:732
bool topoChanging() const noexcept
Is mesh topology changing.
Definition polyMesh.H:750
autoPtr< mapPolyMesh > changeMesh(const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
label nInternalFaces() const noexcept
Number of internal faces.
label nFaces() const noexcept
Number of mesh faces.
topoChangerFvMesh without any added functionality.
virtual bool update()
Update the mesh for both mesh motion and topology change.
Abstract base class for a topology changing fvMesh.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
U
Definition pEqn.H:72
const auto & io
Namespace for OpenFOAM.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< label > labelList
A List of labels.
Definition List.H:62
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > linearInterpolate(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition linear.H:120
vectorField pointField
pointField is a vectorField.
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50