CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

boundary conditions effect on Matrix coefficients

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 20, 2015, 04:28
Default boundary conditions effect on Matrix coefficients
  #1
New Member
 
Join Date: Oct 2015
Posts: 15
Rep Power: 10
martel is on a distinguished road
Hi all,

I am trying to understand how openfoam generates the matrices for the differential operators.

I have programmed a simple example for the laplacian operator:

Code:
// Define a matrix that contains the coefficients of the Laplacian

    fvScalarMatrix TEqnLaplaciano 
	  ( 
	   fvm::laplacian(DT, T) 
	    ); 

// Extract source term, matrix diagonal, upper and lower nonzero elements and their indices

    scalarField& source_  = TEqnLaplaciano.source();
    scalarField& lower_   = TEqnLaplaciano.lower();
    scalarField& upper_   = TEqnLaplaciano.upper();
    scalarField& diag_    = TEqnLaplaciano.diag();

    const unallocLabelList& l_ = TEqnLaplaciano.lduAddr().lowerAddr();
    const unallocLabelList& u_ = TEqnLaplaciano.lduAddr().upperAddr();

    Info<< "\n diagvalues:  \n " << diag_  << endl;
    Info<< "\n lowervalues: \n " << lower_ << endl;
    Info<< "\n lowerAddr:   \n " << l_     << endl;
    Info<< "\n Uppervalues: \n " << upper_ << endl;
    Info<< "\n UpperAddr:   \n " << u_     << endl;

    Info<< "\n sourcevalues:  \n " << source_  << endl;
And it gives:
* Matrix Diagonal terms
* Matrix out of diagonal terms
* Indices of the out of diagonal terms
* source terms (right hand side of the linear system) (zero in my example)

But the effect of the boundary conditions is not yet included in the matrix and source term that I get.

My question is:

How can I get the contribution (coefficients and indices) of the Boundary Conditions to the matrix coefficients (diag and out-of-diag) and to the source term?


Thanks in advance for your help.

--CME
martel is offline   Reply With Quote

Old   February 24, 2016, 17:16
Default
  #2
Member
 
Join Date: Aug 2012
Posts: 33
Rep Power: 13
gigilentini8 is on a distinguished road
same question here. any news on this?
gigilentini8 is offline   Reply With Quote

Old   March 1, 2016, 10:46
Default
  #3
New Member
 
Join Date: Oct 2015
Posts: 15
Rep Power: 10
martel is on a distinguished road
Quote:
Originally Posted by gigilentini8 View Post
same question here. any news on this?
Hi gigilentin8i,

Not much on this unfortunaltely:

I have use these two extra lines to get the information from the boundary conditions:
Code:
 Info <<"\n  TEqnLaplaciano.boundaryCoeffs()     \n " <<       TEqnLaplaciano.boundaryCoeffs() << endl;
    Info <<"\n  TEqnLaplaciano.internalCoeffs()     \n " <<       TEqnLaplaciano.internalCoeffs() << endl;
But I have realized that OpenFoam does not construct the complete matrix of the laplacian because the non-orhogonal contributions to the operator are ALWAYS computed explicitely. So now I am trying to export the mesh coefficients to build the matrices myself in MATLAB.

--Carlos
martel is offline   Reply With Quote

Old   March 1, 2016, 19:47
Default
  #4
Member
 
Join Date: Aug 2012
Posts: 33
Rep Power: 13
gigilentini8 is on a distinguished road
Thanks Carlos,

this explains why I am getting incorrect results for the eigenvalues/functions of the laplacian when the mesh is non cartesian.
does this mean that the additional non-orthogonal contribution are in TEqn.source()? If this is the case I could just try to put them back in the matrix.
or how about using an uncorrected or fourth scheme?

I was able to add the boundary condition contribution to the matrix with this code

Code:
    forAll(TEqn.internalCoeffs(), patchI)
       {
        const label*  fPtr = TEqn.lduAddr().patchAddr(patchI).begin();
        Field<double> intF(TEqn.internalCoeffs()[patchI].component(0));
        forAll(TEqn.lduAddr().patchAddr(patchI), faceI)
          {
              label fCell = fPtr[faceI];
              diag(fCell) -= intF[faceI];
          }
       }
Quote:
Originally Posted by martel View Post
Hi gigilentin8i,

Not much on this unfortunaltely:

I have use these two extra lines to get the information from the boundary conditions:
Code:
 Info <<"\n  TEqnLaplaciano.boundaryCoeffs()     \n " <<       TEqnLaplaciano.boundaryCoeffs() << endl;
    Info <<"\n  TEqnLaplaciano.internalCoeffs()     \n " <<       TEqnLaplaciano.internalCoeffs() << endl;
But I have realized that OpenFoam does not construct the complete matrix of the laplacian because the non-orhogonal contributions to the operator are ALWAYS computed explicitely. So now I am trying to export the mesh coefficients to build the matrices myself in MATLAB.

--Carlos
gigilentini8 is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the height of the stream in the free channel kevinmccartin CFX 12 October 13, 2022 21:43
CGNS Boundary conditions using SU2 denzell SU2 3 July 9, 2018 05:58
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 07:00
How the boundary conditions are disposed into the matrix coefficient? mxylondon OpenFOAM 1 March 1, 2013 16:03
Matrix coefficients from boundary conditions how tehache OpenFOAM Running, Solving & CFD 10 October 16, 2011 18:26


All times are GMT -4. The time now is 18:51.