~corrado-maurini/dolfin/tao

« back to all changes in this revision

Viewing changes to dolfin/mesh/Restriction.cpp

  • Committer: corrado maurini
  • Date: 2012-12-18 12:16:08 UTC
  • mfrom: (6685.78.207 trunk)
  • Revision ID: corrado.maurini@upmc.fr-20121218121608-nk82ly9jgsld9u84
updating with trunk, fix uint in TAO solver and hacking the check for tao FindTAO.cmake

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2012 Anders Logg
 
2
//
 
3
// This file is part of DOLFIN.
 
4
//
 
5
// DOLFIN is free software: you can redistribute it and/or modify
 
6
// it under the terms of the GNU Lesser General Public License as published by
 
7
// the Free Software Foundation, either version 3 of the License, or
 
8
// (at your option) any later version.
 
9
//
 
10
// DOLFIN is distributed in the hope that it will be useful,
 
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
13
// GNU Lesser General Public License for more details.
 
14
//
 
15
// You should have received a copy of the GNU Lesser General Public License
 
16
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
 
17
//
 
18
// First added:  2012-11-14
 
19
// Last changed: 2012-11-19
 
20
 
 
21
#include <dolfin/common/NoDeleter.h>
 
22
#include "SubDomain.h"
 
23
#include "Restriction.h"
 
24
 
 
25
using namespace dolfin;
 
26
 
 
27
//-----------------------------------------------------------------------------
 
28
Restriction::Restriction(const Mesh& mesh,
 
29
                         const SubDomain& sub_domain)
 
30
{
 
31
  init_from_subdomain(mesh, sub_domain, mesh.topology().dim());
 
32
}
 
33
//-----------------------------------------------------------------------------
 
34
Restriction::Restriction(const Mesh& mesh,
 
35
                         const SubDomain& sub_domain, std::size_t dim)
 
36
{
 
37
  init_from_subdomain(mesh, sub_domain, dim);
 
38
}
 
39
//-----------------------------------------------------------------------------
 
40
Restriction::Restriction(const MeshFunction<std::size_t>& domain_markers,
 
41
                         std::size_t domain_number)
 
42
  : _domain_markers(reference_to_no_delete_pointer(domain_markers)),
 
43
    _domain_number(domain_number)
 
44
{
 
45
  // Do nothing
 
46
}
 
47
//-----------------------------------------------------------------------------
 
48
Restriction::Restriction(boost::shared_ptr<const MeshFunction<std::size_t> > domain_markers,
 
49
                         std::size_t domain_number)
 
50
  : _domain_markers(domain_markers),
 
51
    _domain_number(domain_number)
 
52
{
 
53
  // Do nothing
 
54
}
 
55
//-----------------------------------------------------------------------------
 
56
const Mesh& Restriction::mesh() const
 
57
{
 
58
  dolfin_assert(_domain_markers);
 
59
  return _domain_markers->mesh();
 
60
}
 
61
//-----------------------------------------------------------------------------
 
62
std::size_t Restriction::dim() const
 
63
{
 
64
  dolfin_assert(_domain_markers);
 
65
  return _domain_markers->dim();
 
66
}
 
67
//-----------------------------------------------------------------------------
 
68
void Restriction::init_from_subdomain(const Mesh& mesh,
 
69
                                      const SubDomain& sub_domain, std::size_t dim)
 
70
{
 
71
  // Create mesh function
 
72
  MeshFunction<std::size_t>* __domain_markers = new MeshFunction<std::size_t>(mesh, dim);
 
73
  dolfin_assert(__domain_markers);
 
74
 
 
75
  // Set all markers to 1 and mark current domain as 0
 
76
  __domain_markers->set_all(1);
 
77
  sub_domain.mark(*__domain_markers, 0);
 
78
  _domain_number = 0;
 
79
 
 
80
  // Store shared pointer
 
81
  _domain_markers = boost::shared_ptr<const MeshFunction<std::size_t> >(__domain_markers);
 
82
}
 
83
//-----------------------------------------------------------------------------