|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
Romain SL
Join Date: Apr 2020
Location: Lyon, France
Posts: 8
Rep Power: 3 ![]() |
Hello,
I'm trying to find a function to multiply a field by another but I can't find what I want. However I found the functions 'sum' and 'subtract' so I'm assuming that it is possible to multiply fields as well with functions... I also found the function 'scale' but it allows to multiply a field by a scalar only. Any ideas? |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 788
Rep Power: 8 ![]() |
Hi,
- I assume you really meant `function object` by `function`. - To my knowledge, there is no compiled FO for field multiplications, like there is `add` - You can use `codedFunctionObject`s. - You can modify an existing function object for your requirements. Hope this helps for a start.
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak-FSB OpenFOAM Governance and Technical Committees Report bugs/Request features: OpenFOAM (ESI-OpenCFD-Trademark) Report bugs/Request features: FOAM-Extend (Wikki-FSB) Report bugs: OpenFOAM.org How to create a MWE. Journal New: Primer |
|
![]() |
![]() |
![]() |
![]() |
#3 |
New Member
Romain SL
Join Date: Apr 2020
Location: Lyon, France
Posts: 8
Rep Power: 3 ![]() |
Thank you for your answer it helped me a lot. I tried to use codedFunctionObject and I wrote this (I'm not sure about it):
Code:
compute_Power { functionObjectLibs ( "libutilityFunctionObjects.so" ); type coded; enabled true; redirectType Power; executeControl writeTime; writeControl writeTime; code #{ const volScalarField& T = mesh().lookupObject<volScalarField>("T"); const volVectorField& U = mesh().lookupObject<volVectorField>("U"); volScalarField Power ( IOobject ( "Power", mesh().time().timeName(), Power.mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), Power= 4185*1000*mag(U)*(T-293) ); Power.write(); #}; } Last edited by rsaintlege; May 17, 2020 at 09:16. |
|
![]() |
![]() |
![]() |
![]() |
#4 |
New Member
Romain SL
Join Date: Apr 2020
Location: Lyon, France
Posts: 8
Rep Power: 3 ![]() |
This is finally the best I managed to do:
Code:
compute_Power { libs ("libutilityFunctionObjects.so"); type coded; name compute_Power; outputControl writeTime; codeWrite #{ const volScalarField& h = mesh().lookupObject<volScalarField>("h"); const volScalarField& h_0 = mesh().lookupObject<volScalarField>("h_0"); const volVectorField& U = mesh().lookupObject<volVectorField>("U"); volScalarField Power = 1000*mag(U)*(h-h_0); Power.write(); #}; } |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Member
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 96
Rep Power: 16 ![]() |
Do you need this field just for post proccesing? Then you could also do this just in paraview.
|
|
![]() |
![]() |
![]() |
![]() |
#6 | |
New Member
Romain SL
Join Date: Apr 2020
Location: Lyon, France
Posts: 8
Rep Power: 3 ![]() |
Quote:
Yes I just need it for post processing actually. How would you do to get this field with paraview? I previously did it by exporting the needed datas as csv files in Excel but I can't do it 100 times ![]() I'm new on OpenFOAM so I don't really know what are the possibilities yet. I'm still interested about making the previous function object work though. I think it would be more convenient, if you have an idea. *EDIT*: I finally managed to do it with the 'calculator' option in Paraview ![]() |
||
![]() |
![]() |
![]() |
Tags |
field, function, multiply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
potential flows, helmholtz decomposition and other stuffs | pigna | Main CFD Forum | 1 | October 26, 2017 08:34 |
Access to field which is evaluated at the moment | Tobi | OpenFOAM Programming & Development | 6 | April 19, 2017 13:09 |
[General] How to create an additional vector with {Field 4, Field 5, Field 6} | Bombacar | ParaView | 1 | August 15, 2015 18:05 |
[Netgen] Import netgen mesh to OpenFOAM | hsieh | OpenFOAM Meshing & Mesh Conversion | 32 | September 13, 2011 05:50 |
CheckMeshbs errors | ivanyao | OpenFOAM Running, Solving & CFD | 2 | March 11, 2009 02:34 |