Git Product home page Git Product logo

Comments (11)

wence- avatar wence- commented on September 28, 2024

Humph, that doesn't work I think, because the value in the dict holds a strong reference to the key and so it's never collected.

from thetis.

tkarna avatar tkarna commented on September 28, 2024

I agree, both of these dicts were implemented as temporary fixes to issues I had.

I use temporary functions essentially to save memory. I think storing them in the function space directly is a great idea. Why is restore_function necessary?

from thetis.

tkarna avatar tkarna commented on September 28, 2024

As for the LinearProblemCache, I think instead of caching them, another solution would be to implement classes that hold the solver objects. For functions like computeVertVelocity that certainly makes sense. So essentially all those functions in utility would be implemented as objects that are stored in the solver class:

solverObj.uv_vert_integrator = ComputeVerticalIntegral(uv_3d, uv_dav_3d, average=True)
solverObj.uv_vert_integrator.apply(uv_3d, uv_dav_3d)

That should take care of the collection issue.

from thetis.

wence- avatar wence- commented on September 28, 2024

So I had thought the restore_function would be used like this:

tmp = V.get_function()
... do stuff with tmp
tmp2 = V.get_function()
... do stuff with tmp2
V.restore_function(tmp)
... do stuff
tmp3 = V.get_function()
# tmp3 doesn't allocate a new work vector, instead it gets the work vector
# that was previously tmp.

IOW, if I only ever need one temporary function on V but I use it repeatedly in different places, I don't keep on allocating new functions (or allocating and deallocating). But rather V has a (fixed size) number of work vectors that I can grab hold of and then release back to the pool when I'm done with them.

from thetis.

wence- avatar wence- commented on September 28, 2024

That approach to the linear problem cache also sounds sensible.

from thetis.

tkarna avatar tkarna commented on September 28, 2024

OK, I see. Yes, having a pool of temporary functions seems like a good approach.
I'll start implementing those changes in utility.py so we can remove LinearProblemCache.

from thetis.

tkarna avatar tkarna commented on September 28, 2024

linProblemCache is now removed in pull request #8 .

from thetis.

wence- avatar wence- commented on September 28, 2024

Please look at firedrake branch "work_functions" and see if that fits the bill for the temporary function cache.

from thetis.

tkarna avatar tkarna commented on September 28, 2024

OK, looks good, I'll give it a shot.

from thetis.

tkarna avatar tkarna commented on September 28, 2024

So I think it's possible to use the function space work functions. The only caveat is that during initialization we build Projector objects with the work functions and then re-use those Projectors at run time. This requires that you always get the same work function. I've worked around this by setting max_work_functions to 1, which is fine for now but might be too restrictive in some cases.

from thetis.

tkarna avatar tkarna commented on September 28, 2024

Both issues are now addressed in pull requests #8 and #21, closing.

from thetis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.