Skip to content

User Guide for TOMMS

Usman Riaz edited this page Jan 9, 2023 · 1 revision

LAST MODIFIED: Jun 08, 2018

0. Principal Features

  • Triangular 2D mesh of a poloidal plane with field-following vertices for user-defined region of Tokamak
  • Flux surface curves with one element deep element (i.e. one element between two adjacent flux curves)
  • Unstructured meshes for undefined part of scrape-off-layer regions
  • Supporting 0-, 1-, and 2- x-points geometry

1. Input parameters

  • Input parameters are denoted in bold type.
  • Input parameters usually users change or need to pay attention to are denoted with underline.

1.0. Sample inputs

You can get sample inputs for actual devices from this repo under https://github.com/SCOREC/Fusion_Public/tree/master/samples

  • Prefix of the directories implies
    • A-: Alcator C-Mod
    • C-: Concentric Circular
    • D-: DIII-D
    • J-: JET
    • N-: NSTX

1.1. Setting for magnetic field

  • eqdskFile (required)

    • A file name that contains magnetic field information.
    • gxxxxx.xxxxx (geqdsk file) is preferred.
    • .eqd that doesn't have a wall info is supported.
  • reverse_psi (optional, default= 0)

    • The meshing code presumes the given magnetic flux (psi) from eqdskFile is minimum at the magnetic axis and is monotonically increasing on outboard midplane.
    • If the flux at the magnetic axis is minimum, set to '0'. Otherwise, set to '1'.

1.2. SimModSuite

  • SimLic (required)
    • Path to the Simmetrix's license file is required.
    • If you have any issue with license, please contact helpdesk of your clusters, Simmetrix or RPI.

1.3. Inter-/Intra- curve spacing

RADIAL MESHING

  • radial_uniform_meshing_unit (optional, default=1)

    • To select a unit of uniformity in radial meshing
    • Performed along the outboard midplane for inside of separatrix (i.e. closed flux surface curves) and along the wall boundary for outside of separatrix
    • radial_uniform_meshing_unit=1 (default): by constant delta psi
    • radial_uniform_meshing_unit=2 : by constant delta sqrt(psi)
    • radial_uniform_meshing_unit=3 : by multiples of local ion gyroradius size. +Detailed settings for ion temperature (Ti) profile are required as XGC1 input options below.+
      • eq_tempi_shape: (from XGC1 input) = -1: reading a file in XGC1 eqd format (".prf" extension), = 0: constant , =1: Tanh, =2: linear, =3: exponential, =4: modified Tanh, =5: modified exponential. For more details, see the function, "eq_ftn", in XGC1.
      • eq_tempi_x1, eq_tempi_x2, eq_tempi_x3, eq_tempi_v1, eq_tempi_v2, eq_tempi_v3: (from XGC1 input) parameters corresponding to the selected eq_tempi_shape profile.
      • eq_tempi_file: (from XGC1 input): A file name for ion temperature profile in XGC1 eqd format (".prf" extension). Only effective when eq_tempi_shape = -1.
    • radial_uniform_meshing_unit=4 : by constant real distance (unit: meter)
    • radial_uniform_meshing_unit=-1 : by normalized psi unit in a text file, inter_curve_spacing_file, given by user.
      • The user file name should be denoted with inter_curve_spacing_file in the input file of XGC meshing code.
      • -Note that regardless of data in the given file, 0 (axis) and 1 (inner separatrix curve) are always considered.
      • Note that 1 corresponds to innermost separatrix.
      • The file format should follow following format
        1. The number of following radial position data
        2. Radial node positions in normalized psi unit (i.e. range from 0 to 1)
      • For example,
      5
      0.1
      0.3
      0.5
      0.7
      0.9
      
  • inter_curve_spacing (optional, unit: radial_uniform_meshing_unit, default=0.1)

    • interval size in radial_uniform_meshing_unit between adjacent flux surface curves at outboard midplane
    • ignored if an external file for inter-curve spacing is given(i.e. radial_uniform_meshing_unit=-1)
    • For psi-related units (i.e. radial_uniform_meshing_unit=1 and =2), inter_curve_spacing interprets an input value as normalized by (psi at separatrix) - (psi at axis).
      • e.g., inter_curve_spacing = 0.1 will put radial nodes along outboard midplane with 0.1* (psi at separatrix - psi at axis) interval. In other words, approximately 10 radial nodes will place.
    • For the gyroradius unit (i.e. radial_uniform_meshing_unit=3), inter_curve_spacing is a multiplication factor to local gyroradius size.
    • For the absolute value unit (i.e. radial_uniform_meshing_unit=4), inter_curve_spacing is interval size in the real distance (i.e. meter).
    • Note that change of inter_curve_spacing generally requires change of inter_curve_spacing_min and inter_curve_spacing_max. For a reference to adjust minimum and maximum radial mesh size, please refer to runtime screen output with an input setting adv_log=1
      • For example, adv_log=1 shows as below:
      $$$ ADV_LOG $$$: radial psi point R= 2.2213 selected. Distance (meter) from previous point is = 0.02
              |-- tried distance= 0.0198571 w/ inter_curve_spacing_min =0.02 and inter_curve_spacing_max =0.05
      
      This implies that the distance 0.0198571 meter was tried for radial meshing according to the relative value of inter_curve_spacing, but the value was limited by inter_curve_spacing_min=0.02 meter.
  • inter_curve_spacing_min & inter_curve_spacing_max (optional, unit: meter)

    • inter_curve_spacing_min (default=0.01): Minimum value of radial mesh size along the outboard midplane for closed magnetic flux surface curves
    • inter_curve_spacing_max (default=100.0): Maximum value of radial mesh size along the outboard midplane for close magnetic flux surface curves
    • i.e. inter_curve_spacing_min < +radial mesh size+ (by inter_curve_spacing with radial_uniform_meshing_unit) < inter_curve_spacing_max
    • For a reference to adjust minimum and maximum radial mesh size, please refer to runtime screen output with an input setting adv_log=1
  • inter_curve_spacing_axis_forcing (optional, unit: meter)

    • To force to set distance between axis and its adjacent radial node (i.e. the 1st next point from axis) on outboard midplane
    • Conditions for distance around axis are as below.
    • If inter_curve_spacing_axis_forcing > 0, (radial position of the 2nd next point from axis) > (radial position of the 1st next point from axis) + inter_curve_spacing_min
    • Otherwise, (radial position of the 1st next point from axis) > inter_curve_spacing_min
  • drop_open_psi (required, unit: psi) & drop_open_psi_hfs (optional, unit: psi)

    • Flux surface curves with larger psi than (drop_open_psi)+(psi at innermost separatrix) are not generated.
    • Designed for scrape-off-layer regions where the physical distance between adjacent flux surface curves is usually very small
    • To adjust distance outside of separatrix,
      • for radial_uniform_meshing_unit=3, use inter_curve_spacing_sol in psi unit.
    • drop_open_psi_hfs has a default value same with the given drop_open_psi
      • This setting is for a special need when flux curves in high field side should be limited without affecting flux curves in low field side.
  • last_closed_psi (required, unit: psi)

    • Maximum magnetic flux by which flux surface curves are generated
    • Only effective with no x-point magnetic geometry
  • random_start (optional, default=true)

    • true (default): starting points of curve generation for closed flux surfaces are randomly shifted along the corresponding flux curves from outboard midplane.
    • false: starting points of curve generation for closed flux surfaces are aligned in the outboard midplane. (i.e. a mesh seam will appear in the outboard midplane with this setting)

