Limiting the calculations to specific elements


95
views
0
12 weeks ago by
Hi everyone

I've posted before asking about how to calculate heat flux for a moving heat sources (https://www.allanswered.com/post/avewp/#xnmgn). Thanks to klunkean who answered my question and solved my dilemma.
The simulation I'm working on has a moving heat sources that moves to ten of thousands locations, hence tens of thousands of iterations or steps. After started to calculate the heat flux, the running time of my program increased dramatically. For some cases went from 8 hours to couple of days. The last instance of the problem I was working was large and I had to abort after a week of running.
My question is, I only need to calculate the heat flux in particular five locations, therefore I don't need the large amount of flux data. Currently I do the following   

F = (rho*c/Dt*(T-T0)*del_T \
        + kappa*T.dx(i)*del_T.dx(i) \
        - rho*f*del_T)*dv \
        + h*(T-Ta)*del_T*da


F += sum(integrals_N)
T_M = Function(Space)
F += emis*st_bol*(T_M**4-Ta**4)*del_T*ds(5)

left=lhs(F)
right=rhs(F)

A = assemble(left)
b = None
T = Function(Space)


for t in numpy.arange(0, t_end, Dt):
   
    f.t = t
    
    line_n = int(abs(t / line_time))
    
     
    if (line_n % 2) == 0 and (line_n %2 < line_time):
        f.xx = (0.001 + vel*t - (length*line_n - mis))
        f.yy = 0.001 + line_n * hatch
    else:
        f.xx = (0.009 - vel*t + (length*line_n - mis))
        f.yy = 0.001 + line_n * hatch​



    b = assemble(right, tensor=b)
    
    [bc.apply(A, b) for bc in bcs]
    solve(A, T.vector(), b, 'cg')

    VE = VectorElement('DG',Space.mesh().ufl_cell(), Space.ufl_element().degree()-1)
    Vspace = FunctionSpace(Space.mesh(), VE)
    q = project(-kappa*grad(T), Vspace)

    # save the flux values of these five location 
    # P1,..p5 are points on the mesh, eg p1=Point(0.1,0.1,0.01)
    flux = [q(p1), q(p2), q(p3), q(p4), q(p5)]


Clearly in each iteration, the program after solving the heat transfer equation it calculates the heat flux for every element or cell and that what takes time. Is there a way to limit the calculation to specific set of cells since the temperature throughout the mesh has already been calculated?

I tried MeshEditor but didn't work. I did  editor.open(mesh,1,1)  editor.initial_cells(10,10)
I looked at mesh refine but the problem is my points are scattered and in mesh refine I need to define new markers so it's like using a smaller mesh
I also tried Submesh by passing my points as second argument but didn't work
I found some posts about PARENT_VERTEX_INDICES but couldn't figure out how to get it to work in my case
Finally I looked at removing all the cells I didn't want using MeshEditor but I ran into the same first problem above

If there is a way to limit the flux calculations to few elements then that would cut my running time tremendously since I'm trying optimize the heat transfer, so I've got hundreds of simulation instance lined up for me to run which currently might take years to finish
Community: FEniCS Project
You might look into doing the projection onto DG spaces element-wise, with a LocalSover.  This does still project the flux everywhere, but, according to J. Bleyer's tutorial (with code) here

http://comet-fenics.readthedocs.io/en/latest/tips_and_tricks.html#efficient-projection-on-dg-or-quadrature-spaces

it is much faster that doing a global projection, and can even be optimized further for repeated projections.
written 12 weeks ago by David Kamensky  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »