This package contains integrator block that implements Finite Volume Methods.
Release Notes:
| Name | Description |
|---|---|
PDE.FiniteVolume.FVMIntegrator.FVIntegrator
Implements the cell average update rule. In one dimension, the finite volume method subdivide the domain into
cells (intervals) and approximates the integral of the unknown function q over each of these cells at each time step (see figure below).
The ghost cells are the boundary cells that are introduced to avoid writing special formulas for the boundary cells.
Denote the i-th cell by
Then the approximation to the average of q in the cell Ci at time t, which we denote with Qi is
The approximation to this average derives from the integral form of the conservation law
which states that the average within the cell can only changes due to the fluxes at the boundaries (if we assume that
no source or sink is present in the cell).
If we integrate this expression in time from t to t+deltat, we obtain
and dividing by deltax we reach the form
which give us an explicit time marching algorithm. By using the notation for averages introduced above we can write
where
approximates the average flux along the interface xi-1/2.
The FVMIntegrator block implements this average update rule. Initial condition of the problem can be passed to the IC input of the block,
whereas the boundary conditions to the corresponding ghost cells. The number of ghost cells depends on the method we use. In the present
package, two ghost cells at the left and at the right are enough for every method implemented.
Release Notes:
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | n | worldModel1.n | |
| Real | delta_x | 1/n | |
| Unknowns | |||
| Integer | vb | gcl + 1 | The left most unknown |
| Integer | ve | gcl + worldModel1.n | The right most unknown |
| Initial Condition | |||
| Integer | icb | gcl + 1 | Begin of the initial condition |
| Integer | ice | gcl + worldModel1.n | End of the initial condition |
| Boundary Conditions | |||
| Integer | bcl | 1 | Boundary condition at the left (0: no; 1: yes) |
| Integer | bcr | 1 | Boundary condition at the right (0: no; 1: yes) |
| Integer | gcl | 2 | Number of ghost cells at the left |
| Integer | gcr | 2 | Number of ghost cells at the right |
| Type | Name | Description |
|---|---|---|
| input RealInput | u[worldModel1.n + 1] | |
| output RealOutput | y[worldModel1.n + worldModel1.gcl + worldModel1.gcr] | |
| input RealInput | u2[worldModel1.n] | |
| input RealInput | u3[worldModel1.gcl] | |
| input RealInput | u4[worldModel1.gcr] |
block FVIntegrator
extends Icons.BlockIcon1;
outer PDE.World.worldModel worldModel1;
parameter Integer n = worldModel1.n;
//parameter Real beta = 1;
parameter Integer vb = gcl+1 "|Unknowns| The left most unknown";
parameter Integer ve = gcl + worldModel1.n "|Unknowns| The right most unknown";
parameter Integer icb = gcl+1
"|Initial Condition| Begin of the initial condition";
parameter Integer ice = gcl + worldModel1.n
"|Initial Condition| End of the initial condition";
parameter Integer bcl = 1
"|Boundary Conditions| Boundary condition at the left (0: no; 1: yes)";
parameter Integer bcr = 1
"|Boundary Conditions| Boundary condition at the right (0: no; 1: yes)";
parameter Integer gcl = 2
"|Boundary Conditions| Number of ghost cells at the left";
parameter Integer gcr = 2
"|Boundary Conditions| Number of ghost cells at the right";
parameter Real delta_x = 1/n;
//parameter Real delta_t = 0.1;
Real q[n+gcl+gcr];
equation
y = q;
for i in 1:gcl loop
q[i]= u3[i];
end for;
if bcl == 1 then
q[gcl+1] = q[gcl];
end if;
for i in 1:gcr loop
q[gcl+n+i] = u4[i];
end for;
if bcr == 1 then
q[gcl+n] = q[gcl+n+1];
end if;
for i in vb:ve loop
der(q[i]) = -(1/delta_x)*(u[i-gcl+1]-u[i-gcl]);
end for;
initial equation
for i in icb:ice loop
q[i] = u2[i-gcl];
end for;
// equation
// y = q;
//
// if bcl == 1 then
// for i in 1:gcl loop
// q[i]= u3[i];
// end for;
// end if;
//
// if bcr == 1 then
// for i in 1:gcr loop
// q[gcl+n+i] = u4[i];
// end for;
// end if;
//
// for i in vb:ve loop
// der(q[i]) = -(1/delta_x)*(u[i-gcl+1]-u[i-gcl]);
// end for;
//
// initial equation
//
// for i in icb:ice loop
// q[i] = u2[i-gcl];
// end for;
public
Modelica.Blocks.Interfaces.RealInput u[worldModel1.n + 1];
Modelica.Blocks.Interfaces.RealOutput y[worldModel1.n + worldModel1.gcl
+ worldModel1.gcr];
Modelica.Blocks.Interfaces.RealInput u2[worldModel1.n];
Modelica.Blocks.Interfaces.RealInput u3[worldModel1.gcl];
Modelica.Blocks.Interfaces.RealInput u4[worldModel1.gcr];
end FVIntegrator;