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

Creating a new unary_function

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 7, 2023, 07:59
Default Creating a new unary_function
  #1
New Member
 
Join Date: Nov 2023
Posts: 2
Rep Power: 0
stBern is on a distinguished road
I would like to create a new unary_function in OpenFOAM


Code:
inline scalar newSign(const scalar s)
{
    return (s > 0)? 1: -1;
}
How can I add this function to OpenFOAM to use with geometricFields and Fields?
stBern is offline   Reply With Quote

Old   December 7, 2023, 12:42
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by stBern View Post
I would like to create a new unary_function in OpenFOAM


Code:
inline scalar newSign(const scalar s)
{
    return (s > 0)? 1: -1;
}
How can I add this function to OpenFOAM to use with geometricFields and Fields?

You may want something something similar for vectors ? I don't know.
To add in everywhere you will need to touch the following files (header + source):
  • src/OpenFOAM/fields/Fields/Field/FieldFunctions.H
  • src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldFunctions.H
  • src/OpenFOAM/fields/FieldFields/FieldField/FieldFieldFunctions.H
  • src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.H
  • src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldFunctions.H (need to double-check this one)
Essentially you have a lot of boilerplate to add - FieldFunctions for regular fields, DimensionedFieldFunctions to wrap for internal fields, FieldFieldFunctions to wrap all of the boundary field handling and finally GeometricFieldFunctions for the volume fields.


In addition, you will also need to define how the dimensions change (or don't) - some code in dimensionSet.{C,H}




However, how useful is it to have -1 as the sign for a zero value?
olesen 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
[SOWFA] NREL SOWFA ABLTerrainSolver tutorial problem cico0815 OpenFOAM Community Contributions 36 February 3, 2022 11:54
OpenFoam restarting simulation, stops at first Time loop syntex OpenFOAM Running, Solving & CFD 4 April 5, 2019 11:20
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 18:57
Possible Bug in pimpleFoam (or createPatch) (or fluent3DMeshToFoam) cfdonline2mohsen OpenFOAM 3 October 21, 2013 09:28
Problem in running ICEM grid in Openfoam Tarak OpenFOAM 6 September 9, 2011 17:51


All times are GMT -4. The time now is 21:48.