|
[Sponsors] |
November 23, 2022, 13:34 |
Calculate flux of ions on a boundary
|
#1 |
New Member
Join Date: Oct 2022
Posts: 1
Rep Power: 0 |
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. |
|
Tags |
boundary condition, electrostatic field, face from element faces, flux calculation |
|
|
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 |