~ubuntu-branches/ubuntu/natty/dolfin/natty

« back to all changes in this revision

Viewing changes to dolfin/adaptivity/LocalAssembler.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Johannes Ring
  • Date: 2011-02-24 10:34:44 UTC
  • mfrom: (1.1.7 upstream) (14.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110224103444-n3fwnmh32lfoske0
Tags: 0.9.10-1
* New upstream release. This release fixes bug "FTBFS: error:
  'SCOTCH_Dgraph' was not declared in this scope" (closes: #612602).
* debian/control:
  - Add libslepc3.1-dev and libboost-thread-dev to Build-Depends and
    Depends field in binary package libdolfin0-dev.
  - Bump build dependency on python-ufc to >= 2.0.0.
  - Remove Build-Depends-Indep field as upstream no longer ships the
    user manual.
  - Remove old fields Conflicts, Provides, and Replaces from
    libdolfin0-dev, libdolfin0, libdolfin0-dbg, and python-dolfin.
* Remove all patches as they are now incorporated upstream.
* Add dolfin-plot and dolfin-version to debian/dolfin-bin.install.
* Remove .doc-base file since the user manual is removed by upstream.
* Remove targets clean and install/dolfin-doc from debian/rules since
  they are no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2011 Marie E. Rognes
 
2
// Licensed under the GNU LGPL Version 3.0 or any later version
 
3
//
 
4
// First added:  2011-01-04
 
5
// Last changed: 2011-02-21
 
6
 
 
7
#include <dolfin/fem/UFC.h>
 
8
#include <dolfin/mesh/Cell.h>
 
9
#include <dolfin/mesh/Facet.h>
 
10
#include "LocalAssembler.h"
 
11
 
 
12
using namespace dolfin;
 
13
 
 
14
//------------------------------------------------------------------------------
 
15
void LocalAssembler::assemble(arma::mat& A,
 
16
                              UFC& ufc,
 
17
                              const Cell& cell,
 
18
                              const MeshFunction<uint>* cell_domains,
 
19
                              const MeshFunction<uint>* exterior_facet_domains,
 
20
                              const MeshFunction<uint>* interior_facet_domains)
 
21
{
 
22
  // Clear tensor
 
23
  A.zeros();
 
24
 
 
25
  // Assemble contributions from cell integral
 
26
  assemble_cell(A, ufc, cell, cell_domains);
 
27
 
 
28
  // Assemble contributions from facet integrals
 
29
  for (FacetIterator facet(cell); !facet.end(); ++facet)
 
30
  {
 
31
    if (facet->num_entities(cell.dim()) == 2)
 
32
      assemble_interior_facet(A, ufc, cell, *facet,
 
33
                              facet.pos(), interior_facet_domains);
 
34
    else
 
35
      assemble_exterior_facet(A, ufc, cell, *facet,
 
36
                              facet.pos(), exterior_facet_domains);
 
37
  }
 
38
}
 
39
//------------------------------------------------------------------------------
 
40
void LocalAssembler::assemble_cell(arma::mat& A,
 
41
                                   UFC& ufc,
 
42
                                   const Cell& cell,
 
43
                                   const MeshFunction<uint>* domains)
 
44
{
 
45
  // Skip if there are no cell integrals
 
46
  if (ufc.form.num_cell_domains() == 0)
 
47
    return;
 
48
 
 
49
  // Extract default cell integral
 
50
  ufc::cell_integral* integral = ufc.cell_integrals[0].get();
 
51
 
 
52
  // Get integral for sub domain (if any)
 
53
  if (domains && domains->size() > 0)
 
54
  {
 
55
    const uint domain = (*domains)[cell];
 
56
    if (domain < ufc.form.num_cell_domains())
 
57
      integral = ufc.cell_integrals[domain].get();
 
58
    else
 
59
      return;
 
60
  }
 
61
 
 
62
  // Skip integral if zero
 
63
  if (!integral)
 
64
    return;
 
65
 
 
66
  // Update to current cell
 
67
  ufc.update(cell);
 
68
 
 
69
  // Tabulate cell tensor
 
70
  integral->tabulate_tensor(ufc.A.get(), ufc.w, ufc.cell);
 
71
 
 
72
  // Stuff a_ufc.A into A
 
73
  const uint M = A.n_rows;
 
74
  const uint N = A.n_cols;
 
75
  for (uint i=0; i < M; i++)
 
76
    for (uint j=0; j < N; j++)
 
77
      A(i, j) += ufc.A[N*i + j];
 
78
 
 
79
}
 
80
//------------------------------------------------------------------------------
 
81
void LocalAssembler::assemble_exterior_facet(arma::mat& A,
 
82
                                             UFC& ufc,
 
83
                                             const Cell& cell,
 
84
                                             const Facet& facet,
 
85
                                             const uint local_facet,
 
86
                                             const MeshFunction<uint>* domains)
 
87
{
 
88
  // Skip if there are no exterior facet integrals
 
89
  if (ufc.form.num_exterior_facet_domains() == 0)
 
90
    return;
 
91
 
 
92
  // Extract default exterior facet integral
 
93
  ufc::exterior_facet_integral* integral = ufc.exterior_facet_integrals[0].get();
 
94
 
 
95
  // Get integral for sub domain (if any)
 
96
  if (domains && domains->size() > 0)
 
97
  {
 
98
    const uint domain = (*domains)[facet];
 
99
    if (domain < ufc.form.num_exterior_facet_domains())
 
100
      integral = ufc.exterior_facet_integrals[domain].get();
 
101
    else
 
102
      return;
 
103
  }
 
104
 
 
105
  // Skip integral if zero
 
106
  if (!integral)
 
107
    return;
 
108
 
 
109
  // Update to current cell
 
110
  ufc.update(cell, local_facet);
 
111
 
 
112
  // Tabulate exterior facet tensor
 
113
  integral->tabulate_tensor(ufc.A.get(), ufc.w, ufc.cell, local_facet);
 
114
 
 
115
  // Stuff a_ufc.A into A
 
116
  const uint M = A.n_rows;
 
117
  const uint N = A.n_cols;
 
118
  for (uint i=0; i < M; i++)
 
119
  {
 
120
    for (uint j=0; j < N; j++)
 
121
      A(i, j) += ufc.A[N*i + j];
 
122
  }
 
123
}
 
124
//------------------------------------------------------------------------------
 
125
void LocalAssembler::assemble_interior_facet(arma::mat& A,
 
126
                                             UFC& ufc,
 
127
                                             const Cell& cell,
 
128
                                             const Facet& facet,
 
129
                                             const uint local_facet,
 
130
                                             const MeshFunction<uint>* domains)
 
131
{
 
132
  // Skip if there are no interior facet integrals
 
133
  if (ufc.form.num_interior_facet_domains() == 0)
 
134
    return;
 
135
 
 
136
  // Extract default interior facet integral
 
137
  ufc::interior_facet_integral* integral = ufc.interior_facet_integrals[0].get();
 
138
 
 
139
  // Get integral for sub domain (if any)
 
140
  if (domains && domains->size() > 0)
 
141
  {
 
142
    const uint domain = (*domains)[facet];
 
143
    if (domain < ufc.form.num_interior_facet_domains())
 
144
      integral = ufc.interior_facet_integrals[domain].get();
 
145
    else
 
146
      return;
 
147
  }
 
148
 
 
149
  // Skip integral if zero
 
150
  if (!integral)
 
151
    return;
 
152
 
 
153
  // Update to current pair of cells and facets
 
154
  ufc.update(cell, local_facet, cell, local_facet);
 
155
 
 
156
  // Tabulate interior facet tensor on macro element
 
157
  integral->tabulate_tensor(ufc.macro_A.get(), ufc.macro_w,
 
158
                            ufc.cell0, ufc.cell1,
 
159
                            local_facet, local_facet);
 
160
 
 
161
  // Stuff upper left quadrant (corresponding to this cell) into A
 
162
  const uint M = A.n_rows;
 
163
  const uint N = A.n_cols;
 
164
  for (uint i=0; i < M; i++)
 
165
    for (uint j=0; j < N; j++)
 
166
      A(i, j) += ufc.macro_A[2*N*i + j]; // FIXME: row/col swap for vectors!
 
167
}
 
168
//------------------------------------------------------------------------------