The open source CFD toolbox
ensightWriteUpdate.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) 2018-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
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 "ensightWrite.H"
29#include "dictionary.H"
30#include "cellBitSet.H"
31
32// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33
35(
36 fvMeshSubset& subsetter
37) const
38{
39 if (selection_.empty())
40 {
41 return false;
42 }
43
44 bitSet selectedCells
45 (
46 cellBitSet::select(subsetter.baseMesh(), selection_)
47 );
48
49 subsetter.reset(selectedCells);
50
51 return true;
52}
53
54
55bool Foam::functionObjects::ensightWrite::update()
56{
57 if (meshState_ == polyMesh::UNCHANGED)
58 {
59 return false;
60 }
61
62 // Even if selection doesn't nominally change, a new subMesh is built.
63 // Must update the reference for ensightMesh
64 if (meshSubset_.hasSubMesh())
65 {
66 ensMesh_.clear();
67 meshSubset_.clear();
68 }
69 // Probably not needed...
74
76
77 if (!ensMesh_)
78 {
79 ensMesh_.reset(new ensightMesh(meshSubset_.mesh(), writeOpts_));
80 }
81 else if (ensMesh_->needsUpdate())
82 {
83 ensMesh_->correct();
84 }
85
86 meshState_ = polyMesh::UNCHANGED;
87 return true;
88}
89
90
91// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92
94{
95 // Ensure consistency
96 ensMesh_.clear();
97
98 meshSubset_.clear();
99 meshState_ = polyMesh::TOPO_CHANGE;
100
101 selectFields_.clear();
103 selectFields_.uniq();
104
105 // Actions to define selection
106 selection_ = dict.subOrEmptyDict("selection");
107
108 return true;
109}
110
111
113{
114 meshState_ = polyMesh::TOPO_CHANGE;
115}
116
117
119{
120 // Only move to worse states
121 if (meshState_ == polyMesh::UNCHANGED)
122 {
123 meshState_ = polyMesh::POINTS_MOVED;
124 }
125}
126
127
128// ************************************************************************* //
static bitSet select(const polyMesh &mesh, const dictionary &dict, const bool verbosity=false)
Definition: cellBitSet.C:97
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
void movePoints()
Update for new mesh geometry.
void updateMesh()
Update for new mesh topology.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
dictionary dict