Reorganisation of block matrix

This commit is contained in:
Hrvoje Jasak 2010-11-05 12:10:34 +00:00
parent fad81530ca
commit d830a1ca8f
8 changed files with 110 additions and 158 deletions

View file

@ -4,5 +4,4 @@ blockVector2Solvers.C
blockCoupledScalarTransportFoam.C
EXE = $(FOAM_APPBIN)/blockCoupledScalarTransportFoam

View file

@ -1,8 +1,8 @@
EXE_INC = \
-ftemplate-depth-100 \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/blockMatrix/lnInclude
-I$(LIB_SRC)/VectorN/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lblockMatrix
-lVectorN

View file

@ -1,64 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Type
tensor2
Description
TensorN of 2 scalars.
SourceFiles
tensor2.C
\*---------------------------------------------------------------------------*/
#ifndef tensor2_H
#define tensor2_H
#include "TensorN.H"
#include "contiguous.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef TensorN<scalar, 2> tensor2;
//- Specify data associated with tensor2 type is contiguous
template<>
inline bool contiguous<tensor2>() {return true;}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,66 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Type
vector2
Description
vector2 obtained from generic VectorN
SourceFiles
vector2.C
\*---------------------------------------------------------------------------*/
#ifndef vector2_H
#define vector2_H
#include "scalar.H"
#include "VectorN.H"
#include "contiguous.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef VectorN<scalar, 2> vector2;
//- Specify data associated with vector2 type is contiguous
template<>
inline bool contiguous<vector2>() {return true;}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -327,7 +327,9 @@ Foam::tmp<Foam::Field<Type> > Foam::operator op \
BINARY_OPERATOR_TRF(Type1, Type2, op, opFunc) \
BINARY_OPERATOR_TRT(Type1, Type2, op, opFunc)
BINARY_OPERATOR_R(Type, Type, *, multiply)
// Operator multiply is not available for all types, as it expands rank
// HJ, 17/Jun/2010
// BINARY_OPERATOR_R(Type, Type, *, multiply)
#undef BINARY_OPERATOR_R
#undef BINARY_OPERATOR_FF

View file

@ -313,7 +313,7 @@ Foam::tmp<Foam::Field<Type> > Foam::operator op \
BINARY_OPERATOR_TRF(Type1, Type2, op, opFunc) \
BINARY_OPERATOR_TRT(Type1, Type2, op, opFunc)
BINARY_OPERATOR_R(Type, Type, *, multiply)
// BINARY_OPERATOR_R(Type, Type, *, multiply)
#undef BINARY_OPERATOR_R
#undef BINARY_OPERATOR_FF

View file

@ -65,7 +65,12 @@ inline TensorN<Cmpt, length>::TensorN
template <class Cmpt, int length>
inline TensorN<Cmpt, length>::TensorN(const Cmpt& tx)
{
VectorSpaceOps<TensorN<Cmpt, length>::nComponents,0>::eqOpS(*this, tx, eqOp<Cmpt>());
VectorSpaceOps<TensorN<Cmpt, length>::nComponents,0>::eqOpS
(
*this,
tx,
eqOp<Cmpt>()
);
}
@ -121,7 +126,7 @@ template <class Cmpt, int length>
inline TensorN<Cmpt, length> TensorN<Cmpt, length>::negSumDiag() const
{
TensorN<Cmpt, length> negsumdiag;
// Zero main diagonal
int diagI=0;
for (int i = 0; i < TensorN<Cmpt, length>::rowLength; i++)
@ -145,13 +150,14 @@ inline TensorN<Cmpt, length> TensorN<Cmpt, length>::negSumDiag() const
diagI += TensorN<Cmpt, length>::rowLength + 1;
}
}
return negsumdiag;
}
//- Assign to a SphericalTensorN
template <class Cmpt, int length>
inline void TensorN<Cmpt, length>::operator=(const SphericalTensorN<Cmpt, length>& st)
inline void
TensorN<Cmpt, length>::operator=(const SphericalTensorN<Cmpt, length>& st)
{
int diag=0;
for (int i = 0; i < TensorN<Cmpt, length>::nComponents; i++)
@ -171,7 +177,8 @@ inline void TensorN<Cmpt, length>::operator=(const SphericalTensorN<Cmpt, length
//- Assign to a DiagTensorN
template <class Cmpt, int length>
inline void TensorN<Cmpt, length>::operator=(const DiagTensorN<Cmpt, length>& dt)
inline void
TensorN<Cmpt, length>::operator=(const DiagTensorN<Cmpt, length>& dt)
{
int diag=0;
int k=0;
@ -270,7 +277,11 @@ operator&(const TensorN<Cmpt, length>& t1, const TensorN<Cmpt, length>& t2)
template <class Cmpt, int length>
inline typename
innerProduct<DiagTensorN<Cmpt, length>, TensorN<Cmpt, length> >::type
operator&(const DiagTensorN<Cmpt, length>& dt1, const TensorN<Cmpt, length>& t2)
operator&
(
const DiagTensorN<Cmpt, length>& dt1,
const TensorN<Cmpt, length>& t2
)
{
TensorN<Cmpt, length> result;
@ -293,7 +304,11 @@ operator&(const DiagTensorN<Cmpt, length>& dt1, const TensorN<Cmpt, length>& t2)
template <class Cmpt, int length>
inline typename
innerProduct<TensorN<Cmpt, length>, DiagTensorN<Cmpt, length> >::type
operator&(const TensorN<Cmpt, length>& t1, const DiagTensorN<Cmpt, length>& dt2)
operator&
(
const TensorN<Cmpt, length>& t1,
const DiagTensorN<Cmpt, length>& dt2
)
{
TensorN<Cmpt, length> result;
@ -315,11 +330,22 @@ operator&(const TensorN<Cmpt, length>& t1, const DiagTensorN<Cmpt, length>& dt2)
template <class Cmpt, int length>
inline typename
innerProduct<SphericalTensorN<Cmpt, length>, TensorN<Cmpt, length> >::type
operator&(const SphericalTensorN<Cmpt, length>& st1, const TensorN<Cmpt, length>& t2)
operator&
(
const SphericalTensorN<Cmpt, length>& st1,
const TensorN<Cmpt, length>& t2
)
{
const Cmpt& s = st1.v_[0];
TensorN<Cmpt, length> res;
VectorSpaceOps<TensorN<Cmpt, length>::nComponents,0>::opSV(res, s, t2, multiplyOp<Cmpt>());
VectorSpaceOps<TensorN<Cmpt, length>::nComponents,0>::opSV
(
res,
s,
t2,
multiplyOp<Cmpt>()
);
return res;
}
@ -328,11 +354,22 @@ operator&(const SphericalTensorN<Cmpt, length>& st1, const TensorN<Cmpt, length>
template <class Cmpt, int length>
inline typename
innerProduct<TensorN<Cmpt, length>, SphericalTensorN<Cmpt, length> >::type
operator&(const TensorN<Cmpt, length>& t1, const SphericalTensorN<Cmpt, length>& st2)
operator&
(
const TensorN<Cmpt, length>& t1,
const SphericalTensorN<Cmpt, length>& st2
)
{
const Cmpt& s = st2.v_[0];
TensorN<Cmpt, length> res;
VectorSpaceOps<TensorN<Cmpt, length>::nComponents,0>::opVS(res, t1, s, multiplyOp<Cmpt>());
VectorSpaceOps<TensorN<Cmpt, length>::nComponents,0>::opVS
(
res,
t1,
s,
multiplyOp<Cmpt>()
);
return res;
}
@ -413,7 +450,14 @@ inline TensorN<Cmpt,length>
operator+(const TensorN<Cmpt,length>& t1, const TensorN<Cmpt,length>& t2)
{
TensorN<Cmpt,length> res;
VectorSpaceOps<TensorN<Cmpt,length>::nComponents,0>::op(res, t1, t2, plusOp<Cmpt>());
VectorSpaceOps<TensorN<Cmpt,length>::nComponents,0>::op
(
res,
t1,
t2,
plusOp<Cmpt>()
);
return res;
}
@ -457,7 +501,11 @@ operator+(const DiagTensorN<Cmpt,length>& dt1, const TensorN<Cmpt,length>& t2)
//- Addition of TensorN and SphericalTensorN
template <class Cmpt, int length>
inline TensorN<Cmpt,length>
operator+(const TensorN<Cmpt,length>& t1, const SphericalTensorN<Cmpt,length>& st2)
operator+
(
const TensorN<Cmpt,length>& t1,
const SphericalTensorN<Cmpt,length>& st2
)
{
TensorN<Cmpt, length> result(t1);
@ -476,7 +524,11 @@ operator+(const TensorN<Cmpt,length>& t1, const SphericalTensorN<Cmpt,length>& s
//- Addition of SphericalTensorN and TensorN
template <class Cmpt, int length>
inline TensorN<Cmpt,length>
operator+(const SphericalTensorN<Cmpt,length>& st1, const TensorN<Cmpt,length>& t2)
operator+
(
const SphericalTensorN<Cmpt,length>& st1,
const TensorN<Cmpt,length>& t2
)
{
TensorN<Cmpt, length> result(t2);
@ -498,7 +550,14 @@ inline TensorN<Cmpt,length>
operator-(const TensorN<Cmpt,length>& t1, const TensorN<Cmpt,length>& t2)
{
TensorN<Cmpt,length> res;
VectorSpaceOps<TensorN<Cmpt,length>::nComponents,0>::op(res, t1, t2, minusOp<Cmpt>());
VectorSpaceOps<TensorN<Cmpt,length>::nComponents,0>::op
(
res,
t1,
t2,
minusOp<Cmpt>()
);
return res;
}
@ -542,7 +601,11 @@ operator-(const DiagTensorN<Cmpt,length>& dt1, const TensorN<Cmpt,length>& t2)
//- Subtraction of TensorN and SphericalTensorN
template <class Cmpt, int length>
inline TensorN<Cmpt,length>
operator-(const TensorN<Cmpt,length>& t1, const SphericalTensorN<Cmpt,length>& st2)
operator-
(
const TensorN<Cmpt,length>& t1,
const SphericalTensorN<Cmpt,length>& st2
)
{
TensorN<Cmpt, length> result(t1);
@ -561,7 +624,11 @@ operator-(const TensorN<Cmpt,length>& t1, const SphericalTensorN<Cmpt,length>& s
//- Subtraction of SphericalTensorN and TensorN
template <class Cmpt, int length>
inline TensorN<Cmpt,length>
operator-(const SphericalTensorN<Cmpt,length>& st1, const TensorN<Cmpt,length>& t2)
operator-
(
const SphericalTensorN<Cmpt,length>& st1,
const TensorN<Cmpt,length>& t2
)
{
TensorN<Cmpt, length> result(-t2);
@ -623,7 +690,11 @@ operator/(const TensorN<Cmpt,length>& t1, const DiagTensorN<Cmpt,length>& dt2)
//- Inner Product of a SphericalTensorN and an inverse TensorN
template <class Cmpt, int length>
inline TensorN<Cmpt,length>
operator/(const SphericalTensorN<Cmpt,length>& st1, const TensorN<Cmpt,length>& t2)
operator/
(
const SphericalTensorN<Cmpt,length>& st1,
const TensorN<Cmpt,length>& t2
)
{
return st1.v_[0] * inv(t2);
}
@ -632,7 +703,11 @@ operator/(const SphericalTensorN<Cmpt,length>& st1, const TensorN<Cmpt,length>&
//- Inner Product of a TensorN and an inverse SphericalTensorN
template <class Cmpt, int length>
inline TensorN<Cmpt,length>
operator/(const TensorN<Cmpt,length>& t1, const SphericalTensorN<Cmpt,length>& st2)
operator/
(
const TensorN<Cmpt,length>& t1,
const SphericalTensorN<Cmpt,length>& st2
)
{
TensorN<Cmpt, length> result;
@ -759,7 +834,8 @@ inline TensorN<Cmpt, length> inv(const TensorN<Cmpt, length>& t)
label iRow=0, iCol=0;
Cmpt largestCoeff, temp;
Cmpt __restrict__ *srcIter, *destIter;
Cmpt* __restrict__ srcIter;
Cmpt* __restrict__ destIter;
// Lists used for bookkeeping on the pivoting
List<label> indexCol(length), indexRow(length), iPivot(length);

View file

@ -79,7 +79,10 @@ public:
inline VectorN();
//- Construct given VectorSpace
inline VectorN(const VectorSpace<VectorN<Cmpt, length>, Cmpt, length>&);
inline VectorN
(
const VectorSpace<VectorN<Cmpt, length>, Cmpt, length>&
);
//- Construct given component value. Special use only!
explicit inline VectorN(const Cmpt& vx);
@ -97,8 +100,10 @@ public:
inline Cmpt& operator()(const direction i);
//- Componentwise multiply
inline VectorN<Cmpt, length> cmptMultiply(const VectorN<Cmpt, length>&);
inline VectorN<Cmpt, length> cmptMultiply
(
const VectorN<Cmpt, length>&
);
};