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

Create a PNG image output object #13646

Merged
merged 14 commits into from
Jul 16, 2019
Merged

Create a PNG image output object #13646

merged 14 commits into from
Jul 16, 2019

Conversation

Hysrok
Copy link

@Hysrok Hysrok commented Jun 25, 2019

Adds the ability to create PNG files from the data provided by input files.
Can specify desired resolution.
Default output is grayscale, but can be put into color (current color scheme 'low -> high' is 'blue->red->yellow->white')
Can specify to save one specific step PNG (default is to save all steps with filename plus numerical identifier).

Closes #12846

Copy link
Member

@permcody permcody left a comment

Choose a reason for hiding this comment

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

I'm not going to repeat everything in every case. Go ahead and go over this PR and make sure you address each of my comments everywhere where it applies. Let me know if anything doesn't make sense. Nice work!

test/tests/bcs/periodic/wedge.i Outdated Show resolved Hide resolved
test/Makefile Outdated Show resolved Hide resolved
framework/src/outputs/PNGTest.C Outdated Show resolved Hide resolved
framework/src/outputs/PNGTest.C Outdated Show resolved Hide resolved
framework/src/outputs/PNGTest.C Outdated Show resolved Hide resolved
framework/src/outputs/PNGTest.C Outdated Show resolved Hide resolved
framework/src/outputs/PNGTest.C Outdated Show resolved Hide resolved
@dschwen
Copy link
Member

dschwen commented Jun 26, 2019

How about calling this PNGOutput? "Object" is a little strange.

PNGObject(const InputParameters & parameters);

// Method for assigning color values to the PNG
void setRGB(png_byte *rgb, float selection);
Copy link
Member

Choose a reason for hiding this comment

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

How is this working? You are not including libpng stuff here but use this type in a public interface. Does it have to be public in the first place?

Copy link
Member

Choose a reason for hiding this comment

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

Probably doesn't need to be public. This PR has a ways to go. I'm helping Sam get the right things into the Makefile and then we'll continue to work on the interface.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I don't see a reason any of it should be public except the constructor. Public was just easier to start. Right now I switched everything except the constructor to protected. Not sure if any of it should be private yet. I haven't really thought about what other classes would need from this class, if they'd ever need anything at all.

@dschwen
Copy link
Member

dschwen commented Jun 27, 2019

@Hysrok you might want to look into configuring your editor to automatically run clang-format on save...
Here is what I use: https://www.mooseframework.org/help/development/Atom_Editor.html

Copy link
Member

@permcody permcody left a comment

Choose a reason for hiding this comment

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

OK - this is my thorough review

framework/include/outputs/PNGOutput.h Outdated Show resolved Hide resolved
framework/include/outputs/PNGOutput.h Outdated Show resolved Hide resolved
framework/include/outputs/PNGOutput.h Outdated Show resolved Hide resolved
framework/include/outputs/PNGOutput.h Outdated Show resolved Hide resolved
framework/src/outputs/PNGOutput.C Outdated Show resolved Hide resolved
test/Makefile Outdated Show resolved Hide resolved
@@ -0,0 +1,124 @@
[Mesh]
Copy link
Member

Choose a reason for hiding this comment

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

Great! Now you need to add the "tests" file so that these actually get run. I'm going to suggest a "CheckFiles" test but we might be able to do better.

@aeslaughter - Can we do a png difference or is that only available within the python testing infrastructure?

test/tests/outputs/png/adv_diff_reaction_test.i Outdated Show resolved Hide resolved
test/tests/outputs/png/wedge.i Outdated Show resolved Hide resolved
@permcody
Copy link
Member

@Hysrok - I'm going to recommend that you start your fixes by looking at the non-unity build first. You are missing a lot of headers still...

Rule of thumb, if you use a type in your code, include the header (Prefer the .C file unless you have to put it in the .h file).

If you want to compile a non-unity build locally set MOOSE_UNITY=false in your environment and rebuild everything.

@permcody
Copy link
Member

@Hysrok - I added one more line to my existing Makefile branch for the include path to the header. We'll need that to make sure we pick up the right version of the png.h file. I think we are getting lucky and picking it up through conda or vtk (it exists in both places).

@dschwen
Copy link
Member

dschwen commented Jun 28, 2019

Just a thought, instead of reinventing the wheel on color output why not use a library like
https://github.com/richardroberts1992/Spectrum
to translate float values into colors taken from a colormap? This might very well be a follow on PR though.

@dschwen dschwen changed the title Created a class to create png files based on the tests that are run. Create a PNG image output object Jun 28, 2019
@friedmud
Copy link
Contributor

friedmud commented Jun 29, 2019 via email

@dschwen
Copy link
Member

dschwen commented Jun 29, 2019

Yeah, weird. Doesn't seem to use it though. Make a PR?

@Hysrok Hysrok force-pushed the PNGOuput branch 3 times, most recently from b1d1ffc to 49818fb Compare July 4, 2019 00:55
@Hysrok
Copy link
Author

Hysrok commented Jul 4, 2019

