]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add testcase for the deal.II library.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 7 Nov 1998 02:12:34 +0000 (02:12 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 7 Nov 1998 02:12:34 +0000 (02:12 +0000)
git-svn-id: https://svn.dealii.org/trunk@653 0785d39b-7218-0410-832d-ea1e28bc413d

tests/deal.II/Makefile [new file with mode: 0644]
tests/deal.II/gradients.cc [new file with mode: 0644]

diff --git a/tests/deal.II/Makefile b/tests/deal.II/Makefile
new file mode 100644 (file)
index 0000000..d80ad5b
--- /dev/null
@@ -0,0 +1,93 @@
+# $Id$
+# Copyright W. Bangerth, University of Heidelberg, 1998
+
+# use debug mode by default for all testcases
+debug-mode = on
+
+###############################################################################
+# Internals
+
+D = ../..
+
+include ../../deal.II/Make.global_options
+
+
+
+
+# get lists of files we need
+cc-files    = $(wildcard *.cc)
+lib-h-files = $(wildcard ../../deal_II/include/*/*.h) \
+              $(wildcard ../../lac/include/*/*.h) \
+              $(wildcard ../../base/include/*/*.h)
+executables = $(cc-files:.cc=.testcase)
+
+# list of libraries needed to link with
+libs.g   = $D/deal.II/lib/libdeal_II.g.a $D/lac/lib/liblac.g.a $D/base/lib/libbase.g.a
+libs     = $D/deal.II/lib/libdeal_II.a   $D/lac/lib/liblac.a   $D/base/lib/libbase.a
+
+
+# check whether we use debug mode or not
+ifeq ($(debug-mode),on)
+libraries = $(libs.g)
+flags     = $(CXXFLAGS.g)
+endif
+
+ifeq ($(debug-mode),off)
+libraries = $(libs)
+flags     = $(CXXFLAGS)
+endif
+
+
+
+# rule to make executables
+%.testcase:
+       @echo ============================ Compiling Testcase:   $<
+       @$(CXX) $(flags) $< -o $@ $(libraries)
+
+
+
+
+#################################### Here comes the interesting part
+
+# make a rule for each executable
+targets = $(addsuffix .target, $(executables))
+
+# define the action of the targets: execute it. do so by re-getting
+# the right filename by dropping the suffix added for the make-rule
+%.target : %
+       @echo ============================ Executing Testcase:   $<
+       @./$<
+
+# this is the main target
+# make dependence so that it first wants to compile all files then
+# execute them
+check: $(executables) $(targets)
+
+
+
+clean:
+       -rm -f *.o *.go *~ Makefile.dep $(executables)
+
+
+
+.PHONY: check clean
+
+
+#Rule to generate the dependency file. This file is
+#automagically remade whenever needed, i.e. whenever
+#one of the cc-/h-files changed. Make detects whether
+#to remake this file upon inclusion at the bottom
+#of this file.
+#
+#use perl to generate rules for the .go files as well
+#as to make rules not for tria.o and the like, but
+#rather for libnumerics.a(tria.o)
+Makefile.dep: $(cc-files) $(h-files) $(lib-h-files) Makefile
+       @echo ============================ Remaking Makefile
+       @perl ../../deal.II/Make_dep.pl ./Obj $(INCLUDE) $(cc-files) | \
+               perl -pi -e 's?^./Obj.a\((.*)\.o\):?$$1.testcase:?g;'   \
+               > Makefile.dep
+
+
+include Makefile.dep
+
diff --git a/tests/deal.II/gradients.cc b/tests/deal.II/gradients.cc
new file mode 100644 (file)
index 0000000..15a5f04
--- /dev/null
@@ -0,0 +1,84 @@
+// test for correctness of gradients on a given cell
+
+
+#include <grid/tria.h>
+#include <grid/tria_boundary.h>
+#include <grid/dof.h>
+#include <fe/fe_values.h>
+#include <fe/fe_lib.lagrange.h>
+#include <base/quadrature_lib.h>
+#include <grid/tria_iterator.h>
+#include <grid/dof_accessor.h>
+#include <lac/dvector.h>
+
+
+
+
+int main () {
+  Triangulation<2> tria;
+  tria.create_hypercube (0,1);
+  tria.begin_active()->vertex(2)(0) = 2;
+
+  FELinear<2> fe;
+  DoFHandler<2> dof(&tria);
+  dof.distribute_dofs(fe);
+
+  StraightBoundary<2> b;
+  QTrapez<2> q;
+  FEValues<2> fevalues(fe,q,update_gradients);
+  fevalues.reinit (dof.begin_active(),b);
+  
+  
+  dVector val(4);
+
+  cout << "------------------------------------------------------" << endl
+       << "Testing transformation of gradients of shape function:" << endl;
+  
+                                  // test for each of the four
+                                  // shape functions
+  for (unsigned int vertex=0; vertex<4; ++vertex)
+    {
+      val.clear ();
+      val(vertex) = 1;
+
+      vector<Tensor<1,2> > grads(4);
+      fevalues.get_function_grads (val, grads);
+
+      
+      bool ok;
+      switch (vertex) 
+       {
+         case 0:
+               ok = ((grads[0] == Point<2>(-1,-1)) &&
+                     (grads[1] == Point<2>(0,-1)) &&
+                     (grads[2] == Point<2>(-1,1)) &&
+                     (grads[3] == Point<2>(0,0)));
+               break;
+         case 1:
+               ok = ((grads[0] == Point<2>(1,0)) &&
+                     (grads[1] == Point<2>(0,0)) &&
+                     (grads[2] == Point<2>(1,-2)) &&
+                     (grads[3] == Point<2>(0,-1)));
+               break;
+         case 2:
+               ok = ((grads[0] == Point<2>(0,0)) &&
+                     (grads[1] == Point<2>(0.5,0)) &&
+                     (grads[2] == Point<2>(0,1)) &&
+                     (grads[3] == Point<2>(0.5,0.5)));
+               break;
+         case 3:
+               ok = ((grads[0] == Point<2>(0,1)) &&
+                     (grads[1] == Point<2>(-0.5,1)) &&
+                     (grads[2] == Point<2>(0,0)) &&
+                     (grads[3] == Point<2>(-0.5,0.5)));
+               break;
+       };
+
+      cout << "  Shape function " << vertex
+          << ": "
+          << (ok ? "OK" : "WRONG!")
+          << endl;
+    };
+
+  cout << "------------------------------------------------------" << endl;
+};

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.