/usr/include/deal.II/multigrid/mg_transfer_component.templates.h is in libdeal.ii-dev 8.1.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | // ---------------------------------------------------------------------
// $Id: mg_transfer_component.templates.h 30036 2013-07-18 16:55:32Z maier $
//
// Copyright (C) 2003 - 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------
#ifndef __deal2__mg_transfer_component_templates_h
#define __deal2__mg_transfer_component_templates_h
#include <deal.II/lac/sparse_matrix.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/fe/fe.h>
#include <deal.II/lac/constraint_matrix.h>
#include <deal.II/multigrid/mg_base.h>
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/multigrid/mg_tools.h>
#include <deal.II/multigrid/mg_transfer_component.h>
#include <deal.II/numerics/data_out.h>
#include <algorithm>
#include <sstream>
#include <fstream>
DEAL_II_NAMESPACE_OPEN
/* --------------------- MGTransferSelect -------------- */
template <typename number>
template <int dim, typename number2, int spacedim>
void
MGTransferSelect<number>::copy_to_mg (
const DoFHandler<dim,spacedim> &mg_dof_handler,
MGLevelObject<Vector<number> > &dst,
const BlockVector<number2> &src) const
{
do_copy_to_mg (mg_dof_handler, dst, src.block(target_component[selected_component]));
}
template <typename number>
template <int dim, typename number2, int spacedim>
void
MGTransferSelect<number>::copy_to_mg (
const DoFHandler<dim,spacedim> &mg_dof_handler,
MGLevelObject<Vector<number> > &dst,
const Vector<number2> &src) const
{
do_copy_to_mg (mg_dof_handler, dst, src);
}
template <typename number>
template <int dim, typename number2, int spacedim>
void
MGTransferSelect<number>::copy_from_mg (
const DoFHandler<dim,spacedim> &mg_dof_handler,
BlockVector<number2> &dst,
const MGLevelObject<Vector<number> > &src) const
{
dst = 0;
do_copy_from_mg (mg_dof_handler,
dst.block(target_component[selected_component]), src);
if (constraints != 0)
constraints->condense(dst);
}
template <typename number>
template <int dim, typename number2, int spacedim>
void
MGTransferSelect<number>::copy_from_mg (
const DoFHandler<dim,spacedim> &mg_dof_handler,
Vector<number2> &dst,
const MGLevelObject<Vector<number> > &src) const
{
dst = 0;
do_copy_from_mg (mg_dof_handler, dst, src);
if (constraints != 0)
{
//If we were given constraints
//apply them to the dst that goes
//back now to the linear solver.
//Since constraints are globally
//defined create a global vector here
//and copy dst to the right component,
//apply the constraints then and copy
//the block back to dst.
const unsigned int n_blocks =
*std::max_element(target_component.begin(), target_component.end()) + 1;
std::vector<types::global_dof_index> dofs_per_block (n_blocks);
DoFTools::count_dofs_per_block (mg_dof_handler, dofs_per_block, target_component);
BlockVector<number> tmp;
tmp.reinit(n_blocks);
for (unsigned int b=0; b<n_blocks; ++b)
tmp.block(b).reinit(dofs_per_block[b]);
tmp.collect_sizes ();
tmp.block(target_component[selected_component]) = dst;
constraints->condense(tmp);
dst = tmp.block(target_component[selected_component]);
}
}
template <typename number>
template <int dim, typename number2, int spacedim>
void
MGTransferSelect<number>::copy_from_mg_add (
const DoFHandler<dim,spacedim> &mg_dof_handler,
BlockVector<number2> &dst,
const MGLevelObject<Vector<number> > &src) const
{
do_copy_from_mg_add (mg_dof_handler, dst, src);
}
template <typename number>
template <int dim, typename number2, int spacedim>
void
MGTransferSelect<number>::copy_from_mg_add (
const DoFHandler<dim,spacedim> &mg_dof_handler,
Vector<number2> &dst,
const MGLevelObject<Vector<number> > &src) const
{
do_copy_from_mg_add (mg_dof_handler, dst, src);
}
template <typename number>
template <int dim, class OutVector, int spacedim>
void
MGTransferSelect<number>::do_copy_from_mg (
const DoFHandler<dim,spacedim> &mg_dof_handler,
OutVector &dst,
const MGLevelObject<Vector<number> > &src) const
{
// const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
// const unsigned int dofs_per_cell = fe.dofs_per_cell;
// std::vector<unsigned int> global_dof_indices (dofs_per_cell);
// std::vector<unsigned int> level_dof_indices (dofs_per_cell);
typename DoFHandler<dim,spacedim>::active_cell_iterator
level_cell = mg_dof_handler.begin_active();
const typename DoFHandler<dim,spacedim>::active_cell_iterator
endc = mg_dof_handler.end();
// traverse all cells and copy the
// data appropriately to the output
// vector
// Note that the level is
// monotonuosly increasing
dst = 0;
for (; level_cell != endc; ++level_cell)
{
const unsigned int level = level_cell->level();
typedef std::vector<std::pair<types::global_dof_index, unsigned int> >::const_iterator IT;
for (IT i=copy_to_and_from_indices[level].begin();
i != copy_to_and_from_indices[level].end(); ++i)
dst(i->first) = src[level](i->second);
}
}
template <typename number>
template <int dim, class OutVector, int spacedim>
void
MGTransferSelect<number>::do_copy_from_mg_add (
const DoFHandler<dim,spacedim> &mg_dof_handler,
OutVector &dst,
const MGLevelObject<Vector<number> > &src) const
{
const FiniteElement<dim> &fe = mg_dof_handler.get_fe();
const unsigned int dofs_per_cell = fe.dofs_per_cell;
std::vector<types::global_dof_index> global_dof_indices (dofs_per_cell);
std::vector<types::global_dof_index> level_dof_indices (dofs_per_cell);
typename DoFHandler<dim,spacedim>::active_cell_iterator
level_cell = mg_dof_handler.begin_active();
const typename DoFHandler<dim,spacedim>::active_cell_iterator
endc = mg_dof_handler.end();
// traverse all cells and copy the
// data appropriately to the output
// vector
// Note that the level is
// monotonuosly increasing
dst = 0;
for (; level_cell != endc; ++level_cell)
{
const unsigned int level = level_cell->level();
typedef std::vector<std::pair<types::global_dof_index, unsigned int> >::const_iterator IT;
for (IT i=copy_to_and_from_indices[level].begin();
i != copy_to_and_from_indices[level].end(); ++i)
dst(i->first) += src[level](i->second);
}
}
template <typename number>
std::size_t
MGTransferSelect<number>::memory_consumption () const
{
return sizeof(int) + MGTransferComponentBase::memory_consumption();
}
DEAL_II_NAMESPACE_CLOSE
#endif
|