]> git.unchartedbackwaters.co.uk Git - francis/excafe_benchmarks.git/commitdiff
Add vector laplacian example.
authorFrancis Russell <francis@unchartedbackwaters.co.uk>
Thu, 2 Aug 2012 20:14:25 +0000 (21:14 +0100)
committerFrancis Russell <francis@unchartedbackwaters.co.uk>
Thu, 2 Aug 2012 20:36:49 +0000 (21:36 +0100)
.gitignore
benchmark.mk.in
common/benchmark.cpp.tmpl
common/generate_ufl_rules.sh
laplacian_2d/Makefile
vector_laplacian_2d/Makefile [new file with mode: 0644]
vector_laplacian_2d/vector_laplacian_f0.tmpl [new file with mode: 0644]
vector_laplacian_2d/vector_laplacian_f1.tmpl [new file with mode: 0644]
vector_laplacian_2d/vector_laplacian_f2.tmpl [new file with mode: 0644]
vector_laplacian_2d/vector_laplacian_f3.tmpl [new file with mode: 0644]
vector_laplacian_2d/vector_laplacian_f4.tmpl [new file with mode: 0644]

index f0fb820c308b76816023022bdf351007e741d9b3..0232325175ad14870f52970e45e0fe72695e3f9e 100644 (file)
@@ -7,7 +7,6 @@
 /mass_matrix_2d/ufl_rules.mk
 /mass_matrix_2d/benchmark_f?_p?_q?
 /mass_matrix_2d/benchmark_f?_p?_q?.cpp
-/mass_matrix_2d/mass_matrix_f?_p?_q?.cpp
 /mass_matrix_2d/mass_matrix_f?_p?_q?.ufl
 /mass_matrix_2d/mass_matrix_f?_p?_q?_tensor.ufl
 /mass_matrix_2d/mass_matrix_f?_p?_q?_quadrature.ufl
 /laplacian_2d/ufl_rules.mk
 /laplacian_2d/benchmark_f?_p?_q?
 /laplacian_2d/benchmark_f?_p?_q?.cpp
-/laplacian_2d/laplacian_f?_p?_q?.cpp
 /laplacian_2d/laplacian_f?_p?_q?.ufl
 /laplacian_2d/laplacian_f?_p?_q?_tensor.ufl
 /laplacian_2d/laplacian_f?_p?_q?_quadrature.ufl
 /laplacian_2d/laplacian_f?_p?_q?_tensor.h
 /laplacian_2d/laplacian_f?_p?_q?_quadrature.h
 /laplacian_2d/laplacian_f?_p?_q?_excafe.h
+/vector_laplacian_2d/ufl_rules.mk
+/vector_laplacian_2d/benchmark_f?_p?_q?
+/vector_laplacian_2d/benchmark_f?_p?_q?.cpp
+/vector_laplacian_2d/vector_laplacian_f?_p?_q?.ufl
+/vector_laplacian_2d/vector_laplacian_f?_p?_q?_tensor.ufl
+/vector_laplacian_2d/vector_laplacian_f?_p?_q?_quadrature.ufl
+/vector_laplacian_2d/vector_laplacian_f?_p?_q?_tensor.h
+/vector_laplacian_2d/vector_laplacian_f?_p?_q?_quadrature.h
+/vector_laplacian_2d/vector_laplacian_f?_p?_q?_excafe.h
index 81eb6bfa1629af6e09436a5a95f7c92a1cea6a74..11e1128e51e9a2e64a179127b07789bdab96a62d 100644 (file)
@@ -3,7 +3,7 @@ default: tractable-benchmarks
 include ./ufl_rules.mk
 
 ufl_rules.mk: ../common/generate_ufl_rules.sh
-       ./$^ ${MAT_TYPE} > $@ 
+       ./$^ ${MAT_TYPE} ${FIELD_RANK} > $@ 
 
 EXCAFE_LOCATION=${HOME}/excafe
 MASS_MATRIX_2D_GENERATOR=${EXCAFE_LOCATION}/mass_matrix_generator_2d/generator
index 87a5d726819fba894cf585979b3247b9c6397781..f36d7a652dc7106d8fa6535903de8deaae63abf2 100644 (file)
 #include HEADER_EXCAFE
 
 static const ufc::shape CELL_SHAPE    = ufc::triangle;
-static const int        CELL_VERTICES = 3;
 