POLOIDAL MESHING

  • intra_curve_spacing (required, unit: meter)

    • Distance between vertex on a flux surface curve
    • The below figure shows the distance intra_curve_spacing represents.
  • intra_curve_spacing_option (optional, default=0)

    • intra-curve spacing can be set by a user-defined file. intra_curve_spacing_option=-1 in the input file turns on this feature. The file name should be given by intra_curve_spacing_file. It doesn't have to have all radial meshing points in conjunction with inter_curve_spacing_file. intra_curve_spacing_file uses linear interpolation from given 1D data. x-axis data (i.e. radial direction) should be written in increasing order. The region out of minimum and maximum domain leads to constant value at the nearest minimum or maximum point. For example,
      • In input for XGC meshing code,
      intra_curve_spacing_option -1
      intra_curve_spacing_file intra_space.txt
      
      • In "intra_space.txt" file,
      5
      0.1 0.007
      0.7 0.005
      0.9 0.003
      1.2 0.002
      
  • num_phi_planes (optional, no unit, default value=128)

    • The number of poloidal planes that affects a policy to choose field-following vertices
  • intra_curve_minlength_lastedge (optional, default=-1)

    • To control minimum length of last edge for open flux curves.
    • A negative value turns off this function
    • If the last edge of flux curve is smaller than intra_curve_minlength_lastedge, the vertex right behind the last vertex is removed.

MESH QUALITY

  • inter_curve_spacing_sol (optional, only radial_uniform_meshing_unit=4, i.e. unit=meter, is supported now. ) - available from rev. 237 ** When different size of inter curve spacing for SOL regime is required.

  • intra_curve_spacing_xpt_factor and intra_curve_spacing_xpt_range (optional) - available from rev. 237 ** When intra_curve_spacing for elements near X-point should be changed ** Hyper-tangent function, which is a function of distance from x-point, is utilized for the multiplication factor of intra_curve_spacing. ** intra_curve_spacing_xpt_factor : maximum multiplication factor ** intra_curve_spacing_xpt_range : (approx.) decay length of the multiplication factor

  • maxAspectRatioXpt (optional, unit: intra_curve_spacing, default= 2.0) ** Maximum aspect ratio, defined as length ratio of a longer side to base, for good triangles; The base of a triangle is determined by two nodes on one same flux surface curve (See the below figure). !{width:25%}http://redmine.scorec.rpi.edu/attachments/download/899/Aspect_ratio_triangle.png! ** If the ratio of a triangle exceeds maxAspectRatioXpt, it is identified as a bad element. ** The bad elements are specially treated to be improved by Simmetrix package. ** The bad elements are printed out in the paraview format, badElements.vtk.

  • meshSizeXpt (optional, unit: intra_curve_spacing, default= 1.0) ** As meshSizeXpt decreases, mesh sizes near X-points get smaller, and vice versa.

  • refineXpt_level (optional, default=1) - available from rev. 237 ** Additional layer from x-point becomes a subject of mesh refinement. ** Currently, refineXpt_level=2 is supported.

  • meshSizeWall (required, unit: intra_curve_spacing) ** As meshSizeWall decreases, mesh sizes near reactor wall get smaller, and vice versa.

  • meshSizeGrad (optional, no unit, default= 0.3) ** As meshSizeGrad decreases, the change of mesh sizes from the outermost one-element-deep meshes to wall meshes gets smoother.

