simpleMatrix.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "simpleMatrix.H"
00028
00029
00030
00031 template<class Type>
00032 Foam::simpleMatrix<Type>::simpleMatrix(const label mSize)
00033 :
00034 scalarSquareMatrix(mSize),
00035 source_(mSize, pTraits<Type>::zero)
00036 {}
00037
00038
00039 template<class Type>
00040 Foam::simpleMatrix<Type>::simpleMatrix
00041 (
00042 const scalarSquareMatrix& matrix,
00043 const Field<Type>& source
00044 )
00045 :
00046 scalarSquareMatrix(matrix),
00047 source_(source)
00048 {}
00049
00050
00051 template<class Type>
00052 Foam::simpleMatrix<Type>::simpleMatrix(Istream& is)
00053 :
00054 scalarSquareMatrix(is),
00055 source_(is)
00056 {}
00057
00058
00059
00060
00061 template<class Type>
00062 Foam::Field<Type> Foam::simpleMatrix<Type>::solve() const
00063 {
00064 scalarSquareMatrix tmpMatrix = *this;
00065 Field<Type> sourceSol = source_;
00066
00067 Foam::solve(tmpMatrix, sourceSol);
00068
00069 return sourceSol;
00070 }
00071
00072
00073 template<class Type>
00074 Foam::Field<Type> Foam::simpleMatrix<Type>::LUsolve() const
00075 {
00076 scalarSquareMatrix luMatrix = *this;
00077 Field<Type> sourceSol = source_;
00078
00079 Foam::LUsolve(luMatrix, sourceSol);
00080
00081 return sourceSol;
00082 }
00083
00084
00085
00086
00087 template<class Type>
00088 void Foam::simpleMatrix<Type>::operator=(const simpleMatrix<Type>& m)
00089 {
00090 if (this == &m)
00091 {
00092 FatalErrorIn("simpleMatrix<Type>::operator=(const simpleMatrix<Type>&)")
00093 << "Attempted assignment to self"
00094 << abort(FatalError);
00095 }
00096
00097 if (n() != m.n())
00098 {
00099 FatalErrorIn("simpleMatrix<Type>::operator=(const simpleMatrix<Type>&)")
00100 << "Different size matrices"
00101 << abort(FatalError);
00102 }
00103
00104 if (source_.size() != m.source_.size())
00105 {
00106 FatalErrorIn("simpleMatrix<Type>::operator=(const simpleMatrix<Type>&)")
00107 << "Different size source vectors"
00108 << abort(FatalError);
00109 }
00110
00111 scalarSquareMatrix::operator=(m);
00112 source_ = m.source_;
00113 }
00114
00115
00116
00117
00118 template<class Type>
00119 Foam::simpleMatrix<Type> Foam::operator+
00120 (
00121 const simpleMatrix<Type>& m1,
00122 const simpleMatrix<Type>& m2
00123 )
00124 {
00125 return simpleMatrix<Type>
00126 (
00127 static_cast<const scalarSquareMatrix&>(m1)
00128 + static_cast<const scalarSquareMatrix&>(m2),
00129 m1.source_ + m2.source_
00130 );
00131 }
00132
00133
00134 template<class Type>
00135 Foam::simpleMatrix<Type> Foam::operator-
00136 (
00137 const simpleMatrix<Type>& m1,
00138 const simpleMatrix<Type>& m2
00139 )
00140 {
00141 return simpleMatrix<Type>
00142 (
00143 static_cast<const scalarSquareMatrix&>(m1)
00144 - static_cast<const scalarSquareMatrix&>(m2),
00145 m1.source_ - m2.source_
00146 );
00147 }
00148
00149
00150 template<class Type>
00151 Foam::simpleMatrix<Type> Foam::operator*(const scalar s, const simpleMatrix<Type>& m)
00152 {
00153 return simpleMatrix<Type>(s*m.matrix_, s*m.source_);
00154 }
00155
00156
00157
00158
00159 template<class Type>
00160 Foam::Ostream& Foam::operator<<(Ostream& os, const simpleMatrix<Type>& m)
00161 {
00162 os << static_cast<const scalarSquareMatrix&>(m) << nl << m.source_;
00163 return os;
00164 }
00165
00166
00167
Copyright © 2000-2009 OpenCFD Ltd