Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
FieldTracing Namespace Reference

Classes

struct  FieldTracingParameters

Typedefs

template<typename REAL>
using TracingFieldFunction = std::function<bool(std::array<REAL, 3>&, const bool, std::array<REAL, 3>&)>

Enumerations

enum  Direction { FORWARD , BACKWARD }
enum  TracingMethod { Euler , ADPT_Euler , BS , DPrince }
enum  TracingLineEndType {
  UNPROCESSED , CLOSED , OPEN , DANGLING ,
  OUTSIDE , N_TYPES
}
enum  TracingPointConnectionType {
  CLOSED_CLOSED , CLOSED_OPEN , OPEN_CLOSED , OPEN_OPEN ,
  CLOSED_DANGLING , DANGLING_CLOSED , OPEN_DANGLING , DANGLING_OPEN ,
  DANGLING_DANGLING , INVALID
}

Functions

void reduceData (fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, fsgrids::perbspan perb, fsgrids::constdperbspan dperb, dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, std::vector< SBC::SphericalTriGrid::Node > &nodes)
void calculateIonosphereFsgridCoupling (fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, fsgrids::perbspan perb, fsgrids::constdperbspan dperb, std::vector< SBC::SphericalTriGrid::Node > &nodes, creal couplingRadius)
std::array< std::pair< int, Real >, 3 > calculateIonosphereVlasovGridCoupling (std::array< Real, 3 > x, std::vector< SBC::SphericalTriGrid::Node > &nodes, creal couplingRadius)
void traceOpenClosedConnection (fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, fsgrids::perbspan perb, fsgrids::constdperbspan dperb, std::vector< SBC::SphericalTriGrid::Node > &nodes)
void stepCellAcrossTaskDomain (cint n, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, TracingFieldFunction< TReal > &tracingFullField, const std::vector< std::array< TReal, 3 > > &cellInitialCoordinates, const std::vector< TReal > &cellCurvatureRadius, std::vector< std::array< TReal, 3 > > &cellTracingCoordinates, std::vector< TReal > &cellTracingStepSize, std::vector< TReal > &cellRunningDistance, std::vector< TReal > &cellMaxExtension, std::vector< signed char > &cellConnection, bool &warnMaxDistanceExceeded, const TReal maxTracingDistance, cuint DIRECTION)
 Trace magnetic field lines forward and backward from each DCCRG cell to record the connectivity and detect flux ropes.
void traceFullBoxConnectionAndFluxRopes (fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, fsgrids::perbspan perb, fsgrids::constdperbspan dperb, dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid)
int ijk2Index (int i, int j, int k, std::array< int, 3 > dims)
template<typename REAL>
bool traceFullFieldFunction (fsgrids::perbspan perb, fsgrids::constdperbspan dperb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, std::array< REAL, 3 > &r, const bool alongB, std::array< REAL, 3 > &b)
template<typename REAL>
void modifiedMidpointMethod (std::array< REAL, 3 > r, std::array< REAL, 3 > &r1, int n, REAL stepSize, TracingFieldFunction< REAL > &BFieldFunction, const bool outwards=true)
template<typename REAL>
void richardsonExtrapolation (int i, std::vector< REAL > &table, REAL &maxError, std::array< int, 3 > dims)
template<typename REAL>
bool bulirschStoerStep (std::array< REAL, 3 > &r, std::array< REAL, 3 > &b, REAL &stepSize, const REAL minStepSize, const REAL maxStepSize, TracingFieldFunction< REAL > &BFieldFunction, const bool outwards=true)
template<typename REAL>
bool dormandPrinceStep (std::array< REAL, 3 > &r, std::array< REAL, 3 > &b, REAL &stepSize, const REAL minStepSize, const REAL maxStepSize, TracingFieldFunction< REAL > &BFieldFunction, const bool outwards=true)
template<typename REAL>
bool adaptiveEulerStep (std::array< REAL, 3 > &r, std::array< REAL, 3 > &b, REAL &stepSize, const REAL minStepSize, const REAL maxStepSize, TracingFieldFunction< REAL > &BFieldFunction, const bool outwards=true)
template<typename REAL>
void eulerStep (std::array< REAL, 3 > &x, std::array< REAL, 3 > &v, REAL &stepSize, TracingFieldFunction< REAL > &BFieldFunction, const bool outwards=true)
template<typename REAL>
void stepFieldLine (std::array< REAL, 3 > &x, std::array< REAL, 3 > &v, REAL &stepsize, const REAL minStepSize, const REAL maxStepSize, TracingMethod method, TracingFieldFunction< REAL > &BFieldFunction, const bool outwards)
void resetReconstructionCoefficientsCache ()

Variables

FieldTracingParameters fieldTracingParameters

Typedef Documentation

◆ TracingFieldFunction

