# include <lac/sparsity_pattern.h>
# include <lac/block_sparsity_pattern.h>
#endif
+#include <lac/vector_memory.h>
+
#include <multigrid/mg_base.h>
#include <multigrid/mg_level_object.h>
+
+
#include <dofs/dof_handler.h>
#include <boost/shared_ptr.hpp>
* all levels.
*/
std::vector<std::vector<unsigned int> > mg_component_start;
-
+
/**
* Call build_matrices()
* function first.
private MGTransferBlockBase
{
public:
+ /**
+ * Default constructor.
+ */
+ MGTransferBlock();
+
/**
* Destructor.
*/
virtual ~MGTransferBlock ();
+ /**
+ * Initialize additional #factors
+ * and #memory if the restriction
+ * of the components is to be
+ * weighted differently.
+ */
+ void initialize (const std::vector<number>& factors,
+ VectorMemory<Vector<number> >& memory);
+
/**
* Build the prolongation
* matrices for each level.
* for the same function in
* MGTransferBlockBase.
*
- * @arg selected: Opional
- * argument indicating that only
- * matrices for these components
- * are to be built. By default,
- * all matrices are built.
- *
* If <tt>mg_target_component</tt> is
* present, this refers to the
* renumbered components.
template <int dim>
void build_matrices (const DoFHandler<dim> &dof,
const MGDoFHandler<dim> &mg_dof,
- std::vector<bool> selected = std::vector<bool>(),
const std::vector<unsigned int>& target_component
= std::vector<unsigned int>(),
const std::vector<unsigned int>& mg_target_component
MGLevelObject<BlockVector<number> > &dst,
const InVector &src,
const is_1d<false> &) const;
+
+ /**
+ * Optional multiplication
+ * factors for each
+ * component. Requires
+ * initialization of #memory.
+ */
+ std::vector<number> factors;
+
+ /**
+ * Memory pool required if
+ * additional multiplication
+ * using #factors is desired.
+ */
+ SmartPointer<VectorMemory<Vector<number> > > memory;
};
void MGTransferBlock<number>::build_matrices (
const DoFHandler<dim> &dof,
const MGDoFHandler<dim> &mg_dof,
- std::vector<bool> select,
const std::vector<unsigned int>& t_component,
const std::vector<unsigned int>& mg_t_component)
{
-//TODO:[GK] What about selected?
- mg_selected = select;
+ if (selected.size() == 0)
+ selected = std::vector<bool> (mg_dof.get_fe().n_components(), true);
if (mg_selected.size() == 0)
mg_selected = std::vector<bool> (mg_dof.get_fe().n_components(), true);
void MGTransferBlock<float>::build_matrices<deal_II_dimension>
(const DoFHandler<deal_II_dimension> &,
const MGDoFHandler<deal_II_dimension> &,
- std::vector<bool>,
const std::vector<unsigned int>&,
const std::vector<unsigned int>&);
void MGTransferBlock<double>::build_matrices<deal_II_dimension>
(const DoFHandler<deal_II_dimension> &,
const MGDoFHandler<deal_II_dimension> &,
- std::vector<bool>,
const std::vector<unsigned int>&,
const std::vector<unsigned int>&);
#include <multigrid/mg_transfer.templates.h>
#include <multigrid/multigrid.templates.h>
-
-
// Warning: the following function is for debugging purposes only. It
// will be compiled only, if the additional and undocumented compiler
// flag MG_DEBUG is set. Furthermore, as soon as this function is
template <typename number>
-MGTransferBlock<number>::~MGTransferBlock ()
+MGTransferBlock<number>::MGTransferBlock ()
+ :
+ memory(0, typeid(*this).name())
{}
+template <typename number>
+MGTransferBlock<number>::~MGTransferBlock ()
+{
+ if (memory != 0) memory = 0;
+}
+
+
+template <typename number>
+void
+MGTransferBlock<number>::initialize (const std::vector<number>& f,
+ VectorMemory<Vector<number> >& mem)
+{
+ factors = f;
+ memory = &mem;
+}
+
+
template <typename number>
void MGTransferBlock<number>::prolongate (
const unsigned int to_level,
{
if (!selected[k])
++k;
- prolongation_matrices[from_level-1]->block(k,k).Tvmult_add (dst.block(b), src.block(b));
+ if (factors.size() != 0)
+ {
+ Assert (memory != 0, ExcNotInitialized());
+ Vector<number>* aux = memory->alloc();
+ aux->reinit(dst.block(b));
+ prolongation_matrices[from_level-1]->block(k,k).Tvmult (*aux, src.block(b));
+ dst.block(b).add(factors[k], *aux);
+ memory->free(aux);
+ }
+ else
+ {
+ prolongation_matrices[from_level-1]->block(k,k).Tvmult_add (dst.block(b),
+ src.block(b));
+ }
++k;
}
}