WEBVTT

00:00.440 --> 00:01.340
Hello everyone.

00:01.340 --> 00:05.000
Welcome back to the CFD using Openfoam beginner to intermediate course.

00:06.110 --> 00:07.610
This is our class six.

00:07.610 --> 00:13.520
In this class we will be seeing introduction to Transient solvers decomposing methods which will be

00:13.520 --> 00:15.920
useful in running cases in parallel.

00:16.520 --> 00:22.280
If you are interested in running parallel processing, then we will also see how to run parallel processing

00:22.280 --> 00:23.570
for snappy hex mesh.

00:23.570 --> 00:27.800
So the entire meshing process through snappy hex mesh can be done in parallel.

00:27.800 --> 00:29.960
So we will see how to do that.

00:30.680 --> 00:31.040
Okay.

00:31.040 --> 00:33.170
Now introduction to transient solvers.

00:33.200 --> 00:37.550
So transient solvers it uses time dependent simulation.

00:37.550 --> 00:43.520
So we will be getting a sort of animation where every time step is converged solution.

00:43.520 --> 00:48.350
So we will get a feel of the flow progressing over time.

00:49.580 --> 00:56.360
The key features are the model here is unsteady or transient flows such as vortex shedding behind a

00:56.360 --> 00:56.840
cylinder.

00:56.990 --> 01:02.600
Example solvers in Openfoam are pimple foam, eco foam, piezo foam, inter foam.

01:04.010 --> 01:07.850
So applications are like uh, in most cases.

01:07.850 --> 01:13.340
The examples are aerodynamics, combustion, or multiphase phenomena like mixing processes.

01:13.370 --> 01:17.860
The advantage of using a transient solver is to capture time dependent phenomena.

01:17.860 --> 01:19.570
Analyze dynamic behavior.

01:19.660 --> 01:25.300
So in solver settings, apart from what we have done till now, we will also define our time step which

01:25.300 --> 01:26.080
is delta t.

01:27.100 --> 01:32.680
And we will be seeing how to set the convergence criteria which defines solution accuracy.

01:32.710 --> 01:36.220
We will also set maximum Cuda number, serial number and so on.

01:36.910 --> 01:40.960
So we will be seeing a multiple tutorial cases.

01:41.110 --> 01:44.680
So the first one will be backward facing step 2D case.

01:44.680 --> 01:47.230
In openfoam terms it's called pitch daily.

01:48.040 --> 01:50.710
Uh we will be seeing k epsilon turbulence model.

01:50.710 --> 01:53.470
And the solver which we will be using is pimple four.

01:54.310 --> 02:00.880
So as you can see this is the part of control dict file which we will control the entire simulation

02:01.750 --> 02:02.770
parameters.

02:02.770 --> 02:06.430
So the start frame uh start from is set to latest time.

02:06.430 --> 02:12.340
So basically when we don't have any time steps before running the simulation, zero is the latest time.

02:12.340 --> 02:13.900
So it will start at latest time.

02:13.900 --> 02:20.890
But if you want to start at start time every time, then you can start, uh, you can set the start

02:20.890 --> 02:23.440
from to start time instead of latest time.

02:23.710 --> 02:26.890
Too many times in a sentence stop.

02:26.890 --> 02:29.200
It will be n time and you can set the end time.

02:29.200 --> 02:35.530
That is the uh, time flow time in seconds where your simulation will end.

02:35.530 --> 02:39.010
In this case, your simulation will end at 0.3 seconds.

02:39.130 --> 02:42.130
So it's like you're starting a simulation, you're starting a flow.

02:42.130 --> 02:49.570
And after, if you stop the simulation or stop recording the simulation after 0.3 seconds, whatever

02:49.570 --> 02:52.960
video you would have got, that is exactly what we are trying to simulate here.

02:53.050 --> 02:55.690
Then we have the delta T, which is the time step.

02:55.690 --> 02:59.320
In this case it is one over one E minus four.

02:59.590 --> 03:01.780
So that is very small.

03:01.780 --> 03:04.210
And we will see why we said that okay.

03:04.210 --> 03:10.030
In the control deck we are sorry in the right control we are setting it to adjustable and the right

03:10.030 --> 03:21.960
interval is 0.01 which means our delta is 0.0001, but for every 0.01 seconds, we will be saving a

03:21.960 --> 03:26.220
time step file which will cater us to the animation finally.

03:26.220 --> 03:31.950
So we will get a frame of reference for every 0.01 seconds.

03:32.700 --> 03:36.240
So the purge rate is mostly useful only for steady state case.

03:36.240 --> 03:43.050
What it means is if I said purge rate to five, then only the latest five time steps will be stored.

03:43.050 --> 03:46.170
Everything else will be deleted to save some storage space.

03:46.740 --> 03:48.630
Uh, the right format should be Ascii.

03:48.930 --> 03:51.990
You don't have to touch any of these if you just come.

03:52.170 --> 03:52.320
Uh.

03:52.320 --> 03:54.690
Below you will find runtime modifiable.

03:54.690 --> 04:01.260
You can set it to S, because if you see that the simulation is running and you feel like 0.3 is not

04:01.260 --> 04:07.380
enough, then you can, uh, set the end time to 0.5 while the simulation is running.

04:07.410 --> 04:10.980
If you want to do that, then you have to set the runtime modifiable to S.

04:11.580 --> 04:18.240
And in the adjust time step, if you keep s, then what it means is you are doing adaptive time stepping.

04:18.240 --> 04:24.150
So in case of adaptive time stepping you also have to define your maximum current number.

04:24.150 --> 04:26.640
Only then it will uh do it.

04:26.640 --> 04:29.610
So generally maximum current number has to be one.

04:29.610 --> 04:31.410
That is the realistic case.

04:31.890 --> 04:36.810
Uh, it is also popularly known as CFL current Frederic uh Levy number.

04:36.810 --> 04:40.290
But in open form terms it's maximum current number.

