How can I prescribe boundary conditions in the FEATool physics modes (programmatically)

Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I prescribe boundary conditions in the FEATool physics modes (programmatically)

mikeg
Similar to the question on setting equation coefficients in the FEATool fea physics struct https://forum.featool.com/How-to-set-FEATool-equation-coefficient-in-MATLAB-programmatically-td2108.html, what is the correct syntax and format for prescribing boundary conditions.
Reply | Threaded
Open this post in threaded view
|

Re: How can I prescribe boundary conditions in the FEATool physics modes (programmatically)

Precise Simulation
Administrator
Note! Similar to for equation/subdomain coefficients, the next release will introduce a helper function ("setbdrcoef") that will allow more selecting and prescribing boundary conditions more easily.

Boundary conditions are specified in `fea.phys.(mode_tag).bdr` using two fields:

- sel selects the boundary-condition type for each boundary.
- coef contains the values or expressions for each type.

For an external boundary, the general syntax is:

fea.phys.(mode).bdr.sel(ibdr) = itype;
fea.phys.(mode).bdr.coef{itype,end}{ivar,ibdr} = value;

Here, itype is the row in the boundary-condition table, ivar is the dependent-variable index within that physics mode, and ibdr is the boundary number. The final table column (end) contains a cell array with dependent variables along rows and boundary numbers along columns.

For example, assuming a Poisson physics mode (poi) has already been added to a model with four external boundaries:

% Poisson: type 1 = Dirichlet, type 2 = Neumann.
fea.phys.poi.bdr.sel = [1 2 1 2];

% Prescribed solution values on boundaries 1 and 3.
fea.phys.poi.bdr.coef{1,end} = {0, 0, 'x+y', 0};

% Homogeneous Neumann conditions on boundaries 2 and 4.
fea.phys.poi.bdr.coef{2,end} = {0, 0, 0, 0};

Only the coefficient row selected by sel(ibdr) is used on that boundary. To change just one value, for example, prescribe u = 5 on boundary 3, use:

fea.phys.poi.bdr.sel(3) = 1;
fea.phys.poi.bdr.coef{1,end}{1,3} = 5;

The type numbers depend on the physics mode. Inspect the coefficient names and descriptions with:

fea.phys.poi.bdr.coef(:,1:3)

For instance, in the standard 2D Navier-Stokes physics mode, type 2 is a velocity inlet. For an inlet at boundary ibdr:

fea.phys.ns.bdr.sel(ibdr) = 2;
fea.phys.ns.bdr.coef{2,end}{1,ibdr} = '4*y*(1-y)'; % u
fea.phys.ns.bdr.coef{2,end}{2,ibdr} = 0;           % v

This example profile assumes 0 <= y <= 1. The same indexing pattern is used in the channel-flow example.

Values can be numeric scalars or character expressions involving coordinates, time, and solution variables; see Coefficients and Expressions.

After setting the physics-mode boundary conditions, parse the model before solving:

fea = parsephys(fea);
fea = parseprob(fea);