CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

How the boundary conditions are disposed into the matrix coefficient?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   February 20, 2013, 12:39
Default How the boundary conditions are disposed into the matrix coefficient?
  #1
Member
 
Xiangyin Meng
Join Date: Jun 2012
Location: London
Posts: 69
Rep Power: 5
mxylondon is on a distinguished road
Hi guys, does any one know?
How the boundary conditions are disposed into the matrix A of Ax=B?
In other word, which section of source code I need to find about it?

Cheers
mxylondon is offline   Reply With Quote

Old   March 1, 2013, 17:03
Default
  #2
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 418
Rep Power: 15
santiagomarquezd will become famous soon enough
Hi the BC contributions (internalCoffs and boundaryCoeffs) to the matrix and RHS are calculated where the discrete version of the differential operators is assembled. These contributions are stored to be inserted into the matrix prior to the solution. In the case of a case of scalar transport and the div operator the lines are 98 in gaussConvectionScheme.C

Code:
00066 template<class Type>
00067 tmp<fvMatrix<Type> >
00068 gaussConvectionScheme<Type>::fvmDiv
00069 (
00070     const surfaceScalarField& faceFlux,
00071     const GeometricField<Type, fvPatchField, volMesh>& vf
00072 ) const
00073 {
00074     tmp<surfaceScalarField> tweights = tinterpScheme_().weights(vf);
00075     const surfaceScalarField& weights = tweights();
00076 
00077     tmp<fvMatrix<Type> > tfvm
00078     (
00079         new fvMatrix<Type>
00080         (
00081             vf,
00082             faceFlux.dimensions()*vf.dimensions()
00083         )
00084     );
00085     fvMatrix<Type>& fvm = tfvm();
00086 
00087     fvm.lower() = -weights.internalField()*faceFlux.internalField();
00088     fvm.upper() = fvm.lower() + faceFlux.internalField();
00089     fvm.negSumDiag();
00090 
00091     forAll(vf.boundaryField(), patchI)
00092     {
00093         const fvPatchField<Type>& psf = vf.boundaryField()[patchI];
00094         const fvsPatchScalarField& patchFlux = faceFlux.boundaryField()[patchI];
00095         const fvsPatchScalarField& pw = weights.boundaryField()[patchI];
00096 
00097         fvm.internalCoeffs()[patchI] = patchFlux*psf.valueInternalCoeffs(pw);
00098         fvm.boundaryCoeffs()[patchI] = -patchFlux*psf.valueBoundaryCoeffs(pw);
00099     }
00100 
00101     if (tinterpScheme_().corrected())
00102     {
00103         fvm += fvc::surfaceIntegrate(faceFlux*tinterpScheme_().correction(vf));
00104     }
00105 
00106     return tfvm;
00107 }
and 106 and 109 in fvScalarMatrix.C

Code:
00095 template<>
00096 Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve
00097 (
00098     const dictionary& solverControls
00099 )
00100 {
00101     GeometricField<scalar, fvPatchField, volMesh>& psi =
00102         const_cast<GeometricField<scalar, fvPatchField, volMesh>&>
00103         (fvMat_.psi());
00104 
00105     scalarField saveDiag(fvMat_.diag());
00106     fvMat_.addBoundaryDiag(fvMat_.diag(), 0);
00107 
00108     scalarField totalSource(fvMat_.source());
00109     fvMat_.addBoundarySource(totalSource, false);
00110 
00111     // assign new solver controls
00112     solver_->read(solverControls);
00113 
00114     lduMatrix::solverPerformance solverPerf = solver_->solve
00115     (
00116         psi.internalField(),
00117         totalSource
00118     );
00119 
00120     solverPerf.print();
00121 
00122     fvMat_.diag() = saveDiag;
00123 
00124     psi.correctBoundaryConditions();
00125 
00126     psi.mesh().setSolverPerformance(psi.name(), solverPerf);
00127 
00128     return solverPerf;
00129 }
Regards.
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Post-doctoral Fellow
Research Center for Computational Mechanics (CIMEC) - CONICET/FICH-UNL
T.E.: 54-342-4511594 Ext. 1005
Güemes 3450 - (3000) Santa Fe
Santa Fe - Argentina
http://www.cimec.org.ar
santiagomarquezd is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Constant velocity of the material Sas CFX 15 July 13, 2010 08:56
RPM in Wind Turbine Pankaj CFX 9 November 23, 2009 05:05
CFX doesn't continue calculation... mactech001 CFX 6 November 15, 2009 22:25
Simulation of a single bubble with a VOF-method Suzzn CFX 18 October 2, 2009 04:18
A problem about setting boundary conditions lyang Main CFD Forum 0 September 19, 1999 18:29


All times are GMT -4. The time now is 05:17.