Skip to content

Visualization of complex functions#352

Merged
tzanio merged 46 commits intomasterfrom
complex-gf-vis
Jan 31, 2026
Merged

Visualization of complex functions#352
tzanio merged 46 commits intomasterfrom
complex-gf-vis

Conversation

@najlkin
Copy link
Contributor

@najlkin najlkin commented Jan 15, 2026

This PR adds visualization of complex grid functions, which are represented different ways:

  • magnitude
  • phase
  • real part
  • imaginary part

To switch the representation, you may use Q key (like for quadratures) TODO: find a better one 😄
The functions can be loaded from files as normally (the file reader recognizes the format based on the header) or through a socket stream by the new command csolution (also automatically detected).

imageimage
Magnitude and phase in example 22.

The complex solution can be also animated by varying the complex phase. To increase the phase rate, press Alt+Enter, and to decrease Alt+0. To stop/start Alt+. 🎞️ .

↪️dependency: #336

@najlkin najlkin added this to the glvis-4.5 milestone Jan 15, 2026
@najlkin najlkin self-assigned this Jan 15, 2026
@najlkin najlkin added the WIP label Jan 15, 2026
@najlkin najlkin mentioned this pull request Jan 15, 2026
44 tasks
@najlkin najlkin requested a review from mlstowell January 15, 2026 02:09
@najlkin
Copy link
Contributor Author

najlkin commented Jan 15, 2026

@mlstowell , if you are testing it with example 22 in parallel, GLVis crashes quite often, but it is not fault of this PR. I realized the ordering is wrong there and should be fixed eventually. Check other examples, it should be:

  • open socket
  • send data
  • MPI barrier
  • ...

While you batch all operations which causes mismatches in received data as GLVis has no way to know what sockets should be grouped together 🤪 .

@najlkin najlkin requested a review from tzanio January 15, 2026 06:13
@mlstowell
Copy link
Contributor

I'm just starting to look at this but I like it. I can visualize the four fields mentioned in the header but I haven't found the animation option. I can adjust the phase rate as you mention but I'm not seeing an animation so the phase rate doesn't seem to do anything.

Perhaps this feature is not available yet...

@najlkin
Copy link
Contributor Author

najlkin commented Jan 15, 2026

It should be, it works for me 🤔 . Have you switched the representation? Magnitude does not show anything, because it is independent of the phase 😅 .

@mlstowell
Copy link
Contributor

Okay, I see it now. The comment written to screen misled me. When I saw:
Representing complex function by: real part
I thought that was the only thing that would be available in that mode. Perhaps we can add to those comments. Something like:
Representing complex function by: real part (animate with ';')

Another thing I might change is the limits on the color bar. For the phase plot I would suggest a constant range from -pi to pi. For the real and imaginary parts I would suggest a constant range from -max(magnitude) to max(magnitude). I find these constant ranges are more illustrative during animations. What do you think?

@najlkin
Copy link
Contributor Author

najlkin commented Jan 27, 2026

Ok, I generalized the detection of the value range to vector functions. These should be the combinations of complex value representations and vector representations:

cmplx\vec magnitude direction component
magnitude default default default
phase [0, π √dim] [-π,+π] [-π,+π]
component [|mag|min, |mag|max] [-π,+π] [-magmax, +magmax]

where magmin/max is the minimal/maximal complex magnitude.

@najlkin
Copy link
Contributor Author

najlkin commented Jan 28, 2026

After a discussion with @psocratis , I have changed the projection of magnitude and phase (which are nonlinear transformations in essence) from DOF projection to L2 space. This gives smoother visualizations for vector finite elements 😉

@najlkin
Copy link
Contributor Author

najlkin commented Jan 29, 2026

🐛 A known bug, animations of solutions, which overload the internal buffer of socketstream (as GLVis lags behind) are broken due to the automatic detection of complex grid functions in the stream.
UPDATE: After multiple iterations, I have fallen back to just peeking the first character, because there seems to be no reliable way how to not extract/return characters to streams.

@najlkin najlkin changed the title [WIP] Visualization of complex functions Visualization of complex functions Jan 29, 2026
@najlkin najlkin changed the base branch from master to egl-headless January 29, 2026 17:18
@najlkin
Copy link
Contributor Author

najlkin commented Jan 29, 2026

I temporarily changed the base for easier reviewing 😉

@tzanio tzanio requested a review from camierjs January 29, 2026 21:38
@camierjs
Copy link
Contributor

Being able to push directly the ComplexGridFunction is really neat! Works nicely!
Thank you @najlkin !

@najlkin
Copy link
Contributor Author

najlkin commented Jan 30, 2026

❗ TODO: Before merging, the associated data pull request GLVis/data#8 should merged first and the submodule hash here should be updated to point to the merge commit on data/master .

Base automatically changed from egl-headless to master January 31, 2026 03:56
@tzanio tzanio merged commit 201e2df into master Jan 31, 2026
10 checks passed
@tzanio tzanio deleted the complex-gf-vis branch January 31, 2026 04:01
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.

4 participants