CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

How to calculate T+gradT where T is volScalarField and gradT is scalarField ???

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Zhiheng Wang
  • 1 Post By Zhiheng Wang

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 25, 2016, 20:29
Default How to calculate T+gradT where T is volScalarField and gradT is scalarField ???
  #1
Member
 
Zhiheng Wang
Join Date: Mar 2016
Posts: 72
Rep Power: 10
Zhiheng Wang is on a distinguished road
Hi, I have stuck in code where I am preprocesing Temperature values.

label patchID = mesh.boundaryMesh().findPatchID("inlet");
scalarField InletTGrad=T.boundaryField()[patchID].snGrad();
const scalarField HEIGHT = 1.0/mesh.deltaCoeffs().boundaryField()[patchID];
const fvBoundaryMesh& myBoundary = mesh.boundary();
forAll( myBoundary, fvPatchID ) /
{
const fvPatch& myPatch = myBoundary[patchID];
const vectorField& position = myPatch.Cf();
forAll( myPatch, i)
{
Ts.boundaryField()[fvPatchID][i] = Ts.boundaryField()[patchID][i]+HEIGHT*InletTGrad;
}
Problem is Ts is volScalarField and Height*InleGrad is scalarField
How can I update my boundary values using this code
plese Send your valuable suggetions.


Can we convert scalarField to volScalarField ?? or Can access scalarField element one by one
Kummi likes this.
Zhiheng Wang is offline   Reply With Quote

Old   May 26, 2016, 13:59
Default
  #2
Senior Member
 
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18
anishtain4 is on a distinguished road
I'm not sure how this applies to you problem but you are using gradient and Height from inlet to update all of your boundaries, is this physically meaningful?

Your problem here is not about volScalarField and scalarField. your Ts.boundaryField()[patchID][i] is temperature on patchID on face i, which is a scalar, not field. While Height and InletTGrad are fields. if Height and InletTGrad are consistent (which I think they are) the scalar would be added to them, so right hand side runs well, but it's the = operator that gets you, OF can't figure out how to fill you scalar Ts.boundaryField()[fvPatchID][i] with a field you've just calculated.

Probably you want to average the Height*InletTGrad?
anishtain4 is offline   Reply With Quote

Old   May 26, 2016, 17:41
Default
  #3
Member
 
Zhiheng Wang
Join Date: Mar 2016
Posts: 72
Rep Power: 10
Zhiheng Wang is on a distinguished road
Hello and Thank You very much for your quick reply
I have resolved the issue by the way I can explain it is a kind of Cold flow solver part which I need to apply to correct BC before producing spark
You may say its a kind of iterative BC.

yes Its like getting T[i]=T[i]+DT[i]

mesh.dettaCoeffs() gives 1/distance;
so HEIGTHT=1/mesh.deltaCoeffs().boundaryField()[patchID] will be face center to adjacent cell center distance ( difference of y co-ordinate for 2D case in X-Z plane);
inletTGrad gives normal gradient to plane.
Height[i]*InletGradT[i] gives DT[i] (for ith face-center)
I
Kummi likes this.
Zhiheng Wang is offline   Reply With Quote

Old   May 27, 2016, 11:12
Default
  #4
Senior Member
 
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18
anishtain4 is on a distinguished road
I'm not sure if your reply is complete or not as I see a single "I" at the end.
But I just noticed another syntax error in definition of HEIGHT:
HEIGHT=scalar/scalarField, which is not defined in openFoam operator. you can't divide a scalar by a scalarField, it must be either two scalars or a cmptDivide(field1,field2).
anishtain4 is offline   Reply With Quote

Old   May 28, 2016, 14:51
Default
  #5
Member
 
Zhiheng Wang
Join Date: Mar 2016
Posts: 72
Rep Power: 10
Zhiheng Wang is on a distinguished road
Hi Mahdi,
I am sorry for not typing is properly my mistake
The code segment is written as
I am having 16 faces at inlet which i have created for liquid patch for evaporative interface
const scalarField HEIGHT = 1.0/mesh.deltaCoeffs().boundaryField()[patchID];
Info<<endl<<" Normal distance between boundary face centre and cell centre is "<<HEIGHT<<endl;
OUTPUT is
Normal distance between boundary face centre and cell centre is
16
(
0.00333333
0.00333333
0.00333333
0.00333333
0.00333333
0.00333333
0.00333333
0.00333333
0.00333333
0.00333333
0.00333333
0.00333333
0.00333333
0.00333333
0.00333333
0.00333333
)
Regards
Zhiheng Wang 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



All times are GMT -4. The time now is 03:23.