-int dofsPerField(const int degree)
+int getTopologicalDimension(const ufc::shape shape)
 {
-  assert(degree >= 1);
+  switch(shape)
+  {
+    case ufc::triangle: return 2;
+    case ufc::tetrahedron: return 3;
+    default:
+    {
+      assert(false && "Unsupported shape.");
+    }
+  }
+}
+
+int numVertices(const ufc::shape shape)
+{
+  switch(shape)
+  {
+    case ufc::triangle: return 3;
+    case ufc::tetrahedron: return 4;
+    default:
+    {
+      assert(false && "Unsupported shape.");
+    }
+  }
+}
+
+int power(const int x, const int y)
+{
+  assert(y >= 0);
+
+  int result = 1;
+  for(int i=0; i<y; ++i)
+    result *= x;
+
+  return result;
+}
+
+int getSpaceDimension(const int n)
+{
+  assert(n >= 1);
 
   int dofs = 0;
-  for(int m=0; m<degree+1; ++m)
-    for(int n=0; m+n<degree+1; ++n)
-      ++dofs;
+  if (CELL_SHAPE == ufc::triangle)
+  {
+    dofs = (n*n + 3*n + 2)/2;
+  }
+  else if (CELL_SHAPE == ufc::tetrahedron)
+  {
+    dofs = (n*n*n + 6*n*n + 11*n + 6)/6;
+  }
+  else
+  {
+    assert(false && "Unsupported element shape.");
+  }
 
-  return dofs;
+  return dofs * power(getTopologicalDimension(CELL_SHAPE), FIELD_RANK);
 }
 
 void checkPAPI(const int value)
