CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] dynamic no-flux BC for electrokinetics, can groovyBC do this? (https://www.cfd-online.com/Forums/openfoam-community-contributions/194909-dynamic-no-flux-bc-electrokinetics-can-groovybc-do.html)

OmarEGB October 26, 2017 19:03

dynamic no-flux BC for electrokinetics, can groovyBC do this?
 
Hi,
I have a solver for a Poisson-Nernst-Planck system, that is, the Poisson equation gives me an electric field -\nabla \phi and that electric field pushes the ions according the the Nernst-Planck equation, together with diffusion . The ion flux would be something like this

J=-D(\nabla c + z_i c \nabla \phi )

now, as a boundary condition, I need this flux to be zero in one of my boundaries. Obviously, making the condition \nabla c = 0 isn't enough in this case, since \nabla \phi has a constant value (that comes from the boundary conditions to the Poisson equation), and additionally, the simulation starts from a non-uniform c field, so making that zero isn't an option either. I would need to specify a condition for the gradient in the form

\nabla c = -z c \nabla \phi

where the c in the right hand side would be the previous concentration value at the boundary (from the previous timestep) and \nabla \phi is known (since this happens to be a boundary condition for the Poisson equation).

I was looking at my options and apparently It looks like could use groovyBC, or otherwise I would need to write a library specifically for that boundary condition.
I have no experience whatsoever with swak4foam or writing custom boundary conditions so I would like to take the easiest path.
Could anyone enlighten me on whether this can be done with groovyBC? is there any other alternative?

Snapy February 8, 2018 11:03

Hi OmarEGB,

did you manage to add that type of boundary condition? I would like to add a similar BC.

I would appreciate any hint :)

gschaider February 8, 2018 21:22

Quote:

Originally Posted by Snapy (Post 680886)
Hi OmarEGB,

did you manage to add that type of boundary condition? I would like to add a similar BC.

I would appreciate any hint :)

Code:

snGrad(phi)
gives you the gradient in the normal direction of the patch

Snapy February 9, 2018 05:00

Thanks for the fast response and hint :)

So I could use snGrad() in refCast to set the BC for a specific patch:

Am I correct?

Quote:

fixedGradientFVPatchScalarField& c =
refCast<fixedGradientFvPatchScalarField>
(c.boundaryFieldRef()["patchID"]);
c.gradient() = phi.boundaryField()["patchID"].snGrad();


All times are GMT -4. The time now is 08:57.