From ea187869f0a9b12679e265d803281faca3516356 Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Thu, 31 Aug 2017 14:42:00 +0200
Subject: [PATCH] Add a measuring application for 3D stokes

---
 applications/CMakeLists.txt           |  1 +
 applications/stokes_dg/CMakeLists.txt |  5 +++
 applications/stokes_dg/stokes_dg.mini | 52 +++++++++++++++++++++++++++
 applications/stokes_dg/stokes_dg.ufl  | 35 ++++++++++++++++++
 4 files changed, 93 insertions(+)
 create mode 100644 applications/stokes_dg/CMakeLists.txt
 create mode 100644 applications/stokes_dg/stokes_dg.mini
 create mode 100644 applications/stokes_dg/stokes_dg.ufl

diff --git a/applications/CMakeLists.txt b/applications/CMakeLists.txt
index f472b3d2..dbafd91e 100644
--- a/applications/CMakeLists.txt
+++ b/applications/CMakeLists.txt
@@ -1,3 +1,4 @@
 add_subdirectory(poisson_dg)
 add_subdirectory(poisson_dg_tensor)
 add_subdirectory(knl)
+add_subdirectory(stokes_dg)
diff --git a/applications/stokes_dg/CMakeLists.txt b/applications/stokes_dg/CMakeLists.txt
new file mode 100644
index 00000000..c56ebf52
--- /dev/null
+++ b/applications/stokes_dg/CMakeLists.txt
@@ -0,0 +1,5 @@
+dune_add_formcompiler_system_test(UFLFILE stokes_dg.ufl
+                                  BASENAME app_stokes_dg
+                                  INIFILE stokes_dg.mini
+                                  NO_TESTS
+                                  )
diff --git a/applications/stokes_dg/stokes_dg.mini b/applications/stokes_dg/stokes_dg.mini
new file mode 100644
index 00000000..11efaf84
--- /dev/null
+++ b/applications/stokes_dg/stokes_dg.mini
@@ -0,0 +1,52 @@
+__name = app_stokes_dg_{__exec_suffix}
+__exec_suffix = deg{deg_ident}_{opcount_suffix}_level{formcompiler.instrumentation_level}
+
+deg_ident = v{formcompiler.ufl_variants.v_degree}p{formcompiler.ufl_variants.p_degree}
+opcount_suffix = opcount, nonopcount | expand opcount
+{opcount_suffix} == opcount and {formcompiler.instrumentation_level} != 4 | exclude
+
+# Calculate the size of the grid to equlibritate it to 100 MB/rank
+# Input parameters
+dim = 3
+mbperrank = 100
+ranks = 16
+floatingbytes = 8
+
+# Metaini Calculations
+memperrank = {mbperrank} * 1048576 | eval
+vdofsperdir = {formcompiler.ufl_variants.v_degree} + 1 | eval
+pdofsperdir = {formcompiler.ufl_variants.p_degree} + 1 | eval
+celldofs = {vdofsperdir} ** {dim} + {pdofsperdir} ** {dim} | eval
+cellsperrank = {memperrank} / ({floatingbytes} * {celldofs}) | eval
+cellsperdir = {cellsperrank} ** (1/{dim}) | eval | toint
+firstdircells = {ranks} * {cellsperdir} | eval
+dimminusone = {dim} - 1 | eval
+ones = 1 | repeat {dimminusone}
+otherdircells = {cellsperdir} | repeat {dimminusone}
+
+# Set up the timing identifier
+identifier = stokes_dg_deg{deg_ident}
+
+# Setup the grid!
+extension = 1.0 | repeat {dim}
+cells = {firstdircells} {otherdircells}
+partitioning = {ranks} {ones}
+
+[wrapper.vtkcompare]
+name = {__name}
+extension = vtu
+
+[formcompiler]
+fastdg = 1
+sumfact = 1
+vectorize_quad = 1
+vectorize_grads = 1
+instrumentation_level = 2, 3, 4 | expand
+opcounter = 1, 0 | expand opcount
+time_opcounter = 0, 1 | expand opcount
+quadrature_order = {formcompiler.ufl_variants.v_degree} * 2 | eval
+
+[formcompiler.ufl_variants]
+cell = hexahedron
+v_degree = 2, 3, 4, 5, 6, 7, 8, 9, 10 | expand degree
+p_degree = 1, 2, 3, 4, 5, 6, 7, 8, 9  | expand degree
diff --git a/applications/stokes_dg/stokes_dg.ufl b/applications/stokes_dg/stokes_dg.ufl
new file mode 100644
index 00000000..22678c9f
--- /dev/null
+++ b/applications/stokes_dg/stokes_dg.ufl
@@ -0,0 +1,35 @@
+cell = hexahedron
+
+x = SpatialCoordinate(cell)
+g_v = as_vector((16.*x[1]*(1.-x[1])*x[2]*(1.-x[2]), 0.0, 0.0))
+bctype = conditional(x[0] < 1. - 1e-8, 1, 0)
+
+V = VectorElement("DG", cell, v_degree)
+P = FiniteElement("DG", cell, p_degree)
+TH = V * P
+
+v, q = TestFunctions(TH)
+u, p = TrialFunctions(TH)
+
+ds = ds(subdomain_id=1, subdomain_data=bctype)
+
+n = FacetNormal(cell)('+')
+eps = -1.0
+sigma = 1.0
+
+r = inner(grad(u), grad(v))*dx \
+  - p*div(v)*dx \
+  - q*div(u)*dx \
+  + inner(avg(grad(u))*n, jump(v))*dS \
+  + sigma * inner(jump(u), jump(v))*dS \
+  - eps * inner(avg(grad(v))*n, jump(u))*dS \
+  - avg(p)*inner(jump(v), n)*dS \
+  - avg(q)*inner(jump(u), n)*dS \
+  - inner(grad(u)*n, v)*ds \
+  + p*inner(v, n)*ds \
+  + q*inner(u, n)*ds \
+  + eps * inner(grad(v)*n, u-g_v)*ds \
+  + sigma * inner(u-g_v, v)*ds \
+  - q*inner(g_v, n)*ds
+
+forms = [r]
-- 
GitLab