Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
805f6f76
Commit
805f6f76
authored
Dec 30, 2010
by
mattijs
Browse files
ENH: windTurbineTerrain: mesh and run in parallel
parent
7fa1e73a
Changes
3
Hide whitespace changes
Inline
Side-by-side
applications/utilities/parallelProcessing/redistributeMeshPar/redistributeMeshPar.C
View file @
805f6f76
...
...
@@ -53,6 +53,7 @@ Description
#include "fvMeshDistribute.H"
#include "mapDistributePolyMesh.H"
#include "IOobjectList.H"
#include "globalIndex.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -107,7 +108,9 @@ autoPtr<fvMesh> createMesh
fvMesh
&
mesh
=
meshPtr
();
// Determine patches.
// Sync patches
// ~~~~~~~~~~~~
if
(
Pstream
::
master
())
{
// Send patches
...
...
@@ -118,14 +121,14 @@ autoPtr<fvMesh> createMesh
slave
++
)
{
OPstream
toSlave
(
Pstream
::
blocking
,
slave
);
OPstream
toSlave
(
Pstream
::
scheduled
,
slave
);
toSlave
<<
mesh
.
boundaryMesh
();
}
}
else
{
// Receive patches
IPstream
fromMaster
(
Pstream
::
blocking
,
Pstream
::
masterNo
());
IPstream
fromMaster
(
Pstream
::
scheduled
,
Pstream
::
masterNo
());
PtrList
<
entry
>
patchEntries
(
fromMaster
);
if
(
haveMesh
)
...
...
@@ -224,6 +227,58 @@ autoPtr<fvMesh> createMesh
}
}
// Determine zones
// ~~~~~~~~~~~~~~~
wordList
pointZoneNames
(
mesh
.
pointZones
().
names
());
Pstream
::
scatter
(
pointZoneNames
);
wordList
faceZoneNames
(
mesh
.
faceZones
().
names
());
Pstream
::
scatter
(
faceZoneNames
);
wordList
cellZoneNames
(
mesh
.
cellZones
().
names
());
Pstream
::
scatter
(
cellZoneNames
);
if
(
!
haveMesh
)
{
// Add the zones
List
<
pointZone
*>
pz
(
pointZoneNames
.
size
());
forAll
(
pointZoneNames
,
i
)
{
pz
[
i
]
=
new
pointZone
(
pointZoneNames
[
i
],
labelList
(
0
),
i
,
mesh
.
pointZones
()
);
}
List
<
faceZone
*>
fz
(
faceZoneNames
.
size
());
forAll
(
faceZoneNames
,
i
)
{
fz
[
i
]
=
new
faceZone
(
faceZoneNames
[
i
],
labelList
(
0
),
boolList
(
0
),
i
,
mesh
.
faceZones
()
);
}
List
<
cellZone
*>
cz
(
cellZoneNames
.
size
());
forAll
(
cellZoneNames
,
i
)
{
cz
[
i
]
=
new
cellZone
(
cellZoneNames
[
i
],
labelList
(
0
),
i
,
mesh
.
cellZones
()
);
}
mesh
.
addZones
(
pz
,
fz
,
cz
);
}
if
(
!
haveMesh
)
{
// We created a dummy mesh file above. Delete it.
...
...
@@ -236,6 +291,21 @@ autoPtr<fvMesh> createMesh
mesh
.
clearOut
();
mesh
.
globalData
();
// Do some checks.
// Check if the boundary definition is unique
mesh
.
boundaryMesh
().
checkDefinition
(
true
);
// Check if the boundary processor patches are correct
mesh
.
boundaryMesh
().
checkParallelSync
(
true
);
// Check names of zones are equal
mesh
.
cellZones
().
checkDefinition
(
true
);
mesh
.
cellZones
().
checkParallelSync
(
true
);
mesh
.
faceZones
().
checkDefinition
(
true
);
mesh
.
faceZones
().
checkParallelSync
(
true
);
mesh
.
pointZones
().
checkDefinition
(
true
);
mesh
.
pointZones
().
checkParallelSync
(
true
);
return
meshPtr
;
}
...
...
@@ -292,6 +362,59 @@ void printMeshData(Ostream& os, const polyMesh& mesh)
<<
" face zones: "
<<
mesh
.
faceZones
().
size
()
<<
nl
<<
" cell zones: "
<<
mesh
.
cellZones
().
size
()
<<
nl
;
}
void
printMeshData
(
const
polyMesh
&
mesh
)
{
// Collect all data on master
globalIndex
globalCells
(
mesh
.
nCells
());
labelListList
patchNeiProcNo
(
Pstream
::
nProcs
());
labelListList
patchSize
(
Pstream
::
nProcs
());
const
labelList
&
pPatches
=
mesh
.
globalData
().
processorPatches
();
patchNeiProcNo
[
Pstream
::
myProcNo
()].
setSize
(
pPatches
.
size
());
patchSize
[
Pstream
::
myProcNo
()].
setSize
(
pPatches
.
size
());
forAll
(
pPatches
,
i
)
{
const
processorPolyPatch
&
ppp
=
refCast
<
const
processorPolyPatch
>
(
mesh
.
boundaryMesh
()[
pPatches
[
i
]]
);
patchNeiProcNo
[
Pstream
::
myProcNo
()][
i
]
=
ppp
.
neighbProcNo
();
patchSize
[
Pstream
::
myProcNo
()][
i
]
=
ppp
.
size
();
}
Pstream
::
gatherList
(
patchNeiProcNo
);
Pstream
::
gatherList
(
patchSize
);
// Print stats
globalIndex
globalBoundaryFaces
(
mesh
.
nFaces
()
-
mesh
.
nInternalFaces
());
for
(
label
procI
=
0
;
procI
<
Pstream
::
nProcs
();
procI
++
)
{
Info
<<
endl
<<
"Processor "
<<
procI
<<
nl
<<
" Number of cells = "
<<
globalCells
.
localSize
(
procI
)
<<
endl
;
label
nProcFaces
=
0
;
const
labelList
&
nei
=
patchNeiProcNo
[
procI
];
forAll
(
patchNeiProcNo
[
procI
],
i
)
{
Info
<<
" Number of faces shared with processor "
<<
patchNeiProcNo
[
procI
][
i
]
<<
" = "
<<
patchSize
[
procI
][
i
]
<<
endl
;
nProcFaces
+=
patchSize
[
procI
][
i
];
}
Info
<<
" Number of processor patches = "
<<
nei
.
size
()
<<
nl
<<
" Number of processor faces = "
<<
nProcFaces
<<
nl
<<
" Number of boundary faces = "
<<
globalBoundaryFaces
.
localSize
(
procI
)
<<
endl
;
}
}
// Debugging: write volScalarField with decomposition for post processing.
...
...
@@ -507,6 +630,7 @@ void compareFields
int
main
(
int
argc
,
char
*
argv
[])
{
# include "addRegionOption.H"
# include "addOverwriteOption.H"
argList
::
addOption
(
"mergeTol"
,
...
...
@@ -539,6 +663,8 @@ int main(int argc, char *argv[])
}
Info
<<
"Using mesh subdirectory "
<<
meshSubDir
<<
nl
<<
endl
;
const
bool
overwrite
=
args
.
optionFound
(
"overwrite"
);
// Get time instance directory. Since not all processors have meshes
// just use the master one everywhere.
...
...
@@ -573,9 +699,11 @@ int main(int argc, char *argv[])
);
fvMesh
&
mesh
=
meshPtr
();
Pout
<<
"Read mesh:"
<<
endl
;
printMeshData
(
Pout
,
mesh
);
Pout
<<
endl
;
//Pout<< "Read mesh:" << endl;
//printMeshData(Pout, mesh);
//Pout<< endl;
IOdictionary
decompositionDict
(
...
...
@@ -618,7 +746,10 @@ int main(int argc, char *argv[])
}
// Dump decomposition to volScalarField
writeDecomposition
(
"decomposition"
,
mesh
,
finalDecomp
);
if
(
!
overwrite
)
{
writeDecomposition
(
"decomposition"
,
mesh
,
finalDecomp
);
}
// Create 0 sized mesh to do all the generation of zero sized
...
...
@@ -796,12 +927,20 @@ int main(int argc, char *argv[])
// Print a bit
Pout
<<
"After distribution mesh:"
<<
endl
;
printMeshData
(
Pout
,
mesh
);
Pout
<<
endl
;
// Print some statistics
Info
<<
"After distribution:"
<<
endl
;
printMeshData
(
mesh
);
runTime
++
;
Pout
<<
"Writing redistributed mesh to "
<<
runTime
.
timeName
()
<<
nl
<<
endl
;
if
(
!
overwrite
)
{
runTime
++
;
}
else
{
mesh
.
setInstance
(
masterInstDir
);
}
Info
<<
"Writing redistributed mesh to "
<<
runTime
.
timeName
()
<<
nl
<<
endl
;
mesh
.
write
();
...
...
tutorials/incompressible/simpleFoam/windTurbineTerrain/Allrun
View file @
805f6f76
...
...
@@ -18,13 +18,22 @@ runApplication decomposePar
cp
system/decomposeParDict-par system/decomposeParDict
runParallel snappyHexMesh 2
-overwrite
# Add wildcard entries for meshe
s
patches since not preserved
# Add wildcard entries for meshe
d
patches since not preserved
# by decomposePar. Notice -literalRE option to add wildcard itself
# without evaluation.
runParallel changeDictionary 2
-literalRE
runParallel setSet 2
-batch
makeZones
runParallel windSimpleFoam 2
cp
system/decomposeParDict-4proc system/decomposeParDict
runParallel redistributeMeshPar 4
-overwrite
runParallel renumberMesh 4
-overwrite
# Add wildcard entries for meshes patches since not preserved
# by decomposePar. Notice -literalRE option to add wildcard itself
# without evaluation.
#runParallel changeDictionary 4 -literalRE
runParallel setSet 4
-batch
makeZones
runParallel windSimpleFoam 4
runApplication reconstructParMesh
-constant
runApplication reconstructPar
...
...
tutorials/incompressible/simpleFoam/windTurbineTerrain/system/decomposeParDict-4proc
0 → 100644
View file @
805f6f76
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 4;
method ptscotch;
// ************************************************************************* //
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment