]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add no_flux_04.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 24 Jan 2008 17:17:19 +0000 (17:17 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 24 Jan 2008 17:17:19 +0000 (17:17 +0000)
git-svn-id: https://svn.dealii.org/trunk@15670 0785d39b-7218-0410-832d-ea1e28bc413d

tests/deal.II/no_flux_04.cc [new file with mode: 0644]
tests/deal.II/no_flux_04/cmp/generic [new file with mode: 0644]

diff --git a/tests/deal.II/no_flux_04.cc b/tests/deal.II/no_flux_04.cc
new file mode 100644 (file)
index 0000000..361a3d0
--- /dev/null
@@ -0,0 +1,144 @@
+//----------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2007, 2008 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------------------------------------------------
+
+
+// check the creation of no-flux boundary conditions for a finite
+// element that consists of only a single set of vector components
+// (i.e. it has dim components)
+//
+// like no_flux_04 but apply the constraints to a vector field to see
+// whether the result looks alright
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <base/function.h>
+#include <base/quadrature_lib.h>
+#include <lac/vector.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_boundary_lib.h>
+#include <dofs/dof_handler.h>
+#include <dofs/dof_constraints.h>
+#include <fe/fe_q.h>
+#include <fe/fe_system.h>
+#include <fe/mapping_q1.h>
+#include <numerics/vectors.h>
+#include <numerics/data_out.h>
+
+#include <fstream>
+
+
+// a function that shows something useful on the surface of a sphere
+template <int dim>
+class RadialFunction : public Function<dim>
+{
+  public:
+    RadialFunction() : Function<dim> (dim) {}
+    
+    virtual void vector_value (const Point<dim> &p,
+                              Vector<double> &v) const
+      {
+       Assert (v.size() == dim, ExcInternalError());
+
+       switch (dim)
+         {
+           case 2:
+                 v(0) = p[0] + p[1];
+                 v(1) = p[1] - p[0];
+                 break;
+           case 3:
+                 v(0) = p[0] + p[1];
+                 v(1) = p[1] - p[0];
+                 v(2) = p[2];
+                 break;
+           default:
+                 Assert (false, ExcNotImplemented());
+         }
+      }
+};
+
+
+
+template<int dim>
+void test (const Triangulation<dim>& tr,
+          const FiniteElement<dim>& fe)
+{
+  DoFHandler<dim> dof(tr);
+  dof.distribute_dofs(fe);
+
+  deallog << "FE=" << fe.get_name()
+         << std::endl;
+
+  std::set<unsigned char> boundary_ids;
+  boundary_ids.insert (0);
+      
+  ConstraintMatrix cm;
+  VectorTools::compute_no_normal_flux_constraints (dof, 0, boundary_ids, cm);
+  cm.close ();
+
+  DoFHandler<dim> dh (tr);
+  dh.distribute_dofs (fe);
+
+  Vector<double> v(dh.n_dofs());
+  VectorTools::interpolate (dh, RadialFunction<dim>(), v);
+
+  cm.distribute (v);
+
+  std::ofstream o("x.vtk");
+  DataOut<dim> data_out;
+  data_out.attach_dof_handler (dh);
+
+  std::vector<DataComponentInterpretation::DataComponentInterpretation>
+    data_component_interpretation
+    (dim, DataComponentInterpretation::component_is_part_of_vector);
+  
+  data_out.add_data_vector (v, "x",
+                           DataOut<dim>::type_dof_data,
+                           data_component_interpretation);
+  data_out.build_patches (fe.degree);
+
+  data_out.write_vtk (o);
+}
+
+
+
+template<int dim>
+void test_hyper_sphere()
+{
+  Triangulation<dim> tr;
+  GridGenerator::hyper_ball(tr);
+
+  static const HyperBallBoundary<dim> boundary;
+  tr.set_boundary (0, boundary);
+  
+  tr.refine_global(2);
+
+  for (unsigned int degree=1; degree<6-dim; ++degree)
+    {
+      FESystem<dim> fe (FE_Q<dim>(degree), dim);
+      test(tr, fe);
+    }
+}
+
+
+int main()
+{
+  std::ofstream logfile ("no_flux_04/output");
+  deallog << std::setprecision (2);
+  deallog << std::fixed;  
+  deallog.attach(logfile);
+  deallog.depth_console (0);
+  deallog.threshold_double(1.e-12);
+
+  test_hyper_sphere<2>();
+  test_hyper_sphere<3>();
+}
diff --git a/tests/deal.II/no_flux_04/cmp/generic b/tests/deal.II/no_flux_04/cmp/generic
new file mode 100644 (file)
index 0000000..22fa52f
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::FE=FESystem<2>[FE_Q<2>(1)^2]
+DEAL::FE=FESystem<2>[FE_Q<2>(2)^2]
+DEAL::FE=FESystem<2>[FE_Q<2>(3)^2]
+DEAL::FE=FESystem<3>[FE_Q<3>(1)^3]
+DEAL::FE=FESystem<3>[FE_Q<3>(2)^3]

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.