murge.c

Example that generate A Laplacian with multiple degrees of freedom and solves it.

That example only works with the -DDISTRIBUTED option.

The laplacian looks like :

   1       0                      ... 0
-2(n-1)  (n-1)  -2(n-1)   0       ... 0
   0    -2(n-1)  (n-1)  -2(n-1) 0 ... 0
             ....
             ....
   0 ...              -2(n-1)  n-1  -2(n-1)
   0 ...                        0     1

The Right-hand-side member is defined by

The solution should be

The solution is stored in the file “result.plot” that can be ploted using

gnuplot> plot "./result.plot" u 2:3 t "reference", "./result.plot" u 2:4 t "Result, first degree of freedom"

Usage

./murge <size> <DofNbr>

Authors

Xavier LACOSTElac.nosp@m.oste@labr.nosp@m.i.fr
Summary
murge.cExample that generate A Laplacian with multiple degrees of freedom and solves it.
GetCoefFunction GetCoef
GetRhsFunction GetRhs
storeFunction store
main

GetCoef

void GetCoef(COEF *matElem,
INTS i,
INTS j,
double xmin,
double xmax,
INTS n,
INTS dof)

Function GetCoef

Computes the value for a given coefficient.

Parameters

valValue to set
iRow of the coefficient.
jColumn of the coefficient.
xminMinimum value of the interval.
xmaxMaximum value of the interval.
nNumber of points in the interval.

GetRhs

void GetRhs(COEF *val,
INTS i,
double xmin,
double xmax,
INTS n)

Function GetRhs

computes the value of a coefficient of the Right-hand-side member.

Parameters

valValue to set.
iIndex of the value.
xminMinimum value of the interval.
xmaxMaximum value of the interval.
nNumber of points in the interval.

store

void store(COEF *sol,
double xmin,
double xmax,
INTS n,
INTS dof)

Function store

Write the solution into a file result.plot.

The file contains :

k x sin(2 \pi x) sol(k:k+dofnbr-1)

Where k goes from 1 to n*dofnbr, dofnbr by dofnbr and x goes from xmin to xmax, with a step of (xmax - xmin) / (n-1).

Parameters

solThe solution of the problem
xminThe minimum value of the interval.
xmaxThe maximum value of the interval.
dofThe Number of degree of freedom.

main

int main(int argc,
char **argv)
void GetCoef(COEF *matElem,
INTS i,
INTS j,
double xmin,
double xmax,
INTS n,
INTS dof)
Function GetCoef
void GetRhs(COEF *val,
INTS i,
double xmin,
double xmax,
INTS n)
Function GetRhs
void store(COEF *sol,
double xmin,
double xmax,
INTS n,
INTS dof)
Function store
int main(int argc,
char **argv)
Close