From 7a79f4c09028d016e1f1c11c54ff2c1b175d0db9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20He=C3=9F?= <rene@debian>
Date: Wed, 5 Oct 2016 14:34:37 +0200
Subject: [PATCH] Add sumfact test directory

---
 python/dune/perftool/options.py      |  2 ++
 test/CMakeLists.txt                  |  2 ++
 test/sumfact/CMakeLists.txt          |  1 +
 test/sumfact/poisson/CMakeLists.txt  | 11 +++++++++++
 test/sumfact/poisson/poisson.mini    | 18 ++++++++++++++++++
 test/sumfact/poisson/poisson.ufl     |  8 ++++++++
 test/sumfact/poisson/poisson_dg.mini | 18 ++++++++++++++++++
 test/sumfact/poisson/poisson_dg.ufl  | 26 ++++++++++++++++++++++++++
 8 files changed, 86 insertions(+)
 create mode 100644 test/sumfact/CMakeLists.txt
 create mode 100644 test/sumfact/poisson/CMakeLists.txt
 create mode 100644 test/sumfact/poisson/poisson.mini
 create mode 100644 test/sumfact/poisson/poisson.ufl
 create mode 100644 test/sumfact/poisson/poisson_dg.mini
 create mode 100644 test/sumfact/poisson/poisson_dg.ufl

diff --git a/python/dune/perftool/options.py b/python/dune/perftool/options.py
index 8ae4b6c5..9a0bc6c8 100644
--- a/python/dune/perftool/options.py
+++ b/python/dune/perftool/options.py
@@ -36,6 +36,8 @@ def get_form_compiler_arguments():
     parser.add_argument("--ini-file", type=str, help="An inifile to use. A generated driver will be hard-coded to it, a [formcompiler] section will be used as default values to form compiler arguments (use snake case)")
     parser.add_argument("--timer", action="store_true", help="measure times")
     parser.add_argument("--project-basedir", type=str, help="The base (build) directory of the dune-perftool project")
+    # TODO at some point this help description should be updated
+    parser.add_argument("--sumfact", action="store_true", help="Use sumfactorization")
 
     # Modify the positional argument to not be a list
     args = vars(parser.parse_args())
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index d41b9394..f0812d3e 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -3,3 +3,5 @@ add_subdirectory(laplace)
 add_subdirectory(nonlinear)
 add_subdirectory(poisson)
 add_subdirectory(stokes)
+
+add_subdirectory(sumfact)
diff --git a/test/sumfact/CMakeLists.txt b/test/sumfact/CMakeLists.txt
new file mode 100644
index 00000000..6ef2765c
--- /dev/null
+++ b/test/sumfact/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(poisson)
diff --git a/test/sumfact/poisson/CMakeLists.txt b/test/sumfact/poisson/CMakeLists.txt
new file mode 100644
index 00000000..6cdc670b
--- /dev/null
+++ b/test/sumfact/poisson/CMakeLists.txt
@@ -0,0 +1,11 @@
+# 1. Poisson Test Case: source f, bc g
+dune_add_formcompiler_system_test(UFLFILE poisson.ufl
+                                  BASENAME sumfact_poisson
+                                  INIFILE poisson.mini
+                                  )
+
+# 2. Poisson Test Case: DG, f + pure dirichlet
+dune_add_formcompiler_system_test(UFLFILE poisson_dg.ufl
+                                  BASENAME sumfact_poisson_dg
+                                  INIFILE poisson_dg.mini
+                                  )
diff --git a/test/sumfact/poisson/poisson.mini b/test/sumfact/poisson/poisson.mini
new file mode 100644
index 00000000..5f07c985
--- /dev/null
+++ b/test/sumfact/poisson/poisson.mini
@@ -0,0 +1,18 @@
+__name = sumfact_poisson_{__exec_suffix}
+__exec_suffix = numdiff, symdiff | expand num
+
+lowerleft = 0.0 0.0
+upperright = 1.0 1.0
+elements = 32 32
+elementType = simplical
+
+[wrapper.vtkcompare]
+name = {__name}
+reference = poisson_ref
+extension = vtu
+
+[formcompiler]
+numerical_jacobian = 1, 0 | expand num
+exact_solution_expression = g
+compare_l2errorsquared = 1e-6
+sumfact = 1
diff --git a/test/sumfact/poisson/poisson.ufl b/test/sumfact/poisson/poisson.ufl
new file mode 100644
index 00000000..8c62dd3a
--- /dev/null
+++ b/test/sumfact/poisson/poisson.ufl
@@ -0,0 +1,8 @@
+f = Expression("Dune::FieldVector<double,2> c(0.5); c-= x; return 4.*(1.-c.two_norm2())*std::exp(-1.*c.two_norm2());")
+g = Expression("Dune::FieldVector<double,2> c(0.5); c-= x; return std::exp(-1.*c.two_norm2());")
+
+V = FiniteElement("CG", "triangle", 1, dirichlet_expression=g)
+u = TrialFunction(V)
+v = TestFunction(V)
+
+forms = [(inner(grad(u), grad(v)) - f*v)*dx]
diff --git a/test/sumfact/poisson/poisson_dg.mini b/test/sumfact/poisson/poisson_dg.mini
new file mode 100644
index 00000000..8a2000a4
--- /dev/null
+++ b/test/sumfact/poisson/poisson_dg.mini
@@ -0,0 +1,18 @@
+__name = sumfact_poisson_dg_{__exec_suffix}
+__exec_suffix = numdiff, symdiff | expand num
+
+lowerleft = 0.0 0.0
+upperright = 1.0 1.0
+elements = 32 32
+elementType = simplical
+
+[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
+sumfact = 1
diff --git a/test/sumfact/poisson/poisson_dg.ufl b/test/sumfact/poisson/poisson_dg.ufl
new file mode 100644
index 00000000..0ee5a857
--- /dev/null
+++ b/test/sumfact/poisson/poisson_dg.ufl
@@ -0,0 +1,26 @@
+f = Expression("Dune::FieldVector<double,2> c(0.5); c-= x; return 4.*(1.-c.two_norm2())*std::exp(-1.*c.two_norm2());")
+g = Expression("Dune::FieldVector<double,2> c(0.5); c-= x; return std::exp(-1.*c.two_norm2());", on_intersection=True)
+
+cell = triangle
+V = FiniteElement("DG", cell, 1)
+
+u = TrialFunction(V)
+v = TestFunction(V)
+
+n = FacetNormal(cell)('+')
+
+gamma = 1.0
+theta = 1.0
+
+r = inner(grad(u), grad(v))*dx \
+  + inner(n, avg(grad(u)))*jump(v)*dS \
+  + gamma*jump(u)*jump(v)*dS \
+  + theta*jump(u)*inner(avg(grad(v)), n)*dS \
+  - inner(n, grad(u))*v*ds \
+  + gamma*u*v*ds \
+  - theta*u*inner(grad(v), n)*ds \
+  - f*v*dx \
+  + theta*g*inner(grad(v), n)*ds \
+  - gamma*g*v*ds
+
+forms = [r]
-- 
GitLab