|
|
|
lduMatrixTemplates.CGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Description 00026 lduMatrix member H operations. 00027 00028 \*---------------------------------------------------------------------------*/ 00029 00030 #include "lduMatrix.H" 00031 00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00033 00034 template<class Type> 00035 Foam::tmp<Foam::Field<Type> > Foam::lduMatrix::H(const Field<Type>& psi) const 00036 { 00037 tmp<Field<Type> > tHpsi 00038 ( 00039 new Field<Type>(lduAddr().size(), pTraits<Type>::zero) 00040 ); 00041 00042 if (lowerPtr_ || upperPtr_) 00043 { 00044 Field<Type> & Hpsi = tHpsi(); 00045 00046 Type* __restrict__ HpsiPtr = Hpsi.begin(); 00047 00048 const Type* __restrict__ psiPtr = psi.begin(); 00049 00050 const label* __restrict__ uPtr = lduAddr().upperAddr().begin(); 00051 const label* __restrict__ lPtr = lduAddr().lowerAddr().begin(); 00052 00053 const scalar* __restrict__ lowerPtr = lower().begin(); 00054 const scalar* __restrict__ upperPtr = upper().begin(); 00055 00056 register const label nFaces = upper().size(); 00057 00058 for (register label face=0; face<nFaces; face++) 00059 { 00060 HpsiPtr[uPtr[face]] -= lowerPtr[face]*psiPtr[lPtr[face]]; 00061 HpsiPtr[lPtr[face]] -= upperPtr[face]*psiPtr[uPtr[face]]; 00062 } 00063 } 00064 00065 return tHpsi; 00066 } 00067 00068 template<class Type> 00069 Foam::tmp<Foam::Field<Type> > 00070 Foam::lduMatrix::H(const tmp<Field<Type> >& tpsi) const 00071 { 00072 tmp<Field<Type> > tHpsi(H(tpsi())); 00073 tpsi.clear(); 00074 return tHpsi; 00075 } 00076 00077 00078 template<class Type> 00079 Foam::tmp<Foam::Field<Type> > 00080 Foam::lduMatrix::faceH(const Field<Type>& psi) const 00081 { 00082 if (lowerPtr_ || upperPtr_) 00083 { 00084 const scalarField& Lower = const_cast<const lduMatrix&>(*this).lower(); 00085 const scalarField& Upper = const_cast<const lduMatrix&>(*this).upper(); 00086 00087 const unallocLabelList& l = lduAddr().lowerAddr(); 00088 const unallocLabelList& u = lduAddr().upperAddr(); 00089 00090 tmp<Field<Type> > tfaceHpsi(new Field<Type> (Lower.size())); 00091 Field<Type> & faceHpsi = tfaceHpsi(); 00092 00093 for (register label face=0; face<l.size(); face++) 00094 { 00095 faceHpsi[face] = Upper[face]*psi[u[face]] - Lower[face]*psi[l[face]]; 00096 } 00097 00098 return tfaceHpsi; 00099 } 00100 else 00101 { 00102 FatalErrorIn("lduMatrix::faceH(const Field<Type>& psi) const") 00103 << "Cannot calculate faceH" 00104 " the matrix does not have any off-diagonal coefficients." 00105 << exit(FatalError); 00106 00107 return tmp<Field<Type> >(NULL); 00108 } 00109 } 00110 00111 00112 template<class Type> 00113 Foam::tmp<Foam::Field<Type> > 00114 Foam::lduMatrix::faceH(const tmp<Field<Type> >& tpsi) const 00115 { 00116 tmp<Field<Type> > tfaceHpsi(faceH(tpsi())); 00117 tpsi.clear(); 00118 return tfaceHpsi; 00119 } 00120 00121 00122 // ************************************************************************* // |