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

How to use the functionobjects add?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 26, 2018, 02:10
Default How to use the functionobjects add?
  #1
New Member
 
Bingchuan
Join Date: Dec 2017
Posts: 16
Rep Power: 9
bingchuan is on a distinguished road
Dear foamer,

The manual says that the functionobjects add can be used to " Add a list of fields."

At the same time, the code gives an example as
Code:
Ttot {    
 type            add;    
 libs            ("libfieldFunctionObjects.so");    
 fields          (T Tdelta);    
 result          Ttot;    
 executeControl  writeTime;    
 writeControl    writeTime; 
}
But, it is still confusing for me. Can anyone give me more details about when to use it and how to use it. It seems that no such an example in the tutorials.

Bests.

Bingchuan
bingchuan is offline   Reply With Quote

Old   March 26, 2018, 13:43
Default
  #2
Member
 
Hosein
Join Date: Nov 2011
Location: Germany
Posts: 94
Rep Power: 15
einstein_zee is on a distinguished road
Quote:
Originally Posted by bingchuan View Post
Dear foamer,

The manual says that the functionobjects add can be used to " Add a list of fields."

At the same time, the code gives an example as
Code:
Ttot {    
 type            add;    
 libs            ("libfieldFunctionObjects.so");    
 fields          (T Tdelta);    
 result          Ttot;    
 executeControl  writeTime;    
 writeControl    writeTime; 
}
But, it is still confusing for me. Can anyone give me more details about when to use it and how to use it. It seems that no such an example in the tutorials.

Bests.

Bingchuan
Hi there,

I think you forgot to read the next line which states "The operation can be applied to any volume or surface fields generating a volume or surface scalar field." I think this is quite clear about what this class does.
einstein_zee is offline   Reply With Quote

Old   March 27, 2018, 09:03
Default
  #3
New Member
 
Bingchuan
Join Date: Dec 2017
Posts: 16
Rep Power: 9
bingchuan is on a distinguished road
Dear Hosein,

Thank you for your reply.
In fact, I have read "The operation can be applied to any volume or surface fields generating a volume or surface scalar field " before. Since I am new with OF, it is still confusing for me.

I was wondering:
1) Does it have the same efficacy with the VolVectorField or VolScalarField in the creatFields.H?
2) If I created a field by the functionobject add, say a field XX which is related to the temperature. I think the calculation expression of XX should defined in the code. Where should I define the calculation expression of XX ?

So, could you please give me more details, such as sharing an example? Many Thanks.

Bests,
Bingchuan
bingchuan is offline   Reply With Quote

Old   March 27, 2018, 10:09
Default
  #4
Member
 
Hosein
Join Date: Nov 2011
Location: Germany
Posts: 94
Rep Power: 15
einstein_zee is on a distinguished road
Hey there,

I think you mixed up some things with each other. To see what function objects do in general you might refer to this page "https://cfd.direct/openfoam/user-guide/v3-function-objects/".
Quote:
Originally Posted by bingchuan View Post
1) Does it have the same efficacy with the VolVectorField or VolScalarField in the creatFields.H?
volVectorField and volScalarField are just variable types in OF. And this has nothing to do with the function objects.

Quote:
Originally Posted by bingchuan View Post
2) If I created a field by the functionobject add, say a field XX which is related to the temperature. I think the calculation expression of XX should defined in the code. Where should I define the calculation expression of XX ?
Going back to our function object "add", this will add two or more scalar fields with each other. So this means you need to have a volScalarField (exp. temperature as it is stated in the example) defined either on a volume region or a surface one, to add them. The calculation that you referred, here is addition.
einstein_zee is offline   Reply With Quote

Old   March 28, 2018, 05:48
Default
  #5
New Member
 
Bingchuan
Join Date: Dec 2017
Posts: 16
Rep Power: 9
bingchuan is on a distinguished road
Dear Hosein,

I got it
The add function object is just to create a new field which is a sum of a few existing variables. I got it mixed up with registering a new field.
Thanks.

Bests,
Bingchuan
bingchuan is offline   Reply With Quote

Old   June 6, 2020, 15:03
Default
  #6
Member
 
Himanshu
Join Date: Jan 2017
Posts: 34
Rep Power: 9
Himanshu_Shrivastava is on a distinguished road
Quote:
Originally Posted by bingchuan View Post
Dear Hosein,

I got it
The add function object is just to create a new field which is a sum of a few existing variables. I got it mixed up with registering a new field.
Thanks.

Bests,
Bingchuan
Hii, Can you post an example for this add function...
Himanshu_Shrivastava is offline   Reply With Quote

Old   June 6, 2020, 17:36
Default
  #7
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13
HPE is on a distinguished road
Hope this helps: https://www.openfoam.com/documentati...field-add.html
HPE is offline   Reply With Quote

Old   June 8, 2020, 13:41
Default
  #8
Member
 
Himanshu
Join Date: Jan 2017
Posts: 34
Rep Power: 9
Himanshu_Shrivastava is on a distinguished road
Quote:
Originally Posted by HPE View Post
Hello Herpes,
Thank you for the quick reply.
I have seen that page but as I am new to oF and currently in learning phase, I have some doubts and was not able to understand clearly from that page.
Hence, I asked for an example to understand better.

If you allow, Can I asked few question regarding function object. I swear those are easy doubts but not for me
Himanshu_Shrivastava is offline   Reply With Quote

Old   June 8, 2020, 17:24
Default
  #9
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13
HPE is on a distinguished road
Hi,

A minimal example might be, say you want to add two fields of the same size and dimensions, X and Y:

Code:
add1
{
    type            add;
    libs            (fieldFunctionObjects);
    fields          (X Y);
}
You need to put the above inside `system/controlDict` file under `functions` subdictionary. Just append the following to your `controlDict` file if there is no `functions` subdictionary exists:

Code:
functions
{
    add1
    {
        type            add;
        libs            (fieldFunctionObjects);
        fields          (X Y);
    }
}
HPE is offline   Reply With Quote

Old   June 9, 2020, 11:08
Default
  #10
Member
 
Himanshu
Join Date: Jan 2017
Posts: 34
Rep Power: 9
Himanshu_Shrivastava is on a distinguished road
Quote:
Originally Posted by HPE View Post
Hi,

A minimal example might be, say you want to add two fields of the same size and dimensions, X and Y:

Code:
add1
{
    type            add;
    libs            (fieldFunctionObjects);
    fields          (X Y);
}
You need to put the above inside `system/controlDict` file under `functions` subdictionary. Just append the following to your `controlDict` file if there is no `functions` subdictionary exists:

Code:
functions
{
    add1
    {
        type            add;
        libs            (fieldFunctionObjects);
        fields          (X Y);
    }
}
Hello Herpes,

Thank you for the example. I just read many post last night and many of doubts were solved.

Thanks!
Himanshu_Shrivastava is offline   Reply With Quote

Reply

Tags
add, functions


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
[Other] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 12:04
decomposePar problem: Cell 0contains face labels out of range vaina74 OpenFOAM Pre-Processing 37 July 20, 2020 06:38
[PyFoam] and paraview eelcovv OpenFOAM Community Contributions 28 May 30, 2016 10:23
[DesignModeler] add two area around Cylinder in ansys sajjadcheraghian ANSYS Meshing & Geometry 0 May 23, 2016 13:42
OpenFOAM v1.6 & OpenMPI & functionObjects bruce OpenFOAM Running, Solving & CFD 1 August 7, 2009 14:15


All times are GMT -4. The time now is 12:43.