ssh: connect to host github.com port 22: Operation timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I've been getting this problem a lot today. I found a work around that worked for me, but now it looks like even the moosebuild precheck is having the problem. Is something wrong with GitHub, or am I just doing something wrong?

@permcody
Copy link
Member

permcody commented Jul 8, 2019 via email

@permcody
Copy link
Member

permcody commented Jul 9, 2019

@Hysrok - Looks like this is failing to build on Linux still. From a quick glance it might be that we are picking up inconsistent headers from libPNG or something. To troubleshoot this, you are going to want to login to a Linux system with the exact same environment as the build systems.

  1. ssh to "rod.hpc.inl.gov"
  2. run "moosebuild"
  3. clone, build libmesh, build moose and start troubleshooting

I can help when you get to step #3. I suspect we have some more work todo to get the include and library flags rock solid.

@moosebuild
Copy link
Contributor

Job Precheck on 6e158c4 wanted to post the following:

Your code requires style changes.

A patch was auto generated and copied here
You can directly apply the patch by running, in the top level of your repository:

curl -s https://mooseframework.inl.gov/docs/PRs/13646/style.patch | git apply -v

Alternatively, with your repository up to date and in the top level of your repository:

git clang-format cfcf841ec59b526ac8b1c538a1cb1b50a8811b22

@permcody
Copy link
Member

Ought oh.... Somehow you have a mess of other peoples commits in here now. Did you forget to rebase?

@permcody
Copy link
Member

Worse yet you clobbered your change you made earlier just before lunch.

@moosebuild
Copy link
Contributor

moosebuild commented Jul 11, 2019

Job Documentation on 985490b wanted to post the following:

View the site here

This comment will be updated on new commits.

@Hysrok Hysrok force-pushed the PNGOuput branch 2 times, most recently from 4488613 to fb059a3 Compare July 12, 2019 18:22
Samuel Tew and others added 12 commits July 12, 2019 14:55
- Fixed some formatting errors.
- Renamed the classes.
- Created tests that don't change the original tests.
-Using inheriting from FileOutput
-Input files for the png's aren't worrying about exodus etc
-Changed several types
-Removed unnecessary hardcoded lines from MakeFile
-Fixed naming convention of variables
-Added an #IFDEF to the header file
- Added the header files that were missing.
- Removed the macros.
- Redid filename configurations for created png's.
- Using MooseUtils to check file writability.
- Added include path to the header to make sure we get the right version 
of png.h.
- Added vector to store the row data to help avoid raw memory 
management.
- Revmoved the parameter PNGFile and anywhere it was referenced to.
- Added possible blue->red color scheme. Commented out for now.
…select a color scheme - Added additional comments to explain the code
-Wrapped PNGOoutput.C in MOOSE_HAVE_LIBPNG wrapper.
-Updated some colors.
-Added tranparency options.
-Added PNGOutput.md file
-Added "design" parameter in test input files
-Set max_parallel parameter to 1 for adv_diff_reaction
-Lowered the resolution of created images to avoid getting timed out
Removing duplicates and adding detail.
permcody
permcody previously approved these changes Jul 16, 2019
Copy link
Member

@permcody permcody left a comment

Choose a reason for hiding this comment

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

Looks good! I updated your requirements a bit since we don't accept duplicate requirements anymore. Once this tests successfully I'll get it merged. Let me know when you get in and we can talk about what's next and your poster.

@permcody permcody added the PR: Auto Merge Add this label to have CIVET merge on success label Jul 16, 2019
[png]
type = PNGOutput
transparent = true #indicates whether the background will be transparent
resolution = 50 #resolution of each point
Copy link
Member

Choose a reason for hiding this comment

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

Just looking at the documentation strings I have no idea what this number means. The code suggests it is a scale factor to get from MOOSE length units to pixels. I suggest to make this clear in the docs.

Copy link
Member

Choose a reason for hiding this comment

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

The resolution might be "pixels", except that's not even a great definition with things like retina displays and everything else that complicates rendering sizes. This is the number of "samples" taken in the x and y directions right now but that's not the best solution for resolution, which should be in units per something. Also we need to account for different spacing in x and y. More work to do.

@permcody
Copy link
Member

@dschwen - We are going to be working on the next phase of this project now. This capability isn't useful yet on anything but small images because of the extensive use of MeshFunction. It can take minutes to generate a single image on a workstation size run right now. I'm going to merge this in and we will continue to work on documentation and capability as we make this scalable.

@permcody permcody merged commit 5351080 into idaholab:next Jul 16, 2019
permcody added a commit to permcody/moose that referenced this pull request Jul 17, 2019
- PNGOutputter restricted to work in dynaimc linkage mode only
  due to unresolved linkage problem with the library in static mode
- Some constness added to member variables
- Memory issue fixed

refs idaholab#13646
permcody added a commit to permcody/moose that referenced this pull request Jul 17, 2019
- PNGOutputter restricted to work in dynaimc linkage mode only
  due to unresolved linkage problem with the library in static mode
- Some constness added to member variables
- Memory issue fixed

refs idaholab#13646
@friedmud
Copy link
Contributor

friedmud commented Jul 23, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Auto Merge Add this label to have CIVET merge on success
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MOOSE Rasterizer
5 participants