Write custom function for defining boundary conditions


[qmatrix,gmatrix,hmatrix,rmatrix] = pdebound(p,e,u,time)


The Boundary file specifies the boundary conditions of a PDE problem.

The most general form of boundary conditions that we can handle is


By the notation n·(cu) we mean the N-by-1 matrix, where N is the dimension of the system, with (i,1)-component


where the outward normal vector of the boundary n=(cos(α),sin(α)). There are M Dirichlet conditions and the h-matrix is M-by-N, M ≥ 0. The generalized Neumann condition contains a source hμ where the Lagrange multipliers µ is computed such that the Dirichlet conditions become satisfied.

The data that you specify is q, g, h, and r.

For M = 0 we say that we have a generalized Neumann boundary condition, for M = N a Dirichlet boundary condition, and for 0 < M < N a mixed boundary condition.

The Boundary file [qmatrix,gmatrix,hmatrix,rmatrix] = pdebound(p,e,u,time) computes the values of q, g, h, and r, on the a set of edges e.

The matrices p and e are mesh data. e needs only to be a subset of the edges in the mesh. Details on the mesh data representation can be found in the entry on initmesh.

The input arguments u and time are used for the nonlinear solver and time stepping algorithms, respectively. u and time are empty matrices if the corresponding parameter is not passed to assemb. If time is NaN and any of the function q, g, h, and r depends on time, pdebound must return a matrix of correct size, containing NaNs in all positions, in the corresponding output argument. It is not possible to explicitly refer to the time derivative of the solution in the boundary conditions.

Similarly, if an output argument depends on u, then the output argument must return a matrix of NaN of the correct size if the input u is NaN. This requirement signals to the solver, such a parabolic or hyperbolic, that the argument depends on time or the solution u.

The solution u is represented by the solution vector u. Details on the representation can be found in the entry on assempde.

qmatrix and gmatrix must contain the value of q and g on the midpoint of each boundary. Thus we have size(qmatrix) = [N^2 ne], where N is the dimension of the system, and ne the number of edges in e, and size(gmatrix) = [N ne]. For the Dirichlet case, the corresponding values must be zeros.

hmatrix and rmatrix must contain the values of h and r at the first point on each edge followed by the value at the second point on each edge. Thus we have size(hmatrix) = [N^2 2*ne], where N is the dimension of the system, and ne the number of edges in e, and size(rmatrix) = [N 2*ne]. When M < N, h and r must be padded with NM rows of zeros.

The elements of the matrices q and h are stored in column-wise ordering in the MATLAB® matrices qmatrix and hmatrix.


For the boundary conditions


the following values should be stored in qmatrix, gmatrix, hmatrix, and rmatrix

qmatrix = [ ... 2 ... ]

gmatrix = [ ... 3 ... ]

                1     1 
hmatrix = [ ... 0 ... 0 ... ] 
               -1    -1
                0     0

rmatrix = [ ... 2 ... 2 ... ]
                0     0
Was this topic helpful?