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/)
-   -   Segmentation fault while interpolating (https://www.cfd-online.com/Forums/openfoam-programming-development/222277-segmentation-fault-while-interpolating.html)

chenu November 18, 2019 05:12

Segmentation fault while interpolating
 
Hello,
my solver diverges while interpolating.
In my case I have created a new solver which based on icoFoam. After calculating pressure the solver calls my own function to derive some specified points. The velocity of these points are then derived by interpolating and transfer to my own function. At beginning there is no problem, but after 0.5 second flowtime, I got error and it seems that interpolation is fail, so I did some tests
1. If I set 0.5 as startTime and run again my solver, it works but it may stop again if endTime is longer(In my case endTime is 1 second).
2. I have used pthread in my solver(the error #2). I disabled it but the solver still diverges.
3.If I hide all command lines and interpolation except calling my own program, it works, so the Segmentation fault is not from my own program
4.To test solver I set 10 points. I have printed each time step of position and velocity. The solver stops after interpolating first position.

The following are some parts of interpolation and error message. I will be grateful if someone give me advise. Thank you!!

Here is my program:
Quote:

//Here I declare pointField and vectorField to store the position and velocity
pointField pt(n_pt,point(0.0,0.0,0.0));
vectorField pv(n_pt,vector(0.0,0.0,0.0));


while (runTime.loop())
{
~~~The content here is identical to icoFoam~~~
my_prog(); //Calling my own program
runTime.write();
//require_position is a function from my program, which will update the coordinate of position in my
own program, n_pt is number of points
require_position(&(pt[0].x()));
for(i=0;i<n_pt;i++){
pv[i]=Uint.interpolate(pt[i],mesh.findCell(pt[i]));
}

//the value of velocity is then sent to my own program.
send_velocit(&pv[0].x());
}
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}



Here is Error message:
Quote:

#0 Foam::error:PrintStack(Foam::Ostream&) at ??:?
#1 Foam::sigSegv::sigHandler(int) at ??:?
#2 ? in "/lib/x86_64-linux-gnu/libpthread.so.0"
#3 Foam:PolyMeshTetDecomposition::cellTetIndices(Foam :PolyMesh const&, int) at ??:?
#4 Foam::cellPointWeight::findTetrahedron(Foam:PolyMe sh const&, Foam::Vector<double> const&, int) at ??:?
#5 ? in "/myworkdict/linux64GccDPInt32Opt/bin/icointer"
#6 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#7 ? in "/myworkdict/linux64GccDPInt32Opt/bin/icointer"
^C
[1]+ Segmentation fault (core dumped) icointer > log


All times are GMT -4. The time now is 18:47.