This file is indexed.

/usr/include/deal.II/lac/trilinos_block_vector.h is in libdeal.ii-dev 6.3.1-1.1.

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
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
//---------------------------------------------------------------------------
//    $Id: trilinos_block_vector.h 20934 2010-04-02 13:09:20Z bangerth $
//    Version: $Name$
//
//    Copyright (C) 2008, 2009, 2010 by the deal.II authors
//
//    This file is subject to QPL and may not be  distributed
//    without copyright and license information. Please refer
//    to the file deal.II/doc/license.html for the  text  and
//    further information on this license.
//
//---------------------------------------------------------------------------
#ifndef __deal2__trilinos_block_vector_h
#define __deal2__trilinos_block_vector_h


#include <base/config.h>

#ifdef DEAL_II_USE_TRILINOS

#  include <lac/trilinos_vector.h>
#  include <lac/block_indices.h>
#  include <lac/block_vector_base.h>
#  include <lac/exceptions.h>

DEAL_II_NAMESPACE_OPEN

                                   // forward declaration
template <typename Number> class BlockVector;

/*! @addtogroup TrilinosWrappers
 *@{
 */

namespace TrilinosWrappers
{
                                   // forward declaration
  namespace MPI
  {
    class BlockVector;
  }
  class BlockVector;
  class BlockSparseMatrix;


  namespace MPI
  {
/**
 * An implementation of block vectors based on the vector class
 * implemented in TrilinosWrappers. While the base class provides for
 * most of the interface, this class handles the actual allocation of
 * vectors and provides functions that are specific to the underlying
 * vector type.
 *
 * The model of distribution of data is such that each of the blocks
 * is distributed across all MPI processes named in the MPI
 * communicator. I.e. we don't just distribute the whole vector, but
 * each component. In the constructors and reinit() functions, one
 * therefore not only has to specify the sizes of the individual
 * blocks, but also the number of elements of each of these blocks to
 * be stored on the local process.
 *
 * @ingroup Vectors
 * @ingroup TrilinosWrappers
 * @see @ref GlossBlockLA "Block (linear algebra)"
 * @author Martin Kronbichler, Wolfgang Bangerth, 2008, 2009
 */
    class BlockVector : public BlockVectorBase<Vector>
    {
      public:
                                       /**
					* Typedef the base class for simpler
					* access to its own typedefs.
					*/
        typedef BlockVectorBase<Vector> BaseClass;

                                       /**
					* Typedef the type of the underlying
					* vector.
					*/
        typedef BaseClass::BlockType  BlockType;

                                       /**
					* Import the typedefs from the base
					* class.
					*/
        typedef BaseClass::value_type      value_type;
        typedef BaseClass::pointer         pointer;
        typedef BaseClass::const_pointer   const_pointer;
        typedef BaseClass::reference       reference;
        typedef BaseClass::const_reference const_reference;
        typedef BaseClass::size_type       size_type;
        typedef BaseClass::iterator        iterator;
        typedef BaseClass::const_iterator  const_iterator;

                                       /**
					* Default constructor. Generate an
					* empty vector without any blocks.
					*/
        BlockVector ();

                                       /**
					* Constructor. Generate a block
					* vector with as many blocks as
					* there are entries in @p
					* partitioning. Each Epetra_Map
					* contains the layout of the
					* distribution of data among the MPI
					* processes.
					*/
        BlockVector (const std::vector<Epetra_Map> &parallel_partitioning);

                                       /**
					* Constructor. Generate a block
					* vector with as many blocks as
					* there are entries in
					* @p partitioning.  Each IndexSet
					* together with the MPI communicator
					* contains the layout of the
					* distribution of data among the MPI
					* processes.
					*/
        BlockVector (const std::vector<IndexSet> &parallel_partitioning,
		     const MPI_Comm              &communicator = MPI_COMM_WORLD);

                                       /**
					* Copy-Constructor. Set all the
					* properties of the parallel vector
					* to those of the given argument and
					* copy the elements.
					*/
        BlockVector (const BlockVector  &V);

                                       /**
					* Creates a block vector
					* consisting of
					* <tt>num_blocks</tt>
					* components, but there is no
					* content in the individual
					* components and the user has to
					* fill appropriate data using a
					* reinit of the blocks.
					*/
        BlockVector (const unsigned int num_blocks);

                                       /**
					* Destructor. Clears memory
					*/
        ~BlockVector ();

