|
[Sponsors] |
August 8, 2019, 19:49 |
Non uniform temperature gradient
|
#1 |
New Member
Nabeel Khaleel
Join Date: Jun 2016
Posts: 15
Rep Power: 10 |
Hello everyone
I want to apply a non uniform temperature gradient around a pipe... But honestly I don't know which one is suitable... The boundaries I know are only for value not gradient like coded fixedValue, fixed profile etc... Please could you give me a hint to do it... I am very beginnerer to the brogramming. Anyhelp is really appreciated. Thanks |
|
August 9, 2019, 02:58 |
|
#2 |
New Member
Ashwin
Join Date: Mar 2018
Location: Houston Texas
Posts: 10
Rep Power: 8 |
Can you try codedMixed? I am pasting a simple codedMixed bc for pressure which will simply open and close as a sinusoidal. I do not change the gradient, but maybe you can try changing this->refGradient to the value you want in your T boundary file ..
outlet2 { type codedMixed; refValue uniform 0; refGradient uniform 0; valueFraction uniform 0; redirectType PressBC; // name of generated BC codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude #}; codeInclude #{ #include "fvCFD.H" #include <cmath> #include <iostream> #include <fstream> #}; code #{ // this->refValue() = vector(1, 0, 0)*min(10, 0.1*this->db().time().value()); // this->refValue() = 0; // outlet // this->refGrad() = 0; // block // if(this-->db().time().value()% 5==0){ // // } //const fvMesh & my_mesh =db().lookupObject<fvMesh>; const fvPatch& my_patch = patch(); // const fvPatch & my_patch = patch(); //const vectorField& face_center = my_patch.Cf(); scalarField& patch_press = *this; patch_press = patchInternalField(); Info << "pressure at Patch faci I " << patch_press[0] <<endl; //const UList<label> faceList = faceCells(); //Info << faceList << endl; const double FREQ1=0.25; // *****!!!--->CHANGE THIS AS NEEDED!!!! const double omega1 = 2*M_PI*FREQ1; const scalar time_curr1 = this->db().time().value(); //const scalar time_old = db().oldTime().value(); scalar factor1 = sin(omega1*time_curr1); //const volScalarField& my_po = db().lookupObject<volScalarField>("p"); // //const volScalarField& my_p = this->db().lookupObject<volScalarField>("p"); //Info<< my_p[0]<<" is the pressure at cell id 0"<<this->db().time().value()<< endl; //Info<< my_po[0]<<" is the pressure at cell id 0 at old time"<<this->db().oldTime().value()<< endl; scalar tot_press =0.0; scalar avg_area = 0.0; scalar avg_press =0.0; forAll(patch_press,pi) { tot_press = tot_press+patch_press[pi]*my_patch.magSf()[pi]; avg_area = avg_area + my_patch.magSf()[pi]; } avg_press = tot_press/avg_area; Info<< avg_area << "total_area"<< endl; Info<< avg_press<< "averag pressure"<< endl; if(factor1 <= 0) { factor1 = -1*factor1; // factor1 =1-factor1; } // else // { // factor1 = 1 - factor1; // } // forAll(Cf, faceI) //{ // this->valueFraction() = abs(sin(omega*(this->db().time().value()))); this->valueFraction() = factor1; Info << "time =" << this->db().time().value()<< " VAlueFraction for Pressure " << factor1 << endl; //Info << " Runtime Values in Pressure = **** = " << runTime.timeName() << endl; #}; } |
|
August 20, 2019, 09:10 |
|
#3 |
New Member
Nabeel Khaleel
Join Date: Jun 2016
Posts: 15
Rep Power: 10 |
Dear api
Thank you for your reply. I have to use this boundary condition : case hsFlux: { scalar R = 0.0035; scalar theta = mesh.Cf().internalField()[cellI].y() *180.0/R; if ( (theta > 0) && (theta < 75) ) { scalar b3 = 0; scalar b2 = -1.07117e-4; scalar b1 = -8.100954e-4; scalar b0 = 1.112046; scalar LCR = b3 * pow(theta,3) + b2*pow(theta,2) +b1 * pow(theta,1) + b0; gradient() = q_*LCR/(kappa); } if ( (theta > 75) && (theta < 104) ) { scalar b3 = -2.544403e-3; scalar b2 = 6.878607e-1; scalar b1 = -5.97439e1; scalar b0 = 1685.403; scalar LCR = b3 * pow(theta,3) + b2*pow(theta,2) +b1 * pow(theta,1) + b0; gradient() = q_*LCR/(kappa); } if ( (theta > 104) && (theta < 171.2) ) { scalar b3 = -6.602394e-5; scalar b2 = 3.196692e-2; scalar b1 = -5.280388; scalar b0 = 3.275329e2; scalar LCR = b3 * pow(theta,3) + b2*pow(theta,2) +b1 * pow(theta,1) + b0; gradient() = q_*LCR/(kappa); } if ( (theta > 171.2) && (theta < 188.8) ) { scalar b3 = 0; scalar b2 = 1.52459e-1; scalar b1 = -5.488588e1; scalar b0 = 4957.224; scalar LCR = b3 * pow(theta,3) + b2*pow(theta,2) +b1 * pow(theta,1) + b0; gradient() = q_*LCR/(kappa); } if ( (theta > 188.8) && (theta < 256) ) { scalar b3 = 5.961826e-5; scalar b2 = -3.504845e-2; scalar b1 = 6.979938; scalar b0 = -4.403785e2; scalar LCR = b3 * pow(theta,3) + b2*pow(theta,2) +b1 * pow(theta,1) + b0; gradient() = q_*LCR/(kappa); } if ( (theta > 256) && (theta < 285) ) { scalar b3 = 2.493475e-3; scalar b2 = -2.019052; scalar b1 = 5.427366e2; scalar b0 = -4.840387e4; scalar LCR = b3 * pow(theta,3) + b2*pow(theta,2) +b1 * pow(theta,1) + b0; gradient() = q_*LCR/(kappa); } Is that possible to apply? To be honest, I am new to the programming in openfoam and facing some problems. Thank you for your help |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
wallHeatFlux utility for an incompressible case | Mr.Jingles | OpenFOAM Post-Processing | 67 | April 6, 2023 04:25 |
dsmcFoam setup | hherbol | OpenFOAM Pre-Processing | 1 | November 19, 2021 02:52 |
rhoPimpleFoam hardship | petrus | OpenFOAM Running, Solving & CFD | 0 | October 7, 2016 03:41 |
T Junction Stability | ignacio | OpenFOAM Running, Solving & CFD | 5 | May 2, 2013 11:44 |
[swak4Foam] Air Conditioned room groovyBC | Sebaj | OpenFOAM Community Contributions | 7 | October 31, 2012 15:16 |