fvScalarMatrix.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 "fvScalarMatrix.H"
00028 #include "zeroGradientFvPatchFields.H"
00029
00030
00031
00032 template<>
00033 void Foam::fvMatrix<Foam::scalar>::setComponentReference
00034 (
00035 const label patchi,
00036 const label facei,
00037 const direction,
00038 const scalar value
00039 )
00040 {
00041 if (psi_.needReference())
00042 {
00043 if (Pstream::master())
00044 {
00045 internalCoeffs_[patchi][facei] +=
00046 diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]];
00047
00048 boundaryCoeffs_[patchi][facei] +=
00049 diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]]
00050 *value;
00051 }
00052 }
00053 }
00054
00055
00056 template<>
00057 Foam::autoPtr<Foam::fvMatrix<Foam::scalar>::fvSolver>
00058 Foam::fvMatrix<Foam::scalar>::solver
00059 (
00060 const dictionary& solverControls
00061 )
00062 {
00063 if (debug)
00064 {
00065 Info<< "fvMatrix<scalar>::solver(const dictionary& solverControls) : "
00066 "solver for fvMatrix<scalar>"
00067 << endl;
00068 }
00069
00070 scalarField saveDiag = diag();
00071 addBoundaryDiag(diag(), 0);
00072
00073 autoPtr<fvMatrix<scalar>::fvSolver> solverPtr
00074 (
00075 new fvMatrix<scalar>::fvSolver
00076 (
00077 *this,
00078 lduMatrix::solver::New
00079 (
00080 psi_.name(),
00081 *this,
00082 boundaryCoeffs_,
00083 internalCoeffs_,
00084 psi_.boundaryField().interfaces(),
00085 solverControls
00086 )
00087 )
00088 );
00089
00090 diag() = saveDiag;
00091
00092 return solverPtr;
00093 }
00094
00095
00096 template<>
00097 Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve
00098 (
00099 const dictionary& solverControls
00100 )
00101 {
00102 scalarField saveDiag = fvMat_.diag();
00103 fvMat_.addBoundaryDiag(fvMat_.diag(), 0);
00104
00105 scalarField totalSource = fvMat_.source();
00106 fvMat_.addBoundarySource(totalSource, false);
00107
00108
00109 solver_->read(solverControls);
00110
00111 lduMatrix::solverPerformance solverPerf =
00112 solver_->solve(fvMat_.psi().internalField(), totalSource);
00113
00114 solverPerf.print();
00115
00116 fvMat_.diag() = saveDiag;
00117
00118 fvMat_.psi().correctBoundaryConditions();
00119
00120 return solverPerf;
00121 }
00122
00123
00124 template<>
00125 Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve
00126 (
00127 const dictionary& solverControls
00128 )
00129 {
00130 if (debug)
00131 {
00132 Info<< "fvMatrix<scalar>::solve(const dictionary& solverControls) : "
00133 "solving fvMatrix<scalar>"
00134 << endl;
00135 }
00136
00137 scalarField saveDiag = diag();
00138 addBoundaryDiag(diag(), 0);
00139
00140 scalarField totalSource = source_;
00141 addBoundarySource(totalSource, false);
00142
00143
00144 lduMatrix::solverPerformance solverPerf = lduMatrix::solver::New
00145 (
00146 psi_.name(),
00147 *this,
00148 boundaryCoeffs_,
00149 internalCoeffs_,
00150 psi_.boundaryField().interfaces(),
00151 solverControls
00152 )->solve(psi_.internalField(), totalSource);
00153
00154 solverPerf.print();
00155
00156 diag() = saveDiag;
00157
00158 psi_.correctBoundaryConditions();
00159
00160 return solverPerf;
00161 }
00162
00163
00164 template<>
00165 Foam::tmp<Foam::scalarField> Foam::fvMatrix<Foam::scalar>::residual() const
00166 {
00167 scalarField boundaryDiag(psi_.size(), 0.0);
00168 addBoundaryDiag(boundaryDiag, 0);
00169
00170 tmp<scalarField> tres
00171 (
00172 lduMatrix::residual
00173 (
00174 psi_.internalField(),
00175 source_ - boundaryDiag*psi_.internalField(),
00176 boundaryCoeffs_,
00177 psi_.boundaryField().interfaces(),
00178 0
00179 )
00180 );
00181
00182 addBoundarySource(tres());
00183
00184 return tres;
00185 }
00186
00187
00188 template<>
00189 Foam::tmp<Foam::volScalarField> Foam::fvMatrix<Foam::scalar>::H() const
00190 {
00191 tmp<volScalarField> tHphi
00192 (
00193 new volScalarField
00194 (
00195 IOobject
00196 (
00197 "H("+psi_.name()+')',
00198 psi_.instance(),
00199 psi_.mesh(),
00200 IOobject::NO_READ,
00201 IOobject::NO_WRITE
00202 ),
00203 psi_.mesh(),
00204 dimensions_/dimVol,
00205 zeroGradientFvPatchScalarField::typeName
00206 )
00207 );
00208 volScalarField& Hphi = tHphi();
00209
00210 Hphi.internalField() = (lduMatrix::H(psi_.internalField()) + source_);
00211 addBoundarySource(Hphi.internalField());
00212
00213 Hphi.internalField() /= psi_.mesh().V();
00214 Hphi.correctBoundaryConditions();
00215
00216 return tHphi;
00217 }
00218
00219
00220 template<>
00221 Foam::tmp<Foam::volScalarField> Foam::fvMatrix<Foam::scalar>::H1() const
00222 {
00223 tmp<volScalarField> tH1
00224 (
00225 new volScalarField
00226 (
00227 IOobject
00228 (
00229 "H(1)",
00230 psi_.instance(),
00231 psi_.mesh(),
00232 IOobject::NO_READ,
00233 IOobject::NO_WRITE
00234 ),
00235 psi_.mesh(),
00236 dimensions_/(dimVol*psi_.dimensions()),
00237 zeroGradientFvPatchScalarField::typeName
00238 )
00239 );
00240 volScalarField& H1_ = tH1();
00241
00242 H1_.internalField() = lduMatrix::H1();
00243
00244
00245 H1_.internalField() /= psi_.mesh().V();
00246 H1_.correctBoundaryConditions();
00247
00248 return tH1;
00249 }
00250
00251
00252
Copyright © 2000-2009 OpenCFD Ltd