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

[swak4Foam] Boundary condition with a non-uniform gradient - groovyBC?

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 4 Post By STiss

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 11, 2012, 04:43
Default Boundary condition with a non-uniform gradient - groovyBC?
  #1
New Member
 
Stephanie Tissoires
Join Date: May 2012
Posts: 2
Rep Power: 0
STiss is on a distinguished road
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
STiss is offline   Reply With Quote

Old   May 23, 2012, 12:21
Default Pb solved
  #2
New Member
 
Stephanie Tissoires
Join Date: May 2012
Posts: 2
Rep Power: 0
STiss is on a distinguished road
Hello,

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
STiss is offline   Reply With Quote

Old   September 19, 2012, 12:19
Default
  #3
New Member
 
anonymous
Join Date: Sep 2012
Location: Miami, USA
Posts: 7
Rep Power: 13
socrates is on a distinguished road
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
. I need to define only the magnitude of temperature gradient on the tubes.

Could you help me please?

Thank you

aa
socrates is offline   Reply With Quote

Old   October 11, 2013, 02:04
Default
  #4
Senior Member
 
Srivathsan N
Join Date: Jan 2013
Location: India
Posts: 101
Rep Power: 13
Sherlock_1812 is on a distinguished road
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!
__________________
Regards,

Srivaths
Sherlock_1812 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
Boundary Conditions MtnRunBeachBum OpenFOAM Pre-Processing 1 April 30, 2015 16:33
Divergent temperature in chtMultiRegion(Simple)Foam akrasemann OpenFOAM Running, Solving & CFD 13 March 24, 2014 02:54
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 07:00
[swak4Foam] Boundary Conditions with GroovyBC, Normal Gradient treima OpenFOAM Community Contributions 2 January 26, 2013 02:37
Boundary condition setting for non-premixed combustion using reactingFoam skyopener OpenFOAM 0 May 23, 2010 22:55


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