3.3. Miscellaneous

  • adv_log=1 for input parameter is strongly recommended to obtain more information about tuning parameters during program runtime.

  • nodeFile (optional, default = "[EQDSK FILENAME].node") ** File name of node output for XGC ** If not defined, [EQDSK FILENAME] defined by the input parameter, "eqdsk", is used as a default file name with the extension ".node".

  • elmFile (optional, default = "[EQDSK FILENAME].ele") ** File name of element output for XGC ** If not defined, [EQDSK FILENAME] defined by the input parameter, "eqdsk", is used as a default name with the extension ".ele".

  • addinfoFile (optional, default = "[EQDSK FILENAME].aif") ** File name of wall curve node output ** If not defined, [EQDSK FILENAME] defined by the input parameter, "eqdsk", is used as a default name with the extension ".aif".

  • addinfoflxFile (optional, default = "[EQDSK FILENAME].flx.aif") ** File name of flux surface information ** Nodes on each flux surface curve and Elements between two adjacent flux surface curves are written from core to edge ** If not defined, [EQDSK FILENAME] defined by the input parameter, "eqdsk", is used as a default name with the extension ".flx.aif".

  • adv_log (optional, default = 0) ** Runtime screen message controller ** =0: shows minimum messages ** =1: shows radial meshing information (Recommended to use for fine tuning) ** >1: for developer use

  • output_up_down_flip (optional, default = 0 or false) ** A special case where equilibrium file has up-down flipped magnetic geometry, but need the result of unflipped geometry. ** At the moment, even for the case where innermost x-point is located higher than x-point, all the meshing procedures in the code are performed in the same way for the lower innermost x-point case. This option affects only final process of printing out data to file in the code by coordinate transformation.

  • small_feature (optional, default = 0, unit: meter) ** The layered flux curves below the given length is not generated. ** You can measure the distance of unnecessary curves through paraview (ruler) or other graphic tools with the .vtk output file (e.g. [EQDSK FILENAME]_meshImproved.vtk) and directly reflect the value to small_feature.

Related to Inter-curve spacing

  • epsilon_norm_psiplan_pr (default = 0, as of 20170618)

    • To remove flux surfaces right next to flux surfaces emanated from (inner & outer if available) x-points within this tolerance of normalized psi, epsilon_norm_psiplan_pr.
    • negative value (default) turns off this feature.
    • double type
    • Note that flux surface curves emanated from x-points should always exist in meshing. Therefore, neighbor surfaces are removed by this option to avoid very small elements.
  • eq_tempi_file_xunit (default = 1, as of 20170709)

    • To select a unit for X-axis of the reading eq_tempi_file when eq_tempi_shape = -1
    • = 1 (psi, default), = 4 (major radius unit in meter)

Private region

  • If flux surface curves are needed in private region with inter-curve spacing under control, simply set inter_curve_spacing_privateR to a value in meter unit. Other settings will be automatically turned on.
  • intra_curve_spacing sets intra-curve spacing not only for core/edge region but also for private region.

[A FIGURE TO BE APPEARED IN THIS PLACE]

if( inter_curve_spacing_privateR > 0. ) {
    inter_curve_spacing_privateR_on = true;
    fluxC_in_privateR_on = true; // forced for consistency
} else {
    inter_curve_spacing_privateR_on = false;
    (NOTE THAT even in this case, fluxC_in_privateR_on can be "true")
}

if ( fluxC_in_privateR_on == true && inter_curve_spacing_privateR_on == true )
    use on-the-fly algorithm to put radial points for private region from the given inter_curve_spacing_privateR
if ( fluxC_in_privateR_on == true && inter_curve_spacing_privateR_on == false )
    use the plan in the "inter_curve_spacings" for private region as well as core and edge
  • fluxC_in_privateR_on (default = false, as of 20161222)
    • To create flux surface curves in private regions
    • bool type ( 0 or 1 can be used in the input file )
  • inter_curve_spacing_privateR (default = -1., as of 20170629)
    • A value to be used with inter_curve_spacing_privateR_unit unit
  • inter_curve_spacing_privateR_on (default = false, as of 20170629)
    • bool type ( 0 or 1 can be used in the input file )
  • inter_curve_spacing_privateR_unit (default = 4, as of 20170629)
    • Only meter unit (option 4) is supported. (Options can be added by requests)
    • integer type

