Examples

In the sequel, we present different examples, implementd in Fortran, to solve different (systems of) partial differential equations.

TODO

Helmoltz 1d

Example 1

In this first example we solve

Poisson 1d

Available examples

Homogeneous Dirichlet boundary conditions I

In the following examples, the homogeneous dirichlet boundary conditions are directly applied in the finie element space by removing the interpolatory basis functions.

  • ex01_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file. This file has been described in the previous chapter.

Periodic boundary conditions

  • ex02_01.F90 solves Poisson equation with periodic boundary conditions on a line using a simulation parameters file and a penalized linear operator.

Homogeneous Dirichlet boundary conditions II

The following examples solves Poisson equation with homogeneous Dirichlet boundary conditions applied in a strong form using a penalization method.

  • ex03_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file.

Todo

ex03_01 not yet validated

Neumann boundary conditions

The following examples solves Poisson equation with Neumann boundary conditions.

  • ex04_01.F90 solves Poisson equation with Neumann boundary conditions on a line using a simulation parameters file.
  • ex04_02.F90 solves Poisson equation with Neumann boundary conditions on a line using a simulation parameters file.

Todo

ex04_02 not yet validated

Multigrid and GLT

  • ex05_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file and a geometric multigrid for B-Splines.
  • ex05_02.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file and the B-Splines GLT smoother as a solver.
  • ex05_03.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file and a geometric multigrid for B-Splines using the GLT smoother.
  • ex05_04.F90 solves Mass matrix with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file and a B-Splines GLT smoother as a solver.

Todo

move all Multigrid examples to a new directory and write a report for it

ex02_01.F90

In this example we solve the Poisson equation on \Omega=[-2, 2] with periodic boundary conditions

- u^{\prime \prime} = (2 \pi)^2 \cos( 2 \pi x ),& ~ ~ \Omega

where the analytical solution is defined as

u(x) = \cos( 2 \pi x )

Source file

The source file can be found in fema/tutorials/examples/1d/poisson/ex02_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/1d/poisson/periodic input

Then, you can execute the binary file using:

> bin/poisson_1d_ex02_01 input/parameters_sim_1d.nml input/solver_driver.nml
 >>>> context
 * assembly id            1
 * dimension            1
 * ddm name default
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 <<<<
 >>>> context
 * assembly id            1
 * dimension            1
 * ddm name default
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            0
 partitioner_name : DEFAULT
 ddm_dim          :            1
 n_procs         :            1
 <<<<<
Assembly time =  0.000 seconds, on         64 elements.
 * mgmres:  convegence after          15  iterations. Error    2.2616663574154395E-009
Assembly time =  0.004 seconds, on         64 elements.
 >> norms :
   1.3198671325138479E-006   1.3558593778521907E-005

In the case of periodic boundary conditions, the stiffness matrix is singular and using a direct solver is not working anymore. A way to encounter this situation is to use an iterative method with a penalized linear operator. This can be done directly in our parameters file associated to the concrete we are using. Let’s take a look at the file solver_driver.nml:

> more input/solver_driver.nml
&linear_solver

SOLVER_NAME="mgmres"
SOLVER_FILENAME="input/solver_mgmres.nml",

/

You see that we are using the solver mgmres as a concrete type. Let’s take a look to the corresponding parameters file:

> more input/solver_mgmres.nml
&linear_solver

INT_MAXITER=3000
INT_RESTART=30
REAL_ATOL=1.d-8
REAL_RTOL=1.d-8
INT_VERBOSE=1
INT_NULL_SPACE=1

/

Now the important attribut is the INT_NULL_SPACE. When it is set on 1 then PLAF will automatically create a penalized linear operator, that will be used instead of the provided matrix / linear operator, whenever we apply the dot operator (think of it as a generalization of the matrix-vector product).

Note

The geometry is created by the subroutine spl_mapping_linear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex04_01.F90

In this example we solve the Poisson equation on \Omega = [0, 1] with Neumann boundary conditions

- \nabla^2 u + u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(k_1 ( x - x_c ))

where

k_1 = \frac{\pi}{3}
\\
x_c = \frac{1}{3}

Source file

The source file can be found in fema/tutorials/examples/1d/poisson/ex04_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/1d/poisson/neumann_ex2 input

Then, you can execute the binary file using:

> bin/poisson_1d_ex04_01 input/parameters_sim_1d.nml input/solver_driver.nml
 >>>> context
 * assembly id            1
 * dimension            1
 * ddm name default
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 <<<<
 >>>> context
 * assembly id            1
 * dimension            1
 * ddm name default
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            0
 partitioner_name : DEFAULT
 ddm_dim          :            1
 n_procs         :            1
 <<<<<
 >> norms :
   3.9641882510916570E-008   6.8661753003540677E-008   0.0000000000000000

Note

The geometry is created by the subroutine spl_mapping_linear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex04_02.F90

In this example we solve the Poisson equation on \Omega = [0, 1] with Neumann boundary conditions

- \nabla^2 u + u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(k_1 ( x - x_c ))

where

k_1 = \frac{\pi}{3}
\\
x_c = \frac{1}{3}

Source file

The source file can be found in fema/tutorials/examples/1d/poisson/ex04_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/1d/poisson/neumann_ex2 input

Then, you can execute the binary file using:

> bin/poisson_1d_ex04_02 input/parameters_sim_1d.nml input/solver_driver.nml

Note

The geometry is created by the subroutine spl_mapping_linear

Plots

Todo

ex04_02 add plot

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml

Poisson 1d

Available examples

Homogeneous Dirichlet boundary conditions I

In the following examples, the homogeneous dirichlet boundary conditions are directly applied in the finie element space by removing the interpolatory basis functions.

  • ex01_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file. This file has been described in the previous chapter.

Periodic boundary conditions

  • ex02_01.F90 solves Poisson equation with periodic boundary conditions on a line using a simulation parameters file and a penalized linear operator.

Homogeneous Dirichlet boundary conditions II

The following examples solves Poisson equation with homogeneous Dirichlet boundary conditions applied in a strong form using a penalization method.

  • ex03_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file.

Todo

ex03_01 not yet validated

Neumann boundary conditions

The following examples solves Poisson equation with Neumann boundary conditions.

  • ex04_01.F90 solves Poisson equation with Neumann boundary conditions on a line using a simulation parameters file.
  • ex04_02.F90 solves Poisson equation with Neumann boundary conditions on a line using a simulation parameters file.

Todo

ex04_02 not yet validated

Multigrid and GLT

  • ex05_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file and a geometric multigrid for B-Splines.
  • ex05_02.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file and the B-Splines GLT smoother as a solver.
  • ex05_03.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file and a geometric multigrid for B-Splines using the GLT smoother.
  • ex05_04.F90 solves Mass matrix with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file and a B-Splines GLT smoother as a solver.

Todo

move all Multigrid examples to a new directory and write a report for it

ex02_01.F90

In this example we solve the Poisson equation on \Omega=[-2, 2] with periodic boundary conditions

- u^{\prime \prime} = (2 \pi)^2 \cos( 2 \pi x ),& ~ ~ \Omega

where the analytical solution is defined as

u(x) = \cos( 2 \pi x )

Source file

The source file can be found in fema/tutorials/examples/1d/poisson/ex02_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/1d/poisson/periodic input

Then, you can execute the binary file using:

> bin/poisson_1d_ex02_01 input/parameters_sim_1d.nml input/solver_driver.nml
 >>>> context
 * assembly id            1
 * dimension            1
 * ddm name default
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 <<<<
 >>>> context
 * assembly id            1
 * dimension            1
 * ddm name default
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            0
 partitioner_name : DEFAULT
 ddm_dim          :            1
 n_procs         :            1
 <<<<<
Assembly time =  0.000 seconds, on         64 elements.
 * mgmres:  convegence after          15  iterations. Error    2.2616663574154395E-009
Assembly time =  0.004 seconds, on         64 elements.
 >> norms :
   1.3198671325138479E-006   1.3558593778521907E-005

In the case of periodic boundary conditions, the stiffness matrix is singular and using a direct solver is not working anymore. A way to encounter this situation is to use an iterative method with a penalized linear operator. This can be done directly in our parameters file associated to the concrete we are using. Let’s take a look at the file solver_driver.nml:

> more input/solver_driver.nml
&linear_solver

SOLVER_NAME="mgmres"
SOLVER_FILENAME="input/solver_mgmres.nml",

/

You see that we are using the solver mgmres as a concrete type. Let’s take a look to the corresponding parameters file:

> more input/solver_mgmres.nml
&linear_solver

INT_MAXITER=3000
INT_RESTART=30
REAL_ATOL=1.d-8
REAL_RTOL=1.d-8
INT_VERBOSE=1
INT_NULL_SPACE=1

/

Now the important attribut is the INT_NULL_SPACE. When it is set on 1 then PLAF will automatically create a penalized linear operator, that will be used instead of the provided matrix / linear operator, whenever we apply the dot operator (think of it as a generalization of the matrix-vector product).

Note

The geometry is created by the subroutine spl_mapping_linear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex04_01.F90

In this example we solve the Poisson equation on \Omega = [0, 1] with Neumann boundary conditions

- \nabla^2 u + u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(k_1 ( x - x_c ))

where

k_1 = \frac{\pi}{3}
\\
x_c = \frac{1}{3}

Source file

The source file can be found in fema/tutorials/examples/1d/poisson/ex04_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/1d/poisson/neumann_ex2 input

Then, you can execute the binary file using:

> bin/poisson_1d_ex04_01 input/parameters_sim_1d.nml input/solver_driver.nml
 >>>> context
 * assembly id            1
 * dimension            1
 * ddm name default
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 <<<<
 >>>> context
 * assembly id            1
 * dimension            1
 * ddm name default
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            0
 partitioner_name : DEFAULT
 ddm_dim          :            1
 n_procs         :            1
 <<<<<
 >> norms :
   3.9641882510916570E-008   6.8661753003540677E-008   0.0000000000000000

Note

The geometry is created by the subroutine spl_mapping_linear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex04_02.F90

In this example we solve the Poisson equation on \Omega = [0, 1] with Neumann boundary conditions

- \nabla^2 u + u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(k_1 ( x - x_c ))

where

k_1 = \frac{\pi}{3}
\\
x_c = \frac{1}{3}

