Hello all

I wrote a semi-lagrangian code for advection which requires tracing 
characteristics back in time and locating cell where it lies at previous time.

The simplest scheme would be like this

xf = x - a(x,t)*dt
u(x,t+dt) = u(xf, t)

My solution is in FE_Q<dim>(2). For each dof (x), I make a list of neighboring 
cells

   std::vector<std::set<typename DoFHandler<dim>::active_cell_iterator>> cells;

Then for each dof (x), I search for xf in this list. Here is a piece of the code
   
   Functions::FEFieldFunction<dim> fe_fun (dof_handler, solution0);

   for(auto v : interior_vertices) // update only interior dofs
   {
      Tensor<1,dim> vel1 = velocity1.value(support_points[v]);
      Point<dim> p1 = support_points[v] - dt * vel1; // locate backward 
characteristic

      typename DoFHandler<dim>::active_cell_iterator cell1 = dof_handler.end();
      for(auto cell : cells[v]) // Loop over cells around current dof
      {
         CellAccessor<dim> cell_accessor = CellAccessor<dim>(&triangulation,
                                                             cell->level(),
                                                             cell->index());
         bool inside = cell_accessor.point_inside(p1);
         if(inside)
         {
            cell1 = cell;
            break;
         }
      }
      AssertThrow(cell1 != dof_handler.end(),
                  ExcMessage("Did not find cell for p0"));
      fe_fun.set_active_cell (cell1);
      solution1(v) = fe_fun.value (p1);
   }

This code works but it seems to be terribly slow even though I am setting the 
active cell FEFieldFunction. Also, when I run it on my quad-core macbook pro, 
the cpu usage is at 500% due to the call to FEFieldFunction.value() function !!!

Is there a way to make this faster, for locating the characteristic and 
evaluating function ?

Thanks
praveen

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to