Small feature

getFaceSize

  • Return a maximum value of dimensions in X (R) and Y (Z) for a rectangle embracing a given face

Output Format

  • .flx.aif
<<The number of flux curves including the minor axis point>>
<<The number of vertices on each flux curve from core to edge>>
<<vertex index for 0th curve (axis point)>>
<<vertices indices for the 1st curve>>
<<vertices indices for the 2nd curve>>
<<vertices indices for the 3rd curve>>
<<vertices indices for the ... curve>>
<<-1 for sanity check>>
<<The number of vertices NOT on flux curves>>
<<index of a vertex>><<The number of flux curves adjacent to the vertex>>
<<index of the 1st flux curve adjacent to the vertex>> <<index of the 2nd flux curve adjacent to the vertex>> ...
<<-1 for final sanity check>>

For instance,

4
1 3 5 7
1
2 3 4
5 6 7 8 9
10 11 12 13 14 15 16
-1
3
17 2
1 2
18 2
2 3
19 2
3 4
-1

This can be read as

  1. 4 flux curves
  2. each curve has 1, 3, 5, and 7 vertices.
  3. Index of a vertex on the curve 1 which has 1 vertex is 1. (cor axis)
  4. Indices of vertices on the curve 2 which has 3 vertices are 2, 3, and 4.
  5. Indices of vertices on the curve 3 which has 5 vertices are 5, 6, 7, 8, and 9.
  6. Indices of vertices on the curve 4 which has 7 vertices are 10, 11, 12, 13, 14, 15, and 16.
  7. Sanity check : -1
  8. 3 vertices not on flux curves (:technically, vertices classified not on edge but on face)
  9. Index 17 vertex not on flux curves is between 2 flux curves.
  10. The 2 flux curves adjacent to the vertex 17 is 1 and 2.
  11. Index 18 vertex not on flux curves is between 2 flux curves.
  12. The 2 flux curves adjacent to the vertex 18 is 2 and 3.
  13. Index 19 vertex not on flux curves is between 2 flux curves.
  14. The 2 flux curves adjacent to the vertex 19 is 3 and 4.
  15. Final sanity check : -1 (file ends)

User guide for the old code

0. Recently updated

  • May 17, 2016 ** intra-spacing now can be changed locally along the magnetic flux curve as a function of gradient psi - As gradient psi decreases, intra-spacing increases in a curve, and vice versa. This function is supported by below input parameters. intra_curve_spacing_option -2 intra_curve_spacing_prof_min intra_curve_spacing_prof_max

  • Rev. 373 (May. 11, 2016) ** intra_curve_spacing can be set by a user-defined file. intra_curve_spacing_option=-1 in the input file turns on this feature. The file name should be given by intra_curve_spacing_file. It doesn't have to have all radial meshing points in conjunction with inter_curve_spacing_file. intra_curve_spacing_file uses linear interpolation from given 1D data. x-axis data (i.e. radial direction) should be written in increasing order. The region out of minimum and maximum domain leads to constant value at the nearest minimum or maximum point. For example, *** In input for XGC meshing code,

intra_curve_spacing_option -1
intra_curve_spacing_file intra_space.txt

*** In "intra_space.txt" file,

5
0.1 0.007
0.7 0.005
0.9 0.003
1.2 0.002
  • Rev. 353 (Feb. 21, 2016) ** inter_curve_spacing_file now supports SOL region as well as CORE.

  • Rev. 326 (Jan. 26, 2016) ** +NOTE that units of inter_curve_spacing_sol, drop_open_psi, and drop_open_psi_hfs have changed+ from in psi unit to in normalized psi unit. The normalization factor is difference between psi of innermost separatrix and of axis.

  • Rev. 321 ** inter_curve_spacing_axis_forcing is created as an input argument. This parameter (always in meter unit) forces to put a radial node adjacent to axis at the position given by user. For more details, please refer to Sec 3. RADIAL MESHING below.

  • Rev. 305 (Nov. 09, 2015) ** Now .flx.aif contains flux surface element information for all region.

  • Rev. 303 (Oct. 29, 2015) ** An output file with ".flx.aif" extension is now generated for additional node & elements information about flux curves at the end of execution of the XGC meshing code. ** The default file name is eqdskFile.flx.aif. The output file name can be customized by using addinfoflxFile in the input file of XGC meshing code.

  • Rev. 297 (Oct. 26, 2015) ** An output file with ".aif" extension is now generated at the end of execution of the XGC meshing code. ** The default file name is eqdskFile.aif. The output file name can be customized by using addinfoFile in the input file of XGC meshing code. ** The 1st line in the output is the number of node points on boundary (i.e. wall geometry). ** From the 2nd line, (R,Z) positions of the node points on boundary in meter unit are recorded.

  • Rev. 277 (Oct. 13, 2015) ** Only one pGFace can be created using a pSurface. Fixed code in +exportModel.cc+ to do this.

  • Rev. 275 (Oct. 13, 2015) ** radial_uniform_meshing_unit=-1 is created to support a user input file for putting radial nodes inside of separatrix. The user file can be denoted with *inter_curve_spacing_file". The file should contain the number of data and normalized psi values -(i.e. the psi value should be 0<= Normalized Psi<=1)- (as of Rev. 353, SOL region is supported. Normalized Psi=1 corresponds to the innermost x-point). For example, *** In input for XGC meshing code,

