CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How the cyclic boundary condition affect the coefficient matrix (https://www.cfd-online.com/Forums/openfoam-programming-development/111378-how-cyclic-boundary-condition-affect-coefficient-matrix.html)

codinging January 5, 2013 11:17

How the cyclic boundary condition affect the coefficient matrix
 
Hi all,

does anyone examine on how the cyclic boundary condition is implemented? I apply the cyclic boundary condition to the inlet and outlet in a 2D pipe flow, and it works well (generating parabolic flow with right maximum velocity). But I find that the neighbor/owner list of the cyclic boundary generated by 'blockMesh' has no difference with that of normal inlet/outlet boundary.
I think the crucial code is not in 'cyclicFvPatchField.C'. can someone kindly give me some hint which part in OpenFOAM deal with the cyclic boundary in generating the coefficient matrix? Thanks.


Mill

martel October 19, 2015 12:25

Quote:

Originally Posted by codinging (Post 400209)
Hi all,

does anyone examine on how the cyclic boundary condition is implemented? I apply the cyclic boundary condition to the inlet and outlet in a 2D pipe flow, and it works well (generating parabolic flow with right maximum velocity). But I find that the neighbor/owner list of the cyclic boundary generated by 'blockMesh' has no difference with that of normal inlet/outlet boundary.
I think the crucial code is not in 'cyclicFvPatchField.C'. can someone kindly give me some hint which part in OpenFOAM deal with the cyclic boundary in generating the coefficient matrix? Thanks.


Mill

Hi codinging,

Did you find any information related to your question of how cyclic boundary conditions modify the coefficient matrix?

Thanks in advance for your help.

--C

codinging October 20, 2015 06:44

treatment of cyclic boundary conditions
 
Hi Martel,

As far as I know, the coefficient matrix is not affected by the cyclic boundary conditions. If you output the coefficient matrix for a Dirichlet boundary or a Neumann boundary and compare it with that for a cyclic boundary, you would find they are the same. The treatment of cyclic boundary is similar to the treatment of the processorPatch. Functions or variables including valueInternalCoeffs(), valueBoundaryCoeffs() are affected.

Cheers,
Mill

martel October 20, 2015 06:58

Thank you for your quick reply codinging.

Please let me ask you another related question:
I am trying to understand how openfoam generates the matrices for the differential operators.

I have programmed a simple example for the laplacian operator:

Quote:

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

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

// Output complete fvScalarMatrix to console

Info<< "TEqnLaplaciano:\n\n" << TEqnLaplaciano << endl;

// 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;


// Extract source term and matrix coefficients contribution due to the boundary conditions

Info <<"\n TEqnLaplaciano.boundaryCoeffs() \n " << TEqnLaplaciano.boundaryCoeffs() << endl;
Info <<"\n TEqnLaplaciano.internalCoeffs() \n " << TEqnLaplaciano.internalCoeffs() << 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)
* Boundary conditions contribution to the source term coefficients
* Boundary conditions contribution to the matrix term coefficients

As you said, 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 indices (I already have the values) of the Boundary Conditions contribution to the matrix coefficients and to the source term?


Thanks in advance for your help.

--CME

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

codinging October 20, 2015 07:19

boundary conditions
 
Hi Martel,

you are correct that boundary condition contribution to the source terms and the coefficient matrix are separately store in internalCoeffs() and boundaryCoeffs(). I would suggest you to have a look at the D(), H(), A() operators of a fvMatrix. e.g. in fvMatrix.C

template<class Type>
Foam::tmp<Foam::scalarField> Foam::fvMatrix<Type>::D() const
{
tmp<scalarField> tdiag(new scalarField(diag()));
addCmptAvBoundaryDiag(tdiag());
return tdiag;
}

'addCmptAvBoundaryDiag(tdiag())' considers the contribution for the treatment of differential operators related to a boundary.

In addition to this, you might find how internalCoeffs() and boundaryCoeffs() are generated by looking at a specific implementation of a boundary condition, e.g. 'fixedValueFvPatchField.Cí for the Dirichlet boundary condition.


Cheers,
Mill

martel October 20, 2015 07:26

Thanks for the comment


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