~chaffra/+junk/trilinos

« back to all changes in this revision

Viewing changes to packages/Sundance/src-solvers/Operators/TSFLoadableBlockOperatorImpl.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme, Christophe Prud'homme, Johannes Ring
  • Date: 2009-12-13 12:53:22 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20091213125322-in0nrdjc55deqsw9
Tags: 10.0.3.dfsg-1
[Christophe Prud'homme]
* New upstream release

[Johannes Ring]
* debian/patches/libname.patch: Add prefix 'libtrilinos_' to all
  libraries. 
* debian/patches/soname.patch: Add soversion to libraries.
* debian/watch: Update download URL.
* debian/control:
  - Remove python-numeric from Build-Depends (virtual package).
  - Remove automake and autotools from Build-Depends and add cmake to
    reflect switch to CMake.
  - Add python-support to Build-Depends.
* debian/rules: 
  - Cleanup and updates for switch to CMake.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* @HEADER@ */
 
2
/* ***********************************************************************
 
3
// 
 
4
//           TSFExtended: Trilinos Solver Framework Extended
 
5
//                 Copyright (2004) Sandia Corporation
 
6
// 
 
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
 
8
// license for use of this work by or on behalf of the U.S. Government.
 
9
// 
 
10
// This library is free software; you can redistribute it and/or modify
 
11
// it under the terms of the GNU Lesser General Public License as
 
12
// published by the Free Software Foundation; either version 2.1 of the
 
13
// License, or (at your option) any later version.
 
14
//  
 
15
// This library is distributed in the hope that it will be useful, but
 
16
// WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
18
// Lesser General Public License for more details.
 
19
//  
 
20
// You should have received a copy of the GNU Lesser General Public
 
21
// License along with this library; if not, write to the Free Software
 
22
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 
23
// USA
 
24
// Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
 
25
// 
 
26
// **********************************************************************/
 
27
 /* @HEADER@ */
 
28
 
 
29
#ifndef TSFLOADABLEBLOCKOPERATOR_IMPL_HPP
 
30
#define TSFLOADABLEBLOCKOPERATOR_IMPL_HPP
 
31
 
 
32
#include "SundanceDefs.hpp"
 
33
#include "TSFLoadableBlockOperatorDecl.hpp"
 
34
 
 
35
#ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
 
36
#include "TSFSimpleBlockOpImpl.hpp"
 
37
#endif
 
38
 
 
39
 
 
40
 
 
41
namespace TSFExtended
 
42
{
 
43
using namespace Teuchos;
 
44
 
 
45
template <class Scalar> inline
 
46
LoadableBlockOperator<Scalar>:: LoadableBlockOperator(
 
47
  const VectorSpace<Scalar>& domain,
 
48
  int lowestLocalCol,
 
49
  const RefCountPtr<Array<int> >& isBCCol,
 
50
  const RefCountPtr<std::set<int> >& remoteBCCols,
 
51
  const VectorSpace<Scalar>& range,
 
52
  int lowestLocalRow,
 
53
  const RefCountPtr<Array<int> >& isBCRow)
 
54
  : SimpleBlockOp<Scalar>(domain, range),
 
55
    isBCCol_(isBCCol),
 
56
    isBCRow_(isBCRow),
 
57
    remoteBCCols_(remoteBCCols),
 
58
    lowestLocalRow_(lowestLocalRow),
 
59
    lowestLocalCol_(lowestLocalCol),
 
60
    highestLocalRow_(lowestLocalRow + range.numLocalElements()),
 
61
    highestLocalCol_(lowestLocalCol + domain.numLocalElements())
 
62
{
 
63
}
 
64
      
 
65
template <class Scalar> inline
 
66
void LoadableBlockOperator<Scalar>::addToRow(int globalRowIndex,
 
67
  int nElemsToInsert,
 
68
  const int* globalColumnIndices,
 
69
  const Scalar* elementValues) 
 
70
{
 
71
  if (globalRowIndex < lowestLocalRow_ || globalRowIndex >= highestLocalRow_) return;
 
72
  Array<int> bcCols;
 
73
  Array<int> intCols;
 
74
  Array<Scalar> bcVals;
 
75
  Array<Scalar> intVals;
 
76
  bcCols.reserve(nElemsToInsert);
 
77
  intCols.reserve(nElemsToInsert);
 
78
  bcVals.reserve(nElemsToInsert);
 
79
  intVals.reserve(nElemsToInsert);
 
80
        
 
81
  const Array<int>& isBCCol = *isBCCol_;
 
82
        
 
83
  for (int i=0; i<nElemsToInsert; i++)
 
84
  {
 
85
    int g = globalColumnIndices[i];
 
86
    if (g < lowestLocalCol_ || g >= highestLocalCol_)
 
87
    {
 
88
      if (remoteBCCols_->find(g) != remoteBCCols_->end()) bcCols.append(g);
 
89
      else intCols.append(g);
 
90
    }
 
91
    else
 
92
    {
 
93
      int localCol = g - lowestLocalCol_;
 
94
      if (isBCCol[localCol]) 
 
95
      {
 
96
        bcCols.append(g);
 
97
        bcVals.append(elementValues[i]);
 
98
      }
 
99
      else 
 
100
      {
 
101
        intCols.append(g);
 
102
        intVals.append(elementValues[i]);
 
103
      }
 
104
    }
 
105
  }
 
106
        
 
107
  if ((*isBCRow_)[globalRowIndex - lowestLocalRow_])
 
108
  {
 
109
    if (intCols.size() > 0U) /* do (BC, internal) block */
 
110
    {
 
111
      TEST_FOR_EXCEPTION(true, std::logic_error,
 
112
        "There should be no entries in the (BC, internal) block");
 
113
    }
 
114
    if (bcCols.size() > 0U) /* do (BC, BC) block */
 
115
    {
 
116
      loadableBlock(1,1)->addToRow(globalRowIndex, bcCols.size(), 
 
117
        &(bcCols[0]), &(bcVals[0]));
 
118
    }
 
119
  }
 
120
  else
 
121
  {
 
122
    if (intCols.size() > 0U) /* do (internal, internal) block */
 
123
    {
 
124
      loadableBlock(0,0)->addToRow(globalRowIndex, intCols.size(), 
 
125
        &(intCols[0]), &(intVals[0]));
 
126
    }
 
127
    if (bcCols.size() > 0U) /* do (internal, BC) block */
 
128
    {
 
129
      loadableBlock(0,1)->addToRow(globalRowIndex, bcCols.size(), 
 
130
        &(bcCols[0]), &(bcVals[0]));
 
131
    }
 
132
  }
 
133
}
 
134
 
 
135
 
 
136
template <class Scalar> inline
 
137
void  LoadableBlockOperator<Scalar>::zero() 
 
138
{
 
139
  for (int i=0; i<this->numBlockRows(); i++)
 
140
  {
 
141
    for (int j=0; j<this->numBlockCols(); j++)
 
142
    {
 
143
      if (i==1 && j==0) continue;
 
144
      this->loadableBlock(i,j)->zero();
 
145
    }
 
146
  }
 
147
}
 
148
 
 
149
    
 
150
 
 
151
template <class Scalar> inline
 
152
RCP<LoadableMatrix<Scalar> > 
 
153
LoadableBlockOperator<Scalar>::loadableBlock(int i, int j)
 
154
{
 
155
  return this->getNonconstBlock(i,j).matrix();
 
156
}
 
157
 
 
158
 
 
159
}
 
160
 
 
161
#endif