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/)
-   -   define a new boundary condition (https://www.cfd-online.com/Forums/openfoam-programming-development/110896-define-new-boundary-condition.html)

mscheng December 24, 2012 08:44

define a new boundary condition
 
Hi FOAMers,

I want to implement a new boundary condition : Tinlet=(averaged Toutlet)*lambda, where lambda is constant. so how to implement it.

mkraposhin December 30, 2012 12:54

You need to implement fixedValue B.C., (create derived class, like lambdaTInletFvPatchScalarField for example). Then in method lambdaTInletFvPatchScalarField::updateCoeffs() You must implement something like that

//init some intermediate variables
.........
.........

const volScalarField& T = mesh.lookupObject<volScalarField>("T");
outPatchId = mesh.boundaryMesh().findPatchID("outlet");

scalar ToutAv = gSum(T.boundaryField()[outPatchId]*mesh.magSf().boundaryField()[outPatchId]) /
gSum(mesh.magSf().boundaryField()[outPatchId]);

scalarField Tinlet (this->size(), ToutAv*lambda_);

operator == (Tinle);

fixedValueFvPatchField<scalar>::updateCoeffs();

This B.C. must be implemented in a new dynamic library, which You can link to solver in file fvSolution/controlDict

gschaider January 5, 2013 18:46

Quote:

Originally Posted by mscheng (Post 398901)
Hi FOAMers,

I want to implement a new boundary condition : Tinlet=(averaged Toutlet)*lambda, where lambda is constant. so how to implement it.

I personally would recommend groovyBC for this. Assuming your outlet-patch is named outlet something like

Code:

variables (
  "Tout{outlet}=average(T);"
  "lambda=0.5;"
);
valueExpression "lambda*Tout";

would do the trick


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