Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / tutorials / immersedBoundary / thickPlateRefinedMesh / refineThickPlateMesh / refineThickPlateMesh.C
blob4ffc36fcfa977f906b3ba521c17cc59b741e3bd7
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 Application
25     refineImmersedBoundaryMesh
27 Description
28     Refine immersed boundary mesh for a thick plate simulation
30 \*---------------------------------------------------------------------------*/
32 #include "fvCFD.H"
33 #include "refineImmersedBoundaryMesh.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 int main(int argc, char *argv[])
39 #   include "setRootCase.H"
41 #   include "createTime.H"
42 #   include "createMesh.H"
44     // 1
45     {
46         labelHashSet refCellSet;
48         const vectorField& C = mesh.cellCentres();
50         scalar L = 5;
51         forAll(C, cellI)
52         {
53             if (mag(C[cellI].x()) <= L)
54             {
55                 if (mag(C[cellI].y()) <= L)
56                 {
57                     refCellSet.insert(cellI);
58                 }
59             }
60         }
62         labelList refCells(refCellSet.toc());
64         refineImmersedBoundaryMesh rib(mesh);
65         rib.refineMesh(refCells);
66     }
68     // 2
69     {
70         labelHashSet refCellSet;
72         const vectorField& C = mesh.cellCentres();
74         scalar L = 4;
75         forAll(C, cellI)
76         {
77             if (mag(C[cellI].x()) <= L)
78             {
79                 if (mag(C[cellI].y()) <= L)
80                 {
81                     refCellSet.insert(cellI);
82                 }
83             }
84         }
86         labelList refCells(refCellSet.toc());
88         refineImmersedBoundaryMesh rib(mesh);
89         rib.refineMesh(refCells);
90     }
92     // 3
93     {
94         labelHashSet refCellSet;
96         const vectorField& C = mesh.cellCentres();
98         scalar L = 3;
99         forAll(C, cellI)
100         {
101             if (mag(C[cellI].x()) <= L)
102             {
103                 if (mag(C[cellI].y()) <= L)
104                 {
105                     refCellSet.insert(cellI);
106                 }
107             }
108         }
110         labelList refCells(refCellSet.toc());
112         refineImmersedBoundaryMesh rib(mesh);
113         rib.refineMesh(refCells);
114     }
116     // 4
117     {
118         labelHashSet refCellSet;
120         const vectorField& C = mesh.cellCentres();
122         scalar L = 2;
123         forAll(C, cellI)
124         {
125             if (mag(C[cellI].x()) <= L)
126             {
127                 if (mag(C[cellI].y()) <= L)
128                 {
129                     refCellSet.insert(cellI);
130                 }
131             }
132         }
134         labelList refCells(refCellSet.toc());
136         refineImmersedBoundaryMesh rib(mesh);
137         rib.refineMesh(refCells);
138     }
140     // 5
141     {
142         labelHashSet refCellSet;
144         const vectorField& C = mesh.cellCentres();
146         scalar L = 1;
147         forAll(C, cellI)
148         {
149             if (mag(C[cellI].x()) <= L)
150             {
151                 if (mag(C[cellI].y()) <= L)
152                 {
153                     refCellSet.insert(cellI);
154                 }
155             }
156         }
158         labelList refCells(refCellSet.toc());
160         refineImmersedBoundaryMesh rib(mesh);
161         rib.refineMesh(refCells);
162     }
165 //     runTime++;
167     mesh.write();
169     Info<< "End\n" << endl;
171     return(0);
175 // ************************************************************************* //