04:40.290 --> 04:43.890
We can monitor current number while the simulation is running for every time step.

04:43.920 --> 04:47.400
So by default this tutorial comes with a max of five.

04:47.400 --> 04:49.170
So let's stick on to the tutorial.

04:49.170 --> 04:55.140
But when you are actually setting up a case, make sure that mostly it is one or depends on the physics.

04:56.100 --> 05:00.360
So the next image is from turbulence properties file.

05:00.360 --> 05:06.300
The simulation type is going to be Arias and the Arias model is going to be epsilon k epsilon.

05:06.600 --> 05:10.860
The turbulence is turned on and the print coefficients also turned on.

05:10.860 --> 05:16.200
What this does is in the command prompt or the console window, you will be able to see the coefficients

05:16.200 --> 05:20.660
of turbulence parameters like k, epsilon and duty while the simulation is running.

05:21.710 --> 05:31.490
So after running the simulation, we will be getting, uh, multiple files from 0.010.020.03, so on

05:31.490 --> 05:33.020
to 0.3 seconds.

05:33.020 --> 05:40.250
We will be visualizing those things, those, uh, frames of animation in Paraview after running this

05:40.250 --> 05:40.580
case.

05:40.580 --> 05:43.370
So this is what we are trying to, uh, visualize.

05:43.370 --> 05:48.560
So the left one is 0.01 seconds and the right one is 0.3 seconds.

05:48.560 --> 05:49.550
This is how it starts.

05:49.550 --> 05:50.660
And it ends here.

05:50.660 --> 05:52.670
So this is just a backward facing step.

05:52.700 --> 05:56.840
Now we will jump into our command prompt and try to simulate this case.

05:57.650 --> 05:59.780
I am in class six folder.

05:59.780 --> 06:04.130
Here we have the first pitch daily tutorial.

06:04.400 --> 06:07.250
Here we have zero constant and system.

06:07.250 --> 06:11.660
So as you might already know, uh, pitch daily comes with a block mesh.

06:11.750 --> 06:14.630
So I will run block mesh okay.

06:14.930 --> 06:17.420
And we will find out.

06:17.420 --> 06:19.130
What is this, uh, solver?

06:19.130 --> 06:22.370
As we already saw, this is a simple form case.

06:22.370 --> 06:28.850
Sorry, this is a simple form case, so I will write it to simple form.

06:30.560 --> 06:33.560
And let's wait for the simulation to end.

06:33.590 --> 06:35.930
Meanwhile, I'll just pause somewhere.

06:35.930 --> 06:41.720
Like if you scroll your mouse over here, it will snap to specific time and it will keep on running.

06:41.720 --> 06:45.590
It won't stop, but you can just scroll and it will just stop there.

06:45.590 --> 06:51.350
You can see it is progressing, the Delta T is progressing and it is not same as what we had defined

06:51.350 --> 06:58.130
because we have set the maximum current number and we also have the delta t, so it can alter the delta

06:58.130 --> 07:02.240
T to, uh, adapt to the maximum number.

07:02.240 --> 07:04.160
That's what adjustable time step is.

07:04.160 --> 07:06.200
It's mostly adaptive time stepping.

07:06.920 --> 07:10.640
Also you can monitor at what time the simulation is happening.

07:10.640 --> 07:14.150
Like this is 0.018 and so on.

07:14.150 --> 07:19.700
And we can see the parameters residual parameters for UX UI.

07:20.000 --> 07:25.550
And we also have for epsilon k pressure continuity everything.

07:25.550 --> 07:27.080
So this goes on.

07:27.770 --> 07:32.870
And finally when it reaches 0.3 this simulation will end.

07:32.960 --> 07:40.490
So when you are doing this uh you can actually go to that location and see it.

07:41.000 --> 07:43.700
So I will tell you what that latest time is all about.

07:43.700 --> 07:48.940
Now, if I want to stop this simulation, I can just do control C and it will just end there.

07:48.970 --> 07:51.970
Now I will do explorer dot x.

07:52.750 --> 07:59.020
So this location is open and you can see we have all the time steps coming here from 0.01.

07:59.020 --> 08:00.400
And it is slowly progressing.

08:00.400 --> 08:03.250
We have up to 0.14.

08:03.430 --> 08:10.900
So since we have given latest time now see the last time which it ran was 0.141795.

08:10.960 --> 08:15.880
So when I run the pimple form again it will just start from 0.14.

08:16.360 --> 08:20.470
See, it is starting from 0.14 because that is the latest available time step.

08:20.470 --> 08:23.950
So it is starting to write from 0.15.

08:23.950 --> 08:29.830
That is the advantage of having the start time as the latest time instead of starting.

08:30.700 --> 08:38.080
Okay, now the simulation is over as you can see, it took so much time to finish this though I have

08:38.080 --> 08:45.430
got all the, uh, running time in the video, so it took a lot of time and you can see how many actual

08:45.430 --> 08:47.590
seconds it took here.

08:47.590 --> 08:48.040
Okay.

08:48.310 --> 08:50.050
You can also monitor that.

08:50.320 --> 08:54.040
And you can see it ended at 0.3 okay.

08:54.040 --> 08:57.370
And maximum delta T was around 0.0002.

08:57.370 --> 09:03.220
So that was much greater than what we defined like 0.0001 was what we defined.

09:03.430 --> 09:07.510
And you can see a maximum current number is just five here.

09:07.510 --> 09:10.570
So that's why it got adopted okay.

09:10.570 --> 09:14.290
Now we have all the, uh files here.

09:14.290 --> 09:16.480
I'll open the paraview.

09:26.920 --> 09:28.870
Okay, now it has loaded.

09:28.900 --> 09:33.310
I'll click on apply and I'll change it to velocity.

09:33.550 --> 09:34.090
Okay.

09:34.090 --> 09:37.990
Now as you can see we are at 0.01 flow time.

09:38.140 --> 09:45.850
It is always advisable to first go to the last frame and click on this thing which is rescale to visible

