# MATLAB Codes

## KMG2D Mesh Generator

kmg2d is a 2D mesh generator
based on signed distance function, i.e.
the domain Ω must be defined as

Ω={x | φ(x)<0}

where φ is a real-valued function defined on R^{2}.
The code generates unstructured (linear or quadratic) triangular mesh.
The mesh size is automatically adapted to the "thickness" of the
computational domain, using a geometric mesh size function based
on distance from the medial axis. The medial axis is the set of
interior points that have equal distance to two or more points on the
boundary. Computing the medial axis of a domain is a non trivial
problem. To save computational time, the code uses an approximate
medial axis set. The code can also use a user supplied mesh size
function.

The names of the functions and their purposes:

- kmg2d.m
the mesh generator, designed to generate medium-scale meshes
- kmg2dref.m
the fast mesh refinement function
- hgeom.m
the geometric mesh size function

Package: kmg2d

Reference : J. Koko, A MATLAB mesh generator for the
two-dimensional finite element method, Applied Mathematics and Computation
250, 650-664 (2015).

### Gallery

### KMG3D (in progress)

## KPDE

kpde is a vectorized MATLAB library of P^{1} finite
element
assembling functions for the numerical solution of the Poisson problem
and the linear elasticity problem in 2D/3D. Cell-arrays are used to
store the gradient of the element basis functions. The resulting

vectorized MATLAB implementation is close to the standard form. The
code consists of 3 sets of functions

- kpde2d/kpde3d vectorized
functions for the general 2D/3D
scalar Partial Differential Equation

−∇.(ν(x)∇
u(x))+α(x)u(x)=f(x) in Ω

- kelas2d/kelas3d
vectorized function for 2D/3D linear elasticity problem

−∇.σ(u(x))=f(x) in Ω.

- Pre and post-preocessing functions: uniform mesh generation
(kpde2dumsh, kpde3dumsh), visualization (kpde2dcont, kpde3dshow,
kelas2dshow, kelas3dshow), ...

Package: kpde

Reference: J. Koko, Fast MATLAB assembly of FEM matrices in 2D and 3D
using cell-array approach, International
Journal of Modeling, Simulation and Scientific Computing, to
appear, DOI: 10.1142/S1793962316500100

## KSTOK

kstok is a vectorized MATLAB
assembling functions for the numerical solution of Stokes problem using
P^{1}-bubble/P^{1} and P^{1}-Stab finite
element in 2D and 3D. The implementation uses cell-array to store
the gradient of the element basis functions. Consequently,

the current code is about two times faster than the previous one (see
below). Note that, the code shares some functions with kpde package.

Package: available soon

### Old versions (2D)

- Stokes problem 1 :
Vectorized Matlab codes with P1-bubble/P1 finite element
- Stokes problem 2 :
Vectorized Matlab code for Uzawa Conjugate gradient method with
P1-iso-P2/P1 finite element

# CUDA Codes

## PCGSSOR

Conjugate Gradient algorithm Preconditioned by Symmetric Successive
OverRelaxation Approximate Inverse (SSOR - AI). The
preconditioning matrix, computed using a Neumann expansion, is used
through sparse matrix-vector multiplication. The proposed
preconditioner is then well-suited for massively parallel architectures
like GPUs.

Package: available soon.

J. koko Mar 2016

_{
}