]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
discontinuous output
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 17 Jan 2002 20:46:28 +0000 (20:46 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 17 Jan 2002 20:46:28 +0000 (20:46 +0000)
git-svn-id: https://svn.dealii.org/trunk@5389 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/matrix_out.h
deal.II/lac/source/matrix_out.cc

index 1b12d09409e0ef0ccb70c392d1921f53a1bf3108..4ce9c56e0024b09bb25418dcd48525fa97215ced 100644 (file)
@@ -98,6 +98,12 @@ class MatrixOut : public DataOutInterface<2,2>
                                          */
        unsigned int block_size;
 
+                                      /**
+                                       * If true, plot discontinuous
+                                       * patches, one for each entry.
+                                       **/
+      bool discontinuous;
+
                                         /**
                                          * Default constructor. Set
                                          * all elements of this
@@ -105,7 +111,8 @@ class MatrixOut : public DataOutInterface<2,2>
                                          * values.
                                          */
        Options (const bool         show_absolute_values = false,
-                const unsigned int block_size           = 1);
+                const unsigned int block_size           = 1,
+                const bool         discontinuous        = false);
     };
     
                                     /**
@@ -337,23 +344,31 @@ MatrixOut::build_patches (const Matrix      &matrix,
                          const std::string &name,
                          const Options     &options)
 {
-  const unsigned int
+  unsigned int
     gridpoints_x = (matrix.n() / options.block_size
                    +
                    (matrix.n() % options.block_size != 0 ? 1 : 0)),
     gridpoints_y = (matrix.m() / options.block_size
                    +
                    (matrix.m() % options.block_size != 0 ? 1 : 0));
-               
+
+                                  // If continuous, the number of
+                                  // plotted patches is matrix size-1
+  if (!options.discontinuous)
+    {
+      --gridpoints_x;
+      --gridpoints_y;
+    }
+  
                                   // first clear old data and set it
                                   // to virgin state
   patches.clear ();
-  patches.resize ((gridpoints_x-1) * (gridpoints_y-1));
+  patches.resize ((gridpoints_x) * (gridpoints_y));
 
                                   // now build the patches
   unsigned int index=0;
-  for (unsigned int i=0; i<gridpoints_y-1; ++i)
-    for (unsigned int j=0; j<gridpoints_x-1; ++j, ++index)
+  for (unsigned int i=0; i<gridpoints_y; ++i)
+    for (unsigned int j=0; j<gridpoints_x; ++j, ++index)
       {
                                         // within each patch, order
                                         // the points in such a way
@@ -393,10 +408,18 @@ MatrixOut::build_patches (const Matrix      &matrix,
        patches[index].n_subdivisions = 1;
 
        patches[index].data.reinit (1,4);
-       patches[index].data(0,0) = get_gridpoint_value(matrix, i,   j,   options);
-       patches[index].data(0,1) = get_gridpoint_value(matrix, i,   j+1, options);
-       patches[index].data(0,2) = get_gridpoint_value(matrix, i+1, j,   options);
-       patches[index].data(0,3) = get_gridpoint_value(matrix, i+1, j+1, options);
+       if (options.discontinuous)
+         {
+           patches[index].data(0,0) = get_gridpoint_value(matrix, i, j, options);
+           patches[index].data(0,1) = get_gridpoint_value(matrix, i, j, options);
+           patches[index].data(0,2) = get_gridpoint_value(matrix, i, j, options);
+           patches[index].data(0,3) = get_gridpoint_value(matrix, i, j, options);
+         } else {
+           patches[index].data(0,0) = get_gridpoint_value(matrix, i,   j,   options);
+           patches[index].data(0,1) = get_gridpoint_value(matrix, i,   j+1, options);
+           patches[index].data(0,2) = get_gridpoint_value(matrix, i+1, j,   options);
+           patches[index].data(0,3) = get_gridpoint_value(matrix, i+1, j+1, options);
+         }
       };
 
                                   // finally set the name
index aef4b9f21da2cf8b7605ffd58f2badb8747e1e2a..f49391fb2d1f6658bbe7fd52cfa66e26f1e8c9aa 100644 (file)
 
 
 MatrixOut::Options::Options (const bool         show_absolute_values,
-                            const unsigned int block_size)
+                            const unsigned int block_size,
+                            const bool         discontinuous)
                :
                show_absolute_values (show_absolute_values),
-               block_size (block_size)
+               block_size (block_size),
+               discontinuous (discontinuous)
 {};
 
 

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.