09:45.850 --> 09:49.500
data range, and then go back to your first time step.

09:49.920 --> 09:57.480
Mostly that would be better if you are running a transient cases, but if you think the physics is like

09:57.480 --> 10:03.120
the initially, it will be high in velocity and finally it will be lower in velocity.

10:03.120 --> 10:07.350
Then you have to do the rescale to visible data range in the first time step.

10:07.380 --> 10:15.210
So in this case the final time step has some less velocity than the first time step.

10:15.210 --> 10:20.730
So first time step has to be rescaled so that it can adapt till the last time step.

10:20.820 --> 10:25.050
So you will understand when you are actually working on multiple cases and you will get it.

10:25.380 --> 10:27.540
So I will click on play.

10:28.410 --> 10:31.320
So this is how the flow is progressing.

10:31.440 --> 10:38.520
So you can see the time is changing here I'll click play again and it will start from 0.00 0.01 seconds.

10:41.100 --> 10:44.580
Now as you can see the minimum is 0.01.

10:44.580 --> 10:51.120
But if you want to include the zeroth time timestep as well, you can check on this button and click

10:51.120 --> 10:51.690
apply.

10:51.900 --> 10:57.300
Now you would also have the zeroth timestep, but mostly it wouldn't make sense at all because it is

10:57.300 --> 10:58.650
just initial condition.

10:58.800 --> 11:02.310
Click on run and it will be done.

11:02.310 --> 11:07.200
So it is not generally advised to take the zeroth time step because it is just initial values.

11:07.200 --> 11:10.080
It won't, uh, give you any proper insight.

11:11.640 --> 11:13.950
Okay, now we got the velocity.

11:13.950 --> 11:21.990
Similarly, you can also monitor pressure and go to the first time step, rescale it and click on pressure.

11:21.990 --> 11:25.440
And you can see it is getting like an animation.

11:26.310 --> 11:32.310
Now I can do this same thing for k nu t epsilon.

11:32.430 --> 11:34.440
Okay so you get the point.

11:34.530 --> 11:40.890
Now if I want to do uh velocity streamlines as an animation then I can still do it.

11:43.080 --> 11:48.350
I just plot streamlines, just like how, uh, just the way I would do normally.

11:48.680 --> 11:50.000
I'll hide the line.

11:50.390 --> 11:50.570
Okay.

11:50.570 --> 11:53.120
Maybe reduce the number of lines here.

11:55.910 --> 12:02.930
Okay, now I can do the same thing, like start play and it is running.

12:02.930 --> 12:11.030
Now it is a bit slow and loading because it is, uh, loading all the time steps and plotting the stream

12:11.030 --> 12:11.300
lines.

12:11.300 --> 12:13.580
So it is doing multiple things at the same time.

12:13.580 --> 12:15.830
So it is a bit glitchy.

12:15.920 --> 12:24.080
So what you can do is go to file, click on Save Animation and probably I will save it as stream lines.

12:25.220 --> 12:30.260
Hit okay and probably I will take yeah.

12:30.260 --> 12:33.560
Just for this case I would take just one frame per second.

12:34.190 --> 12:34.430
Okay.

12:34.730 --> 12:42.980
But if you want a realistic scale, then you have to choose ten frame per seconds for, uh, for you

12:42.980 --> 12:47.510
to get a slowed down animation of ten times.

12:47.510 --> 12:53.540
But if you do 100 frames per second, then you would get the exact realistic thing, because our lowest

12:53.540 --> 13:00.890
time step is 0.01 and our delta T is, uh, I mean delta t in terms of saving animation.

13:00.890 --> 13:04.670
Every frame here as we saved it is 0.01 seconds.

13:04.670 --> 13:08.900
So when you want everything for one second, you just have to multiply it by 100.

13:09.620 --> 13:13.310
But that would be too fast because the animation would end in 0.3 seconds.

13:13.310 --> 13:15.920
So I'll change it to one and click on okay.

13:17.000 --> 13:19.580
So you don't have to worry about this error.

13:19.580 --> 13:23.870
It is uh because of the resolution okay.

13:23.870 --> 13:24.710
It doesn't matter.

13:24.740 --> 13:25.220
now.

13:25.220 --> 13:32.630
We got the file, saved the animation file, and I can open the stream lines and it would be decent

13:32.630 --> 13:33.710
enough and fine.

13:33.710 --> 13:37.700
As you can see, it is saving one frame per one second.

13:39.170 --> 13:47.330
You can get some good insight from this, but if you really want, uh, a fast forwarded kind of thing,

13:47.330 --> 13:54.670
like a realistic animation kind of thing, maybe a ten times slow but animation kind of thing.

13:54.670 --> 13:59.830
Then you can choose ten frames per second in this case.

13:59.830 --> 14:01.870
Okay, I'll just save it.

14:12.460 --> 14:14.320
Now I will run this.

14:15.550 --> 14:18.910
Now you can see it is much better and looking like an animation.

14:19.390 --> 14:23.320
Since it is a streamline, we can't infer much as well.

14:23.830 --> 14:28.810
I will go here and save this as, uh, velocity file.

14:30.520 --> 14:37.570
But instead of ten I am even going to use 20, so it is just half scaled down.

14:39.910 --> 14:40.660
Go here.

14:40.660 --> 14:41.980
Run the velocity file.

14:44.110 --> 14:46.900
So this ran very fast as you can see.

14:47.920 --> 14:52.060
So this is what a real animation would look like at the end.

14:52.060 --> 14:57.640
If we had much higher time steps of flow time then we would have a longer animation.

14:57.640 --> 14:59.830
But this was just for demonstration.

14:59.830 --> 15:00.940
So this is okay.

15:02.050 --> 15:07.210
Now, you understood how to set up a transient case and run this.

15:07.210 --> 15:09.970
So this is the first part of the video.

15:10.420 --> 15:13.000
Uh, from the second part we would continue.

