idefix-code/idefix

How do I properly initialise the magnetic field without any potential vector in 2.5D runs?

jeankpf opened this issue · 5 comments

Question

I am currently encountering a technical problem regarding the initialisation of a magnetic field in a 2.5D (i.e. 3 components and 2 dimensions) run. What is the correct way of initialising the third component of the magnetic field without resorting to a potential vector in this case? Naively, one would simply write the following line:
Vs(BX3s,k,j,i) = 1.0;
But this leads to some memory-corruption error because Vs seems to be free from any BX3s component. This makes sense since it might be hard to define the value of the magnetic field at the interface between two cells in a direction which is not accounted for (in a dimensional sense at least) by the code. Hence my question: what is the proper way to initialise a non-zero third-component of the magnetic field in 2.5D sim?

PS: this behaviour was encountered with hash 10e5ad0 of IDEFIX

glesur commented

As you pointed out, Vs(Bx3s,...) exists only when DIMENSIONS =3, otherwise one can't define the cell faces in the X3 direction.

In such a case, one uses the cell centred Vc(BX3,...) instead.

Thanks for the quick reply. So does it mean that, in all generality, one could always initialise B with its cell-centered value or one can just do so when using DIMENSIONS < COMPONENTS for the component(s) which is not accounted for by any dimension?

glesur commented

The face centred field always erases the cell centred one, when it is defined.

So you have to initialise:

in DIMENSION = 1, Vs(BX1s...) Vc(BX2...), Vc(BX3...)

In DIMENSION = 2 Vs(BX1s...) Vs(BX2s...), Vc(BX3...)

In DIMENSION = 3 Vs(BX1s...) Vs(BX2s...), Vs(BX3s...)

The same fields have to be set in the ghost zones when using user-defined boundary conditions.

Regarding this last comment, I guess we can still use the hydro->boundary->BoundaryForX*s routine in order to set the component (which is not associated to a dimension) of the cell-centred magnetic field in the ghost zones?

glesur commented

For cell-centered fields, it has to be hydro->boundary->BoundaryFor, for face-centered fields, it is hydro->boundary->BoundaryForX*s. Do not use face-centered loops on cell-centered variables.