|
[Sponsors] |
How to calculate T+gradT where T is volScalarField and gradT is scalarField ??? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 25, 2016, 20:29 |
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 |
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 |
|
May 26, 2016, 13:59 |
|
#2 |
Senior Member
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18 |
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? |
|
May 26, 2016, 17:41 |
|
#3 |
Member
Zhiheng Wang
Join Date: Mar 2016
Posts: 72
Rep Power: 10 |
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 |
|
May 27, 2016, 11:12 |
|
#4 |
Senior Member
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18 |
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). |
|
May 28, 2016, 14:51 |
|
#5 |
Member
Zhiheng Wang
Join Date: Mar 2016
Posts: 72
Rep Power: 10 |
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 |
|
|
|