15:13.000 --> 15:13.450
Okay.

15:14.890 --> 15:15.250
Okay.

15:15.250 --> 15:17.650
Now we are going to see decomposing methods.

15:17.650 --> 15:27.820
So decomposing is a method where you will split the mesh into separate sections or regions, and give

15:27.820 --> 15:32.230
your processors each part of the mesh and ask it to solve for you.

15:32.230 --> 15:40.000
So this is done through a process called message passing interface, also popularly known as MPI.

15:40.240 --> 15:42.580
Openfoam comes with the MPI installation.

15:42.580 --> 15:48.340
Generally, people have to write MPI codes to parallel process their simulations.

15:48.340 --> 15:52.350
But since Openfoam comes with the installation of MPI, we can use it.

15:52.470 --> 15:55.530
So it also depends on the number.

15:55.530 --> 15:57.570
Of course, your system has.

15:57.570 --> 16:01.890
So cores are the number of physical processors your CPU comes with.

16:01.920 --> 16:02.280
Okay.

16:02.280 --> 16:08.310
So your CPU will have certain number of physical cores and logical course Openfoam can access only physical

16:08.310 --> 16:08.610
cores.

16:08.610 --> 16:15.330
Commercial software like Ansys fluent can access even logical processors, but Openfoam can access only

16:15.330 --> 16:16.500
the physical cores.

16:16.500 --> 16:22.020
So we will see how to find out the physical cores in your PC, because this is the number or value which

16:22.020 --> 16:24.600
you have to remember while decomposing.

16:25.200 --> 16:29.850
So I have given a set of methods to find out the course in your PC.

16:29.880 --> 16:35.820
So you just have to open your task manager and you will go to the performance section.

16:35.820 --> 16:38.460
And inside that you will go to CPU section.

16:38.490 --> 16:42.540
Under there you will go to course and you can find the number of course.

16:42.540 --> 16:44.430
So you just have to remember it.

16:44.910 --> 16:45.150
Okay.

16:45.150 --> 16:48.840
Sometimes your laptop comes with the stickers saying uh number.

16:48.840 --> 16:54.360
Of course if it is a gaming laptop, but if you are on a very regular laptop, then mostly it won't

16:54.360 --> 16:54.600
be there.

16:54.600 --> 16:55.800
So you have to find it out.

16:56.880 --> 17:04.590
So to do that, either you can open task manager from this or any shortcut methods which you know,

17:04.590 --> 17:06.510
there are a lot of shortcuts for this.

17:06.990 --> 17:10.350
So I'll go here, click on performance and on CPU.

17:10.380 --> 17:12.750
As you can see we have the number of cores here.

17:12.750 --> 17:14.400
In my system it is eight.

17:14.400 --> 17:21.930
So whenever I'm using eight for decomposing and MPI please remember that you have to use the num value

17:21.930 --> 17:24.360
which your PC is supposed to have.

17:24.510 --> 17:31.020
Just because I am typing eight somewhere, please don't follow the same and uh, face errors, so just

17:31.020 --> 17:33.240
replace it in the appropriate places.

17:33.630 --> 17:35.190
I will close the task manager now.

17:36.870 --> 17:39.660
Okay, now we are going to see the decomposing methods.

17:39.660 --> 17:46.650
So decomposing in open form is done through a file called decompose uh part dict okay.

17:47.160 --> 17:48.600
Uh we will see the file as well.

17:48.600 --> 17:50.700
So this is how the file actually looks like.

17:50.700 --> 17:52.490
It will have number of subdomains.

17:52.730 --> 17:55.040
And it will ask you for a method.

17:55.160 --> 18:00.320
If you choose hierarchical then you have to define the coefficients.

18:00.320 --> 18:08.210
So the coefficients are like if you have an entire mesh and in each direction how many subdivisions

18:08.210 --> 18:08.930
do you need.

18:09.650 --> 18:18.590
So in this example we are subdividing the x in four subdivisions the Y into two subdivisions, and the

18:18.650 --> 18:22.220
Z is going to be just one, which means it might be a 2D case.

18:22.220 --> 18:25.730
We are interested in decomposing only x and y.

18:25.760 --> 18:31.220
So what is important about the 4211 and why did I choose it?

18:31.220 --> 18:37.670
It is like when you multiply x by y by z you have to get the number of processors.

18:37.670 --> 18:43.880
So in this case it is four times two times one which is eight which is the same as number of subdomains.

18:44.150 --> 18:48.380
It is not mandatory that you always have to use all the cores which you have.

18:48.410 --> 18:56.750
If you have eight cores, you can still use just six or just two or just, uh, four.

18:56.750 --> 18:57.020
Okay.

18:57.020 --> 19:02.600
But it is very recommended that you use even numbers and not odd numbers.

19:03.110 --> 19:05.900
So use two, four, 6 or 8.

19:06.200 --> 19:06.980
Things like that.

19:06.980 --> 19:09.290
But don't use odd numbers.

19:09.590 --> 19:11.900
Mostly it can't work well.

19:11.900 --> 19:16.250
That is why laptops or computers come with even numbers, of course.

19:16.280 --> 19:18.680
Okay, so you always use even numbers.

19:18.680 --> 19:24.380
If you want to find out why it has to be even numbers, you have to study about message passing interface.

19:24.920 --> 19:25.250
Okay.

19:25.250 --> 19:30.740
Now in uh, other method which is called scotch, you don't have to define the coefficients.

19:30.740 --> 19:33.410
The program will do it for you.

19:33.410 --> 19:37.160
So you just have to specify the number of subdomains and the method.

19:37.970 --> 19:44.540
So to execute the decompose predict file and decompose your case the command is just decompose part

19:44.930 --> 19:45.290
okay.

19:45.290 --> 19:50.060
The purpose of decomposing is to divide the computational domain into smaller parts.

19:50.060 --> 19:55.960
The benefit is it enables parallel processing and reduces computational time by splitting the work to

