From de673222b55f9ff2ab349aaa43b0404767e0eb42 Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Tue, 17 Jan 2017 14:10:13 +0100
Subject: [PATCH] Add poisson tensor test examples

---
 test/poisson/CMakeLists.txt         | 12 +++++++++++
 test/poisson/poisson_dg_tensor.mini | 17 +++++++++++++++
 test/poisson/poisson_dg_tensor.ufl  | 32 +++++++++++++++++++++++++++++
 test/poisson/poisson_tensor.mini    | 17 +++++++++++++++
 test/poisson/poisson_tensor.ufl     | 15 ++++++++++++++
 5 files changed, 93 insertions(+)
 create mode 100644 test/poisson/poisson_dg_tensor.mini
 create mode 100644 test/poisson/poisson_dg_tensor.ufl
 create mode 100644 test/poisson/poisson_tensor.mini
 create mode 100644 test/poisson/poisson_tensor.ufl

diff --git a/test/poisson/CMakeLists.txt b/test/poisson/CMakeLists.txt
index 844fdce8..e1925db7 100644
--- a/test/poisson/CMakeLists.txt
+++ b/test/poisson/CMakeLists.txt
@@ -60,6 +60,18 @@ dune_add_formcompiler_system_test(UFLFILE poisson_dg_quadrilateral.ufl
                                   INIFILE poisson_dg_quadrilateral.mini
                                   )
 
+# 10. Poisson Test Case with a full permeability tensor
+dune_add_formcompiler_system_test(UFLFILE poisson_tensor.ufl
+                                  BASENAME poisson_tensor
+                                  INIFILE poisson_tensor.mini
+                                  )
+
+# 11. Poisson Test Case: DG with full permeability tensor
+dune_add_formcompiler_system_test(UFLFILE poisson_dg_tensor.ufl
+                                  BASENAME poisson_dg_tensor
+                                  INIFILE poisson_dg_tensor.mini
+                                  )
+
 # the reference vtk file
 add_executable(poisson_dg_ref reference_main.cc)
 set_target_properties(poisson_dg_ref PROPERTIES EXCLUDE_FROM_ALL 1)
diff --git a/test/poisson/poisson_dg_tensor.mini b/test/poisson/poisson_dg_tensor.mini
new file mode 100644
index 00000000..f3463f5c
--- /dev/null
+++ b/test/poisson/poisson_dg_tensor.mini
@@ -0,0 +1,17 @@
+__name = poisson_dg_tensor_{__exec_suffix}
+__exec_suffix = numdiff, symdiff | expand num
+
+lowerleft = 0.0 0.0
+extension = 1.0 1.0
+cells = 32 32
+elementType = quadrilateral
+
+[wrapper.vtkcompare]
+name = {__name}
+reference = poisson_dg_ref
+extension = vtu
+
+[formcompiler]
+numerical_jacobian = 1, 0 | expand num
+exact_solution_expression = g
+compare_l2errorsquared = 2e-5
diff --git a/test/poisson/poisson_dg_tensor.ufl b/test/poisson/poisson_dg_tensor.ufl
new file mode 100644
index 00000000..f88ec567
--- /dev/null
+++ b/test/poisson/poisson_dg_tensor.ufl
@@ -0,0 +1,32 @@
+cell = quadrilateral
+
+x = SpatialCoordinate(cell)
+
+I = Identity(2)
+A = as_matrix([[x[i]*x[j] + I[i,j] for j in range(2)] for i in range(2)])
+g = x[0]**2 + x[1]**2
+c = 8.
+f = -4.
+
+V = FiniteElement("DG", cell, 1)
+
+u = TrialFunction(V)
+v = TestFunction(V)
+
+n = FacetNormal(cell)('+')
+
+gamma = 1.0
+theta = -1.0
+
+r = (inner(A*grad(u), grad(v)) + c*u*v)*dx \
+  + inner(n, A*avg(grad(u)))*jump(v)*dS \
+  + gamma*jump(u)*jump(v)*dS \
+  + theta*jump(u)*inner(A*avg(grad(v)), n)*dS \
+  - inner(n, A*grad(u))*v*ds \
+  + gamma*u*v*ds \
+  - theta*u*inner(A*grad(v), n)*ds \
+  - f*v*dx \
+  + theta*g*inner(A*grad(v), n)*ds \
+  - gamma*g*v*ds
+
+forms = [r]
diff --git a/test/poisson/poisson_tensor.mini b/test/poisson/poisson_tensor.mini
new file mode 100644
index 00000000..dd922fef
--- /dev/null
+++ b/test/poisson/poisson_tensor.mini
@@ -0,0 +1,17 @@
+__name = poisson_tensor_{__exec_suffix}
+__exec_suffix = numdiff, symdiff | expand num
+
+lowerleft = 0.0 0.0
+upperright = 1.0 1.0
+elements = 32 32
+elementType = quadrilateral
+
+[wrapper.vtkcompare]
+name = {__name}
+reference = poisson_ref
+extension = vtu
+
+[formcompiler]
+numerical_jacobian = 1, 0 | expand num
+exact_solution_expression = g
+compare_l2errorsquared = 1e-6
diff --git a/test/poisson/poisson_tensor.ufl b/test/poisson/poisson_tensor.ufl
new file mode 100644
index 00000000..c8d936ac
--- /dev/null
+++ b/test/poisson/poisson_tensor.ufl
@@ -0,0 +1,15 @@
+cell = triangle
+
+x = SpatialCoordinate(cell)
+
+I = Identity(2)
+A = as_matrix([[x[i]*x[j] + I[i,j] for j in range(2)] for i in range(2)])
+g = x[0]**2 + x[1]**2
+c = 8.
+f = -4.
+
+V = FiniteElement("CG", cell, 1, dirichlet_expression=g)
+u = TrialFunction(V)
+v = TestFunction(V)
+
+forms = [(inner(A*grad(u), grad(v)) + c*u*v -f*v)*dx]
-- 
GitLab