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

dividing a dimensioned vectorfield by a dimensioned scalar

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Tobi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 8, 2021, 07:58
Default dividing a dimensioned vectorfield by a dimensioned scalar
  #1
New Member
 
Wiebke Scholz
Join Date: Feb 2021
Posts: 2
Rep Power: 0
weikou is on a distinguished road
Hi,



I am aiming to write a chemistry-solver (I am still with OpenFoam v4.1) , that is solving the reaction and scalar transport on a (RANS averaged turbulent) incompressible flow field, that is already in steady state.

Therefore I need to solve the YEqn only, but adjust it by giving it a reaction source term.

Since I am working with incompressible flow, the dimensions of the terms are all in s⁻¹.

But dimension of reaction->R(Yi) is in kgm⁻³s⁻¹.



Therefore I would like to calculate


volScalarField& reactionRate = (reaction->R(Yi)) / rhoRef;


with 'rhoRef' being a scalar with dimensions kgm⁻³ to end up with reactionRate in dimension s⁻¹.

But when I try, it doesn't compile and gives me the error


no match for ‘operator/’ (operand types are ‘Foam::tmp<Foam::fvMatrix<double> >’ and ‘Foam::dimensionedScalar {aka Foam::dimensioned<double>}’)

Because I didn't find a lot of information on this in the OpenFOAM programmers' guide, I naively thought, this should work, but it seems like I was wrong. Maybe you have an idea, on how to fix this?


Thanks already in advance!
Wiebke
weikou is offline   Reply With Quote

Old   February 8, 2021, 08:31
Default
  #2
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
The problem you encounter here is that the ::R() function will not return a volScalarField but it will rather be a fvScalarMatrix and for the fvScalarMatrix we don´t have the operator/ defined. Out of the box, I am not sure about the conversions implemented. However, I don´t think that even this line will work:

Code:
volScalarField& reactionRate = reaction->R(Yi)
weikou likes this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   February 8, 2021, 08:47
Default
  #3
New Member
 
Wiebke Scholz
Join Date: Feb 2021
Posts: 2
Rep Power: 0
weikou is on a distinguished road
Hi Tobias,



thanks for the quick answer. In that case, it is probably best to leave the result of ::R() as it is and multiply all the other fields in the equation with a constant density.



I just tried it and that seems to work. Thanks for clarifying the types there.



Wiebke
weikou is offline   Reply With Quote

Old   February 8, 2021, 08:55
Default
  #4
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
A work around could be to make it in that way:

Code:
fvScalarMatrix reactionRates = reaction->R();

fvScalarMatrix tmp(reactionRates.size(), dimensionSet("tmp", dimensions(Your Dimensions), scalar(0));    // Not sure about the constructor of that class right now


// Create loop and copy only the data without the units into the new one.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Reply

Tags
dimensioned scalars, dimensioned vectorfields, incompressible flow, reaction


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
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' muth OpenFOAM Running, Solving & CFD 3 August 27, 2018 04:18
Division by zero exception - loop over scalarField Pat84 OpenFOAM Programming & Development 6 February 18, 2017 05:57
Issue symmetryPlane 2.5d extruded airfoil simulation 281419 OpenFOAM Running, Solving & CFD 5 November 28, 2015 13:09
Diverging solution in transonicMRFDyMFoam tsalter OpenFOAM Running, Solving & CFD 30 July 7, 2014 06:20
compressible flow in turbocharger riesotto OpenFOAM 50 May 26, 2014 01:47


All times are GMT -4. The time now is 10:02.