19:55.960 --> 19:57.130
all the processors.

19:57.220 --> 20:04.090
When you are running in series, the computation will be done in a series manner by one processor,

20:04.090 --> 20:06.610
but you are doing parallel processing.

20:06.610 --> 20:11.650
The work will be split to multiple processor and it runs in parallel, so you get it faster.

20:12.610 --> 20:17.770
So the method is like first you split the domain into sub domains and assign different tasks to each

20:17.770 --> 20:22.120
processor, and you will be able to run the simulation or mesh.

20:22.120 --> 20:24.430
So the Openfoam command is decomposed part.

20:24.790 --> 20:30.160
Okay, so before we jump into what parallel processing and how to do it just we will see how to do the

20:30.160 --> 20:31.180
decomposing.

20:31.780 --> 20:35.020
I'll go to the terminal.

20:35.020 --> 20:39.880
I'll clear this and go to the second tutorial of today.

20:41.650 --> 20:48.460
Okay, we have zero constant and system as usual, but if you see under system we have one more file

20:48.460 --> 20:50.020
called decompose bardic.

20:50.020 --> 20:52.540
So that is what we are going to view now.

20:52.540 --> 20:56.680
Okay I will go to the second folder.

20:57.130 --> 20:58.840
We have decompose bardic.

21:02.890 --> 21:08.800
Here initially I have chosen Scotch, but if you want to trial with hierarchical, you can do it.

21:08.800 --> 21:12.190
So we have the number of subdomains where I have specified eight.

21:12.190 --> 21:13.570
You have to specify the number.

21:13.570 --> 21:14.560
Of course you are.

21:16.120 --> 21:18.790
And the method in this case is scotch.

21:18.790 --> 21:24.730
Otherwise it is just normal daily case which we run here for transient phenomena.

21:25.180 --> 21:27.220
We will see the control dict.

21:28.450 --> 21:36.040
So we are again using pimple form only and the time step is delta t is equal to 0.0001.

21:36.340 --> 21:38.980
And let the maximum see will be five.

21:38.980 --> 21:42.760
Sorry, this shouldn't be there.

21:42.760 --> 21:52.360
So that was my mistake okay so we have the delta T as 0.001 and maximum current number as five.

21:52.570 --> 21:53.020
Okay.

21:53.020 --> 21:54.910
So we are going to decompose it.

21:54.910 --> 21:55.300
Now.

21:55.300 --> 21:58.900
As you can see initially we have only zero constant and system.

21:58.900 --> 22:03.250
So this zero file has u p nu t k and epsilon.

22:04.120 --> 22:09.610
Because we are using k epsilon turbulence model, all you need as turbulence parameters is just these

22:09.610 --> 22:12.220
three turbulence viscosity k and epsilon.

22:12.460 --> 22:16.840
If you want to explore what I said for the boundary condition, you can go in and check it.

22:16.840 --> 22:18.990
But that's not the scope of this video.

22:19.080 --> 22:21.450
Okay, so we have zero.

22:21.840 --> 22:24.330
We don't have any other time step because we didn't run it.

22:24.390 --> 22:28.800
Now I will go here and I will execute decomposing.

22:28.800 --> 22:32.490
So the command is decompose part with P capital hit enter.

22:33.840 --> 22:37.290
As you can see it is saying that it is subdividing.

22:38.040 --> 22:38.250
Okay.

22:38.250 --> 22:42.270
It is subdividing the time zero into 0 to 7 which is eight.

22:42.750 --> 22:43.830
uh, field transfer.

22:43.830 --> 22:49.080
And you can see the number of cells, number of points has been assigned to each processor.

22:49.080 --> 22:51.420
So it might be a little bit more or less.

22:51.420 --> 22:59.490
But each processor has a set of mesh which it has to, uh, work on and do the simulation.

22:59.490 --> 23:00.000
Okay.

23:00.000 --> 23:06.090
So after we do this we got these files processor zero to processor seven.

23:06.240 --> 23:13.980
So when you go into processes zero you have made a copy of process uh zero files and the constant file

23:13.980 --> 23:20.340
under Polymesh you will have only the mesh this processor is assigned to you.

23:20.340 --> 23:23.430
It will not have all the mesh which you generated using block mesh.

23:23.430 --> 23:28.320
It will have only the mesh content which is necessary for this processor.

23:28.320 --> 23:30.870
And same applies to every processor Okay.

23:30.870 --> 23:35.970
So it has the zero file because we are going to run things in parallel and it needs a reference for

23:35.970 --> 23:36.420
zero.

23:36.420 --> 23:38.490
So it has the zeroth time step.

23:38.670 --> 23:43.260
Now I will explain what parallel processing is and how to do it.

23:44.760 --> 23:47.220
So parallel processing using MPI.

23:47.280 --> 23:50.040
So MPI is a message passing interface.

23:50.160 --> 23:53.280
The definition is it is standard for parallel computing.

23:53.280 --> 23:58.170
And the functionality is functionalities it allows processes to communicate with each other.

23:58.470 --> 24:04.470
In implementation for Openfoam, we will enable parallel processing for faster simulation, which is

24:04.470 --> 24:06.810
the same for any CFD software.

24:07.050 --> 24:11.280
And you will, uh, run a piece of foam simulation for this.

24:11.910 --> 24:19.890
Uh, as an example for yourself, you will try a piece of foam tutorial if you want and you can try

24:19.890 --> 24:21.000
it using MPI.

24:21.030 --> 24:25.470
For now, we will be sticking with the simple form tutorial and we will see a demonstration.

24:25.470 --> 24:31.770
But if you want to do it with icofom or simple form, the methodology remains the same.

24:31.770 --> 24:40.020
All you have to do is you have to copy this decomposed par dict and put it into any system directory

24:40.020 --> 24:42.270
of any case, and you can decompose it.

24:42.270 --> 24:46.220
You just have to set everything properly like the number of subdomains.

