Coder Social home page Coder Social logo

fluidfoam's Introduction

FluidDyn project and fluiddyn package

Latest version Supported Python versions Documentation status Code coverage Heptapod CI Github Actions

FluidDyn project is an ecosystem of packages for research and teaching in fluid dynamics. The Python package fluiddyn contains:

  • basic utilities to manage: File I/O for some esoteric formats, publication quality figures, job submission on clusters, MPI
  • powerful classes to handle: parameters, arrays, series of files
  • simplified interfaces to calculate: FFT, spherical harmonics

and much more. It is used as a library in the other specialized packages of the FluidDyn project (in particular in fluidfft, fluidsim, fluidlab and fluidimage).

Documentation: Read the Docs, Heptapod Pages

Installation

The simplest way to install fluiddyn is by using pip:

pip install fluiddyn

You can also get the source code from https://foss.heptapod.net/fluiddyn/fluiddyn or from the Python Package Index. The development mode is often useful if you intend to modify fluiddyn. From the root directory:

pip install -e .[dev]

Requirements

Minimum Python (>=3.9), numpy matplotlib h5py psutil
Full functionality h5py h5netcdf pillow imageio mpi4py scipy pyfftw (requires FFTW library), SHTns
Optional OpenCV with Python bindings, scikit-image

Note: Detailed instructions to install the above dependencies using Anaconda / Miniconda or in a specific operating system such as Ubuntu, macOS etc. can be found here.

Tests

With an editable installation, you can run the tests with:

pytest

Metapaper and citation

If you use any of the FluidDyn packages to produce scientific articles, please cite our metapaper presenting the FluidDyn project and the fluiddyn package:

History

The FluidDyn project started in 2015 as the evolution of two packages previously developed by Pierre Augier (CNRS researcher at LEGI, Grenoble): solveq2d (a numerical code to solve fluid equations in a periodic two-dimensional space with a pseudo-spectral method, developed at KTH, Stockholm) and fluidlab (a toolkit to do experiments, developed in the G. K. Batchelor Fluid Dynamics Laboratory at DAMTP, University of Cambridge).

Keywords and ambitions: fluid dynamics research with Python (>= 3.6), modular, object-oriented, collaborative, tested and documented, free and open-source software.

License

FluidDyn is distributed under the CeCILL-B License, a BSD compatible french license.

fluidfoam's People

Contributors

cyrillebonamy avatar gfngoncalves avatar hoehnp avatar jchauchat avatar marieskorlic avatar mathieu7an avatar quentinclemencot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fluidfoam's Issues

Streamline plot

I am trying to create streamline plot using fluidfoam library but it is giving me a lot of issues of mismatching data of my grid with velocity etc. Is there any script available for streamplot for 3D data? For 2D it successfully load openFoam grid and solution of for example velocity.

Simple change to improve compatibility

Hi,

Started using this library to parse foam files. I used it with the bunny and started getting some errors. That is because the old file format for neighbors allowed -1 to be present in the file to say "the face isn't here". I updated the _parse_owner function in the foam reader to handle this case. works fine now.

def _parse_owner(self):

        for line in self.lines_stripped:
            try:
                int(line)
                break
            except ValueError:
                continue
            break
        self.nb_faces = int(line)
        data = self.content.split(line, -1)[-1]

        self.type_data = self.header[b"class"]

        if not self.is_ascii:
            nb_numbers = self.nb_faces
            data = b"\n(".join(data.split(b"\n(")[1:])
            self.values = np.array(
                struct.unpack(
                    "{}i".format(nb_numbers),
                    data[: nb_numbers * struct.calcsize("i")],
                )
            )
        else:
            lines = data.split(b"\n(")[1:]
            lines = [line.split(b")")[0] for line in lines]
            data = b" ".join(lines).strip()
            self.values = np.array([int(s) for s in data.split()])
        if self.values.min() < 0:
            self.values = self.values[np.where(self.values>=0)[0]]
            self.nb_faces = self.values.size
        self.nb_cell = np.max(self.values) + 1

