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

Wave visualization as a post-processing function #678

Merged
merged 30 commits into from
Aug 25, 2021

Conversation

jtgrasb
Copy link
Contributor

@jtgrasb jtgrasb commented Aug 12, 2021

I created a function in the response class which creates a visualization of the waves and body reactions and saves it as either a video file or gif. I've attached examples below of the RM3 with regular waves and the OSWEC with irregular, directional waves.

wave_visualization_rm3

wave_visualization_oswec

The function can be run by adding "output.plotWaves(simu.dt,1,simu.g,[-100 100 -100 100 -40 15],body,waves,1);" to the userDefinedFunctions.

@akeeste akeeste assigned akeeste and unassigned akeeste Aug 13, 2021
@akeeste akeeste self-requested a review August 13, 2021 18:11
Copy link
Contributor

@akeeste akeeste left a comment

Choose a reason for hiding this comment

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

See inline comments for suggested changes. I think this works well but there are a few changes that can make it more robust and easier to read. Also, I would consider including a colored plane for the seafloor and force the axes to have the same aspect ratio (see daspect([]) or axis equal commands). If not, then the device can appear stretched depending on the domain size input

source/objects/responseClass.m Outdated Show resolved Hide resolved
source/objects/responseClass.m Outdated Show resolved Hide resolved
source/objects/responseClass.m Outdated Show resolved Hide resolved
source/objects/responseClass.m Outdated Show resolved Hide resolved
source/objects/responseClass.m Outdated Show resolved Hide resolved
source/objects/responseClass.m Outdated Show resolved Hide resolved
source/objects/responseClass.m Outdated Show resolved Hide resolved
@jtgrasb
Copy link
Contributor Author

jtgrasb commented Aug 16, 2021

@akeeste Thanks for the suggestions! I made the requested changes and I think it is a lot simpler and easier to read now. One small issue I ran into is that because I used simu.domainSize/2 for the axes, the seafloor is not on the figure for the RM3 because it's at -200 m. Should I just make the axes go to the full simu.domainSize?

@akeeste
Copy link
Contributor

akeeste commented Aug 16, 2021

@jtgrasb For the lower z-axis limit, you could instead use -waves.waterDepth. This is the parameter that currently determines the depth shown in the Mechanics Explorer.

The upper z-axis limit doesn't need to be very high. A couple thoughts:

  • Easy solution - choose something relatively arbitrary (15m? 20m?) and let users optionally input the z-limits to overwrite the default value.
  • Alternative - use the maximum z position of the bodies and calculate the highest point that any mesh reaches. The maximum z-axis could then be that point + ~5m.

It might be worthwhile letting users override the default limits regardless of method chosen.

@jtgrasb
Copy link
Contributor Author

jtgrasb commented Aug 17, 2021

@akeeste I like the idea of having options instead of needing to specify some of the inputs. I made the default z maximum 10 and allow the user to input the axis limits, timesPerFrame, and saveSetting as optional inputs.

- use ``options.axisLimits`` for ``X,Y`` grids
- allow different simu.dtOut and simu.dt
- Change default z axis maximum to -999. By default this is overwritten with the ``maxHeight`` of the body if the user does not input another option
- move time annotation to the 2nd title line so that it cannot lie on top of the title box (this happened to me depending on the figure size upon opening)
@akeeste
Copy link
Contributor

akeeste commented Aug 17, 2021

@jtgrasb Great work! I made a few more minor changes:

  • use options.axisLimits for X,Y grids
  • allow different simu.dtOut and simu.dt
  • Change default z axis maximum to -999. By default this is overwritten with the maxHeight of the body if the user does not input another option
  • move time annotation to the 2nd title line so that it cannot lie on top of the title box (this happened to me depending on the figure size upon opening)

I wasn't sure if you will have time to review before your semester starts so I went ahead and committed directly to your branch. Let me know if you disagree with anything

Adam

@akeeste
Copy link
Contributor

akeeste commented Aug 17, 2021

@kmruehl @jtgrasb My only other concern is that this function will not work with the variable step solver. However this relates to a larger problem of how we use simu.maxIt to calculate the waves.waveAmpTime before the simulation, instead of using the actual simulation sample time or the output sample time. I am okay merging this PR in and addressing the variable step solver problems later on when I solve issue #656

@kmruehl kmruehl added Visualization Visualization and Paraview Wave Class Wave Classs (waveClass.m) labels Aug 23, 2021
@kmruehl
Copy link
Contributor

kmruehl commented Aug 23, 2021

@akeeste I like the idea of having options instead of needing to specify some of the inputs. I made the default z maximum 10 and allow the user to input the axis limits, timesPerFrame, and saveSetting as optional inputs.

@jtgrasb another option would be to make it a multiplier of waves.H, so it could be 4*waves.H by default (or similar).

@kmruehl
Copy link
Contributor

kmruehl commented Aug 23, 2021

@kmruehl @jtgrasb My only other concern is that this function will not work with the variable step solver. However this relates to a larger problem of how we use simu.maxIt to calculate the waves.waveAmpTime before the simulation, instead of using the actual simulation sample time or the output sample time. I am okay merging this PR in and addressing the variable step solver problems later on when I solve issue #656

@akeeste that sounds good to me. I think we should go ahead and merge it and then open an issue or project card related to the variable time-step issue with this feature.

@kmruehl kmruehl self-requested a review August 23, 2021 23:25
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.

@jtgrasb and @akeeste I made some minor revisions in this PR, feel free to merge or resolve them elsewhere: jtgrasb#1

  • added output.plotWaves to examples, we could comment this but provide it as an example
  • resolved issues with examples files to use the wecSimInputFile instead of custom parameters

To Do

  • add documentation

@kmruehl kmruehl self-requested a review August 24, 2021 00:15
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.

Please add documentation!

@akeeste
Copy link
Contributor

akeeste commented Aug 24, 2021

Please add documentation!

@kmruehl Where are you thinking to add this? I don't see anything in the documentation about plotForces() or plotReponse() outside of the autogenerated API. Maybe we should start an advanced features section on the response class?

@kmruehl
Copy link
Contributor

kmruehl commented Aug 24, 2021

@akeeste I think that's a good suggestion. The only reason we don't have docs for functions it because they were merged prior to our enforcement of the docs requirement. So if you'd like to add docs for them too... :)

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.

This looks good, I'll add a the lines to the examples, and we should be good to go.

@kmruehl kmruehl merged commit 2d83275 into WEC-Sim:dev Aug 25, 2021
@jtgrasb jtgrasb deleted the wave_viz_post branch November 17, 2021 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Visualization Visualization and Paraview Wave Class Wave Classs (waveClass.m)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants