CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   Setting normal gradient as BC (

Dozer_94 May 3, 2019 09:27

Setting normal gradient as BC
Hi all,

I am editing icoFoam for a specific calculation in which I want to set the normal gradient of a patch as a boundary condition.

So normally scalar field 'c' would be solved using the BCs for the values of 'c', but now I would like OF to use normal gradient 'dc/dn' as BC.

I know that 'c.boundaryField()[patch].snGrad()' would return the values of the normal gradient, but I'd like it vice versa.

Anyone know if this is possible at all?

Thanks in advance,

fumiya May 7, 2019 08:14


You can use the fixedGradient boundary condition to set a patch normal gradient to a user-specified value.

Hope this helps,

Dozer_94 May 7, 2019 11:22

Hi Fumiya,

Thanks for your reply. I was aware that this was the way to go for the initial conditions. However, I would like OF to do this for me as a BC that changes each timestep.

To give a bit more information: I am using an external solver that calculates dc/dn from other quantities. The goal is to set this calculated dc/dn as BC for the next timestep. Therefore, I need a way (be it a provided member function or a more elaborate method) to incorporate this in the solver itself.


fumiya May 8, 2019 09:54

Hi Dozer_94,

The following thread will be of help:


Dozer_94 May 21, 2019 10:33

Thank you Fumiya, this was exactly what I was searching for. Seems like something I could have figured out myself, though.

All times are GMT -4. The time now is 07:16.