@@ -211,20 +256,8 @@ private:
 
   void initCellData(const ufc::shape shape)
   {
-    switch(shape)
-    {
-      case ufc::triangle:
-      {
-        dimension = 2;
-        vertices = 3;
-        break;
-      }
-      default:
-      {
-        std::cerr << "Unimplemented cell shape." << std::endl;
-        exit(EXIT_FAILURE);
-      }
-    }
+    vertices = numVertices(shape);
+    dimension = getTopologicalDimension(shape);
 
     vertexData.reset(new double[dimension * vertices]);
     vertexPointers.reset(new double*[vertices]);
@@ -311,8 +344,8 @@ int main(int argc, char** argv)
   static const char* const childOption = "--child";
   const bool isChild = argc == 3 && strcmp(argv[1], childOption) == 0;
 
-  static const int pDofs = dofsPerField(P_VALUE);
-  static const int qDofs = dofsPerField(Q_VALUE);
+  static const int pDofs = getSpaceDimension(P_VALUE);
+  static const int qDofs = getSpaceDimension(Q_VALUE);
   static const int numProcs = 100;
   const std::size_t batchSize = 10 * 1000;
   const long operations = (1000 * 1000 * 1000)/numProcs;
index 544b373696b23a0f652f5afbf4002ea6f5414f66..42dedcdf009833e700bf62590a9c5b76040d6b14 100755 (executable)
@@ -5,6 +5,7 @@ CLEAN_FILES=""
 INTERMEDIATES=""
 ECHO="/bin/echo"
 MAT_TYPE=${1:?}
+FIELD_RANK=${2:?}
 
 for NF in 1 2 3 4; do
   for P in 1 2 3; do
@@ -53,7 +54,7 @@ for NF in 1 2 3 4; do
 
       # Generate dependencies for benchmark executable
       ${ECHO} "${BENCHMARK_SOURCE}: ${BENCHMARK_TEMPLATE}"
-      ${ECHO} -e "\tm4 -DMAT_TYPE=${MAT_TYPE} -DNF_VALUE=${NF} -DP_VALUE=${P} -DQ_VALUE=${Q} \$^ > \$@"
+      ${ECHO} -e "\tm4 -DMAT_TYPE=${MAT_TYPE} -DNF_VALUE=${NF} -DP_VALUE=${P} -DQ_VALUE=${Q} -DFIELD_RANK=${FIELD_RANK} \$^ > \$@"
       ${ECHO} "${BENCHMARK_EXECUTABLE}: ${BENCHMARK_SOURCE} ${FFC_BUILT_SOURCES} ${EXCAFE_BUILT_SOURCES}"
       ${ECHO} -e '\t${CXX} ${CXXFLAGS} ${LDFLAGS} $< -o $@'
 
index 0cb63a1ebf3291d270ec264c5bddd9eebd4180c3..2d2825dbfc4735aceab76d71bb9537b91fd1aa67 100644 (file)
@@ -1,4 +1,6 @@
 MAT_TYPE="laplacian"
+FIELD_RANK="0"
+
 include ../benchmark.mk
 
 tractable-benchmarks: benchmark_f1_p1_q1 benchmark_f1_p2_q3 \
diff --git a/vector_laplacian_2d/Makefile b/vector_laplacian_2d/Makefile
new file mode 100644 (file)
index 0000000..ff4a04f
--- /dev/null
@@ -0,0 +1,18 @@
+MAT_TYPE="vector_laplacian"
+FIELD_RANK="1"
+
+include ../benchmark.mk
+
+tractable-benchmarks: benchmark_f1_p1_q1 benchmark_f1_p2_q3 \
+benchmark_f2_p1_q1 benchmark_f2_p2_q3 benchmark_f3_p1_q1 \
+benchmark_f1_p1_q2 benchmark_f1_p2_q4 \
+benchmark_f2_p1_q2 benchmark_f2_p2_q4 benchmark_f3_p1_q2 \
+benchmark_f4_p1_q1 benchmark_f1_p1_q3 benchmark_f1_p3_q1 \
+benchmark_f2_p1_q3 benchmark_f2_p3_q1 benchmark_f3_p1_q3 \
+benchmark_f4_p1_q2 benchmark_f1_p1_q4 benchmark_f1_p3_q2 \
+benchmark_f2_p1_q4 benchmark_f2_p3_q2 benchmark_f3_p1_q4 \
+benchmark_f4_p1_q3 benchmark_f1_p2_q1 benchmark_f1_p3_q3 \
+benchmark_f2_p2_q1 benchmark_f2_p3_q3 benchmark_f3_p2_q1 \
+benchmark_f4_p1_q4 benchmark_f1_p2_q2 benchmark_f1_p3_q4 \
+benchmark_f2_p2_q2 benchmark_f2_p3_q4 benchmark_f3_p2_q2 \
+benchmark_f4_p2_q1
diff --git a/vector_laplacian_2d/vector_laplacian_f0.tmpl b/vector_laplacian_2d/vector_laplacian_f0.tmpl
new file mode 100644 (file)
index 0000000..9572175
--- /dev/null
@@ -0,0 +1,6 @@
+element   = VectorElement("Lagrange", "triangle", Q_VALUE)
+
+v = TestFunction(element)
+u = TrialFunction(element)
+
+a = inner(grad(v), grad(u))*dx
diff --git a/vector_laplacian_2d/vector_laplacian_f1.tmpl b/vector_laplacian_2d/vector_laplacian_f1.tmpl
new file mode 100644 (file)
index 0000000..cca9ea6
--- /dev/null
@@ -0,0 +1,9 @@
+element   = VectorElement("Lagrange", "triangle", Q_VALUE)
+element_f = VectorElement("Lagrange", "triangle", P_VALUE)
+
+v = TestFunction(element)
+u = TrialFunction(element)
+
+f = Coefficient(element_f)
+
+a = div(f)*inner(grad(v), grad(u))*dx
diff --git a/vector_laplacian_2d/vector_laplacian_f2.tmpl b/vector_laplacian_2d/vector_laplacian_f2.tmpl
new file mode 100644 (file)
index 0000000..6d6b1f6
--- /dev/null
@@ -0,0 +1,10 @@
+element   = VectorElement("Lagrange", "triangle", Q_VALUE)
+element_f = VectorElement("Lagrange", "triangle", P_VALUE)
+
+v = TestFunction(element)
+u = TrialFunction(element)
+
+f = Coefficient(element_f)
+g = Coefficient(element_f)
+
+a = div(f)*div(g)*inner(grad(v), grad(u))*dx
diff --git a/vector_laplacian_2d/vector_laplacian_f3.tmpl b/vector_laplacian_2d/vector_laplacian_f3.tmpl
new file mode 100644 (file)
index 0000000..9e59a36
--- /dev/null
@@ -0,0 +1,11 @@
+element   = VectorElement("Lagrange", "triangle", Q_VALUE)
+element_f = VectorElement("Lagrange", "triangle", P_VALUE)
+
+v = TestFunction(element)
+u = TrialFunction(element)
+
+f = Coefficient(element_f)
+g = Coefficient(element_f)
+h = Coefficient(element_f)
+
+a = div(f)*div(g)*div(h)*inner(grad(v), grad(u))*dx
diff --git a/vector_laplacian_2d/vector_laplacian_f4.tmpl b/vector_laplacian_2d/vector_laplacian_f4.tmpl
new file mode 100644 (file)
index 0000000..d78f7fc
--- /dev/null
@@ -0,0 +1,12 @@
+element   = VectorElement("Lagrange", "triangle", Q_VALUE)
+element_f = VectorElement("Lagrange", "triangle", P_VALUE)
+
+v = TestFunction(element)
+u = TrialFunction(element)
+
+f = Coefficient(element_f)
+g = Coefficient(element_f)
+h = Coefficient(element_f)
+i = Coefficient(element_f)
+
+a = div(f)*div(g)*div(h)*div(i)*inner(grad(v), grad(u))*dx