Comments (7)
As @garth-wells says, context manager and python's GC is recommended approach. However is not possible for the old XDMFFile::write
unless you want to have your time loop wrapped and tabbed in context manager. That being said, once you destroy XDMFFile object the old write()
method won't append it. On the other hand new write_checkpoint
appends it and "local" context managers are possible for time loops.
There is also a parameter flush_output
(https://github.com/FEniCS/dolfinx/blob/master/cpp/dolfin/io/XDMFFile.cpp#L58) which forces underlying HDF file to be closed after every XDMFFile::write
method call. That should solve the issue you are reporting.
But I do not like these parameters, especially when they are set to an object as whole (e.g. XDMFFile) but they apply only to part of that object (like XDMFFile::write on functions). Very confusing.
If you'd like to do very quick fix of this I'd recommend putting flush_output = True by default.
from dolfinx.
Are there any objections to having XDMF::close
back in the python interface? I agree with using with
wherever possible, but the nested indentation from with
and loops for complicated FE problems could quickly get out of hand...
from dolfinx.
with XDMFFile("out2.xdmf") as f:
f.write(uu, float(100.0), XDMFFile.Encoding.HDF5)
is the recommended approach. Garbage is collection is complicated, especially when calling 3rd party libs, so we should change the i/o syntax in demos.
from dolfinx.
@michalhabera @nate-sime I would suggest using with
where possible, and in other cases use close()
. We should update demos to follow this pattern.
from dolfinx.
You can always use del xdmf2
. But probably close
is neater
from dolfinx.
@nate-sime is this now resolved?
from dolfinx.
Issues addressed and resolved in PR #77
from dolfinx.
Related Issues (20)
- [BUG]: cannot export several components of function with VTX HOT 7
- Allow `CoordinateElement` to be passed to built-in mesh generators
- Define concept of `FunctionSpace` for mixed topology
- using shared_ptr comparison for entity_maps keys
- Performance regression in collapsing blocked subspace HOT 11
- [BUG]: Visualization of one dimensional data with ParaView HOT 5
- [BUG]: Implicit use of previously created function space HOT 1
- [BUG]: Can't (easily) assemble a block vector without providing a left-hand side in Python HOT 2
- Parent cells not correct in refine_plaza HOT 2
- Access NewtonSolver residual from Python
- Enable macOS CI on PRs (PETSc-less)
- [BUG]: XDMFFile with ASCII encoding is broken in parallel
- Clarity requested: Confusing namespaces `functionspace` is a module in `ufl` but a function in `fem` HOT 6
- [BUG]: dolfinx.io.gmshio.read_from_msh went wrong while using MPI HOT 2
- [BUG]: Unable to run docker container inside a venv HOT 1
- [BUG]: gmshio causes kernel crash if entities are tagged several times HOT 8
- Handling of assertions in python module HOT 1
- Time stamps for XDMF mesh
- Make redhat pipeline compatbile with cffi version 1.17.0
- Lagrange Multiplier for the NS equation with additional constrain
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dolfinx.