24:46.250 --> 24:46.640
Okay.

24:46.640 --> 24:49.220
So that is the only thing which you have to do.

24:50.870 --> 24:51.470
Okay.

24:51.470 --> 24:55.130
The benefit is it utilizes multiple processes simultaneously.

24:55.130 --> 24:58.610
And it scales well with increasing computational resources.

24:59.780 --> 25:04.580
So let's see what is the step to do parallel processing using MPI.

25:04.820 --> 25:07.250
The first thing is decompose power.

25:07.250 --> 25:11.820
But but before that you must have a mesh and initial boundary condition in zero five.

25:12.240 --> 25:16.350
So that's what I mentioned as poly mesh must be available because not just block mesh.

25:16.350 --> 25:21.420
You could have generated that with snappy hex mesh or imported from Ansys fluent mesh, which we will

25:21.420 --> 25:21.840
see later.

25:21.840 --> 25:25.470
So anyways, it will all the mesh will be in polymer, so it has to be there.

25:26.070 --> 25:32.060
Then you are running decompose power which will subdivide everything, every mesh for each process.

25:32.600 --> 25:40.220
Then the command to initiate the solution or simulation is MPI run space hyphen NP space.

25:40.220 --> 25:46.760
The number of processor, which in my case is eight and uh process which is in this case pimple foam.

25:46.760 --> 25:49.370
If it is a simple form then you have to do simple form.

25:49.370 --> 25:55.610
If it is a micro form you have to type ICO form in place of process and space hyphen parallel.

25:55.640 --> 25:59.780
So this is what will initiate the solver to run in parallel.

26:00.560 --> 26:01.730
I have put some examples.

26:01.730 --> 26:08.540
If it is an eight core processor, it will be mpirun space hyphen NP space eight and the command if

26:08.540 --> 26:09.290
it is simple form.

26:09.440 --> 26:11.240
Simple form space hyphen parallel.

26:11.990 --> 26:15.980
If it is six cores, then NP six.

26:16.040 --> 26:17.210
Simple form parallel.

26:17.480 --> 26:22.390
Okay, we will see about reconstruct, uh, after we run the simulation, actually.

26:22.690 --> 26:22.930
Okay.

26:22.930 --> 26:31.270
Now that we have all the decomposed files, we can initiate it through Mpirun NP eight.

26:31.300 --> 26:31.630
Eight.

26:31.630 --> 26:35.200
In my case, simple form.

26:37.360 --> 26:37.930
Parallel.

26:38.860 --> 26:45.100
When I hit enter, it will start to do the same process, which we did previously, but in parallel.

26:45.100 --> 26:47.140
So it is going to end super fast.

26:48.730 --> 26:50.590
As you can see, it is running super fast.

26:50.590 --> 26:54.490
Then what it was running previously because it is just eight times faster right now.

26:59.770 --> 27:02.830
So let's wait for the simulation to end and I will get back to you.

27:06.520 --> 27:09.010
So the simulation is about to end.

27:09.040 --> 27:10.840
Okay, it is done.

27:11.200 --> 27:14.500
Now I will do ls again.

27:14.500 --> 27:16.540
All you can see is processes 0 to 7.

27:16.540 --> 27:18.190
We are not able to see the time step.

27:18.640 --> 27:21.820
But what happened because everything is inside processor.

27:22.150 --> 27:28.870
So we have 0.1 to 0.3 everything here for every processor.

27:29.680 --> 27:30.100
Okay.

27:30.100 --> 27:36.730
So we have to reconstruct everything and then we can, uh, see the visualization.

27:37.060 --> 27:42.640
So what reconstructing will do is it will take the mesh information from every processor, collectively

27:42.640 --> 27:46.930
put it, and just save everything as, uh, separate time step.

27:46.930 --> 27:49.180
And then it would look something like this.

27:49.180 --> 27:57.310
But if you don't want to reconstruct because it takes a bit of time, you can open paraview Paraview

27:58.060 --> 28:01.510
and instead of directly clicking on apply, you can change it here.

28:01.510 --> 28:06.760
Instead of reconstructed case, you can go to decomposed Case and then click on apply.

28:07.930 --> 28:08.350
Okay.

28:08.350 --> 28:11.950
Now what if I just click on reconstructed case.

28:12.100 --> 28:17.200
You are not going to see anything because it doesn't know that if there are any files at all, because

28:17.200 --> 28:21.040
it is expecting the time 0.01, but it is not there.

28:21.040 --> 28:23.250
So you have to give decomposed case.

28:23.250 --> 28:27.150
So it will go inside every processor and try to recollect it for you.

28:27.420 --> 28:28.380
For visualization.

28:28.380 --> 28:30.240
Now I can see the velocity.

28:31.320 --> 28:36.090
Right now if I play, it is going to be playing because it is trying to recollect.

28:36.090 --> 28:39.930
But since the mesh is very less, mesh count is less.

28:39.930 --> 28:41.970
We are not getting stuck.

28:41.970 --> 28:47.370
But when the mesh count is very high, let's say in a 3D case where where there are millions of cells,

28:47.370 --> 28:50.670
then every loading time step is going to be very high.

28:50.700 --> 28:55.290
That's why we are going to reconstruct and then visualize it very easily.

28:55.470 --> 28:55.710
Okay.

28:55.710 --> 29:01.560
Because it takes time for paraview to reconstruct every single time step without storing it and displaying

29:01.560 --> 29:02.100
it to you.

29:02.100 --> 29:06.570
It's too much on the memory, so we will see how to reconstruct it.

29:06.750 --> 29:11.520
To reconstruct the very simple thing is just run, reconstruct part.

29:11.640 --> 29:13.230
That's all you have to do.

29:13.230 --> 29:16.860
So just like how you did decompose part, now you have to do reconstruct part.

29:17.310 --> 29:17.460
Okay.

29:17.460 --> 29:21.870
Now I will go to my terminal and I will do reconstruct part.

