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

Add FieldPoyntingFlux reduced diagnostic #5475

Open
wants to merge 32 commits into
base: development
Choose a base branch
from

Conversation

dpgrote
Copy link
Member

@dpgrote dpgrote commented Nov 20, 2024

This adds a reduced diagnostic that calculates the Poynting flux on the surfaces of the domain, providing the power flow into and out of the domain. This also includes the time integrated data.

When using the implicit evolve scheme, to get the energy accounting correct, the flux needs to be calculated at the mid step. For this reason, the ComputeDiagsMidStep was added which is called directly at the appropriate times.

Because of the time integration, there are two main differences of this reduced diagnostic compared to the others. The first is that it is calculated every time step in order to get the full resolution in time. The intervals parameter still controls how often the diagnostic data is written out. The second is that a facility is added to write out the values of the time integration to a file when a checkpoint is made, so on a restart the integration can continue with the previous values. The facility was written in a general way so that other reduced diagnostics can also do this.

The CI test using the implicit solver is dependent on PR #5498 and PR #5489.

@dpgrote dpgrote added the component: diagnostics all types of outputs label Nov 20, 2024
@dpgrote dpgrote changed the title [WIP]Add FieldPoyntingFlux reduced diagnostic Add FieldPoyntingFlux reduced diagnostic Dec 9, 2024
EZoni pushed a commit that referenced this pull request Jan 17, 2025
Fix #5482.

Also, with this PR the temporary implicit particle attributes are not
written to the checkpoint file, and also are not communicated when doing
a redistribute of the particles. Note that this requires AMReX PR #4264.

A CI test of this restart is included in PR #5475.

---------

Co-authored-by: David Grote <[email protected]>
Comment on lines +173 to +180
if (face().isHigh() && WarpX::field_boundary_hi[face_dir] == FieldBoundaryType::Periodic) {
// For upper periodic boundaries, copy the lower value instead of regenerating it.
int const iu = int(face());
int const il = int(face().flip());
m_data[iu] = -m_data[il];
m_data[iu + 2*AMREX_SPACEDIM] = -m_data[il + 2*AMREX_SPACEDIM];
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps another option to consider would be to skip writing for periodic directions all together.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would rather leave it in. It could be a useful diagnostic to keep track of flows in the system. Also, skipping the periodic directions would make the format of the output file be dependent on the boundary conditions which would be problematic when reading it.

@JustinRayAngus
Copy link
Contributor

This looks good to me, pending the minor comments I made.

After a closer look at the 2D CI test, it seems that FieldBoundaryType::Neumann does nothing for the electromagnetic solvers. As we have discussed, this can be addressed in a future PR.

@JustinRayAngus JustinRayAngus enabled auto-merge (squash) February 3, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: diagnostics all types of outputs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants