Twistshift for field-aligned variables#1732
Conversation
When TwistShift==true, only apply the twist-shift for field-aligned variables. Since #1635 variables in the 'standard' x-z orthogonal coordinates do not require a twist-shift. This change allows field-aligned and orthogonal variables to both be communicated correctly in the same simulation, by setting TwistShift==true.
ShiftedMetric is now compatible with twistshift==true, as the twist-shift is now only applied to field-aligned variables.
|
These changes do raise the question of whether simulations using It might help to do that if the parallel derivative operators, etc. returned a field-aligned field when their original input was field-aligned. Looking at how the field-aligned variables are going in STORM, I think this could be a useful feature. While it is sometimes shorter to have the result of say Any thoughts? |
|
Personally, I would prefer keeping the default For the result of the operators in field aligned or in orthogonal coordinates: is it possible to introduce a flag in the operators, with default value returning orthogonal, but if changed not performing the |
|
@friva000 yes, I like that! Will update... |
Where the twist-shift is applied during communications in BoutMesh::wait(), instead of just checking the TwistShift flag, pass the flag to a new twistShift(bool twist_shift_enabled) method of Field3D, that then calls a twistShift method of ParallelTransform with both the value of the TwistShift flag, and the y-direction type (standard or aligned) of the Field3D. This enables us to have different behaviour depending on the ParallelTransform: - ParallelTransformIdentity twist-shifts all fields if TwistShift=true, or none if TwistShift=false (this keeps the old behaviour of TwistShift). - ShiftedMetric twist-shifts only field-aligned fields, throwing an exception if TwistShift=false and the field is field-aligned. - FCI never twist-shifts as there cannot be field-aligned variables.
a73e5c2 to
f3f0425
Compare
|
I've rolled back to before changing the default of After some discussion with Fabio about how the different
|
|
@friva000 @johnomotani Is there any chance there's some kind of simple test we can write to check we're handling twist-shifting correctly? For example, checking that something constant on a field-line, but with some shape perpendicular to it, is really periodic? Ideally as a unit test, but even as an integrated test would be good. |
Renaming makes it clear that this method is a query, and does not change the object.
|
Testing the twist-shift operation requires a fully-initialised The test uses |
When
TwistShift = true, apply the shift only when communicating field-aligned variables. The twist-shift at the branch cut in the core region is needed for field-aligned variables, but incorrect for variables in x-z orthogonal coordinates.When
TwistShift = trueit is necessary to loadShiftAnglefrom the gridfile or grid options, so it is useful to keep the option. FCI simulations and simulations in periodic slab geometry do not require a twist-shift, and so should be able to run without providingShiftAngle.I'm in favour of changing the default value of
TwistShiftfromfalsetotrue. WhenTwistShift = truewe will now either do the right thing, or raise an exception which tells the user how to fix the error (setTwistShift = false) and when it is safe to do so (for FCI, periodic slab or slab with only open field lines). IfTwistShift = falsethere is a danger of a simulation running but giving incorrect results - then the best case is that the errors cause an instability that makes them obvious in the way that Fabio found. On the other hand changing the default may break existing simulations (e.g. many of the tests need to setTwistShift = false).Fixes #1731.