29:21.870 --> 29:23.340
And you will see what happens.

29:23.340 --> 29:29.910
It is starting to reconstruct every single time step by putting the time step name.

29:29.940 --> 29:34.350
See it is saying time 0.01 and it is reconstructing all the fields.

29:34.470 --> 29:37.290
Volume, scalar field, vector field and surface scalar fields.

29:37.470 --> 29:40.170
So as you can see it is taking a bit of time.

29:40.170 --> 29:41.280
It is running slow.

29:42.330 --> 29:46.170
We will also see a method to run this parallel as well.

29:46.530 --> 29:48.990
But for now this is the most popular method.

29:48.990 --> 29:51.150
So let it run.

29:51.150 --> 29:56.220
We are not going to wait for it to end completely because this is just for demonstration.

29:56.220 --> 29:58.140
We will stop it at 0.05.

29:58.170 --> 29:59.190
Till then, let's wait.

30:08.550 --> 30:13.500
Okay, now it is done before it starts with 0.06.

30:13.500 --> 30:20.970
If you want to end any process, just hit Ctrl C and it will be interrupted by the keyboard.

30:21.510 --> 30:26.390
If I go here now, you can see we have 0.01 to 0.05.

30:27.440 --> 30:32.150
Okay, but let's assume that you have reconstructed everything, okay?

30:32.150 --> 30:41.090
And, uh, you don't need these files anymore because these are going to consume a lot of space.

30:41.090 --> 30:43.040
Since this is a very small scale, it is less.

30:43.040 --> 30:44.930
Otherwise it's going to be in gigabytes.

30:45.350 --> 30:49.250
So we don't want these anymore because the data has been reconstructed.

30:49.250 --> 30:54.620
So what you can do is arm space minus r proc star.

30:54.620 --> 31:00.560
So it just says that delete everything and everything inside those folder which starts with the four

31:00.560 --> 31:01.940
letters p, r o, c.

31:01.940 --> 31:04.010
And we don't care what comes later.

31:04.010 --> 31:07.700
So anything any folder that starts with proc will be deleted.

31:07.820 --> 31:13.520
When you're doing through terminal, it's going to be faster than what you will be manually clicking

31:13.520 --> 31:15.020
and deleting through windows.

31:15.020 --> 31:22.220
Since this is through WSL, it's going to be faster than what windows can even do.

31:22.370 --> 31:25.340
So as you can see, it is slowly getting deleted one by one.

31:29.330 --> 31:31.040
And now it is all done.

31:31.040 --> 31:36.470
Okay, now you can go to paraview and click on Reconstructed Case.

31:36.470 --> 31:38.390
Click on apply and it will still work.

31:38.390 --> 31:43.460
But we have only 0.05 seconds of data.

31:44.120 --> 31:48.230
Okay, now let's say like you don't want these time step.

31:48.230 --> 31:55.850
Also, you want to start from uh scratch by changing let's say delta t or maximum quota number if you

31:55.850 --> 31:57.500
want to choose it as two.

31:57.500 --> 32:00.230
And if you want to run it, you have to delete all the time steps.

32:00.230 --> 32:04.910
Right now it is just like, uh, around 100 time step.

32:04.910 --> 32:09.560
But what if it is so much you can't delete everything one by one?

32:09.560 --> 32:14.600
Or just even if you select everything and delete windows is going to take a lot of time.

32:14.720 --> 32:22.160
So Openfoam gives you this nice command for list times.

32:22.460 --> 32:26.650
Notice that L and T are capital space hyphen m.

32:26.650 --> 32:31.480
Hit enter and all the time steps will be gone, like in an instant.

32:31.660 --> 32:34.390
So you have deleted all the time steps through this command.

32:34.390 --> 32:38.920
So this is just some additional information apart from today's topic.

32:39.940 --> 32:45.190
So this is just nice to know because when we are working with terminal, it will be much faster than

32:45.190 --> 32:46.870
what you can do directly with windows.

32:48.070 --> 32:48.220
Okay.

32:48.220 --> 32:54.430
now we know how to decompose a case and run it in parallel using MPI and also reconstruct part.

32:56.020 --> 33:00.790
Okay, now we are going to see how to run parallel snappy hex mesh.

33:01.030 --> 33:03.130
Snap hex mesh is a meshing process.

33:03.130 --> 33:09.160
And we are going to do meshing itself as uh parallel processing.

33:09.160 --> 33:15.760
As I was saying, we must have a poly mesh to generate any sort of decomposing, right?

33:15.760 --> 33:20.680
Because we need a poly mesh to even put it in constant and split the mesh to the processor.

33:20.980 --> 33:23.620
But snappy mesh itself is a mesh.

33:23.620 --> 33:29.140
So what we are going to do is we will generate the block mesh and split the block mesh to different

33:29.140 --> 33:34.990
processor, and we will do snappy mesh as a process to every processor.

33:35.230 --> 33:40.840
So I think you get the point and we will do the tutorial so you understand it better.

33:40.870 --> 33:42.100
I'll clear this.

33:42.820 --> 33:46.390
Go to the third case for this class.

33:47.050 --> 33:47.290
Okay.

33:47.290 --> 33:52.300
Now we just have constant and system no zero file because we are not interested in running simulation.

33:52.750 --> 34:00.280
So just this now what I'm going to do is I'm going to do block mesh because first we are going to run

34:00.280 --> 34:01.030
the block mesh.

34:01.030 --> 34:07.960
So this is the pipe external case which we made if you remember meshing around the pipe.

34:08.080 --> 34:08.440
Okay.

34:08.440 --> 34:10.240
Now I have generated the block mesh.

34:10.360 --> 34:13.780
Then the next command is to decompose this.

34:14.650 --> 34:20.500
So I will decompose using decompose part.

34:20.500 --> 34:20.500
Ah.

34:28.930 --> 34:31.360
Okay, now we have decomposed the block mesh.