                                       /**
					* Copy operator: fill all
					* components of the vector that
					* are locally stored with the
					* given scalar value.
					*/
        BlockVector &
	  operator = (const value_type s);

                                       /**
					* Copy operator for arguments of
					* the same type.
					*/
        BlockVector &
	  operator = (const BlockVector &V);

                                       /**
					* Copy operator for arguments of
					* the localized Trilinos vector
					* type.
					*/
        BlockVector &
	  operator = (const ::dealii::TrilinosWrappers::BlockVector &V);

                                       /**
					* Another copy function. This
					* one takes a deal.II block
					* vector and copies it into a
					* TrilinosWrappers block
					* vector. Note that the number
					* of blocks has to be the same
					* in the vector as in the input
					* vector. Use the reinit()
					* command for resizing the
					* BlockVector or for changing
					* the internal structure of the
					* block components.
					*
					* Since Trilinos only works on
					* doubles, this function is
					* limited to accept only one
					* possible number type in the
					* deal.II vector.
					*/
        template <typename Number>
	BlockVector &
	  operator = (const ::dealii::BlockVector<Number> &V);

                                         /**
                                          * Reinitialize the BlockVector to
                                          * contain as many blocks as there
					  * are Epetra_Maps given in the input
					  * argument, according to the
					  * parallel distribution of the
					  * individual components described
					  * in the maps.
                                          *
                                          * If <tt>fast==false</tt>, the vector
                                          * is filled with zeros.
                                          */
        void reinit (const std::vector<Epetra_Map> &parallel_partitioning,
		     const bool                     fast = false);

                                         /**
                                          * Reinitialize the BlockVector to
                                          * contain as many blocks as there
					  * are index sets given in the input
					  * argument, according to the
					  * parallel distribution of the
					  * individual components described
					  * in the maps.
                                          *
                                          * If <tt>fast==false</tt>, the vector
                                          * is filled with zeros.
                                          */
        void reinit (const std::vector<IndexSet> &parallel_partitioning,
		     const MPI_Comm              &communicator = MPI_COMM_WORLD,
		     const bool                   fast = false);

                                         /**
                                          * Change the dimension to that
                                          * of the vector <tt>V</tt>. The same
                                          * applies as for the other
                                          * reinit() function.
                                          *
                                          * The elements of <tt>V</tt> are not
                                          * copied, i.e.  this function is
                                          * the same as calling <tt>reinit
                                          * (V.size(), fast)</tt>.
                                          *
                                          * Note that you must call this
                                          * (or the other reinit()
                                          * functions) function, rather
                                          * than calling the reinit()
                                          * functions of an individual
                                          * block, to allow the block
                                          * vector to update its caches of
                                          * vector sizes. If you call
                                          * reinit() on one of the
                                          * blocks, then subsequent
                                          * actions on this object may
                                          * yield unpredictable results
                                          * since they may be routed to
                                          * the wrong block.
                                          */
        void reinit (const BlockVector &V,
		     const bool fast = false);

                                         /**
                                          * Change the number of blocks to
					  * <tt>num_blocks</tt>. The individual
					  * blocks will get initialized with
					  * zero size, so it is assumed that
					  * the user resizes the
					  * individual blocks by herself
					  * in an appropriate way, and
					  * calls <tt>collect_sizes</tt>
					  * afterwards.
                                          */
        void reinit (const unsigned int num_blocks);

				         /**
					  * This reinit function is meant to
					  * be used for parallel
					  * calculations where some
					  * non-local data has to be
					  * used. The typical situation
					  * where one needs this function is
					  * the call of the
					  * FEValues<dim>::get_function_values
					  * function (or of some
					  * derivatives) in parallel. Since
					  * it is usually faster to retrieve
					  * the data in advance, this
					  * function can be called before
					  * the assembly forks out to the
					  * different processors. What this
					  * function does is the following:
					  * It takes the information in the
					  * columns of the given matrix and
					  * looks which data couples between
					  * the different processors. That
					  * data is then queried from the
					  * input vector. Note that you
					  * should not write to the
					  * resulting vector any more, since
					  * the some data can be stored
					  * several times on different
					  * processors, leading to
					  * unpredictable results. In
					  * particular, such a vector cannot
					  * be used for matrix-vector
					  * products as for example done
					  * during the solution of linear
					  * systems.
					  */
	void import_nonlocal_data_for_fe (const TrilinosWrappers::BlockSparseMatrix &m,
					  const BlockVector                         &v);

					 /**
					  * Compresses all the components
					  * after assembling together all
					  * elements.
					  */
	void compress ();

