]> https://gitweb.dealii.org/ - dealii.git/commitdiff
new NamedData and NamedSelection classes
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Sun, 13 Sep 2009 19:56:31 +0000 (19:56 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Sun, 13 Sep 2009 19:56:31 +0000 (19:56 +0000)
git-svn-id: https://svn.dealii.org/trunk@19453 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/Makefile
tests/base/bdm.cc
tests/base/named_data.cc [new file with mode: 0644]
tests/base/named_data/cmp/generic [new file with mode: 0644]
tests/deal.II/block_info.cc

index ce67d3a7fa6cf2e31e270eca9be42df3dee72dcb..932f13da0c93148ce7975e0b1ff412c74c3a51de 100644 (file)
@@ -66,6 +66,7 @@ tests_x =  geometry_info_* \
           reference \
           quadrature_* qprojector \
           path_search \
+          named_data \
           slice_vector \
           table \
           tensor \
index a7d7864359ec780577f96675bf8d6471ae75007d..35169a88d848348ca756b4aa33c313d6b9af92a3 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$ 
 //
-//    Copyright (C) 2000, 2001, 2002, 2003, 2004 by the deal.II authors
+//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2009 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -13,7 +13,6 @@
 
 #include "../tests.h"
 #include <iomanip>
-#include <iomanip>
 #include <fstream>
 #include <cmath>
 
diff --git a/tests/base/named_data.cc b/tests/base/named_data.cc
new file mode 100644 (file)
index 0000000..5a71a36
--- /dev/null
@@ -0,0 +1,85 @@
+//-----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2009 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.
+//
+//-----------------------------------------------------------------------------
+
+
+#include "../tests.h"
+#include <base/named_data.h>
+#include <base/logstream.h>
+
+#include <fstream>
+#include <boost/shared_ptr.hpp>
+
+template<typename DATA>
+void
+test_const(const NamedData<DATA>& data)
+{
+  NamedData<DATA> newdata;
+  newdata.merge(data);
+  data.print(deallog);
+  
+  deallog << "Const should be true: " << (newdata.is_const() ? "true" : "false") << std::endl;
+}
+
+template<typename DATA>
+void
+test_selector(const NamedData<DATA>& data)
+{
+  NamedSelection select;
+  select.add("P1");
+  select.add("P6");
+  select.add("P5");  
+  select.add("P3");
+  select.initialize(data);
+
+  for (unsigned int i=0;i<select.size();++i)
+    {
+      deallog << "Selection " << i << ':';
+      if (select(i) != deal_II_numbers::invalid_unsigned_int)
+       deallog << data.name(select(i)) << ' ' << *data(select(i));
+      deallog << std::endl;
+    }
+}
+
+void
+test_shared_pointer()
+{
+  NamedData<boost::shared_ptr<double> > data;
+  deallog << "const" << data.is_const() << std::endl;
+  boost::shared_ptr<double> p = boost::shared_ptr<double>(new double);
+  data.add(p, "P1");
+  p = boost::shared_ptr<double>(new double);
+  data.add(p, "P2");
+  p = boost::shared_ptr<double>(new double);
+  data.add(p, "P3");
+  p = boost::shared_ptr<double>(new double);
+  data.add(p, "P4");
+  p = boost::shared_ptr<double>(new double);
+  data.add(p, "P5");
+
+  for (unsigned int i=0;i<data.size();++i)
+    *data(i) = i+0.5;
+
+  test_const(data);
+  test_selector(data);
+}
+
+
+int main ()
+{
+  std::ofstream logfile("named_data/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+//  deallog.log_cerr();
+
+  test_shared_pointer();
+}
diff --git a/tests/base/named_data/cmp/generic b/tests/base/named_data/cmp/generic
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
index 080fea764474b28f3a4a19032042c97ec9cdcf7c..705f22ce25d55f713bba25dc22e3783d10d92d40 100644 (file)
@@ -83,7 +83,7 @@ int main ()
 {
   std::ofstream logfile("block_info/output");
   deallog.attach(logfile);
-  deallog.depth_console(10);
+  deallog.depth_console(0);
 
   FE_Q<2> q21(1);
   FE_Q<2> q22(2);

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.