radial_uniform_meshing_unit -1
inter_curve_spacing_file radial_node.txt

*** In "radial_node.txt" file,

5
0.1
0.3
0.5
0.7
0.9

*** As always, adv_log 1 gives detailed information during runtime. ** output_up_down_flip was added. This bool (or logical) is for the case when the equilibrium file contains up-down flipped geometry. with output_up_down_flip true, all the operations are performed on the original geometry as it is in the equilibrium file, and meshing results are flipped only when output files are generated. ** A few minor bugs are fixed.

  • Rev. 243 (Sep. 15, 2015) ** small_feature now has meter unit for convenience. You can measure the distance of unnecessary curves through paraview or other graphic tools and directly reflect the value to small_feature. ** An input option, named drop_open_psi_hfs is created for limiting generation of open flux curves (or the one-element-deep layered mesh) in high field side (HFS). ** Note that the offset separatrix psi for drop_open_psi and drop_open_psi_hfs has been changed to the psi value at innermost x-point. *** Effectively, meshing code generates up to drop_open_psi + (psi at innermost x-point) for low field side (LFS) and to drop_open_psi_hfs +(psi at innermost x-point) for high field side (HFS).

  • Rev. 241 (Sep. 11, 2015) ** The obsolete option small_feature is revived. This input limits generation of flux curves, of which length is smaller than the -small_feature x (reference domain box size)-. You can refer the effective small_feature (in meter unit) by the input setting adv_log >=1. ** Putting nodes near magnetic axis and x-points are improved.

  • Rev. 240 (Sep. 10, 2015) ** To add a function to adjust distance between flux curves using inter_curve_spacing_sol for radial_uniform_meshing_unit=3, gyroradius

1. Getting Started

1.0. Checklist

  • The executable file, xgc_mesh
Location of the executable in PPPL server
/p/epsi/rpi/bin/xgc_mesh
  • A license file for Simmetrix Note that Simmetrix is licensed software. This has been already installed in PPPL server. You should indicate the location of the license file in your input for XGC meshing program. For the license path, please refer to one of input files in sample directories
Location of examples for XGC meshing program in PPPL server
/p/epsi/rpi/samples
  • openmpi openmpi is required by Simmetrix.
>> module load openmpi
  • An input file for the meshing code: Arbitrary names are allowed.
  • An EFIT data file or an eqdsk file

1.2. Running (with a sample input)

  • Executable file : xgc_mesh

  • You can use any name of the input as an argument for the executable file on command line as below:

>> /p/epsi/rpi/bin/xgc_mesh <INPUT FILE NAME>

** If the input file name is not provided, the predefined name, "xgc_mesh_in", will be assumed as an input file name. ** Note that input parameters are described in Sec 3 : http://redmine.scorec.rpi.edu/projects/epsi/wiki/User_guides_for_the_mesh_generation#3-How-to-Set-Input-Values ** Sample inputs for no x-point, 1 x-point, and 2 x-point cases are located at

>> /p/epsi/rpi/samples/

** Before running the code, make sure that you have loaded openmpi.

>> module load openmpi
>> module list      
Currently Loaded Modulefiles:
  1) modules          2) openmpi/latest
  • Below is a sample input which contains all input parameters.
!Input EFIT file containing psi grid and wall boundary.
eqdskFile g096333.03337

!If set to 1, this reverses the sign of Psi, allowing for a maximum at the axis
reverse_psi 0

!License file for Simmetrix software
SimLic <$(SIMMETRIX LICENCE FILE PATH)>

!Advanced runtime log (we recommend for user to use adv_log=1 for fine tuning of meshing)
adv_log 0

!==============================================RADIAL MESHING

!Choose a way of uniformity in radial direction (1: psi, 2: sqrt(psi), 3: gyroradius, 4: meter)
radial_uniform_meshing_unit 1

!This is the desired spacing between psi curves, in meters
inter_curve_spacing 0.003

! Minimum value of radial meshing along outboard midplane
inter_curve_spacing_min 0.001

! Maximum value of radial meshing along outboard midplane
inter_curve_spacing_min 0.005

!Curve with psi value larger than it will be dropped
drop_open_psi 0.02

! used if xpt_location = 0 (no x point is used)
last_closed_psi 0.020

! random starting points for curve generation of closed flux surface lines
random_start 1

! Temperature profile setup (XGC1), only effective when radial_uniform_meshing_unit=3
eq_tempi_shape = -1
eq_tempi_x1 0.001
eq_tempi_x2 0.925
eq_tempi_x3 0.0
eq_tempi_v1 1e3
eq_tempi_v2 0.1e3
eq_tempi_v3 0.1e3
eq_tempi_file tempi.prf

!==============================================POLOIDAL MESHING

!This is the desired spacing between points on a psi curve, in meters
intra_curve_spacing 0.01

