|
[Sponsors] |
how to add the third component of a scalar field to the equation. |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 14, 2023, 07:47 |
how to add the third component of a scalar field to the equation.
|
#1 |
Senior Member
|
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 |
|
March 14, 2023, 09:02 |
|
#2 |
Senior Member
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 113
Rep Power: 5 |
I think it should be "2.0*fvc::grad(T).z()"
|
|
March 14, 2023, 09:18 |
|
#3 |
Senior Member
|
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 |
|
March 14, 2023, 09:41 |
|
#4 |
Senior Member
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 113
Rep Power: 5 |
Maybe because it is a tmp field? Perhaps try
volVectorField gradT = fvc::grad(T); and then: +2.0 * gradT.z() |
|
March 14, 2023, 10:15 |
|
#5 |
Senior Member
|
||
March 14, 2023, 13:59 |
|
#6 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
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. |
|
March 21, 2023, 00:00 |
|
#7 | |
Senior Member
|
Quote:
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. |
||
March 21, 2023, 05:07 |
|
#8 |
Senior Member
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 113
Rep Power: 5 |
I am pretty sure you just need to loop over all of the cells you want to calculate the sqrt() of.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] swakExpression not writing to log | alexfells | OpenFOAM Community Contributions | 3 | March 16, 2020 19:19 |
OpenFOAM extended 4.0 Error with Multinode Set-up | Liweix | OpenFOAM Running, Solving & CFD | 1 | February 18, 2020 01:50 |
Steady Advection-diffusion equation, with scalar velocity field, openfoam | andrea5 | OpenFOAM Programming & Development | 0 | September 17, 2019 05:10 |
Calculation of the Governing Equations | Mihail | CFX | 7 | September 7, 2014 07:27 |
compressible flow in turbocharger | riesotto | OpenFOAM | 50 | May 26, 2014 02:47 |