OpenFOAM: API Guide
v2112
The open source CFD toolbox
attachPolyTopoChanger.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 "
attachPolyTopoChanger.H
"
29
#include "
polyMesh.H
"
30
#include "
polyTopoChange.H
"
31
32
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
34
Foam::attachPolyTopoChanger::attachPolyTopoChanger
35
(
36
const
IOobject
&
io
,
37
polyMesh
&
mesh
38
)
39
:
40
polyTopoChanger
(
io
,
mesh
)
41
{}
42
43
44
Foam::attachPolyTopoChanger::attachPolyTopoChanger
45
(
46
polyMesh
&
mesh
47
)
48
:
49
polyTopoChanger
(
mesh
)
50
{}
51
52
53
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
54
55
void
Foam::attachPolyTopoChanger::attach
(
const
bool
removeEmptyPatches)
56
{
57
if
(debug)
58
{
59
Pout
<<
"void attachPolyTopoChanger::attach(): "
60
<<
"Attaching mesh"
<<
endl
;
61
}
62
63
// Save current file instance
64
const
fileName
oldInst = mesh_.facesInstance();
65
66
// Execute all polyMeshModifiers
67
changeMesh(
false
);
// no inflation
68
69
const
pointField
p
= mesh_.oldPoints();
70
71
mesh_.movePoints(
p
);
72
73
if
(debug)
74
{
75
Pout
<<
"Clearing mesh."
<<
endl
;
76
}
77
78
if
(removeEmptyPatches)
79
{
80
// Re-do the boundary patches, removing the ones with zero size
81
const
polyBoundaryMesh
& oldPatches = mesh_.boundaryMesh();
82
83
List<polyPatch*>
newPatches(oldPatches.
size
());
84
label nNewPatches = 0;
85
86
forAll
(oldPatches, patchi)
87
{
88
if
(oldPatches[patchi].size())
89
{
90
newPatches[nNewPatches] = oldPatches[patchi].
clone
91
(
92
mesh_.boundaryMesh(),
93
nNewPatches,
94
oldPatches[patchi].
size
(),
95
oldPatches[patchi].
start
()
96
).ptr();
97
98
nNewPatches++;
99
}
100
else
101
{
102
if
(debug)
103
{
104
Pout
<<
"Removing zero-sized patch "
<< patchi
105
<<
" named "
<< oldPatches[patchi].
name
() <<
endl
;
106
}
107
}
108
}
109
110
newPatches.
setSize
(nNewPatches);
111
112
mesh_.removeBoundary();
113
mesh_.addPatches(newPatches);
114
}
115
116
// Reset the file instance to overwrite the original mesh
117
mesh_.setInstance(oldInst);
118
119
if
(debug)
120
{
121
Pout
<<
"void attachPolyTopoChanger::attach(): "
122
<<
"Finished attaching mesh"
<<
endl
;
123
}
124
125
mesh_.checkMesh();
126
}
127
128
129
// ************************************************************************* //
attachPolyTopoChanger.H
Foam::Field< vector >
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition:
IOobject.H:170
Foam::IOobject::name
const word & name() const noexcept
Return the object name.
Definition:
IOobjectI.H:65
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition:
List.H:77
Foam::List::setSize
void setSize(const label n)
Alias for resize()
Definition:
List.H:218
Foam::PtrList::clone
PtrList< T > clone(Args &&... args) const
Make a copy by cloning each of the list elements.
Foam::UPtrList::size
label size() const noexcept
The number of elements in the list.
Definition:
UPtrListI.H:106
Foam::attachPolyTopoChanger
This class is derived from polyMesh and serves as a tool for statically connecting pieces of a mesh b...
Definition:
attachPolyTopoChanger.H:65
Foam::attachPolyTopoChanger::attach
void attach(const bool removeEmptyPatches=true)
Attach mesh. By default filter out empty patches.
Definition:
attachPolyTopoChanger.C:55
Foam::fileName
A class for handling file names.
Definition:
fileName.H:76
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition:
polyBoundaryMesh.H:66
Foam::polyBoundaryMesh::start
label start() const noexcept
The start label of boundary faces in the polyMesh face list.
Definition:
polyBoundaryMesh.C:589
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition:
polyMesh.H:81
Foam::polyTopoChanger
List of mesh modifiers defining the mesh dynamics.
Definition:
polyTopoChanger.H:66
p
volScalarField & p
Definition:
createFieldRefs.H:8
mesh
dynamicFvMesh & mesh
Definition:
createDynamicFvMesh.H:6
io
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition:
Ostream.H:372
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
polyMesh.H
polyTopoChange.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition:
stdFoam.H:333
src
dynamicMesh
polyTopoChange
attachPolyTopoChanger
attachPolyTopoChanger.C
Generated by
1.9.5
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.