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

how to add the third component of a scalar field to the equation.

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 14, 2023, 06:47
Default how to add the third component of a scalar field to the equation.
  #1
Senior Member
 
ztdep's Avatar
 
p ding
Join Date: Mar 2009
Posts: 427
Rep Power: 19
ztdep is on a distinguished road
Send a message via Yahoo to ztdep Send a message via Skype™ to ztdep
I need to add the 3.0*dT/dz in to the right hand side of my equation.
I add the following term to my eq:
+2.0*fvc::grad(T).component(2)

but the error are :
error: ‘class Foam::tmp<Foam::GeometricField<Foam::Vector<double >, Foam::fvPatchField, Foam::volMesh> >’ has no member named ‘component’

how to resolve this problem
ztdep is offline   Reply With Quote

Old   March 14, 2023, 08:02
Default
  #2
Senior Member
 
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 112
Rep Power: 5
joshwilliams is on a distinguished road
I think it should be "2.0*fvc::grad(T).z()"
joshwilliams is offline   Reply With Quote

Old   March 14, 2023, 08:18
Default
  #3
Senior Member
 
ztdep's Avatar
 
p ding
Join Date: Mar 2009
Posts: 427
Rep Power: 19
ztdep is on a distinguished road
Send a message via Yahoo to ztdep Send a message via Skype™ to ztdep
Quote:
Originally Posted by joshwilliams View Post
I think it should be "2.0*fvc::grad(T).z()"
thanks, but i still get :

TEqn.H:13:43: error: ‘class Foam::tmp<Foam::GeometricField<Foam::Vector<double >, Foam::fvPatchField, Foam::volMesh> >’ has no member named ‘z’

what had happened. why it says no this member
ztdep is offline   Reply With Quote

Old   March 14, 2023, 08:41
Default
  #4
Senior Member
 
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 112
Rep Power: 5
joshwilliams is on a distinguished road
Maybe because it is a tmp field? Perhaps try

volVectorField gradT = fvc::grad(T);


and then:

+2.0 * gradT.z()
joshwilliams is offline   Reply With Quote

Old   March 14, 2023, 09:15
Default
  #5
Senior Member
 
ztdep's Avatar
 
p ding
Join Date: Mar 2009
Posts: 427
Rep Power: 19
ztdep is on a distinguished road
Send a message via Yahoo to ztdep Send a message via Skype™ to ztdep
Quote:
Originally Posted by joshwilliams View Post
Maybe because it is a tmp field? Perhaps try

volVectorField gradT = fvc::grad(T);


and then:

+2.0 * gradT.z()
gradT.component(2)

this one works. thank you very much for your help. but .z() still can't be recongnized.
ztdep is offline   Reply With Quote

Old   March 14, 2023, 12:59
Default
  #6
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
There are no 'x(), y(), z()' methods defined for Field volVectorField etc. Would be nice, but absolutely horrible to implement since they would only be enabled if vector. Would need a whole bunch more methods xx(), xy(), etc for tensor.


Thus if you need to slice out a component, use the component() method. For better documentation, would normally write fld.component(vector::Z) for example.
Tobermory likes this.
olesen is offline   Reply With Quote

Old   March 20, 2023, 23:00
Default
  #7
Senior Member
 
ztdep's Avatar
 
p ding
Join Date: Mar 2009
Posts: 427
Rep Power: 19
ztdep is on a distinguished road
Send a message via Yahoo to ztdep Send a message via Skype™ to ztdep
Quote:
Originally Posted by joshwilliams View Post
Maybe because it is a tmp field? Perhaps try

volVectorField gradT = fvc::grad(T);


and then:

+2.0 * gradT.z()
Dear friends:
I need to compute the "sqrt(T)*T" , how to programming this term. It seems the sqrt in openfoam doesn't support component-wise operations.
ztdep is offline   Reply With Quote

Old   March 21, 2023, 04:07
Default
  #8
Senior Member
 
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 112
Rep Power: 5
joshwilliams is on a distinguished road
I am pretty sure you just need to loop over all of the cells you want to calculate the sqrt() of.
joshwilliams 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
[swak4Foam] swakExpression not writing to log alexfells OpenFOAM Community Contributions 3 March 16, 2020 18:19
OpenFOAM extended 4.0 Error with Multinode Set-up Liweix OpenFOAM Running, Solving & CFD 1 February 18, 2020 00:50
Steady Advection-diffusion equation, with scalar velocity field, openfoam andrea5 OpenFOAM Programming & Development 0 September 17, 2019 04:10
Calculation of the Governing Equations Mihail CFX 7 September 7, 2014 06:27
compressible flow in turbocharger riesotto OpenFOAM 50 May 26, 2014 01:47


All times are GMT -4. The time now is 20:29.