|
[Sponsors] |
Method to change boundary condition (BC) type on the fly |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
Senior Member
|
Hi everyone,
I recently ran into what seemed like a trivial issue: dynamically changing the boundary condition of a field, e.g., from 'calculated' to 'fixedValue'. As you know, you can't solve equations in OpenFOAM for fields with 'calculated' type patches, so I needed to explicitly switch them to 'fixedValue'. Although I expected the solution to be simple and concise, it actually took me quite some time to sort it out, and surprisingly, I couldn't find a clear answer online, even though I remember doing something similar over a decade ago. I’ve currently tested this approach with OpenFOAM 10, but it should be fairly straightforward to adapt it for use in other versions as well. So, I’d like to share the working code snippet here in case it saves someone else the trouble: Code:
// Set boundary type to fixedValue dictionary dict; dict.add("value", "uniform (0 0 0)"); forAll(U.boundaryFieldRef(), patchi) { U.boundaryFieldRef().set ( patchi, new fixedValueFvPatchVectorField ( mesh.boundary()[patchi], // fvPatch reference U.ref(), // Internal field reference dict ) ); } Cheers,
__________________
Best regards, Dr. Alexander VAKHRUSHEV Christian Doppler Laboratory for "Metallurgical Applications of Magnetohydrodynamics" Simulation and Modelling of Metallurgical Processes Department of Metallurgy University of Leoben http://smmp.unileoben.ac.at |
|
![]() |
![]() |
![]() |
Tags |
change boundary condition, fvpatch, type |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
chtmultiRegion case is not generating sets folder in postprocessing | boffin5 | OpenFOAM Running, Solving & CFD | 14 | April 19, 2024 17:40 |
Openfoam Turbulent Car Simulation | meganrw | OpenFOAM Running, Solving & CFD | 0 | July 5, 2021 15:50 |
[OpenFOAM.org] compile error in dynamicMesh and thermophysicalModels libraries | NickG | OpenFOAM Installation | 3 | December 30, 2019 00:21 |
Divergent temperature in chtMultiRegion(Simple)Foam | akrasemann | OpenFOAM Running, Solving & CFD | 13 | March 24, 2014 02:54 |
[swak4Foam] Air Conditioned room groovyBC | Sebaj | OpenFOAM Community Contributions | 7 | October 31, 2012 14:16 |