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

Calculate flux of ions on a boundary

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 23, 2022, 13:34
Post Calculate flux of ions on a boundary
  #1
New Member
 
Join Date: Oct 2022
Posts: 1
Rep Power: 0
pasei is on a distinguished road
Hello this is my first post in this forum and please correct me if i make serious mistakes. Since I am completely new to c++ i have some difficultys to read the source code.



I would like to calculate the electric field in a domain. I found the electrostaticFoam solver and created my own solver, so I can solve also the electrostatic/fluid coupling.


Important in this problem is the proper calculation of the iondensity in the field.



For my unterstanding the code:



//

rhoFlux = -k*mesh.magSf()*fvc::snGrad(phi);


solve
(
fvm::ddt(rho) + fvm::div(rhoFlux, rho)
);

//

calculates a flux at the cell faces (like "phi" for the momentum equation).


Now i have the problem, that the iondensity doesn't get calculated properly. Especially there is no "flux of ions" into the domain.
I found in an other thread that the mesh.magSf() ist zero on boundary faces.

magSf() on boundaries


So no flux can be calculated at the boundarys.


I have spend several hours solving this problem but have not found an solution. My attempt is to calculate the flux for the whole field and at the boundary faces I'd like to correct the flux.



My code is:

//////////////////

//iondensityflux is the flux at the cellfaces and a surfaceScalarField
//potent is the potential field of the electric Field in the domain a volScalarField

//qui is a constant dimensionedScalar



// the flux gets calculated

iondensityflux = -qui*mesh.magSf()*fvc::snGrad(potent);

//A surfaceSalarField only with the values at the boundarys
tmp<surfaceScalarField::GeometricBoundaryField>& patchiondensityflux =
iondensityflux.boundaryField();


//A surfaceVectorField only with the values at the boundarys
tmp<surfaceVectorField> patchgradpot =
fvc::snGrad(potent).boundaryField();

//now it should loop over all the faces and correct the flux
forAll(patchiondensityflux, patchi)
{
iondensityflux[patchi] = mesh.magSf().boundaryField()[patchi]*patchgradpot[patchi];
}
//////////////////


Everything works fine till the compiler gets to the correction part. For example i get the error code:



calcionflux.H:14:5: error: ‘GeometricBoundaryField’ is not a member of ‘Foam::surfaceScalarField {aka Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>}’
tmp<surfaceScalarField::GeometricBoundaryField>& patchiondensityflux = .....


I'm not sure if boundaryField() is the right way to acces the correct values at the boundarys. I think i have some serius coding problems and would be very thankful for any suggestions.

I found the part with the geometricBoundaryField here:



https://github.com/Himscipy/wallHeat...compressible.C



Many thanks in advance.
pasei is offline   Reply With Quote

Reply

Tags
boundary condition, electrostatic field, face from element faces, flux calculation


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
sliding mesh problem in CFX Saima CFX 46 September 11, 2021 08:38
CFD analaysis of Pelton turbine amodpanthee CFX 31 April 19, 2018 19:02
Out File does not show Imbalance in % Mmaragann CFX 5 January 20, 2017 11:20
Error - Solar absorber - Solar Thermal Radiation MichaelK CFX 12 September 1, 2016 06:15
Wrong flow in ratating domain problem Sanyo CFX 17 August 15, 2015 07:20


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