~ubuntu-branches/ubuntu/wily/dolfin/wily-proposed

« back to all changes in this revision

Viewing changes to dolfin/la/Vector.h

  • Committer: Package Import Robot
  • Author(s): Johannes Ring
  • Date: 2014-09-22 14:35:34 UTC
  • mfrom: (1.1.17) (19.1.23 sid)
  • Revision ID: package-import@ubuntu.com-20140922143534-0yi89jyuqbgdxwm9
Tags: 1.4.0+dfsg-4
* debian/control: Disable libcgal-dev on i386, mipsel and sparc.
* debian/rules: Remove bad directives in pkg-config file dolfin.pc
  (closes: #760658).
* Remove debian/libdolfin-dev.lintian-overrides.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
#include <string>
30
30
#include <utility>
31
 
#include <boost/shared_ptr.hpp>
 
31
#include <memory>
32
32
#include <dolfin/common/types.h>
33
33
#include "DefaultFactory.h"
34
34
#include "GenericVector.h"
53
53
    }
54
54
 
55
55
    /// Create vector of size N
56
 
    explicit Vector(std::size_t N)
 
56
    Vector(MPI_Comm comm, std::size_t N)
57
57
    {
58
58
      DefaultFactory factory;
59
59
      vector = factory.create_vector();
60
 
      vector->resize(N);
 
60
      vector->init(comm, N);
61
61
    }
62
62
 
63
63
    /// Copy constructor
69
69
    //--- Implementation of the GenericTensor interface ---
70
70
 
71
71
    /// Return copy of vector
72
 
    virtual boost::shared_ptr<GenericVector> copy() const
 
72
    virtual std::shared_ptr<GenericVector> copy() const
73
73
    {
74
 
      boost::shared_ptr<Vector> x(new Vector(*this));
 
74
      std::shared_ptr<Vector> x(new Vector(*this));
75
75
      return x;
76
76
    }
77
77
 
83
83
    virtual void apply(std::string mode)
84
84
    { vector->apply(mode); }
85
85
 
 
86
    /// Return MPI communicator
 
87
    virtual MPI_Comm mpi_comm() const
 
88
    { return vector->mpi_comm(); }
 
89
 
86
90
    /// Return informal string representation (pretty-print)
87
91
    virtual std::string str(bool verbose) const
88
92
    { return "<Vector wrapper of " + vector->str(verbose) + ">"; }
89
93
 
90
94
    //--- Implementation of the GenericVector interface ---
91
95
 
92
 
    /// Resize vector to size N
93
 
    virtual void resize(std::size_t N)
94
 
    { vector->resize(N); }
95
 
 
96
 
    /// Resize vector with given ownership range
97
 
    virtual void resize(std::pair<std::size_t, std::size_t> range)
98
 
    { vector->resize(range); }
99
 
 
100
 
    /// Resize vector with given ownership range and with ghost values
101
 
    virtual void resize(std::pair<std::size_t, std::size_t> range,
102
 
                        const std::vector<la_index>& ghost_indices)
103
 
    { vector->resize(range, ghost_indices); }
 
96
    /// Initialize vector to size N
 
97
    virtual void init(MPI_Comm comm, std::size_t N)
 
98
    { vector->init(comm, N); }
 
99
 
 
100
    /// Initlialize vector with given ownership range
 
101
    virtual void init(MPI_Comm comm, std::pair<std::size_t, std::size_t> range)
 
102
    { vector->init(comm, range); }
 
103
 
 
104
    /// Initialize vector with given ownership range and with ghost
 
105
    /// values
 
106
    virtual void init(MPI_Comm comm,
 
107
                      std::pair<std::size_t, std::size_t> range,
 
108
                      const std::vector<la_index>& ghost_indices)
 
109
    { vector->init(comm, range, ghost_indices); }
 
110
 
 
111
    // Bring init function from GenericVector into scope
 
112
    using GenericVector::init;
104
113
 
105
114
    /// Return true if vector is empty
106
115
    virtual bool empty() const
238
247
    virtual double* data()
239
248
    { return vector->data(); }
240
249
 
241
 
    /// Update ghost values
242
 
    virtual void update_ghost_values()
243
 
    {
244
 
      vector->update_ghost_values();
245
 
    }
246
250
    //--- Special functions ---
247
251
 
248
252
    /// Return linear algebra backend factory
259
263
    virtual GenericVector* instance()
260
264
    { return vector.get(); }
261
265
 
262
 
    virtual boost::shared_ptr<const LinearAlgebraObject> shared_instance() const
 
266
    virtual std::shared_ptr<const LinearAlgebraObject> shared_instance() const
263
267
    { return vector; }
264
268
 
265
 
    virtual boost::shared_ptr<LinearAlgebraObject> shared_instance()
 
269
    virtual std::shared_ptr<LinearAlgebraObject> shared_instance()
266
270
    { return vector; }
267
271
 
268
272
    //--- Special Vector functions ---
274
278
  private:
275
279
 
276
280
    // Pointer to concrete implementation
277
 
    boost::shared_ptr<GenericVector> vector;
 
281
    std::shared_ptr<GenericVector> vector;
278
282
 
279
283
  };
280
284