<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">The solution to put the coordinates in variables is overkill, using up memory, and doesn’t work if you only do it in Simulation_initBlock and then the mesh refines later. <div><br></div><div>You need to use Grid_getCellCoords, which has a public interface and can be called from the MagneticResistivity unit:</div><div><br></div><div><div>use Grid_interface, ONLY: Grid_getCellCoords, Grid_getBlkIndexLimits</div></div><div><br></div><div><div>#include "Flash.h"</div><div><br></div><div>logical :: gcell = .true. ! True if you need the guardcells, false if not</div></div><div>real :: size(3)</div><div>real, dimension(:), allocatable :: xc, yc, zc</div><div><div>integer, dimension(LOW:HIGH,MDIM) :: blkLimits,blkLimitsGC</div></div><div><br></div><div>! for a given blockId: </div><div><br></div><div>call Grid_getBlkIndexLimits(blockID,blkLimits,blkLimitsGC)</div><div><br></div><div>if (gcell) then</div><div><div> size(1) = blkLimitsGC(HIGH,IAXIS) - blkLimitsGC(LOW,IAXIS) + 1</div><div> size(2) = blkLimitsGC(HIGH,JAXIS) - blkLimitsGC(LOW,JAXIS) + 1</div><div> size(3) = blkLimitsGC(HIGH,KAXIS) - blkLimitsGC(LOW,KAXIS) + 1</div></div><div>else</div><div><div><div> size(1) = blkLimits(HIGH,IAXIS) - blkLimits(LOW,IAXIS) + 1</div><div> size(2) = blkLimits(HIGH,JAXIS) - blkLimits(LOW,JAXIS) + 1</div><div> size(3) = blkLimits(HIGH,KAXIS) - blkLimits(LOW,KAXIS) + 1</div></div></div><div>endif</div><div><br></div><div><div>call Grid_getCellCoords(KAXIS, blockId, CENTER, gcell, zc, size(3))</div><div>call Grid_getCellCoords(JAXIS, blockId, CENTER, gcell, yc, size(2))</div><div>call Grid_getCellCoords(IAXIS, blockId, CENTER, gcell, xc, size(1))</div></div><div><br></div><div>The xc, yc, zc now contain the cell coordinates for the block. </div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Nov 14, 2023, at 11:29 AM, Leland Ellison <lee@pacificfusion.energy> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr">Hi Ernesto,<div><br></div><div>To make a custom magnetic resistivity model that depends on spatial coordinates, I'd do this by customizing the MagneticResitivity_fullState.f90 file in your problem directory. Notice that the fullState version gets passed in the full vector of unknowns and not just the density and temperature. If you look carefully at e.g. diff_advanceMag, it's actually calling the fullState version by passing in the solnVec so this is the one you want to customize. Next, as you noticed, you don't typically have the spatial coordinates available in your solnVec, but it's quite straightforward to add them. For instance, you can add:</div><div><br></div><div>VARIABLE XCTR</div><div>VARIABLE YCTR</div><div>VARIABLE ZCTR </div><div><br></div><div>in the Config file for your problem, and then in your Simulation_initBlock you can populate these mesh variables with cell centered coordinates, e.g.:</div><div><br></div><div>! inside your i,j,k mesh loop after you've fetched the spatial coordinates</div><div>#ifdef XCTR_VAR<br> solnData(XCTR_VAR, i,j,k) = xCoord(i)<br>#endif<br></div><div><br></div><div>Then these coordinates will be present in your solnVec for use inside of your customized MagneticResistivity_fullState routine. </div><div><br></div><div>Hope this helps!</div><div>Lee</div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span style="color:rgb(34,34,34)">________________</span><div style="color:rgb(34,34,34)">Leland Ellison PhD<div><br></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 14, 2023 at 7:56 AM Ernesto Zurbriggen <<a href="mailto:ezurbriggen@unc.edu.ar">ezurbriggen@unc.edu.ar</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi all! <br>I'm carrying out some single fluid resistive MHD runs with constant resistivity using the <i>/MagneticResistivity/MagneticResistivityMain/Constant</i> unit. <br>Now I would like to implement a spatially dependent resistivity, but I'm not sure which is the easiest way without modifying different subroutines in different units. <br><br>The optimal implementation would be to create a new unit that keeps the structure of the <i>/MagneticResistivity/MagneticResistivityMain/Constant</i> unit, <br>so I didn't have to change anything else in other units. But the problem with this idea is that the <i>MagneticResistivity subroutine</i>, <br>which calculates the resistivity, has no notion of spatial coordinates. And to provide this subroutine with the spatial coordinates doesn't seem obvious. <br><br>Another possibility might be to save the resistivity in a scratchcenter variable, but in this case I couldn't take advantage of the structure of the <i>/MagneticResistivity/MagneticResistivityMain/Constant</i> unit. <br><br>Any ideas or suggestions will be appreciated!<br></div><div><br></div><div>Thanks in advance! </div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr" style="font-style:inherit;font-variant:inherit;font-weight:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline"><font face="monospace" color="#666666"><font style="background-color:rgb(234,209,220)"><font><span style="font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;margin:0px;padding:0px;border:0px;vertical-align:baseline"><div style="font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;margin:0px;padding:0px;border:0px;vertical-align:baseline"><i style="background-color:rgb(255,255,255);line-height:normal">PhD Ernesto Zurbriggen,<br></i></div><div style="font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;margin:0px;padding:0px;border:0px;vertical-align:baseline"><i style="background-color:rgb(255,255,255);line-height:normal">Assistant researcher (CONICET)</i><i><br></i></div></span></font></font><font style="background-color:rgb(234,209,220)"><span style="font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;margin:0px;padding:0px;border:0px;vertical-align:baseline"><div style="font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;margin:0px;padding:0px;border:0px;vertical-align:baseline"><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;background-color:rgb(255,255,255)"><i></i></span></div></span></font></font></div><div dir="ltr" style="font-style:inherit;font-variant:inherit;font-weight:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline"><div style="margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline"><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:normal;vertical-align:baseline"><i style="line-height:normal"><font face="monospace" color="#666666"><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline"><i style="background-color:rgb(234,209,220)"><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline"><div style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline"><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:normal;vertical-align:baseline;background-color:rgb(255,255,255)">Email:</span><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:normal;vertical-align:baseline;background-color:rgb(255,255,255)"><i style="line-height:normal"> <a href="mailto:ernesto.zurbriggen@craam.mackenzie.br" target="_blank">ezurbriggen@</a><a href="http://unc.edu.ar/" target="_blank">unc.edu.ar</a></i></span><i><br></i></div><div style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline"><i><span style="font-size:12.8px">IP phone: (+54) 351-535 3776</span> (int. 75601)<br></i></div></span></i></span><br></font></i></span></div><div style="margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline"><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:normal;vertical-align:baseline"><i style="line-height:normal"><font face="monospace" color="#666666">Instituto de Astronomía Teórica y Experimental (IATE-CONICET), </font></i></span></div><div style="margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;vertical-align:baseline"><font face="monospace" color="#666666"><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:normal;vertical-align:baseline"><i style="line-height:normal"><i style="font-weight:inherit;line-height:normal">Francisco Laprida sth 922</i></i></span><i style="font-weight:inherit;line-height:normal">, X5000BGR, </i><i style="font-weight:inherit;line-height:normal">Córdoba, </i><i style="font-weight:inherit;line-height:normal">Argentina. </i></font></div></div></div></div></div>
_______________________________________________<br>
flash-users mailing list<br>
<a href="mailto:flash-users@flash.rochester.edu" target="_blank">flash-users@flash.rochester.edu</a><br>
<br>
For list info, including unsubscribe:<br>
<a href="https://flash.rochester.edu/mailman/listinfo/flash-users" rel="noreferrer" target="_blank">https://flash.rochester.edu/mailman/listinfo/flash-users</a><br>
</blockquote></div>
_______________________________________________<br>flash-users mailing list<br>flash-users@flash.rochester.edu<br><br>For list info, including unsubscribe:<br>https://flash.rochester.edu/mailman/listinfo/flash-users<br></div></blockquote></div><br></div></body></html>