View on GitHub
Download this project as a .zip file Download this project as a tar.gz file
redbKIT
a MATLAB library for reduced-order modeling of PDEs

ADR Equations: Simulation Setup

We provide here an example of data and main files which are used to setup a simulation.

Datafile options

Define the source term (i.e. the right-hand side term )

% Source term
data.force = @(x,y,t,param)( exp(-((x-0.5).^2 + (y-0.5).^2)./(0.07^2) ) );

Set the flags for the boundary conditions: in this case we impose Neumann condition on all the boundaries [1 2 3 4]

% BC flag
data.flag_dirichlet = [];
data.flag_neumann   = [1 2 3 4];
data.flag_robin     = [];

Specify the functions for Dirichlet, Neumann and Robin boundary conditions

% Dirichlet
data.bcDir = @(x,y,t,param)( 0.*x.*y );  % i.e. g

% Neumann
data.bcNeu = @(x,y,t,param)(0.*x.*y); % i.e. r

% Robin
data.bcRob_alpha    = @(x,y,t,param)(0.*x); % i.e. alpha
data.bcRob_fun      = @(x,y,t,param)(0.*x); % i.e. gamma

Set diffusion ($\mu$), transport ($\mathbf{b}$) and reaction ($c$) coefficients

% diffusion
data.diffusion = @(x,y,t,param)(0.005 + 0.*x.*y);

% transport vector (first and second components)
data.transport{1} = @(x,y,t,param)( cos(t)  + 0.*x.*y);
data.transport{2} = @(x,y,t,param)( sin(t) + 0.*x.*y);

% reaction
data.reaction = @(x,y,t,param)(0.01 + 0.*x.*y);

Set parameters for the linear solver and preconditioner. In this case, we always use a direct solver

% Linear Solver
data.LinearSolver.type           = 'backslash'; % MUMPS, backslash, gmres
% Preconditioner
data.Preconditioner.type         = 'None'; % AdditiveSchwarz, None, ILU

Set time parameters for the BDF scheme (only for unsteady simulations)

% Time options
data.time.BDF_order = 2;
data.time.t0        = 0;
data.time.tf        = 2*pi;
data.time.dt        = 2*pi/20;

Main file

Set the spatial dimension: 2 for 2D simulations, 3 for 3D simulations

% spatial dimension
dim      = 3;

Set the finite element space (either linear or quadratic finite elements)

% FE space
fem = 'P1';% 'P1', 'P2'

Load the mesh saved in the msh format

%% load mesh
[vertices, boundaries, elements] = msh_to_Mmesh('SliceCube', dim);

Launch the Elliptic_Solver for steady simulations or the ADRt_Solver for unsteady simulations

%% Steady simulation
[U, FE_SPACE, MESH, DATA]  = Elliptic_Solver(dim, elements, vertices, boundaries, fem, 'datafile', [], 'SolutionSteady_');
%% Unsteady simulation
[U, FE_SPACE, MESH, DATA]  = ADRt_Solver(dim, elements, vertices, boundaries, fem, 'datafile', [], 'SolutionUnsteady_');

Open the VTK files with Paraview to visualize and postprocess the solution.