LifeV
VectorContainer.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 Containers Of Vectors
30  *
31  * @date 29-09-2009
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  *
34  * @contributor Simone Rossi <simone.rossi@epfl.ch>
35  * @mantainer Cristiano Malossi <cristiano.malossi@epfl.ch>
36  */
37 
38 
39 #ifndef VectorContainer_H
40 #define VectorContainer_H 1
41 
42 #include <lifev/core/LifeV.hpp>
43 #include <lifev/core/util/LifeDebug.hpp>
44 
45 #include <lifev/core/LifeV.hpp>
46 #include <lifev/core/util/LifeDebug.hpp>
47 
48 namespace LifeV
49 {
50 
51 //! VectorContainer - LifeV vector composed by concatenating other vectors
52 /*!
53  * @author Cristiano Malossi
54  *
55  * The \c VectorContainer class has the purpose to concatenate a certain number of
56  * different vectors providing also some general methods to perform common algebraic operations.
57  *
58  * <b> Type of compatible vectors </b><BR>
59  * This class has been developed in order to work with:
60  * <ol>
61  * <li> \c VectorEpetra
62  * <li> \c boost::numeric::ublas::vector
63  * </ol>
64  *
65  * <b> Type of compatible containers </b><BR>
66  * This class has been developed in order to work with:
67  * <ol>
68  * <li> \c std::vector
69  * <li> \c std::dequee
70  * <li> \c std::list
71  * </ol>
72  *
73  * <b> NOTES </b><BR>
74  * <ol>
75  * <li> The \c VectorContainer contains \c shared_ptr to vectors: if you perform an operation (such as the
76  * element by element multiplication) among two containers which hold the same vectors (or at least one),
77  * the results can be different from what expected!
78  * <li> Up to now it has been tested only with \c VectorEpetra. However the design should be
79  * more or less compatible also with \c boost::numeric::ublas::vector.
80  * </ol>
81  *
82  */
83 template< class VectorType, class ContainerType = std::vector< std::shared_ptr< VectorType > > >
85 {
86 public:
87 
88  //! @name Constructors & Destructor
89  //@{
90 
96 
97  //@}
98 
99 
100  //! @name Constructors & Destructor
101  //@{
102 
103  //! Constructor
104  VectorContainer();
105 
106  //! Copy constructor
107  /*!
108  * Makes a copy of all the objects contained in the shared_ptr(s).
109  * @param VectorContainer - VectorContainer
110  */
112 
113  //! Destructor
114  virtual ~VectorContainer() {}
115 
116  //@}
117 
118 
119  //! @name Operators
120  //@{
121 
122  //! Operator=
123  /*!
124  * Make a true copy of all the objects contained in the shared_ptr(s)
125  * @param vectorContainer - VectorContainer
126  */
128 
129  //! Operator=
130  /*!
131  * Set all the components of the vector equal to a scalar quantity.
132  * Cannot be done for an empty vector!
133  * @param scalar - Scalar value
134  */
135  VectorContainer& operator= ( const Real& scalar );
136 
137  //! Operator&=
138  /*!
139  * Make a copy of the shared_ptr(s), without duplicates the objects contained in them.
140  * @param vectorContainer - VectorContainer
141  */
143 
144  //! Operator[]
145  /*!
146  * The element access operator (by reference) has been implemented just for debugging or other special cases,
147  * because it is not efficient with this type of implementation.
148  *
149  * @param id - Element id
150  */
151  Real& operator[] ( const UInt& id ) const;
152 
153  //! Operator()
154  /*!
155  * Vector access operator (by shared_ptr).
156  *
157  * @param id - Vector id
158  */
159  vectorPtr_Type& operator() ( const UInt& id );
160 
161  //! Operator+=
162  /*!
163  * @param vectorContainer - VectorContainer
164  */
166 
167  //! Operator-=
168  /*!
169  * @param vectorContainer - VectorContainer
170  */
172 
173  //! Operator*=
174  /*!
175  * Multiplication element by element of two vectors.
176  * @param vectorContainer - VectorContainer
177  */
179 
180  //! Operator/=
181  /*!
182  * Division element by element of two vectors.
183  * @param vectorContainer - VectorContainer
184  */
186 
187  //! Operator+
188  /*!
189  * @param vectorContainer - VectorContainer
190  */
192 
193  //! Operator-
194  /*!
195  * @param vectorContainer - VectorContainer
196  */
198 
199  //! Operator*
200  /*!
201  * Multiplication element by element of two vectors.
202  * @param vectorContainer - VectorContainer
203  */
205 
206  //! Operator/
207  /*!
208  * Division element by element of two vectors.
209  * @param vectorContainer - VectorContainer
210  */
212 
213  //! Operator+=
214  /*!
215  * Multiplication of the vector by a scalar.
216  * @param scalar - Scalar value
217  */
218  VectorContainer& operator+= ( const Real& scalar );
219 
220  //! Operator-=
221  /*!
222  * Division of the vector by a scalar.
223  * @param scalar - Scalar value
224  */
225  VectorContainer& operator-= ( const Real& scalar );
226 
227  //! Operator*=
228  /*!
229  * Multiplication of the vector by a scalar.
230  * @param scalar - Scalar value
231  */
232  VectorContainer& operator*= ( const Real& scalar );
233 
234  //! Operator/=
235  /*!
236  * Division of the vector by a scalar.
237  * @param scalar - Scalar value
238  */
239  VectorContainer& operator/= ( const Real& scalar );
240 
241  //! Operator*=
242  /*!
243  * Multiplication of the vector by a scalar.
244  * @param scalar - Scalar value
245  */
246  const VectorContainer operator+ ( const Real& scalar ) const;
247 
248  //! Operator/=
249  /*!
250  * Division of the vector by a scalar.
251  * @param scalar - Scalar value
252  */
253  const VectorContainer operator- ( const Real& scalar ) const;
254 
255  //! Operator*=
256  /*!
257  * Multiplication of the vector by a scalar.
258  * @param scalar - Scalar value
259  */
260  const VectorContainer operator* ( const Real& scalar ) const;
261 
262  //! Operator/=
263  /*!
264  * Division of the vector by a scalar.
265  * @param scalar - Scalar value
266  */
267  const VectorContainer operator/ ( const Real& scalar ) const;
268 
269  //! operator==
270  /*!
271  * Return a VectorContainer containing 1 where vector elements are == scalar;
272  * @param scalar - Value for the comparison.
273  */
274  VectorContainer operator== ( const Real& scalar );
275 
276  //! operator!=
277  /*!
278  * Return a VectorContainer containing 1 where vector elements are != scalar;
279  * @param scalar - Value for the comparison.
280  */
281  VectorContainer operator!= ( const Real& scalar );
282 
283  //! operator<
284  /*!
285  * Return a VectorContainer containing 1 where vector elements are < scalar;
286  * @param scalar - Value for the comparison.
287  */
288  VectorContainer operator< ( const Real& scalar );
289 
290  //! operator>
291  /*!
292  * Return a VectorContainer containing 1 where vector elements are > scalar;
293  * @param scalar - Value for the comparison.
294  */
295  VectorContainer operator> ( const Real& scalar );
296 
297  //! operator<=
298  /*!
299  * Return a VectorContainer containing 1 where vector elements are <= scalar;
300  * @param scalar - Value for the comparison.
301  */
302  VectorContainer operator<= ( const Real& scalar );
303 
304  //! operator>=
305  /*!
306  * Return a VectorContainer containing 1 where vector elements are >= scalar;
307  * @param scalar - Value for the comparison.
308  */
309  VectorContainer operator>= ( const Real& scalar );
310 
311  //! Logic operator&&
312  /*!
313  * Return a vector containing one where both the elements are different from zero;
314  * @param vectorContainer - VectorContainer
315  */
317 
318  //! Logic operator||
319  /*!
320  * Return a vector containing one if one of the two elements is different from zero;
321  * @param vectorContainer - VectorContainer
322  */
324 
325  //! Logic operator!
326  /*!
327  * Return a vector containing one where the elements are equal to zero;
328  */
330 
331  //@}
332 
333 
334  //! @name Methods
335  //@{
336 
337  //! Dot - Scalar product
338  /*!
339  * Scalar product of the vectors
340  * @param vectorContainer - VectorContainer
341  */
343 
344  //! Dot - Scalar product
345  /*!
346  * Scalar product of the vectors
347  * @param vectorContainer - VectorContainer
348  * @param scalarProduct - result
349  */
351 
352  //! Abs
353  /*!
354  * Replace all the elements in the vectorContainer with their abs.
355  */
356  void abs();
357 
358  /*!
359  * Compute the abs of the VectorContainer and return it in a new container.
360  * @param vectorContainer - The output vectorContainer containing the abs of the vector.
361  */
363 
364  //! Norm2
365  /*!
366  * Compute the weight Norm2 of the vector
367  */
368  Real weightNorm2();
369 
370  //! push_back
371  /*!
372  * Concatenate a VectorContainer to another
373  * @param vectorContainer - VectorContainer
374  */
376 
377  //! push_back
378  /*!
379  * Add a vector at the end of the VectorContainer
380  * @param vector_ptr - Shared pointer to a vector
381  */
383 
384  //! push_front
385  /*!
386  * Concatenate a VectorContainer to another inserting it at the beginning
387  * @param vectorContainer - VectorContainer
388  */
390 
391  //! push_front
392  /*!
393  * Add a vector at the begin of the VectorContainer
394  * @param vector_ptr - Shared pointer to a vector
395  */
397 
398  //! Replace
399  /*!
400  * @param vector_ptr - Shared pointer to the new vector
401  * @param id - id of the vector that has to be replaced
402  */
403  void replace ( const vectorPtr_Type& vector_ptr, const UInt& id )
404  {
406  }
407 
408  //! resize
409  /*!
410  * @param size - New size of the container
411  */
412  void resize ( const UInt& size )
413  {
414  M_container.resize ( size );
415  }
416 
417  //! Clear
418  void clear()
419  {
420  M_container.clear();
421  }
422 
423  //! ShowMe
424  void showMe ( std::ostream& output = std::cout ) const;
425 
426  //@}
427 
428 
429  //! @name Get Methods
430  //@{
431 
432  //! Get the number of elements contained inside the VectorContainer object
433  UInt size() const;
434 
435  //! Get the number of vectors contained inside the VectorContainer object
437  {
438  return static_cast< UInt > ( M_container.size() );
439  }
440 
441  //@}
442 
443 private:
444 
446 };
447 
448 // ===================================================
449 // Constructors
450 // ===================================================
451 template< class VectorType, class ContainerType >
452 VectorContainer< VectorType, ContainerType >::VectorContainer() :
453  M_container()
454 {
455 
456 #ifdef HAVE_LIFEV_DEBUG
457  debugStream ( 3100 ) << "VectorContainer::VectorContainer()" << "\n";
458 #endif
459 
460 }
461 
462 template< class VectorType, class ContainerType >
464  M_container()
465 {
466 
467 #ifdef HAVE_LIFEV_DEBUG
468  debugStream ( 3100 ) << "VectorContainer::VectorContainer( vectorContainer )" << "\n";
469 #endif
470 
471  *this = vectorContainer;
472 }
473 
474 // ===================================================
475 // Operators
476 // ===================================================
477 template< class VectorType, class ContainerType >
480 {
481 
482 #ifdef HAVE_LIFEV_DEBUG
483  debugStream ( 3100 ) << "VectorContainer::operator=( vector_ptr )" << "\n";
484 #endif
485 
486  if ( this != &vectorContainer )
487  {
489 
491  for ( UInt i ( 0 ); i < vectorContainer.vectorsNumber(); ++i )
492  {
494  this->operator() ( i ) = myVectorCopy;
495  }
496  }
497  return *this;
498 }
499 
500 template< class VectorType, class ContainerType >
503 {
504 
505 #ifdef HAVE_LIFEV_DEBUG
506  debugStream ( 3100 ) << "VectorContainer::operator=( scalar )" << "\n";
507 #endif
508 
509  for ( constIterator_Type i = M_container.begin(); i < M_container.end(); ++i )
510  {
511  ( *i )->operator= ( scalar );
512  }
513 
514  return *this;
515 }
516 
517 template< class VectorType, class ContainerType >
520 {
521 
522 #ifdef HAVE_LIFEV_DEBUG
523  debugStream ( 3100 ) << "VectorContainer::operator&=( vector_ptr )" << "\n";
524 #endif
525 
526  if ( this != &vectorContainer )
527  {
529  }
530 
531  return *this;
532 }
533 
534 template< class VectorType, class ContainerType >
535 Real&
537 {
538 
539 #ifdef HAVE_LIFEV_DEBUG
540  debugStream ( 3100 ) << "VectorContainer::operator[]( id )" << "\n";
541 #endif
542 
543  UInt k ( 0 );
545  for ( ; i < M_container.end(); ++i )
546  {
547  if ( id <= k + ( *i )->size() - 1 )
548  {
549  break;
550  }
551  else
552  {
553  k += static_cast< UInt > ( ( *i )->size() );
554  }
555  }
556 
557  return ( * ( *i ) ) [id - k];
558 }
559 
560 template< class VectorType, class ContainerType >
563 {
564 
565 #ifdef HAVE_LIFEV_DEBUG
566  debugStream ( 3100 ) << "VectorContainer::operator()( id )" << "\n";
567 #endif
568 
569  return M_container[id];
570 }
571 
572 template< class VectorType, class ContainerType >
575 {
576 
577 #ifdef HAVE_LIFEV_DEBUG
578  debugStream ( 3100 ) << "VectorContainer::operator+=( vectorContainer )" << "\n";
579 #endif
580 
581  for ( UInt i ( 0 ); i < vectorContainer.vectorsNumber(); ++i )
582  {
584  }
585 
586  return *this;
587 }
588 
589 template< class VectorType, class ContainerType >
592 {
593 
594 #ifdef HAVE_LIFEV_DEBUG
595  debugStream ( 3100 ) << "VectorContainer::operator-=( vectorContainer )" << "\n";
596 #endif
597 
598  for ( UInt i ( 0 ); i < vectorContainer.vectorsNumber(); ++i )
599  {
601  }
602 
603  return *this;
604 }
605 
606 template< class VectorType, class ContainerType >
609 {
610 
611 #ifdef HAVE_LIFEV_DEBUG
612  debugStream ( 3100 ) << "VectorContainer::operator*=( vectorContainer )" << "\n";
613 #endif
614 
615  for ( UInt i ( 0 ); i < vectorsNumber(); ++i )
616  {
618  }
619 
620  return *this;
621 }
622 
623 template< class VectorType, class ContainerType >
626 {
627 
628 #ifdef HAVE_LIFEV_DEBUG
629  debugStream ( 3100 ) << "VectorContainer::operator/=( vectorContainer )" << "\n";
630 #endif
631 
632  for ( UInt i ( 0 ); i < vectorsNumber(); ++i )
633  {
635  }
636 
637  return *this;
638 }
639 
640 template< class VectorType, class ContainerType >
643 {
644 
645 #ifdef HAVE_LIFEV_DEBUG
646  debugStream ( 3100 ) << "VectorContainer::operator+( vectorContainer )" << "\n";
647 #endif
648 
650 
652 
653  return myVectorCopy;
654 }
655 
656 template< class VectorType, class ContainerType >
659 {
660 
661 #ifdef HAVE_LIFEV_DEBUG
662  debugStream ( 3100 ) << "VectorContainer::operator-( vectorContainer )" << "\n";
663 #endif
664 
666 
668 
669  return myVectorCopy;
670 }
671 
672 template< class VectorType, class ContainerType >
675 {
676 
677 #ifdef HAVE_LIFEV_DEBUG
678  debugStream ( 3100 ) << "VectorContainer::operator*( vectorContainer )" << "\n";
679 #endif
680 
682 
684 
685  return myVectorCopy;
686 }
687 
688 template< class VectorType, class ContainerType >
691 {
692 
693 #ifdef HAVE_LIFEV_DEBUG
694  debugStream ( 3100 ) << "VectorContainer::operator/( vectorContainer )" << "\n";
695 #endif
696 
698 
700 
701  return myVectorCopy;
702 }
703 
704 template< class VectorType, class ContainerType >
707 {
708 
709 #ifdef HAVE_LIFEV_DEBUG
710  debugStream ( 3100 ) << "VectorContainer::operator+=( scalar )" << "\n";
711 #endif
712 
713  for ( constIterator_Type i = M_container.begin(); i < M_container.end(); ++i )
714  {
715  ( *i )->operator+= ( scalar );
716  }
717 
718  return *this;
719 }
720 
721 template< class VectorType, class ContainerType >
724 {
725 
726 #ifdef HAVE_LIFEV_DEBUG
727  debugStream ( 3100 ) << "VectorContainer::operator-=( scalar )" << "\n";
728 #endif
729 
730  for ( constIterator_Type i = M_container.begin(); i < M_container.end(); ++i )
731  {
732  ( *i )->operator+= ( -scalar );
733  }
734 
735  return *this;
736 }
737 
738 template< class VectorType, class ContainerType >
741 {
742 
743 #ifdef HAVE_LIFEV_DEBUG
744  debugStream ( 3100 ) << "VectorContainer::operator*=( scalar )" << "\n";
745 #endif
746 
747  for ( constIterator_Type i = M_container.begin(); i < M_container.end(); ++i )
748  {
749  ( *i )->operator*= ( scalar );
750  }
751 
752  return *this;
753 }
754 
755 template< class VectorType, class ContainerType >
758 {
759 
760 #ifdef HAVE_LIFEV_DEBUG
761  debugStream ( 3100 ) << "VectorContainer::operator/=( scalar )" << "\n";
762 #endif
763 
764  this->operator*= ( 1. / scalar );
765 
766  return *this;
767 }
768 
769 template< class VectorType, class ContainerType >
772 {
773 
774 #ifdef HAVE_LIFEV_DEBUG
775  debugStream ( 3100 ) << "VectorContainer::operator+( scalar )" << "\n";
776 #endif
777 
779 
780  myVectorCopy += scalar;
781 
782  return myVectorCopy;
783 }
784 
785 template< class VectorType, class ContainerType >
788 {
789 
790 #ifdef HAVE_LIFEV_DEBUG
791  debugStream ( 3100 ) << "VectorContainer::operator-( scalar )" << "\n";
792 #endif
793 
795 
796  myVectorCopy -= scalar;
797 
798  return myVectorCopy;
799 }
800 
801 template< class VectorType, class ContainerType >
804 {
805 
806 #ifdef HAVE_LIFEV_DEBUG
807  debugStream ( 3100 ) << "VectorContainer::operator*( scalar )" << "\n";
808 #endif
809 
811 
812  myVectorCopy *= scalar;
813 
814  return myVectorCopy;
815 }
816 
817 template< class VectorType, class ContainerType >
820 {
821 
822 #ifdef HAVE_LIFEV_DEBUG
823  debugStream ( 3100 ) << "VectorContainer::operator/( scalar )" << "\n";
824 #endif
825 
827 
828  myVectorCopy /= scalar;
829 
830  return myVectorCopy;
831 }
832 
833 // Multiplication by a scalar with the scalar on the left.
834 template< class ScalarType, class VectorType, class ContainerType >
838 {
839 
840 #ifdef HAVE_LIFEV_DEBUG
841  debugStream ( 3100 ) << "VectorContainer::operator*( scalar, vectorContainer )" << "\n";
842 #endif
843 
845 
846  return vectorContainerCopy *= scalar;
847 }
848 
849 template< class VectorType, class ContainerType >
852 {
853 
854 #ifdef HAVE_LIFEV_DEBUG
855  debugStream ( 3100 ) << "VectorContainer::operator==( scalar )" << "\n";
856 #endif
857 
860 
862  {
863  myVectorCopy.reset ( new vector_Type ( ( *i )->operator== ( scalar ) ) );
864  ( *i ) = myVectorCopy;
865  }
866 
867  return vectorContainerCopy;
868 }
869 
870 template< class VectorType, class ContainerType >
873 {
874 
875 #ifdef HAVE_LIFEV_DEBUG
876  debugStream ( 3100 ) << "VectorContainer::operator!=( scalar )" << "\n";
877 #endif
878 
881 
883  {
884  myVectorCopy.reset ( new vector_Type ( ( *i )->operator!= ( scalar ) ) );
885  ( *i ) = myVectorCopy;
886  }
887 
888  return vectorContainerCopy;
889 }
890 
891 template< class VectorType, class ContainerType >
894 {
895 
896 #ifdef HAVE_LIFEV_DEBUG
897  debugStream ( 3100 ) << "VectorContainer::operator>( scalar )" << "\n";
898 #endif
899 
902 
904  {
905  myVectorCopy.reset ( new vector_Type ( ( *i )->operator> ( scalar ) ) );
906  ( *i ) = myVectorCopy;
907  }
908 
909  return vectorContainerCopy;
910 }
911 
912 template< class VectorType, class ContainerType >
915 {
916 
917 #ifdef HAVE_LIFEV_DEBUG
918  debugStream ( 3100 ) << "VectorContainer::operator<( scalar )" << "\n";
919 #endif
920 
923 
925  {
926  myVectorCopy.reset ( new vector_Type ( ( *i )->operator< ( scalar ) ) );
927  ( *i ) = myVectorCopy;
928  }
929 
930  return vectorContainerCopy;
931 }
932 
933 template< class VectorType, class ContainerType >
936 {
937 
938 #ifdef HAVE_LIFEV_DEBUG
939  debugStream ( 3100 ) << "VectorContainer::operator>=( scalar )" << "\n";
940 #endif
941 
944 
946  {
947  myVectorCopy.reset ( new vector_Type ( ( *i )->operator>= ( scalar ) ) );
948  ( *i ) = myVectorCopy;
949  }
950 
951  return vectorContainerCopy;
952 }
953 
954 template< class VectorType, class ContainerType >
957 {
958 
959 #ifdef HAVE_LIFEV_DEBUG
960  debugStream ( 3100 ) << "VectorContainer::operator<=( scalar )" << "\n";
961 #endif
962 
965 
967  {
968  myVectorCopy.reset ( new vector_Type ( ( *i )->operator<= ( scalar ) ) );
969  ( *i ) = myVectorCopy;
970  }
971 
972  return vectorContainerCopy;
973 }
974 
975 template< class VectorType, class ContainerType >
978 {
979 
980 #ifdef HAVE_LIFEV_DEBUG
981  debugStream ( 3100 ) << "VectorContainer::operator&&( vectorContainer )" << "\n";
982 #endif
983 
986 
988  for ( UInt i ( 0 ); i < vectorContainer.vectorsNumber(); ++i )
989  {
992  }
993 
994  return vectorContainerCopy;
995 }
996 
997 template< class VectorType, class ContainerType >
1000 {
1001 
1002 #ifdef HAVE_LIFEV_DEBUG
1003  debugStream ( 3100 ) << "VectorContainer::operator||( vectorContainer )" << "\n";
1004 #endif
1005 
1008 
1010  for ( UInt i ( 0 ); i < vectorContainer.vectorsNumber(); ++i )
1011  {
1014  }
1015 
1016  return vectorContainerCopy;
1017 }
1018 
1019 template< class VectorType, class ContainerType >
1022 {
1023 
1024 #ifdef HAVE_LIFEV_DEBUG
1025  debugStream ( 3100 ) << "VectorContainer::operator!()" << "\n";
1026 #endif
1027 
1030 
1032  for ( UInt i ( 0 ); i < vectorsNumber(); ++i )
1033  {
1036  }
1037 
1038  return vectorContainerCopy;
1039 }
1040 
1041 // ===================================================
1042 // Methods
1043 // ===================================================
1044 template< class VectorType, class ContainerType >
1045 Real
1047 {
1048 
1049 #ifdef HAVE_LIFEV_DEBUG
1050  debugStream ( 3100 ) << "VectorContainer::dot( vectorContainer )" << "\n";
1051 #endif
1052 
1053  Real scalarProduct = 0;
1054 
1055  for ( UInt i ( 0 ); i < vectorsNumber(); ++i )
1056  {
1058  }
1059 
1060  return scalarProduct;
1061 }
1062 
1063 template< class VectorType, class ContainerType >
1064 void
1066 {
1067 
1068 #ifdef HAVE_LIFEV_DEBUG
1069  debugStream ( 3100 ) << "VectorContainer::dot( vectorContainer, scalarProduct )" << "\n";
1070 #endif
1071 
1072  for ( UInt i ( 0 ); i < vectorsNumber(); ++i )
1073  {
1075  }
1076 }
1077 
1078 template< class VectorType, class ContainerType >
1079 void
1081 {
1082 
1083 #ifdef HAVE_LIFEV_DEBUG
1084  debugStream ( 3100 ) << "VectorContainer::abs()" << "\n";
1085 #endif
1086 
1087  for ( constIterator_Type i = M_container.begin(); i < M_container.end(); ++i )
1088  {
1089  ( *i )->abs();
1090  }
1091 }
1092 
1093 template< class VectorType, class ContainerType >
1094 void
1097 {
1098 
1099 #ifdef HAVE_LIFEV_DEBUG
1100  debugStream ( 3100 ) << "VectorContainer::abs( vectorContainer )" << "\n";
1101 #endif
1102 
1103  vectorContainer = *this;
1104 
1105  vectorContainer.abs();
1106 }
1107 
1108 template< class VectorType, class ContainerType >
1109 Real
1111 {
1112 
1113 #ifdef HAVE_LIFEV_DEBUG
1114  debugStream ( 3100 ) << "VectorContainer::weightNorm2()" << "\n";
1115 #endif
1116 
1117  Real PartialNorm, TotalNorm = 0;
1118 
1119  for ( constIterator_Type i = M_container.begin(); i < M_container.end(); ++i )
1120  {
1121  ( *i )->norm2 ( PartialNorm );
1122  TotalNorm += PartialNorm * ( *i )->size();
1123  }
1124 
1125  return TotalNorm / this->size();
1126 }
1127 
1128 template< class VectorType, class ContainerType >
1131 {
1132 
1133 #ifdef HAVE_LIFEV_DEBUG
1134  debugStream ( 3100 ) << "VectorContainer::push_back( vector_ptr )" << "\n";
1135 #endif
1136 
1138  {
1139  this->push_back ( *i );
1140  }
1141 
1142  return *this;
1143 }
1144 
1145 template< class VectorType, class ContainerType >
1148 {
1149 
1150 #ifdef HAVE_LIFEV_DEBUG
1151  debugStream ( 3100 ) << "VectorContainer::push_back( vector_ptr )" << "\n";
1152 #endif
1153 
1155 
1156  return *this;
1157 }
1158 
1159 template< class VectorType, class ContainerType >
1162 {
1163 
1164 #ifdef HAVE_LIFEV_DEBUG
1165  debugStream ( 3100 ) << "VectorContainer::push_front( vector_ptr )" << "\n";
1166 #endif
1167 
1169  {
1170  this->push_front ( *i );
1171  }
1172 
1173  return *this;
1174 }
1175 
1176 template< class VectorType, class ContainerType >
1179 {
1180 
1181 #ifdef HAVE_LIFEV_DEBUG
1182  debugStream ( 3100 ) << "VectorContainer::push_front( vector_ptr )" << "\n";
1183 #endif
1184 
1186 
1187  return *this;
1188 }
1189 
1190 template< class VectorType, class ContainerType >
1191 void
1193 {
1194 
1195 #ifdef HAVE_LIFEV_DEBUG
1196  debugStream ( 3100 ) << "VectorContainer::showMe()" << "\n";
1197 #endif
1198 
1199  output << "Number of vectors: " << vectorsNumber() << std::endl;
1200  output << "Global vector size: " << size() << std::endl;
1201 
1202  for ( constIterator_Type i = M_container.begin(); i < M_container.end(); ++i )
1203  {
1204  ( *i )->showMe ( output );
1205  }
1206  // for ( UInt i( 0 ); i < size(); ++i )
1207  // output << "V[" << i << "] = " << this->operator[]( i ) << std::endl;
1208 
1209  output << std::endl;
1210 }
1211 
1212 // ===================================================
1213 // Get Methods
1214 // ===================================================
1215 template< class VectorType, class ContainerType >
1216 UInt
1218 {
1219 
1220 #ifdef HAVE_LIFEV_DEBUG
1221  debugStream ( 3100 ) << "VectorContainer::size()" << "\n";
1222 #endif
1223 
1224  UInt size = 0;
1225 
1226  for ( constIterator_Type i = M_container.begin(); i < M_container.end(); ++i )
1227  {
1228  size += static_cast< UInt > ( ( *i )->size() );
1229  }
1230 
1231  return size;
1232 }
1233 
1234 } // Namespace LifeV
1235 
1236 #endif /* VectorContainer_H */
void updateInverseJacobian(const UInt &iQuadPt)