Commit e67dbb10 authored by prudhomm's avatar prudhomm
Browse files

* too many changes to remember them all

* more C++ standard compliance. unfortunately there are still lots
 of construct that are non standard (e.g. int v[size] where size is variable)
* fixed a lot of template specialization
* removed all ; after } (except for classes of course)
* tons of work remains to be done before LifeV can be fully compiled
  with g++-3.4. most lifesolver won't compile for example
parent 90d616b8
......@@ -36,10 +36,10 @@ AM_INIT_AUTOMAKE([foreign check-news 1.7.8 dist-bzip2])
AM_CONFIG_HEADER(lifeconfig.h)
# checks for a C compiler
AC_PROG_CC( gcc-3.3 gcc-3.2 gcc )
AC_PROG_CC( gcc-3.4 gcc-3.3 gcc-3.2 gcc )
AC_PROG_CC_C_O
AC_PROG_CXX( g++-3.3 g++-3.2 g++ )
AC_PROG_F77( g77-3.3 g77-3.2 g77 )
AC_PROG_CXX( g++-3.4 g++-3.3 g++-3.2 g++ )
AC_PROG_F77( g++-3.4 g77-3.3 g77-3.2 g77 )
AC_PROG_F77_C_O
# no need for static libs
......@@ -78,14 +78,18 @@ then
AC_MSG_ERROR(Cannot use --enable-debug and --enable-opt at the same time!)
fi
#CXXFLAGS="-Wall -Wno-long-long -ansi -pedantic"
#CXXFLAGS="-Wall -Wno-long-long -pedantic"
CXXFLAGS="-Wall -Wno-long-long"
if test $ac_use_debug_code = "yes"; then
CPPFLAGS="-DLIFEV_CHECK_ALL ${CPPFLAGS}"
CXXFLAGS="-g3 -O0 -Wall"
CFLAGS="-g3 -O0 -Wall"
CXXFLAGS="-g3 -O0 ${CXXFLAGS}"
CFLAGS="-g3 -O0 ${CFLAGS}"
else
if test $ac_use_opt_code = "yes"; then
CXXFLAGS="-O2 -funroll-all-loops -fargument-noalias-global -fno-gcse -Wall"
CFLAGS="-O2 -funroll-all-loops -fargument-noalias-global -fno-gcse -Wall"
CXXFLAGS="-O2 -funroll-all-loops -fargument-noalias-global -fno-gcse ${CXXFLAGS}"
CFLAGS="-O2 -funroll-all-loops -fargument-noalias-global -fno-gcse ${CFLAGS}"
CPPFLAGS="-DNDEBUG ${CPPFLAGS}"
fi
fi
......
......@@ -26,6 +26,8 @@
\author Christoph Winkelmann <christoph.winkelmann@epfl.ch>
\date 2004-09-22
*/
#include <iostream>
#include <fstream>
#include <SolverAztec.hpp>
......
......@@ -29,8 +29,7 @@
#ifndef SolverAztec_H
#define SolverAztec_H 1
#include <iostream>
#include "dataAztec.hpp"
#include <dataAztec.hpp>
#include <vecUnknown.hpp>
class GetPot;
......
......@@ -17,6 +17,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <iostream>
#include <vector>
#include <fstream>
#include "dataAztec.hpp"
namespace LifeV
......@@ -279,14 +282,14 @@ void DataAztec::dataAztecShowMe(std::ostream& c)
c << "\n*** Values for data [aztec]\n\n";
c << "aztec_solver = " << aztec_solver << " ("
<< aztec_solver_str<< ")" << std::endl;
c << "aztec_scaling = " << aztec_scaling << " ("
c << "aztec_scaling = " << aztec_scaling << " ("
<< aztec_scaling_str << ")" << std::endl;
c << "aztec_precond = " << aztec_precond << " ("
c << "aztec_precond = " << aztec_precond << " ("
<< aztec_precond_str << ")" << std::endl;
c << "aztec_tol = " << aztec_tol << std::endl;
c << "aztec_conv = " << aztec_conv << " ("
c << "aztec_conv = " << aztec_conv << " ("
<< aztec_conv_str << ")" << std::endl;
c << "aztec_output = " << aztec_output << " ("
c << "aztec_output = " << aztec_output << " ("
<< aztec_output_str << ")" << std::endl;
c << "aztec_pre_calc = " << aztec_pre_calc << std::endl;
c << "aztec_max_iter = " << aztec_max_iter << std::endl;
......
......@@ -18,16 +18,21 @@
*/
#ifndef _DATAAZTEC_H_
#define _DATAAZTEC_H_
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
extern "C"
{
//! Aztec include
#include "az_aztec.h"
}
#include "GetPot.hpp"
#include "sparseArray.hpp"
#include "dataString.hpp"
#include <GetPot.hpp>
#include <sparseArray.hpp>
#include <dataString.hpp>
namespace LifeV
{
......@@ -50,8 +55,6 @@ namespace LifeV
\todo dataAztecHelp() is not complete, and other items could
be named with a string rather than with an integer
*/
//using namespace std;
class DataAztec
{
public:
......
......@@ -37,112 +37,112 @@ namespace LifeV
template<class R>
void MatMul(KNM_<R> & ab, KNM_<R> & a, KNM_<R> & b){
// attention ne marche que si les adresses ne sont pas les memes
int N= a.shapei.n;
int M= a.shapej.n;
K_assert(a.shapej.n == a.shapei.n);
K_assert(a.shapei.n == ab.shapei.n);
K_assert(b.shapej.n == ab.shapej.n);
K_assert(b.v != ab.v);
K_assert(a.v != ab.v);
KN_<R> ai =a(0);
for(int i=1;i<N;i++,++ai){
KN_<R> bj=b[0];
for(int j=1;j<M;j++,++bj)
ab(i,j) = (ai , bj) ;}
// attention ne marche que si les adresses ne sont pas les memes
int N= a.shapei.n;
int M= a.shapej.n;
K_assert(a.shapej.n == a.shapei.n);
K_assert(a.shapei.n == ab.shapei.n);
K_assert(b.shapej.n == ab.shapej.n);
K_assert(b.v != ab.v);
K_assert(a.v != ab.v);
KN_<R> ai =a(0);
for(int i=1;i<N;i++,++ai){
KN_<R> bj=b[0];
for(int j=1;j<M;j++,++bj)
ab(i,j) = (ai , bj) ;}
}
inline std::ostream & operator<<(std::ostream & f,const ShapeOfArray & s)
{ f << s.n ;
if(s.step != 1)
f << ":" << s.step ;
if (s.step*s.n != s.next )
f << " n: " << std::setw(3) << s.next ;
f << ",";
return f;
};
{ f << s.n ;
if(s.step != 1)
f << ":" << s.step ;
if (s.step*s.n != s.next )
f << " n: " << std::setw(3) << s.next ;
f << ",";
return f;
}
template<class R> std::ostream & operator<<(std::ostream & f,const KN_<const_R> & v)
{ //f << " KN_ : " << (ShapeOfArray) v << " " << (const_R *) v << " :\n\t" ;
{ //f << " KN_ : " << (ShapeOfArray) v << " " << (const_R *) v << " :\n\t" ;
f << v.N() << "\t:\t" ;
for (int i=0;i<v.N();i++)
std::cout << std::setw(3) << v[i] << ((i % 10) == 9 ? "\n\t" : "\t");
return f;
};
std::cout << std::setw(3) << v[i] << ((i % 10) == 9 ? "\n\t" : "\t");
return f;
}
template<class R> std::ostream & operator<<(std::ostream & f,const KNM_<const_R> & v)
{ //f << " KNM_ "<<v.N()<<"x"<<v.M()<< ": " << (ShapeOfArray) v
//<< " i " << v.shapei
// << " j " << v.shapej
// << " " << &v(0,0) << " :\n\t";
f << v.N()<<'x'<<v.M() /*<< " n" << v.next<<" :"<< v.shapei.next << "," << v.shapej.next */<< "\t:\n\t" ;
{ //f << " KNM_ "<<v.N()<<"x"<<v.M()<< ": " << (ShapeOfArray) v
//<< " i " << v.shapei
// << " j " << v.shapej
// << " " << &v(0,0) << " :\n\t";
f << v.N()<<'x'<<v.M() /*<< " n" << v.next<<" :"<< v.shapei.next << "," << v.shapej.next */<< "\t:\n\t" ;
for (int i=0;i<v.N();i++) {
for (int j=0;j<v.M();j++)
std::cout << " " << std::setw(3) << v(i,j);
std::cout << "\n\t";}
return f;
for (int j=0;j<v.M();j++)
std::cout << " " << std::setw(3) << v(i,j);
std::cout << "\n\t";}
return f;
};
}
template<class R> std::ostream & operator<<(std::ostream & f,const KNMK_<const_R> & v)
{ //f << " KNM_" <<v.N()<<"x"<<v.M()<<"x"<<v.K()<< " : " << (ShapeOfArray) v
{ //f << " KNM_" <<v.N()<<"x"<<v.M()<<"x"<<v.K()<< " : " << (ShapeOfArray) v
// << " i " << v.shapei
// << " j " << v.shapej
// << " k " << v.shapek << std::endl;
// << " " << (void *) & v(0,0,0) << "\n\t" ;
f << v.N()<< 'x' <<v.M()<< 'x'<<v.K() << "\t:\n\t" ;
for (int i=0;i<v.shapei.n;i++){
for (int j=0;j<v.shapej.n;j++){
for (int k=0;k<v.shapek.n;k++)
std::cout << " " << std::setw(3) << v(i,j,k);
std::cout << "\n\t";}
std::cout << "\n\t";}
return f;
f << v.N()<< 'x' <<v.M()<< 'x'<<v.K() << "\t:\n\t" ;
for (int i=0;i<v.shapei.n;i++){
for (int j=0;j<v.shapej.n;j++){
for (int k=0;k<v.shapek.n;k++)
std::cout << " " << std::setw(3) << v(i,j,k);
std::cout << "\n\t";}
std::cout << "\n\t";}
return f;
};
}
template<class R>
R KN_<R>::operator,(const KN_<const_R> & u) const {
R KN_<R>::operator,(const KN_<const_R> & u) const {
K_assert(u.n == n);
double s=0;
R * l(v);
R *r(u.v);
for (int i=0;i<n;i++,l += step, r += u.step) s += *l * *r;
return s;
}
}
template<class R>
R KN_<R>::KNMmin() const {
R minv = v[index(0)];
for (int i=1;i<n;i++)
minv = minv < v[index(i)] ? minv : v[index(i)];
minv = minv < v[index(i)] ? minv : v[index(i)];
return minv;
}
}
template<class R>
R KN_<R>::KNMmax() const {
R maxv = v[index(0)];
for (int i=1;i<n;i++)
maxv = maxv > v[index(i)] ? maxv : v[index(i)];
maxv = maxv > v[index(i)] ? maxv : v[index(i)];
return maxv;
}
}
template<class R>
R KN_<R>::sum() const {
R s = v[index(0)];
for (int i=1;i<n;i++)
s += v[index(i)];
s += v[index(i)];
return s;
}
}
template<class R>
KN_<R>& KN_<R>::map(R (*f)(R )) {
KN_<R>& KN_<R>::map(R (*f)(R )) {
for (int i=0;i<n;i++)
{ R & x(v[index(i)]);
x = f(x);}
{ R & x(v[index(i)]);
x = f(x);}
return *this;
}
}
}
///////////////// definition des operateurs d'affectation /////////////////////////
......
This diff is collapsed.
......@@ -18,7 +18,7 @@
*/
/*----------------------------------------------------------------------*
|
| $Header: /cvsroot/lifev/lifev/life/lifearray/Attic/pattern.hpp,v 1.11 2004-10-04 16:18:11 prudhomm Exp $
| $Header: /cvsroot/lifev/lifev/life/lifearray/Attic/pattern.hpp,v 1.12 2004-10-05 09:36:08 prudhomm Exp $
|
|
| #Version 0.1 Experimental 07/7/00. Luca Formaggia & Alessandro Veneziani |
......@@ -973,7 +973,7 @@ CSRPatt::CSRPatt(DOF1 const & dof1, UInt const nbcomp) {
#else
buildPattern(dof1, nbcomp);
#endif
};
}
// Alain (nov. 2002): version for (nbcomp X nbcomp) block matrix.
template<typename DOF1>
......@@ -997,7 +997,7 @@ CSRPatt::CSRPatt(DOF const& dof, UInt const nbcomp, MESH const& mesh) {
#else
buildPattern(dof, nbcomp, mesh);
#endif
};
}
template<typename DOF, typename MESH>
bool CSRPatt::buildPattern(DOF const& dof, const UInt nbcomp,
......@@ -1114,7 +1114,7 @@ void CSRPatt::_buildPattern(DOF1 const & dof1, DynPattern const & dynpatt,
_filled=true;
_diagfirst=true;
};
}
template<typename DOF1,typename DOF2>
CSRPatt::CSRPatt(DOF1 const & dof1, DOF2 const & dof2,
......@@ -1122,7 +1122,7 @@ CSRPatt::CSRPatt(DOF1 const & dof1, DOF2 const & dof2,
bool built;
built = buildPattern(dof1, dof2, bRows, bCols);
ASSERT_PRE(built,"Error in CSR Pattern construction from DOF object");
};
}
template<typename DOF1,typename DOF2>
bool CSRPatt::buildPattern(DOF1 const & dof1, DOF2 const & dof2,
......@@ -1214,7 +1214,7 @@ ID CSRPatt::neighbour(ID const i, ID const d) const {
ASSERT_BD(i>0);
ASSERT_PRE(_filled, "Cannot access an empty pattern");
return _i2d(_ja[_i2o(_ia[d-1]) +_d2o(i)]);
};
}
inline
void CSRPatt::neighbours(ID const d, Container & neigs) const{
......@@ -1225,7 +1225,7 @@ void CSRPatt::neighbours(ID const d, Container & neigs) const{
neigs.resize(nbNeighbours(d),0);// copy wants a sequence!
copy(start1,start1+nbNeighbours(d),neigs.begin());
_i2d(neigs);// trasform to DOF ID's
};
}
template <typename Iter>
inline
......@@ -1460,7 +1460,7 @@ VBRPatt::VBRPatt(DOF1 const & dof1,DOF2 const & dof2, UInt
{
bool built = buildPattern(blockSize);
ASSERT_PRE(built,"Error in VBR Pattern construction from DOF object");
};
}
inline UInt VBRPatt::row(Diff_t const row, Container & coldata, Container & position) const
{
......@@ -1484,11 +1484,11 @@ inline UInt VBRPatt::row(Diff_t const row, Container & coldata, Container & pos
for (UInt i=0; i<blsize; ++i){
coldata.push_back(colblocdata[ibl-start]*blsize+i);
position.push_back(_indx[ibl]+localr+i*blsize);
};
};
}
}
return (end-start)*blsize;
};
}
////////////////////////////////////////////////////////////////////////
//
// C S R Symmetric Pattern
......@@ -1580,7 +1580,7 @@ bool CSRPattSymm::buildPattern(DOF1 const & dof1){
_diagfirst=true;
dynpatt.clear(); // not sure if this helps...
return true;
};
}
inline
std::pair<PatternDefs::Diff_t,bool>
......@@ -1644,7 +1644,7 @@ MSRPatt::MSRPatt(DOF1 const & dof1, UInt const nbcomp)
bool built;
built = buildPattern(dof1, nbcomp);
ASSERT_PRE(built,"Error in MSR Pattern construction from DOF object");
};
}
// Miguel 12/2003
//
......@@ -1654,7 +1654,7 @@ MSRPatt::MSRPatt(const DOF& dof, const MESH& mesh, const UInt nbcomp)
bool built;
built = buildPattern(dof, mesh, nbcomp);
ASSERT_PRE(built,"Error in MSR Pattern construction from DOF object");
};
}
template<typename DOF1>
......
......@@ -16,7 +16,7 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "sparseArray.hpp"
#include <sparseArray.hpp>
namespace LifeV
{
......@@ -37,8 +37,8 @@ void MultInvDiag(const std::vector<Real> &Diag,
}
//version for Datatype=Tab2d
CSRMatr<CSRPatt,Tab2d>::
CSRMatr(const CSRPatt &ex_pattern, UInt const nr, UInt const nc)
template<>
CSRMatr<CSRPatt,Tab2d>::CSRMatr(const CSRPatt &ex_pattern, UInt const nr, UInt const nc)
{
_Patt = &ex_pattern;
Tab2d mzero(nr,nc);
......@@ -47,9 +47,9 @@ CSRMatr(const CSRPatt &ex_pattern, UInt const nr, UInt const nc)
}
// version for block matrices
template<>
VectorBlock
CSRMatr<CSRPatt,Tab2d>::
trans_mult(const VectorBlock &v)
CSRMatr<CSRPatt,Tab2d>::trans_mult(const VectorBlock &v)
{
UInt nblockr=_Patt->nRows(); // for square matrices...
int blsize=_value[0].N(); // for square block
......@@ -70,8 +70,9 @@ trans_mult(const VectorBlock &v)
}
// version for block matrices
VectorBlock CSRMatr<CSRPatt,Tab2d>::
operator*(const VectorBlock &v) const
template<>
VectorBlock
CSRMatr<CSRPatt,Tab2d>::operator*(const VectorBlock &v) const
{
UInt nblockr=_Patt->nRows();
UInt nblockc=_Patt->nCols();
......@@ -85,13 +86,14 @@ operator*(const VectorBlock &v) const
{
for (UInt ii=_Patt->give_ia()[ir]-OFFSET;ii<_Patt->give_ia()[ir+1]-OFFSET;++ii)
ans.numBlock(ir)+=(_value[ii]*v.numBlock(_Patt->give_ja()[ii]-OFFSET));
};
}
return ans;
}
// the case of block matrices with Tab2d block type.
void CSRMatr<CSRPatt,Tab2d>::
spy(std::string const &filename)
template<>
void
CSRMatr<CSRPatt,Tab2d>::spy(std::string const &filename)
{
// Purpose: Matlab dumping and spy
std::string name=filename, uti=" , ";
......@@ -128,11 +130,12 @@ spy(std::string const &filename)
file_out << "I=S(:,1); J=S(:,2); S=S(:,3); A=sparse(I,J,S); spy(A);"
<< std::endl;
};
}
//version without using static (I think it is better)
// Modified by A. Gilardi. 03/02.
void colUnify(CSRMatr<CSRPatt,double> &ans, const CSRMatr<CSRPatt,double> &Mat1,
const CSRMatr<CSRPatt,double> &Mat2)
void
colUnify(CSRMatr<CSRPatt,double> &ans, const CSRMatr<CSRPatt,double> &Mat1,
const CSRMatr<CSRPatt,double> &Mat2)
{
typedef std::vector<double>::const_iterator ConstIter;
typedef std::vector<double>::iterator Iter;
......@@ -441,8 +444,8 @@ double nihil(double val){
//-----------------------------------------------------------------------
//for CSR or MSR normal pattern
DiagPreconditioner<Vector>::
DiagPreconditioner(const CSRMatr<CSRPatt,double> &M)
template<>
DiagPreconditioner<Vector>::DiagPreconditioner(const CSRMatr<CSRPatt,double> &M)
{
double loc_val=0.0;
UInt M_size=M.Patt()->nRows();
......@@ -457,8 +460,8 @@ DiagPreconditioner(const CSRMatr<CSRPatt,double> &M)
_diag(i) = 1./loc_val ;
};
}
DiagPreconditioner<Vector>::
DiagPreconditioner(const MSRMatr<double> &M)
template<>
DiagPreconditioner<Vector>::DiagPreconditioner(const MSRMatr<double> &M)
{
double loc_val=0.0;
UInt M_size=M.Patt()->nRows();
......@@ -474,8 +477,8 @@ DiagPreconditioner(const MSRMatr<double> &M)
};
}
//for VBR pattern
DiagPreconditioner<Vector>::
DiagPreconditioner(const VBRMatr<double> &M)
template<>
DiagPreconditioner<Vector>::DiagPreconditioner(const VBRMatr<double> &M)
{
double loc_val=0.0;
UInt Nblocks=M.Patt()->nRows();
......@@ -494,8 +497,8 @@ DiagPreconditioner(const VBRMatr<double> &M)
}
//for CSR block pattern
DiagPreconditioner<VectorBlock>::
DiagPreconditioner(const CSRMatr<CSRPatt,Tab2d> &M)
template<>
DiagPreconditioner<VectorBlock>::DiagPreconditioner(const CSRMatr<CSRPatt,Tab2d> &M)
{
UInt Nblocks=M.Patt()->nRows();
int blockSize =M.value()[0].N();
......@@ -517,9 +520,9 @@ DiagPreconditioner(const CSRMatr<CSRPatt,Tab2d> &M)
};
}
//solve the diagonal system
template<>
Vector
DiagPreconditioner<Vector>::
solve(const Vector &x) const
DiagPreconditioner<Vector>::solve(const Vector &x) const
{
Vector y(x.size());
......@@ -528,9 +531,9 @@ solve(const Vector &x) const
return y;
}
template<>
VectorBlock
DiagPreconditioner<VectorBlock>::
solve(const VectorBlock &x) const
DiagPreconditioner<VectorBlock>::solve(const VectorBlock &x) const
{
VectorBlock y(x.size(),x.numBlock(0).N());
......@@ -545,8 +548,8 @@ solve(const VectorBlock &x) const
//-----------------------------------------------------------------------
//for CSR or MSR normal pattern
IDPreconditioner<Vector>::
IDPreconditioner(const CSRMatr<CSRPatt,double> &M)
template<>
IDPreconditioner<Vector>::IDPreconditioner(const CSRMatr<CSRPatt,double> &M)
{
UInt M_size=M.Patt()->nRows();
Vector v_id(M_size);
......@@ -554,8 +557,8 @@ IDPreconditioner(const CSRMatr<CSRPatt,double> &M)
_diag=v_id;
}
IDPreconditioner<Vector>::
IDPreconditioner(const MSRMatr<double> &M)
template<>
IDPreconditioner<Vector>::IDPreconditioner(const MSRMatr<double> &M)
{
UInt M_size=M.Patt()->nRows();
Vector v_id(M_size);
......@@ -564,8 +567,8 @@ IDPreconditioner(const MSRMatr<double> &M)
}
//for VBR pattern
IDPreconditioner<Vector>::
IDPreconditioner(const VBRMatr<double> &M)
template<>
IDPreconditioner<Vector>::IDPreconditioner(const VBRMatr<double> &M)
{
UInt Nblocks=M.Patt()->nRows();
UInt blockSize = M.Patt()->rpntr()[1]-M.Patt()->rpntr()[0];
......@@ -575,8 +578,8 @@ IDPreconditioner(const VBRMatr<double> &M)
_diag=v_id;
}
//for CSR block pattern
IDPreconditioner<VectorBlock>::
IDPreconditioner(const CSRMatr<CSRPatt,Tab2d> &M)
template<>
IDPreconditioner<VectorBlock>::IDPreconditioner(const CSRMatr<CSRPatt,Tab2d> &M)
{
int Nblocks=M.Patt()->nRows();
int blockSize =M.value()[0].N();
......@@ -586,14 +589,16 @@ IDPreconditioner(const CSRMatr<CSRPatt,Tab2d> &M)
}
//solve the diagonal system
template<>
Vector
IDPreconditioner<Vector>::
solve(const Vector &x) const
{return x;}
IDPreconditioner<Vector>::solve(const Vector &x) const
{
return x;
}
template<>
VectorBlock
IDPreconditioner<VectorBlock>::
solve(const VectorBlock &x) const
IDPreconditioner<VectorBlock>::solve(const VectorBlock &x) const
{return x;}