Skip to content

Commit

Permalink
Fix #3448 (#3450)
Browse files Browse the repository at this point in the history
  • Loading branch information
StasJ committed Sep 19, 2023
1 parent cc9d1b1 commit 0b5cc7f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions apps/pythonapi/examples/flow_example.py
Expand Up @@ -123,3 +123,21 @@
ren.SetSeedGenMode(ren.FlowSeedMode.LIST)
ren.SetSeedInputFilename("flow_seeds.txt")
ses.Show()

# %% [md]
#
# ### Outputting Flow Lines
#
# The advected flow lines can be saved to a .csv file
#
# %%
ren.SetFlowlineOutputFilename("flow_output.csv") # Needs to be set once per renderer
ren.SetFlowOutputMoreVariables([U, V]) # Optionally specify additional variables to sample at each point

ren.SetNeedFlowlineOutput(True) # Needs to be called before each render call that should output the computed flow in a .csv file
_ = ses.RenderToImage() # This returns a PIL image variable that is not displayed by default and can be ignored if only saving flow output

# %%
import pandas as pd
pd.read_csv("flow_output.csv", sep=",").head(10)

3 changes: 3 additions & 0 deletions apps/pythonapi/vapor/renderer.py
Expand Up @@ -209,7 +209,10 @@ class FlowRenderer(Renderer, wrap=link.VAPoR.FlowParams):
SetSeedInputFilename
GetFlowlineOutputFilename
SetFlowlineOutputFilename
GetNeedFlowlineOutput
SetNeedFlowlineOutput
GetFlowOutputMoreVariables
SetFlowOutputMoreVariables
GetPeriodic
SetPeriodic
GetGridNumOfSeeds
Expand Down
4 changes: 4 additions & 0 deletions include/vapor/FlowParams.h
Expand Up @@ -151,6 +151,10 @@ class PARAMS_API FlowParams : public RenderParams {
//! \retval std::vector<std::string> - A vector containing the variables being written to the specified output file name.
std::vector<std::string> GetFlowOutputMoreVariables() const;

//! One or more variable to be sampled along flowlines and written to an output file.
//! \param[in] std::vector<std::string> - A vector containing the variables being written to the specified output file name.
void SetFlowOutputMoreVariables(std::vector<std::string> vars);

//! Inquires whether the current flow advection scheme is periodic.
//! \details IE - Do pathlines or streamlines continue on the opposite side of the domain when the exit it? Similar to when PAC-MAN exits the right side of the screen, and re-enters on the left.\n
//! Note: this result vector could be of size 2 or 3.
Expand Down
1 change: 1 addition & 0 deletions lib/params/FlowParams.cpp
Expand Up @@ -202,6 +202,7 @@ std::string FlowParams::GetFlowlineOutputFilename() const { return GetValueStrin
void FlowParams::SetFlowlineOutputFilename(const std::string &name) { SetValueString(_flowlineOutputFilenameTag, "filename for output flow lines", name); }

std::vector<std::string> FlowParams::GetFlowOutputMoreVariables() const { return GetValueStringVec(_flowOutputMoreVariablesTag); }
void FlowParams::SetFlowOutputMoreVariables(std::vector<std::string> vars) { SetValueStringVec(_flowOutputMoreVariablesTag, "", vars); }

int FlowParams::GetFlowDirection() const { return GetValueLong(_flowDirectionTag, (int)FlowDir::FORWARD); }

Expand Down

0 comments on commit 0b5cc7f

Please sign in to comment.