Cannot read the airfoil2D case from OpenFOAM tutorials

Hello,
I am trying to use this package to read the mesh from the OpenFOAM's airfoil2D tutorial located in $FOAM_TUTORIALS/incompressible/simpleFoam/airFoil2D. Note that I am using OpenFOAM 9.

  • I have copied the tutorial to the directory: /tmp/mywork/airf

When I try to read the mesh from the case as follows:

from fluidfoam import readmesh
sol="/tmp/mywork/airf"
x, y, z = readmesh(sol, structured=True) # note that I have also used structured=False

When I run the code I always get errors when I use either structured=True or structured=False. In both cases I get errors as below:

handling multiple regions

Hi,
It would be great, if multi-region cases can be handled in fluidfoam as well.
E.g. I would like to read scalar values from the different regions for the multiRegionHeater case, which has 5 regions (with non-moving fixed mesh)?
Thank you in advance!
Fab

Scipy version

Hello,
In setup.py the scipy version is set to scipy==1.7.3. At the time of writing, the latest version of scipy is 1.8.0.

Is there a reason to restrict the version of scipy? why not using scipy>=1.7.3 for example?

Thank you

Update Sphinx config for favicon

Thanks for using Sphinx Favicon in your project! I just released version 1.0 of the extension, which brings one breaking change: to better conform with Python standards, we changed the module name to sphinx_favicon (instead of sphinx-favicon). This means you'll have to update the name in the extensions list of your conf.py file (https://github.com/fluiddyn/fluidfoam/blob/master/doc/conf.py#L62) before you can use version 1.0. Otherwise, your existing configuration should continue to work!

readpostpro probe reader header information

I am very happy about this repository and would like to contribute to it myself. But i would like to check in advance if there is a correct approach for this and if there is any interest at all.

I am currently simulating an LES case using rhoPimpleFoam. Especially the initial transient phase of this simulation needs to be monitored. Therefore, I am using probes along the domain. Because the simulation must remain performant, I may wish to change something in the simulation settings. Also, I don't necessarily know how the probes were placed by myself.

readpostpro.readprobes returns only the data in the postProcessing file. I would like to have the information in the header as well.

I am currently fiddling around with fluidfoam v0.2.3. The header is parsed in lines 154-155. I would focus on developing a new function in the following section of code

readpostpro.py

    with open(os.path.join(path_probes_name, time_name, name), "rb") as f:
        content = f.readlines()
    j = 0
    header = True
    for dummy, line in enumerate(content):
        if "#".encode() in line:
            j += 1
        elif "#".encode() not in line and header:
            header = False
            line = line.replace(b")", b"")
            line = line.split(b"(")
            try:
                dim = len(line[1].split())
            except IndexError:
                dim = 1
                line = line[0].split()
            time_vect = np.zeros(len(content) - j)
            time_vect[0] = line[0]
            tab = np.zeros([len(content) - j, len(line) - 1, dim], dtype=float)

The new return of the function should be an array of vectors of the positions. I am not super familiar with OpenFOAM. If necessary, it can also be read out if a probe was in the domain or if only dummy data was written out.

A header of my probes, generated with OpenFOAM v2106:

# Probe 0 (-0.1599997156611697 -0.1430012427480623 0.02)  # Not Found
# Probe 1 (-0.1411821182118212 -0.1216852152363719 0.02)  # Not Found
# Probe 2 (-0.1223642364236424 -0.1003691877246815 0.02)
# Probe 3 (-0.1035463546354636 -0.07905316021299112 0.02)
# Probe 4 (-0.08472847284728473 -0.05773713270130074 0.02)
# Probe 5 (-0.06591059105910591 -0.03642110518961036 0.02)
# Probe 6 (-0.0470927092709271 -0.01510507767791999 0.02)
# Probe 7 (-0.02827482748274826 0.006210949833770418 0.02)
# Probe 8 (-0.009456945694569452 0.02752697734546078 0.02)
# Probe 9 (0.009192919291929197 0.04894795650267177 0.02)
# Probe 10 (0.02960696069606961 0.06865296732743971 0.02)
# Probe 11 (0.05224722472247226 0.08574924993606114 0.02)
# Probe 12 (0.07652565256525654 0.1004819781869841 0.02)
# Probe 13 (0.1023582358235824 0.1122743312794287 0.02)
# Probe 14 (0.1287368736873687 0.1227380007946636 0.02)
# Probe 15 (0.1551155115511551 0.1331984540812058 0.02)
# Probe 16 (0.1814941494149415 0.143658907367748 0.02)
# Probe 17 (0.2078727872787279 0.1541193606542902 0.02)
# Probe 18 (0.2342514251425143 0.1645798139408323 0.02)
# Probe 19 (0.2599997156611698 0.1747904156361355 0.02)

Any thoughts on this are highly appreciated.

[Meta]: Adding releases to the Github repository

Hello,
This is a meta question related to this repository. I think it would be very nice if releases added to the repository. This is useful because any user watching the repository could get notifications when a new release of fluidfoam is available.

Best regards

read probes error.

Dear developer,

I am using the latest package of fluidfoam. But when I test the example of plot_3_postprocprobe.py, error occured. I also noticed the latest update changed probes_locU.

Reading file ../output_samples/ascii/postProcessing/probes/0/U 4 probes over 10 timesteps Traceback (most recent call last): File "/Users/seanwang/Dropbox/@NUS/run/myLES/5_postProcess/fluidfoam-master/examples/plot_3_postprocprobe.py", line 21, in <module> probes_locU, timeU, u = readprobes(sol, time_name = 'mergeTime', name = 'U') File "/Users/seanwang/Library/Python/3.10/lib/python/site-packages/fluidfoam/readpostpro.py", line 132, in readprobes time_vect, tab = readprobes(path, probes_name, timename, name) File "/Users/seanwang/Library/Python/3.10/lib/python/site-packages/fluidfoam/readpostpro.py", line 198, in readprobes return time_vect, tab UnboundLocalError: local variable 'time_vect' referenced before assignment

Verbose flag/level for reading fields

For integration with other packages, it would be good if the functions on readof.py could receive an optional argument that would turn off the non-essential messages (e.g. "Reading file ..."). The default value could be set to True (or 1, if the preference is for verbosity levels) if backwards compatibility is essential.

I can prepare a PR if there is interest in the feature.

File dissapearing when processing multiple timesteps in a row

I have a weird problem and not sure why. I have the following code:

for j, t in enumerate(timesteps):
                # Read data
                vel = readvector(path, t, "U", verbose=args.verbose)
                p = readscalar(path, t, "p", verbose=args.verbose)

In some timesteps when I read p it fails and dissapears from the filesystem:

Traceback (most recent call last):
  File "mlwind\source\getbounds.py", line 80, in <module>
    main(parser.parse_args())
  File "mlwind\source\getbounds.py", line 54, in main
    p = readscalar(path, t, "p", verbose=args.verbose)
  File "fluidfoam\readof.py", line 750, in readscalar
    scalar = OpenFoamFile(
  File "fluidfoam\readof.py", line 100, in __init__
    with self._open(self.path, "rb") as f:
OSError: [Errno 22] Invalid argument: '..\\..\\mlwind2\\1.007875\\p'

I'm on Windows 11 x64, Python 3.10.13, fluidfoam 0.2.5.

Any ideas on what can be happening here? I'm totally puzzled.

Support for multi-region cases

Hello,
First off, thank you for this package. I have seen several using it successfully to post-process their OpenFOAM cases. But in all those cases, the mesh must be without multiple regions.

In some cases such as when using the Arbitrary mesh interface (using a sliding interface between two regions: a rotating region and a fixed domain), it's not possible to use fluidfoam to read the case.

I would like to ask if there are any planes to add this feature?

Best regards

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.