template<typename REAL>
using FieldTracing::TracingFieldFunction = std::function<bool(std::array<REAL, 3>&, const bool, std::array<REAL, 3>&)>

Handler function for field line tracing

Definition at line 152 of file fieldtracing.h.

Enumeration Type Documentation

◆ Direction

Enumerator
FORWARD 
BACKWARD 

Definition at line 71 of file fieldtracing.h.

◆ TracingLineEndType

Type of field line ending, used to classify the ionospheric nodes and the forward and backward field lines in full.box tracing. CLOSED: ends in the ionosphere OPEN: exits the simulation domain DANGLING: has not exited, might keep looping or would exit given enough time/steps. Not called LOOP to avoid confusion with fluxrope tracing. UNPROCESSED: cells inside the ionosphere or outside the outer limits that weren't even processed in the first place

Enumerator
UNPROCESSED 
CLOSED 
OPEN 
DANGLING 
OUTSIDE 
N_TYPES 

Definition at line 118 of file fieldtracing.h.

◆ TracingMethod

Field line integrator for Magnetosphere<->Ionosphere coupling

Enumerator
Euler 
ADPT_Euler 
BS 
DPrince 

Definition at line 77 of file fieldtracing.h.

◆ TracingPointConnectionType

Type of connection for a point traced forward and backward. The first is for the forward end, the second for the backward end. Used for full-box tracing. See TracingLineEndTypes for explanation of types. INVALID used for UNPROCESSED or other unparsed values ==> bug?

See also
TracingLineEndTypes
Enumerator
CLOSED_CLOSED 
CLOSED_OPEN 
OPEN_CLOSED 
OPEN_OPEN 
CLOSED_DANGLING 
DANGLING_CLOSED 
OPEN_DANGLING 
DANGLING_OPEN 
DANGLING_DANGLING 
INVALID 

Definition at line 134 of file fieldtracing.h.

Function Documentation

◆ adaptiveEulerStep()

template<typename REAL>
bool FieldTracing::adaptiveEulerStep ( std::array< REAL, 3 > & r,
std::array< REAL, 3 > & b,
REAL & stepSize,
const REAL minStepSize,
const REAL maxStepSize,
TracingFieldFunction< REAL > & BFieldFunction,
const bool outwards = true )

Definition at line 487 of file fieldtracing.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bulirschStoerStep()

template<typename REAL>
bool FieldTracing::bulirschStoerStep ( std::array< REAL, 3 > & r,
std::array< REAL, 3 > & b,
REAL & stepSize,
const REAL minStepSize,
const REAL maxStepSize,
TracingFieldFunction< REAL > & BFieldFunction,
const bool outwards = true )

Definition at line 297 of file fieldtracing.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateIonosphereFsgridCoupling()

void FieldTracing::calculateIonosphereFsgridCoupling ( fsgrids::technicalspan technical,
FieldSolverGrid & fsgrid,
fsgrids::perbspan perb,
fsgrids::constdperbspan dperb,
std::vector< SBC::SphericalTriGrid::Node > & nodes,
creal couplingRadius )

Calculate mapping between ionospheric nodes and fsGrid cells. To do so, the magnetic field lines are traced from all mesh nodes outwards until a non-boundary cell is encountered. Their proportional coupling values are recorded in the grid nodes.

Link each ionospheric node to fsgrid cells for coupling

Definition at line 61 of file fieldtracing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateIonosphereVlasovGridCoupling()

std::array< std::pair< int, Real >, 3 > FieldTracing::calculateIonosphereVlasovGridCoupling ( std::array< Real, 3 > x,
std::vector< SBC::SphericalTriGrid::Node > & nodes,
creal couplingRadius )

Calculate mapping between ionospheric nodes and Vlasov grid cells. Input is the cell coordinate of the vlasov grid cell. To do so, magnetic field lines are traced inwords from the Vlasov grid IONOSPHERE boundary cells to the ionosphere shell.

The return value is a pair of nodeID and coupling factor for the three corners of the containing element.

Find coupled ionosphere mesh node for given location

Definition at line 296 of file fieldtracing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dormandPrinceStep()

template<typename REAL>
bool FieldTracing::dormandPrinceStep ( std::array< REAL, 3 > & r,
std::array< REAL, 3 > & b,
REAL & stepSize,
const REAL minStepSize,
const REAL maxStepSize,
TracingFieldFunction< REAL > & BFieldFunction,
const bool outwards = true )

Definition at line 371 of file fieldtracing.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eulerStep()

template<typename REAL>
void FieldTracing::eulerStep ( std::array< REAL, 3 > & x,
std::array< REAL, 3 > & v,
REAL & stepSize,
TracingFieldFunction< REAL > & BFieldFunction,
const bool outwards = true )

Definition at line 529 of file fieldtracing.h.

Here is the caller graph for this function:

◆ ijk2Index()

int FieldTracing::ijk2Index ( int i,
int j,
int k,
std::array< int, 3 > dims )
inline

Simple method to translate 3D to 1D indices

Definition at line 148 of file fieldtracing.h.

Here is the caller graph for this function:

◆ modifiedMidpointMethod()

template<typename REAL>
void FieldTracing::modifiedMidpointMethod ( std::array< REAL, 3 > r,
std::array< REAL, 3 > & r1,
int n,
REAL stepSize,
TracingFieldFunction< REAL > & BFieldFunction,
const bool outwards = true )

Definition at line 244 of file fieldtracing.h.

Here is the caller graph for this function:

◆ reduceData()

void FieldTracing::reduceData ( fsgrids::technicalspan technical,
FieldSolverGrid & fsgrid,
fsgrids::perbspan perb,
fsgrids::constdperbspan dperb,
dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
std::vector< SBC::SphericalTriGrid::Node > & nodes )

Definition at line 43 of file fieldtracing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetReconstructionCoefficientsCache()

void FieldTracing::resetReconstructionCoefficientsCache ( )
inline

function to empty the Balsara reconstruction coefficient cache at a new time step

Definition at line 586 of file fieldtracing.h.

Here is the caller graph for this function:

◆ richardsonExtrapolation()

template<typename REAL>
void FieldTracing::richardsonExtrapolation ( int i,
std::vector< REAL > & table,
REAL & maxError,
std::array< int, 3 > dims )

Richardson extrapolation using polynomial fitting used by the Bulirsch-Stoer Method

Definition at line 275 of file fieldtracing.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stepCellAcrossTaskDomain()

void FieldTracing::stepCellAcrossTaskDomain ( cint n,
fsgrids::technicalspan technical,
FieldSolverGrid & fsgrid,
TracingFieldFunction< TReal > & tracingFullField,
const std::vector< std::array< TReal, 3 > > & cellInitialCoordinates,
const std::vector< TReal > & cellCurvatureRadius,
std::vector< std::array< TReal, 3 > > & cellTracingCoordinates,
std::vector< TReal > & cellTracingStepSize,
std::vector< TReal > & cellRunningDistance,
std::vector< TReal > & cellMaxExtension,
std::vector< signed char > & cellConnection,
bool & warnMaxDistanceExceeded,
const TReal maxTracingDistance,
cuint DIRECTION )

Trace magnetic field lines forward and backward from each DCCRG cell to record the connectivity and detect flux ropes.

Full box connection and flux rope tracing

We are doing two things in one function here as we save a *lot* especially in MPI reductions by combining those. And
they are doing very similar things anyway.

Firstly we are interested in knowing the ultimate magnetic connection forward and backward from any given location.
The locations are the DCCRG cell centers, there's too many fsgrid cells for practical purposes. We initially discard
cells too close to the domain boundaries or inside the inner radius as type OUTSIDE. Therefore we step along the
magnetic field until we hit an outer box wall (OPEN) or the inner boundary radius (CLOSED). In rare cases the line
might not have reached either of these two termination conditions by the time the field line has reached a length of
maxTracingDistance. In that case we call it DANGLING, it likely ended up in a loop somewhere (we don't call it "loop"
to avoid confusion with the flux rope tracing). As long as we have not hit any of the above termination conditions,
the type is called UNPROCESSED. We allow fieldTracingParameters.fullbox_max_incomplete_cells to remain UNPROCESSED
when we exit the loop, that is a fraction of the total cells left over, as this allows substantial shortening of the
total time spent due to the MPI_Allreduce calls occurring when we cross MPI domain boundaries. (NOTE: an algorithm
doing direct task-to-task communication will likely be more efficient!) The connection type of the field line is a
member of the enum TracingLineEndType and stored in cellFWConnection, cellBWConnection, cellConnection and the
reduction arrays. enum TracingLineEndType { UNPROCESSED, CLOSED, OPEN, DANGLING, OUTSIDE, N_TYPES
};
Once we have obtained a connection type for both directions, we parse the combinations and assign a value in the enum
TracingPointConnectionType below to CellParams::CONNECTION that will be written out by the vg_connection DRO.
enum TracingPointConnectionType {
   CLOSED_CLOSED,
   CLOSED_OPEN,
   OPEN_CLOSED,
   OPEN_OPEN,
   CLOSED_DANGLING,
   DANGLING_CLOSED,
   OPEN_DANGLING,
   DANGLING_OPEN,
   DANGLING_DANGLING,
   INVALID
};

Secondly, we are interested in finding out whether the seed point/DCCRG cell centre coordinate (again, too many
fsgrid cells for sanity) are near/in a flux rope. As this relies also on tracing forward and backward along the
field, we piggyback on the full box connection algorithm explained above. We trace along the field up to
fieldTracingParameters.fluxrope_max_curvature_radii_to_trace*cellCurvatureRadius[n] and if within that tracing
distance we have't extended further than
fieldTracingParameters.fluxrope_max_curvature_radii_extent*cellCurvatureRadius[n] we are rolled up tightly enough to
consider being close to a flux rope. We'll store the max extension reached into cellMaxExtension[n] for later
fine-grained analysis. The arithmetic idea to avoid using yet more arrays: We use the
cellFWConnection[n]/cellBWConnection[n]/cellConnection[n] (that can only be UNPROCESSED, CLOSED, OPEN or DANGLING,
see TracingLineEndType enum above, ending with N_TYPES). As long as no full box tracing termination condition was
reached we are at UNPROCESSED. If we exceed
fieldTracingParameters.fluxrope_max_curvature_radii_to_trace*cellCurvatureRadius[n], we definitely are not near a
flux rope and we mark this by adding N_TYPES to cellConnection[n]. If we reach
fieldTracingParameters.fluxrope_max_curvature_radii_to_trace*cellCurvatureRadius[n] without hitting the other
thresholds or the inner/outer domain limits we are near/at a flux rope and we mark this by adding 2*N_TYPES to
cellConnection[n].
Later in the tracing when we reach a full box tracing termination condition we add CLOSED, OPEN or DANGLING to
cellConnection[n]. If we reached such termination condition before the flux rope method reached a conclusion it's
fine too, nothing has been added to cellConnection[n]. At the very end, we check whether both cellFWConnection[n] and
cellBWConnection[n] >= 2*TracingLineEndType::N_TYPES. If yes, this cell is near a fluxrope. This means we store the
value of cellMaxExtension[n] into CellParams::FLUXROPE. Otherwise we store zero. After that we apply %
TracingLineEndType::N_TYPES to recover values UNPROCESSED, CLOSED, OPEN, DANGLING, OUTSIDE in cellFWConnection[n] and
cellBWConnection[n] so that we can assign the connection types for the full box connection described above.

As a freebie since we computed the curvature anyway for flux rope tracing we store that into CellParams::CURVATUREX/Y/Z.

\sa stepCellAcrossTaskDomain

Definition at line 643 of file fieldtracing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stepFieldLine()

template<typename REAL>
void FieldTracing::stepFieldLine ( std::array< REAL, 3 > & x,
std::array< REAL, 3 > & v,
REAL & stepsize,
const REAL minStepSize,
const REAL maxStepSize,
TracingMethod method,
TracingFieldFunction< REAL > & BFieldFunction,
const bool outwards )

Take a step along the field line

Definition at line 541 of file fieldtracing.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ traceFullBoxConnectionAndFluxRopes()

void FieldTracing::traceFullBoxConnectionAndFluxRopes ( fsgrids::technicalspan technical,
FieldSolverGrid & fsgrid,
fsgrids::perbspan perb,
fsgrids::constdperbspan dperb,
dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid )

Trace magnetic field lines forward and backward from each DCCRG cell to record the connectivity and detect flux ropes.

< For reduction of node coupling

< For reduction of node coupling

< In-flight node upmapping coordinates (for global reduction)

< In-flight node upmapping coordinates (for global reduction)

Definition at line 804 of file fieldtracing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ traceFullFieldFunction()

template<typename REAL>
bool FieldTracing::traceFullFieldFunction ( fsgrids::perbspan perb,
fsgrids::constdperbspan dperb,
fsgrids::technicalspan technical,
FieldSolverGrid & fsgrid,
std::array< REAL, 3 > & r,
const bool alongB,
std::array< REAL, 3 > & b )

Definition at line 155 of file fieldtracing.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ traceOpenClosedConnection()

void FieldTracing::traceOpenClosedConnection ( fsgrids::technicalspan technical,
FieldSolverGrid & fsgrid,
fsgrids::perbspan perb,
fsgrids::constdperbspan dperb,
std::vector< SBC::SphericalTriGrid::Node > & nodes )

Trace magnetic field lines out from ionospheric nodes to record whether they are on an open or closed field line. Inside the tracing loop for full box + flux rope tracing, trace all field lines across this task's domain. Beware this is inside a threaded region.

See also
traceFullBoxConnectionAndFluxRopes

Compute whether a node is connected to the ionosphere or the IMF.

< For reduction of node coupling

< Count number of field line tracing steps

< Flag, whether tracing needs to continue on another task

< In-flight node upmapping coordinates (for global reduction)

Definition at line 471 of file fieldtracing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ fieldTracingParameters

FieldTracingParameters FieldTracing::fieldTracingParameters

Definition at line 39 of file fieldtracing.cpp.