]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Output of first and second derivatives
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Mon, 5 Mar 2001 11:52:43 +0000 (11:52 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Mon, 5 Mar 2001 11:52:43 +0000 (11:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@4099 0785d39b-7218-0410-832d-ea1e28bc413d

tests/fe/Makefile.in
tests/fe/derivatives.cc [new file with mode: 0644]

index 6b8c025437899dc6cb88d8973c3ff13d7a51c91e..7b7fc6b68819b6aa474c1fca18dc80ceff9dc69c 100644 (file)
@@ -23,10 +23,10 @@ debug-mode = on
 # Define library names
 ############################################################
 
-libs.g   = $(lib-deal2-3d.g) $(lib-deal2-2d.g) \
+libs.g   = $(lib-deal2-3d.g) $(lib-deal2-2d.g) $(lib-deal2-1d.g) \
            $(lib-lac.g)      \
            $(lib-base.g)
-libs     = $(lib-deal2-2d.o) \
+libs     = $(lib-deal2-3d.o) $(lib-deal2-2d.o) $(lib-deal2-1d.o) \
            $(lib-lac.o)      \
            $(lib-base.o)
 
@@ -115,6 +115,19 @@ performance: $(performance-o-files) $(libraries)
 
 ############################################################
 
+derivatives-cc-files = derivatives.cc
+
+ifeq ($(debug-mode),on)
+derivatives-o-files = $(derivatives-cc-files:.cc=.go)
+else
+derivatives-o-files = $(derivatives-cc-files:.cc=.o)
+endif
+
+derivatives: $(derivatives-o-files) $(libraries)
+       @$(CXX) $(LDFLAGS) -g -o $@ $^ $(LIBS)
+
+############################################################
+
 internals-cc-files = internals.cc
 
 ifeq ($(debug-mode),on)
diff --git a/tests/fe/derivatives.cc b/tests/fe/derivatives.cc
new file mode 100644 (file)
index 0000000..d5b56c3
--- /dev/null
@@ -0,0 +1,151 @@
+// $Id$
+// (c) Guido Kanschat
+//
+// Show the shape functions implemented.
+
+#include <base/quadrature_lib.h>
+#include <base/logstream.h>
+#include <lac/vector.h>
+#include <grid/tria.h>
+#include <grid/tria_iterator.h>
+#include <dofs/dof_accessor.h>
+#include <grid/grid_generator.h>
+#include <fe/fe_lib.lagrange.h>
+#include <fe/fe_lib.dg.h>
+#include <fe/fe_system.h>
+#include <fe/fe_values.h>
+#include <vector>
+#include <fstream>
+#include <string>
+
+char fname[50];
+
+template<int dim>
+inline void
+plot_derivatives(FiniteElement<dim>& finel,
+                const char* name)
+{
+  deallog.push (name);
+  
+  Triangulation<dim> tr;
+  DoFHandler<dim> dof(tr);
+  GridGenerator::hyper_cube(tr, 2., 5.);
+  DoFHandler<dim>::cell_iterator c = dof.begin();
+  dof.distribute_dofs(finel);
+
+  const unsigned int div = 1;
+
+  QTrapez<dim> q;
+//  QIterated<dim> q(q_trapez, div);
+  FEValues<dim> fe(finel, q, UpdateFlags(update_gradients
+                                        | update_second_derivatives));
+  fe.reinit(c);
+
+  unsigned int k=0;
+  for (unsigned int mz=0;mz<=((dim>2) ? div : 0) ;++mz)
+    {
+      for (unsigned int my=0;my<=((dim>1) ? div : 0) ;++my)
+       {
+         for (unsigned int mx=0;mx<=div;++mx)
+           {
+             deallog << q.point(k) << endl;
+         
+             for (unsigned int i=0;i<finel.dofs_per_cell;++i)
+               {
+                 deallog << "\tGrad " << fe.shape_grad(i,k);
+                 deallog << "\t2nd " << fe.shape_2nd_derivative(i,k);
+                 deallog << endl;
+               }
+             k++;
+           }
+       }
+    }
+  deallog.pop ();
+}
+
+
+
+template<int dim>
+void plot_FE_Q_shape_functions()
+{
+  FEQ1<dim> q1;
+  plot_derivatives(q1, "Q1");
+//  plot_face_shape_functions(m, q1, "Q1");
+  FEQ2<dim> q2;
+  plot_derivatives(q2, "Q2");
+//  plot_face_shape_functions(m, q2, "Q2");
+  FEQ3<dim> q3;
+  plot_derivatives(q3, "Q3");
+//  plot_face_shape_functions(m, q3, "Q3");
+  FEQ4<dim> q4;
+  plot_derivatives(q4, "Q4");
+//  plot_face_shape_functions(m, q4, "Q4");
+//    FE_Q<dim> q5(5);
+//    plot_derivatives(m, q5, "Q5");
+//    FE_Q<dim> q6(6);
+//    plot_derivatives(m, q6, "Q6");
+//    FE_Q<dim> q7(7);
+//    plot_derivatives(m, q7, "Q7");
+//    FE_Q<dim> q8(8);
+//    plot_derivatives(m, q8, "Q8");
+//    FE_Q<dim> q9(9);
+//    plot_derivatives(m, q9, "Q9");
+//    FE_Q<dim> q10(10);
+//    plot_derivatives(m, q10, "Q10");
+}
+
+
+template<int dim>
+void plot_FE_DGQ_shape_functions()
+{
+  FEDG_Q1<dim> q1;
+  plot_derivatives(q1, "DGQ1");
+//  plot_face_shape_functions(m, q1, "DGQ1");
+  FEDG_Q2<dim> q2;
+  plot_derivatives(q2, "DGQ2");
+//  plot_face_shape_functions(m, q2, "DGQ2");
+  FEDG_Q3<dim> q3;
+  plot_derivatives(q3, "DGQ3");
+//  plot_face_shape_functions(m, q3, "DGQ3");
+  FEDG_Q4<dim> q4;
+  plot_derivatives(q4, "DGQ4");
+//  plot_face_shape_functions(m, q4, "DGQ4");
+//    FE_DGQ<dim> q5(5);
+//    plot_derivatives(m, q5, "DGQ5");
+//    FE_DGQ<dim> q6(6);
+//    plot_derivatives(m, q6, "DGQ6");
+//    FE_DGQ<dim> q7(7);
+//    plot_derivatives(m, q7, "DGQ7");
+//    FE_DGQ<dim> q8(8);
+//    plot_derivatives(m, q8, "DGQ8");
+//    FE_DGQ<dim> q9(9);
+//    plot_derivatives(m, q9, "DGQ9");
+//    FE_DGQ<dim> q10(10);
+//    plot_derivatives(m, q10, "DGQ10");
+}
+
+
+int
+main()
+{
+  ofstream logfile ("derivatives.log");
+  deallog.attach (logfile);
+  logfile.precision(3);
+
+  deallog.push ("1d");
+  plot_FE_Q_shape_functions<1>();
+  deallog.pop ();
+  
+  deallog.push ("2d");
+  plot_FE_Q_shape_functions<2>();
+  plot_FE_DGQ_shape_functions<2>();
+  deallog.pop ();
+  
+  deallog.push ("3d");
+//  plot_FE_Q_shape_functions<3>();
+  deallog.pop ();
+   return 0;
+}
+
+
+

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.