Tag: algorithm

I’ve been working on proper orthogonal decomposition (POD) for a while. Though it’s nice to have packages such as modred out there, I cannot help myself writing a snippet using R, since lots of my previosu data processing was in that language. Without all the theory chitchat like K-L transformation, from the the implementation-on-discrete-data perspective the (snapshot) POD method boils down to just singular value decomposition (SVD), and it’s out of box in R, which makes the task mostly straightforward. That’s why a POD function in R essentially calls svd in R (and it further calls LAPACK routines DGESDD and ZGESVD.):

Here “nmod” is the number of POD modes to be retrieved. Though it’s default to be the length of each snapshot, it’s rarely necessary this large. Mostly of the time a reasonable correlated set of snapshots requires less than 10 modes to obtain most of the system energy.

With pod of data “arr” obtained, we can do several thing immediately. We can obtain the modes by retrieving the right singular vector:

Code below is to solve the static version of the equation in previous FDM code demo, with B.C. changed as homogeneous. The Jacobi method is used to replace the LAPACK solver which gives inexact method. The exact solution is
Using initial guess as
one can see that most of the computing cost is spent on smoothing lowest mode.

Alpha shape is a generalized way determining the geometric objects by a set of points, of which convex hull is a special case. It can be applied to FEM for boundary recognition. Essentially this method identifies the boundary of a set of points by eliminating those triangles (generated by triangulation of the points) which can be put into empty circles whose diagram are defined by threshold alpha. It is intuitive for a more simple criteria: eliminating the triangles whose circumcircles contains no points in the defined set. Below is a simple demo by Mathematica which tries to identify the boundary of a subset of points within circle radius 5 from a set points randomly distributed. The red arc isolates the point set inside, the first step is to eliminate the triangles whose circumcirlces contains no points in , the next step is to eliminate the triangles contain nodes other than those in . More delicate results can be reached by tuning alpha circle instead of using simple circumcirlces.

3D version implementation of Bowyer/Watson algorithm is almost the same as the 2D. Instead of eliminating lines that belong only to the triangles whose circumcirlce contains the newly added point, in 3D we eliminate the facets that belong only to the tetrahedra whose circumsphere contains the newly added point, then form new tetrahedra by appending new point to those facets’ nodes. Here is an example generated by Mathematica scripts I compiled. Below on the right is tetrahedronization of 200 random points, together with enclosing tetrahedron. On the left is he tetrahedrons generated by first two points.

DistMesh is no doubt the most interesting way meshing a domain, simple and elegant. There is a MATHEMATICA version of the original Matlab code, but only in 2D. Base on that, I wrote a script for mesh test. Hopefully continue working on this one would bring some application to my research. Here is one simple case of generating a non-uniform mesh within a circle, whose distance funtion is the easist to define. At the end of termination, most of the ill-shaped triangles are corrected.