Skip to content

Conversation

@termi-official
Copy link
Contributor

@termi-official termi-official commented Oct 8, 2021

I work coupled 1D-3D problems so for me it is sometimes helpful to visualize the solutions side by side while MFEM is computing the solution to track down issues.

The draft is not very clean yet and might come with some level of memory corruption (could not test everything in detail yet). This is basically my late try on fixing #68 .

To test the PR I currently just utilize two very simple meshes which I feed into MFEM example 0.

3D mesh

MFEM mesh v1.0

dimension
1

elements
5
1 1 0 1
1 1 1 2
1 1 2 3
1 1 2 4
2 1 4 5

boundary
3
1 0 0
2 0 3
3 0 5

vertices
6
3
  0    0 -1.0
1.0    0    0
2.0    0    0
3.0  1.0    0
3.0 -1.0    0
4.0 -1.0  1.0

3D vector test field

FiniteElementSpace
FiniteElementCollection: H1_1D_P2
VDim: 3
Ordering: 0

0
2.029082637937203
2.25675394962394
0
2.128376974811976
0
1.264541318968602
2.267918293780571
1.378376974811971
2.442565462217959
1.314188487405989
0.6947706594843015
2.179750465858888
1.880065462217956
2.412159705920951
1.783782731108984
1.709311978452903
2.293586121702257
0.7516884874059858
2.347971218514969
0.719594243702995
0
2.029082637937203
2.25675394962394
0
2.128376974811976
0
1.264541318968602
2.267918293780571
1.378376974811971
-1.442565462217959
1.314188487405989
0.6947706594843015
2.179750465858888
1.880065462217956
2.41211241205920951
1.783782731108984
1.709311978452903
-2.293586121702257
0.7516884874059858
0.347971218514969
0.719594243702995
0
2.029082637937203
2.25675394962394
0
2.128376974811976
0
1.264541318968602
2.267918293780571
1.378376974811971
2.442565462217959
-1.314188487405989
0.6947706594843015
-2.179750465858888
2.179750465858888
1.880065462217956
-2.412159705920951
1.783782731108984
2.293586121702257
-0.7516884874059858
2.347971218514969
0.719594243702995

2D mesh

MFEM mesh v1.0

dimension
1

elements
5
1 1 0 1
1 1 1 2
1 1 2 3
1 1 2 4
2 1 4 5

boundary
3
1 0 0
2 0 3
3 0 5

vertices
6
2
  0    0 
1.0    0 
2.0    0 
3.0  1.0 
3.0 -1.0 
4.0 -1.0 

2d vector test field

FiniteElementSpace
FiniteElementCollection: H1_1D_P1
VDim: 2
Ordering: 0

-0.84018773
-0.39438292
-0.78309923
-0.79844004
-0.91164738
-0.19755137
-0.33522275
-0.7682296
-0.27777472
-0.55396998
-0.47739705
-0.6288709

scalar test field

0
2.029082637937203
2.25675394962394
0
2.128376974811976
0
1.264541318968602
2.267918293780571
1.378376974811971
2.442565462217959
1.314188487405989

GlVis output (left 2D, right 3D)
glvis-1d-domain-example

TODOs

  • Visualizing the grid without solution
  • Visualizing element attributes
  • Visualizing boundary attributes (possible future work)
  • Visualizing the element endpoints correctly (possible future work)
  • Visualizing high order solutions
  • Vector valued problems
  • Merge master after Configurable line width with modern OpenGL #232 gets merged
  • Add keys to control line width for solution interactively
  • Add tests

@tzanio
Copy link
Member

tzanio commented Oct 16, 2021

This looks really cool @termi-official. If you clean it up we will be interested in merging it. -Tzanio

@termi-official
Copy link
Contributor Author

termi-official commented Oct 23, 2021

Okay this is more problematic than anticipated. I am currently working on modifying the mesh to support mixed dimensional elements (while also making at least 1d branching meshes possible, because they are required from time to time in mechanics and electrophysiology).

One major issue I ran into is that the elements keep disconnecting (I assume because for branched meshes the connectivity tables are broken) - this is "fixed" by simply providing different visualization modes for now.