!==============================================MESH QUALITY

!Determines what elements near the x-point will be improved
maxAspectRatioXpt 3

!The mesh size at the x-point
meshSizeXpt 3.0

!Defines the mesh size at the boundary wall.
meshSizeWall 16.0

!Define the mesh size gradient in unstructured area
meshSizeGrad 0.8

!==============================================Miscellaneous

!The output node and element files
nodeFile xgc.node
elmFile xgc.ele

!Runtime screen message controller
adv_log 0

!==============================================Parameters for algorithms

!Tolerance for the gradient of psi
!Effects how exactly the critical points (mins, x-point) are found
tolerance_psi_deriv 1E-10

!Tolerance for psi
!All points on a psi surface are guaranteed to be within this range of the target psi value.
tolerance_psi 1E-8

!Tolerance in meters
!Used in checking if a point is on the boundary, or if it is a duplicate of another point.
tolerance_meters 5E-10

!If possible, point spacing on a curve will fall within this fraction of the desired value.
spacing_tolerance_optimal 0.5

!Point spacing on a curve will always be within this fraction of the desired value.
!The acceptable range is calculated as 1/(1+tol) to (1+tol) so a value of 1.0 gives a range of .5 to 2.0 times the desired spacing.
spacing_tolerance_absolute 0.61803398874989484820

!This value is used to prevent the same critical point from being detected twice.
!If two of the same type of critical point are within this distance, one will be ignored.
min_critical_spacing 0.25

!If the dot product between a curve's direction and the wall direction is greater than
!this value, the curve may be cut off as it approaches too close to the edge.
!The default value (0.996) corresponds to an approach angle of 5 degrees.
parallel_cutoff 0.999975

!The inverse of this value gives the number of steps used to search in parametric space on the outer grid boundary.
step_normalized 0.0125

!This is the change in phi of each rk4 step taken when moving a point along a psi curve.
step_radians 0.00125

!This is a maximum step size added to Newton's method to deal with extremely small derivatives near critical points.
max_step_meters 0.0025

!the order of limiter nodes. 0: clock-wise; 1 counter
bdyNodeOrder 0

!factor to rescale psi
eqd_psi_factor 1.3

!Number of 2D planes around the torus, used in spacing points on a curve.
num_phi_planes 128
  • It usually takes less than 1 minute to complete a run.
  • With the above sample input, you can see screen output for a normally completed run as below. This is simply a report of the execution of the steps in the process.
1. Read input and EFIT data.

	* Input filename *

		xgc_mesh_in

        * EFIT data filename * 

                g096333.03337

2. Make a face of reactor domain.

3. Search a magnetic axis and x-points.

	* Domain of Magnetic Flux Data *

		R = [0.84, 2.54]		Z = [-1.6, 1.6]

	* Magnetic Axis * 

		Position (R,Z) = (1.72485, 0.020566)
		Magnetic flux (psi) at axis = -0.209239

	* X-point * 

		Position of x_point #1 (R,Z) = (1.55764, -1.17717)
		Magnetic flux (psi) at x_point #1 = 0.136817

	=============================================================
	*<OUTPUT> Write faces for Paraview: g096333.03337_initModel.vtk
		- Use "faceID" to select the boundary of a model face
	=============================================================

4. Create nodes and curves, and Cut along each curve to make regions (also called faces) for meshing

	4-1. Separatrix curve

	4-2. All the other curves

	=============================================================
	*<OUTPUT> Write faces for Paraview: g096333.03337_Model.vtk
		- Use "faceID" to select the boundary of a model face
	=============================================================

	=============================================================
	*<OUTPUT> Write model for SimModeler: g096333.03337_simModel.smd
	=============================================================

5. Generate one-element-deep meshes for each region between the adjacent magnetic flux surface curves.

	=============================================================
	*<OUTPUT> Write meshes for Paraview: g096333.03337_layeredMesh.vtk
		-Use "faceID" to select elements on a single model face
	=============================================================

6. Identify bad elements near x-points based on an aspect ratio criterion. 

7. For the other regions besides one-element-deep meshes, Simmetrix generates unstructured meshes. 

	=============================================================
	*<OUTPUT> Write meshes for Paraview: g096333.03337_meshInit.vtk
		-Use "faceID" to select elements on a single model face
	=============================================================

8. Simmetrix improves the bad elements. 

	=============================================================
	*<OUTPUT> Write mesh elements for Paraview: g096333.03337_badElements.vtk
	=============================================================

	=============================================================
	*<OUTPUT> Write meshes for Paraview: g096333.03337_meshImproved.vtk
		-Use "faceID" to select elements on a single model face
	=============================================================

	=============================================================
	*<OUTPUT> Write meshes in MeshSim format: g096333.03337_mesh.sms
	=============================================================

***************************************************************
<OUTPUT FOR XGC> Write mesh data into g096333.03337.node  and g096333.03337.ele
***************************************************************
***************************************************************
<OUTPUT> Write node positions of flux surface curves into g096333.03337.flx.aif
***************************************************************
	=============================================================
	*<OUTPUT> Write meshes for Paraview: g096333.03337_flx.vtk
		-Use "faceID" to select elements on a single model face
	=============================================================

