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

Non-const fvMesh& from BC

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By tomislav_maric

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 21, 2014, 03:07
Default Non-const fvMesh& from BC
  #1
Senior Member
 
Pablo Higuera
Join Date: Jan 2011
Location: Auckland
Posts: 627
Rep Power: 19
Phicau is on a distinguished road
Hi all,

I would like to create a regular (non-constant) reference to the mesh within a boundary condition. The goal is to register a dictionary, so that it will be available for all the boundary conditions that are alike. However, I have not figured out how to do that, as I can only access const fvMesh& references.

Of course I have an ace up my sleeve and can pre-register the dictionary within the solver, but I'd rather not modify it. This way that the BCs could still be included in controlDict dynamically.

I understand the current implementation is safe, as the initial mesh is not modified in any way. With the great power of modifying the mesh comes great responsibility, but I think I can manage.

Is this even possible without major changes in other basic classes?

Thanks!

Pablo
Phicau is offline   Reply With Quote

Old   May 21, 2014, 06:01
Default
  #2
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21
tomislav_maric is on a distinguished road
[QUOTE]
...
The goal is to register a dictionary, so that it will be available for all the boundary conditions that are alike.
...
[QUOTE]

Why go outside the boundary condition class at all?

Reading the sentence above it seems that the dictionary is a common data attribute to a bunch of similar boundary conditions.

Make a parent class that is inherited by all similar boundary conditions. Put the dictionary as the private attribute and provide non-const access to it via a protected member function to make it accessible only to the derived boundary conditions. Make the dictionary a sub-dict of the usual BC dictionary input. Read it by the base class constructor. Done. This does not require you to modify any existing code, but to extend the BCs in the appropriate way by introducing your BC class hierarchy.
Phicau, alia and Kummi like this.
__________________
When asking a question, prepare a SSCCE.
tomislav_maric is offline   Reply With Quote

Old   May 21, 2014, 07:31
Default
  #3
Senior Member
 
Pablo Higuera
Join Date: Jan 2011
Location: Auckland
Posts: 627
Rep Power: 19
Phicau is on a distinguished road
Hi Tomislav,

thanks for all the details, it certainly makes more sense than my approach. I will try that!

Best,

Pablo
Phicau 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
Second Derivative Zero - Boundary Condition fu-ki-pa OpenFOAM 11 March 27, 2021 04:28
compressible flow in turbocharger riesotto OpenFOAM 50 May 26, 2014 01:47
Wall bounded values and streamlines Ruli OpenFOAM Post-Processing 5 February 2, 2014 16:45
[snappyHexMesh] Error in SnappyHexMesh gooya_kabir OpenFOAM Meshing & Mesh Conversion 2 October 23, 2013 04:41
LiftDrag coefficient in LES fabian_korn OpenFOAM Post-Processing 1 September 22, 2008 02:34


All times are GMT -4. The time now is 14:54.