next up previous contents
Next: Compilation Up: Selecting Examples Previous: Selecting Examples   Contents

Structure of Example files

The set of routines and its functionalists in an Example file will be discussed here. Let us consider an example file for a stationary convection-diffusion equation. Four main functions defined in an Examples File are :

  1. Exact solution
    \begin{lstlisting}
void Exact(double x, double y, double *values)
{
values[0] =...
...n(Pi*x)*cos(Pi*y);
values[3] = -2*Pi*Pi*sin(Pi*x)*sin(Pi*y);
}
\end{lstlisting}
    Here, values[0],..., values[3] are the exact solution $ u(x,y)$ of the problem, partial derivative of $ u(x,y)$ w.r.t $ x$ , partial derivative of $ u(x,y)$ w.r.t $ y$ and Laplacian of $ u(x,y)$ , respectively. Note that the Exact() routine will be called only if MEASURE_ERRORS: 1, that is, only when the approximation error is calculated in computations.
  2. Imposing boundary condition
    \begin{lstlisting}
void BoundCondition(int BdComp, double t, BoundCond &cond)
{
if(BdComp==1)
cond = NEUMANN;
else
cond = DIRICHLET;
}
\end{lstlisting}
    Here, the BdComp is the ID of the boundary component in the domain. Based on the values of BdComp, different boundary conditions (DIRICHLET, NEUMANN, ROBIN, SLIP, FREESURF, SLIP_FRICTION_PENETRATION_RESISTANCE, etc) can be set. Note that the routine for imposing boundary condition in 3D will be
    \begin{lstlisting}
void BoundCondition(int BdComp, double x, double y,
double z, BoundCond &cond),
\end{lstlisting}
    and the boundary conditions can be set based on the (x,y,z) coordinates of the boundary.

  3. Setting boundary values
    \begin{lstlisting}
void BoundValue(int BdComp, double Param, double &value)
{
s...
...(BdComp==1)
value = -eps*Pi*sin(Pi*Param);
else
value = 0;
}
\end{lstlisting}
    Here, again the BdComp is the ID of the boundary component in the domain and based on the values of BdComp, boundary values for different boundary conditions can be set. Note that the routine BoundValue( ) will be called from the assemble routine for every quadrature point on the boundary integral.

    In 2D, the important parameter in this routine is Param, which is a parametrized/scaled length $ [0,1]$ of each boundary in the domain. For example, consider the rectangular domain $ [0,0]\times[5,2]$ , then the (x,y) coordinated values can be obtained from Param as described in Figure [*].

    Figure: Defining boundary values in ParMooN, where the orientation of the boundaries is always anti-clockwise.
    1cm
    \begin{picture}(8, 3)
\put(1.,-1.25){\makebox(6,5){\includegraphics[width=6cm]{p...
...=3, Param = 1 to 0 }}
\put(-3.1,1){ {\tt x = 0, y=2*(1 - Param) }}
\end{picture}

    Note that the routine for imposing boundary values in 3D will be
    \begin{lstlisting}
void BoundValue(int BdComp, double x, double y,
double z, double &value)
\end{lstlisting}
    and thus, the $ (x,y,z)$ coordinate values are input values so no need to calculate.

    Imposing the boundary condition and boundary values for Navier-Stokes problems is similar as above, but needs to be imposed for every component of the velocity vector.

  4. Setting problem data

    All data (diffusion $ \epsilon$ , convection $ \textbf{b}=(b_1,b_2)$ in 2D, reaction $ c$ , source $ f$ ) of the problem can be set by using the below routine, which will be called from the assemble routine for every cell in the mesh.
    \begin{lstlisting}
void BilinearCoeffs(int n_points, double *x, double *y,
doub...
... = 0;
coeff[4] = (2*Pi*Pi*eps)*sin(Pi*x[i])*sin(Pi*y[i]);
}
}
\end{lstlisting}
    Here, n_points is the number of quadrature points in the cell, x[], y[], z[] are the quadrature points in the cell. Further, the input values coeff[0],..., coeff[4] are $ \epsilon$ , $ b_1$ , $ b_2$ , $ c$ and $ f$ , respectively, need to be given for every quadrature point in the cell.

Example 1: Considered a stationary convection diffusion equation with Dirichlet boundary condition, that is,

$\displaystyle -\frac{1}{\text{Pe}} \Delta {u} + \textbf{b}\cdot \nabla {u} + c {u}$ $\displaystyle = {f}$   in $\displaystyle \Omega :=(0,~1)^2$    
$\displaystyle u$ $\displaystyle = u_D$   on $\displaystyle \partial\Omega,$    

Here, the user chosen parameters $ \epsilon$ , $ \textbf{b}=(b_1,b_2)$ , $ c$ , $ f$ and boundary data can be defined in the routine BilinearCoeffs( ) of the Example file, as described in Section [*]. For the considered model, open the Example file
Plane.h
and update it, if needed. This file can be found in the /ParMooN/Examples/CD_2D folder. Next, open the Main program, that is, for the considered model open
CD2D_ParMoon.C
This file can be found in the /ParMooN/2D_Programs folder. Finally, include the chosen example file (Plane.h) in the main program. Now the ParMooN is ready to compile.


next up previous contents
Next: Compilation Up: Selecting Examples Previous: Selecting Examples   Contents
Sashi 2016-11-26