]> https://gitweb.dealii.org/ - dealii.git/commitdiff
test patches
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Mon, 16 Jan 2006 13:03:31 +0000 (13:03 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Mon, 16 Jan 2006 13:03:31 +0000 (13:03 +0000)
git-svn-id: https://svn.dealii.org/trunk@12047 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/patches.h [new file with mode: 0644]

diff --git a/tests/base/patches.h b/tests/base/patches.h
new file mode 100644 (file)
index 0000000..3617b53
--- /dev/null
@@ -0,0 +1,70 @@
+//-----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2006 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.
+//
+//-----------------------------------------------------------------------------
+
+// Function for dreating a set of patches with different subgrids.
+
+// To be included after all headers
+
+
+double cell_coordinates [3][8] =
+{
+      { 0, 1, 0, 1, 0, 1, 0, 1 },
+      { 0, 0, 1, 1, 0, 0, 1, 1 },
+      { 0, 0, 0, 0, 1, 1, 1, 1 }
+};
+
+      
+template <int dim, int spacedim>
+void
+create_patches(std::vector<DataOutBase::Patch<dim, spacedim> > & patches)
+{
+  for (unsigned int p=0;p<patches.size();++p)
+    {
+      DataOutBase::Patch<dim, spacedim>& patch = patches[p];
+      
+      const unsigned int nsub = p+1;
+      const unsigned int nsubp = nsub+1;
+      
+      patch.n_subdivisions = nsub;
+      for (unsigned int v=0;v<GeometryInfo<dim>::vertices_per_cell;++v)
+       for (unsigned int d=0;d<spacedim;++d)
+         patch.vertices[v](d) = p+cell_coordinates[d][v]
+                                + ((d>=dim) ? v : 0);
+      
+      unsigned int n1 = (dim>0) ? nsubp : 1;
+      unsigned int n2 = (dim>1) ? nsubp : 1;
+      unsigned int n3 = (dim>2) ? nsubp : 1;
+      unsigned int n4 = (dim>3) ? nsubp : 1;
+      patch.data.reinit(5, n1*n2*n3*n4);
+      
+      for (unsigned int i4=0;i4<n4;++i4)
+       for (unsigned int i3=0;i3<n3;++i3)
+         for (unsigned int i2=0;i2<n2;++i2)
+           for (unsigned int i1=0;i1<n1;++i1)
+             {
+               const unsigned int i = i1+nsubp*(i2+nsubp*(i3+nsubp*i4));
+               const float x1 = 2.*i1/n1-1.;
+               const float x2 = 2.*i2/n2-1.;
+               const float x3 = 2.*i3/n3-1.;
+               const float x4 = 2.*i4/n4-1.;
+               
+               patch.data(0,i) = p+x1;
+               patch.data(1,i) = p+x2;
+               patch.data(2,i) = p+x3;
+               patch.data(3,i) = p+x4;
+               patch.data(4,i) = i;//x1*x1+x2*x2+x3*x3+x4*x4;
+             }
+
+    }
+}
+

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.