</p>
<ol>
+ <li>Removed: The class NamedData has been removed after it had been
+ superceded by AnyData a while ago. This affects the use of classes
+ in Algorithms and MeshWorker
+ <br>
+ (Guido KAnschat, 2015/04/02)
+ </li>
+
<li> Removed: The CMake configuration does not use the variable
<code>DEAL_II_CMAKE_MACROS_RELDIR</code> any more. Instead, the fixed
location <code>${DEAL_II_SHARE_RELDIR}/macros</code> is used
unconditionally
<br>
(Matthias Maier, 2015/03/26)
-
+ </li>
+
<li> Changed: The TrilinosWrappers::SparseMatrix::clear_row() function used
to call TrilinosWrappers::SparseMatrix::compress() before doing its work,
but this is neither efficient nor safe. You will now have to do this
// Since this assembler allows us to fill several vectors, the interface is
// a little more complicated as above. The pointers to the vectors have to
- // be stored in a NamedData object. While this seems to cause two extra
+ // be stored in a AnyData object. While this seems to cause two extra
// lines of code here, it actually comes handy in more complex
// applications.
MeshWorker::Assembler::ResidualSimple<Vector<double> > assembler;
- NamedData<Vector<double>* > data;
- Vector<double> *rhs = &right_hand_side;
- data.add(rhs, "RHS");
+ AnyData data;
+ data.add<Vector<double>*>(&right_hand_side, "RHS");
assembler.initialize(data);
RHSIntegrator<dim> integrator;
info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points);
// but now we need to notify the info box of the finite element function we
- // want to evaluate in the quadrature points. First, we create a NamedData
+ // want to evaluate in the quadrature points. First, we create an AnyData
// object with this vector, which is the solution we just computed.
- NamedData<Vector<double>* > solution_data;
- solution_data.add(&solution, "solution");
+ AnyData solution_data;
+ solution_data.add<const Vector<double>*>(&solution, "solution");
// Then, we tell the Meshworker::VectorSelector for cells, that we need
// the second derivatives of this solution (to compute the
// flags are already adjusted to the values and derivatives we requested
// above.
info_box.add_update_flags_boundary(update_quadrature_points);
- info_box.initialize(fe, mapping, solution_data);
+ info_box.initialize(fe, mapping, solution_data, solution);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
// The assembler stores one number per cell, but else this is the same as
// in the computation of the right hand side.
MeshWorker::Assembler::CellsAndFaces<double> assembler;
- NamedData<BlockVector<double>* > out_data;
- BlockVector<double> *est = &estimates;
- out_data.add(est, "cells");
+ AnyData out_data;
+ out_data.add<BlockVector<double>*>(&estimates, "cells");
assembler.initialize(out_data, false);
Estimator<dim> integrator;
const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1;
info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points);
- NamedData<Vector<double>* > solution_data;
- solution_data.add(&solution, "solution");
+ AnyData solution_data;
+ solution_data.add<Vector<double>*>(&solution, "solution");
info_box.cell_selector.add("solution", true, true, false);
info_box.boundary_selector.add("solution", true, false, false);
info_box.add_update_flags_cell(update_quadrature_points);
info_box.add_update_flags_boundary(update_quadrature_points);
- info_box.initialize(fe, mapping, solution_data);
+ info_box.initialize(fe, mapping, solution_data, solution);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::CellsAndFaces<double> assembler;
- NamedData<BlockVector<double>* > out_data;
- BlockVector<double> *est = &errors;
- out_data.add(est, "cells");
+ AnyData out_data;
+ out_data.add<BlockVector<double>* >(&errors, "cells");
assembler.initialize(out_data, false);
ErrorIntegrator<dim> integrator;
#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>
void add(type entry, const std::string &name);
/**
- * @brief Merge the data of another NamedData to the end of this object.
+ * @brief Merge the data of another AnyData to the end of this object.
*/
void merge(const AnyData &other);
template <class STREAM>
void list (STREAM &os) const;
- /// Conversion from old NamedData
- template <typename type>
- AnyData(const NamedData<type> &);
-
/// An entry with this name does not exist in the AnyData object.
DeclException1(ExcNameNotFound, std::string,
<< "No entry with the name " << arg1 << " exists.");
{}
-template <typename type>
-inline
-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
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2000 - 2015 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.
+//
+// ---------------------------------------------------------------------
+
+#ifndef __deal2__named_selection_h
+#define __deal2__named_selection_h
+
+#include <deal.II/base/config.h>
+#include <deal.II/algorithms/any_data.h>
+
+#include <string>
+
+DEAL_II_NAMESPACE_OPEN
+
+/**
+ * Select data from NamedData corresponding to the attached name.
+ *
+ * Given a list of names to search for (provided by add()), objects of
+ * this
+ * class provide an index list of the selected data.
+ *
+ * @author Guido Kanschat, 2009
+ */
+class NamedSelection
+{
+
+public:
+
+ /**
+ * Add a new name to be searched for in NamedData.
+ *
+ * @note Names will be added to the end of the current list.
+ */
+ void add (const std::string &name);
+
+
+ /**
+ * 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 used
+ * whether
+ * initialize() was called before or not.
+ */
+ unsigned int size() const;
+
+
+ /**
+ * Return the corresponding index in the NamedData object supplied
+ * to the
+ * last initialize(). It is an error if initialize() has not been
+ * called
+ * before.
+ *
+ * Indices are in the same order as the calls to add().
+ */
+ unsigned int operator() (unsigned int i) const;
+
+
+private:
+
+ /**
+ * The selected names.
+ */
+ std::vector<std::string> names;
+
+ /**
+ * The index map generated by initialize() and accessed by
+ * operator().
+ */
+ std::vector<unsigned int> indices;
+
+};
+
+
+inline
+unsigned int
+NamedSelection::size() const
+{
+
+ return names.size();
+
+}
+
+
+inline
+void
+NamedSelection::add(const std::string &s)
+{
+
+ names.push_back(s);
+
+}
+
+
+inline
+unsigned int
+NamedSelection::operator() (unsigned int i) const
+{
+
+ Assert (indices.size() == names.size(), ExcNotInitialized());
+
+ AssertIndexRange(i, size());
+
+ return indices[i];
+
+}
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif
*/
virtual void operator() (AnyData &out, const AnyData &in);
- /**
- * @deprecated Use the function using AnyData
- */
- virtual void operator() (NamedData<VECTOR *> &out, const NamedData<VECTOR *> &in);
-
virtual void notify(const Event &);
/**
}
- template <class VECTOR>
- void
- Newton<VECTOR>::operator() (NamedData<VECTOR *> &out, const NamedData<VECTOR *> &in)
- {
- Operator<VECTOR>::operator() (out, in);
- }
-
template <class VECTOR>
void
Newton<VECTOR>::operator() (AnyData &out, const AnyData &in)
if (debug_vectors)
{
- NamedData<VECTOR *> out;
+ AnyData out;
VECTOR *p = &u;
- out.add(p, "solution");
+ out.add<const VECTOR *>(p, "solution");
p = Du;
- out.add(p, "update");
+ out.add<const VECTOR *>(p, "update");
p = res;
- out.add(p, "residual");
+ out.add<const VECTOR *>(p, "residual");
*data_out << step;
*data_out << out;
}
if (debug_vectors)
{
- NamedData<VECTOR *> out;
+ AnyData out;
VECTOR *p = &u;
- out.add(p, "solution");
+ out.add<const VECTOR *>(p, "solution");
p = Du;
- out.add(p, "update");
+ out.add<const VECTOR *>(p, "update");
p = res;
- out.add(p, "residual");
+ out.add<const VECTOR *>(p, "residual");
*data_out << step;
*data_out << out;
}
#include <deal.II/base/config.h>
#include <deal.II/algorithms/any_data.h>
-#include <deal.II/base/named_data.h>
#include <deal.II/base/event.h>
#include <fstream>
{
public:
Operator();
-
- /**
- * Implementation of the function in the base class in order to do
- * compatibility conversions between the old and the new interface.
- */
- virtual void operator() (AnyData &out, const AnyData &in);
-
- /**
- * @deprecated It is in particular this function which should not be used
- * anymore.
- *
- * The actual operation, which is implemented in a derived class.
- */
- virtual void operator() (NamedData<VECTOR *> &out, const NamedData<VECTOR *> &in);
-
- /**
- * Set this true to avoid compatibility warnings.
- */
- bool silent_compatibility;
-
- private:
- /**
- * While we are providing compatibility functions to the old interface,
- * this variable will ensure there is no endless loop.
- */
- bool compatibility_flag;
};
/**
- * An unary operator base class, intended to output the vectors in NamedData
- * in each step of an iteration.
+ * An unary operator base class, intended to output the vectors in
+ * AnyData in each step of an iteration.
*
* @author Guido Kanschat, 2010
*/
/**
* Set the current step.
*/
- OutputOperator<VECTOR> &operator<< (unsigned int step);
-
+ void set_step(const unsigned int step);
/**
* Output all the vectors in AnyData.
*/
virtual OutputOperator<VECTOR> &operator<< (const AnyData &vectors);
- /**
- * @deprecated Output all the vectors in NamedData.
- */
- OutputOperator<VECTOR> &operator<< (const NamedData<VECTOR *> &vectors);
protected:
unsigned int step;
private:
};
template <class VECTOR>
- OutputOperator<VECTOR> &
- OutputOperator<VECTOR>::operator<< (unsigned int s)
+ inline
+ void
+ OutputOperator<VECTOR>::set_step (const unsigned int s)
{
step = s;
- return *this;
}
-}
+ /**
+ * Set the step number in OutputOperator by shifting an integer value.
+ *
+ * @relates OutputOperator
+ */
+ template <class VECTOR>
+ inline
+ OutputOperator<VECTOR> &
+ operator<< (OutputOperator<VECTOR> &out, unsigned int step)
+ {
+ out.set_step(step);
+ return out;
+ }
+}
+
DEAL_II_NAMESPACE_CLOSE
#endif
{
template <class VECTOR>
Operator<VECTOR>::Operator()
- : silent_compatibility(false), compatibility_flag(false)
{}
-
- template <class VECTOR>
- void
- Operator<VECTOR>::operator() (AnyData &out, const AnyData &in)
- {
- // Had this function been overloaded in a derived clas, it would
- // not have been called. Therefore, we have to start the
- // compatibility engine. But before, we have to avoid an endless loop.
- Assert(!compatibility_flag, ExcMessage("Compatibility resolution of Operator generates and endless loop\n"
- "Please provide an operator() in a derived class"));
- compatibility_flag = true;
-
- NamedData<VECTOR *> new_out;
- for (unsigned int i=0; i<out.size(); ++i)
- {
- if (out.is_type<VECTOR *>(i))
- new_out.add(out.entry<VECTOR *>(i), out.name(i));
- else if (!silent_compatibility)
- deallog << "Cannot convert AnyData argument " << out.name(i) << " to NamedData"
- << std::endl;
- }
-
- NamedData<VECTOR *> new_in;
- for (unsigned int i=0; i<in.size(); ++i)
- {
- // deallog << "Convert " << in.name(i) << std::endl;
- if (in.is_type<VECTOR *>(i))
- {
- // This const cast is due to the wrong constness handling
- // in NamedData. As soon as NamedData is gone, this code
- // will not be necessary anymore. And deprecating begins
- // now.
- VECTOR *p = const_cast<VECTOR *> (in.entry<VECTOR *>(i));
- new_in.add(p, in.name(i));
- }
- else if (in.is_type<const VECTOR *>(i))
- {
- // This const cast is due to the wrong constness handling
- // in NamedData. As soon as NamedData is gone, this code
- // will not be necessary anymore. And deprecating begins
- // now.
- VECTOR *p = const_cast<VECTOR *> (in.entry<const VECTOR *>(i));
- new_in.add(p, in.name(i));
- }
- else if (!silent_compatibility)
- deallog << "Cannot convert AnyData argument " << in.name(i)
- << " to NamedData" << std::endl;
- }
- this->operator() (new_out, new_in);
- compatibility_flag = false;
- }
-
-
- template <class VECTOR>
- void
- Operator<VECTOR>::operator() (NamedData<VECTOR *> &out, const NamedData<VECTOR *> &in)
- {
- // Had this function been overloaded in a derived clas, it would
- // not have been called. Therefore, we have to start the
- // compatibility engine. But before, we have to avoid an endless loop.
- Assert(!compatibility_flag, ExcMessage("Compatibility resolution of Operator generates and endless loop\n"
- "Please provide an operator() in a derived class"));
- compatibility_flag = true;
-
- AnyData new_out;
- for (unsigned int i=0; i<out.size(); ++i)
- new_out.add(out(i), out.name(i));
-
- AnyData new_in;
- for (unsigned int i=0; i<in.size(); ++i)
- new_in.add(in(i), in.name(i));
-
- this->operator() (new_out, new_in);
- compatibility_flag = false;
- }
-
-
template <class VECTOR>
OutputOperator<VECTOR>::~OutputOperator()
{}
}
return *this;
}
-
-
- template <class VECTOR>
- OutputOperator<VECTOR> &
- OutputOperator<VECTOR>::operator<< (const NamedData<VECTOR *> &vectors)
- {
- const AnyData newdata = vectors;
- (*this) << newdata;
- return *this;
- }
}
DEAL_II_NAMESPACE_CLOSE
if (output != 0)
(*output) << 0U << out;
- // Avoid warnings because time and timestep cannot be converted to VECTOR*
- const bool explicit_silent = op_explicit->silent_compatibility;
- const bool implicit_silent = op_implicit->silent_compatibility;
- op_explicit->silent_compatibility = true;
- op_implicit->silent_compatibility = true;
-
for (unsigned int count = 1; d_explicit.time < control.final(); ++count)
{
const bool step_change = control.advance();
d_explicit.time = control.now();
}
- op_explicit->silent_compatibility = explicit_silent;
- op_implicit->silent_compatibility = implicit_silent;
deallog.pop();
}
}
+++ /dev/null
-// ---------------------------------------------------------------------
-//
-// Copyright (C) 2000 - 2015 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.
-//
-// ---------------------------------------------------------------------
-
-#ifndef __deal2__named_data_h
-#define __deal2__named_data_h
-
-#include <deal.II/base/config.h>
-#include <deal.II/base/exceptions.h>
-#include <deal.II/base/subscriptor.h>
-
-#include <vector>
-#include <algorithm>
-
-DEAL_II_NAMESPACE_OPEN
-
-class AnyData;
-
-/**
- * @deprecated The use of this class is deprecated and AnyData should be used
- * instead. It is not only more flexible, the way constness was assured in
- * this class never worked the way it was intended. Therefore, the according
- * checks have been disabled.
- *
- * This class is a collection of DATA objects. Each of the pointers has a name
- * associated, enabling identification by this name rather than the index in
- * the vector only.
- *
- * Note that it is the actual data stored in this object. Therefore, for
- * storing vectors and other large objects, it should be considered to use
- * SmartPointer or boost::shared_ptr for DATA.
- *
- * Objects of this kind have a smart way of treating constness: if a const
- * data object is added or a const NamedData is supplied with merge(), the
- * object will henceforth consider itself as const (#is_constant will be
- * true). Thus, any subsequent modification will be illegal and
- * ExcConstantObject will be raised in debug mode.
- *
- * @author Guido Kanschat, 2007, 2008, 2009
- */
-template <typename DATA>
-class NamedData : public Subscriptor
-{
-public:
- /**
- * Standard constructor creating an empty object.
- */
- NamedData();
-
- /**
- * Assignment operator, copying conversible data from another object.
- */
- template <typename DATA2>
- NamedData<DATA> &operator = (const NamedData<DATA2> &other);
-
- /**
- * \name Adding members
- */
-//@{
- /**
- * Add a new data item to the end of the collection.
- */
- void add(DATA &v, const std::string &name);
-
- /**
- * Add a new constant data item to the end of the collection and make the
- * collection constant.
- */
- void add(const DATA &v, const std::string &name);
-
- /**
- * Merge the data of another NamedData to the end of this object.
- *
- * If the other object had #is_constant set, so will have this object after
- * merge.
- */
- template <typename DATA2>
- void merge(NamedData<DATA2> &);
- /**
- * Merge the data of another NamedData to the end of this object.
- *
- * After this operation, all data in this object will be treated as const.
- */
- template <typename DATA2>
- void merge(const NamedData<DATA2> &);
-//@}
- /**
- * \name Accessing and querying contents
- */
-//@{
-/// Number of stored data objects.
- unsigned int size() const;
-
- /**
- * @brief Access to stored data object by index.
- *
- * @note This function throws an exception, if is_const() returns
- * <tt>true</tt>. In such a case, either cast the NamedData object to a
- * const reference, or use the function read() instead of this operator.
- */
- DATA &operator() (unsigned int i);
-
-/// Read-only access to stored data object by index.
- const DATA &operator() (unsigned int i) const;
-
-/// Read only access for a non-const object.
- const DATA &read (unsigned int i) const;
-
-/// Name of object at index.
- const std::string &name(unsigned int i) const;
-
-/// Find index of a named object
- unsigned int find(const std::string &name) const;
-
-/// Returns true if this object contains constant data
- bool is_const () const;
-
-/// List names of stored objects
- template <class OUT>
- void print(OUT &o) const;
-//@}
- /**
- * Exception indicating that a function expected a vector to have a certain
- * name, but NamedData had a different name in that position.
- */
- DeclException2(ExcNameMismatch, int, std::string,
- << "Name at position " << arg1 << " is not equal to " << arg2);
-
- /**
- * Exception indicating that read access to stored data was attempted
- * although the NamedData object contains const data and #is_constant was
- * true.
- */
- DeclException0(ExcConstantObject);
-
-private:
- /// True if the object is to be treated constant
- bool is_constant;
- /// The actual data stored
- std::vector<DATA> data;
-
- /// Names for the data
- std::vector<std::string> names;
-};
-
-
-/**
- * Select data from NamedData corresponding to the attached name.
- *
- * Given a list of names to search for (provided by add()), objects of this
- * class provide an index list of the selected data.
- *
- * @author Guido Kanschat, 2009
- */
-class NamedSelection
-{
-public:
- /**
- * Add a new name to be searched for in NamedData.
- *
- * @note Names will be added to the end of the current list.
- */
- void add (const std::string &name);
-
- /**
- * Create the index vector pointing into the NamedData object.
- */
- 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 used whether
- * initialize() was called before or not.
- */
- unsigned int size() const;
-
- /**
- * Return the corresponding index in the NamedData object supplied to the
- * last initialize(). It is an error if initialize() has not been called
- * before.
- *
- * Indices are in the same order as the calls to add().
- */
- unsigned int operator() (unsigned int i) const;
-
-private:
- /**
- * The selected names.
- */
- std::vector<std::string> names;
- /**
- * The index map generated by initialize() and accessed by operator().
- */
- std::vector<unsigned int> indices;
-};
-
-
-//----------------------------------------------------------------------//
-
-template<typename DATA>
-inline
-NamedData<DATA>::NamedData()
- :
- is_constant(false)
-{}
-
-
-template<typename DATA>
-inline
-void
-NamedData<DATA>::add(DATA &v, const std::string &n)
-{
- // see operator() below
-
- // Assert(!is_constant, ExcConstantObject());
- names.push_back(n);
- data.push_back(v);
-}
-
-
-template<typename DATA>
-inline
-void
-NamedData<DATA>::add(const DATA &v, const std::string &n)
-{
- // see operator() below
-
- // Assert(!is_constant, ExcConstantObject());
- DATA &aux = const_cast<DATA &>(v);
- data.push_back(aux);
- names.push_back(n);
- is_constant = true;
-}
-
-
-template<typename DATA>
-template<typename DATA2>
-inline
-void
-NamedData<DATA>::merge(NamedData<DATA2> &other)
-{
- // see operator() below
-
- // Assert(!is_constant, ExcConstantObject());
-
- for (unsigned int i=0; i<other.size(); ++i)
- {
- names.push_back(other.name(i));
- data.push_back(other.read(i));
- }
- is_constant = other.is_const();
-}
-
-
-template<typename DATA>
-template<typename DATA2>
-inline
-void
-NamedData<DATA>::merge(const NamedData<DATA2> &other)
-{
- // see operator() below
-
- // Assert(!is_constant, ExcConstantObject());
- for (unsigned int i=0; i<other.size(); ++i)
- {
- names.push_back(other.name(i));
- data.push_back(other(i));
- }
- is_constant = true;
-}
-
-
-
-template<typename DATA>
-template<typename DATA2>
-inline
-NamedData<DATA> &
-NamedData<DATA>::operator= (const NamedData<DATA2> &other)
-{
- is_constant = false;
- merge(other);
- is_constant = other.is_const();
- return *this;
-}
-
-
-
-template<typename DATA>
-inline
-unsigned int
-NamedData<DATA>::size() const
-{
- return data.size();
-}
-
-
-template<typename DATA>
-inline
-bool
-NamedData<DATA>::is_const() const
-{
- return is_constant;
-}
-
-
-template<typename DATA>
-inline
-DATA &
-NamedData<DATA>::operator() (unsigned int i)
-{
- // Remove this assertion, since is_const() does not really assert
- // what we would like to. This can only be fixed by using constness
- // in AnyData.
-
- // Assert(!is_constant, ExcConstantObject());
- AssertIndexRange(i, size());
- return data[i];
-}
-
-
-template<typename DATA>
-inline
-const DATA &
-NamedData<DATA>::operator() (unsigned int i) const
-{
- AssertIndexRange(i, size());
- return data[i];
-}
-
-
-template<typename DATA>
-inline
-const DATA &
-NamedData<DATA>::read (unsigned int i) const
-{
- AssertIndexRange(i, size());
- return data[i];
-}
-
-
-template<typename DATA>
-inline
-const std::string &
-NamedData<DATA>::name(unsigned int i) const
-{
- AssertIndexRange(i, size());
- return names[i];
-}
-
-
-template<typename DATA>
-inline
-unsigned int
-NamedData<DATA>::find (const std::string &name) const
-{
- const std::vector<std::string>::const_iterator
- i = std::find(names.begin(), names.end(), name);
- if (i == names.end())
- return numbers::invalid_unsigned_int;
- return i - names.begin();
-}
-
-
-template<typename DATA>
-template<class OUT>
-inline
-void
-NamedData<DATA>::print(OUT &o) const
-{
- o << "NamedData:";
- for (unsigned int i=0; i<size(); ++i)
- o << ' ' << '\"' << names[i] << '\"';
- o << std::endl;
-}
-
-
-inline
-void
-NamedSelection::add(const std::string &s)
-{
- names.push_back(s);
-}
-
-
-template <typename DATA>
-inline void
-NamedSelection::initialize(const NamedData<DATA> &data)
-{
- indices.resize(names.size());
- for (unsigned int i=0; i<names.size(); ++i)
- indices[i] = data.find(names[i]);
-}
-
-
-inline
-unsigned int
-NamedSelection::size() const
-{
- return names.size();
-}
-
-
-inline
-unsigned int
-NamedSelection::operator() (unsigned int i) const
-{
- Assert (indices.size() == names.size(), ExcNotInitialized());
- AssertIndexRange(i, size());
- return indices[i];
-}
-
-
-DEAL_II_NAMESPACE_CLOSE
-
-
-#endif
#define __deal2__matrix_block_h
#include <deal.II/base/config.h>
-#include <deal.II/base/named_data.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/std_cxx11/shared_ptr.h>
#include <deal.II/base/memory_consumption.h>
#include <deal.II/lac/block_sparsity_pattern.h>
#include <deal.II/lac/sparse_matrix.h>
#include <deal.II/lac/full_matrix.h>
+#include <deal.II/algorithms/any_data.h>
DEAL_II_NAMESPACE_OPEN
template <class MATRIX>
class MatrixBlockVector
:
- private NamedData<std_cxx11::shared_ptr<MatrixBlock<MATRIX> > >
+ private AnyData
{
public:
/**
*/
typedef MatrixBlock<MATRIX> value_type;
+ /**
+ * The pointer type used for storing the objects. We use a shard
+ * pointer, such that they get deleted automatically when not used
+ * anymore.
+ */
+ typedef std_cxx11::shared_ptr<value_type> ptr_type;
+
/**
* Add a new matrix block at the position <tt>(row,column)</tt> in the block
* system.
/**
* import functions from private base class
*/
- using NamedData<std_cxx11::shared_ptr<value_type> >::subscribe;
- using NamedData<std_cxx11::shared_ptr<value_type> >::unsubscribe;
- using NamedData<std_cxx11::shared_ptr<value_type> >::size;
- using NamedData<std_cxx11::shared_ptr<value_type> >::name;
+ using AnyData::subscribe;
+ using AnyData::unsubscribe;
+ using AnyData::size;
+ using AnyData::name;
};
std::size_t memory_consumption () const;
private:
/// Clear one of the matrix objects
- void clear_object(NamedData<MGLevelObject<MatrixBlock<MATRIX> > > &);
+ void clear_object(AnyData &);
/// Flag for storing matrices_in and matrices_out
const bool edge_matrices;
const bool edge_flux_matrices;
/// The level matrices
- NamedData<MGLevelObject<MatrixBlock<MATRIX> > > matrices;
+ AnyData matrices;
/// The matrix from the interior of a level to the refinement edge
- NamedData<MGLevelObject<MatrixBlock<MATRIX> > > matrices_in;
+ AnyData matrices_in;
/// The matrix from the refinement edge to the interior of a level
- NamedData<MGLevelObject<MatrixBlock<MATRIX> > > matrices_out;
+ AnyData matrices_out;
/// The DG flux from a level to the lower level
- NamedData<MGLevelObject<MatrixBlock<MATRIX> > > flux_matrices_down;
+ AnyData flux_matrices_down;
/// The DG flux from the lower level to a level
- NamedData<MGLevelObject<MatrixBlock<MATRIX> > > flux_matrices_up;
+ AnyData flux_matrices_up;
};
size_type row, size_type column,
const std::string &name)
{
- std_cxx11::shared_ptr<value_type> p(new value_type(row, column));
- NamedData<std_cxx11::shared_ptr<value_type> >::add(p, name);
+ ptr_type p(new value_type(row, column));
+ AnyData::add(p, name);
}
inline const MatrixBlock<MATRIX> &
MatrixBlockVector<MATRIX>::block(size_type i) const
{
- return *this->read(i);
+ return *this->read<ptr_type>(i);
}
inline MatrixBlock<MATRIX> &
MatrixBlockVector<MATRIX>::block(size_type i)
{
- return *(*this)(i);
+ return *this->entry<ptr_type>(i);
}
inline MATRIX &
MatrixBlockVector<MATRIX>::matrix(size_type i)
{
- return (*this)(i)->matrix;
+ return this->entry<ptr_type>(i)->matrix;
}
inline const MGLevelObject<MatrixBlock<MATRIX> > &
MGMatrixBlockVector<MATRIX>::block(size_type i) const
{
- return matrices.read(i);
+ return *matrices.read<const MGLevelObject<MATRIX>* >(i);
}
inline MGLevelObject<MatrixBlock<MATRIX> > &
MGMatrixBlockVector<MATRIX>::block(size_type i)
{
- return matrices(i);
+ return *matrices.entry<MGLevelObject<MATRIX>* >(i);
}
inline const MGLevelObject<MatrixBlock<MATRIX> > &
MGMatrixBlockVector<MATRIX>::block_in(size_type i) const
{
- return matrices_in.read(i);
+ return *matrices_in.read<const MGLevelObject<MATRIX>* >(i);
}
inline MGLevelObject<MatrixBlock<MATRIX> > &
MGMatrixBlockVector<MATRIX>::block_in(size_type i)
{
- return matrices_in(i);
+ return *matrices_in.entry<MGLevelObject<MATRIX>* >(i);
}
inline const MGLevelObject<MatrixBlock<MATRIX> > &
MGMatrixBlockVector<MATRIX>::block_out(size_type i) const
{
- return matrices_out.read(i);
+ return *matrices_out.read<const MGLevelObject<MATRIX>* >(i);
}
inline MGLevelObject<MatrixBlock<MATRIX> > &
MGMatrixBlockVector<MATRIX>::block_out(size_type i)
{
- return matrices_out(i);
+ return *matrices_out.entry<MGLevelObject<MATRIX>* >(i);
}
inline const MGLevelObject<MatrixBlock<MATRIX> > &
MGMatrixBlockVector<MATRIX>::block_up(size_type i) const
{
- return flux_matrices_up.read(i);
+ return *flux_matrices_up.read<const MGLevelObject<MATRIX>* >(i);
}
inline MGLevelObject<MatrixBlock<MATRIX> > &
MGMatrixBlockVector<MATRIX>::block_up(size_type i)
{
- return flux_matrices_up(i);
+ return *flux_matrices_up.entry<MGLevelObject<MATRIX>* >(i);
}
inline const MGLevelObject<MatrixBlock<MATRIX> > &
MGMatrixBlockVector<MATRIX>::block_down(size_type i) const
{
- return flux_matrices_down.read(i);
+ return *flux_matrices_down.read<const MGLevelObject<MATRIX>* >(i);
}
inline MGLevelObject<MatrixBlock<MATRIX> > &
MGMatrixBlockVector<MATRIX>::block_down(size_type i)
{
- return flux_matrices_down(i);
+ return *flux_matrices_down.entry<MGLevelObject<MATRIX>* >(i);
}
template <class MATRIX>
inline void
-MGMatrixBlockVector<MATRIX>::clear_object(NamedData<MGLevelObject<MatrixBlock<MATRIX> > > &mo)
+MGMatrixBlockVector<MATRIX>::clear_object(AnyData &mo)
{
for (size_type i=0; i<mo.size(); ++i)
{
- MGLevelObject<MatrixBlock<MATRIX> > &o = mo(i);
+ MGLevelObject<MatrixBlock<MATRIX> > &o = mo.entry<MGLevelObject<MATRIX>* >(i);
for (size_type level = o.min_level(); level <= o.max_level(); ++level)
o[level].matrix.clear();
}
#ifndef __deal2__mesh_worker_assembler_h
#define __deal2__mesh_worker_assembler_h
-#include <deal.II/base/named_data.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/mg_level_object.h>
#include <deal.II/lac/block_vector.h>
#include <deal.II/meshworker/functional.h>
#include <deal.II/meshworker/simple.h>
#include <deal.II/multigrid/mg_constrained_dofs.h>
+#include <deal.II/algorithms/any_data.h>
DEAL_II_NAMESPACE_OPEN
* Copy the BlockInfo and the matrix pointers into local variables.
*/
void initialize(const BlockInfo *block_info,
- NamedData<VECTOR *> &residuals);
+ AnyData &residuals);
/**
* Initialize the constraints.
*/
const std::vector<types::global_dof_index> &dof);
/**
- * The global matrices, stored as a vector of pointers.
+ * The global vectors, stored as an AnyData container of pointers.
*/
- NamedData<SmartPointer<VECTOR,
- ResidualLocalBlocksToGlobalBlocks<VECTOR> > > residuals;
+ AnyData residuals;
/**
* A pointer to the object containing the block structure.
template <class VECTOR>
inline void
ResidualLocalBlocksToGlobalBlocks<VECTOR>::initialize(const BlockInfo *b,
- NamedData<VECTOR *> &m)
+ AnyData &m)
{
block_info = b;
residuals = m;
#ifndef __deal2__mesh_worker_functional_h
#define __deal2__mesh_worker_functional_h
-#include <deal.II/base/named_data.h>
#include <deal.II/algorithms/any_data.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/mg_level_object.h>
void initialize(AnyData &results, bool separate_faces = true);
/**
- * @deprecated
- */
- void initialize(NamedData<BlockVector<number>*> &results,
- bool separate_faces = true);
- /**
- * Initialize the local data in the DoFInfo object used later for
- * assembling.
+ * Initialize the local data in the DoFInfo object used later
+ * for assembling.
*
* The info object refers to a cell if <code>!face</code>, or else to an
* interior or boundary face.
separate_faces = sep;
}
- template <typename number>
- inline void
- CellsAndFaces<number>::initialize(NamedData<BlockVector<number>*> &r, bool sep)
- {
- Assert(r.name(0) == "cells", AnyData::ExcNameMismatch(0, "cells"));
- if (sep)
- {
- Assert(r.name(1) == "faces", AnyData::ExcNameMismatch(1, "faces"));
- AssertDimension(r(0)->n_blocks(),r(1)->n_blocks());
- }
-
- results = r;
- separate_faces = sep;
- }
-
-
template <typename number>
template <class DOFINFO>
inline void
const VECTOR &dummy,
const BlockInfo *block_info = 0);
/**
- * @deprecated Use AnyData instead of NamedData.
- */
- template <typename VECTOR>
- void initialize(const FiniteElement<dim, spacedim> &el,
- const Mapping<dim, spacedim> &mapping,
- const NamedData<VECTOR *> &data,
- const BlockInfo *block_info = 0);
-
- /**
- * @deprecated Use AnyData instead of NamedData.
+ * Initialize the IntegrationInfo objects contained.
+ *
+ * Before doing so, add update flags necessary to produce the data needed
+ * and also set uninitialized quadrature rules to Gauss formulas, which
+ * integrate polynomial bilinear forms exactly.
*/
template <typename VECTOR>
void initialize(const FiniteElement<dim, spacedim> &el,
const Mapping<dim, spacedim> &mapping,
- const NamedData<MGLevelObject<VECTOR>*> &data,
+ const AnyData &data,
+ const MGLevelObject<VECTOR> &dummy,
const BlockInfo *block_info = 0);
/**
* @name FEValues setup
neighbor.initialize_data(p);
}
-
- template <int dim, int sdim>
- template <typename VECTOR>
- void
- IntegrationInfoBox<dim,sdim>::initialize(
- const FiniteElement<dim,sdim> &el,
- const Mapping<dim,sdim> &mapping,
- const NamedData<VECTOR *> &data,
- const BlockInfo *block_info)
- {
- initialize(el, mapping, block_info);
- std_cxx11::shared_ptr<VectorData<VECTOR, dim, sdim> > p;
-
- p = std_cxx11::shared_ptr<VectorData<VECTOR, dim, sdim> >(new VectorData<VECTOR, dim, sdim> (cell_selector));
- p->initialize(data);
- cell_data = p;
- cell.initialize_data(p);
-
- p = std_cxx11::shared_ptr<VectorData<VECTOR, dim, sdim> >(new VectorData<VECTOR, dim, sdim> (boundary_selector));
- p->initialize(data);
- boundary_data = p;
- boundary.initialize_data(p);
-
- p = std_cxx11::shared_ptr<VectorData<VECTOR, dim, sdim> >(new VectorData<VECTOR, dim, sdim> (face_selector));
- p->initialize(data);
- face_data = p;
- face.initialize_data(p);
- subface.initialize_data(p);
- neighbor.initialize_data(p);
- }
-
-
template <int dim, int sdim>
template <typename VECTOR>
void
IntegrationInfoBox<dim,sdim>::initialize(
const FiniteElement<dim,sdim> &el,
const Mapping<dim,sdim> &mapping,
- const NamedData<MGLevelObject<VECTOR>*> &data,
+ const AnyData &data,
+ const MGLevelObject<VECTOR> &dummy,
const BlockInfo *block_info)
{
initialize(el, mapping, block_info);
std_cxx11::shared_ptr<MGVectorData<VECTOR, dim, sdim> > p;
+ VectorDataBase<dim,sdim> *pp;
p = std_cxx11::shared_ptr<MGVectorData<VECTOR, dim, sdim> >(new MGVectorData<VECTOR, dim, sdim> (cell_selector));
- p->initialize(data);
+ // Public member function of parent class was not found without
+ // explicit cast
+ pp = &*p;
+ pp->initialize(data);
cell_data = p;
cell.initialize_data(p);
p = std_cxx11::shared_ptr<MGVectorData<VECTOR, dim, sdim> >(new MGVectorData<VECTOR, dim, sdim> (boundary_selector));
- p->initialize(data);
+ pp = &*p;
+ pp->initialize(data);
boundary_data = p;
boundary.initialize_data(p);
p = std_cxx11::shared_ptr<MGVectorData<VECTOR, dim, sdim> >(new MGVectorData<VECTOR, dim, sdim> (face_selector));
- p->initialize(data);
+ pp = &*p;
+ pp->initialize(data);
face_data = p;
face.initialize_data(p);
subface.initialize_data(p);
neighbor.initialize_data(p);
}
-
template <int dim, int sdim>
template <class DOFINFO>
void
#define __deal2__mesh_worker_output_h
#include <deal.II/meshworker/dof_info.h>
-#include <deal.II/base/named_data.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/utilities.h>
#include <deal.II/lac/block_vector.h>
#ifndef __deal2__mesh_worker_simple_h
#define __deal2__mesh_worker_simple_h
-#include <deal.II/base/named_data.h>
#include <deal.II/algorithms/any_data.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/mg_level_object.h>
*/
void initialize(AnyData &results);
- /**
- * @deprecated Use initialize(AnyData&) instead.
- */
- void initialize(NamedData<VECTOR *> &results);
/**
* Initialize the constraints.
*/
residuals = results;
}
- template <class VECTOR>
- inline void
- ResidualSimple<VECTOR>::initialize(NamedData<VECTOR *> &results)
- {
- residuals = results;
- }
-
template <class VECTOR>
inline void
ResidualSimple<VECTOR>::initialize(const ConstraintMatrix &c)
#ifndef __deal2__mesh_worker_vector_selector_h
#define __deal2__mesh_worker_vector_selector_h
-#include <deal.II/base/named_data.h>
#include <deal.II/algorithms/any_data.h>
+#include <deal.II/algorithms/named_selection.h>
#include <deal.II/base/tensor.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/mg_level_object.h>
*/
void initialize(const AnyData &);
- /**
- * @deprecated Use AnyData instead of NamedData.
- */
- template <class DATA>
- void initialize(const NamedData<DATA> &);
-
/**
* Check whether any vector is selected.
*/
template <class STREAM, typename DATA>
void print (STREAM &s, const AnyData &v) const;
- /**
- * @deprecated Use AnyData instead of NamedData.
- */
- template <class STREAM, typename DATA>
- void print (STREAM &s, const NamedData<DATA> &v) const;
-
/**
* Print the number of selections to the stream.
*/
VectorData(const VectorSelector &);
/**
- * @deprecated Use AnyData instead of NamedData.
+ * Initialize with an object of named vectors.
*/
- void initialize(const NamedData<VECTOR *> &);
+ void initialize(const AnyData &);
/**
* Initialize with a single vector and cache the indices in the
MGVectorData(const VectorSelector &);
/**
- * @deprecated Use AnyData instead of NamedData.
+ * Initialize with an object of named vectors
*/
- void initialize(const NamedData<MGLevelObject<VECTOR>*> &);
+ void initialize(const AnyData &);
/**
* Initialize with a single vector and cache the indices in the
hessian_selection.initialize(src);
}
- template <typename DATA>
- inline void
- VectorSelector::initialize(const NamedData<DATA> &src)
- {
- value_selection.initialize(src);
- gradient_selection.initialize(src);
- hessian_selection.initialize(src);
- }
-
inline bool
VectorSelector::empty() const
{
}
- template <class STREAM, typename DATA>
- inline void
- VectorSelector::print(STREAM &s, const NamedData<DATA> &v) const
- {
- s << "values: ";
- for (unsigned int i=0; i<n_values(); ++i)
- s << " '" << v.name(value_selection(i)) << '\'';
- s << std::endl << "gradients:";
- for (unsigned int i=0; i<n_gradients(); ++i)
- s << " '" << v.name(gradient_selection(i)) << '\'';
- s << std::endl << "hessians: ";
- for (unsigned int i=0; i<n_hessians(); ++i)
- s << " '" << v.name(hessian_selection(i)) << '\'';
- s << std::endl;
- }
-
-
inline
std::size_t
VectorSelector::memory_consumption () const
template <class VECTOR, int dim, int spacedim>
void
- VectorData<VECTOR, dim, spacedim>::initialize(const NamedData<VECTOR *> &d)
+ VectorData<VECTOR, dim, spacedim>::initialize(const AnyData &d)
{
this->data = d;
VectorSelector::initialize(d);
template <class VECTOR, int dim, int spacedim>
void
- MGVectorData<VECTOR, dim, spacedim>::initialize(const NamedData<MGLevelObject<VECTOR>*> &d)
+ MGVectorData<VECTOR, dim, spacedim>::initialize(const AnyData &d)
{
this->data = d;
VectorSelector::initialize(d);
#include <deal.II/base/config.h>
#include <deal.II/base/parameter_handler.h>
-#include <deal.II/base/named_data.h>
#include <deal.II/algorithms/any_data.h>
#include <deal.II/base/event.h>
#include <deal.II/algorithms/operator.h>
//
// ---------------------------------------------------------------------
-#include <deal.II/base/named_data.h>
+#include <deal.II/algorithms/named_selection.h>
#include <deal.II/algorithms/any_data.h>
DEAL_II_NAMESPACE_OPEN
#include <deal.II/algorithms/operator.h>
#include <deal.II/algorithms/newton.h>
#include <deal.II/numerics/vector_tools.h>
-#include <deal.II/base/named_data.h>
//test computing square root of 2 with newton's method
sq_solver);
newton.initialize(output);
- NamedData<Vector<double>*> in_data;
- NamedData<Vector<double>*> out_data;
+ AnyData in_data;
+ AnyData out_data;
Vector<double> solution (1);
solution = 10.;
- Vector<double> *p = &solution;
- out_data.add(p, "solution");
+ out_data.add<Vector<double>*>(&solution, "solution");
newton.control.set_reduction(1.e-20);
newton.control.log_history(true);
newton.debug_vectors = true;
newton(out_data, in_data);
- deallog << " square root " << (*out_data(0))(0) << std::endl;
+ deallog << " square root " << (*out_data.read<Vector<double>*>(0))(0) << std::endl;
}
+++ /dev/null
-// ---------------------------------------------------------------------
-//
-// Copyright (C) 2008 - 2014 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 "../tests.h"
-#include <deal.II/algorithms/operator.h>
-#include <deal.II/algorithms/newton.h>
-#include <deal.II/numerics/vector_tools.h>
-#include <deal.II/base/named_data.h>
-
-
-//test computing square root of 2 with newton's method
-
-using namespace dealii;
-
-class SquareRoot : public Subscriptor
-{
-public:
- void start_vector (Vector<double> &start) const;
- void residual (NamedData<Vector<double>*> &out,
- const NamedData<Vector<double>*> &in);
- void solve (NamedData<Vector<double>*> &out,
- const NamedData<Vector<double>*> &in);
-};
-
-class SquareRootResidual : public
- Algorithms::Operator<Vector<double> >
-{
- SmartPointer<SquareRoot, SquareRootResidual>
- discretization;
-public:
-
- SquareRootResidual(SquareRoot &problem)
- : discretization(&problem)
- {}
-
- virtual void operator ()(
- NamedData<Vector<double>*> &out,
- const NamedData<Vector<double>*> &in)
- {
- discretization->residual(out,in);
- }
-};
-
-class SquareRootSolver : public
- Algorithms::Operator<Vector<double> >
-{
- SmartPointer<SquareRoot, SquareRootSolver>
- solver;
-public:
-
- SquareRootSolver(SquareRoot &problem)
- : solver(&problem)
- {}
-
- virtual void operator ()(
- NamedData<Vector<double>*> &out,
- const NamedData<Vector<double>*> &in)
- {
- solver->solve(out,in);
- }
-};
-
-void SquareRoot::residual (
- NamedData<Vector<double>*> &out,
- const NamedData<Vector<double>*> &in)
-{
- //residuum = 0
- *out(0) = 0.;
- const Vector<double> &x = *in(in.find("Newton iterate"));
- *out(0) = x*x - 2.;
-}
-
-void SquareRoot::solve (
- NamedData<Vector<double>*> &out,
- const NamedData<Vector<double>*> &in)
-{
- *out(0) = 0;
- const Vector<double> &x = *in(in.find("Newton iterate"));
- const Vector<double> &r = *in(in.find("Newton residual"));
-
- (*out(0))(0) = 1./2./x(0)* r(0);
-}
-
-
-
-void test ()
-{
- SquareRoot square_root;
- SquareRootSolver sq_solver (square_root);
- SquareRootResidual sq_residual (square_root);
-
- Algorithms::OutputOperator<Vector<double> > output;
-
- Algorithms::Newton<Vector<double> > newton(
- sq_residual,
- sq_solver);
- newton.initialize(output);
-
- NamedData<Vector<double>*> in_data;
- NamedData<Vector<double>*> out_data;
-
- Vector<double> solution (1);
- solution = 10.;
- Vector<double> *p = &solution;
- out_data.add(p, "solution");
-
- newton.control.set_reduction(1.e-20);
- newton.control.log_history(true);
- newton.debug_vectors = true;
- newton(out_data, in_data);
- deallog << " square root " << (*out_data(0))(0) << std::endl;
-}
-
-
-
-
-int main()
-{
- std::string logname = "output";
- std::ofstream logfile(logname.c_str());
- deallog.attach(logfile);
- deallog.depth_console(0);
- deallog.threshold_double(1.e-10);
-
- test ();
-}
+++ /dev/null
-
-DEAL:Newton::Step 0
-DEAL:Newton::solution 10.0000
-DEAL:Newton::update
-DEAL:Newton::residual 98.0000
-DEAL:Newton::
-DEAL:Newton::Check 0 98.0000
-DEAL:Newton::Starting value 98.0000
-DEAL:Newton::Step 1
-DEAL:Newton::solution 10.0000
-DEAL:Newton::update 4.90000
-DEAL:Newton::residual 98.0000
-DEAL:Newton::
-DEAL:Newton::Check 1 24.0100
-DEAL:Newton::Step 2
-DEAL:Newton::solution 5.10000
-DEAL:Newton::update 2.35392
-DEAL:Newton::residual 24.0100
-DEAL:Newton::
-DEAL:Newton::Check 2 5.54095
-DEAL:Newton::Step 3
-DEAL:Newton::solution 2.74608
-DEAL:Newton::update 1.00888
-DEAL:Newton::residual 5.54095
-DEAL:Newton::
-DEAL:Newton::Check 3 1.01785
-DEAL:Newton::Step 4
-DEAL:Newton::solution 1.73719
-DEAL:Newton::update 0.292957
-DEAL:Newton::residual 1.01785
-DEAL:Newton::
-DEAL:Newton::Check 4 0.0858237
-DEAL:Newton::Step 5
-DEAL:Newton::solution 1.44424
-DEAL:Newton::update 0.0297124
-DEAL:Newton::residual 0.0858237
-DEAL:Newton::
-DEAL:Newton::Check 5 0.000882829
-DEAL:Newton::Step 6
-DEAL:Newton::solution 1.41453
-DEAL:Newton::update 0.000312058
-DEAL:Newton::residual 0.000882829
-DEAL:Newton::
-DEAL:Newton::Check 6 9.73804e-08
-DEAL:Newton::Step 7
-DEAL:Newton::solution 1.41421
-DEAL:Newton::update 3.44292e-08
-DEAL:Newton::residual 9.73804e-08
-DEAL:Newton::
-DEAL:Newton::Check 7 0
-DEAL:Newton::Convergence step 7 value 0
-DEAL:: square root 1.41421
+++ /dev/null
-// ---------------------------------------------------------------------
-//
-// Copyright (C) 2008 - 2014 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.
-//
-// ---------------------------------------------------------------------
-
-// Test the compatibility functionality for Operator::operator()
-
-#include "../tests.h"
-#include <deal.II/algorithms/operator.h>
-#include <deal.II/lac/vector.h>
-
-using namespace Algorithms;
-
-class Op1 : public Operator<Vector<double> >
-{
- public:
- virtual void operator() (AnyData& out, const AnyData& in)
- {
- Vector<double>* u = out.entry<Vector<double>*>("u");
- deallog << "u " << (*u)(0) << std::endl;
-
- const Vector<double>* v = in.entry<Vector<double>*>("v");
- deallog << "v " << (*v)(0) << std::endl;
- }
-};
-
-class Op2 : public Operator<Vector<double> >
-{
- public:
- virtual void operator() (NamedData<Vector<double>*>& out,
- const NamedData<Vector<double>*>& in)
- {
- Vector<double>* u = out(out.find("u"));
- deallog << "u " << (*u)(0) << std::endl;
-
- const Vector<double> * const v = in(in.find("v"));
- deallog << "v " << (*v)(0) << std::endl;
- }
-};
-
-void test(Operator<Vector<double> >& op)
-{
- Vector<double> u(1);
- Vector<double>* p = &u;
- Vector<double> v(1);
- u(0) = 3.;
- v(0) = 7.;
-
- AnyData o1;
- o1.add (p, "u");
- AnyData i1;
- i1.add (&v, "v");
-
- NamedData<Vector<double>*> o2;
- o2.add (p, "u");
- NamedData<Vector<double>*> i2;
- i2.add (&v, "v");
-
- deallog << "Call with AnyData" << std::endl;
- op(o1, i1);
- deallog << "Call with NamedData" << std::endl;
- op(o2, i2);
-}
-
-int main()
-{
- // deal_II_exceptions::disable_abort_on_exception();
-
- std::ofstream logfile("output");
- deallog.attach(logfile);
- deallog.depth_console(0);
-
- deallog << "Operator with AnyData" << std::endl;
- Op1 op1;
- test(op1);
-
- deallog << "Operator with NamedData" << std::endl;
- Op2 op2;
- test(op2);
-
- // deallog << "Operator with NamedData" << std::endl;
- // Op2 op2;
- // test(op1);
-}
+++ /dev/null
-
-DEAL::Operator with AnyData
-DEAL::Call with AnyData
-DEAL::u 3.00000
-DEAL::v 7.00000
-DEAL::Call with NamedData
-DEAL::u 3.00000
-DEAL::v 7.00000
-DEAL::Operator with NamedData
-DEAL::Call with AnyData
-DEAL::u 3.00000
-DEAL::v 7.00000
-DEAL::Call with NamedData
-DEAL::u 3.00000
-DEAL::v 7.00000
+++ /dev/null
-// ---------------------------------------------------------------------
-//
-// Copyright (C) 2005 - 2015 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.
-//
-// ---------------------------------------------------------------------
-
-
-// See documentation of ThetaTimestepping for documentation of this example
-
-#include <deal.II/base/logstream.h>
-#include <deal.II/lac/vector.h>
-#include <deal.II/lac/full_matrix.h>
-
-#include <deal.II/algorithms/operator.h>
-#include <deal.II/algorithms/theta_timestepping.h>
-
-#include <iostream>
-
-using namespace dealii;
-using namespace Algorithms;
-
-
-class Explicit
- : public Operator<Vector<double> >
-{
-public:
- Explicit(const FullMatrix<double> &matrix);
- void operator() (NamedData<Vector<double>*> &out,
- const NamedData<Vector<double>*> &in);
-
- void initialize_timestep_data(const TimestepData &);
-private:
- const TimestepData *timestep_data;
- SmartPointer<const FullMatrix<double>, Explicit> matrix;
- FullMatrix<double> m;
-};
-
-
-class Implicit
- : public Operator<Vector<double> >
-{
-public:
- Implicit(const FullMatrix<double> &matrix);
- void operator() (NamedData<Vector<double>*> &out,
- const NamedData<Vector<double>*> &in);
-
- void initialize_timestep_data(const TimestepData &);
-private:
- const TimestepData *timestep_data;
- SmartPointer<const FullMatrix<double>, Implicit> matrix;
- FullMatrix<double> m;
-};
-
-// End of declarations
-
-int main()
-{
- std::string logname = "output";
- std::ofstream logfile(logname.c_str());
- deallog.attach(logfile);
- deallog.depth_console(0);
- deallog.threshold_double(1.e-10);
-
- FullMatrix<double> matrix(2);
- matrix(0,0) = 0.;
- matrix(1,1) = 0.;
- matrix(0,1) = numbers::PI;
- matrix(1,0) = -numbers::PI;
-
- OutputOperator<Vector<double> > out;
- out.initialize_stream(logfile);
-
- Explicit op_explicit(matrix);
- Implicit op_implicit(matrix);
- ThetaTimestepping<Vector<double> > solver(op_explicit, op_implicit);
- op_explicit.initialize_timestep_data(solver.explicit_data());
- op_implicit.initialize_timestep_data(solver.implicit_data());
- solver.timestep_control().start_step(0.1);
- //solver.set_output(out);
-
- Vector<double> value(2);
- value(0) = 1.;
- NamedData<Vector<double>*> indata;
- NamedData<Vector<double>*> outdata;
- Vector<double> *p = &value;
- outdata.add(p, "value");
- deallog << "Initial: " << value(0) << ' ' << value(1) << std::endl;
- solver.notify(Events::initial);
- solver.Operator<Vector<double> >::operator()(outdata, indata);
- deallog << "Result: " << value(0) << ' ' << value(1)
- << " Norm " << value.l2_norm() << std::endl;
-}
-
-
-Explicit::Explicit(const FullMatrix<double> &M)
- :
- matrix(&M)
-{
- m.reinit(M.m(), M.n());
-}
-
-
-void
-Explicit::initialize_timestep_data(const TimestepData &t)
-{
- timestep_data = &t;
-}
-
-
-void
-Explicit::operator() (NamedData<Vector<double>*> &out, const NamedData<Vector<double>*> &in)
-{
- if (this->notifications.test(Events::initial) || this->notifications.test(Events::new_timestep_size))
- {
- m.equ(-timestep_data->step, *matrix);
- for (unsigned int i=0; i<m.m(); ++i)
- m(i,i) += 1.;
- }
- this->notifications.clear();
- unsigned int i = in.find("Previous iterate");
- m.vmult(*out(0), *in(i));
-}
-
-
-Implicit::Implicit(const FullMatrix<double> &M)
- :
- matrix(&M)
-{
- m.reinit(M.m(), M.n());
-}
-
-
-void
-Implicit::initialize_timestep_data(const TimestepData &t)
-{
- timestep_data = &t;
-}
-
-
-void
-Implicit::operator() (NamedData<Vector<double>*> &out, const NamedData<Vector<double>*> &in)
-{
- if (this->notifications.test(Events::initial) || this->notifications.test(Events::new_timestep_size))
- {
- m.equ(timestep_data->step, *matrix);
- for (unsigned int i=0; i<m.m(); ++i)
- m(i,i) += 1.;
- m.gauss_jordan();
- }
- this->notifications.clear();
-
- unsigned int i = in.find("Previous time");
- m.vmult(*out(0), *in(i));
-}
-
-
+++ /dev/null
-
-DEAL::Initial: 1.00000 0
-DEAL:Theta::Time step:0.100000
-DEAL:Theta::Time step:0.200000
-DEAL:Theta::Time step:0.300000
-DEAL:Theta::Time step:0.400000
-DEAL:Theta::Time step:0.500000
-DEAL:Theta::Time step:0.600000
-DEAL:Theta::Time step:0.700000
-DEAL:Theta::Time step:0.800000
-DEAL:Theta::Time step:0.900000
-DEAL:Theta::Time step:1.00000
-DEAL::Result: -0.999676 0.0254599 Norm 1.00000
+++ /dev/null
-// ---------------------------------------------------------------------
-//
-// Copyright (C) 2000 - 2015 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 "../tests.h"
-#include <deal.II/base/named_data.h>
-#include <deal.II/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) != numbers::invalid_unsigned_int)
- deallog << data.name(select(i)) << ' ' << *data(select(i));
- deallog << std::endl;
- }
-}
-
-void
-test_shared_pointer()
-{
- NamedData<std_cxx11::shared_ptr<double> > data;
- deallog << "const" << data.is_const() << std::endl;
- std_cxx11::shared_ptr<double> p = std_cxx11::shared_ptr<double>(new double);
- data.add(p, "P1");
- p = std_cxx11::shared_ptr<double>(new double);
- data.add(p, "P2");
- p = std_cxx11::shared_ptr<double>(new double);
- data.add(p, "P3");
- p = std_cxx11::shared_ptr<double>(new double);
- data.add(p, "P4");
- p = std_cxx11::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("output");
- deallog.attach(logfile);
- deallog.depth_console(0);
-// deallog.log_cerr();
-
- test_shared_pointer();
-}
+++ /dev/null
-
-DEAL::const0
-DEAL::NamedData: "P1" "P2" "P3" "P4" "P5"
-DEAL::Const should be true: true
-DEAL::Selection 0:P1 0.500000
-DEAL::Selection 1:
-DEAL::Selection 2:P5 4.50000
-DEAL::Selection 3:P3 2.50000
cells.collect_sizes();
faces.collect_sizes();
- NamedData<BlockVector<double>* > out_data;
- BlockVector<double> *p = &cells;
- out_data.add(p, "cells");
- p = &faces;
- out_data.add(p, "faces");
+ AnyData out_data;
+ out_data.add<BlockVector<double>*>(&cells, "cells");
+ out_data.add<BlockVector<double>*>(&faces, "faces");
Local<dim> local;
EmptyInfoBox info_box;
#include <deal.II/lac/matrix_block.h>
#include <deal.II/lac/sparse_matrix.h>
#include <deal.II/lac/block_sparsity_pattern.h>
-#include <deal.II/lac/compressed_sparsity_pattern.h>
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
#include <deal.II/lac/solver_cg.h>
#include <deal.II/lac/precondition.h>
BlockSparsityPattern sparsity;
sparsity.reinit(dof.block_info().global().size(),
dof.block_info().global().size());
- BlockCompressedSparsityPattern c_sparsity(dof.block_info().global(),
- dof.block_info().global());
+ BlockDynamicSparsityPattern c_sparsity(dof.block_info().global(),
+ dof.block_info().global());
DoFTools::make_flux_sparsity_pattern(dof, c_sparsity, constraints, false);
sparsity.copy_from(c_sparsity);
info_box.add_update_flags(update_flags, true, true, true, true);
- NamedData<Vector<double>* > solution_data;
+ AnyData solution_data;
- Vector<double> *u = &solution;
-
- solution_data.add(u, "solution");
+ solution_data.add<Vector<double>* >(&solution, "solution");
info_box.cell_selector.add("solution", true, true, false);
info_box.boundary_selector.add("solution", true, false, false);
info_box.face_selector.add("solution", true, false, false);
- info_box.initialize(fe, mapping, solution_data);
+ info_box.initialize(fe, mapping, solution_data, solution);
//deallog<<"\nWe are now going to attend construction of MeshWorker::DoFInfo..."<<std::endl;
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
//deallog<<"\nApparently it DoFInfo was constructed fine!"<<std::endl;
MeshWorker::Assembler::ResidualSimple<Vector<double> > assembler;
- NamedData<Vector<double>* > data;
- Vector<double> *rhs = &residual;
- data.add(rhs, "Residual");
+ AnyData data;
+ data.add<Vector<double>* >(&residual, "Residual");
assembler.initialize(data);
MeshWorker::LoopControl lctrl;
{
diff.reinit (v);
const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell;
- std::vector<unsigned int> mg_dof_indices(dofs_per_cell);
+ std::vector<types::global_dof_index> mg_dof_indices(dofs_per_cell);
const unsigned int n_comp = dof.get_fe().n_components();
for (typename DoFHandler<dim>::cell_iterator
cell= dof.begin(level);
UpdateFlags update_flags = update_quadrature_points | update_values | update_gradients;
info_box.add_update_flags(update_flags, true, true, true, true);
- NamedData<MGLevelObject<Vector<double> >* > data;
- data.add(&v, "mg_vector");
+ AnyData data;
+ data.add<MGLevelObject<Vector<double> >* >(&v, "mg_vector");
info_box.cell_selector.add("mg_vector");
- info_box.initialize(fe, mapping, data);
+ info_box.initialize(fe, mapping, data, v);
MeshWorker::DoFInfo<dim> dof_info(dof);
DoFHandler<dim> mg_dof_handler_renumbered;
const unsigned int degree;
- std::vector<std::set<unsigned int> >
+ std::vector<std::set<types::global_dof_index> >
boundary_indices, boundary_indices_renumbered;
};
QTrapez<1> trapez;
QIterated<dim> quadrature(trapez, n_gauss_points);
info_box.cell_quadrature = quadrature;
- NamedData<MGLevelObject<Vector<double> >* > data;
- data.add(&v, "mg_vector");
+ AnyData data;
+ data.add<MGLevelObject<Vector<double> >* >(&v, "mg_vector");
info_box.cell_selector.add("mg_vector");
info_box.initialize_update_flags();
UpdateFlags update_flags = update_quadrature_points | update_values | update_gradients;
info_box.add_update_flags(update_flags, true, true, true, true);
- info_box.initialize(fe, mapping, data);
+ info_box.initialize(fe, mapping, data, v);
MeshWorker::DoFInfo<dim> dof_info(dof);
#include "../tests.h"
#include <deal.II/lac/sparse_matrix.h>
-#include <deal.II/lac/compressed_sparsity_pattern.h>
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
#include <deal.II/lac/solver_cg.h>
#include <deal.II/lac/precondition.h>
#include <deal.II/lac/precondition_block.h>
Triangulation<dim> triangulation;
const MappingQ1<dim> mapping;
const FiniteElement<dim> &fe;
- DoFHandler<dim> mg_dof_handler;
- DoFHandler<dim> &dof_handler;
+ DoFHandler<dim> dof_handler;
SparsityPattern sparsity;
SparseMatrix<double> matrix;
:
mapping(),
fe(fe),
- mg_dof_handler(triangulation),
- dof_handler(mg_dof_handler),
+ dof_handler(triangulation),
estimates(1)
{
GridGenerator::hyper_cube_slit(triangulation, -1, 1);
solution.reinit(n_dofs);
right_hand_side.reinit(n_dofs);
- CompressedSparsityPattern c_sparsity(n_dofs);
- DoFTools::make_flux_sparsity_pattern(dof_handler, c_sparsity);
- sparsity.copy_from(c_sparsity);
+ DynamicSparsityPattern dsp(n_dofs);
+ DoFTools::make_flux_sparsity_pattern(dof_handler, dsp);
+ sparsity.copy_from(dsp);
matrix.reinit(sparsity);
const unsigned int n_levels = triangulation.n_levels();
for (unsigned int level=mg_sparsity.min_level();
level<=mg_sparsity.max_level(); ++level)
{
- CompressedSparsityPattern c_sparsity(mg_dof_handler.n_dofs(level));
- MGTools::make_flux_sparsity_pattern(mg_dof_handler, c_sparsity, level);
- mg_sparsity[level].copy_from(c_sparsity);
+ DynamicSparsityPattern dsp(dof_handler.n_dofs(level));
+ MGTools::make_flux_sparsity_pattern(dof_handler, dsp, level);
+ mg_sparsity[level].copy_from(dsp);
mg_matrix[level].reinit(mg_sparsity[level]);
mg_matrix_in_out[level].reinit(mg_sparsity[level]);
if (level>0)
{
- CompressedSparsityPattern ci_sparsity;
- ci_sparsity.reinit(mg_dof_handler.n_dofs(level-1), mg_dof_handler.n_dofs(level));
- MGTools::make_flux_sparsity_pattern_edge(mg_dof_handler, ci_sparsity, level);
- mg_sparsity_dg_interface[level].copy_from(ci_sparsity);
+ DynamicSparsityPattern dsp;
+ dsp.reinit(dof_handler.n_dofs(level-1), dof_handler.n_dofs(level));
+ MGTools::make_flux_sparsity_pattern_edge(dof_handler, dsp, level);
+ mg_sparsity_dg_interface[level].copy_from(dsp);
mg_matrix_dg_up[level].reinit(mg_sparsity_dg_interface[level]);
mg_matrix_dg_down[level].reinit(mg_sparsity_dg_interface[level]);
}
info_box.add_update_flags_all(update_flags);
info_box.initialize(fe, mapping);
- MeshWorker::DoFInfo<dim> dof_info(mg_dof_handler);
+ MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::MGMatrixSimple<SparseMatrix<double> > assembler;
assembler.initialize(mg_matrix);
MatrixIntegrator<dim> integrator;
MeshWorker::integration_loop<dim, dim> (
- mg_dof_handler.begin_mg(), mg_dof_handler.end_mg(),
+ dof_handler.begin_mg(), dof_handler.end_mg(),
dof_info, info_box,
integrator, assembler);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::ResidualSimple<Vector<double> > assembler;
- NamedData<Vector<double>* > data;
- Vector<double> *rhs = &right_hand_side;
- data.add(rhs, "RHS");
+ AnyData data;
+ data.add<Vector<double>*>(&right_hand_side, "RHS");
assembler.initialize(data);
RHSIntegrator<dim> integrator;
SolverCG<Vector<double> > solver(control);
MGTransferPrebuilt<Vector<double> > mg_transfer;
- mg_transfer.build_matrices(mg_dof_handler);
+ mg_transfer.build_matrices(dof_handler);
FullMatrix<double> coarse_matrix;
coarse_matrix.copy_from (mg_matrix[0]);
mg::Matrix<Vector<double> > mgup(mg_matrix_dg_up);
mg::Matrix<Vector<double> > mgedge(mg_matrix_in_out);
- Multigrid<Vector<double> > mg(mg_dof_handler, mgmatrix,
+ Multigrid<Vector<double> > mg(dof_handler, mgmatrix,
mg_coarse, mg_transfer,
mg_smoother, mg_smoother);
mg.set_edge_flux_matrices(mgdown, mgup);
PreconditionMG<dim, Vector<double>,
MGTransferPrebuilt<Vector<double> > >
- preconditioner(mg_dof_handler, mg, mg_transfer);
+ preconditioner(dof_handler, mg, mg_transfer);
solver.solve(matrix, solution, right_hand_side, preconditioner);
}
const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1;
info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points);
- NamedData<Vector<double>* > solution_data;
- solution_data.add(&solution, "solution");
+ AnyData solution_data;
+ solution_data.add<const Vector<double>*>(&solution, "solution");
info_box.cell_selector.add("solution", false, false, true);
info_box.boundary_selector.add("solution", true, true, false);
info_box.face_selector.add("solution", true, true, false);
info_box.add_update_flags_boundary(update_quadrature_points);
- info_box.initialize(fe, mapping, solution_data);
+ info_box.initialize(fe, mapping, solution_data, solution);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::CellsAndFaces<double> assembler;
- NamedData<BlockVector<double>* > out_data;
- BlockVector<double> *est = &estimates;
- out_data.add(est, "cells");
+ AnyData out_data;
+ out_data.add<BlockVector<double>*>(&estimates, "cells");
assembler.initialize(out_data, false);
Estimator<dim> integrator;
const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1;
info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points);
- NamedData<Vector<double>* > solution_data;
- solution_data.add(&solution, "solution");
+ AnyData solution_data;
+ solution_data.add<Vector<double>*>(&solution, "solution");
info_box.cell_selector.add("solution", true, true, false);
info_box.boundary_selector.add("solution", true, false, false);
info_box.add_update_flags_cell(update_quadrature_points);
info_box.add_update_flags_boundary(update_quadrature_points);
- info_box.initialize(fe, mapping, solution_data);
+ info_box.initialize(fe, mapping, solution_data, solution);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::CellsAndFaces<double> assembler;
- NamedData<BlockVector<double>* > out_data;
- BlockVector<double> *est = &errors;
- out_data.add(est, "cells");
+ AnyData out_data;
+ out_data.add<BlockVector<double>* >(&errors, "cells");
assembler.initialize(out_data, false);
ErrorIntegrator<dim> integrator;
setup_system();
deallog << "DoFHandler " << dof_handler.n_dofs() << " dofs, level dofs";
for (unsigned int l=0; l<triangulation.n_levels(); ++l)
- deallog << ' ' << mg_dof_handler.n_dofs(l);
+ deallog << ' ' << dof_handler.n_dofs(l);
deallog << std::endl;
deallog << "Assemble matrix" << std::endl;
#include "../tests.h"
#include <deal.II/lac/sparse_matrix.h>
-#include <deal.II/lac/compressed_sparsity_pattern.h>
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
#include <deal.II/lac/solver_cg.h>
#include <deal.II/lac/precondition.h>
#include <deal.II/lac/precondition_block.h>
Triangulation<dim> triangulation;
const MappingQ1<dim> mapping;
const FiniteElement<dim> &fe;
- DoFHandler<dim> mg_dof_handler;
- DoFHandler<dim> &dof_handler;
- MGConstrainedDoFs mg_constraints;
+ DoFHandler<dim> dof_handler;
+ MGConstrainedDoFs mg_constraints;
SparsityPattern sparsity;
SparseMatrix<double> matrix;
:
mapping(),
fe(fe),
- mg_dof_handler(triangulation),
- dof_handler(mg_dof_handler),
+ dof_handler(triangulation),
estimates(1)
{
GridGenerator::hyper_cube_slit(triangulation, -1, 1);
{
dof_handler.distribute_dofs(fe);
dof_handler.distribute_mg_dofs(fe);
- unsigned int n_dofs = dof_handler.n_dofs();
+ types::global_dof_index n_dofs = dof_handler.n_dofs();
solution.reinit(n_dofs);
right_hand_side.reinit(n_dofs);
mg_constraints.clear();
mg_constraints.initialize(dof_handler);
- CompressedSparsityPattern c_sparsity(n_dofs);
- DoFTools::make_flux_sparsity_pattern(dof_handler, c_sparsity);
- sparsity.copy_from(c_sparsity);
+ DynamicSparsityPattern dsp(n_dofs);
+ DoFTools::make_flux_sparsity_pattern(dof_handler, dsp);
+ sparsity.copy_from(dsp);
matrix.reinit(sparsity);
const unsigned int n_levels = triangulation.n_levels();
for (unsigned int level=mg_sparsity.min_level();
level<=mg_sparsity.max_level(); ++level)
{
- CompressedSparsityPattern c_sparsity(mg_dof_handler.n_dofs(level));
- MGTools::make_flux_sparsity_pattern(mg_dof_handler, c_sparsity, level);
- mg_sparsity[level].copy_from(c_sparsity);
+ DynamicSparsityPattern dsp(dof_handler.n_dofs(level));
+ MGTools::make_flux_sparsity_pattern(dof_handler, dsp, level);
+ mg_sparsity[level].copy_from(dsp);
mg_matrix[level].reinit(mg_sparsity[level]);
mg_matrix_in_out[level].reinit(mg_sparsity[level]);
if (level>0)
{
- CompressedSparsityPattern ci_sparsity;
- ci_sparsity.reinit(mg_dof_handler.n_dofs(level-1), mg_dof_handler.n_dofs(level));
- MGTools::make_flux_sparsity_pattern_edge(mg_dof_handler, ci_sparsity, level);
- mg_sparsity_dg_interface[level].copy_from(ci_sparsity);
+ DynamicSparsityPattern dsp;
+ dsp.reinit(dof_handler.n_dofs(level-1), dof_handler.n_dofs(level));
+ MGTools::make_flux_sparsity_pattern_edge(dof_handler, dsp, level);
+ mg_sparsity_dg_interface[level].copy_from(dsp);
mg_matrix_dg_up[level].reinit(mg_sparsity_dg_interface[level]);
mg_matrix_dg_down[level].reinit(mg_sparsity_dg_interface[level]);
}
info_box.add_update_flags_all(update_flags);
info_box.initialize(fe, mapping);
- MeshWorker::DoFInfo<dim> dof_info(mg_dof_handler);
+ MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::MGMatrixSimple<SparseMatrix<double> > assembler;
assembler.initialize(mg_matrix);
MatrixIntegrator<dim> integrator;
MeshWorker::integration_loop<dim, dim> (
- mg_dof_handler.begin_mg(), mg_dof_handler.end_mg(),
+ dof_handler.begin_mg(), dof_handler.end_mg(),
dof_info, info_box,
integrator, assembler);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::ResidualSimple<Vector<double> > assembler;
- NamedData<Vector<double>* > data;
- Vector<double> *rhs = &right_hand_side;
- data.add(rhs, "RHS");
+ AnyData data;
+ data.add<Vector<double>*>(&right_hand_side, "RHS");
assembler.initialize(data);
RHSIntegrator<dim> integrator;
SolverCG<Vector<double> > solver(control);
MGTransferPrebuilt<Vector<double> > mg_transfer;
- mg_transfer.build_matrices(mg_dof_handler);
+ mg_transfer.build_matrices(dof_handler);
FullMatrix<double> coarse_matrix;
coarse_matrix.copy_from (mg_matrix[0]);
mg::Matrix<Vector<double> > mgup(mg_matrix_dg_up);
mg::Matrix<Vector<double> > mgedge(mg_matrix_in_out);
- Multigrid<Vector<double> > mg(mg_dof_handler, mgmatrix,
+ Multigrid<Vector<double> > mg(dof_handler, mgmatrix,
mg_coarse, mg_transfer,
mg_smoother, mg_smoother);
mg.set_edge_flux_matrices(mgdown, mgup);
PreconditionMG<dim, Vector<double>,
MGTransferPrebuilt<Vector<double> > >
- preconditioner(mg_dof_handler, mg, mg_transfer);
+ preconditioner(dof_handler, mg, mg_transfer);
solver.solve(matrix, solution, right_hand_side, preconditioner);
}
const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1;
info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points);
- NamedData<Vector<double>* > solution_data;
- solution_data.add(&solution, "solution");
+ AnyData solution_data;
+ solution_data.add<const Vector<double>*>(&solution, "solution");
info_box.cell_selector.add("solution", false, false, true);
info_box.boundary_selector.add("solution", true, true, false);
info_box.face_selector.add("solution", true, true, false);
info_box.add_update_flags_boundary(update_quadrature_points);
- info_box.initialize(fe, mapping, solution_data);
+ info_box.initialize(fe, mapping, solution_data, solution);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::CellsAndFaces<double> assembler;
- NamedData<BlockVector<double>* > out_data;
- BlockVector<double> *est = &estimates;
- out_data.add(est, "cells");
+ AnyData out_data;
+ out_data.add<BlockVector<double>*>(&estimates, "cells");
assembler.initialize(out_data, false);
Estimator<dim> integrator;
const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1;
info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points);
- NamedData<Vector<double>* > solution_data;
- solution_data.add(&solution, "solution");
+ AnyData solution_data;
+ solution_data.add<Vector<double>*>(&solution, "solution");
info_box.cell_selector.add("solution", true, true, false);
info_box.boundary_selector.add("solution", true, false, false);
info_box.add_update_flags_cell(update_quadrature_points);
info_box.add_update_flags_boundary(update_quadrature_points);
- info_box.initialize(fe, mapping, solution_data);
+ info_box.initialize(fe, mapping, solution_data, solution);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::CellsAndFaces<double> assembler;
- NamedData<BlockVector<double>* > out_data;
- BlockVector<double> *est = &errors;
- out_data.add(est, "cells");
+ AnyData out_data;
+ out_data.add<BlockVector<double>* >(&errors, "cells");
assembler.initialize(out_data, false);
ErrorIntegrator<dim> integrator;
setup_system();
deallog << "DoFHandler " << dof_handler.n_dofs() << " dofs, level dofs";
for (unsigned int l=0; l<triangulation.n_levels(); ++l)
- deallog << ' ' << mg_dof_handler.n_dofs(l);
+ deallog << ' ' << dof_handler.n_dofs(l);
deallog << std::endl;
deallog << "Assemble matrix" << std::endl;
#include "../tests.h"
#include <deal.II/lac/sparse_matrix.h>
-#include <deal.II/lac/compressed_sparsity_pattern.h>
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
#include <deal.II/lac/solver_cg.h>
#include <deal.II/lac/solver_gmres.h>
#include <deal.II/lac/precondition.h>
Triangulation<dim> triangulation;
const MappingQ1<dim> mapping;
const FiniteElement<dim> &fe;
- DoFHandler<dim> mg_dof_handler;
- DoFHandler<dim> &dof_handler;
+ DoFHandler<dim> dof_handler;
SparsityPattern sparsity;
SparseMatrix<double> matrix;
:
mapping(),
fe(fe),
- mg_dof_handler(triangulation),
- dof_handler(mg_dof_handler),
+ dof_handler(triangulation),
estimates(1)
{
GridGenerator::hyper_cube_slit(triangulation, -1, 1);
solution.reinit(n_dofs);
right_hand_side.reinit(n_dofs);
- CompressedSparsityPattern c_sparsity(n_dofs);
- DoFTools::make_flux_sparsity_pattern(dof_handler, c_sparsity);
- sparsity.copy_from(c_sparsity);
+ DynamicSparsityPattern dsp(n_dofs);
+ DoFTools::make_flux_sparsity_pattern(dof_handler, dsp);
+ sparsity.copy_from(dsp);
matrix.reinit(sparsity);
const unsigned int n_levels = triangulation.n_levels();
for (unsigned int level=mg_sparsity.min_level();
level<=mg_sparsity.max_level(); ++level)
{
- CompressedSparsityPattern c_sparsity(mg_dof_handler.n_dofs(level));
- MGTools::make_flux_sparsity_pattern(mg_dof_handler, c_sparsity, level);
- mg_sparsity[level].copy_from(c_sparsity);
+ DynamicSparsityPattern dsp(dof_handler.n_dofs(level));
+ MGTools::make_flux_sparsity_pattern(dof_handler, dsp, level);
+ mg_sparsity[level].copy_from(dsp);
mg_matrix[level].reinit(mg_sparsity[level]);
mg_matrix_in_out[level].reinit(mg_sparsity[level]);
if (level>0)
{
- CompressedSparsityPattern ci_sparsity;
- ci_sparsity.reinit(mg_dof_handler.n_dofs(level-1), mg_dof_handler.n_dofs(level));
- MGTools::make_flux_sparsity_pattern_edge(mg_dof_handler, ci_sparsity, level);
- mg_sparsity_dg_interface[level].copy_from(ci_sparsity);
+ DynamicSparsityPattern dsp;
+ dsp.reinit(dof_handler.n_dofs(level-1), dof_handler.n_dofs(level));
+ MGTools::make_flux_sparsity_pattern_edge(dof_handler, dsp, level);
+ mg_sparsity_dg_interface[level].copy_from(dsp);
mg_matrix_dg_up[level].reinit(mg_sparsity_dg_interface[level]);
mg_matrix_dg_down[level].reinit(mg_sparsity_dg_interface[level]);
}
info_box.add_update_flags_all(update_flags);
info_box.initialize(fe, mapping);
- MeshWorker::DoFInfo<dim> dof_info(mg_dof_handler);
+ MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::MGMatrixSimple<SparseMatrix<double> > assembler;
assembler.initialize(mg_matrix);
MatrixIntegrator<dim> integrator;
MeshWorker::integration_loop<dim, dim> (
- mg_dof_handler.begin_mg(), mg_dof_handler.end_mg(),
+ dof_handler.begin_mg(), dof_handler.end_mg(),
dof_info, info_box,
integrator, assembler);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::ResidualSimple<Vector<double> > assembler;
- NamedData<Vector<double>* > data;
- Vector<double> *rhs = &right_hand_side;
- data.add(rhs, "RHS");
+ AnyData data;
+ data.add<Vector<double>*>(&right_hand_side, "RHS");
assembler.initialize(data);
RHSIntegrator<dim> integrator;
SolverGMRES<Vector<double> > solver(control);
MGTransferPrebuilt<Vector<double> > mg_transfer;
- mg_transfer.build_matrices(mg_dof_handler);
+ mg_transfer.build_matrices(dof_handler);
FullMatrix<double> coarse_matrix;
coarse_matrix.copy_from (mg_matrix[0]);
mg::Matrix<Vector<double> > mgup(mg_matrix_dg_up);
mg::Matrix<Vector<double> > mgedge(mg_matrix_in_out);
- Multigrid<Vector<double> > mg(mg_dof_handler, mgmatrix,
+ Multigrid<Vector<double> > mg(dof_handler, mgmatrix,
mg_coarse, mg_transfer,
mg_smoother, mg_smoother);
mg.set_edge_flux_matrices(mgdown, mgup);
PreconditionMG<dim, Vector<double>,
MGTransferPrebuilt<Vector<double> > >
- preconditioner(mg_dof_handler, mg, mg_transfer);
+ preconditioner(dof_handler, mg, mg_transfer);
solver.solve(matrix, solution, right_hand_side, preconditioner);
}
const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1;
info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points);
- NamedData<Vector<double>* > solution_data;
- solution_data.add(&solution, "solution");
+ AnyData solution_data;
+ solution_data.add<const Vector<double>*>(&solution, "solution");
info_box.cell_selector.add("solution", false, false, true);
info_box.boundary_selector.add("solution", true, true, false);
info_box.face_selector.add("solution", true, true, false);
info_box.add_update_flags_boundary(update_quadrature_points);
- info_box.initialize(fe, mapping, solution_data);
+ info_box.initialize(fe, mapping, solution_data, solution);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::CellsAndFaces<double> assembler;
- NamedData<BlockVector<double>* > out_data;
- BlockVector<double> *est = &estimates;
- out_data.add(est, "cells");
+ AnyData out_data;
+ out_data.add<BlockVector<double>*>(&estimates, "cells");
assembler.initialize(out_data, false);
Estimator<dim> integrator;
const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1;
info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points);
- NamedData<Vector<double>* > solution_data;
- solution_data.add(&solution, "solution");
+ AnyData solution_data;
+ solution_data.add<Vector<double>*>(&solution, "solution");
info_box.cell_selector.add("solution", true, true, false);
info_box.boundary_selector.add("solution", true, false, false);
info_box.add_update_flags_cell(update_quadrature_points);
info_box.add_update_flags_boundary(update_quadrature_points);
- info_box.initialize(fe, mapping, solution_data);
+ info_box.initialize(fe, mapping, solution_data, solution);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::CellsAndFaces<double> assembler;
- NamedData<BlockVector<double>* > out_data;
- BlockVector<double> *est = &errors;
- out_data.add(est, "cells");
+ AnyData out_data;
+ out_data.add<BlockVector<double>* >(&errors, "cells");
assembler.initialize(out_data, false);
ErrorIntegrator<dim> integrator;
setup_system();
deallog << "DoFHandler " << dof_handler.n_dofs() << " dofs, level dofs";
for (unsigned int l=0; l<triangulation.n_levels(); ++l)
- deallog << ' ' << mg_dof_handler.n_dofs(l);
+ deallog << ' ' << dof_handler.n_dofs(l);
deallog << std::endl;
deallog << "Assemble matrix" << std::endl;
#include "../tests.h"
#include <deal.II/lac/sparse_matrix.h>
-#include <deal.II/lac/compressed_sparsity_pattern.h>
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
#include <deal.II/lac/solver_cg.h>
#include <deal.II/lac/precondition.h>
#include <deal.II/lac/precondition_block.h>
Triangulation<dim> triangulation;
const MappingQ1<dim> mapping;
const FiniteElement<dim> &fe;
- DoFHandler<dim> mg_dof_handler;
- DoFHandler<dim> &dof_handler;
+ DoFHandler<dim> dof_handler;
SparsityPattern sparsity;
SparseMatrix<double> matrix;
:
mapping(),
fe(fe),
- mg_dof_handler(triangulation),
- dof_handler(mg_dof_handler),
+ dof_handler(triangulation),
estimates(1)
{
GridGenerator::hyper_cube_slit(triangulation, -1, 1);
{
dof_handler.distribute_dofs(fe);
dof_handler.distribute_mg_dofs(fe);
- unsigned int n_dofs = dof_handler.n_dofs();
+ types::global_dof_index n_dofs = dof_handler.n_dofs();
solution.reinit(n_dofs);
right_hand_side.reinit(n_dofs);
- CompressedSparsityPattern c_sparsity(n_dofs);
- DoFTools::make_flux_sparsity_pattern(dof_handler, c_sparsity);
- sparsity.copy_from(c_sparsity);
+ DynamicSparsityPattern dsp(n_dofs);
+ DoFTools::make_flux_sparsity_pattern(dof_handler, dsp);
+ sparsity.copy_from(dsp);
matrix.reinit(sparsity);
const unsigned int n_levels = triangulation.n_levels();
for (unsigned int level=mg_sparsity.min_level();
level<=mg_sparsity.max_level(); ++level)
{
- CompressedSparsityPattern c_sparsity(mg_dof_handler.n_dofs(level));
- MGTools::make_flux_sparsity_pattern(mg_dof_handler, c_sparsity, level);
- mg_sparsity[level].copy_from(c_sparsity);
+ DynamicSparsityPattern dsp(dof_handler.n_dofs(level));
+ MGTools::make_flux_sparsity_pattern(dof_handler, dsp, level);
+ mg_sparsity[level].copy_from(dsp);
mg_matrix[level].reinit(mg_sparsity[level]);
if (level>0)
{
- CompressedSparsityPattern ci_sparsity;
- ci_sparsity.reinit(mg_dof_handler.n_dofs(level-1), mg_dof_handler.n_dofs(level));
- MGTools::make_flux_sparsity_pattern_edge(mg_dof_handler, ci_sparsity, level);
- mg_sparsity_dg_interface[level].copy_from(ci_sparsity);
+ DynamicSparsityPattern dsp;
+ dsp.reinit(dof_handler.n_dofs(level-1), dof_handler.n_dofs(level));
+ MGTools::make_flux_sparsity_pattern_edge(dof_handler, dsp, level);
+ mg_sparsity_dg_interface[level].copy_from(dsp);
mg_matrix_dg_up[level].reinit(mg_sparsity_dg_interface[level]);
mg_matrix_dg_down[level].reinit(mg_sparsity_dg_interface[level]);
}
info_box.add_update_flags_all(update_flags);
info_box.initialize(fe, mapping);
- MeshWorker::DoFInfo<dim> dof_info(mg_dof_handler);
+ MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::MGMatrixSimple<SparseMatrix<double> > assembler;
assembler.initialize(mg_matrix);
MatrixIntegrator<dim> integrator;
MeshWorker::integration_loop<dim, dim> (
- mg_dof_handler.begin_mg(), mg_dof_handler.end_mg(),
+ dof_handler.begin_mg(), dof_handler.end_mg(),
dof_info, info_box,
integrator, assembler);
}
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::ResidualSimple<Vector<double> > assembler;
- NamedData<Vector<double>* > data;
- Vector<double> *rhs = &right_hand_side;
- data.add(rhs, "RHS");
+ AnyData data;
+ data.add<Vector<double>*>(&right_hand_side, "RHS");
assembler.initialize(data);
RHSIntegrator<dim> integrator;
SolverCG<Vector<double> > solver(control);
MGTransferPrebuilt<Vector<double> > mg_transfer;
- mg_transfer.build_matrices(mg_dof_handler);
+ mg_transfer.build_matrices(dof_handler);
FullMatrix<double> coarse_matrix;
coarse_matrix.copy_from (mg_matrix[0]);
mg::Matrix<Vector<double> > mgdown(mg_matrix_dg_down);
mg::Matrix<Vector<double> > mgup(mg_matrix_dg_up);
- Multigrid<Vector<double> > mg(mg_dof_handler, mgmatrix,
+ Multigrid<Vector<double> > mg(dof_handler, mgmatrix,
mg_coarse, mg_transfer,
mg_smoother, mg_smoother);
mg.set_edge_flux_matrices(mgdown, mgup);
PreconditionMG<dim, Vector<double>,
MGTransferPrebuilt<Vector<double> > >
- preconditioner(mg_dof_handler, mg, mg_transfer);
+ preconditioner(dof_handler, mg, mg_transfer);
solver.solve(matrix, solution, right_hand_side, preconditioner);
}
const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1;
info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points);
- NamedData<Vector<double>* > solution_data;
- solution_data.add(&solution, "solution");
+ AnyData solution_data;
+ solution_data.add<const Vector<double>*>(&solution, "solution");
info_box.cell_selector.add("solution", false, false, true);
info_box.boundary_selector.add("solution", true, true, false);
info_box.face_selector.add("solution", true, true, false);
info_box.add_update_flags_boundary(update_quadrature_points);
- info_box.initialize(fe, mapping, solution_data);
+ info_box.initialize(fe, mapping, solution_data, solution);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::CellsAndFaces<double> assembler;
- NamedData<BlockVector<double>* > out_data;
- BlockVector<double> *est = &estimates;
- out_data.add(est, "cells");
+ AnyData out_data;
+ out_data.add<BlockVector<double>*>(&estimates, "cells");
assembler.initialize(out_data, false);
Estimator<dim> integrator;
const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1;
info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points);
- NamedData<Vector<double>* > solution_data;
- solution_data.add(&solution, "solution");
+ AnyData solution_data;
+ solution_data.add<Vector<double>*>(&solution, "solution");
info_box.cell_selector.add("solution", true, true, false);
info_box.boundary_selector.add("solution", true, false, false);
info_box.add_update_flags_cell(update_quadrature_points);
info_box.add_update_flags_boundary(update_quadrature_points);
- info_box.initialize(fe, mapping, solution_data);
+ info_box.initialize(fe, mapping, solution_data, solution);
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
MeshWorker::Assembler::CellsAndFaces<double> assembler;
- NamedData<BlockVector<double>* > out_data;
- BlockVector<double> *est = &errors;
- out_data.add(est, "cells");
+ AnyData out_data;
+ out_data.add<BlockVector<double>* >(&errors, "cells");
assembler.initialize(out_data, false);
ErrorIntegrator<dim> integrator;
setup_system();
deallog << "DoFHandler " << dof_handler.n_dofs() << " dofs, level dofs";
for (unsigned int l=0; l<triangulation.n_levels(); ++l)
- deallog << ' ' << mg_dof_handler.n_dofs(l);
+ deallog << ' ' << dof_handler.n_dofs(l);
deallog << std::endl;
deallog << "Assemble matrix" << std::endl;