/usr/include/deal.II/multigrid/mg_constrained_dofs.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 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | // ---------------------------------------------------------------------
// $Id: mg_constrained_dofs.h 31075 2013-10-02 17:51:27Z heister $
//
// Copyright (C) 2010 - 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_constraints_h
#define __deal2__mg_constraints_h
#include <deal.II/base/config.h>
#include <deal.II/base/subscriptor.h>
#include <deal.II/multigrid/mg_tools.h>
#include <vector>
#include <set>
DEAL_II_NAMESPACE_OPEN
template <int dim, int spacedim> class DoFHandler;
template <int dim> struct FunctionMap;
/**
* Collection of boundary constraints and refinement edge constraints
* for level vectors.
*
* @ingroup mg
*/
class MGConstrainedDoFs : public Subscriptor
{
public:
typedef std::vector<std::set<types::global_dof_index> >::size_type size_dof;
/**
* Fill the internal data
* structures with values
* extracted from the dof
* handler.
*
* This function leaves
* #boundary_indices empty, since
* no boundary values are
* provided.
*/
template <int dim, int spacedim>
void initialize(const DoFHandler<dim,spacedim> &dof);
/**
* Fill the internal data
* structures with values
* extracted from the dof
* handler, applying the boundary
* values provided.
*/
template <int dim, int spacedim>
void initialize(const DoFHandler<dim,spacedim> &dof,
const typename FunctionMap<dim>::type &function_map,
const ComponentMask &component_mask = ComponentMask());
/**
* Reset the data structures.
*/
void clear();
/**
* Determine whether a dof index is subject to a boundary
* constraint. (is on boundary of domain)
*/
bool is_boundary_index (const unsigned int level,
const types::global_dof_index index) const;
/**
* Determine whether a dof index is at an edge that is not a
* refinement edge.
*/
// TODO: remove
bool non_refinement_edge_index (const unsigned int level,
const types::global_dof_index index) const;
/**
* Determine whether a dof index is at the refinement edge.
*/
bool at_refinement_edge (const unsigned int level,
const types::global_dof_index index) const;
/**
* Determine whether a dof index is at the refinement edge and
* subject to a boundary constraint .
* = is_boundary_index() && at_refinement_edge()
*/
bool at_refinement_edge_boundary (const unsigned int level,
const types::global_dof_index index) const;
/**
* Return the indices of dofs for each level that lie on the
* boundary of the domain.
*/
// TODO: remove
const std::vector<std::set<types::global_dof_index> > &
get_boundary_indices () const;
/**
* Return the indices of dofs for each level that lie on the
* boundary of the domain.
*/
// TODO: remove
const std::vector<std::set<types::global_dof_index> > &
get_non_refinement_edge_indices () const;
/**
* Return the indices of dofs for each level that lie on the
* refinement edge (i.e. are on faces between cells of this level
* and cells on the level below).
*/
// TODO: remove
const std::vector<std::vector<bool> > &
get_refinement_edge_indices () const;
/**
* Return the indices of dofs for each level that are in the
* intersection of the sets returned by get_boundary_indices() and
* get_refinement_edge_indices().
*/
// TODO: remove
const std::vector<std::vector<bool> > &
get_refinement_edge_boundary_indices () const;
/**
* Return if boundary_indices need to be set or not.
*/
bool set_boundary_values () const;
/**
* Return if the finite element requires continuity across
* refinement edges.
*/
bool continuity_across_refinement_edges () const;
private:
/**
* The indices of boundary dofs for each level.
*/
std::vector<std::set<types::global_dof_index> > boundary_indices;
/**
* The degrees of freedom on egdges that are not a refinement edge
* between a level and coarser cells.
*/
std::vector<std::set<types::global_dof_index> > non_refinement_edge_indices;
/**
* The degrees of freedom on the refinement edge between a level and
* coarser cells.
*/
std::vector<std::vector<bool> > refinement_edge_indices;
/**
* The degrees of freedom on the refinement edge between a level and
* coarser cells, which are also on the boundary.
*
* This is a subset of #refinement_edge_indices.
*/
std::vector<std::vector<bool> > refinement_edge_boundary_indices;
};
template <int dim, int spacedim>
inline
void
MGConstrainedDoFs::initialize(const DoFHandler<dim,spacedim> &dof)
{
const unsigned int nlevels = dof.get_tria().n_global_levels();
refinement_edge_indices.resize(nlevels);
refinement_edge_boundary_indices.resize(nlevels);
non_refinement_edge_indices.resize(nlevels);
for (unsigned int l=0; l<nlevels; ++l)
{
refinement_edge_indices[l].resize(dof.n_dofs(l));
refinement_edge_boundary_indices[l].resize(dof.n_dofs(l));
}
MGTools::extract_inner_interface_dofs (dof, refinement_edge_indices,
refinement_edge_boundary_indices);
MGTools::extract_non_interface_dofs (dof, non_refinement_edge_indices);
}
template <int dim, int spacedim>
inline
void
MGConstrainedDoFs::initialize(
const DoFHandler<dim,spacedim> &dof,
const typename FunctionMap<dim>::type &function_map,
const ComponentMask &component_mask)
{
const unsigned int nlevels = dof.get_tria().n_global_levels();
boundary_indices.resize(nlevels);
refinement_edge_indices.resize(nlevels);
refinement_edge_boundary_indices.resize(nlevels);
non_refinement_edge_indices.resize(nlevels);
for (unsigned int l=0; l<nlevels; ++l)
{
boundary_indices[l].clear();
refinement_edge_indices[l].resize(dof.n_dofs(l));
refinement_edge_boundary_indices[l].resize(dof.n_dofs(l));
}
MGTools::make_boundary_list (dof, function_map, boundary_indices, component_mask);
MGTools::extract_inner_interface_dofs (dof, refinement_edge_indices,
refinement_edge_boundary_indices);
MGTools::extract_non_interface_dofs (dof, non_refinement_edge_indices);
}
inline
void
MGConstrainedDoFs::clear()
{
for (unsigned int l=0; l<boundary_indices.size(); ++l)
boundary_indices[l].clear();
for (unsigned int l=0; l<refinement_edge_indices.size(); ++l)
refinement_edge_indices[l].clear();
for (unsigned int l=0; l<refinement_edge_boundary_indices.size(); ++l)
refinement_edge_boundary_indices[l].clear();
for (unsigned int l=0; l<non_refinement_edge_indices.size(); ++l)
non_refinement_edge_indices[l].clear();
}
inline
bool
MGConstrainedDoFs::is_boundary_index (const unsigned int level,
const types::global_dof_index index) const
{
AssertIndexRange(level, boundary_indices.size());
if (boundary_indices[level].find(index) != boundary_indices[level].end())
return true;
else
return false;
}
inline
bool
MGConstrainedDoFs::non_refinement_edge_index (const unsigned int level,
const types::global_dof_index index) const
{
AssertIndexRange(level, non_refinement_edge_indices.size());
if (non_refinement_edge_indices[level].find(index) != non_refinement_edge_indices[level].end())
return true;
else
return false;
}
inline
bool
MGConstrainedDoFs::at_refinement_edge (const unsigned int level,
const types::global_dof_index index) const
{
AssertIndexRange(level, refinement_edge_indices.size());
AssertIndexRange(index, refinement_edge_indices[level].size());
return refinement_edge_indices[level][index];
}
inline
bool
MGConstrainedDoFs::at_refinement_edge_boundary (const unsigned int level,
const types::global_dof_index index) const
{
AssertIndexRange(level, refinement_edge_boundary_indices.size());
AssertIndexRange(index, refinement_edge_boundary_indices[level].size());
return refinement_edge_boundary_indices[level][index];
}
inline
const std::vector<std::set<types::global_dof_index> > &
MGConstrainedDoFs::get_boundary_indices () const
{
return boundary_indices;
}
inline
const std::vector<std::set<types::global_dof_index> > &
MGConstrainedDoFs::get_non_refinement_edge_indices () const
{
return non_refinement_edge_indices;
}
inline
const std::vector<std::vector<bool> > &
MGConstrainedDoFs::get_refinement_edge_indices () const
{
return refinement_edge_indices;
}
inline
const std::vector<std::vector<bool> > &
MGConstrainedDoFs::get_refinement_edge_boundary_indices () const
{
return refinement_edge_boundary_indices;
}
inline
bool
MGConstrainedDoFs::set_boundary_values () const
{
const bool boundary_values_need_to_be_set
= boundary_indices.size()!=0;
return boundary_values_need_to_be_set;
}
inline
bool
MGConstrainedDoFs::continuity_across_refinement_edges () const
{
bool is_continuous = false;
for (unsigned int l=0; l<refinement_edge_indices.size(); ++l)
for (unsigned int i=0; i<refinement_edge_indices[l].size(); ++i)
if (refinement_edge_indices[l][i])
{
is_continuous = true;
return is_continuous;
}
return is_continuous;
}
DEAL_II_NAMESPACE_CLOSE
#endif
|