How do I create a boundary file for the Partial Differential Equation Toolbox?

2 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 5 Nov 2020
Edited: MathWorks Support Team on 5 Nov 2020
The Boundary Condition matrix (bl) can also be saved into a boundary file, with a .m extension, for later use with the WBOUND function.
For each column in the Decomposed Geometry matrix there must be a corresponding column in the Boundary Condition matrix. The format of each column is according to the list below:
Row one contains the dimension N of the system.
Row two contains the number M of Dirichlet boundary conditions.
Row three to 3 + N^2 - 1 contain the lengths for the strings representing q. The lengths are stored in column-wise order with respect to q.
Row 3 + N^2 to 3 + N^2 +N- 1 contain the lengths for the strings representing g.
Row 3 + N^2 + N to 3 + N^2 + N + MN - 1 contain the lengths for the strings representing h. The lengths are stored in column-wise order with respect to h.
Row 3 + N^2 + N + NM to 3 + N^2 + N + MN + M - 1 contain the lengths for the strings representing r.
The following rows contain MATLAB text expressions representing the actual boundary condition functions. The text strings have the lengths according to above. The MATLAB text expressions are stored in column-wise order with respect to matrices h and q. There are no separation characters between the strings. You can insert MATLAB expressions containing the following variables:
- The 2-D coordinates x and y
- A boundary segment parameter s, proportional to arc length. s is 0 at the start of the boundary segment and increases to 1 along the boundary segment in the direction indicated by the arrow.
- The outward normal vector components nx and ny. If you need the tangential vector, it can be expressed using nx and ny since tx = -ny and ty = nx.
- The solution u (only if the input argument u has been specified)
- The time t (only if the input argument time has been specified)
For example, refer to the cardioid example on page 5-58 of the 'Partial Differential Equation Toolbox' documentation. The boundary file is 'cardb.m' and the boundary condition matrix is bl. According to the example, the boundary conditions are a Dirichlet BC, u=0. In this case, note the following:
1. N=1 and M=1
2. h='1' r='0' q='0' g='0'
3. There will be 4 columns because the Geometry file cardg.m has 4 boundaries.
4. Accoring the format mentioned above the bl matrix is
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
48 48 48 48
48 48 48 48
49 49 49 49
48 48 48 48
Row one contains the dimension N of the system, which is 1 since there is 1 PDE.
Row two contains the number M of Dirichlet boundary conditions, 1.
Row three to 3 + N^2 - 1 (rows 3-3) contain the lengths for the strings representing q. Since it is a single character, this length is 1.
Row 3 + N^2 to 3 + N^2 +N- 1 (rows 4-4) contain the lengths for the strings representing g, which is again 1.
Row 3 + N^2 + N to 3 + N^2 + N + MN - 1 (rows 5-5) contain the lengths for the strings representing h.
Row 3 + N^2 + N + NM to 3 + N^2 + N + MN + M - 1 (rows 6-6) contain the lengths for the strings representing r.
Row 7 has the value for q which is zero (note that '0' has the ASCII value 48.)
Row 8 has the value for g which is zero (note that '0' has the ASCII value 48.)
Row 9 has the value for h which is one (note that '1' has the ASCII value 49.)
Row 10 has the value for r which is zero (note that '0' has the ASCII value 48.)
NOTE: The function DOUBLE converts a char array to a double array containing the ASCII values of the characters.
For more information on the boundary files, please refer to the following URL:

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!