Source file

The source file can be found in fema/tutorials/examples/1d/poisson/ex04_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/1d/poisson/neumann_ex2 input

Then, you can execute the binary file using:

> bin/poisson_1d_ex04_02 input/parameters_sim_1d.nml input/solver_driver.nml

Note

The geometry is created by the subroutine spl_mapping_linear

Plots

Todo

ex04_02 add plot

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml

Projector 1d

Available examples

Homogeneous Dirichlet boundary conditions I

In the following examples, the homogeneous dirichlet boundary conditions are directly applied in the finie element space by removing the interpolatory basis functions.

  • ex01_01.F90 solves Mass operator with homogeneous Dirichlet boundary conditions on a line using a simulation parameters file. This file has been described in the previous chapter.

Maxwell Harmonic Domain 2d

In these examples, we solve the Maxwell Harmonic Domain problem in 2d. The problem in the strong form writes

\nabla \times \nabla \times \mathbf{u} + \mu \mathbf{u} = \mathbf{f},& ~ ~ \Omega

Weak formulation

Let \Vcurl = \mathbf{span} \{ \PsiPsi_i, ~ 1 \leq i \leq n \} be a discrete subspace of \Hcurl. The weak formulation using the natural boundary conditions writes

\mbox{Find}~ \uu \in \Vcurl, \mbox{such that}, ~ ~ \forall \vv \in \Vcurl

  \left( \Curl \uu, \Curl \vv  \right)_{\Omega}
+ \mu \left( \uu, \vv  \right)_{\Omega}
= \left( \ff, \vv  \right)_{\Omega}
+ \langle \left( \Curl \uu \right) \times \nn , \vv  \rangle_{\partial \Omega}

The weak formulation using the essential boundary conditions writes

\mbox{Find}~ \uu \in \Vcurl, \mbox{such that}, ~ ~ \forall \vv \in \Vcurl

  \left( \Curl \uu, \Curl \vv  \right)_{\Omega}
+ \mu \left( \uu, \vv  \right)_{\Omega}
= \left( \ff, \vv  \right)_{\Omega}
+ \langle \Curl \uu , \vv \times \nn  \rangle_{\partial \Omega}

Available examples

Essential boundary conditions

In the following examples, the essential boundary conditions are directly applied in the finie element space by removing the interpolatory basis functions.

  • ex01_01.F90 solves Harmonic Maxwell equation with essential boundary conditions on a square.
  • ex01_02.F90 solves Harmonic Maxwell equation with essential boundary conditions on a collela domain.

Periodic boundary conditions

  • ex02_01.F90 solves Harmonic Maxwell equation with periodic boundary conditions on a square.

Natural boundary conditions

  • ex03_01.F90 solves Harmonic Maxwell equation with natural boundary conditions on a square.
  • ex03_02.F90 solves Harmonic Maxwell equation with complex entries and natural boundary conditions on a square.

ex01_01.F90

In this example we solve the Maxwell Harmonic equation on a square [0,1] \times [0,1] domain. The analytical solution is defined as

\mathbf{u}(x,y) =
   \begin{pmatrix}
     \cos(k_1 x) \sin(k_2 y)
   \\
     \sin(k_1 x) \cos(k_2 y)
   \end{pmatrix}

Source file

The source file can be found in fema/tutorials/examples/2d/maxwell_hd/ex01_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/maxwell_hd/essential_ex1 input

Then, you can execute the binary file using:

> bin/maxwell_hd_2d_ex01_01 input/parameters_bspline.nml input/parameters_ddm.nml input/solver_driver.nml
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
 >>>>> parameters
 dimension  :            2
 n_elements :           16          16
 degrees    :            3           3
 procs      :            1           1
 bc_min     :            1           1
 bc_max     :            1           1
 <<<<<
Assembly time =  0.228 seconds, on        256 elements.
 * cg:  convegence after         279  iterations. Error    7.5095100007597058E-013
Assembly time =  0.016 seconds, on        256 elements.
 >> norms :
   3.1094776762578992E-005   0.0000000000000000        0.0000000000000000

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field_one_form.py ex_comp.nml ey_comp.nml mapping.nml
alternate text

Numerical solution \mathbf{E}_h

ex01_02.F90

In this example we solve the Maxwell Harmonic equation on a collela domain on a [0,1] \times [0,1] square. The analytical solution is defined as

\mathbf{u}(x,y) =
   \begin{pmatrix}
     \cos(k_1 x) \sin(k_2 y)
   \\
     \sin(k_1 x) \cos(k_2 y)
   \end{pmatrix}

Source file

The source file can be found in fema/tutorials/examples/2d/maxwell_hd/ex01_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/maxwell_hd/essential_ex1 input

Then, you can execute the binary file using:

> bin/maxwell_hd_2d_ex01_02 input/parameters_bspline.nml input/parameters_ddm.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.208 seconds, on        256 elements.
Assembly time =  0.020 seconds, on        256 elements.
 >> norms :
   2.3097985935819380E-003   0.0000000000000000        0.0000000000000000
.. note:: The geometry is created by the subroutine **spl_mapping_collela**.

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field_one_form.py ex_comp.nml ey_comp.nml mapping.nml
alternate text

Numerical solution E_h^x

alternate text

Numerical solution E_h^y

ex02_01.F90

In this example we solve the Maxwell Harmonic equation on a square [0,1] \times [0,1] domain using periodic boundary conditions. The analytical solution is defined as

\mathbf{u}(x,y) =
   \begin{pmatrix}
     \cos(k_1 x) \sin(k_2 y)
   \\
     \sin(k_1 x) \cos(k_2 y)
   \end{pmatrix}

Source file

The source file can be found in fema/tutorials/examples/2d/maxwell_hd/ex02_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/maxwell_hd/periodic_ex1 input

Then, you can execute the binary file using:

> bin/maxwell_hd_2d_ex02_01 input/parameters_bspline.nml input/parameters_ddm.nml input/solver_driver.nml
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
 >>>>> parameters
 dimension  :            2
 n_elements :           16          16
 degrees    :            3           3
 procs      :            1           1
 bc_min     :            1           1
 bc_max     :            1           1
 <<<<<
Assembly time =  0.236 seconds, on        256 elements.
 * cg:  convegence after           4  iterations. Error    6.1213575413070655E-013
Assembly time =  0.020 seconds, on        256 elements.
 >> norms :
   2.5676303971453100E-004   0.0000000000000000        0.0000000000000000

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field_one_form.py ex_comp.nml ey_comp.nml mapping.nml
alternate text

Numerical solution \mathbf{E}_h

ex03_01.F90

In this example we solve the Maxwell Harmonic equation on a square [0,1] \times [0,1] domain using natural boundary conditions. The analytical solution is defined as

\uu(x,y) =
   \begin{pmatrix}
     \sin{\left (k_{2} \left(y - yc\right) \right )} \cos{\left (k_{1} \left(x - xc\right) \right )}
     \\
     \sin{\left (k_{1} \left(x - xc\right) \right )} \cos{\left (k_{2} \left(y - yc\right) \right )}
   \end{pmatrix}

Source file

The source file can be found in fema/tutorials/examples/2d/maxwell_hd/ex03_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/maxwell_hd/natural_ex1 input

Then, you can execute the binary file using:

> bin/maxwell_hd_2d_ex03_01 input/parameters_bspline.nml input/parameters_ddm.nml input/solver_driver.nml
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
 >>>>> parameters
 dimension  :            2
 n_elements :           32          32
 degrees    :            3           3
 procs      :            1           1
 bc_min     :            2           2
 bc_max     :            2           2
 <<<<<
Assembly time =  0.664 seconds, on       1024 elements.
Assembly time on the boundary =  0.000 seconds, on         32 elements.
Assembly time on the boundary =  0.000 seconds, on         32 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time on the boundary =  0.000 seconds, on         32 elements.
Assembly time =  0.068 seconds, on       1024 elements.
 >> norms :
   3.0439859766756265E-005   0.0000000000000000        0.0000000000000000

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field_one_form.py ex_comp.nml ey_comp.nml mapping.nml
alternate text

Numerical solution \mathbf{E}_h

Todo

why is there a problem with the bounds of the first component? using paraviw it is correct. Probably a bug in our python scripts.

ex03_02.F90

In this example we solve the following equation on a square [0,1] \times [0,1] domain using natural boundary conditions.

\nabla \times \nabla \times \uu + \kappa \uu = \ff,& ~ ~ \Omega

where

\kappa = - \omega^2 \epsilon + i \omega \sigma

where

\omega = 1.0, \quad  \sigma = 1.0, \quad \epsilon = 1.0

Weak formulation

\mbox{Find}~ \uu \in \Vcurl, \mbox{such that}, ~ ~ \forall \vv \in \Vcurl

  \left( \Curl \uu, \Curl \vv  \right)_{\Omega}
+ \mu \left( \uu, \vv  \right)_{\Omega}
= \left( \ff, \vv  \right)_{\Omega}
+ \langle \left( \Curl \uu \right) \times \nn , \vv  \rangle_{\partial \Omega}

The analytical solution is defined as

\uu(x,y) =\uu_r(x,y) + i \uu_i(x,y)

where

\uu_r(x,y) =
   \begin{pmatrix}
     \cos(k_1^r x) \sin(k_2^r y)
   \\
     \sin(k_1^r x) \cos(k_2^r y)
   \end{pmatrix}
\quad \mbox{and} \quad
\uu_i(x,y) =
   \begin{pmatrix}
     \cos(k_1^i x) \sin(k_2^i y)
   \\
     \sin(k_1^i x) \cos(k_2^i y)
   \end{pmatrix}

Source file

The source file can be found in fema/tutorials/examples/2d/maxwell_hd/ex03_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/maxwell_hd/natural_ex1 input

Then, you can execute the binary file using:

> bin/maxwell_hd_2d_ex03_02 input/parameters_bspline.nml input/parameters_ddm.nml input/solver_driver.nml
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
 >>>>> parameters
 dimension  :            2
 n_elements :           16          16
 degrees    :            3           3
 procs      :            1           1
 bc_min     :            2           2
 bc_max     :            2           2
 <<<<<
Assembly time =  0.164 seconds, on        256 elements.
Assembly time on the boundary =  0.000 seconds, on         16 elements.
Assembly time on the boundary =  0.000 seconds, on         16 elements.
Assembly time on the boundary =  0.000 seconds, on         16 elements.
Assembly time on the boundary =  0.004 seconds, on         16 elements.
 error lapack lu :    5.7313884422133314E-016
Assembly time =  0.016 seconds, on        256 elements.
 >> norms :
   2.4572753632307818E-004   3.0796891495339608E-005   0.0000000000000000

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Todo

add plot for maxwell_hd_2d_ex03_02

Maxwell Time Domain 2d

Monge-Ampere 2d

Available examples

Validation of Monge-Ampere Solver

  • ex01.F90 solves Monge-Ampere solver with Neumann boundary conditions on a square [0,1] \times [0,1]

in this example the exact radial solution is: u(x,y) =  \text{exp}(\frac{x^2+y^2}{2})+C (C is constante) and the monitor equetion is: f(x,y) = (1+x^2+y^2)\text{exp}(x^2+y^2). don’t take an account the L^2 error beacouse of the consante C. the valide norm is the H^{1}_{0} one.

Equidistributed grid generation based on Monge-Ampere equation

  • ex02.F90 solves Monge-Ampere solver with Neumann boundary conditions on a square [0,1] \times [0,1]

in this example the monitor function f(x,y) = 1 + 5  \text{exp}(-50 | (x-0.5-t)^2 + (y-0.5)^2 - 0.09 | )

  • ex03.F90

Poisson 2d

Available examples

Homogeneous Dirichlet boundary conditions I

In the following examples, the homogeneous dirichlet boundary conditions are directly applied in the finie element space by removing the interpolatory basis functions.

  • ex01_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a square using a simulation parameters file. This file has been described in the previous chapter.
  • ex01_02.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a circle using a simulation parameters file.
  • ex01_03.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a quart-circle using a simulation parameters file.
  • ex01_04.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a annulus using a simulation parameters file.

Periodic boundary conditions

  • ex02_01.F90 solves Poisson equation with periodic boundary conditions on a square using a simulation parameters file and a penalized linear operator.

Homogeneous Dirichlet boundary conditions II

Todo

ex03_01 not yet validated

Todo

ex03_02 not yet validated

The following examples solves Poisson equation with homogeneous Dirichlet boundary conditions applied in a strong form using a penalization method.

  • ex03_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a square using a simulation parameters file.
  • ex03_02.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a circle using a simulation parameters file.

Neumann boundary conditions

The following examples solves Poisson equation with Neumann boundary conditions.

  • ex04_01.F90 solves Poisson equation with Neumann boundary conditions on a square using a simulation parameters file.
  • ex04_02.F90 solves Poisson equation with Neumann boundary conditions on a circle using a simulation parameters file.

Multigrid and GLT

  • ex05_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a square using a simulation parameters file and a geometric multigrid for B-Splines.
  • ex05_02.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a square using a simulation parameters file and the B-Splines GLT smoother as a solver.
  • ex05_03.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a square using a simulation parameters file and a geometric multigrid for B-Splines using the GLT smoother.
  • ex05_04.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a circle using a simulation parameters file and a geometric multigrid for B-Splines using the GLT smoother.

Mixed Dirichlet-Neumann boundary conditions

Todo

ex06_02 not yet validated

  • ex06_01.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a square using a simulation parameters file.
  • ex06_02.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a annulus using a simulation parameters file.
  • ex06_03.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a quart-circle using a simulation parameters file.

ex01_02.F90

In this example we solve the Poisson equation on a non-singular circular domain

- \nabla^2 u = 4,& ~ ~ \Omega
  \\
  u = 0,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = 1 - x^2 - y^2

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex01_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/dirichlet_ex1 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex01_02 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.248 seconds, on       1024 elements.
Assembly time =  0.048 seconds, on       1024 elements.
 >> norms :
   3.2505818279129479E-008   3.7987674746537319E-006

Note

The geometry is created by the subroutine spl_mapping_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex01_03.F90

In this example we solve the Poisson equation on a quart circle with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin, with Homogeneous Dirichlet boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  u = 0,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = x y \sin( \frac{\pi}{(r_{max}^2 - r_{min}^2)} (r_{max}^2 - x^2 - y^2))

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex01_03.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/dirichlet_ex1 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex01_03 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.252 seconds, on       1024 elements.
Assembly time =  0.044 seconds, on       1024 elements.
 >> norms :
   5.1362139552004299E-008   2.0461305603479069E-005

Note

The geometry is created by the subroutine spl_mapping_quart_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex01_04.F90

In this example we solve the Poisson equation on an annulus with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin, with Homogeneous Dirichlet boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  u = 0,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin( \frac{\pi}{(r_{max}^2 - r_{min}^2)} (r_{max}^2 - x^2 - y^2))

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex01_04.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/dirichlet_ex3 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex01_04 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.272 seconds, on       1024 elements.
Assembly time =  0.048 seconds, on       1024 elements.
 >> norms :
   2.2714037165493845E-007   9.0149505808980509E-005

Note

The geometry is created by the subroutine spl_mapping_annulus

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex02_01.F90

In this example we solve the Poisson equation on \Omega=[-2, 2]^2 with periodic boundary conditions

- \nabla^2 u = f ,& ~ ~ \Omega

where the analytical solution is defined as

u(x,y) =  \cos( 2 \pi x ) \cos( 2 \pi y )

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex02_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/periodic input

Then, you can execute the binary file using:

> bin/poisson_2d_ex02_01 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.296 seconds, on       1024 elements.
 * cg:  convegence after           1  iterations. Error    4.8212270540403445E-010
Assembly time =  0.044 seconds, on       1024 elements.
 >> norms :
   1.2370823389417612E-003   5.8183923487075226E-002

In the case of periodic boundary conditions, the stiffness matrix is singular and using a direct solver is not working anymore. A way to encounter this situation is to use an iterative method with a penalized linear operator. This can be done directly in our parameters file associated to the concrete we are using. Let’s take a look at the file solver_driver.nml:

> more input/solver_driver.nml
&linear_solver

SOLVER_NAME="cg"
SOLVER_FILENAME="input/solver_cg.nml",

/

You see that we are using the solver cg as a concrete type. Let’s take a look to the corresponding parameters file:

> more input/solver_cg.nml
&linear_solver

INT_MAXITER=3000
REAL_ATOL=1.d-8
REAL_RHO=1.0d0
REAL_GAMMA=0.97d0
INT_VERBOSE=1
INT_NULL_SPACE=1

/

Now the important attribut is the INT_NULL_SPACE. When it is set on 1 then PLAF will automatically create a penalized linear operator, that will be used instead of the provided matrix / linear operator, whenever we apply the dot operator (think of it as a generalization of the matrix-vector product).

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex03_01.F90

In this example we solve the Poisson equation on a square domain

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  u = 0,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(2 \pi x)  \sin(2 \pi y)

The homogeneous boundary conditions is imposed in a strong form, where we enforce the constraint u_i = 0, ~ \forall i \in \mathcal{I} where \mathcal{I} is the set of the basis functions indices that are non vanishing on the boundary.

In practice, when assembling the stiffness matrix S, we add the following term \frac{1}{\epsilon} on the entries S_{ii},~ \forall i \in \mathcal{I}

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex03_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/dirichlet_ex2 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex03_01 input/parameters_sim_1d1d.nml input/solver_driver.nml

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Todo

ex03_01 add plot

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml

ex03_02.F90

In this example we solve the Poisson equation on a circle domain

- \nabla^2 u = 4,& ~ ~ \Omega
  \\
  u = 0,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = 1 - x^2 - y^2

The homogeneous boundary conditions is imposed in a strong form, where we enforce the constraint u_i = 0, ~ \forall i \in \mathcal{I} where \mathcal{I} is the set of the basis functions indices that are non vanishing on the boundary.

In practice, when assembling the stiffness matrix S, we add the following term \frac{1}{\epsilon} on the entries S_{ii},~ \forall i \in \mathcal{I}

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex03_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/dirichlet_ex2 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex03_02 input/parameters_sim_1d1d.nml input/solver_driver.nml

Note

The geometry is created by the subroutine spl_mapping_circle

Plots

Todo

ex03_02 add plot

ex04_01.F90

In this example we solve the Poisson equation on \Omega = [0, 1]^2 with Neumann boundary conditions

- \nabla^2 u + u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(k_1 ( x - x_c )) \sin(k_2 ( y - y_c ))

where

k_1 = \frac{\pi}{3}, ~ ~ k_2 = \frac{5 \pi}{3}
\\
x_c = \frac{1}{3}, ~ ~ y_c = \frac{1}{4}

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex04_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/neumann_ex1 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex04_01 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  4.772 seconds, on      16384 elements.
Assembly time on the boundary =  0.000 seconds, on        128 elements.
Assembly time on the boundary =  0.004 seconds, on        128 elements.
Assembly time on the boundary =  0.004 seconds, on        128 elements.
Assembly time on the boundary =  0.004 seconds, on        128 elements.
 * cg:  convegence after        1778  iterations. Error    9.9732671653874003E-015
Assembly time =  0.704 seconds, on      16384 elements.
 >> norms :
   5.4097331935080999E-010   4.4826832136013520E-007

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex04_02.F90

In this example we solve the Poisson equation on a circle of radius 0.5 and centered at the origin with Neumann boundary conditions

- \nabla^2 u + u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(1 - x^2 - y^2)

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex04_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/neumann_ex1 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex04_02 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  4.452 seconds, on      16384 elements.
Assembly time on the boundary =  0.000 seconds, on        128 elements.
Assembly time on the boundary =  0.004 seconds, on        128 elements.
Assembly time on the boundary =  0.004 seconds, on        128 elements.
Assembly time on the boundary =  0.004 seconds, on        128 elements.
 * cg:  convegence after        1469  iterations. Error    8.3169231747949645E-015
Assembly time =  0.868 seconds, on      16384 elements.
 >> norms :
   1.9861611717543211E-011   1.6940756257701295E-008

Note

The geometry is created by the subroutine spl_mapping_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex06_01.F90

