Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / dynamicMesh / topoChangerFvMesh / attachDetachFvMesh / attachDetachFvMesh.C
blob56a30c739cf165b2032fcbc61509df9701589e71
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "attachDetachFvMesh.H"
27 #include "foamTime.H"
28 #include "attachDetach.H"
29 #include "mapPolyMesh.H"
30 #include "polyTopoChange.H"
31 #include "volMesh.H"
32 #include "addToRunTimeSelectionTable.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 namespace Foam
38     defineTypeNameAndDebug(attachDetachFvMesh, 0);
40     addToRunTimeSelectionTable
41     (
42         topoChangerFvMesh,
43         attachDetachFvMesh,
44         IOobject
45     );
49 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
51 void Foam::attachDetachFvMesh::addZonesAndModifiers()
53     Info<< "Time = " << time().timeName() << endl
54         << "Adding zones and modifiers to the mesh" << endl;
56     // Add a topology modifier
57     Info << "Adding topology modifiers" << endl;
59     PtrList<entry> entries(motionDict_.lookup("modifiers"));
61     topoChanger_.setSize(entries.size());
63     forAll (entries, i)
64     {
65         topoChanger_.set
66         (
67             i,
68             new attachDetach
69             (
70                 entries[i].keyword(),
71                 i,
72                 topoChanger_,
73                 word(entries[i].dict().lookup("faceZone")),
74                 word(entries[i].dict().lookup("topPatch")),
75                 word(entries[i].dict().lookup("bottomPatch")),
76                 scalarField(entries[i].dict().lookup("triggerTimes"))
77             )
78         );
79     }
81     // Write mesh and modifiers
82     topoChanger_.writeOpt() = IOobject::AUTO_WRITE;
83     topoChanger_.write();
84     write();
88 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
90 // Construct from components
91 Foam::attachDetachFvMesh::attachDetachFvMesh(const IOobject& io)
93     topoChangerFvMesh(io),
94     motionDict_
95     (
96         IOdictionary
97         (
98             IOobject
99             (
100                 "dynamicMeshDict",
101                 time().constant(),
102                 *this,
103                 IOobject::MUST_READ,
104                 IOobject::NO_WRITE
105             )
106         ).subDict(typeName + "Coeffs")
107     )
109     addZonesAndModifiers();
113 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
115 Foam::attachDetachFvMesh::~attachDetachFvMesh()
119 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
121 bool Foam::attachDetachFvMesh::update()
123     autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh();
125     return topoChangeMap->morphing();
129 // ************************************************************************* //