				         /**
					  * Returns the state of the
					  * vector, i.e., whether
					  * compress() needs to be
					  * called after an operation
					  * requiring data
					  * exchange. Does only return
					  * non-true values when used in
					  * <tt>debug</tt> mode, since
					  * it is quite expensive to
					  * keep track of all operations
					  * that lead to the need for
					  * compress().
					  */
	bool is_compressed () const;

                                         /**
                                          * Swap the contents of this
                                          * vector and the other vector
                                          * <tt>v</tt>. One could do this
                                          * operation with a temporary
                                          * variable and copying over the
                                          * data elements, but this
                                          * function is significantly more
                                          * efficient since it only swaps
                                          * the pointers to the data of
                                          * the two vectors and therefore
                                          * does not need to allocate
                                          * temporary storage and move
                                          * data around.
                                          *
                                          * Limitation: right now this
                                          * function only works if both
                                          * vectors have the same number
                                          * of blocks. If needed, the
                                          * numbers of blocks should be
                                          * exchanged, too.
                                          *
                                          * This function is analog to the
                                          * the swap() function of all C++
                                          * standard containers. Also,
                                          * there is a global function
                                          * swap(u,v) that simply calls
                                          * <tt>u.swap(v)</tt>, again in analogy
                                          * to standard functions.
                                          */
        void swap (BlockVector &v);

				     /**
				      * Print to a stream.
				      */
	void print (std::ostream       &out,
		    const unsigned int  precision = 3,
		    const bool          scientific = true,
		    const bool          across = true) const;

                                         /**
                                          * Exception
                                          */
        DeclException0 (ExcIteratorRangeDoesNotMatchVectorSize);

                                         /**
                                          * Exception
                                          */
        DeclException0 (ExcNonMatchingBlockVectors);
    };



/*----------------------- Inline functions ----------------------------------*/


    inline
    BlockVector::BlockVector ()
    {}



    inline
    BlockVector::BlockVector (const std::vector<Epetra_Map> &parallel_partitioning)
    {
      reinit (parallel_partitioning, false);
    }



    inline
    BlockVector::BlockVector (const std::vector<IndexSet> &parallel_partitioning,
			      const MPI_Comm              &communicator)
    {
      reinit (parallel_partitioning, communicator, false);
    }



    inline
    BlockVector::BlockVector (const unsigned int num_blocks)
    {
      reinit (num_blocks);
    }



    inline
    BlockVector::BlockVector (const BlockVector& v)
                    :
                    BlockVectorBase<Vector > ()
    {
      this->components.resize (v.n_blocks());
      this->block_indices = v.block_indices;

      for (unsigned int i=0; i<this->n_blocks(); ++i)
        this->components[i] = v.components[i];
    }



    inline
    bool
    BlockVector::is_compressed () const
    {
      bool compressed = true;
      for (unsigned int row=0; row<n_blocks(); ++row)
	if (block(row).is_compressed() == false)
	  {
	    compressed = false;
	    break;
	  }

      return compressed;
    }



    template <typename Number>
    BlockVector &
    BlockVector::operator = (const ::dealii::BlockVector<Number> &v)
    {
      if (n_blocks() != v.n_blocks())
	{
	  std::vector<unsigned int> block_sizes (v.n_blocks(), 0);
	  block_indices.reinit (block_sizes);
	  if (components.size() != n_blocks())
	    components.resize(n_blocks());
	}

      for (unsigned int i=0; i<this->n_blocks(); ++i)
	this->components[i] = v.block(i);

      collect_sizes();

      return *this;
    }


    inline
    void
    BlockVector::swap (BlockVector &v)
    {
      Assert (n_blocks() == v.n_blocks(),
	      ExcDimensionMismatch(n_blocks(),v.n_blocks()));

      for (unsigned int row=0; row<n_blocks(); ++row)
	block(row).swap (v.block(row));
    }



/**
 * Global function which overloads the default implementation
 * of the C++ standard library which uses a temporary object. The
 * function simply exchanges the data of the two vectors.
 *
 * @relates TrilinosWrappers::MPI::BlockVector
 * @author Martin Kronbichler, Wolfgang Bangerth, 2008
 */
    inline
    void swap (BlockVector &u,
               BlockVector &v)
    {
      u.swap (v);
    }

  } /* end of namespace MPI */




/**
 * An implementation of block vectors based on the vector class
 * implemented in TrilinosWrappers. While the base class provides for
 * most of the interface, this class handles the actual allocation of
 * vectors and provides functions that are specific to the underlying
 * vector type.
 *
 * In contrast to the class MPI::BlockVector, this class is based on a
 * localized version of the vectors, which means that the whole vector
 * is stored on each processor. Note that matrix vector products with
 * this block vector class do only work in case the program is run on
 * only one processor, since the Trilinos matrices are inherently
 * parallel.
 *
 * @ingroup Vectors
 * @ingroup TrilinosWrappers
 * @see @ref GlossBlockLA "Block (linear algebra)"
 * @author Martin Kronbichler, 2008
 */
  class BlockVector : public BlockVectorBase<Vector>
  {
    public:
                                       /**
					* Typedef the base class for simpler
					* access to its own typedefs.
					*/
      typedef BlockVectorBase<Vector> BaseClass;

                                       /**
					* Typedef the type of the underlying
					* vector.
					*/
      typedef BaseClass::BlockType  BlockType;

                                       /**
					* Import the typedefs from the base
					* class.
					*/
      typedef BaseClass::value_type      value_type;
      typedef BaseClass::pointer         pointer;
      typedef BaseClass::const_pointer   const_pointer;
      typedef BaseClass::reference       reference;
      typedef BaseClass::const_reference const_reference;
      typedef BaseClass::size_type       size_type;
      typedef BaseClass::iterator        iterator;
      typedef BaseClass::const_iterator  const_iterator;

                                       /**
					* Default constructor. Generate an
					* empty vector without any blocks.
					*/
      BlockVector ();

                                       /**
					* Constructor. Generate a block
					* vector with as many blocks as
					* there are entries in Input_Maps.
					* For this non-distributed vector,
					* the %parallel partitioning is not
					* used, just the global size of the
					* partitioner.
					*/
      BlockVector (const std::vector<Epetra_Map> &partitioner);

                                       /**
					* Constructor. Generate a block
					* vector with as many blocks as
					* there are entries in Input_Maps.
					* For this non-distributed vector,
					* the %parallel partitioning is not
					* used, just the global size of the
					* partitioner.
					*/
      BlockVector (const std::vector<IndexSet> &partitioner,
		   const MPI_Comm              &communicator = MPI_COMM_WORLD);

                                       /**
					* Copy-Constructor. Set all the
					* properties of the non-%parallel
					* vector to those of the given
					* %parallel vector and import the
					* elements.
					*/
      BlockVector (const MPI::BlockVector &V);

                                       /**
					* Copy-Constructor. Set all the
					* properties of the vector to those
					* of the given input vector and copy
					* the elements.
					*/
      BlockVector (const BlockVector  &V);

                                       /**
					* Creates a block vector
					* consisting of
					* <tt>num_blocks</tt>
					* components, but there is no
					* content in the individual
					* components and the user has to
					* fill appropriate data using a
					* reinit of the blocks.
					*/
      BlockVector (const unsigned int num_blocks);

                                       /**
					* Constructor. Set the number of
					* blocks to <tt>n.size()</tt> and
					* initialize each block with
					* <tt>n[i]</tt> zero elements.
					*
					* References BlockVector.reinit().
					*/
      BlockVector (const std::vector<unsigned int> &N);

                                       /**
                                        * Constructor. Set the number of
                                        * blocks to
                                        * <tt>n.size()</tt>. Initialize the
                                        * vector with the elements
                                        * pointed to by the range of
                                        * iterators given as second and
                                        * third argument. Apart from the
                                        * first argument, this
                                        * constructor is in complete
                                        * analogy to the respective
                                        * constructor of the
                                        * <tt>std::vector</tt> class, but the
                                        * first argument is needed in
                                        * order to know how to subdivide
                                        * the block vector into
                                        * different blocks.
                                        */
      template <typename InputIterator>
      BlockVector (const std::vector<unsigned int> &n,
                   const InputIterator              first,
                   const InputIterator              end);

                                       /**
					* Destructor. Clears memory
					*/
      ~BlockVector ();

                                       /**
					* Copy operator: fill all
					* components of the vector that
					* are locally stored with the
					* given scalar value.
					*/
      BlockVector &
        operator = (const value_type s);

                                       /**
					* Copy operator for a
					* distributed Trilinos vector to
					* a localized one.
					*/
      BlockVector &
	operator = (const MPI::BlockVector &V);

                                       /**
					* Copy operator for arguments of
					* the same type.
					*/
      BlockVector &
	operator = (const BlockVector &V);

