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

Feature paraview #1081

Merged
merged 6 commits into from Aug 3, 2023
Merged

Feature paraview #1081

merged 6 commits into from Aug 3, 2023

Conversation

agmoore4
Copy link
Contributor

@agmoore4 agmoore4 commented Jul 7, 2023

Several changes were made to improve visualization with ParaView and make WEC-Sim compatible with ParaView 5.11.1:

  • Previously, the script WEC-Sim.py used BlockIndices with ExtractBlock. As of Paraview 5.10, ExtractBlock no longer works with BlockIndices. ExtractBlock was updated to use Selectors instead. Similarly, the method of counting the number of bodies had to be changed to be compatible with ParaView 5.11.1.
  • Previously, the script pressureGlyphs.py could not find the properties it needed (Hydrostatic Pressure, etc.) because whitespace is automatically removed in calculator.Function strings. To resolve this, spaces were removed from the property names in writeParaviewBody.m (eg, HydrostaticPressure).
  • The documentation for the ParaView section of user/advanced_features was updated to reflect the current examples in WEC-Sim_Applications. New animations for the two examples will be sent to Kelley to be included in the documentation.
  • Previously, simu.paraview.startTime and simu.paraview.endTime were set to 0 and 100 by default in simulationClass.m, which led to the waves and the bodies to be visualized for different amounts of time. This was changed so that simu.paraview.startTime and simu.paraview.endTime are initialized as empty in simulationClass.m. Then in paraviewVisualization.m, if still empty after reading the input file, they are set to match simu.startTime and simu.endTime, respectively.
  • Previously, the displayed times in ParaView were forced to always start at t=0 by subtracting off simu.paraview.startTime in paraviewVisualization.m. This was changed for clarity so that ParaView always refers to the beginning of the simulation as t=0, meaning that the visualization's first time step will always be the same value as simu.paraview.startTime.

@kmruehl kmruehl self-requested a review July 10, 2023 15:41
@kmruehl kmruehl added the Visualization Visualization and Paraview label Jul 10, 2023
@kmruehl kmruehl self-assigned this Jul 10, 2023
Copy link
Contributor

@kmruehl kmruehl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @agmoore4 for your Paraview PR. My apologies for the delay reviewing it. Overall this looks really good. I had a comment regarding paraview.dt, otherwise I think this is ready for a merge.

'startTime', 0, ... %
'endTime', 100, ... %
'startTime', [], ... %
'endTime', [], ... %
'dt', 0.1, ... %
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should paraview.dt = [ ] too? For consistency I think it should, and then it should also be updated in paraviewVisualization.m, similar to paraview.startTime and paraview.endTime

end
if isempty(simu.paraview.endTime)
simu.paraview.endTime = simu.endTime;
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should also add an if statement here to set simu.paraview.dt

@@ -29,9 +29,15 @@
mkdir([simu.paraview.path filesep 'body' num2str(vtkbodiesii) '_' bodyname]);
TimeBodyParav = output.bodies(ii).time;
PositionBodyParav = output.bodies(ii).position;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all of this could be inside one if statement that re-assigns TimeBodyParaview only if paraview.startTime, paraview.endTime, or paraview.dt are specified. Otherwise all of these lines can be skipped, and go straight to line 41.

if isempty(simu.paraview.startTime) || isempty(simu.paraview.dt) || isempty(simu.paraview.endTime)
            if isempty(simu.paraview.startTime)
                simu.paraview.startTime = simu.startTime;
            end
            if isempty(simu.paraview.dt)
                simu.paraview.dt= simu.dt;
            end
            if isempty(simu.paraview.endTime)
                simu.paraview.endTime = simu.endTime;
            end
            NewTimeParaview(:,1) = simu.paraview.startTime:simu.paraview.dt:simu.paraview.endTime;
            PositionBodyParav = interp1(TimeBodyParav,PositionBodyParav,NewTimeParaview);
            TimeBodyParav = NewTimeParaview;
end

@agmoore4
Copy link
Contributor Author

agmoore4 commented Aug 1, 2023

Implemented the requested changes.

@kmruehl
Copy link
Contributor

kmruehl commented Aug 2, 2023

@agmoore4 this looks good, and it's ready for a merge once you update the embedded videos. The update should be something like this for the RM3:

.. raw:: html

	<iframe width="560" height="315" src="https://www.youtube.com/embed/yL6LHdYTBIo" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

and this for nonlinear:

.. raw:: html

	<iframe width="560" height="315" src="https://www.youtube.com/embed/JfKxQ1AgQBk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

@kmruehl
Copy link
Contributor

kmruehl commented Aug 3, 2023

Thanks @agmoore4. As soon as these tests run and pass I'll merge the PR

@kmruehl
Copy link
Contributor

kmruehl commented Aug 3, 2023

All tests are passing, so I'm going to merge this PR. Thanks again!

@kmruehl kmruehl merged commit 8655893 into WEC-Sim:dev Aug 3, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Visualization Visualization and Paraview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants