Hi,
I am solving a diffusion-reaction problem using fenics. Recently I moved from 1.4 to 1.5. My code was working correctly with the older version of fenics, but not with the 1.5. A simple check revealed the source of the error came from the reaction part.
The code structure of main function:
// 1. read in meshes, define functions and do assembling.
// ... // This part runs without giving any errors.
// 2. allocate object for reactions.
std::vector<CELL*> cells;
for ( int i = 0; i < mesh.num_vertices(); ++i )
{
cells.push_back( new CELL() );
}
while(t<T) {
// run the time loop solving reaction
for(i = 0; i<cells.size();i++)
// error here in fenics 1.5 but not 1.4
cells[i]->Run(); // note -> giving errors here -> NaN error
// checking NaNs.
if(cells[i]->V != cells[i]->V)
std::cerr << "NaNs" << std::endl;
//update diffusion solution vector and solve diffusion problem.
t+=dt;
}
However, if I define and allocate cells vector at the very beginning of the main function, the reaction part works fine without giving NaNs.
// 1. allocate object for reactions.
std::vector<CELL*> cells;
// NUM == mesh.num_vertices();
for ( int i = 0; i < NUM; ++i )
{
cells.push_back( new CELL() );
}
// 2. read in meshes, define functions and do assembling.
// ... // This part runs without giving any errors.
while(t<T) {
// run the time loop solving reaction
for(i = 0; i<cells.size();i++)
cells[i]->Run(); // note it's working now...
// checking NaNs.
if(cells[i]->V != cells[i]->V)
std::cerr << "NaNs" << std::endl;
//update diffusion solution vector and solve diffusion problem.
t+=dt;
}
I am wondering if this is due to memory allocating problem? Any changes on compiling options from fenics 1.4 to 1.5?
Thanks!