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

Sub-grid model for pitch-angle diffusion #846

Open
wants to merge 122 commits into
base: dev
Choose a base branch
from

Conversation

MaximeII
Copy link

Enjoy.

MaximeII added 30 commits March 4, 2021 11:07
Remove abs value for diff coeff.
Added include<string> in various files
Built Spanier diffusion
Moved old diffusion
@markusbattarbee
Copy link
Contributor

Hmm, CI compilation fails:

[CC] vlasovsolver/velocity_space_diffusion.cpp
In file included from vlasovsolver/velocity_space_diffusion.cpp:28:
Error: /__w/vlasiator/vlasiator/libraries/include/vector3d.h:22:2: error: #error Incompatible version of vector class library. Must use version 2 or later
   22 | #error Incompatible version of vector class library. Must use version 2 or later
      |  ^~~~~
[CC] projects/Riemann1/Riemann1.cpp
make: *** [Makefile:253: velocity_space_diffusion.o] Error 1
make: *** Waiting for unfinished jobs....
Error: Process completed with exit code 2.

We've so far always used version 1 of vectorclass, will moving to version 2 cause some new issues?

Copy link
Contributor

@markusbattarbee markusbattarbee left a comment

Choose a reason for hiding this comment

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

First round enjoyed.

datareduction/datareducer.cpp Outdated Show resolved Hide resolved
for (uint k = 0; k < WID; ++k) for (uint j = 0; j < WID; ++j) { // Iterate through coordinates (z,y)

//Get velocity space coordinates
const Vec4d VX(parameters[n * BlockParams::N_VELOCITY_BLOCK_PARAMS + BlockParams::VXCRD]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is now hard-coded to vec4d. It's a velocity, not a distribution function value, so it should be Real instead of Realf, but hard-coding the length to 4 will be messy in the future. I would recommend instead doing something like looping j over vec_per_plane - look in acceleration for suggestions on how to accomplish this.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can also use #pragma omp simd here to suggest vectorisation on the compiler level (and run some tests if it works or not)

Copy link
Contributor

Choose a reason for hiding this comment

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

We attempted #pragma omp simd autovectorization here, but the compiler is adamant that a memory access prevents vectorization altogether:

vlasovsolver/velocity_space_diffusion.cpp:241:48: missed: couldn't vectorize loop
vlasovsolver/velocity_space_diffusion.cpp:276:29: missed: not vectorized: no vectype for stmt: CellValue_803 = *_802;
 scalar_type: Realf

I suppose there would be a way to nudge the compiler in the right direction here, but this probably needs a special kind of witchcraft that I am not familiar with.

parameters.cpp Outdated Show resolved Hide resolved
projects/Fluctuations/Fluctuations.cfg Outdated Show resolved Hide resolved
projects/LossCone/LossCone.cpp Show resolved Hide resolved
vlasiator.cpp Outdated Show resolved Hide resolved
vlasovsolver/cpu_moments.cpp Outdated Show resolved Hide resolved
vlasovsolver/cpu_moments.cpp Outdated Show resolved Hide resolved
{cell.parameters[CellParams::P_12],cell.parameters[CellParams::P_22],cell.parameters[CellParams::P_23]},
{cell.parameters[CellParams::P_13],cell.parameters[CellParams::P_23],cell.parameters[CellParams::P_33]}};

// Build Rotation Matrix
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah this looks pretty horrible :D
it would be a lot better to use the Eigen library for this.

vlasovsolver/velocity_space_diffusion_cart.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@markusbattarbee markusbattarbee left a comment

Choose a reason for hiding this comment

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

Also still need to remove the _cart and _mu diffusion cpp files

vlasovsolver/cpu_moments.cpp Outdated Show resolved Hide resolved
LossCone.cfg Outdated Show resolved Hide resolved
nu0Box.txt Outdated Show resolved Hide resolved
parameters.cpp Outdated Show resolved Hide resolved
datareduction/datareducer.cpp Show resolved Hide resolved
@@ -227,7 +227,12 @@ void computeNewTimeStep(dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpi
Real subcycleDt;

// reduce/increase dt if it is too high for any of the three propagators or too low for all propagators
if ((P::dt > dtMaxGlobal[0] * P::vlasovSolverMaxCFL ||
if (P::dt == P::dt_ceil) {
isChanged = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: This means that if the timestep ever reaches the ceiling, it can never become smaller again. That's dangerous!

Instead, add ((P::dt_ceil > 0)&&(P::dt>P::dt_ceil)) to the if-clause-list on line 235-240.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah now I see the continue-mechanism Yann talked about. Not so straightforward, then...

Copy link
Contributor

Choose a reason for hiding this comment

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

Went through the logic again, and in fact the above suggested change should do the trick, if I'm correct.

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.

3 participants