- **OpenFOAM Programming & Development**
(*http://www.cfd-online.com/Forums/openfoam-programming-development/*)

- - **Boundary condition with a non-uniform gradient - groovyBC?**
(*http://www.cfd-online.com/Forums/openfoam-programming-development/101698-boundary-condition-non-uniform-gradient-groovybc.html*)

Boundary condition with a non-uniform gradient - groovyBC?Hello !
I would like to run a simulation with laplacianFoam (one variable to solve : T). On one surface of my geometry (normal to z direction), I want to impose a boundary condition where the gradient in z direction is spatially dependent with x and y. I thought that groovyBC was one way to achieve this particular BC by using gradientExpression. Before running simulations with my real expression, I tested a simple case with the gradientExpression set as a constant. But it doesn't give the right result, i.e.: results in paraview are wrong (when compared to fixedGradient BC) and show that the gradient is neither defined on the surface corressponding to the BC nor in the domain (but still calculated as there is a file gradTz in my result file). Does somebody has an example of use of this kind of BC? Here is the different cases that I tried : Extern { type groovyBC; gradientExpression "-150000"; } Extern { type groovyBC; fractionExpression "1"; gradientExpression "-150000"; } compared to : Extern { type fixedGradient; gradient uniform -150000; } Something must be missing when I use groovyBC... Thanks |

Pb solvedHello,
finally I write my own script to modify the BC. The following script creates a BC with a fixed gradient (depending on the radial position) on the surface called "Extern". gradTz = a first polynomial function when r<= 0.016, and = a second polynomial function for r>0.016. \*---------------------------------------------------------------------------*/ #include "fvCFD.H" #include "simpleControl.H" #include "fixedGradientFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" // Constants float A0 = -0.27776; float A1 = -0.039557; float A2 = -4.8824e-3; float A3 = 2.4143e-3; float A4 = -2.267e-3; float A5 = -9.5923e-4; float B0 = -0.47948; float B1 = -0.076608; float B2 = -0.014216; float B3 = -0.054171; float B4 = -0.12812; float B5 = -7.0919e-4; float B6 = 0.1443; float B7 = 0.054432; float B8 = -0.057662; float B9 = -0.044232; float B10 = -8.365e-10; //simpleControl simple(mesh); //// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //Get index of the patch where you want to have the spatially dependent BC label ExternPatchID = mesh.boundaryMesh().findPatchID("Extern"); //Get reference to boundary value fixedGradientFvPatchScalarField& Textern = refCast<fixedGradientFvPatchScalarField>(T.boundar yField()[ExternPatchID]); scalarField& gradTextern = Textern.gradient(); //Get coordinates for cell centre const fvPatchVectorField& centre = mesh.C().boundaryField()[ExternPatchID]; //scalarField x = centre.component(vector::X); //scalarField y = centre.component(vector::Y); forAll(gradTextern, cell) { const vector& xy = centre[cell]; // Info << xy[2] << endl; double rdim=(Foam::sqrt(xy[0]*xy[0]+xy[1]*xy[1])); if(rdim<=0.016){ double r=(Foam::sqrt(xy[0]*xy[0]+xy[1]*xy[1])-0.0073928)/0.00487; gradTextern[cell] = A0 + A1*r + A2*r*r + A3*pow(r,3) + A4*pow(r,4) + A5*pow(r,5); } else { double r=(Foam::sqrt(xy[0]*xy[0]+xy[1]*xy[1])-0.017786)/0.00088936; gradTextern[cell] =B0 + B1*r + B2*r*r + B3*pow(r,3) + B4*pow(r,4) + B5*pow(r,5) + B6*pow(r,6) + B7*pow(r,7) + B8*pow(r,8) + B9*pow(r,9) + B10*pow(r,10); } } T.write(); #include "write.H" Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; Info<< "End\n" << endl; return 0; } // ************************************************** *********************** // It may help somebody wanting to have a spatially dependant BC with a fixed gradient. Stephanie |

I am trying to apply a constant BC on micro-tubes surfaces inside a substrate. I have tried these:
1. { type fixedGradient; gradient uniform -10000; } 2. { type groovyBC; gradientExpression "-10000"; fractionExpression "0"; } 3. { type groovyBC; value uniform 300; gradientExpression "gradT"; variables "htot=15000.00;Tinf=293.00;k=130;gradT=htot/(k)*(Tinf-T);"; } The results show different gradient values on the walls, gradTx, gradTy and gradTz are so much more that the input values. I should mention that when I apply this BC for top surface which is horizontal I get perfect results. Here it says ( http://www.foamcfd.org/Nabla/guides/...Guidese11.html) that by "fixedgradient" we define http://www.foamcfd.org/Nabla/guides/...sGuide452x.gif . I need to define only the magnitude of temperature gradient on the tubes. Could you help me please? Thank you aa |

Hi Stephanie,
Your script file will be of guidance in my case. Thank you. I have a basic doubt. These script files are specific to the case. So are they saved in the case folder or in FOAM_SRC as a derived BC? I am just starting on writing custom BC. Your reply will be of immense help. Thanks in advance! |

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