#include <base/config.h>
#include <base/exceptions.h>
#include <base/template_constraints.h>
+#include <base/synchronous_iterator.h>
#include <base/std_cxx1x/tuple.h>
#include <base/std_cxx1x/bind.h>
#include <base/std_cxx1x/function.h>
-#include <iterator>
#include <cstddef>
#if DEAL_II_USE_MT == 1
{
namespace internal
{
- /**
- * A class that represents a set of
- * iterators each of which are
- * incremented by one at the same
- * time. This is typically used in calls
- * like <code>std::transform(a.begin(),
- * a.end(), b.begin(), functor);</code>
- * where we have synchronous iterators
- * marching through the containers
- * <code>a,b</code>. If an object of this
- * type represents the end of a range,
- * only the first element is considered
- * (we only have <code>a.end()</code>,
- * not <code>b.end()</code>)
- *
- * The template argument of the current
- * class shall be of type
- * <code>std_cxx1x::tuple</code> with
- * arguments equal to the iterator types.
- *
- * This type, and the helper functions
- * associated with it, are used as the
- * Value concept for the blocked_range
- * type of the Threading Building Blocks.
- */
- template <typename Iterators>
- struct SynchronousIterators
- {
- /**
- * Constructor.
- */
- SynchronousIterators (const Iterators &i);
-
- /**
- * Copy constructor.
- */
- SynchronousIterators (const SynchronousIterators &i);
-
- /**
- * Storage for the iterators
- * represented by the current class.
- */
- Iterators iterators;
- };
-
-
-
- template <typename Iterators>
- inline
- SynchronousIterators<Iterators>::
- SynchronousIterators (const Iterators &i)
- :
- iterators (i)
- {}
-
-
- template <typename Iterators>
- inline
- SynchronousIterators<Iterators>::
- SynchronousIterators (const SynchronousIterators &i)
- :
- iterators (i.iterators)
- {}
-
-
-
- /**
- * Return whether the first element of
- * the first argument is less than the
- * first element of the second
- * argument. Since the objects compared
- * march forward all elements at the same
- * time, comparing the first element is
- * sufficient.
- */
- template <typename Iterators>
- inline
- bool
- operator< (const SynchronousIterators<Iterators> &a,
- const SynchronousIterators<Iterators> &b)
- {
- return std_cxx1x::get<0>(a.iterators) < std_cxx1x::get<0>(b.iterators);
- }
-
-
-
- /**
- * Return the distance between the first
- * and the second argument. Since the
- * objects compared march forward all
- * elements at the same time,
- * differencing the first element is
- * sufficient.
- */
- template <typename Iterators>
- inline
- std::size_t
- operator- (const SynchronousIterators<Iterators> &a,
- const SynchronousIterators<Iterators> &b)
- {
- Assert (std::distance (std_cxx1x::get<0>(b.iterators),
- std_cxx1x::get<0>(a.iterators)) >= 0,
- ExcInternalError());
- return std::distance (std_cxx1x::get<0>(b.iterators),
- std_cxx1x::get<0>(a.iterators));
- }
-
-
- /**
- * Advance a tuple of iterators by $n$.
- */
- template <typename I1, typename I2>
- inline
- void advance (std_cxx1x::tuple<I1,I2> &t,
- const unsigned int n)
- {
- std::advance (std_cxx1x::get<0>(t), n);
- std::advance (std_cxx1x::get<1>(t), n);
- }
-
- /**
- * Advance a tuple of iterators by $n$.
- */
- template <typename I1, typename I2, typename I3>
- inline
- void advance (std_cxx1x::tuple<I1,I2,I3> &t,
- const unsigned int n)
- {
- std::advance (std_cxx1x::get<0>(t), n);
- std::advance (std_cxx1x::get<1>(t), n);
- std::advance (std_cxx1x::get<2>(t), n);
- }
-
- /**
- * Advance a tuple of iterators by $n$.
- */
- template <typename I1, typename I2,
- typename I3, typename I4>
- inline
- void advance (std_cxx1x::tuple<I1,I2,I3, I4> &t,
- const unsigned int n)
- {
- std::advance (std_cxx1x::get<0>(t), n);
- std::advance (std_cxx1x::get<1>(t), n);
- std::advance (std_cxx1x::get<2>(t), n);
- std::advance (std_cxx1x::get<3>(t), n);
- }
-
-
-
- /**
- * Advance a tuple of iterators by 1.
- */
- template <typename I1, typename I2>
- inline
- void advance_by_one (std_cxx1x::tuple<I1,I2> &t)
- {
- ++std_cxx1x::get<0>(t);
- ++std_cxx1x::get<1>(t);
- }
-
- /**
- * Advance a tuple of iterators by 1.
- */
- template <typename I1, typename I2, typename I3>
- inline
- void advance_by_one (std_cxx1x::tuple<I1,I2,I3> &t)
- {
- ++std_cxx1x::get<0>(t);
- ++std_cxx1x::get<1>(t);
- ++std_cxx1x::get<2>(t);
- }
-
- /**
- * Advance a tuple of iterators by 1.
- */
- template <typename I1, typename I2,
- typename I3, typename I4>
- inline
- void advance_by_one (std_cxx1x::tuple<I1,I2,I3,I4> &t)
- {
- ++std_cxx1x::get<0>(t);
- ++std_cxx1x::get<1>(t);
- ++std_cxx1x::get<2>(t);
- ++std_cxx1x::get<3>(t);
- }
-
-
-
- /**
- * Advance the elements of this iterator
- * by $n$.
- */
- template <typename Iterators>
- inline
- SynchronousIterators<Iterators>
- operator + (const SynchronousIterators<Iterators> &a,
- const std::size_t n)
- {
- SynchronousIterators<Iterators> x (a);
- parallel::internal::advance (x.iterators, n);
- return x;
- }
-
- /**
- * Advance the elements of this iterator
- * by 1.
- */
- template <typename Iterators>
- inline
- SynchronousIterators<Iterators>
- operator ++ (SynchronousIterators<Iterators> &a)
- {
- parallel::internal::advance_by_one (a.iterators);
- return a;
- }
-
-
- /**
- * Compare synch iterators for
- * inequality. Since they march in synch,
- * comparing only the first element is
- * sufficient.
- */
- template <typename Iterators>
- inline
- bool
- operator != (const SynchronousIterators<Iterators> &a,
- const SynchronousIterators<Iterators> &b)
- {
- return (std_cxx1x::get<0>(a.iterators) !=
- std_cxx1x::get<0>(b.iterators));
- }
-
-
/**
* Convert a function object of type F
* into an object that can be applied to
*out++ = predicate (*in++);
#else
typedef std_cxx1x::tuple<InputIterator,OutputIterator> Iterators;
- typedef internal::SynchronousIterators<Iterators> SyncIterators;
+ typedef SynchronousIterators<Iterators> SyncIterators;
Iterators x_begin (begin_in, out);
Iterators x_end (end_in, OutputIterator());
tbb::parallel_for (tbb::blocked_range<SyncIterators>(x_begin,
typedef
std_cxx1x::tuple<InputIterator1,InputIterator2,OutputIterator>
Iterators;
- typedef internal::SynchronousIterators<Iterators> SyncIterators;
+ typedef SynchronousIterators<Iterators> SyncIterators;
Iterators x_begin (begin_in1, in2, out);
Iterators x_end (end_in1, InputIterator2(), OutputIterator());
tbb::parallel_for (tbb::blocked_range<SyncIterators>(x_begin,
typedef
std_cxx1x::tuple<InputIterator1,InputIterator2,InputIterator3,OutputIterator>
Iterators;
- typedef internal::SynchronousIterators<Iterators> SyncIterators;
+ typedef SynchronousIterators<Iterators> SyncIterators;
Iterators x_begin (begin_in1, in2, in3, out);
Iterators x_end (end_in1, InputIterator2(),
InputIterator3(), OutputIterator());
--- /dev/null
+//---------------------------------------------------------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2008, 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.
+//
+//---------------------------------------------------------------------------
+#ifndef __deal2__synchronous_iterator_h
+#define __deal2__synchronous_iterator_h
+
+
+#include <base/config.h>
+
+#include <base/std_cxx1x/tuple.h>
+
+#include <iterator>
+
+DEAL_II_NAMESPACE_OPEN
+
+/**
+ * A class that represents a set of
+ * iterators each of which are
+ * incremented by one at the same
+ * time. This is typically used in calls
+ * like <code>std::transform(a.begin(),
+ * a.end(), b.begin(), functor);</code>
+ * where we have synchronous iterators
+ * marching through the containers
+ * <code>a,b</code>. If an object of this
+ * type represents the end of a range,
+ * only the first element is considered
+ * (we only have <code>a.end()</code>,
+ * not <code>b.end()</code>)
+ *
+ * The template argument of the current
+ * class shall be of type
+ * <code>std_cxx1x::tuple</code> with
+ * arguments equal to the iterator types.
+ *
+ * This type, and the helper functions
+ * associated with it, are used as the
+ * Value concept for the blocked_range
+ * type of the Threading Building Blocks.
+ *
+ * @author Wolfgang Bangerth, 2008
+ */
+template <typename Iterators>
+struct SynchronousIterators
+{
+ /**
+ * Constructor.
+ */
+ SynchronousIterators (const Iterators &i);
+
+ /**
+ * Copy constructor.
+ */
+ SynchronousIterators (const SynchronousIterators &i);
+
+ /**
+ * Storage for the iterators
+ * represented by the current class.
+ */
+ Iterators iterators;
+};
+
+
+
+template <typename Iterators>
+inline
+SynchronousIterators<Iterators>::
+SynchronousIterators (const Iterators &i)
+ :
+ iterators (i)
+{}
+
+
+template <typename Iterators>
+inline
+SynchronousIterators<Iterators>::
+SynchronousIterators (const SynchronousIterators &i)
+ :
+ iterators (i.iterators)
+{}
+
+
+
+ /**
+ * Return whether the first element of
+ * the first argument is less than the
+ * first element of the second
+ * argument. Since the objects compared
+ * march forward all elements at the same
+ * time, comparing the first element is
+ * sufficient.
+ */
+template <typename Iterators>
+inline
+bool
+operator< (const SynchronousIterators<Iterators> &a,
+ const SynchronousIterators<Iterators> &b)
+{
+ return std_cxx1x::get<0>(a.iterators) < std_cxx1x::get<0>(b.iterators);
+}
+
+
+
+ /**
+ * Return the distance between the first
+ * and the second argument. Since the
+ * objects compared march forward all
+ * elements at the same time,
+ * differencing the first element is
+ * sufficient.
+ */
+template <typename Iterators>
+inline
+std::size_t
+operator- (const SynchronousIterators<Iterators> &a,
+ const SynchronousIterators<Iterators> &b)
+{
+ Assert (std::distance (std_cxx1x::get<0>(b.iterators),
+ std_cxx1x::get<0>(a.iterators)) >= 0,
+ ExcInternalError());
+ return std::distance (std_cxx1x::get<0>(b.iterators),
+ std_cxx1x::get<0>(a.iterators));
+}
+
+
+ /**
+ * Advance a tuple of iterators by $n$.
+ */
+template <typename I1, typename I2>
+inline
+void advance (std_cxx1x::tuple<I1,I2> &t,
+ const unsigned int n)
+{
+ std::advance (std_cxx1x::get<0>(t), n);
+ std::advance (std_cxx1x::get<1>(t), n);
+}
+
+ /**
+ * Advance a tuple of iterators by $n$.
+ */
+template <typename I1, typename I2, typename I3>
+inline
+void advance (std_cxx1x::tuple<I1,I2,I3> &t,
+ const unsigned int n)
+{
+ std::advance (std_cxx1x::get<0>(t), n);
+ std::advance (std_cxx1x::get<1>(t), n);
+ std::advance (std_cxx1x::get<2>(t), n);
+}
+
+ /**
+ * Advance a tuple of iterators by $n$.
+ */
+template <typename I1, typename I2,
+ typename I3, typename I4>
+inline
+void advance (std_cxx1x::tuple<I1,I2,I3, I4> &t,
+ const unsigned int n)
+{
+ std::advance (std_cxx1x::get<0>(t), n);
+ std::advance (std_cxx1x::get<1>(t), n);
+ std::advance (std_cxx1x::get<2>(t), n);
+ std::advance (std_cxx1x::get<3>(t), n);
+}
+
+
+
+ /**
+ * Advance a tuple of iterators by 1.
+ */
+template <typename I1, typename I2>
+inline
+void advance_by_one (std_cxx1x::tuple<I1,I2> &t)
+{
+ ++std_cxx1x::get<0>(t);
+ ++std_cxx1x::get<1>(t);
+}
+
+ /**
+ * Advance a tuple of iterators by 1.
+ */
+template <typename I1, typename I2, typename I3>
+inline
+void advance_by_one (std_cxx1x::tuple<I1,I2,I3> &t)
+{
+ ++std_cxx1x::get<0>(t);
+ ++std_cxx1x::get<1>(t);
+ ++std_cxx1x::get<2>(t);
+}
+
+ /**
+ * Advance a tuple of iterators by 1.
+ */
+template <typename I1, typename I2,
+ typename I3, typename I4>
+inline
+void advance_by_one (std_cxx1x::tuple<I1,I2,I3,I4> &t)
+{
+ ++std_cxx1x::get<0>(t);
+ ++std_cxx1x::get<1>(t);
+ ++std_cxx1x::get<2>(t);
+ ++std_cxx1x::get<3>(t);
+}
+
+
+
+ /**
+ * Advance the elements of this iterator
+ * by $n$.
+ */
+template <typename Iterators>
+inline
+SynchronousIterators<Iterators>
+operator + (const SynchronousIterators<Iterators> &a,
+ const std::size_t n)
+{
+ SynchronousIterators<Iterators> x (a);
+ dealii::advance (x.iterators, n);
+ return x;
+}
+
+ /**
+ * Advance the elements of this iterator
+ * by 1.
+ */
+template <typename Iterators>
+inline
+SynchronousIterators<Iterators>
+operator ++ (SynchronousIterators<Iterators> &a)
+{
+ dealii::advance_by_one (a.iterators);
+ return a;
+}
+
+
+ /**
+ * Compare synch iterators for
+ * inequality. Since they march in synch,
+ * comparing only the first element is
+ * sufficient.
+ */
+template <typename Iterators>
+inline
+bool
+operator != (const SynchronousIterators<Iterators> &a,
+ const SynchronousIterators<Iterators> &b)
+{
+ return (std_cxx1x::get<0>(a.iterators) !=
+ std_cxx1x::get<0>(b.iterators));
+}
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif
std::vector<unsigned char> boundary_indicators;
Triangulation<dim> triangulation;
-
+
FE_Q<dim> fe_velocity;
FE_Q<dim> fe_pressure;
-
+
DoFHandler<dim> dof_handler_velocity;
DoFHandler<dim> dof_handler_pressure;
SparsityPattern sparsity_pattern_velocity;
SparsityPattern sparsity_pattern_pressure;
SparsityPattern sparsity_pattern_pres_vel;
-
+
SparseMatrix<double> vel_Laplace_plus_Mass;
SparseMatrix<double> vel_it_matrix[dim];
SparseMatrix<double> vel_Mass;
SparseMatrix<double> pres_Mass;
SparseMatrix<double> pres_Diff[dim];
SparseMatrix<double> pres_iterative;
-
+
Vector<double> pres_n;
Vector<double> pres_n_minus_1;
Vector<double> phi_n;
typename DoFHandler<dim>::active_cell_iterator
> IteratorTuple;
- typedef parallel::internal::SynchronousIterators<IteratorTuple> IteratorPair;
+ typedef SynchronousIterators<IteratorTuple> IteratorPair;
void init_gradient_operator();
FullMatrix<double> local_grad;
std::vector<unsigned int> vel_local_dof_indices;
std::vector<unsigned int> pres_local_dof_indices;
-
+
InitGradPerTaskData (const unsigned int dd,
const unsigned int vdpc,
const unsigned int pdpc)
pres_local_dof_indices (pdpc)
{}
};
-
+
struct InitGradScratchData
{
unsigned int nqp;
data.fe_val_pres.get_update_flags())
{}
};
-
+
void assemble_one_cell_of_gradient (const IteratorPair &SI,
InitGradScratchData &scratch,
InitGradPerTaskData &data);
-
+
void copy_gradient_local_to_global (const InitGradPerTaskData &data);
// The same general layout also applies
// implementing the assembly of the
// advection term:
void assemble_advection_term();
-
+
struct AdvectionPerTaskData
{
FullMatrix<double> local_advection;
local_dof_indices (dpc)
{}
};
-
+
struct AdvectionScratchData
{
unsigned int nqp;
u_star_tmp (nqp),
fe_val (fe, quad, flags)
{}
-
+
AdvectionScratchData (const AdvectionScratchData &data)
:
nqp (data.nqp),
void assemble_one_cell_of_advection (const typename DoFHandler<dim>::active_cell_iterator &cell,
AdvectionScratchData &scratch,
AdvectionPerTaskData &data);
-
+
void copy_advection_local_to_global (const AdvectionPerTaskData &data);
// The final few functions implement the
void diffusion_component_solve (const unsigned int d);
void plot_solution (const unsigned int step);
-
+
void assemble_vorticity (const bool reinit_prec);
};
const unsigned int n_of_plots)
{
ConditionalOStream verbose_cout (std::cout, verbose);
-
+
unsigned int n_steps = (T - t_0)/dt;
vel_exact.set_time (2.*dt);
plot_solution(1);