From f7614c132828b622b94c195f8cbb9d10bf40b2fc Mon Sep 17 00:00:00 2001 From: wolf Date: Sat, 7 Nov 1998 02:12:34 +0000 Subject: [PATCH] Add testcase for the deal.II library. git-svn-id: https://svn.dealii.org/trunk@653 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/deal.II/Makefile | 93 ++++++++++++++++++++++++++++++++++++++ tests/deal.II/gradients.cc | 84 ++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 tests/deal.II/Makefile create mode 100644 tests/deal.II/gradients.cc diff --git a/tests/deal.II/Makefile b/tests/deal.II/Makefile new file mode 100644 index 0000000000..d80ad5bdb9 --- /dev/null +++ b/tests/deal.II/Makefile @@ -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 index 0000000000..15a5f04a21 --- /dev/null +++ b/tests/deal.II/gradients.cc @@ -0,0 +1,84 @@ +// test for correctness of gradients on a given cell + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + + +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 > 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; +}; -- 2.39.5