Skip to content

Commit d3083b0

Browse files
authored
Merge pull request ITHACA-FV#602 from Ruansh233/tutorial_parallelization
Tutorial parallelization
2 parents ac1ac49 + 7c32c77 commit d3083b0

File tree

23 files changed

+211
-14
lines changed

23 files changed

+211
-14
lines changed

applications/POD/perform_POD.C

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,7 @@ int main(int argc, char *argv[])
8484
{
8585
pod_exist = false;
8686
Info << "POD don't exist, performing a POD decomposition" << endl;
87-
mkDir("./ITHACAoutput/POD");
88-
system("ln -s ../../constant ./ITHACAoutput/POD/constant");
89-
system("ln -s ../../0 ./ITHACAoutput/POD/0");
90-
system("ln -s ../../system ./ITHACAoutput/POD/system");
87+
ITHACAutilities::createSymLink("./ITHACAoutput/POD");
9188
}
9289
if(pod_exist == 1)
9390
{

src/ITHACA_FOMPROBLEMS/steadyNS/steadyNS.C

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,10 @@ Eigen::MatrixXd steadyNS::pressure_BC1(label NUmodes, label NPmodes)
13231323

13241324
for (label k = 0; k < lpl.boundaryField().size(); k++)
13251325
{
1326-
s += gSum(lpl.boundaryField()[k]);
1326+
if (lpl.boundaryField()[k].type() != "processor")
1327+
{
1328+
s += gSum(lpl.boundaryField()[k]);
1329+
}
13271330
}
13281331

13291332
BC1_matrix(i, j) = s;
@@ -1366,7 +1369,10 @@ List <Eigen::MatrixXd> steadyNS::pressure_BC2(label NUmodes, label NPmodes)
13661369

13671370
for (label k = 0; k < div_m.boundaryField().size(); k++)
13681371
{
1369-
s += gSum(div_m.boundaryField()[k]);
1372+
if (div_m.boundaryField()[k].type() != "processor")
1373+
{
1374+
s += gSum(div_m.boundaryField()[k]);
1375+
}
13701376
}
13711377

13721378
BC2_matrix[i](j, k) = s;
@@ -1398,7 +1404,10 @@ Eigen::Tensor<double, 3> steadyNS::pressureBC2(label NUmodes, label NPmodes)
13981404

13991405
for (label k = 0; k < div_m.boundaryField().size(); k++)
14001406
{
1401-
s += gSum(div_m.boundaryField()[k]);
1407+
if (div_m.boundaryField()[k].type() != "processor")
1408+
{
1409+
s += gSum(div_m.boundaryField()[k]);
1410+
}
14021411
}
14031412

14041413
bc2Tensor(i, j, k) = s;
@@ -1434,7 +1443,10 @@ Eigen::MatrixXd steadyNS::pressure_BC3(label NUmodes, label NPmodes)
14341443
double s = 0;
14351444
for (label k = 0; k < BC5.boundaryField().size(); k++)
14361445
{
1437-
s += gSum(BC5.boundaryField()[k]);
1446+
if (BC5.boundaryField()[k].type() != "processor")
1447+
{
1448+
s += gSum(BC5.boundaryField()[k]);
1449+
}
14381450
}
14391451

14401452
BC3_matrix(i, j) = s;
@@ -1468,7 +1480,10 @@ Eigen::MatrixXd steadyNS::pressure_BC4(label NUmodes, label NPmodes)
14681480

14691481
for (label k = 0; k < BC5.boundaryField().size(); k++)
14701482
{
1471-
s += gSum(BC5.boundaryField()[k]);
1483+
if (BC5.boundaryField()[k].type() != "processor")
1484+
{
1485+
s += gSum(BC5.boundaryField()[k]);
1486+
}
14721487
}
14731488

14741489
BC4_matrix(i, j) = s;

tutorials/CFD/01POD/Allclean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ cd ${0%/*} || exit 1 # Run from this directory
66
# Source tutorial clean functions
77
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
88

9-
runApplication foamListTimes -rm
9+
cleanTimeDirectories
10+
rm -rf processor* &> /dev/null
1011

1112
rm -r ITHACAoutput
1213
rm log.*
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
cd ${0%/*} || exit 1 # Run from this directory
3+
4+
# Source tutorial run functions
5+
. $WM_PROJECT_DIR/bin/tools/RunFunctions
6+
7+
runApplication decomposePar
8+
runParallel icoFoam
9+
runParallel perform_POD

tutorials/CFD/01POD/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ Eventually, instead of the finalTime you could define the number of snapshots
4343

4444
// a fake class just to print out the doxygen documentation
4545
class fake
46+
47+
## Parallel running
48+
49+
Please modify the setup in __decomposeParDict__ to the number of processors you need.
50+
51+
The case can run in parallel with the script `Allrun_parallel`.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
========= |
3+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4+
\\ / O peration | Website: https://openfoam.org
5+
\\ / A nd | Version: 6
6+
\\/ M anipulation |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
version 2.0;
11+
format ascii;
12+
class dictionary;
13+
location "system";
14+
object decomposeParDict;
15+
}
16+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
17+
18+
numberOfSubdomains 4;
19+
20+
method scotch;
21+
22+
23+
// ************************************************************************* //

tutorials/CFD/02thermalBlock/02thermalBlock.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class tutorial02: public laplacianProblem
7979
{
8080
for (label j = 0; j < mu.cols() ; j++)
8181
{
82-
// mu_now[i] =
82+
mu_now[j] = mu(i, j);
8383
theta[j] = mu(i, j);
8484
}
8585

tutorials/CFD/02thermalBlock/Allclean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cd ${0%/*} || exit 1 # Run from this directory
66
# Source tutorial clean functions
77
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
88

9+
rm -rf processor* &> /dev/null
910
rm -r ITHACAoutput
10-
rm -r *.foam
11+
rm -rf *.foam &> /dev/null
1112
rm log.*
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
cd ${0%/*} || exit 1 # Run from this directory
3+
4+
# Source tutorial run functions
5+
. $WM_PROJECT_DIR/bin/tools/RunFunctions
6+
7+
runApplication decomposePar
8+
runParallel 02thermalBlock -stage online

tutorials/CFD/02thermalBlock/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,5 @@ reduced matrices on the whole domain
282282
The online stage is performed analogously
283283

284284
mpirun -np 4 02thermalBlock -stage online -parallel
285+
286+
Or the users can simple run the script `Allrun_parallel`.

0 commit comments

Comments
 (0)