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

Adds notebook to plot MFEM dofs and quadrature points #72

Merged

Conversation

kennyweiss
Copy link
Member

Currently hardcoded to plot only one element of a Cartesian mesh,
but can be extended relatively easily.

Current output contains figures of the following form (as svg, png and pdf figures, but not in an html table):
DOFs:
image

QPts:
image

Currently hardcoded to plot only one element of a Cartesian mesh,
but can be extended relatively easily.
* Only add alpha to fills, not to edges. This makes it easier to see the small qpts
* Sort qpt list by distance to center for nicer view of overlaps qpts
@kennyweiss
Copy link
Member Author

After some tweaks, the overlapping qpts looks a little nicer,
E.g. for P4 Open-Uniform:
image

@kennyweiss
Copy link
Member Author

@sshiraiwa -- Is there a way to add a binder for this?

@sshiraiwa
Copy link
Member

Good question! That would be wonderful, but TBH, i am not so familiar with Binder.
@tomstitt Do you have any advice?

@v-dobrev
Copy link
Member

One suggestion for small improvement: in the quadrature point plots make the area of the discs proportional to the quadrature weight -- right now it looks like the weight is proportional to the radius. Perceptually, we tend to see a disc as two times larger if its area is two times larger.

@v-dobrev
Copy link
Member

You can also use red color for negative weights. 😁

@kennyweiss
Copy link
Member Author

Thanks for the suggestions @v-dobrev -- working on it now

* Scale weights proportionally to area of circle instead of radius
* Use complementary color for negative weights
* Plot qpts at even orders
@kennyweiss
Copy link
Member Author

Here's the updated Open-Uniform P4 quadrature points:
image

@kennyweiss
Copy link
Member Author

Note: I didn't play with the scaling factors too much, e.g. in cases where the weights are significantly greater than 1,
like Open-Half-Uniform P10:
image

But there is an option not to scale the circles by weight, where it would look more like this:
image

@tomstitt
Copy link
Member

tomstitt commented May 5, 2021

Good question! That would be wonderful, but TBH, i am not so familiar with Binder.
@tomstitt Do you have any advice?

I've tried to get this working a bit ago but the default binder environment doesn't work because of the cmake build. There are ways to make more complex envs and I'll look into it more in the near future

" 'ix': ip.x, \n",
" 'iy': ip.y,\n",
" 'w' : ip.weight}\n",
" #print(d)\n",
Copy link
Member

Choose a reason for hiding this comment

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

(very minor) remove?

" pts = getDofPositions(fespace, 0)\n",
" plotDofPositions(F'{fec.Name()}_{bname}', pts, 0.05)\n",
" except:\n",
" #print(F\"\\tFEC {fec.Name()} did not work: dim {dim} -- basis type {b} -- fec type {f}\" )\n",
Copy link
Member

Choose a reason for hiding this comment

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

(very minor) remove?

" name = F\"qpts_{g_name}_{q['name']}_{dim}D_P{2*o}\"\n",
"\n",
" #for p in pts:\n",
" # print(F\"{name}: P{2*o} {p['w']}\")\n",
Copy link
Member

Choose a reason for hiding this comment

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

(very minor) remove?

"\n",
"To use this, your python environment must have:\n",
"* PyMFEM (https://github.com/mfem/PyMFEM)\n",
"* Matplotlib (https://matplotlib.org)"
Copy link
Member

Choose a reason for hiding this comment

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

add NumPy (https://numpy.org)?

"import os\n",
"import math\n",
"\n",
"%matplotlib inline\n",
Copy link
Member

Choose a reason for hiding this comment

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

(minor) not needed since you plot to files, did you want to have an option at the top like save_to_files that is True by default?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure about this one -- this notebook both plots the generated figures and saves them to disk.
Are you suggesting that it should be converted to one or the other?

Copy link
Member

@tomstitt tomstitt left a comment

Choose a reason for hiding this comment

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

Looks great! Nice work @kennyweiss !

@sshiraiwa
Copy link
Member

Looks like this (jupyterhub/mybinder.org-user-guide#56) makes a trick.
We have the launch binder button on the front page now.
It opens a binder session and shows a repository. I was able to go to example folder and launch ex1.ipynb.
Is this how we are supposed to use it, or any suggestions?

@sshiraiwa sshiraiwa merged commit 8ce6223 into mfem:master May 8, 2021
@sshiraiwa
Copy link
Member

sshiraiwa commented May 8, 2021

@kennyweiss
While the discussion is continuing, I merged this PR.
I also added matplotlib in binder/requirements.txt. This allows to run this notebook on Binder.
Please feel free to open another PR for any update. Thank you for the contribution.

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

Successfully merging this pull request may close these issues.

4 participants