LifeV
VectorEpetra.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but 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 License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief VectorEpetra
30 
31  @author Gilles Fourestey <gilles.fourestey@epfl.ch>
32  @author Simone Deparis <simone.deparis@epfl.ch>
33  @author Cristiano Malossi <cristiano.malossi@epfl.ch>
34  @contributor Gwenol Grandperrin <gwenol.grandperrin@epfl.ch>
35  @maintainer Gwenol Grandperrin <gwenol.grandperrin@epfl.ch>
36 
37  @date 04-10-2006
38  */
39 
40 #ifndef _EPETRAVECTOR_HPP_
41 #define _EPETRAVECTOR_HPP_
42 
43 
44 #include <Epetra_FEVector.h>
45 #include <Epetra_Export.h>
46 
47 
48 #include <lifev/core/LifeV.hpp>
49 #include <lifev/core/array/MapEpetra.hpp>
50 
51 namespace LifeV
52 {
53 
54 //! VectorEpetra - The Epetra Vector format Wrapper
55 /*!
56  @author Gilles Fourestey, Simone Deparis, Cristiano Malossi
57 
58  The VectorEpetra class provides a general interface for the Epetra_Vector of Trilinos.
59 
60  Visit http://trilinos.sandia.gov for more informations about Epetra_Vector.
61  */
63 {
64 public:
65 
66  //! @name Public Types
67  //@{
68 
71  typedef Real data_type;
73 
74  //@}
75 
76 
77  //! @name Constructors & Destructor
78  //@{
79 
80  //! Empty Constructor
81  /*!
82  @param mapType Specify whether the map is Unique or Repeated
83  */
84  explicit VectorEpetra ( const MapEpetraType& mapType = Unique, const combineMode_Type combineMode = Add );
85 
86  //! Constructor - Using Maps
87  /*!
88  This constructor uses maps to build the vector
89  @param map Map to be used to split the vector between the processors
90  @param mapType Specify wether the map is Unique or Repeated
91  */
92  explicit VectorEpetra ( const MapEpetra& map,
93  const MapEpetraType& mapType = Unique,
94  const combineMode_Type combineMode = Add );
95 
96  //! Constructor - Using Maps
97  /*!
98  This constructor uses maps to build the vector
99  @param mapPtr Pointer to the map which has to be used to split the vector between the processors
100  @param mapType Specify wether the map is Unique or Repeated
101  */
102  explicit VectorEpetra ( const std::shared_ptr< MapEpetra >& mapPtr,
103  const MapEpetraType& mapType = Unique,
104  const combineMode_Type combineMode = Add );
105 
106  //! Copy constructor
107  /*!
108  @param vector Vector to be used to create the new vector
109  */
110  VectorEpetra ( const VectorEpetra& vector );
111 
112  //! Copy constructor
113  /*!
114  @param vector Vector to be used to create the new vector
115  @param mapType Specify whether the map is Unique or Repeated
116  */
117  VectorEpetra ( const VectorEpetra& vector, const MapEpetraType& mapType );
118 
119  //! Copy constructor
120  /*!
121  @param vector Vector to be used to create the new vector
122  @param mapType Specify wether the map is Unique or Repeated
123  @param combineMode Parameter used during the copy, and not in subsequent calls.
124  */
125  VectorEpetra ( const VectorEpetra& vector,
126  const MapEpetraType& mapType,
127  const combineMode_Type& combineMode );
128 
129  //! Copy constructor
130  /*!
131  Copies vector to FEvector that comes as Multivector
132  @param vector Vector to be used to create the new vector
133  @param map Map to be used to split the vector between the processors
134  @param mapType Specify wether the map is Unique or Repeated
135  */
136  VectorEpetra ( const Epetra_MultiVector& vector,
137  const std::shared_ptr< MapEpetra > map,
138  const MapEpetraType& mapType,
139  const combineMode_Type combineMode = Add );
140 
141  //! Copy constructor
142  /*!
143  Copies vector to a vector which resides only on the processor "reduceToProc".
144  @param vector Vector to be used to create the new vector
145  @param map Map to be used to split the vector between the processors
146  @param mapType Specify wether the map is Unique or Repeated
147  */
148  VectorEpetra ( const VectorEpetra& vector, const Int& reduceToProc );
149 
150  //! Destructor
151  virtual ~VectorEpetra() {}
152 
153  //@}
154 
155 
156  //! @name Operators
157  //@{
158  //! Access operators
159  /*!
160  @param row Index of the entry to be accessed
161  */
162  data_type& operator[] ( const UInt row );
163 
164  //! Access operators
165  /*!
166  @param row Index of the entry to be accessed
167  */
168  const data_type& operator[] ( const UInt row ) const;
169 
170  //! Access operators
171  /*!
172  @param row Index of the entry to be accessed
173  */
174  data_type& operator() ( const UInt row );
175 
176  //! Access operators
177  /*!
178  @param row Index of the entry to be accessed
179  */
180  const data_type& operator() ( const UInt row ) const;
181 
182  //! Affectation operator
183  /*!
184  Copies the value of the given vector inside the vector.
185  If the map is not the same, try to import the values.
186  Calls Import with Add.
187  @param vector Vector to be affected to the current vector
188  */
189  VectorEpetra& operator= ( const VectorEpetra& vector );
190 
191  //! Affectation operator
192  /*!
193  Copies the value of the given vector inside the vector.
194  If the map is not the same, try to import the values.
195  Calls Import with Add.
196  @param vector Vector to be affected to the current vector
197  */
198  VectorEpetra& operator= ( const Epetra_MultiVector& vector );
199 
200  //! Affectation operator
201  /*!
202  Put the given scalar in each component of the vector
203  @param scalar Scalar to be used to fill the current vector
204  */
205  VectorEpetra& operator= ( data_type scalar );
206 
207  //! Addition operator
208  /*!
209  Element by Element addition (if the map is not the same, try to import values)
210  @param vector Vector to be added to the current vector
211  */
212  VectorEpetra& operator+= ( const VectorEpetra& vector );
213 
214  //! Subtraction operator
215  /*!
216  Element by Element subtraction (if the map is not the same, try to import values)
217  @param vector Vector to be subtracted to the current vector
218  */
219  VectorEpetra& operator-= ( const VectorEpetra& vector );
220 
221  //! Multiplication operator
222  /*!
223  Element by Element multiplication (if the map is not the same, try to import values)
224  @param vector Vector to be perform the multiplication
225  */
226  VectorEpetra& operator*= ( const VectorEpetra& vector );
227 
228  //! Division operator
229  /*!
230  Element by Element division (if the map is not the same, try to import values)
231  @param vector Vector to be perform the division
232  */
233  VectorEpetra& operator/= ( const VectorEpetra& vector );
234 
235  //! Addition operator
236  /*!
237  Element by Element addition (do not modify the vector of the class)
238  @param vector Vector to be added to the current vector
239  */
240  const VectorEpetra operator+ ( const VectorEpetra& vector ) const;
241 
242  //! Subtraction operator
243  /*!
244  Element by Element subtraction (do not modify the vector of the class)
245  @param vector Vector to be subtracted to the current vector
246  */
247  const VectorEpetra operator- ( const VectorEpetra& vector ) const;
248 
249  //! Multiplication operator
250  /*!
251  Element by Element multiplication (do not modify the vector of the class)
252  @param vector Vector to be perform the multiplication
253  */
254  const VectorEpetra operator* ( const VectorEpetra& vector ) const;
255 
256  //! Division operator
257  /*!
258  Element by Element division (do not modify the vector of the class)
259  @param vector Vector to be perform the division
260  */
261  const VectorEpetra operator/ ( const VectorEpetra& vector ) const;
262 
263  //! Addition operator
264  /*!
265  Add a scalar value to the components of the current vector.
266  (modify the vector of the class)
267  @param scalar Value to be added
268  */
269  VectorEpetra& operator+= ( const data_type& scalar );
270 
271  //! Subtraction operator
272  /*!
273  Subtract a scalar value to the components of the current vector.
274  (modify the vector of the class)
275  @param scalar Value to be subtracted
276  */
277  VectorEpetra& operator-= ( const data_type& scalar );
278 
279  //! Multiplication operator
280  /*!
281  Multiply by a scalar value the components of the current vector.
282  (modify the vector of the class)
283  @param scalar Value for the multiplication
284  */
285  VectorEpetra& operator*= ( const data_type& scalar );
286 
287  //! Division operator
288  /*!
289  Division by a scalar value the components of the current vector.
290  (modify the vector of the class)
291  @param scalar Value for the division
292  */
293  VectorEpetra& operator/= ( const data_type& scalar );
294 
295  //! Operations with scalar values (do not modify the vector of the class)
296 
297  //! Addition operator
298  /*!
299  Add a scalar value to the components of the current vector.
300  (do not modify the vector of the class)
301  @param scalar Value to be added
302  */
303  const VectorEpetra operator+ ( const data_type& scalar ) const;
304 
305  //! Subtraction operator
306  /*!
307  Subtract a scalar value to the components of the current vector.
308  (do not modify the vector of the class)
309  @param scalar Value to be subtracted
310  */
311  const VectorEpetra operator- ( const data_type& scalar ) const;
312 
313  //! Multiplication operator
314  /*!
315  Multiply by a scalar value the components of the current vector.
316  (do not modify the vector of the class)
317  @param scalar Value for the multiplication
318  */
319  const VectorEpetra operator* ( const data_type& scalar ) const;
320 
321  //! Division operator
322  /*!
323  Division by a scalar value the components of the current vector.
324  (do not modify the vector of the class)
325  @param scalar Value for the division
326  */
327  const VectorEpetra operator/ ( const data_type& scalar ) const;
328 
329  //! Equality operator
330  /*!
331  Return a vector containing 1 where vector elements are == scalar
332  @param scalar Value for the comparison.
333  */
334  VectorEpetra operator== ( const Real& scalar ) const;
335 
336  //! Inequality operator
337  /*!
338  Return a vector containing 1 where vector elements are != scalar
339  @param scalar Value for the comparison.
340  */
341  VectorEpetra operator!= ( const Real& scalar ) const;
342 
343  //! Less than operator
344  /*!
345  Return a vector containing 1 where vector elements are < scalar
346  @param scalar Value for the comparison.
347  */
348  VectorEpetra operator< ( const Real& scalar ) const;
349 
350  //! Greater than operator
351  /*!
352  Return a vector containing 1 where vector elements are > scalar
353  @param scalar Value for the comparison.
354  */
355  VectorEpetra operator> ( const Real& scalar ) const;
356 
357  //! Less than or equal to operator
358  /*!
359  Return a vector containing 1 where vector elements are <= scalar
360  @param scalar Value for the comparison.
361  */
362  VectorEpetra operator<= ( const Real& scalar ) const;
363 
364  //! Greater than or equal to operator
365  /*!
366  Return a vector containing 1 where vector elements are >= scalar
367  @param scalar Value for the comparison.
368  */
369  VectorEpetra operator>= ( const Real& scalar ) const;
370 
371  //! Logical AND operator
372  /*!
373  Return a vector containing one where both elements are != zero
374  @param vector Vector for the logical comparison.
375  */
376  VectorEpetra operator&& ( const VectorEpetra& vector ) const;
377 
378  //! Logical OR operator
379  /*!
380  Return a vector containing one where one of the elements is != zero
381  @param vector Vector for the logical comparison.
382  */
383  VectorEpetra operator|| ( const VectorEpetra& vector ) const;
384 
385  //! Logical NOT operator
386  /*!
387  Return a vector containing one where the vector is equal to zero
388  */
389  VectorEpetra operator! ( void ) const;
390 
391  //@}
392 
393 
394  //! @name Methods
395  //@{
396 
397  //! Access operators
398  /**
399  * It returns true if the element is present in the vector
400  * @param row The element to test
401  */
402  bool isGlobalIDPresent (const UInt row) const;
403 
404  //! Assemble the vector
405  /*!
406  Gather any shared data into the non-overlapping partitioning defined by
407  the Map that was passed to this vector at construction time.
408  Data imported from other processors is stored on the owning processor
409  with a the given operation
410  @param mode Combining mode used to gather the data
411  */
413  {
414  return M_epetraVector->GlobalAssemble ( mode );
415  }
416 
417  //! Assemble the vector
418  /*!
419  Specialization of the globalAssemble ( combineMode_Type mode )
420  that uses M_combineMode as default value
421  */
422 
424  {
425  return M_epetraVector->GlobalAssemble ( M_combineMode );
426  }
427 
428  //! Return the local Id of a global row
429  /*!
430  @param row Global row Id
431  <ol>
432  <li> if row is mine returns the LID
433  <li> if row is not mine and if the numCpus > 1, returns -1
434  <li> if row is not mine and if the numCpus == 1, asserts
435  </ol>
436  */
437  Int globalToLocalRowId ( const UInt row ) const;
438 
439  //! set zero in all the vector entries
440  void zero()
441  {
442  M_epetraVector->PutScalar (0.);
443  }
444 
445  //! Look for the given global row and set its value
446  /*!
447  @param row Global row Id
448  <ol>
449  <li> if row is mine sets this[row] = value and return true
450  <li> if row is not mine and if the numCpus > 1, returns false
451  <li> if row is not mine and if the numCpus == 1, asserts
452  </ol>
453  @param value Value to be set at the given row
454  @param offset Offset used in the map numbering
455  */
456  bool setCoefficient ( const UInt row, const data_type& value, UInt offset = 0 );
457 
458  //! Set the row of the vector to the given value
459  /*!
460  @param rowsVector Vector containing the row Ids
461  @param valuesVector Vector containing the values
462  */
463  Int setCoefficients ( std::vector< Int >& rowsVector, std::vector< Real >& valuesVector );
464 
465  //! insert a global value
466  /*!
467  After insertion, you will have to call global assemble
468  @param GID Global Id of the row where the value should be inserted
469  @param value Value to be inserted
470  */
471  Int sumIntoGlobalValues ( const Int GID, const Real value );
472 
473  //! Add a vector to the current vector with an offset
474  /*!
475  typically to do: (u,p) += p or (u,p) += u.
476  Note: the nodes to add are taken by the map of vector, hence:
477  <ol>
478  <li> if this has a unique map: then vector should also (otherwise run time error)
479  <li> if this has a repeated map: then vector should also. (otherwise wrong)
480  </ol>
481  @param vector Vector to be added
482  @param offset Offset to shift the value
483  */
484  VectorEpetra& add ( const VectorEpetra& vector, const Int offset = 0 );
485 
486  //! Replace part of the vector with a given vector
487  /*!
488  * Typical examples are: (u,p) = p or (u,p) = u.
489  * Note: the nodes to add are taken by the map of vector, hence:
490  * <ol>
491  * <li> if this has a unique map: then vector should also (otherwise run time error)
492  * <li> if this has a repeated map: then vector should also. (otherwise wrong)
493  * </ol>
494  * @param vector given vector
495  * @param offset identify the first element to be replaced
496  */
497  VectorEpetra& replace ( const VectorEpetra& vector, const Int& offset );
498 
499  //! Set the current vector to a subset of the given vector with an offset
500  /*!
501  typically to do: p = (u,p) or u = (u,p).
502  Note: the nodes to add are taken by the map of this, hence:
503  <ol>
504  <li> if vector has a unique map: then this should also (otherwise run time error)
505  <li> if vector has a repeated map: then this should also. (otherwise wrong)
506  @param vector Vector of value to set the current vector
507  @param offset Offset to shift the value
508  */
509  VectorEpetra& subset ( const VectorEpetra& vector, const UInt offset = 0 );
510 
511  //! Set the current vector to a subset of vector with an offset.
512  /*!
513  similar to subset( const VectorEpetra& , const Int ), but with
514  additional parameters:
515  @param vector vector from which to copy data
516  @param map map from which to select indeces to copy
517  @param offset1 offset to apply to input vector
518  @param offset2 offset to apply to this vector
519  */
520  VectorEpetra& subset ( const VectorEpetra& vector,
521  const MapEpetra& map,
522  const UInt offset1,
523  const UInt offset2 );
524 
525  //! Set the current vector to a subset of vector with an offset.
526  /*!
527  similar to subset( const VectorEpetra& , const Int ), but with
528  additional parameters:
529  @param vector Epetra_MultiVector, instead of VectorEpetra, from which to copy data
530  @param map map from which to select indeces to copy
531  @param offset1 offset to apply to input vector
532  @param offset2 offset to apply to this vector
533  @param column column of the multivector from which to extract the data
534  */
535  VectorEpetra& subset (const Epetra_MultiVector& vector,
536  const MapEpetra& map,
537  const UInt offset1,
538  const UInt offset2,
539  const UInt column = 0);
540 
541  //! Compute the mean value of the vector components and store it in the given variable
542  /*!
543  @param result Variable where the result should be stored
544  */
545  void meanValue ( Real* result ) const;
546 
547  //! Compute and return the norm 1
548  Real norm1 () const;
549 
550  //! Compute and store the norm 1 in the given pointed variable
551  /*!
552  @param result Pointer on the variable where the result should be stored
553  */
554  void norm1 ( Real* result ) const;
555 
556  //! Compute and store the norm 1 in the given variable
557  /*!
558  @param result Variable where the result should be stored
559  */
560  void norm1 ( Real& result ) const;
561 
562  //! Compute and return the norm 2
563  Real norm2 () const;
564 
565  //! Compute and store the norm 2 in the given pointed variable
566  /*!
567  @param result Pointer on the variable where the result should be stored
568  */
569  void norm2 ( Real* result ) const;
570 
571  //! Compute and store the norm 2 in the given variable
572  /*!
573  @param result Variable where the result should be stored
574  */
575  void norm2 ( Real& result ) const;
576 
577  //! Compute and return the norm inf
578  Real normInf () const;
579 
580  //! Compute and store the norm inf in the given pointed variable
581  /*!
582  @param result Pointer on the variable where the result should be stored
583  */
584  void normInf ( Real* result ) const;
585 
586  //! Compute and store the norm inf in the given variable
587  /*!
588  @param result Variable where the result should be stored
589  */
590  void normInf ( Real& result ) const;
591 
592  //! Compute and return the minimum value in the vector
593  Real minValue() const;
594 
595  //! Compute and store the minimum value of the vector in the given pointed variable
596  /*!
597  @param result Pointer on the variable where the result should be stored
598  */
599  void minValue ( Real* result ) const;
600 
601  //! Compute and store the minimum value of the vector in the given variable
602  /*!
603  @param result Variable where the result should be stored
604  */
605  void minValue ( Real& result ) const;
606 
607  //! Compute and return the maximum value in the vector
608  Real maxValue() const;
609 
610  //! Compute and store the maximum value of the vector in the given pointed variable
611  /*!
612  @param result Pointer on the variable where the result should be stored
613  */
614  void maxValue ( Real* result ) const;
615 
616  //! Compute and store the maximum value of the vector in the given variable
617  /*!
618  @param result Variable where the result should be stored
619  */
620  void maxValue ( Real& result ) const;
621 
622  //! Replace the vector with his absolute value
623  void abs ( void );
624 
625  //! Compute the absolute value of a vector and store it in an other vector
626  /*!
627  @param vector Output vector to store the absolute value of the vector
628  */
629  void abs ( VectorEpetra& vector );
630 
631  //! Apply the square root to of each element in the vector
632  void sqrt ();
633 
634  //! Compute the scalar product of two vectors
635  /*!
636  @param vector Second vector for the scalar product
637  */
638  data_type dot ( const VectorEpetra& vector ) const;
639 
640  //! Compute the scalar product of two vectors and store the result in a given variable
641  /*!
642  @param vector Second vector for the scalar product
643  @param scalarProduct Variable to store the result
644  */
645  void dot ( const VectorEpetra& vector, data_type& scalarProduct );
646 
647  //! Save the values of the matrix into a file
648  /*!
649  To read the file in Matlab type load filename;
650  @param filename File where to save the vector
651  */
652  void matrixMarket ( std::string const& fileName, const bool headers = true ) const;
653 
654  //! Save the values of the matrix into a file
655  /*!
656  To read the file in Matlab type load filename;
657  @param filename File where to save the vector
658  */
659  void spy ( std::string const& fileName ) const;
660 
661  //! Print the contents of the vector
662  /*!
663  @param output Stream where the informations must be printed
664  */
665  void showMe ( std::ostream& output = std::cout ) const;
666 
667  void apply (const std::function<Real (Real)>& f);
668 
669  //@}
670 
671 
672  //! @name Set Methods
673  //@{
674 
675  //! Sets the combine mode for the import/export operations.
676  /*!
677  Most of the LifeV library is structured to use combine mode
678  equal to Add. In some cases (cf test_filters) it is necessary
679  to discard the data coming from other processors.
680  @param combineMode combien mode to use for this vector from now on
681  */
682  void setCombineMode ( combineMode_Type combineMode );
683 
684  //! Sets the combine mode for the import/export operations to default.
685  /*!
686  Most of the LifeV library is structured to use combine mode
687  equal to Add.
688  */
689  void setDefaultCombineMode();
690 
691  //! Sets the map to use for the epetra vector
692  /*!
693  This method can be used when building the VectorEpetra using
694  empty constructor.
695  @param map the map of the vector
696  */
697  void setMap ( const MapEpetra& map );
698 
699  //@}
700 
701  //! @name Get Methods
702  //@{
703 
704  //! Return the communicator of the vector
705  const Epetra_Comm& comm() const
706  {
707  return blockMap().Comm();
708  }
709 
710  //! Return the VectorEpetra in the wrapper
712  {
713  return *M_epetraVector;
714  }
715 
716  //! Return the VectorEpetra in the wrapper
717  const vector_type& epetraVector() const
718  {
719  return *M_epetraVector;
720  }
721 
722  //! Return the shared pointer on the raw VectorEpetra
724  {
725  return M_epetraVector;
726  }
727 
728  //! Return the Epetra_BlockMap of the vector
729  const Epetra_BlockMap& blockMap() const
730  {
731  return M_epetraVector->Map();
732  }
733 
734  //! Return the map type of the vector (Unique or Repeated)
736  {
737  return M_mapType;
738  }
739 
740  //! Return the MapEpetra of the vector
741  const MapEpetra& map() const
742  {
743  return *M_epetraMap;
744  }
745 
746  //! Return a shared pointer on the MapEpetra
747  const std::shared_ptr< MapEpetra > mapPtr() const
748  {
749  return M_epetraMap;
750  }
751 
752  //! Return the MapEpetra of the vector
753  const Epetra_Map& epetraMap() const
754  {
755  return * ( M_epetraMap->map ( M_mapType ) );
756  }
757 
758 
759  inline void setMapType (MapEpetraType type)
760  {
761  M_mapType = type;
762  }
763  //! Return the size of the vector
764  Int size() const;
765 
766  //@}
767 
768 private:
769 
770  //! @name Private Methods
771  //@{
772 
773  //! Import the value of a vector
774  /*!
775  Copies the value of a vector u. If the map is not the same,
776  try to import the values. Let you decide wether to add or replace shared nodes:
777  note:
778  <ol>
779  <li> if the original source vector vector is not repeated : use Import
780  <li> if the original source vector vector is repeated : use Export
781  </ol>
782  CombineMode Values:
783  <ol>
784  <li> Add - Components on the receiving processor will be added together.
785  <li> Insert - Off-processor components will be inserted into locations on receiving processor replacing existing values.
786  <li> InsertAdd - Off-processor components will be inserted into locations on receiving processor and added to existing values.
787  <li> Average - Off-processor components will be averaged with existing components on the receiving processor.
788  <li> (+ Zero and AbsMax, probably never useful)
789  </ol>
790  @param vector Vector to be imported
791  @param combineMode Mode to be used to combine the vector
792  */
793  VectorEpetra& Import ( const Epetra_FEVector& vector, combineMode_Type combineMode );
794 
795  //! Export the value of a vector
796  /*!
797  Copies the value of this to a vector vector. If the map is not the same,
798  try to import the values. Let you decide wether to add or replace shared nodes:
799  note: tested only if the destination source vector vector is not repeated
800  CombineMode Values:
801  <ol>
802  <li> Add - Components on the receiving processor will be added together.
803  <li> Insert - Off-processor components will be inserted into locations on receiving processor replacing existing values.
804  <li> InsertAdd - Off-processor components will be inserted into locations on receiving processor and added to existing values.
805  <li> Average - Off-processor components will be averaged with existing components on the receiving processor.
806  <li> (+ Zero and AbsMax, probably never useful)
807  </ol>
808  @param vector Vector where to store the exportation
809  @param combineMode Mode to be used to combine the vector
810  */
811  VectorEpetra& Export ( const Epetra_FEVector& vector, combineMode_Type combineMode );
812 
813  //@}
814 
819 };
820 
821 VectorEpetra operator- ( const VectorEpetra& vector );
822 VectorEpetra operator+ ( const VectorEpetra::data_type& scalar, const VectorEpetra& vector );
823 VectorEpetra operator- ( const VectorEpetra::data_type& scalar, const VectorEpetra& vector );
824 VectorEpetra operator* ( const VectorEpetra::data_type& scalar, const VectorEpetra& vector );
825 
826 } // end namespace LifeV
827 
828 #endif
VectorEpetra & operator-=(const data_type &scalar)
Subtraction operator.
bool isGlobalIDPresent(const UInt row) const
Access operators.
VectorEpetra - The Epetra Vector format Wrapper.
VectorEpetra operator*(const VectorEpetra::data_type &scalar, const VectorEpetra &vector)
void normInf(Real *result) const
Compute and store the norm inf in the given pointed variable.
void minValue(Real *result) const
Compute and store the minimum value of the vector in the given pointed variable.
Epetra_CombineMode combineMode_Type
VectorEpetra operator-(const VectorEpetra::data_type &scalar, const VectorEpetra &vector)
const VectorEpetra operator*(const data_type &scalar) const
Multiplication operator.
VectorEpetra & operator+=(const data_type &scalar)
Addition operator.
VectorEpetra operator>=(const Real &scalar) const
Greater than or equal to operator.
const VectorEpetra operator-(const VectorEpetra &vector) const
Subtraction operator.
VectorEpetra(const VectorEpetra &vector, const MapEpetraType &mapType)
Copy constructor.
const Epetra_Map & epetraMap() const
Return the MapEpetra of the vector.
std::shared_ptr< vector_type > vectorPtr_Type
VectorEpetra & subset(const Epetra_MultiVector &vector, const MapEpetra &map, const UInt offset1, const UInt offset2, const UInt column=0)
Set the current vector to a subset of vector with an offset.
VectorEpetra & subset(const VectorEpetra &vector, const UInt offset=0)
Set the current vector to a subset of the given vector with an offset.
data_type & operator()(const UInt row)
Access operators.
const VectorEpetra operator+(const data_type &scalar) const
Operations with scalar values (do not modify the vector of the class)
VectorEpetra & add(const VectorEpetra &vector, const Int offset=0)
Add a vector to the current vector with an offset.
data_type dot(const VectorEpetra &vector) const
Compute the scalar product of two vectors.
vectorPtr_Type M_epetraVector
void abs(void)
Replace the vector with his absolute value.
const vectorPtr_Type & epetraVectorPtr() const
Return the shared pointer on the raw VectorEpetra.
VectorEpetra & Export(const Epetra_FEVector &vector, combineMode_Type combineMode)
Export the value of a vector.
bool setCoefficient(const UInt row, const data_type &value, UInt offset=0)
Look for the given global row and set its value.
void abs(VectorEpetra &vector)
Compute the absolute value of a vector and store it in an other vector.
VectorEpetra & Import(const Epetra_FEVector &vector, combineMode_Type combineMode)
Import the value of a vector.
Int globalToLocalRowId(const UInt row) const
Return the local Id of a global row.
Real norm1() const
Compute and return the norm 1.
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
void dot(const VectorEpetra &vector, data_type &scalarProduct)
Compute the scalar product of two vectors and store the result in a given variable.
void maxValue(Real &result) const
Compute and store the maximum value of the vector in the given variable.
MapEpetraType mapType() const
Return the map type of the vector (Unique or Repeated)
const data_type & operator[](const UInt row) const
Access operators.
VectorEpetra(const MapEpetra &map, const MapEpetraType &mapType=Unique, const combineMode_Type combineMode=Add)
Constructor - Using Maps.
void updateInverseJacobian(const UInt &iQuadPt)
virtual ~VectorEpetra()
Destructor.
VectorEpetra & operator/=(const data_type &scalar)
Division operator.
const VectorEpetra operator-(const data_type &scalar) const
Subtraction operator.
VectorEpetra operator!(void) const
Logical NOT operator.
VectorEpetra operator-(const VectorEpetra &vector)
void apply(const std::function< Real(Real)> &f)
const Epetra_BlockMap & blockMap() const
Return the Epetra_BlockMap of the vector.
VectorEpetra & operator*=(const VectorEpetra &vector)
Multiplication operator.
void setCombineMode(combineMode_Type combineMode)
Sets the combine mode for the import/export operations.
VectorEpetra operator &&(const VectorEpetra &vector) const
Logical AND operator.
Int globalAssemble()
Assemble the vector.
VectorEpetra operator||(const VectorEpetra &vector) const
Logical OR operator.
VectorEpetra & operator+=(const VectorEpetra &vector)
Addition operator.
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
Real normInf() const
Compute and return the norm inf.
std::shared_ptr< MapEpetra > M_epetraMap
VectorEpetra(const MapEpetraType &mapType=Unique, const combineMode_Type combineMode=Add)
Empty Constructor.
void norm2(Real *result) const
Compute and store the norm 2 in the given pointed variable.
VectorEpetra operator>(const Real &scalar) const
Greater than operator.
VectorEpetra & replace(const VectorEpetra &vector, const Int &offset)
Replace part of the vector with a given vector.
Int globalAssemble(combineMode_Type mode)
Assemble the vector.
const VectorEpetra operator+(const VectorEpetra &vector) const
Addition operator.
const MapEpetra & map() const
Return the MapEpetra of the vector.
void sqrt()
Apply the square root to of each element in the vector.
Int setCoefficients(std::vector< Int > &rowsVector, std::vector< Real > &valuesVector)
Set the row of the vector to the given value.
VectorEpetra operator+(const VectorEpetra::data_type &scalar, const VectorEpetra &vector)
void norm1(Real *result) const
Compute and store the norm 1 in the given pointed variable.
Epetra_FEVector vector_type
VectorEpetra & operator-=(const VectorEpetra &vector)
Subtraction operator.
VectorEpetra & operator=(data_type scalar)
Affectation operator.
vector_type & epetraVector()
Return the VectorEpetra in the wrapper.
Real minValue() const
Compute and return the minimum value in the vector.
Real maxValue() const
Compute and return the maximum value in the vector.
Int size() const
Return the size of the vector.
double Real
Generic real data.
Definition: LifeV.hpp:175
const std::shared_ptr< MapEpetra > mapPtr() const
Return a shared pointer on the MapEpetra.
const VectorEpetra operator/(const data_type &scalar) const
Division operator.
VectorEpetra(const VectorEpetra &vector, const Int &reduceToProc)
Copy constructor.
VectorEpetra(const std::shared_ptr< MapEpetra > &mapPtr, const MapEpetraType &mapType=Unique, const combineMode_Type combineMode=Add)
Constructor - Using Maps.
void setDefaultCombineMode()
Sets the combine mode for the import/export operations to default.
VectorEpetra & operator=(const Epetra_MultiVector &vector)
Affectation operator.
void norm2(Real &result) const
Compute and store the norm 2 in the given variable.
const VectorEpetra operator/(const VectorEpetra &vector) const
Division operator.
void maxValue(Real *result) const
Compute and store the maximum value of the vector in the given pointed variable.
VectorEpetra & operator*=(const data_type &scalar)
Multiplication operator.
const vector_type & epetraVector() const
Return the VectorEpetra in the wrapper.
void meanValue(Real *result) const
Compute the mean value of the vector components and store it in the given variable.
VectorEpetra operator==(const Real &scalar) const
Equality operator.
void norm1(Real &result) const
Compute and store the norm 1 in the given variable.
VectorEpetra(const VectorEpetra &vector)
Copy constructor.
VectorEpetra(const Epetra_MultiVector &vector, const std::shared_ptr< MapEpetra > map, const MapEpetraType &mapType, const combineMode_Type combineMode=Add)
Copy constructor.
VectorEpetra & operator=(const VectorEpetra &vector)
Affectation operator.
Int sumIntoGlobalValues(const Int GID, const Real value)
insert a global value
void setMap(const MapEpetra &map)
Sets the map to use for the epetra vector.
void normInf(Real &result) const
Compute and store the norm inf in the given variable.
combineMode_Type M_combineMode
VectorEpetra operator!=(const Real &scalar) const
Inequality operator.
const Epetra_Comm & comm() const
Return the communicator of the vector.
VectorEpetra & subset(const VectorEpetra &vector, const MapEpetra &map, const UInt offset1, const UInt offset2)
Set the current vector to a subset of vector with an offset.
void showMe(std::ostream &output=std::cout) const
Print the contents of the vector.
void zero()
set zero in all the vector entries
const VectorEpetra operator*(const VectorEpetra &vector) const
Multiplication operator.
VectorEpetra(const VectorEpetra &vector, const MapEpetraType &mapType, const combineMode_Type &combineMode)
Copy constructor.
const data_type & operator()(const UInt row) const
Access operators.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
void setMapType(MapEpetraType type)
void minValue(Real &result) const
Compute and store the minimum value of the vector in the given variable.
data_type & operator[](const UInt row)
Access operators.
VectorEpetra & operator/=(const VectorEpetra &vector)
Division operator.
MapEpetraType M_mapType
Real norm2() const
Compute and return the norm 2.