Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readpostpro probe reader header information #41

Closed
MaNyh opened this issue Nov 21, 2022 · 3 comments
Closed

readpostpro probe reader header information #41

MaNyh opened this issue Nov 21, 2022 · 3 comments

Comments

@MaNyh
Copy link

MaNyh commented Nov 21, 2022

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.

@CyrilleBonamy
Copy link
Collaborator

Hello @MaNyh,

Thank you very much for your issue.

For your problem, the simplest is that I show you what I have just coded quickly to read the positions of the probes: CyrilleBonamy@c3a2339#diff-699cb509103e2e5138ece7122f39177185bea7be242a665e12330885ae17ddd5R158

I invite you to test my implementation by getting my fork : https://github.com/CyrilleBonamy/fluidfoam.
And tell me if it meets your needs. If yes i will merge my modifications here.
Usage example : probes_loc, time_vect, dummy = fluidfoam.readprobes(case, time_name="mergeTime")

Don't hesitate to contribute if you feel like it.

@CyrilleBonamy
Copy link
Collaborator

implemented in #42

@MaNyh
Copy link
Author

MaNyh commented Mar 13, 2023

Hey there.

I wanted to appreciate your work. Thanks for the updated release. Next time i hope i can help myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants