From 0ae29fb4a221e127a51de220acd59da3d2a41467 Mon Sep 17 00:00:00 2001 From: Francis Russell Date: Thu, 2 Aug 2012 21:14:25 +0100 Subject: [PATCH] Add vector laplacian example. --- .gitignore | 11 ++- benchmark.mk.in | 2 +- common/benchmark.cpp.tmpl | 79 ++++++++++++++------ common/generate_ufl_rules.sh | 3 +- laplacian_2d/Makefile | 2 + vector_laplacian_2d/Makefile | 18 +++++ vector_laplacian_2d/vector_laplacian_f0.tmpl | 6 ++ vector_laplacian_2d/vector_laplacian_f1.tmpl | 9 +++ vector_laplacian_2d/vector_laplacian_f2.tmpl | 10 +++ vector_laplacian_2d/vector_laplacian_f3.tmpl | 11 +++ vector_laplacian_2d/vector_laplacian_f4.tmpl | 12 +++ 11 files changed, 136 insertions(+), 27 deletions(-) create mode 100644 vector_laplacian_2d/Makefile create mode 100644 vector_laplacian_2d/vector_laplacian_f0.tmpl create mode 100644 vector_laplacian_2d/vector_laplacian_f1.tmpl create mode 100644 vector_laplacian_2d/vector_laplacian_f2.tmpl create mode 100644 vector_laplacian_2d/vector_laplacian_f3.tmpl create mode 100644 vector_laplacian_2d/vector_laplacian_f4.tmpl diff --git a/.gitignore b/.gitignore index f0fb820..0232325 100644 --- a/.gitignore +++ b/.gitignore @@ -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 @@ -17,10 +16,18 @@ /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 diff --git a/benchmark.mk.in b/benchmark.mk.in index 81eb6bf..11e1128 100644 --- a/benchmark.mk.in +++ b/benchmark.mk.in @@ -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 diff --git a/common/benchmark.cpp.tmpl b/common/benchmark.cpp.tmpl index 87a5d72..f36d7a6 100644 --- a/common/benchmark.cpp.tmpl +++ b/common/benchmark.cpp.tmpl @@ -46,18 +46,63 @@ #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= 1); int dofs = 0; - for(int m=0; m \$@" + ${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 $@' diff --git a/laplacian_2d/Makefile b/laplacian_2d/Makefile index 0cb63a1..2d2825d 100644 --- a/laplacian_2d/Makefile +++ b/laplacian_2d/Makefile @@ -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 index 0000000..ff4a04f --- /dev/null +++ b/vector_laplacian_2d/Makefile @@ -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 index 0000000..9572175 --- /dev/null +++ b/vector_laplacian_2d/vector_laplacian_f0.tmpl @@ -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 index 0000000..cca9ea6 --- /dev/null +++ b/vector_laplacian_2d/vector_laplacian_f1.tmpl @@ -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 index 0000000..6d6b1f6 --- /dev/null +++ b/vector_laplacian_2d/vector_laplacian_f2.tmpl @@ -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 index 0000000..9e59a36 --- /dev/null +++ b/vector_laplacian_2d/vector_laplacian_f3.tmpl @@ -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 index 0000000..d78f7fc --- /dev/null +++ b/vector_laplacian_2d/vector_laplacian_f4.tmpl @@ -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 -- 2.47.3