                                       /**
					* Another copy function. This
					* one takes a deal.II block
					* vector and copies it into a
					* TrilinosWrappers block
					* vector. Note that the number
					* of blocks has to be the same
					* in the vector as in the input
					* vector. Use the reinit()
					* command for resizing the
					* BlockVector or for changing
					* the internal structure of the
					* block components.
					*
					* Since Trilinos only works on
					* doubles, this function is
					* limited to accept only one
					* possible number type in the
					* deal.II vector.
					*/
      template <typename Number>
      BlockVector &
	operator = (const ::dealii::BlockVector<Number> &V);

                                         /**
                                          * Reinitialize the BlockVector to
                                          * contain as many blocks as there
                                          * are Epetra_Maps given in the
                                          * input argument, according to the
                                          * global size of the individual
                                          * components described in the
                                          * maps. Note that the resulting
                                          * vector will be stored completely
                                          * on each process. The Epetra_Map
                                          * is useful when data exchange
                                          * with a distributed vector based
                                          * on the same Epetra_map is
                                          * intended. In that case, the same
                                          * communicator is used for data
                                          * exchange.
                                          *
                                          * If <tt>fast==false</tt>, the vector
                                          * is filled with zeros.
                                          */
      void reinit (const std::vector<Epetra_Map> &partitioning,
		   const bool                     fast = false);

                                         /**
                                          * Reinitialize the BlockVector to
                                          * contain as many blocks as there
                                          * are index sets given in the
                                          * input argument, according to the
                                          * global size of the individual
                                          * components described in the
                                          * index set, and using a given MPI
                                          * communicator. The MPI
                                          * communicator is useful when data
                                          * exchange with a distributed
                                          * vector based on the same
                                          * initialization is intended. In
                                          * that case, the same communicator
                                          * is used for data exchange.
                                          *
                                          * If <tt>fast==false</tt>, the vector
                                          * is filled with zeros.
                                          */
      void reinit (const std::vector<IndexSet> &partitioning,
		   const MPI_Comm              &communicator = MPI_COMM_WORLD,
		   const bool                   fast = false);

                                         /**
                                          * Reinitialize the BlockVector to
                                          * contain as many blocks as there
                                          * are elements in the first
                                          * argument, and with the respective
                                          * sizes. Since no distribution map
                                          * is given, all vectors are local
                                          * vectors.
                                          *
                                          * If <tt>fast==false</tt>, the vector
                                          * is filled with zeros.
                                          */
      void reinit (const std::vector<unsigned int> &N,
		   const bool                       fast=false);

                                         /**
                                          * Reinit the function
                                          * according to a distributed
                                          * block vector. The elements
                                          * will be copied in this
                                          * process.
                                          */
      void reinit (const MPI::BlockVector &V);

                                         /**
                                          * Change the dimension to that
                                          * of the vector <tt>V</tt>. The same
                                          * applies as for the other
                                          * reinit() function.
                                          *
                                          * The elements of <tt>V</tt> are not
                                          * copied, i.e.  this function is
                                          * the same as calling <tt>reinit
                                          * (V.size(), fast)</tt>.
                                          *
                                          * Note that you must call this
                                          * (or the other reinit()
                                          * functions) function, rather
                                          * than calling the reinit()
                                          * functions of an individual
                                          * block, to allow the block
                                          * vector to update its caches of
                                          * vector sizes. If you call
                                          * reinit() on one of the
                                          * blocks, then subsequent
                                          * actions on this object may
                                          * yield unpredictable results
                                          * since they may be routed to
                                          * the wrong block.
                                          */
      void reinit (const BlockVector &V,
		   const bool fast = false);

                                         /**
                                          * Change the number of blocks to
					  * <tt>num_blocks</tt>. The individual
					  * blocks will get initialized with
					  * zero size, so it is assumed that
					  * the user resizes the
					  * individual blocks by herself
					  * in an appropriate way, and
					  * calls <tt>collect_sizes</tt>
					  * afterwards.
                                          */
      void reinit (const unsigned int num_blocks);

                                         /**
                                          * Swap the contents of this
                                          * vector and the other vector
                                          * <tt>v</tt>. One could do this
                                          * operation with a temporary
                                          * variable and copying over the
                                          * data elements, but this
                                          * function is significantly more
                                          * efficient since it only swaps
                                          * the pointers to the data of
                                          * the two vectors and therefore
                                          * does not need to allocate
                                          * temporary storage and move
                                          * data around.
                                          *
                                          * Limitation: right now this
                                          * function only works if both
                                          * vectors have the same number
                                          * of blocks. If needed, the
                                          * numbers of blocks should be
                                          * exchanged, too.
                                          *
                                          * This function is analog to the
                                          * the swap() function of all C++
                                          * standard containers. Also,
                                          * there is a global function
                                          * swap(u,v) that simply calls
                                          * <tt>u.swap(v)</tt>, again in analogy
                                          * to standard functions.
                                          */
      void swap (BlockVector &v);

				     /**
				      * Print to a stream.
				      */
      void print (std::ostream       &out,
		  const unsigned int  precision = 3,
		  const bool          scientific = true,
		  const bool          across = true) const;

                                         /**
                                          * Exception
                                          */
      DeclException0 (ExcIteratorRangeDoesNotMatchVectorSize);

                                         /**
                                          * Exception
                                          */
      DeclException0 (ExcNonMatchingBlockVectors);

                                       /**
					* Exception
					*/
      DeclException2 (ExcNonLocalizedMap,
      		      int, int,
      		      << "For the generation of a localized vector the map has "
		      << "to assign all elements to all vectors! "
		      << "local_size = global_size is a necessary condition, but"
		      << arg1 << " != " << arg2 << " was given!");

  };



/*----------------------- Inline functions ----------------------------------*/



  inline
  BlockVector::BlockVector ()
  {}



  inline
  BlockVector::BlockVector (const std::vector<Epetra_Map> &partitioning)
  {
    reinit (partitioning);
  }



  inline
  BlockVector::BlockVector (const std::vector<IndexSet> &partitioning,
			    const MPI_Comm              &communicator)
  {
    reinit (partitioning, communicator);
  }



  inline
  BlockVector::BlockVector (const std::vector<unsigned int> &N)
  {
    reinit (N);
  }



  template <typename InputIterator>
  BlockVector::BlockVector (const std::vector<unsigned int> &n,
                            const InputIterator              first,
                            const InputIterator              end)
  {
                                     // first set sizes of blocks, but
                                     // don't initialize them as we will
                                     // copy elements soon
    reinit (n, true);
    InputIterator start = first;
    for (unsigned int b=0; b<n.size(); ++b)
      {
        InputIterator end = start;
        std::advance (end, static_cast<signed int>(n[b]));

	for (unsigned int i=0; i<n[b]; ++i, ++start)
	  this->block(b)(i) = *start;
      }
    Assert (start == end, ExcIteratorRangeDoesNotMatchVectorSize());
  }



  inline
  BlockVector::BlockVector (const unsigned int num_blocks)
  {
    reinit (num_blocks);
  }



  inline
  BlockVector::~BlockVector()
  {}



  inline
  BlockVector::BlockVector (const MPI::BlockVector &v)
  {
    reinit (v);
  }



  inline
  BlockVector::BlockVector (const BlockVector& v)
                    :
                    BlockVectorBase<Vector > ()
  {
    this->components.resize (v.n_blocks());
    this->block_indices = v.block_indices;

    for (unsigned int i=0; i<this->n_blocks(); ++i)
      this->components[i] = v.components[i];
  }


  inline
  void
  BlockVector::swap (BlockVector &v)
  {
    Assert (n_blocks() == v.n_blocks(),
	    ExcDimensionMismatch(n_blocks(),v.n_blocks()));

    for (unsigned int row=0; row<n_blocks(); ++row)
      block(row).swap (v.block(row));
  }


  template <typename Number>
  BlockVector &
  BlockVector::operator = (const ::dealii::BlockVector<Number> &v)
  {
    if (n_blocks() != v.n_blocks())
      {
	std::vector<unsigned int> block_sizes (v.n_blocks(), 0);
	block_indices.reinit (block_sizes);
	if (components.size() != n_blocks())
	  components.resize(n_blocks());
      }

    for (unsigned int i=0; i<this->n_blocks(); ++i)
      this->components[i] = v.block(i);

    collect_sizes();

    return *this;
  }


/**
 * Global function which overloads the default implementation
 * of the C++ standard library which uses a temporary object. The
 * function simply exchanges the data of the two vectors.
 *
 * @relates TrilinosWrappers::BlockVector
 * @author Martin Kronbichler, 2008
 */
  inline
  void swap (BlockVector &u,
	     BlockVector &v)
  {
    u.swap (v);
  }

}

/*@}*/

DEAL_II_NAMESPACE_CLOSE

#endif  // DEAL_II_USE_TRILINOS

#endif