Some features are missing in 1d vis which I probably cannot address by myself. I am aware that the following does not work (see above for bullet points).

@termi-official termi-official marked this pull request as ready for review October 23, 2021 14:26
@tzanio tzanio mentioned this pull request Apr 13, 2022
7 tasks
@termi-official
Copy link
Contributor Author

termi-official commented May 24, 2022

Turns out many of the issues I encountered has been fixed with recent MFEM patches and the ongoing restructuring of the GLVis codebase. Scalar field visualization is basically working now. Some minor things remain to be resolved for scalar fields.

GLVis_s01

However, vector-valued fields are still open, which are important in some areas of mechanics.

@termi-official
Copy link
Contributor Author

Okay 3d vector visualization is also okayish now.

GLVis_s01

The visualization is not very pretty, because modifying the renderer to include dynamic line thickness information seems a big out of scope for now. I also noticed a crazy amount of code duplication between scalar and vector field visualizer classes. Maybe a good future PR is to merge the duplicate code (and hence features).

@termi-official
Copy link
Contributor Author

Bump @tzanio @publixsubfan . I think #232 is not being worked on anymore? Can we merge this PR then and leave the open TODOs for a follow up PR which addresses line rendering?

@tzanio
Copy link
Member

tzanio commented Aug 6, 2023

Can we merge this PR then and leave the open TODOs for a follow up PR which addresses line rendering?

Yes, lets do that. Sorry for the long delay @termi-official !

@termi-official
Copy link
Contributor Author

Absolutely no problem! :) I will merge master and fi the remaining errors tomorrow.

Copy link
Member

@tzanio tzanio left a comment

Choose a reason for hiding this comment

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

Two more items:

  1. Can you please update CHANGELOG

  2. Should we add some of the 1D example meshes/results in MFEM and/or https://github.com/GLVis/data?

Thanks again for the contribution, @termi-official!

Tzanio

Comment on lines +1155 to +1156
double line_width = GetLineWidth();
double ms_line_width = GetLineWidthMS();
Copy link
Member

Choose a reason for hiding this comment

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

Do these make any difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If your question is regarding the change itself, then this change just introduces a call to the internal API to keep the defaults consistent. If your question is regarding whether multisampling makes a difference, then it depends on the system. Not all systems support the respective OpenGL calls for multisampling of lines, which is part of the reason why I wanted to merge the line rendering PR before this. However, this PR is also functional without the line rendering PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For example pressing A on my workstation during interactive visualization removes stair-casing though antialiasing.

Comment on lines -629 to -632
// if (vals(j) >= 0.0)
// vals(j) = sqrt(vals(j));
// else
// vals(j) = -sqrt(-vals(j));
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure we can remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a comment on master, so it does not have any functional consequences - should I leave it anyway?

Comment on lines +1403 to 1405
if (v_normals && dim > 1)
{
PrepareWithNormals();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regarding this change here I am not super confident. This change will need intervention further intervention for the line rendering PR to setup the normals of the flat representation correctly.

@termi-official
Copy link
Contributor Author

termi-official commented Aug 7, 2023

Sure, we can think about adding some of the 1D network mesh stuff to MFEM, but we might need to think a bit how to do this one properly. My heart simulation framework is heavy patchwork (subclasses of mesh to patch the connectivity tables) to work around the assumption that we have the scenario of more than 2 element sharing a face. I do not have a good solution to make this properly work for now, because this assumption seems to be quite deeply rooted into the MFEM core. Happy to discuss further.

Edit: I should note that the "solution" for the visualization in the PR description is hand-constructed and not part of any simulation. I can make a PR into the data repository for smoke tests.

@tzanio
Copy link
Member

tzanio commented Aug 8, 2023

Thanks for making the changes, @termi-official !

@jandrej jandrej self-requested a review August 12, 2023 17:14
@tzanio tzanio merged commit c2e621c into GLVis:master Aug 12, 2023
@termi-official termi-official deleted the 1d-elements-dev branch August 12, 2023 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants