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

Writing functions in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 4 Post By HPE
  • 1 Post By Tobi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 11, 2020, 06:11
Talking Writing functions in OpenFOAM
  #1
New Member
 
Join Date: Dec 2019
Posts: 3
Rep Power: 6
constance13 is on a distinguished road
Hello everyone!

I am really new to OpenFOAM and I am wondering how I can define functions (for example velocity or forces or surface vectors in general as a function of coordinates).Can I write expressions inside the files of a case and specify functions, considering each patch? Or could I write different files and include them in the main ones (like a different file that's included in controlDict for instance)?




Thank you very much in advance!

Constance
constance13 is offline   Reply With Quote

Old   May 11, 2020, 18:19
Default
  #2
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12
HPE is on a distinguished road
Hi,

- I would start by looking at the links below, which contain lots of useful information, tutorials and examples. I don't know how familiar you are with OpenFOAM, or C++, or CFD, but if you are new to most of them, I would start small with perseverance. The learning curve for OpenFOAM gets smoother every year, but still steep.
- I think whatever one can do with bare C++ can be done in OpenFOAM, so the overall answer to your question is yes.
- It would help forum people a lot if you can isolate your question, if possible.

Good luck!
HPE is offline   Reply With Quote

Old   May 12, 2020, 03:59
Default
  #3
New Member
 
Join Date: Dec 2019
Posts: 3
Rep Power: 6
constance13 is on a distinguished road
Quote:
Originally Posted by HPE View Post
Hi,

- I would start by looking at the links below, which contain lots of useful information, tutorials and examples. I don't know how familiar you are with OpenFOAM, or C++, or CFD, but if you are new to most of them, I would start small with perseverance. The learning curve for OpenFOAM gets smoother every year, but still steep.
- I think whatever one can do with bare C++ can be done in OpenFOAM, so the overall answer to your question is yes.
- It would help forum people a lot if you can isolate your question, if possible.

Good luck!
Hello again,

thank you very much for this fast reply and the links you provided,
very helpful. I'm starting from there and if I end up in dead end, I'll be
more specific to the next possible question.

Thanks!
constance13 is offline   Reply With Quote

Old   May 12, 2020, 08:44
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
I just want to elaborate on the question a bit more.
  • Yes, and no. You can add functionalities to the controlDict, which can handle objectFunctions. These functions are already programmed and ready to use. There are different scenarios available in the tutorial cases that show one how to use these functionObjects. It is a powerful tool and run-time adjustable as well as can be constructed on the fly (no recompiling or code development needed)
  • If the functionObjects do not fit your needs, you can either program your function object, integrate it to the library, and use it afterward. Or you can modify the solver you are using. In either way, it means that you have to code your function and implement it to the solver or functionObject library
  • At last, you can develop your complete library that analyzes the numerical data without using the FOAM namespace functions and classes or using them. It is identical to the second one, but you are not adding the function to the functionObject library. However, it does not matter which way you go

Summing up: If the function objects that are already included in the toolbox are fitting your needs, you are happy and can use them on the fly. Otherwise, you need to make your functionality. Hope this will help you.

Tobi
constance13 likes this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   May 13, 2020, 03:36
Default
  #5
New Member
 
Join Date: Dec 2019
Posts: 3
Rep Power: 6
constance13 is on a distinguished road
Quote:
Originally Posted by Tobi View Post
I just want to elaborate on the question a bit more.
  • Yes, and no. You can add functionalities to the controlDict, which can handle objectFunctions. These functions are already programmed and ready to use. There are different scenarios available in the tutorial cases that show one how to use these functionObjects. It is a powerful tool and run-time adjustable as well as can be constructed on the fly (no recompiling or code development needed)
  • If the functionObjects do not fit your needs, you can either program your function object, integrate it to the library, and use it afterward. Or you can modify the solver you are using. In either way, it means that you have to code your function and implement it to the solver or functionObject library
  • At last, you can develop your complete library that analyzes the numerical data without using the FOAM namespace functions and classes or using them. It is identical to the second one, but you are not adding the function to the functionObject library. However, it does not matter which way you go

Summing up: If the function objects that are already included in the toolbox are fitting your needs, you are happy and can use them on the fly. Otherwise, you need to make your functionality. Hope this will help you.

Tobi
Greetings!

It is indeed helpful, getting to understand how it all works.
Thank you very much for your reply as well!
constance13 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
Frequently Asked Questions about Installing OpenFOAM wyldckat OpenFOAM Installation 3 November 14, 2023 11:58
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 02:36
OpenFOAM Training Jan-Apr 2017, Virtual, London, Houston, Berlin cfd.direct OpenFOAM Announcements from Other Sources 0 September 21, 2016 11:50
[snappyHexMesh] crash sHM H25E OpenFOAM Meshing & Mesh Conversion 11 November 10, 2014 11:27
Suggestion for a new sub-forum at OpenFOAM's Forum wyldckat Site Help, Feedback & Discussions 20 October 28, 2014 09:04


All times are GMT -4. The time now is 04:40.