***************************************************************
<OUTPUT> Write boundary node positions into g096333.03337.aif
***************************************************************

1.3. Output

Note that output file names have a tag [EQDSK FILENAME], which is provided by the input parameter, "eqdskFile". The file names can be changed by input parameters, nodeFile for ".node" file, elmFile for ".ele" file, addinfoFile for '.aif' file, and addinfoflxFile for '.flx.aif'.

+Mesh files for XGC inputs+

  • [EQDSK FILENAME].node

  • [EQDSK FILENAME].ele

+Additional Mesh Information+

  • [EQDSK FILENAME].aif ** '.aif' has the number of nodes and their positions on boundary (i.e. wall geometry). For example,
154
1.297089  -1.366000
1.330255  -1.366000
1.359476  -1.366000
1.385516  -1.366000
1.410463  -1.366000
...

*** 154 node points on boundary are present, and followed by their positions.

  • [EQDSK FILENAME].flx.aif ** '.flx.aif' has
  1. The number of CLOSED flux curves (i.e. inside of separatrix)
  2. List of the number of nodes for each CLOSED flux curve
  3. Node indices for CLOSED flux curve (referring to the XGC output file, [EQDSK FILENAME].node)
  4. The number of OPEN flux curves (i.e. outside of separatrix) including the separatrix line
  5. List of the number of nodes for each OPEN flux curve
  6. Node indices for OPEN flux curve (referring to the XGC output file, [EQDSK FILENAME].node)
  7. The number of faces between two adjacent flux curves
  8. List of the number of elements for each face
  9. List of 3 nodes for each element (referring to the XGC output file, [EQDSK FILENAME].node) For example,
20
13 26 37 47 55 62 74 84 91 97 103 110 116 122 128 135 142 150 158 168
2
3
4
...
2
194 191
2328
1920
1921
1922
1923
...
21
13 39 63 84 102 117 136 158 175 188 200 213 226 238 250 263 277 292 308 326 431
1 2 3
1 3 4
1 4 5
1 5 6
1 6 7

Files in Paraview format (for visual integrity check)

The order of file list below is based on processing flows of meshing.

  • [EQDSK FILENAME]_initModel.vtk : Boundary of meshing domain (usually region limited by reactor vessel, limiters, and divertors)

  • [EQDSK FILENAME]_Model.vtk : Flux surface curves generated in the meshing domain to make one-element-deep meshes in the next step

  • [EQDSK FILENAME]_layeredMesh.vtk : Only one-element-deep mesh generated along the flux surface curves before unstructured mesh is created.

  • [EQDSK FILENAME]_meshInit.vtk : An intermediate mesh after unstructured mesh is created by Simmetrix. (For magnetic field without having x-points, this is the final mesh in vtk format.)

  • [EQDSK FILENAME]_badElements.vtk : Picking up regions where meshing improvements are required based on a input parameter, "maxAspectRatioXpt" (See Section 3.2)

  • [EQDSK FILENAME]_meshImproved.vtk : Final mesh with improvement, which is exported to XGC format, 'xgc.node' and 'xgc.ele'.

  • [EQDSK FILENAME]_flx.vtk : Verification file for the '.flx.aif' output

+Files in Simmetrix format+

  • [EQDSK FILENAME]_simModel.smd (model file)

  • [EQDSK FILENAME]_mesh.sms (mesh file)

  • xgc_sim.log (Simmetrix library log file)

2. Geometry Construction and Mesh Generation

2.1. Definitions

2.2. Flows of Mesh Development (from nodes to elements)

  1. Read input and eqdsk data.
  2. Make an area (corresponding to toroidal face in topology) of reactor domain.
  3. Search a magnetic axis and x-points.
  4. Iterations (to create nodes, curves, and faces) Trace the same magnetic flux (psi) to create a curve and nodes on it. From the curve, one area is divided into two areas. Check if the resultant areas still have curves to be generated. If so, continue iterations (i.e. cycle). Otherwise, save it for meshing.
  5. Generate one-element-deep elements for each area (i.e. geometric face) between the adjacent magnetic flux surface curves.
  6. Identify bad elements near x-points based on an aspect ratio criterion.
  7. For the other areas besides one-element-deep meshes, Simmetrix generates unstructured mesh elements.
  8. Simmetrix improves the bad elements.

For more details about topological operations used in this code, refer to the link below: http://redmine.scorec.rpi.edu/projects/epsi/wiki/Reconstruction_of_XGC1_meshing_program#2-Construct-the-geometric-model-by-topological-bisections

4. Examples

5. Troubleshoot

  • ./xgc_mesh: error while loading shared libraries: libmpi_cxx.so.1: cannot open shared object file: No such file or directory ** Check if openmpi has been loaded
>> module list      
Currently Loaded Modulefiles:
  1) modules 
>> module load openmpi
>> module list      
Currently Loaded Modulefiles:
  1) modules          2) openmpi/latest
  • When one-deep element mesh (flux surface curve) is not generated at the outside of separatrix ** Set adv_log 1 in your input file ** You can see *$$$ ADV_LOG $$$ in runtime screen output as below