In this example we solve the Poisson equation on \Omega=[0, 1]^2 with mixed Homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(2 \pi x)  \sin(2 \pi y)

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex06_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/neumann_ex1 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex06_01 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.068 seconds, on        256 elements.
Assembly time on the boundary =  0.000 seconds, on         16 elements.
Assembly time =  0.012 seconds, on        256 elements.
 >> norms :
   1.1327811104728541E-005   1.1367977784254783E-003

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex06_02.F90

In this example we solve the Poisson equation on an annulus with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin, with mixed Homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(1 - x^2 - y^2)

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex06_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/neumann_ex1 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex06_02 input/parameters_sim_1d1d.nml input/solver_driver.nml

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Todo

ex06_02 add plot

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml

ex06_03.F90

In this example we solve the Poisson equation on a quart circle with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin, with mixed Homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = x y \sin( \frac{\pi}{2 (r_{max}^2 - r_{min}^2)} (r_{max}^2 - x^2 - y^2))

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex06_03.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/dirichlet_neumann_ex3 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex06_03 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.064 seconds, on        256 elements.
Assembly time on the boundary =  0.000 seconds, on         16 elements.
Assembly time =  0.012 seconds, on        256 elements.
 >> norms :
   2.1683323543233551E-007   2.4521547111997523E-005

Note

The geometry is created by the subroutine spl_mapping_quart_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

Nitsche 2d

Available examples

Poisson

The following examples solves Poisson equation with the Nitsche method.

  • ex01_01.F90 solves Poisson equation with the Nitsche method on a square using a simulation parameters file.
  • ex01_02.F90 solves Poisson equation with the Nitsche method on a circle using a simulation parameters file.
  • ex01_03.F90 computes the stabilization parameter for a given discretization and a mapping.
  • ex01_04.F90 solves Poisson for different values of the stabilization parameter. Can be used for automatic testing using the Python script.

Maxwell Harmonic Domain

  • ex02_01.F90 solves Maxwell Harmonic Domain problem with the Nitsche method on a square using a simulation parameters file.
  • ex02_04.F90 solves Maxwell Harmonic Domain problem for different values of the stabilization parameter. Can be used for automatic testing using the Python script.

ex01_01.F90

In this example we solve the Poisson equation on a square domain

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  u = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(k_1 ( x - x_c )) \sin(k_2 ( y - y_c ))

where

k_1 = \frac{\pi}{3}, ~ ~ k_2 = \frac{5 \pi}{3}
\\
x_c = \frac{1}{3}, ~ ~ y_c = \frac{1}{4}

Weak formulation

We denote the discrete finite elements space \mathcal{V}_h = \mathbf{span}\{ \phi_j, 1 \leq j \leq n_V \} for trial functions and test functions.

Let’s introduce the bilinear form a and linear form F, defined for all (u,v) \in H_0^1(\Omega)

a(u,v) := \int_{\Omega} \nabla u \cdot \nabla v d\Omega
\\
F(v) := \int_{\Omega} f v d\Omega

Then we introduce the penalized forms

a_{\epsilon}(u_h^{\epsilon}, v_h) := a(u_h^{\epsilon}, v_h) - < \partial_n u_h^{\epsilon} , v_h > + \frac{1}{\epsilon} < u_h^{\epsilon} , v_h >
\\
F_{\epsilon}(v_h) := F(v_h) + \frac{1}{\epsilon} < g , v_h >

Source file

The source file can be found in fema/tutorials/examples/2d/nitsche/ex01_01.F90.

Usage

As usual, you need to copy the input files, then you can execute the binary file. If you want to use open knots vector (i.e with interoplatory B-Splines):

> cp -R $CLAPP_DIR/inputs/fema/2d/nitsche/nitsche_ex1 input
> bin/nitsche_2d_ex01_01 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.288 seconds, on       1024 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time on the boundary =  0.008 seconds, on         32 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time =  0.040 seconds, on       1024 elements.
 >> norms :
   1.3782562295728396E-007   2.8488157158484054E-005

For uniform knots vector:

> cp -R $CLAPP_DIR/inputs/fema/2d/nitsche/nitsche_ex2 input
> bin/nitsche_2d_ex01_01 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.288 seconds, on       1024 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time on the boundary =  0.008 seconds, on         32 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time =  0.040 seconds, on       1024 elements.
 >> norms :
   1.3782562321493963E-007   2.8488157159069350E-005

Note

The geometry is created by the subroutine spl_mapping_square

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex01_02.F90

In this example we solve the Poisson equation on a circular domain

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  u = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(k_1 ( x - x_c )) \sin(k_2 ( y - y_c ))

where

k_1 = \frac{\pi}{3}, ~ ~ k_2 = \frac{5 \pi}{3}
\\
x_c = \frac{1}{3}, ~ ~ y_c = \frac{1}{4}

Weak formulation

We denote the discrete finite elements space \mathcal{V}_h = \mathbf{span}\{ \phi_j, 1 \leq j \leq n_V \} for trial functions and test functions.

Let’s introduce the bilinear form a and linear form F, defined for all (u,v) \in H_0^1(\Omega)

a(u,v) := \int_{\Omega} \nabla u \cdot \nabla v d\Omega
\\
F(v) := \int_{\Omega} f v d\Omega

Then we introduce the penalized forms

a_{\epsilon}(u_h^{\epsilon}, v_h) := a(u_h^{\epsilon}, v_h) - < \partial_n u_h^{\epsilon} , v_h > + \frac{1}{\epsilon} < u_h^{\epsilon} , v_h >
\\
F_{\epsilon}(v_h) := F(v_h) + \frac{1}{\epsilon} < g , v_h >

Source file

The source file can be found in fema/tutorials/examples/2d/nitsche/ex01_02.F90.

Usage

As usual, you need to copy the input files, then you can execute the binary file. If you want to use open knots vector (i.e with interoplatory B-Splines):

> cp -R $CLAPP_DIR/inputs/fema/2d/nitsche/nitsche_ex1 input
> bin/nitsche_2d_ex01_01 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.304 seconds, on       1024 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time on the boundary =  0.008 seconds, on         32 elements.
Assembly time =  0.052 seconds, on       1024 elements.
 >> norms :
   5.5834023746495397E-006   6.4319214108933217E-004

For uniform knots vector:

> cp -R $CLAPP_DIR/inputs/fema/2d/nitsche/nitsche_ex2 input
> bin/nitsche_2d_ex01_01 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.300 seconds, on       1024 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time on the boundary =  0.008 seconds, on         32 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time on the boundary =  0.004 seconds, on         32 elements.
Assembly time =  0.052 seconds, on       1024 elements.
 >> norms :
   5.5834023766030747E-006   6.4319214108755191E-004

Note

The geometry is created by the subroutine spl_mapping_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex01_03.F90

In this example we compute the stabilization parameter for the Poisson problem given a discretization and a mapping.

Source file

The source file can be found in fema/tutorials/examples/2d/nitsche/ex01_03.F90.

Usage

As usual, you need to copy the input files, then you can execute the binary file. If you want to use open knots vector (i.e with interoplatory B-Splines):

> cp -R $CLAPP_DIR/inputs/fema/2d/nitsche/nitsche_ex1 input
> bin/nitsche_2d_ex01_03 input/parameters_sim_1d1d.nml input/solver_driver.nml

For uniform knots vector:

> cp -R $CLAPP_DIR/inputs/fema/2d/nitsche/nitsche_ex2 input
> bin/nitsche_2d_ex01_03 input/parameters_sim_1d1d.nml input/solver_driver.nml

ex01_04.F90

This example solves Poisson with different values of the stabilization parameter. If the optimal one was provided, it will be added as entry.

You can run this example using the python script run_tests.py with the following arguments:

python ../run_tests.py  --degree 5 --grid 16 --binary bin/nitsche_2d_ex01_04 --h1

This will run the binary on the grid 16 \times 16 for degrees p \leq 5 then proceed to some diagnostics and plots.

ex02_04.F90

This example solves Poisson with different values of the stabilization parameter. If the optimal one was provided, it will be added as entry.

You can run this example using the python script run_tests.py with the following arguments:

python ../run_tests.py  --degree 5 --grid 16 --binary bin/nitsche_2d_ex02_04

This will run the binary on the grid 16 \times 16 for degrees p \leq 5 then proceed to some diagnostics and plots.

Poisson 2d

Available examples

Homogeneous Dirichlet boundary conditions I

In the following examples, the homogeneous dirichlet boundary conditions are directly applied in the finie element space by removing the interpolatory basis functions.

  • ex01_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a square using a simulation parameters file. This file has been described in the previous chapter.
  • ex01_02.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a circle using a simulation parameters file.
  • ex01_03.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a quart-circle using a simulation parameters file.
  • ex01_04.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a annulus using a simulation parameters file.

Periodic boundary conditions

  • ex02_01.F90 solves Poisson equation with periodic boundary conditions on a square using a simulation parameters file and a penalized linear operator.

Homogeneous Dirichlet boundary conditions II

Todo

ex03_01 not yet validated

Todo

ex03_02 not yet validated

The following examples solves Poisson equation with homogeneous Dirichlet boundary conditions applied in a strong form using a penalization method.

  • ex03_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a square using a simulation parameters file.
  • ex03_02.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a circle using a simulation parameters file.

Neumann boundary conditions

The following examples solves Poisson equation with Neumann boundary conditions.

  • ex04_01.F90 solves Poisson equation with Neumann boundary conditions on a square using a simulation parameters file.
  • ex04_02.F90 solves Poisson equation with Neumann boundary conditions on a circle using a simulation parameters file.

Multigrid and GLT

  • ex05_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a square using a simulation parameters file and a geometric multigrid for B-Splines.
  • ex05_02.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a square using a simulation parameters file and the B-Splines GLT smoother as a solver.
  • ex05_03.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a square using a simulation parameters file and a geometric multigrid for B-Splines using the GLT smoother.
  • ex05_04.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a circle using a simulation parameters file and a geometric multigrid for B-Splines using the GLT smoother.

Mixed Dirichlet-Neumann boundary conditions

Todo

ex06_02 not yet validated

  • ex06_01.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a square using a simulation parameters file.
  • ex06_02.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a annulus using a simulation parameters file.
  • ex06_03.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a quart-circle using a simulation parameters file.

ex01_02.F90

In this example we solve the Poisson equation on a non-singular circular domain

- \nabla^2 u = 4,& ~ ~ \Omega
  \\
  u = 0,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = 1 - x^2 - y^2

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex01_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/dirichlet_ex1 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex01_02 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.248 seconds, on       1024 elements.
Assembly time =  0.048 seconds, on       1024 elements.
 >> norms :
   3.2505818279129479E-008   3.7987674746537319E-006

Note

The geometry is created by the subroutine spl_mapping_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex01_03.F90

In this example we solve the Poisson equation on a quart circle with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin, with Homogeneous Dirichlet boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  u = 0,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = x y \sin( \frac{\pi}{(r_{max}^2 - r_{min}^2)} (r_{max}^2 - x^2 - y^2))

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex01_03.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/dirichlet_ex1 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex01_03 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.252 seconds, on       1024 elements.
Assembly time =  0.044 seconds, on       1024 elements.
 >> norms :
   5.1362139552004299E-008   2.0461305603479069E-005

Note

The geometry is created by the subroutine spl_mapping_quart_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex01_04.F90

In this example we solve the Poisson equation on an annulus with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin, with Homogeneous Dirichlet boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  u = 0,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin( \frac{\pi}{(r_{max}^2 - r_{min}^2)} (r_{max}^2 - x^2 - y^2))

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex01_04.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/dirichlet_ex3 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex01_04 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.272 seconds, on       1024 elements.
Assembly time =  0.048 seconds, on       1024 elements.
 >> norms :
   2.2714037165493845E-007   9.0149505808980509E-005

Note

The geometry is created by the subroutine spl_mapping_annulus

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex02_01.F90

In this example we solve the Poisson equation on \Omega=[-2, 2]^2 with periodic boundary conditions

- \nabla^2 u = f ,& ~ ~ \Omega

where the analytical solution is defined as

u(x,y) =  \cos( 2 \pi x ) \cos( 2 \pi y )

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex02_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/periodic input

Then, you can execute the binary file using:

> bin/poisson_2d_ex02_01 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.296 seconds, on       1024 elements.
 * cg:  convegence after           1  iterations. Error    4.8212270540403445E-010
Assembly time =  0.044 seconds, on       1024 elements.
 >> norms :
   1.2370823389417612E-003   5.8183923487075226E-002

In the case of periodic boundary conditions, the stiffness matrix is singular and using a direct solver is not working anymore. A way to encounter this situation is to use an iterative method with a penalized linear operator. This can be done directly in our parameters file associated to the concrete we are using. Let’s take a look at the file solver_driver.nml:

> more input/solver_driver.nml
&linear_solver

SOLVER_NAME="cg"
SOLVER_FILENAME="input/solver_cg.nml",

/

You see that we are using the solver cg as a concrete type. Let’s take a look to the corresponding parameters file:

> more input/solver_cg.nml
&linear_solver

INT_MAXITER=3000
REAL_ATOL=1.d-8
REAL_RHO=1.0d0
REAL_GAMMA=0.97d0
INT_VERBOSE=1
INT_NULL_SPACE=1

/

Now the important attribut is the INT_NULL_SPACE. When it is set on 1 then PLAF will automatically create a penalized linear operator, that will be used instead of the provided matrix / linear operator, whenever we apply the dot operator (think of it as a generalization of the matrix-vector product).

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex03_01.F90

In this example we solve the Poisson equation on a square domain

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  u = 0,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(2 \pi x)  \sin(2 \pi y)

The homogeneous boundary conditions is imposed in a strong form, where we enforce the constraint u_i = 0, ~ \forall i \in \mathcal{I} where \mathcal{I} is the set of the basis functions indices that are non vanishing on the boundary.

In practice, when assembling the stiffness matrix S, we add the following term \frac{1}{\epsilon} on the entries S_{ii},~ \forall i \in \mathcal{I}

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex03_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/dirichlet_ex2 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex03_01 input/parameters_sim_1d1d.nml input/solver_driver.nml

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Todo

ex03_01 add plot

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml

ex03_02.F90

In this example we solve the Poisson equation on a circle domain

- \nabla^2 u = 4,& ~ ~ \Omega
  \\
  u = 0,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = 1 - x^2 - y^2

The homogeneous boundary conditions is imposed in a strong form, where we enforce the constraint u_i = 0, ~ \forall i \in \mathcal{I} where \mathcal{I} is the set of the basis functions indices that are non vanishing on the boundary.

In practice, when assembling the stiffness matrix S, we add the following term \frac{1}{\epsilon} on the entries S_{ii},~ \forall i \in \mathcal{I}

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex03_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/dirichlet_ex2 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex03_02 input/parameters_sim_1d1d.nml input/solver_driver.nml

Note

The geometry is created by the subroutine spl_mapping_circle

Plots

Todo

ex03_02 add plot

ex04_01.F90

In this example we solve the Poisson equation on \Omega = [0, 1]^2 with Neumann boundary conditions

- \nabla^2 u + u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(k_1 ( x - x_c )) \sin(k_2 ( y - y_c ))

where

k_1 = \frac{\pi}{3}, ~ ~ k_2 = \frac{5 \pi}{3}
\\
x_c = \frac{1}{3}, ~ ~ y_c = \frac{1}{4}

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex04_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/neumann_ex1 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex04_01 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  4.772 seconds, on      16384 elements.
Assembly time on the boundary =  0.000 seconds, on        128 elements.
Assembly time on the boundary =  0.004 seconds, on        128 elements.
Assembly time on the boundary =  0.004 seconds, on        128 elements.
Assembly time on the boundary =  0.004 seconds, on        128 elements.
 * cg:  convegence after        1778  iterations. Error    9.9732671653874003E-015
Assembly time =  0.704 seconds, on      16384 elements.
 >> norms :
   5.4097331935080999E-010   4.4826832136013520E-007

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex04_02.F90

In this example we solve the Poisson equation on a circle of radius 0.5 and centered at the origin with Neumann boundary conditions

- \nabla^2 u + u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(1 - x^2 - y^2)

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex04_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/neumann_ex1 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex04_02 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  4.452 seconds, on      16384 elements.
Assembly time on the boundary =  0.000 seconds, on        128 elements.
Assembly time on the boundary =  0.004 seconds, on        128 elements.
Assembly time on the boundary =  0.004 seconds, on        128 elements.
Assembly time on the boundary =  0.004 seconds, on        128 elements.
 * cg:  convegence after        1469  iterations. Error    8.3169231747949645E-015
Assembly time =  0.868 seconds, on      16384 elements.
 >> norms :
   1.9861611717543211E-011   1.6940756257701295E-008

Note

The geometry is created by the subroutine spl_mapping_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex06_01.F90

In this example we solve the Poisson equation on \Omega=[0, 1]^2 with mixed Homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(2 \pi x)  \sin(2 \pi y)

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex06_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/neumann_ex1 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex06_01 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.068 seconds, on        256 elements.
Assembly time on the boundary =  0.000 seconds, on         16 elements.
Assembly time =  0.012 seconds, on        256 elements.
 >> norms :
   1.1327811104728541E-005   1.1367977784254783E-003

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex06_02.F90

In this example we solve the Poisson equation on an annulus with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin, with mixed Homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = \sin(1 - x^2 - y^2)

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex06_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/neumann_ex1 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex06_02 input/parameters_sim_1d1d.nml input/solver_driver.nml

Note

The geometry is created by the subroutine spl_mapping_bilinear

Plots

Todo

ex06_02 add plot

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml

ex06_03.F90

In this example we solve the Poisson equation on a quart circle with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin, with mixed Homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y) = x y \sin( \frac{\pi}{2 (r_{max}^2 - r_{min}^2)} (r_{max}^2 - x^2 - y^2))

Source file

The source file can be found in fema/tutorials/examples/2d/poisson/ex06_03.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/2d/poisson/dirichlet_neumann_ex3 input

Then, you can execute the binary file using:

> bin/poisson_2d_ex06_03 input/parameters_sim_1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>> context
 * assembly id           11
 * dimension            2
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            2
 n_procs         :            1           1
 <<<<<
Assembly time =  0.064 seconds, on        256 elements.
Assembly time on the boundary =  0.000 seconds, on         16 elements.
Assembly time =  0.012 seconds, on        256 elements.
 >> norms :
   2.1683323543233551E-007   2.4521547111997523E-005

Note

The geometry is created by the subroutine spl_mapping_quart_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

Projector 2d

Available examples

Homogeneous Dirichlet boundary conditions I

In the following examples, the homogeneous dirichlet boundary conditions are directly applied in the finie element space by removing the interpolatory basis functions.

  • ex01_01.F90 solves Mass operator with homogeneous Dirichlet boundary conditions on a square using a simulation parameters file. This file has been described in the previous chapter.
  • ex01_02.F90 solves Mass operator with homogeneous Dirichlet boundary conditions on a circle using a simulation parameters file. This file has been described in the previous chapter.

Bilaplacian 3d

TODO : JLA ex01_01 in the cartesian domain ex01_02 in the cylindic domain

Maxwell Harmonic Domain 3d

In these examples, we solve the Maxwell Harmonic Domain problem in 3d. The problem in the strong form writes

\nabla \times \nabla \times \mathbf{u} + \mu \mathbf{u} = \mathbf{f},& ~ ~ \Omega

Weak formulation

Let \Vcurl = \mathbf{span} \{ \PsiPsi_i, ~ 1 \leq i \leq n \} be a discrete subspace of \Hcurl. The weak formulation using the natural boundary conditions writes

\mbox{Find}~ \uu \in \Vcurl, \mbox{such that}, ~ ~ \forall \vv \in \Vcurl

  \left( \Curl \uu, \Curl \vv  \right)_{\Omega}
+ \mu \left( \uu, \vv  \right)_{\Omega}
= \left( \ff, \vv  \right)_{\Omega}
+ \langle \left( \Curl \uu \right) \times \nn , \vv  \rangle_{\partial \Omega}

The weak formulation using the essential boundary conditions writes

\mbox{Find}~ \uu \in \Vcurl, \mbox{such that}, ~ ~ \forall \vv \in \Vcurl

  \left( \Curl \uu, \Curl \vv  \right)_{\Omega}
+ \mu \left( \uu, \vv  \right)_{\Omega}
= \left( \ff, \vv  \right)_{\Omega}
+ \langle \Curl \uu , \vv \times \nn  \rangle_{\partial \Omega}

Available examples

Essential boundary conditions

In the following examples, the essential boundary conditions are directly applied in the finie element space by removing the interpolatory basis functions.

  • ex01_01.F90 solves Harmonic Maxwell equation with essential boundary conditions on a cube.

Periodic boundary conditions

  • ex02_01.F90 solves Harmonic Maxwell equation with periodic boundary conditions on a cube.

Natural boundary conditions

  • ex03_01.F90 solves Harmonic Maxwell equation with natural boundary conditions on a cube.
  • ex03_02.F90 solves Harmonic Maxwell equation with complex entries and natural boundary conditions on a cube.

ex01_01.F90

We consider solving the Maxwell Harmonic equation in a cube under periodic boundary conditions. The analytical solution is defined as

\mathbf{u}(x,y,z) =
   \begin{pmatrix}
     \cos(k_1 x) \sin(k_2 y) \sin(k_3 z)
   \\
     \sin(k_1 x) \cos(k_2 y) \sin(k_3 z)
   \\
     \sin(k_1 x) \sin(k_2 y) \cos(k_3 z)
   \end{pmatrix}

Source file

The source file can be found in fema/tutorials/examples/3d/maxwell_hd/ex01_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/maxwell_hd/essential_ex1 input

Then, you can execute the binary file using:

> bin/maxwell_hd_3d_ex01_01 input/parameters_bspline.nml input/parameters_ddm.nml input/solver_driver.nml
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
 >>>>> parameters
 dimension  :            3
 n_elements :           16          16          16
 degrees    :            2           2           2
 procs      :            1           1           1
 bc_min     :            2           2           2
 bc_max     :            2           2           2
 <<<<<
Assembly time = 26.260 seconds, on       4096 elements.
 * cg:  convegence after           9  iterations. Error    4.6028403344934176E-016
Assembly time =  1.052 seconds, on       4096 elements.
 >> norms :
   3.5950699782513894E-003   0.0000000000000000        0.0000000000000000

Note

The geometry is created by the subroutine spl_mapping_trilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field_one_form.py ex_comp.nml ey_comp.nml ez_comp.nml mapping.nml

Todo

ex01_01 add plot

ex02_01.F90

We consider solving the Maxwell Harmonic equation in a cube under periodic boundary conditions. The analytical solution is defined as

\mathbf{u}(x,y,z) =
   \begin{pmatrix}
    \sin(k1 x) \cos(k2 y) \cos(k3 z)
     \\
    \cos(k1 x) \sin(k2 y) \cos(k3 z)
     \\
    \cos(k1 x) \cos(k2 y) \sin(k3 z)
   \end{pmatrix}

Source file

The source file can be found in fema/tutorials/examples/3d/maxwell_hd/ex02_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/maxwell_hd/essential_ex1 input

Then, you can execute the binary file using:

> bin/maxwell_hd_3d_ex02_01 input/parameters_bspline.nml input/parameters_ddm.nml input/solver_driver.nml
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
 >>>>> parameters
 dimension  :            3
 n_elements :           16          16          16
 degrees    :            2           2           2
 procs      :            1           1           1
 bc_min     :            1           1           1
 bc_max     :            1           1           1
 <<<<<
Assembly time = 32.436 seconds, on       4096 elements.
 * cg:  convegence after           1  iterations. Error    6.4691448260515334E-015
Assembly time =  1.072 seconds, on       4096 elements.
 >> norms :
   3.5950688863735582E-003   0.0000000000000000        0.0000000000000000

Note

The geometry is created by the subroutine spl_mapping_trilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field_one_form.py ex_comp.nml ey_comp.nml ez_comp.nml mapping.nml

Todo

ex02_01 add plot

ex03_01.F90

In this example we solve the Maxwell Harmonic equation on a cube [0,1]^3 domain using natural boundary conditions. The analytical solution is defined as

\uu(x,y,z) =
   \begin{pmatrix}
  \sin{\left (k_{2} \left(y - yc\right) \right )} \sin{\left (k_{3} \left(z - zc\right) \right )} \cos{\left (k_{1} \left(x - xc\right) \right )}
  \\
  \sin{\left (k_{1} \left(x - xc\right) \right )} \sin{\left (k_{3} \left(z - zc\right) \right )} \cos{\left (k_{2} \left(y - yc\right) \right )}
  \\
  \sin{\left (k_{1} \left(x - xc\right) \right )} \sin{\left (k_{2} \left(y - yc\right) \right )} \cos{\left (k_{3} \left(z - zc\right) \right )}
   \end{pmatrix}

where

k_1 = 2 \pi, \quad k_2 = 2 \pi, \quad k_3 = 2 \pi
\\
x_c = \frac{1}{3}, ~ ~ y_c = \frac{1}{4}, ~ ~ z_c = \frac{3}{4}

Source file

The source file can be found in fema/tutorials/examples/2d/maxwell_hd/ex03_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/maxwell_hd/natural_ex1 input

Then, you can execute the binary file using:

> bin/maxwell_hd_3d_ex03_01 input/parameters_bspline.nml input/parameters_ddm.nml input/solver_driver.nml
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
 >>>>> parameters
 dimension  :            3
 n_elements :           16          16          16
 degrees    :            2           2           2
 procs      :            1           1           1
 bc_min     :            2           2           2
 bc_max     :            2           2           2
 <<<<<
Assembly time = 31.468 seconds, on       4096 elements.
Assembly time on the boundary =  0.040 seconds, on        256 elements.
Assembly time on the boundary =  0.036 seconds, on        256 elements.
Assembly time on the boundary =  0.040 seconds, on        256 elements.
Assembly time on the boundary =  0.040 seconds, on        256 elements.
Assembly time on the boundary =  0.040 seconds, on        256 elements.
Assembly time on the boundary =  0.036 seconds, on        256 elements.
 * cg:  convegence after          53  iterations. Error    9.6241832990251682E-013
Assembly time =  1.032 seconds, on       4096 elements.
 >> norms :
   3.5900610955089613E-003   0.0000000000000000        0.0000000000000000

Note

The geometry is created by the subroutine spl_mapping_trilinear

Plots

Todo

add plot for maxwell_hd_3d_ex03_01

ex03_02.F90

In this example we solve the following equation on a cube [0,1]^3 domain using natural boundary conditions.

\nabla \times \nabla \times \uu + \kappa \uu = \ff,& ~ ~ \Omega

where

\kappa = - \omega^2 \epsilon + i \omega \sigma

where

\omega = 1.0, \quad  \sigma = 1.0, \quad \epsilon = 1.0

Weak formulation

\mbox{Find}~ \uu \in \Vcurl, \mbox{such that}, ~ ~ \forall \vv \in \Vcurl

  \left( \Curl \uu, \Curl \vv  \right)_{\Omega}
+ \mu \left( \uu, \vv  \right)_{\Omega}
= \left( \ff, \vv  \right)_{\Omega}
+ \langle \left( \Curl \uu \right) \times \nn , \vv  \rangle_{\partial \Omega}

The analytical solution is defined as

\uu(x,y,z) =\uu_r(x,y,z) + i \uu_i(x,y,z)

where

\uu_r(x,y,z) =
   \begin{pmatrix}
     \cos(k_1^r x) \sin(k_2^r y) \sin(k_3^r z)
   \\
     \sin(k_1^r x) \cos(k_2^r y) \sin(k_3^r z)
   \\
     \sin(k_1^r x) \sin(k_2^r y) \cos(k_3^r z)
   \end{pmatrix}
\quad \mbox{and} \quad
\uu_i(x,y,z) =
   \begin{pmatrix}
     \cos(k_1^i x) \sin(k_2^i y) \sin(k_3^i z)
   \\
     \sin(k_1^i x) \cos(k_2^i y) \sin(k_3^i z)
   \\
     \sin(k_1^i x) \sin(k_2^i y) \cos(k_3^i z)
   \end{pmatrix}

Source file

The source file can be found in fema/tutorials/examples/3d/maxwell_hd/ex03_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/maxwell_hd/natural_ex2 input

Then, you can execute the binary file using:

> bin/maxwell_hd_3d_ex03_02 input/parameters_bspline.nml input/parameters_ddm.nml input/solver_driver.nml
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
 >>>>> parameters
 dimension  :            3
 n_elements :            8           8           8
 degrees    :            2           2           2
 procs      :            1           1           1
 bc_min     :            2           2           2
 bc_max     :            2           2           2
 <<<<<
Assembly time =  4.056 seconds, on        512 elements.
Assembly time on the boundary =  0.016 seconds, on         64 elements.
Assembly time on the boundary =  0.012 seconds, on         64 elements.
Assembly time on the boundary =  0.012 seconds, on         64 elements.
Assembly time on the boundary =  0.012 seconds, on         64 elements.
Assembly time on the boundary =  0.012 seconds, on         64 elements.
Assembly time on the boundary =  0.012 seconds, on         64 elements.
 error lapack lu :    2.1690818654827680E-018
Assembly time =  0.136 seconds, on        512 elements.
 >> norms :
   1.5165558107942940E-002   3.5877281363971168E-003   0.0000000000000000

Note

The geometry is created by the subroutine spl_mapping_trilinear

Plots

Todo

add plot for maxwell_hd_3d_ex03_02

Multigrid 3d

Available examples

Poisson

  • ex05_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a cube using a simulation parameters file and a geometric multigrid for B-Splines.
  • ex05_02.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a cube using a simulation parameters file and the B-Splines GLT smoother as a solver.
  • ex05_03.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a cube using a simulation parameters file and a geometric multigrid for B-Splines using the GLT smoother.

ex01_01.F90

- \nabla^2 u = f ,& ~ ~ \Omega

where the analytical solution is defined as

u(x,y,z) =  ( 1 - x^2 - y^2 ) \sin( k_3 z )

where

k_3 = \frac{2 \pi}{L_z}

Source file

The source file can be found in fema/tutorials/examples/3d/multigrid/ex01_03.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/multigrid/poisson_ex1 input

Then, you can execute the binary file using:

> bin/multigrid_3d_ex01_01 input/parameters_sim_1d1d1d.nml input/solver_driver.nml

Nitsche 3d

Available examples

Poisson

In the following examples, the homogeneous dirichlet boundary conditions are directly applied in the finie element space by removing the interpolatory basis functions.

  • ex01_01.F90 solves Poisson equation with the Nitsche method on a cube using a simulation parameters file.
  • ex01_01.F90 solves Poisson equation with the Nitsche method on a cylinder of quart-circle section using a simulation parameters file.

Maxwell Harmonic Domain

ex01_01.F90

In this example we solve the Poisson equation on a cube [0,1]^3

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y,z) =  x y (-r_{min}^2 + x^2 + y^2) \sin( k_3 z )

where

k_3 = \frac{2 \pi}{L_z}

Source file

The source file can be found in fema/tutorials/examples/3d/nitsche/ex01_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/nitsche/ex1 input

Then, you can execute the binary file using:

> bin/nitsche_3d_ex01_01 input/parameters_sim_1d1d1d.nml input/solver_driver.nml

Note

The geometry is created by using the spl_t_mapping_cad object to extrude an ellipse map created using the subroutine spl_mapping_quart_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml

Todo

nitsche_3d_ex01_01 add plot

ex01_02.F90

In this example we solve the Poisson equation on cylinder of length L_z and a quart circle with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y,z) =  x y (-r_{min}^2 + x^2 + y^2) \sin( k_3 z )

where

k_3 = \frac{2 \pi}{L_z}

Source file

The source file can be found in fema/tutorials/examples/3d/nitsche/ex01_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/nitsche/ex1 input

Then, you can execute the binary file using:

> bin/nitsche_3d_ex01_02 input/parameters_sim_1d1d1d.nml input/solver_driver.nml

Note

The geometry is created by using the spl_t_mapping_cad object to extrude an ellipse map created using the subroutine spl_mapping_quart_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml

Todo

nitsche_3d_ex01_02 add plot

Poisson 3d

Available examples

Homogeneous Dirichlet boundary conditions I

In the following examples, the homogeneous dirichlet boundary conditions are directly applied in the finie element space by removing the interpolatory basis functions.

  • ex01_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a cube using a simulation parameters file. This file has been described in the previous chapter.
  • ex01_02.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a cylinder of circular section using a simulation parameters file. This file has been described in the previous chapter.
  • ex01_03.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a cylinder of an ellipse section using a simulation parameters file. This file has been described in the previous chapter.
  • ex01_04.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a cylinder of quart_circle section using a simulation parameters file. This file has been described in the previous chapter.
  • ex01_05.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a cylinder of ring section using a simulation parameters file. This file has been described in the previous chapter.

Todo

ex01_05 not yet implemented

Periodic boundary conditions

  • ex02_01.F90 solves Poisson equation with periodic boundary conditions on a cube using a simulation parameters file and a penalized linear operator.

Homogeneous Dirichlet boundary conditions II

Todo

ex03_01 not yet validated

The following examples solves Poisson equation with homogeneous Dirichlet boundary conditions applied in a strong form using a penalization method.

  • ex03_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a cube using a simulation parameters file.

Neumann boundary conditions

The following examples solves Poisson equation with Neumann boundary conditions.

  • ex04_01.F90 solves Poisson equation with Neumann boundary conditions on a cube using a simulation parameters file.
  • ex04_02.F90 solves Poisson equation with Neumann boundary conditions on a cylinder of a circular section using a simulation parameters file.

Multigrid and GLT

  • ex05_01.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a cube using a simulation parameters file and a geometric multigrid for B-Splines.
  • ex05_02.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a cube using a simulation parameters file and the B-Splines GLT smoother as a solver.
  • ex05_03.F90 solves Poisson equation with homogeneous Dirichlet boundary conditions on a cube using a simulation parameters file and a geometric multigrid for B-Splines using the GLT smoother.

Mixed Dirichlet-Neumann boundary conditions

  • ex06_01.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a cube using a simulation parameters file.
  • ex06_02.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a cylinder of circular section using a simulation parameters file.
  • ex06_03.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a cylinder of circular section using a simulation parameters file.
  • ex06_04.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a cylinder of an ellipse section using a simulation parameters file.
  • ex06_05.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a cylinder of an ellipse section using a simulation parameters file.
  • ex06_06.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a cylinder of an ellipse section using a simulation parameters file.
  • ex06_07.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a cylinder of an ellipse section using a simulation parameters file.
  • ex06_08.F90 solves Poisson equation with both Neumann and Homogeneous Dirichlet (removing the interpolatory basis functions) boundary conditions on a cylinder of an ellipse section using a simulation parameters file.

ex01_02.F90

In this example we solve the Poisson equation on a cylinder of length L_z and a circular section of radius 1 with homogeneous Dirichlet boundary conditions

- \nabla^2 u = f ,& ~ ~ \Omega

where the analytical solution is defined as

u(x,y,z) =  ( 1 - x^2 - y^2 ) \sin( k_3 z )

where

k_3 = \frac{2 \pi}{L_z}

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex01_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/dirichlet_ex1 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex01_02 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     3.084 seconds, on       4096 elements.
 * cg:  convegence after          23  iterations. Error    6.9081284582086301E-013
Assembly time =     0.332 seconds, on       4096 elements.
 >> norms :
   3.8612317087185891E-004   1.5449977565259104E-002

Note

The geometry is created by using the spl_t_mapping_cad object to extrude a circular map created using the subroutine spl_mapping_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex01_03.F90

In this example we solve the Poisson equation on a cylinder of length L_z and an ellipse section of semiminor axis r_a and semimajor axis r_b with homogeneous Dirichlet boundary conditions

- \nabla^2 u = f ,& ~ ~ \Omega

where the analytical solution is defined as

u(x,y,z) =  ( 1 - \frac{x^2}{r_a^2} - \frac{y^2}{r_b^2} ) \sin( k_3 z )

where

k_3 = \frac{2 \pi}{L_z}

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex01_03.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/dirichlet_ex1 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex01_03 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     4.104 seconds, on       4096 elements.
 * cg:  convegence after          36  iterations. Error    9.0265856410831577E-013
Assembly time =     0.436 seconds, on       4096 elements.
 >> norms :
   7.0455800454957967E-004   1.6990324451465887E-002

Note

The geometry is created by using the spl_t_mapping_cad object to extrude an ellipse map created using the subroutine spl_mapping_ellipse

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex01_04.F90

In this example we solve the Poisson equation on a cylinder of length L_z and a quart circle with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin with homogeneous Dirichlet boundary conditions

- \nabla^2 u = f ,& ~ ~ \Omega

where the analytical solution is defined as

u(x,y,z) =  x y \sin( \frac{\pi}{(r_{max}^2 - r_{min}^2)} (r_{max}^2 - x^2 - y^2)) \sin( k_3 z )

where

k_3 = \frac{2 \pi}{L_z}

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex01_04.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/dirichlet_ex1 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex01_04 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     4.288 seconds, on       4096 elements.
 * cg:  convegence after          20  iterations. Error    7.8722920262164920E-013
Assembly time =     0.436 seconds, on       4096 elements.
 >> norms :
   6.2163509966165143E-005   3.9042332945051594E-003

Note

The geometry is created by using the spl_t_mapping_cad object to extrude an ellipse map created using the subroutine spl_mapping_quart_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex02_01.F90

In this example we solve the Poisson equation on \Omega=[0, 1]^3 with periodic boundary conditions

- \nabla^2 u = f ,& ~ ~ \Omega

where the analytical solution is defined as

u(x,y,z) =  \cos( 2 \pi x ) \cos( 2 \pi y ) \cos( 2 \pi z )

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex02_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/periodic input

Then, you can execute the binary file using:

> bin/poisson_3d_ex02_01 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     5.636 seconds, on       4096 elements.
                       CONVERGENCE HISTORY FOR CG

Errors are displayed in unit:  6
Warnings are displayed in unit:  6
Matrix size:    4096
No preconditioning
User supplied initial guess
Maximum number of iterations:  3000
Tolerance for convergence: 0.10E-07
Backward error on the unpreconditioned system Ax = b:
    the residual is normalised by ||b||
Optimal size for the workspace:  24577

Convergence history: b.e. on the unpreconditioned system
 Iteration   Approx. b.e.    True b.e.
    1           0.39E-07         --
    2           0.19E-07         --
    3           0.11E-07         --
    4           0.40E-08       0.40E-08

Convergence achieved
B.E. on the unpreconditioned system: 0.40E-08
info(1) =  0
Number of iterations (info(2)):     4
Assembly time =     0.512 seconds, on       4096 elements.
 >> norms :
   1.8867457659018882E-004   2.2588484636586872E-002

In the case of periodic boundary conditions, the stiffness matrix is singular and using a direct solver is not working anymore. A way to encounter this situation is to use an iterative method with a penalized linear operator. This can be done directly in our parameters file associated to the concrete we are using. Let’s take a look at the file solver_driver.nml:

> more input/solver_driver.nml
&linear_solver

SOLVER_NAME="packcg"
SOLVER_FILENAME="input/solver_packcg.nml",

/

You see that we are using the solver packcg as a concrete type. Let’s take a look to the corresponding parameters file:

> more input/solver_packcg.nml
&linear_solver

INT_MAXITER=3000
REAL_ATOL=1.d-8
INT_EIGEN_ESTIMATE=0
INT_VERBOSE=1
INT_NULL_SPACE=1

/

Now the important attribut is the INT_NULL_SPACE. When it is set on 1 then PLAF will automatically create a penalized linear operator, that will be used instead of the provided matrix / linear operator, whenever we apply the dot operator (think of it as a generalization of the matrix-vector product).

Note

The geometry is created by the subroutine spl_mapping_trilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex04_01.F90

In this example we solve the Poisson equation on \Omega = [0, 1]^3 with Neumann boundary conditions

- \nabla^2 u + u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y,z) = \sin(k_1 ( x - x_c )) \sin(k_2 ( y - y_c )) \sin(k_3 ( z - z_c ))

where

k_1 = \frac{\pi}{3}, ~ ~ k_2 = \frac{5 \pi}{3}, ~ ~ k_3 = \frac{7 \pi}{3}
\\
x_c = \frac{1}{3}, ~ ~ y_c = \frac{1}{4}, ~ ~ z_c = \frac{3}{4}

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex04_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/neumann_ex1 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex04_01 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     4.480 seconds, on       4096 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
Assembly time on the boundary =  0.012 seconds, on        256 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
Assembly time on the boundary =  0.012 seconds, on        256 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
 * cg:  convegence after          86  iterations. Error    9.2621657767139080E-015
