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-------------------------------------------------------------------------------
10License
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
29#include "polyMesh.H"
30#include "polyTopoChange.H"
31
32// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
35(
36 const IOobject& io,
38)
39:
41{}
42
43
45(
47)
48:
50{}
51
52
53// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
54
55void 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// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
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
void setSize(const label n)
Alias for resize()
Definition: List.H:218
PtrList< T > clone(Args &&... args) const
Make a copy by cloning each of the list elements.
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
This class is derived from polyMesh and serves as a tool for statically connecting pieces of a mesh b...
void attach(const bool removeEmptyPatches=true)
Attach mesh. By default filter out empty patches.
A class for handling file names.
Definition: fileName.H:76
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
label start() const noexcept
The start label of boundary faces in the polyMesh face list.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
List of mesh modifiers defining the mesh dynamics.
volScalarField & p
dynamicFvMesh & mesh
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333