3. Search a magnetic axis and x-points.

        * Domain of Magnetic Flux Data *

                R = [0.84, 2.54]                Z = [-1.6, 1.6]

        * Magnetic Axis * 

                Position (R,Z) = (1.72485, 0.020566)
                Magnetic flux (psi) at axis = -0.209239

        * X-point * 

                Position of x_point #1 (R,Z) = (1.55764, -1.17717)
                Magnetic flux (psi) at x_point #1 = 0.136817

        $$$ ADV_LOG $$$: d(Psi) absolute = 0.0432569 <-- d(Psi) rel (=inter_curve_spacing from input) = 0.125
        $$$ ADV_LOG $$$: WARNING! Note that you will NOT get flux surface curve outside of separatrix because of d(Psi) absolute = 0.0432569 > (drop_open_psi)= 0.04
        $$$ ADV_LOG $$$: WARNING! You can generate the outside flux surface curve by increasing drop_open_psi or decreasing inter_curve_spacing in input options

        =============================================================
        *<OUTPUT> Write faces for Paraview: g096333.03337_initModel.vtk
                - Use "faceID" to select the boundary of a model face
        =============================================================

** Referring to the input values on drop_open_psi and inter_curve_spacing, please increase drop_open_psi or decrease inter_curve_spacing. ** Note that inter_curve_spacing is a normalized psi by (psi at separatrix) - (psi at magnetic axis) for magnetic flux related radial meshing unit (i.e. radial_uniform_meshing_unit = 1, =2)

  • When there is no radial point inside of separatrix ** This is probably due to the large inter_curve_spacing_max value. The radial meshing from separtrix to magnetic axis ends if length between magnetic axis and previous radial meshing point on the outboard midplane is less than inter_curve_spacing_max. Therefore, if inter_curve_spacing_max is too large, it can be larger than the length between separtrix and magnetic axis, which yields no radial meshing point inside of separatrix.

FOR DEVELOPERS ONLY

1.1 Source code and required libraries for compiling

  • Download (Checkout) source files from SVN server
>> svn co http://redmine.scorec.rpi.edu/svn/epsi/xgc
  • Required Libraries : pspline, Simmetrix, openmpi

1.2. Compiling and Linking

  • We provide "Makefile" in the source codes. In the source code directory, "make" will generate an executable file, xgc_mesh.
>> make 

** If compiling and linking succeed, you'll see the message "compile finished" at the end of screen output. ** (>> make clean) will delete object(.o) files and the executable file.

  • (tested) Compiler : openmpi using gcc ** If other compilers are preferred, you may modify environmental variables, "CC", "CXX", and "FC" in the "Makefile". ** Note that Simmetrix library requires openmpi.

1.3. Debugging Mode

  • Compile with '-DDEBUG' flags. i.e., in 'Makefile', add '-DDEBUG' to 'FFLAGS' and 'CFLAGS' as below:

CFLAGS = -g -Wno-write-strings -DDEBUG FFLAGS = -g -DDEBUG

1.4. Simmetrix manuals

2. <INPUT PARAMETERS, NOT USED FREQUENTLY, BUT POSSIBLE TO RESOLVE ISSUES>

  • tolerance_psi_deriv (optional, default value=1E-10)

  • tolerance_psi (optional, default value=1E-8)

  • max_step_meters (optional, default value=0.0025)

  • tolerance_meters (optional, default value=5E-10)

  • min_critical_spacing (optional, default value=0.25)

  • parallel_cutoff (optional, default value=0.999975)

  • bdyNodeOrder (optional, default value=0)

  • spacing_tolerance_absolute (optional, default value=0.61803398874989484820) ** To identify if target distance is achieved or not (a normalized value, i.e. 0 < spacing_tolerance_absolute <1, generally used with inter_curve_spacing & intra_curve_spacing) [THE ROLE OF THIS VALUE IN THE CODE SEEMS TO BE SAME WITH spacing_tolerance_optimal. i.e. redundant]

  • spacing_tolerance_optimal (optional, default value=0.5) ** To identify if target distance is achieved or not (a normalized value, i.e. 0 < spacing_tolerance_optimal <1, generally used with inter_curve_spacing & intra_curve_spacing) [THE ROLE OF THIS VALUE IN THE CODE SEEMS TO BE SAME WITH spacing_tolerance_absolute. i.e. redundant]

  • eqd_psi_factor (optional, no unit, default value=1.0) ** Magnetic flux from data is multiplied by eqd_psi_factor value.

  • step_normalized (optional, no unit, default value=0.0125) ** A step size modifier to search target magnetic flux along domain boundary in counter-clockwise direction ** step_normalized should be less than 1 (i.e. 0< step_normalized < 1) ** For more accurate search, decrease the value.

  • step_radians (optional, unit: radian, default value=0.00125) ** A step modifierfor RK4 search ** step_radians should be less than 2*pi/num_phi_planes [WE MIGHT NOT NEED THIS PARAMETER SINCE CODE ADJUST ACCURACY AUTOMATICALLY.]