Assembly time =     0.312 seconds, on       4096 elements.
 >> norms :
   8.0940363833526086E-005   9.5090884351483086E-003

Note

The geometry is created by the subroutine spl_mapping_trilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex04_02.F90

In this example we solve the Poisson equation on cylinder of length 1 and circular section of radius 1 with Neumann boundary conditions

- \nabla^2 u + u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y,z) = \sin(k_1 ( x - x_c )) \sin(k_2 ( y - y_c )) \sin(k_3 ( z - z_c ))

where

k_1 = \frac{\pi}{3}, ~ ~ k_2 = \frac{5 \pi}{3}, ~ ~ k_3 = \frac{7 \pi}{3}
\\
x_c = \frac{1}{3}, ~ ~ y_c = \frac{1}{4}, ~ ~ z_c = \frac{3}{4}

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex04_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/neumann_ex1 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex04_02 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     5.472 seconds, on       4096 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
Assembly time on the boundary =  0.020 seconds, on        256 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
Assembly time on the boundary =  0.020 seconds, on        256 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
 * cg:  convegence after         198  iterations. Error    9.1772349168642772E-015
Assembly time =     0.484 seconds, on       4096 elements.
 >> norms :
   6.6081282662012574E-004   4.9190966017697686E-002

Note

The geometry is created by the subroutine spl_mapping_trilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex06_01.F90

In this example we solve the Poisson equation on cube [0,1]^3 with mixed homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y,z) = \sin(k_1  x) \sin(k_2 y) \sin(k_3 z)

where

k_1 = \frac{\pi}{2}, ~ ~ k_2 = 2 \pi, ~ ~ k_3 = 2 \pi

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex06_01.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/dirichlet_neumann_ex1 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex06_01 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     3.732 seconds, on       4096 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
 * cg:  convegence after          13  iterations. Error    9.3736312682598782E-013
Assembly time =     0.316 seconds, on       4096 elements.
 >> norms :
   1.5419268658428844E-004   1.8420793871319379E-002   0.0000000000000000

Note

The geometry is created by the subroutine spl_mapping_trilinear

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex06_02.F90

In this example we solve the Poisson equation on cylinder of length 1 and a circular section of radius 1 with mixed homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y,z) =  ( 1 - x^2 - y^2 ) \sin( k_3 z )

where

k_3 = \frac{3 \pi}{4 L_z}

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex06_02.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/dirichlet_neumann_ex2 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex06_02 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     4.128 seconds, on       4096 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
 * cg:  convegence after          49  iterations. Error    8.4634013536013029E-013
Assembly time =     0.432 seconds, on       4096 elements.
 >> norms :
   2.4010071272671378E-005   1.5754512240320968E-003   0.0000000000000000

Note

The geometry is created by using the spl_t_mapping_cad object to extrude a circular map created using the subroutine spl_mapping_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex06_03.F90

In this example we solve the Poisson equation on cylinder of length 1 and a circular section of radius \frac{1}{2} with mixed homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y,z) = \sin(k_1 ( x - x_c )) \sin(k_2 ( y - y_c )) \sin(k_3 ( z - z_c ))

where

k_1 = \frac{\pi}{3}, ~ ~ k_2 = \frac{5 \pi}{3}, ~ ~ k_3 = \frac{2 \pi}{L_z}
\\
x_c = \frac{1}{3}, ~ ~ y_c = \frac{1}{4}, ~ ~ z_c = 0

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex06_03.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/dirichlet_neumann_ex3 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex06_03 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     5.256 seconds, on       4096 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
Assembly time on the boundary =  0.020 seconds, on        256 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
 * cg:  convegence after         123  iterations. Error    7.5874040737487838E-013
Assembly time =     0.472 seconds, on       4096 elements.
 >> norms :
   1.0632853071347102E-003   6.8484158870167192E-002   0.0000000000000000

Note

The geometry is created by using the spl_t_mapping_cad object to extrude a circular map created using the subroutine spl_mapping_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex06_04.F90

In this example we solve the Poisson equation on cylinder of length 1 and an ellipse section of semiminor axis r_a and semimajor axis r_b with mixed homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y,z) = \sin(k_1 ( x - x_c )) \sin(k_2 ( y - y_c )) \sin(k_3 ( z - z_c ))

where

k_1 = \frac{\pi}{3}, ~ ~ k_2 = \frac{5 \pi}{3}, ~ ~ k_3 = \frac{2 \pi}{L_z}
\\
x_c = \frac{1}{3}, ~ ~ y_c = \frac{1}{4}, ~ ~ z_c = 0

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex06_04.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/dirichlet_neumann_ex3 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex06_04 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     5.236 seconds, on       4096 elements.
Assembly time on the boundary =  0.020 seconds, on        256 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
 * cg:  convegence after         187  iterations. Error    6.7336515014694847E-013
Assembly time =     0.468 seconds, on       4096 elements.
 >> norms :
   5.8406165092483528E-004   3.8792525507888732E-002   0.0000000000000000

Note

The geometry is created by using the spl_t_mapping_cad object to extrude an ellipse map created using the subroutine spl_mapping_ellipse

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex06_05.F90

In this example we solve the Poisson equation on cylinder of length L_z and a quart circle with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin with mixed homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y,z) =  y \sin( \frac{\pi}{(r_{max}^2 - r_{min}^2)} (r_{max}^2 - x^2 - y^2)) \sin( k_3 z )

where

k_3 = \frac{2 \pi}{L_z}

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex06_05.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/dirichlet_neumann_ex5 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex06_05 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     4.308 seconds, on       4096 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
 * cg:  convegence after          31  iterations. Error    5.1668217484030822E-013
Assembly time =     0.416 seconds, on       4096 elements.
 >> norms :
   1.5076249837912378E-004   8.1816430628700136E-003   0.0000000000000000

Note

The geometry is created by using the spl_t_mapping_cad object to extrude an ellipse map created using the subroutine spl_mapping_quart_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex06_06.F90

In this example we solve the Poisson equation on cylinder of length L_z and a quart circle with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin with mixed homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y,z) =  x \sin( \frac{\pi}{(r_{max}^2 - r_{min}^2)} (r_{max}^2 - x^2 - y^2)) \sin( k_3 z )

where

k_3 = \frac{2 \pi}{L_z}

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex06_06.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/dirichlet_neumann_ex6 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex06_06 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     4.460 seconds, on       4096 elements.
Assembly time on the boundary =  0.016 seconds, on        256 elements.
 * cg:  convegence after          31  iterations. Error    5.1668217484012879E-013
Assembly time =     0.420 seconds, on       4096 elements.
 >> norms :
   1.5076249837912506E-004   8.1816430628700136E-003   0.0000000000000000

Note

The geometry is created by using the spl_t_mapping_cad object to extrude an ellipse map created using the subroutine spl_mapping_quart_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex06_07.F90

In this example we solve the Poisson equation on cylinder of length L_z and a quart circle with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin with mixed homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y,z) =  x y (r_{max}^2 - x^2 - y^2) \sin( k_3 z )

where

k_3 = \frac{2 \pi}{L_z}

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex06_07.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/dirichlet_neumann_ex7 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex06_07 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     4.236 seconds, on       4096 elements.
Assembly time on the boundary =  0.012 seconds, on        256 elements.
 * cg:  convegence after          23  iterations. Error    9.1060281276833992E-013
Assembly time =     0.404 seconds, on       4096 elements.
 >> norms :
   2.6647689272254521E-005   8.3620640018792862E-004   0.0000000000000000

Note

The geometry is created by using the spl_t_mapping_cad object to extrude an ellipse map created using the subroutine spl_mapping_quart_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

ex06_08.F90

In this example we solve the Poisson equation on cylinder of length L_z and a quart circle with r_{min} = 0.5, r_{max} = 1.0 and centered at the origin with mixed homogeneous Dirichlet and Neumann boundary conditions

- \nabla^2 u = f,& ~ ~ \Omega
  \\
  \nabla u \cdot \mathbf{n} = g,& ~ ~ \partial \Omega

where the analytical solution is defined as

u(x,y,z) =  x y (-r_{min}^2 + x^2 + y^2) \sin( k_3 z )

where

k_3 = \frac{2 \pi}{L_z}

Source file

The source file can be found in fema/tutorials/examples/3d/poisson/ex06_08.F90.

Usage

First you need to copy the following parameters input:

> cp -R $CLAPP_DIR/inputs/fema/3d/poisson/dirichlet_neumann_ex8 input

Then, you can execute the binary file using:

> bin/poisson_3d_ex06_08 input/parameters_sim_1d1d1d.nml input/solver_driver.nml
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>> context
 * assembly id          111
 * dimension            3
 * ddm name tensor
 * ddm filename input/parameters_ddm.nml
 * discretization_1 bspline
 * discretization_2 bspline
 * discretization_3 bspline
 <<<<
 >>>>> parameters
 partitioner_id   :            1
 partitioner_name : TENSOR
 ddm_dim          :            3
 n_procs         :            1           1           1
 <<<<<
Assembly time =     4.300 seconds, on       4096 elements.
Assembly time on the boundary =  0.012 seconds, on        256 elements.
 * cg:  convegence after          42  iterations. Error    9.7560469503682433E-013
Assembly time =     0.420 seconds, on       4096 elements.
 >> norms :
   4.7682030772917216E-005   1.3409298353565149E-003   0.0000000000000000

Note

The geometry is created by using the spl_t_mapping_cad object to extrude an ellipse map created using the subroutine spl_mapping_quart_circle

Plots

Using the Python package:

> python $CLAPP_DIR/scripts/disco/plot_field.py phi.nml mapping.nml
alternate text

Numerical solution u_h

Poisson 3d

Available examples

Periodic boundary conditions

  • ex02_01.F90 solves Poisson equation with periodic boundary conditions on a cube using a simulation parameters file and a penalized linear operator.

In the sequel, we present different examples, implementd in Fortran, to solve different (systems of) partial differential equations.