Skip to content

Conversation

@jguterl
Copy link
Contributor

@jguterl jguterl commented Oct 21, 2020

  • superload and supersave methods to reload an entire set of patches and associated grids. Corresponding workflow is: create a grid with INGRID -> run UEDGE -> identify an issue with a cell -> remake grid only in the patch where it occurs if possible (e.g. poloidal point distribution modification) or in patches of same topological region (e.g. radial point distribution modification)
  • add new format capabilities to add simag and sigbndry values to the header of the generated grid file. This is turned off by default.
  • Adding a distribution function parser (new fille added DistribFunc.py) where distribution functions of grid point can be defined through a string converted into a lambda function (old system) or through a function defined in python or through a predefined function in DistribFunc.py
  • some other minor modifications

I would suggest to push these additions one by one through a new commit each time.

…d and supersave methods to reload an entire set of patches and associated grids. Corresponding workflow is: create a grid with INGRID -> run UEDGE -> identify an issue with a cell -> remake grid only in the patch where it occurs if possible (e.g. poloidal point distribution modification) or in patches of same topological region (e.g. radial point distribution modification)
return fpath


def StoreSettings(self, fname: str = '', settings: dict = {}) -> 'Path':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe SaveSettings for consistency with SavePatches

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.

Copy link
Collaborator

@bryan-garcia bryan-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments before testing pull request in GUI workflow.

if self.settings['patch_data']['preferences']['new_file']:
self.SavePatches(self.settings['patch_data']['preferences']['new_fname'])
self.CurrentTopology.SetBoundarySplines()
#not practical in a workflow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the thought is to separate patch saving from patch construction?

This commented out if statement can be moved to the gui code in master with ease (if that's your thought)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was about the new_file variable. Probably easier to have a single filename system with a prompt to replace existing file or an option to overwrite automatically.

Comment on lines +1629 to +1633
if type(PatchName)==str:
if len(PatchName)<1 or len(PatchName)>2:
raise IOError('PatchName must be a string of one or two characters')
L=''
N=None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

len(PatchName) should be 2 by our convention. Is there a new feature for Patch with 1 char name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is to generate a list of patches based on one letter. For instance, I can redo A1/A2 and B1/B2 by simply putting in the list ['A','B']. similary, I can redo all the core with ['1'].

Comment on lines +1346 to +1373

def SuperSavePatches(self, fname: str = '') -> None:
"""
Save patches as '.npy' file for later reconstruction in Ingrid.
This file contains the information required to reconstruct patches
at a later time and bypass the line_tracing.
Parameters
----------
fname : str, optional
Name of file/location for patch data.
"""
if fname in ['', None]:
fname = self.CurrentTopology.config + '_patches_' + str(int(time()))
self.CurrentTopology.ResetHeavyAttr()

Data={'patches':self.CurrentTopology.patches,
'config':self.CurrentTopology.config,
'xpt_data':self.CurrentTopology.LineTracer.NSEW_lookup
}
np.save(fname, Data)

if Path(fname).suffix == '.npy':
tail = ''
else:
tail = '.npy'
print(f"# Saved patch data for file {Path(fname).name + tail}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does SuperSavePatches only differ from SavePatches by saving the data in npy format as dict all at once without spline data?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes and the grids as well.

Comment on lines +1362 to +1381
def SetPatchesOrientation(self):


# set radial orientation negative if patch is in PFR
for name, patch in self.patches.items():
if patch.plate_patch and self.GetPatchLetterNumber(patch.get_tag())[1]=='1':
patch.RadOrientation=-1
else:
patch.RadOrientation=1

#set poloidal orientation negative if patches in high field side region (must be checked for other config)
Letters=list(dict.fromkeys([L for L,N in self.GetPatchLetterNumber(self.GetListAllPatches())]))
Nhalf=int(len(Letters)/2)
ListLFS=Letters[0:Nhalf]
for name, patch in self.patches.items():
if self.GetPatchLetterNumber(patch.get_tag())[0] in ListLFS:
patch.PolOrientation=-1
else:
patch.PolOrientation=1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetPatchesOrientation should be added strictly to the SNL class first since all other topologies inherit from TopologyUtils.

This will allow us to implement topology specific patch orientations (we see some SF configs have number-tag == 1 in the core)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

bryan-garcia added a commit that referenced this pull request Oct 28, 2020
@bryan-garcia
Copy link
Collaborator

bryan-garcia commented Oct 28, 2020

More comments:

  • LoadPatches error occurs with merging due to differing patch-data file contents (added grid data expectation)
  • Patch map labeling with SNL keywords will not carry to other topologies (move labeling to SNL class itself?)

@jguterl
Copy link
Contributor Author

jguterl commented Nov 13, 2020

It would be probably a good idea to reorganize the patch loading structure into a dictionary so the saving is straightforward.
Loading a dictionary rather than structured data prevent future compatibility issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants