forked from boutproject/hermes-3
-
Notifications
You must be signed in to change notification settings - Fork 1
Extending the kinetic mesh beyond the BOUT++ plasma domain #44
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
Draft
mrhardman
wants to merge
48
commits into
VANTAGE-Reactions-Coupling/dev
Choose a base branch
from
VANTAGE-Reactions-Coupling/dmplex-features
base: VANTAGE-Reactions-Coupling/dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
4bdba86
For the `particle_animator.py` script, use the length normalisation s…
mrhardman 839d0a8
Initial changes to load a mesh from a GMSH .msh file in serial, and t…
mrhardman fbc2695
Define `use_external_msh` in the VANTAGE class to allow the same flag…
mrhardman fc820e9
Move definition of dg0 pointer to vantage header file, introduce sket…
mrhardman d53e0ee
Make separate function for writing the DMPlex to HDF5.
mrhardman 3ef4de7
Use a c++ style static cast in `DMPlexCreateGmshFromFile()`.
mrhardman 720781d
Restructure `vantage_dmplex.cxx` so that `create_dmplex_from_Bout_mes…
mrhardman 03a1566
Make `kinetic_mesh_map` a class variable, read in map to global index…
mrhardman ab9b186
Add Rxy, Zxy, and corner variables to the BOUT.dmp.vantage.*.nc outpu…
mrhardman 2b5f8ea
Set xlim based on command-line argument.
mrhardman f769f56
Use forward and backward tranfers in conversion from NESO-Particles d…
mrhardman 0e0b1f7
Extend the kinetic -> bout mesh data transfer to the VantageSourceMan…
mrhardman d1c4ccf
Refactor the inputs of the [vantage] component so that pressure and t…
mrhardman a9dbfac
Experiments using .vtkhdf for prototype velocity-moment diagnostics o…
mrhardman b9d3d2c
Create function to contain kinetic moment diagnostic code.
mrhardman 39d2c9d
Update derived diagnostics moment kernels before projection.
mrhardman 1d38449
Calculate the Gamma = nu mean flow moment in the kinetic diagnostics.
mrhardman f8f0f5f
Refactor diagnostics calculation to enable the calculation of derived…
mrhardman 61e1d25
Merge branch 'VANTAGE-Reactions-Coupling/dev' into VANTAGE-Reactions-…
mrhardman 10924f9
Extend checks on cell volumes to cover the case where the kinetic mes…
mrhardman 559302b
Ensure that `y_boundary_guards` is saved to that the `BOUT.dmp.vantag…
mrhardman 1badeeb
Begin refactoring diagnostics so that they are managed through a clas…
mrhardman 277ac52
Split kinetic diagnostic function into update and write functions.
mrhardman 88a58f2
Initial move of BOUT++ style diagnostic functions to VantageDiagnosti…
mrhardman fca6dec
Extract BOUT++ Field2D from the computed scalar variable diagnostics …
mrhardman b146830
Split VantageSourceManager class to separate file to speed up compila…
mrhardman 26986ed
Add a vector to store source data on the kinetic mesh.
mrhardman 9a65ea0
Define get functions for plasma grid and kinetic mesh data.
mrhardman 5891a06
Changes aimed to allow testing of mass conservation when the kinetic …
mrhardman 2bc7f23
Make VantageDataTransfer class to handle the transfer of data between…
mrhardman 324da12
Use VantageDataTransfer in VantageSourceManager.
mrhardman 06d7c1f
Changes to initialise the plasma properties on Field2D on the BOUT++ …
mrhardman bde3529
Fix bug in `VantageDataTransfer::transfer_scalar_to_kinetic_mesh`.
mrhardman c60dcfc
Make the particle group variable passed as an arguement to enable the…
mrhardman 3825b2a
Introduce particle sub groups which ensure neutral-plasma reactions a…
mrhardman cac6c3d
Modify the diagnostics so that the sources are written to both kineti…
mrhardman 993353b
Attempt to calculate total mass for mass conservation check using the…
mrhardman 43e8cb1
Fix mass conservation test by using the correct summation of neso_mes…
mrhardman aef21d0
Confirm that mass is conserved (in a slab) when density is computed f…
mrhardman c7517da
Write out neso_cell_volumes -> neso_cell_areas as BOUT++ Field2D, use…
mrhardman 8921151
Test the sum of neutral mass and ionised mass by summing over sources.
mrhardman 6962119
Support non-rectangular BOUT++ plasma grid cells, by computing the re…
mrhardman 3c0161d
Refactor particle-pusher/runtest so that simulation directory is spec…
mrhardman abc713f
Include a .msh file and necessary data to generate a valid bout.grd.n…
mrhardman 9fb7247
Use fewer x, y cells in the test of particle pushing on quad cells al…
mrhardman 0246316
Extend `test_dmplex_cell_centres = true` to test cell centres also on…
mrhardman d08d05c
Reuse functions to replace copied code.
mrhardman 248ce6b
Move helper and check functions to a library component.
mrhardman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| #pragma once | ||
| #include "bout/bout.hxx" | ||
| #include <bout/bout_types.hxx> | ||
| #include <neso_particles.hpp> | ||
| #include <vector> | ||
|
|
||
| using namespace NESO::Particles; | ||
|
|
||
| /// @brief Class to handle transfer of data between kinetic mesh and plasma grid in VANTAGE. | ||
| class VantageDataTransfer { | ||
| public: | ||
| VantageDataTransfer(std::shared_ptr<PetscInterface::DMPlexInterface>& neso_mesh, | ||
| std::shared_ptr<PetscInterface::DMPlexProjectEvaluateDG>& project_eval_dg0, | ||
| std::shared_ptr<PetscInterface::DMPlexMeshCouplerDG0>& mesh_coupler, | ||
| Mesh* bout_mesh, size_t ndim_vector); | ||
|
|
||
| // transfer functions for physics scalars | ||
| void transfer_scalar_to_plasma_grid( | ||
| std::vector<REAL>& scalar_kinetic_mesh, | ||
| Field2D& scalar_plasma_grid); | ||
| void transfer_scalar_to_kinetic_mesh( | ||
| Field2D& scalar_plasma_grid, | ||
| std::vector<REAL>& scalar_kinetic_mesh); | ||
| void transfer_scalar_to_particle_property( | ||
| std::vector<REAL>& scalar_kinetic_mesh, | ||
| std::shared_ptr<ParticleGroup>& A_particle_group, | ||
| std::string particle_property); | ||
| void transfer_scalar_to_particle_property( | ||
| Field2D& scalar_plasma_grid, | ||
| std::shared_ptr<ParticleGroup>& A_particle_group, | ||
| std::string particle_property); | ||
| void transfer_particle_property_to_scalar( | ||
| std::shared_ptr<ParticleGroup>& A_particle_group, | ||
| std::string particle_property, | ||
| std::vector<REAL>& scalar_kinetic_mesh); | ||
| void transfer_particle_property_to_vector( | ||
| std::shared_ptr<ParticleGroup>& A_particle_group, | ||
| std::string particle_property, | ||
| std::vector<REAL>& vector_kinetic_mesh); | ||
|
|
||
| // transfer functions for physics vectors | ||
| void transfer_vector_to_particle_property( | ||
| std::vector<Field2D>& vector_plasma_grid, | ||
| std::shared_ptr<ParticleGroup>& A_particle_group, | ||
| std::string particle_property); | ||
| void transfer_vector_to_particle_property( | ||
| std::vector<REAL>& vector_kinetic_mesh, | ||
| std::shared_ptr<ParticleGroup>& A_particle_group, | ||
| std::string particle_property); | ||
| void transfer_vector_to_kinetic_mesh( | ||
| std::vector<Field2D>& vector_plasma_grid, | ||
| std::vector<REAL>& vector_kinetic_mesh); | ||
|
|
||
|
|
||
| private: | ||
| // internal variables needed for data transfer | ||
| std::shared_ptr<PetscInterface::DMPlexInterface> neso_mesh; | ||
| std::shared_ptr<PetscInterface::DMPlexProjectEvaluateDG> project_eval_dg0; | ||
| std::shared_ptr<PetscInterface::DMPlexMeshCouplerDG0> mesh_coupler; | ||
|
|
||
| // the bout_mesh variable needed for Hermes-3/BOUT++ diagnostics | ||
| Mesh* bout_mesh; | ||
|
|
||
| // variable used to transfer dofs from kinetic | ||
| // to BOUT++ meshes | ||
| size_t num_cells_owned_bout_grid; | ||
| std::vector<REAL> dof_bout_grid_scalar; | ||
| std::vector<REAL> dof_kinetic_mesh_scalar; | ||
| // number of physics vector components | ||
| size_t ndim_vector; | ||
| std::vector<REAL> dof_bout_grid_vector; | ||
| std::vector<REAL> dof_kinetic_mesh_vector; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| #pragma once | ||
| #include "bout/bout.hxx" | ||
| #include <bout/bout_types.hxx> | ||
| #include <memory> | ||
| #include <neso_particles.hpp> | ||
| #include <string> | ||
| #include <vector> | ||
| #include "../include/vantage_datatransfer.hxx" | ||
| #include "../include/vantage_sources.hxx" | ||
|
|
||
| using namespace NESO::Particles; | ||
|
|
||
| REAL calculate_total_mass(std::vector<REAL>& density, | ||
| std::shared_ptr<PetscInterface::DMPlexInterface>& neso_mesh); | ||
| REAL calculate_total_mass(Field2D& density, | ||
| std::vector<REAL>& neso_cell_volume_on_bout_mesh); | ||
|
|
||
| /// @brief Class to manage diagnostics from VANTAGE. | ||
| class VantageDiagnosticsManager { | ||
| public: | ||
| VantageDiagnosticsManager(std::string vtkhdf_filename, | ||
| std::shared_ptr<PetscInterface::DMPlexInterface>& neso_mesh, | ||
| // neso_mesh cell volumes on the BOUT++ mesh | ||
| std::vector<REAL>& neso_cell_volumes, | ||
| std::shared_ptr<ParticleGroup>& A_particle_group, | ||
| std::shared_ptr<VantageDataTransfer>& data_transfer, | ||
| std::shared_ptr<VantageSourceManager>& source_manager, | ||
| BoutReal N_w, BoutReal mass, | ||
| Mesh* bout_mesh, Options& units, | ||
| std::string vantage_dump_filepath); | ||
|
|
||
| // compute the kinetic velocity moments and | ||
| // store in private variables | ||
| void update_kinetic_velocity_moments(); | ||
| // write kinetic diagnostics to a vtkhdf file | ||
| void write_kinetic_velocity_moment_diagnostics(int istep, std::vector<REAL>& ion_density); | ||
| // transfer kinetic moments to BOUT++ grid | ||
| void transfer_moments_to_plasma_grid(); | ||
| // write BOUT++ style diagnostics on the BOUT++ grid | ||
| void write_bout_diagnostics( | ||
| Field2D& ion_density, | ||
| BoutReal particle_time); | ||
| std::vector<REAL> get_density_kinetic_mesh(); | ||
| // Field2D transfer_scalar_to_plasma_grid(std::vector<REAL>& scalar_field); | ||
|
|
||
| private: | ||
| // internal variables needed for diagnostics | ||
| std::string vtkhdf_filename; | ||
| std::shared_ptr<PetscInterface::DMPlexInterface> neso_mesh; | ||
| std::shared_ptr<ParticleGroup> A_particle_group; | ||
| std::shared_ptr<VantageDataTransfer> data_transfer; | ||
| // pointer to vantage source_manager for diagnostics | ||
| std::shared_ptr<VantageSourceManager> source_manager; | ||
| BoutReal N_w; | ||
| BoutReal mass; | ||
|
|
||
| // the bout_mesh variable needed for Hermes-3/BOUT++ diagnostics | ||
| Mesh* bout_mesh; | ||
| Options& units; | ||
| std::string vantage_dump_filepath; | ||
| Options bout_output_data; // Options object to hold output data for VANTAGE diagnostics | ||
| std::unique_ptr<bout::OptionsIO> | ||
| vantage_dump_writer; // OptionsIO object to write VANTAGE diagnostics | ||
|
|
||
| // variables used to store the moments of | ||
| // the neutral distribution function, on | ||
| // the kinetic mesh | ||
| const size_t ndimv = 2; // number of velocity dimensions | ||
| std::vector<REAL> density; | ||
| std::vector<REAL> energy; | ||
| std::vector<REAL> gamma; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we rename this to "flux"? "gamma" usually means sheath heat transfer coefficient. It would also be helpful to include units here. |
||
| std::vector<REAL> uvector; | ||
| std::vector<REAL> pressure; | ||
| std::vector<REAL> temperature; | ||
|
|
||
| // variable used to transfer dofs from kinetic | ||
| // to BOUT++ meshes | ||
| std::vector<REAL> dof_bout_mesh_scalar; | ||
| // variables used to store the moments of the | ||
| // neutral distribution function projected on | ||
| // to the BOUT++ grid | ||
| Field2D density_plasma_grid; | ||
| Field2D energy_plasma_grid; | ||
| Field2D pressure_plasma_grid; | ||
| Field2D temperature_plasma_grid; | ||
| // n.b. only treat scalar variables for now | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm finding the name of this and similar objects confusing. What do you think about renaming them to make it clear they are quantities, e.g.
plasma_grid_scalar.