# HOWTO

HOWTO collection's main purpose is to make easier a fast start with BEMLab software. Examples presented in this section are directed to novice BEMLab users as well as advanced developers. Examples show main BEMLab abilities with simple and complex problems.

## Example

Let's say that we want to solve the problem of the specified geometry using the chosen Partial Differential Equation (PDE). First of all the mesh of the geometry has to be created and saved in the .m file which is a BEMLAB input/output data format compatible with Matlab[1], Octave [2] and Scilab [3]. Then boundary conditions and domain function parameters (if any) have to be added to the same file or the separate one. BEMLAB supports multiple input files. Finally, the following shell command can be run to start calculations:

% obem_solve -i input.m -m 1234 -o output.m

where option `-i`

defines the input file, `-o`

defines the output file, and `-m`

defines what exactly has to be done.
Now, potential u and its normal derivative q values are all known for all boundary elements and they are written into the `output.m`

file.

### Example 1 -- 2D capacitor

The below example presents the 2D problem modelling the capacitor. The problem geometry, boundary conditions and equation type are all included in the file `ex2d_const_capacitor.m`

. This file is distributed with the BEMLAB source code. The geometry consists of 4 boundary elements. Potential and its normal derivative are interpolated using constant interpolation functions. The problem is defined by Poisson's equation. On one boundary element (no. 1) potential of 0V was set, whereas on the opposite one (no. 3) potential of 10V was set. On boundary elements 2 and 4 zero Neumann boundary condition was set .

% cat /usr/share/bemlab/share/ex2d_const_capacitor.m % % DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. % % $Id: ex2d_const_capacitor.m 14 2011-11-03 22:56:41Z pwieleba $ % % % BEMLAB - a boundary element method software % % Copyright (C) 2006-2010 Paweł Wieleba % % This file is part of BEMLAB. % % BEMLAB is free software: you can redistribute it and/or modify % it under the terms of the GNU Lesser General Public License version 3 % only, as published by the Free Software Foundation. % % BEMLAB is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU Lesser General Public License version 3 for more details % (a copy is included in the COPYING.LESSER and COPYING files % that accompanied this code). % % You should have received a copy of the GNU Lesser General Public License % version 3 along with BEMLAB. If not, see <http://www.gnu.org/licenses/>. % % % Example problem in BEMLAB data format: mesh and boundary conditions. % nodes=[ 0, 0; 5, 0; 10, 0; 10, 5; 10, 10; 5 , 10; 0, 10; 0, 5 ]; % elementsGeom=[ 1, 3; 3, 5; 5, 7; 7, 1 ]; % 4 elementsU=[ 2; 4; 6; 8 ]; % 4 elementsQ=[ 2; 4; 6; 8 ]; % 4 elementTypeGeom=['LineLinear']; elementTypeU=['LineConst']; elementTypeQ=elementTypeU; elements_1=[ 1 2 3 4 ]; dirichletElements=[ 1, 3 ]; % 2 dirichletBC=[ 0; 10; ]; % 2 neumannElements=[ 2, 4 ]; % 2 neumannBC=[ 0; 0 ]; % 2 methodType_1=['poisson'];

To run BEM calculations using BEMLAB software run the following command:

% obem_solve -i /usr/share/bemlab/share/ex2d_const_capacitor.m -m 1234 -o /tmp/sol.m

The result is written into `/tmp/sol.m`

file.

% cat /tmp/sol.m uqNodes=[ 2 4 6 8 ]; % uqNodes(1,4) boundaryPotentialUQNodes=[ 0; 5.00025; 10; 5.00025 ]; % boundaryPotentialUQNodes(4,1) boundaryDerivativeElementsNodes=[ -1.22128; 0; 1.22105; 0 ]; % boundaryDerivativeElementsNodes(4,1)

The potential (`boundaryPotentialUQNodes`

matrix) and its normal derivative (`boundaryDerivativeElementsNodes`

matrix) values were calculated for nodes 2, 4, 6 and 8 of the `nodes`

matrix from the input file `ex2d_const_capacitor.m`

as matrix `uqNodes`

values state.

#### Example 1 -- 2D capacitor -- Calculate internal nodes potential

% cat /usr/share/bemlab/share/ex2d_const_capacitor_internalNodes.m internalNodes=[ 5, 5; ]; % internalNodes_1=[ 1 ];

To calculate potential of internal nodes run:

% obem_solve -i /usr/share/bemlab/share/ex2d_const_capacitor.m -m 5 -S /tmp/sol.m -I /usr/share/bemlab/share/ex2d_const_capacitor_internalNodes.m -o /tmp/internalNodes_potential.m