Modular Modeling >> Getting started > Example on a cube (3D)

Example on a cube (3D)

Let start with a very simple 3d example.

Start MmodD

First, we launch the toolbox tabs MmodD (case sensitive) by writing :

MmodD

Then, we can see the "MmodD" Menu on the right corner of the screen.

Create a simple mesh

Initialize a simple mesh on a unit 3-dimensional cube, and name it 'th3d' :

th3d=tcube3d(20,20,20)
meshtool(th3d)

The result is a mesh 8000 points and 41 154 tetrahedra.

tcube3d :

It's a 3-dimensional cube with 6 borders (North "N", South "S", East "E", West "W", Up "U" and Down "D").

Create a variable and an equation

Define an empty variable of type p1 on the previous mesh :

u=p1(th3d)

Define a new problem associated with your new variable, and name this problem 'mypb' for example :

mypb=pde(u)

Then, you can choose an equation :

mypb.eq="-Laplace(u)=1"

You can also change the boundary conditions :

mypb.S="Id(u)=1"
mypb.E="Dn(u)=y"
mypb.W="Dn(u)+Id(u)=sin(y)"   
mypb.U="Id(u)=1+x"
mypb.D="Id(u)=1+x"

See other help topics to see the exact syntax to change the equations.

Assemble and Solve the equation

Assemble the problem, before solving it :

assemble(mypb)
lsolve(mypb)
vartool(u)

See the result

You can visualize the result by clicking on 'vartool' in the 'MmodD' menu.

If paraview is installed, you can try

paraview(u)

Authors

  • Pallotta Q.