/
myDecompose.C
55 lines (47 loc) · 903 Bytes
/
myDecompose.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "fvCFD.H"
int main(int argc, char *argv[])
{
// Read
Foam::argList args(argc,argv);
if(not args.checkRootCase()) Foam::FatalError.exit();
Foam::Time runTime(Foam::Time::controlDictName, args);
Foam::fvMesh mesh
(
Foam::IOobject
(
Foam::fvMesh::defaultRegion,
runTime.timeName(),
runTime,
Foam::IOobject::MUST_READ
)
);
// Write
labelList procIds(mesh.cells().size());
forAll(mesh.cells(), cid){
const vector &C = mesh.C()[cid];
if(C[0]*C[0]+C[1]*C[1] < 0.01){
procIds[cid] = 1;
}
else{
procIds[cid] = 0;
}
if(C[0] + C[1] < 0.1){
++procIds[cid];
}
}
labelIOList cellDecomposition
(
IOobject
(
"cellDecomposition",
mesh.facesInstance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
procIds
);
cellDecomposition.write();
return 0;
}