]> https://gitweb.dealii.org/ - dealii.git/commitdiff
conversion from NamedData to AnyData and initialization of NamedSelection with AnyData
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 16 May 2014 09:40:20 +0000 (09:40 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 16 May 2014 09:40:20 +0000 (09:40 +0000)
git-svn-id: https://svn.dealii.org/trunk@32920 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/algorithms/any_data.h
deal.II/include/deal.II/base/named_data.h
deal.II/source/base/CMakeLists.txt
deal.II/source/base/named_selection.cc [new file with mode: 0644]

index 4f5550e9e35944216d9d36f77a568e18bab520b3..000d29e66ece470ca4206b8e3f8204c4e333e5e7 100644 (file)
@@ -20,6 +20,7 @@
 #include <deal.II/base/config.h>
 #include <deal.II/base/exceptions.h>
 #include <deal.II/base/subscriptor.h>
+#include <deal.II/base/named_data.h>
 
 #include <boost/any.hpp>
 #include <vector>
@@ -38,6 +39,9 @@ class AnyData :
    public Subscriptor
 {
   public:
+    /// Default constructor for empty object
+    AnyData();
+    
     /// Number of stored data objects.
     unsigned int size() const;
     
@@ -125,6 +129,10 @@ class AnyData :
     /// Find out if object is of a certain type
     template <typename type>
     bool is_type(const unsigned int i) const;
+
+    /// Conversion from old NamedData
+    template <typename type>
+    AnyData(const NamedData<type>&);
     
     /// The requested type and the stored type are different
   DeclException2(ExcTypeMismatch,
@@ -141,6 +149,18 @@ class AnyData :
 };
 
 
+AnyData::AnyData()
+{}
+
+
+template <typename type>
+AnyData::AnyData(const NamedData<type>& other)
+{
+  for (unsigned int i=0;i<other.size();++i)
+    add(other(i), other.name(i));
+}
+
+
 unsigned int
 inline
 AnyData::size () const
index 20b549080c3fc1930c79d9ec923178467c4af7ea..59e2a96b883db4844be5ecc18641b34205b20a71 100644 (file)
@@ -26,6 +26,7 @@
 
 DEAL_II_NAMESPACE_OPEN
 
+class AnyData;
 
 /**
  * @deprecated The use of this class is deprecated and AnyData should
@@ -207,6 +208,13 @@ public:
   template <typename DATA>
   void initialize(const NamedData<DATA> &data);
 
+  /**
+   * Create the index vector
+   * pointing into the AnyData
+   * object.
+   */
+  void initialize(const AnyData &data);
+
   /**
    * The number of names in this
    * object. This function may be
index 6745cb7eaf711bb1764bf2a3b38c10da6d2ca820..2041c63052f74a46c7da8081e9d1ed8134a79a76 100644 (file)
@@ -38,6 +38,7 @@ SET(_src
   memory_consumption.cc
   mpi.cc
   multithread_info.cc
+  named_selection.cc
   parallel.cc
   parameter_handler.cc
   parsed_function.cc
diff --git a/deal.II/source/base/named_selection.cc b/deal.II/source/base/named_selection.cc
new file mode 100644 (file)
index 0000000..59f45de
--- /dev/null
@@ -0,0 +1,31 @@
+// ---------------------------------------------------------------------
+// $Id: logstream.cc 31932 2013-12-08 02:15:54Z heister $
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#include <deal.II/base/named_data.h>
+#include <deal.II/algorithms/any_data.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+void
+NamedSelection::initialize(const AnyData &data)
+{
+  indices.resize(names.size());
+  for (unsigned int i=0; i<names.size(); ++i)
+    indices[i] = data.find(names[i]);
+}
+
+DEAL_II_NAMESPACE_CLOSE
+

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.