CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Specify value of surfaceVectorField (https://www.cfd-online.com/Forums/openfoam-programming-development/233458-specify-value-surfacevectorfield.html)

chenu January 28, 2021 08:04

Specify value of surfaceVectorField
 
Hello,
I have a problem when I specify surfaceVectorField.
I will compute flow velocity of each cell face by my own program instead of using fvc::interpolation(U). So I declare a surfaceVectorField called Uf in the createFields.H, just like velocity:

surfaceVectorField Uf
(
IOobject
(
"Uf",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENTS,
IOobject::NO_WRITE
),
mesh
);


In each time step I will assign Uf, for example
Uf[faceID].x()=x velocity I computed ,which is also applied for y and z

But while executing the program, I have this error:
free(): invalid pointer
Aborted (core dumped)


If I comment this line, then there be no problem. It looks like if I specify Uf directly, the program will free Uf twice.

My questions are:
1. How do I assign surfaceVectorField by value and
2. why Uf will be free twice? I have earlier did the same to velocity (volVectorField) but there is no problem.

I will appreciate for any advice. Thank you

mAlletto January 31, 2021 04:20

https://www.openfoam.com/documentati...8H_source.html

Maybe the way the face flux phi is created helps

chenu February 4, 2021 06:59

Hello, mAlletto,
Thank you for your answer. I did the same way to create my variable.
I have found the reason due to this error
Quote:

Originally Posted by mAlletto (Post 794890)
https://www.openfoam.com/documentati...8H_source.html

Maybe the way the face flux phi is created helps



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