34:31.390 --> 34:34.990
Now, the next thing is we have to initiate snap x mesh.

34:35.710 --> 34:40.630
So the command is same Mpirun NP eight.

34:41.560 --> 34:45.220
And the process name which is snappy x mesh.

34:45.400 --> 34:46.810
As usual parallel.

34:46.810 --> 34:53.970
If you remember we always do snappy x mesh with space overwrite, so we can also include that it doesn't

34:53.970 --> 34:57.600
matter if you put parallel first or overwrite first, it's going to be the same.

34:57.600 --> 35:01.860
So what I have done is let me shorten this so that you can see it better.

35:05.820 --> 35:06.330
Right.

35:09.480 --> 35:09.960
Okay.

35:09.960 --> 35:15.720
It is mpirun I am not able to put it in the a single line or can I?

35:17.580 --> 35:18.090
Yeah.

35:18.210 --> 35:23.280
So it is just like MPI run PNP, snappy hex mesh, parallel override.

35:23.640 --> 35:28.740
Now I can hit enter and this will start the snappy hex mesh process.

35:29.730 --> 35:31.710
Now you see this running much faster.

35:31.710 --> 35:37.020
If you remember at what speed it was running when you initiated the mesh, you would know that it is

35:37.020 --> 35:38.460
much, much faster.

35:39.390 --> 35:47.220
So now let's wait for it to end and we will reconstruct the mesh through a special command called reconstruct

35:47.220 --> 35:47.970
per mesh.

35:48.000 --> 35:55.140
So as you remember, we just did reconstruct part when we are doing the time step reconstruction.

35:55.140 --> 36:00.360
But in this case we have to do reconstruct per mesh space hyphen constant.

36:00.360 --> 36:04.260
Because we are trying to write this mesh inside the constant folder.

36:04.380 --> 36:12.630
So I will do reconstruct power mesh hyphen constant.

36:13.140 --> 36:13.920
I'll hit enter.

36:13.920 --> 36:18.750
Now you can see it is taking data from all eight processors and putting it in the.

36:20.790 --> 36:21.420
Poly mesh.

36:21.450 --> 36:26.250
Okay now we don't need these processor 0 to 7 anymore.

36:26.250 --> 36:30.480
So what we can do is r minus r proc.

36:32.040 --> 36:34.530
And it will delete all the processor files.

36:34.530 --> 36:36.180
So we can save upon some space.

36:36.180 --> 36:41.610
Now if you just want to view the mesh you can go to para Para view.

36:42.390 --> 36:43.470
Click on apply.

36:45.600 --> 36:48.480
You can go to wireframe and you can see we have the mesh.

36:48.720 --> 36:52.910
So the output is going to be the same but the process will be faster.

36:52.910 --> 36:55.310
That is the advantage of using MPI.

36:56.450 --> 37:05.120
So I hope you understood how to do the uh decomposing as well as reconstruction.

37:05.120 --> 37:09.200
Now let's say you have a zero file also.

37:09.200 --> 37:11.630
And now you want to run things in parallel.

37:11.630 --> 37:17.300
So what you can do is after deleting all the processor files now, then reconstruct, just like how

37:17.300 --> 37:21.080
you would do for any simulation case like this process.

37:21.080 --> 37:22.700
So again you have to decompose.

37:22.700 --> 37:25.700
Then you can run things in parallel and reconstruct part.

37:25.880 --> 37:27.710
So that is the best method.

37:28.460 --> 37:30.530
So now we have an additional tip.

37:30.530 --> 37:33.050
What if you want to reconstruct in parallel.

37:33.050 --> 37:36.950
Because reconstruct if it has like too many time steps.

37:36.950 --> 37:40.880
Like the previous case it had a lot of time steps, right?

37:40.880 --> 37:47.000
So if the case is like that, then it's going to take a lot of time to reconstruct.

37:47.000 --> 37:51.020
You saw how much time it took to reconstruct that.

37:51.020 --> 37:57.770
So what I will do is I will again run that case and show you how much time it takes.

37:59.180 --> 38:04.580
When we are reconstructing it in parallel, it's going to take a lot less time.

38:05.360 --> 38:09.830
So I'll just run this case and get back to you once this is over.

38:11.840 --> 38:14.090
I'm just going to run a few time steps.

38:14.090 --> 38:15.170
Not completely.

38:18.080 --> 38:24.440
So we have five time steps, or maybe four because I stopped it early.

38:25.640 --> 38:27.350
Yeah, we have five time steps.

38:27.380 --> 38:27.830
now.

38:27.830 --> 38:31.640
You remember how much time it took when we tried to reconstruct it?

38:31.640 --> 38:33.530
It was very, very slow.

38:34.130 --> 38:39.560
But now we are going to try to use this command and see how fast it is going to reconstruct, because

38:39.560 --> 38:40.430
it's running in parallel.

38:40.430 --> 38:43.940
So it is Mpirun NP eight again, the same thing.

38:43.940 --> 38:52.540
Then we are going to run a reduced tribute pa PA.

38:53.920 --> 38:56.620
Reconstruct.

38:58.030 --> 38:58.780
Parallel.

39:00.190 --> 39:02.590
New times.

39:02.680 --> 39:04.360
So you just type this.

39:04.360 --> 39:07.750
I hope I didn't make any mistake in spelling and hit enter.

39:07.750 --> 39:11.050
Now you see just how fast it is reconstructing.

39:19.450 --> 39:20.500
Now it is just done.

39:20.530 --> 39:23.950
This was the time it took to just reconstruct two time steps.

39:24.010 --> 39:29.050
So, uh, this is not very popularly known among a lot of users.

39:29.050 --> 39:32.110
So if you use this, it's an advantage to you.

39:32.650 --> 39:32.950
Okay.

39:32.950 --> 39:38.500
If you have any questions about anything related to this video, please feel free to contact me.

39:38.860 --> 39:40.150
See you in the next class.

39:40.150 --> 39:40.960
Thank you.
