Commit fbcebd0d authored by Salko Jr, Robert's avatar Salko Jr, Robert
Browse files

Changes for integration of SubKit into CTF

Modify SubKit.build to use the SubKit input filename as the base name
for the CTF input deck that is created.
Add a unit test on the InpBuilder class to test new procedures added
for getting the base name and number of procs required.
Add remaining files needed by Workbench.
Modify the input.sch file so autocompletion can be used in Workbench.
parent 5e963e2f
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -94,7 +94,8 @@ if(NOT "find_python_module(PyQt4)")
  endif()
endif()

INSTALL( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/conda DESTINATION ${CMAKE_INSTALL_PREFIX} )
INSTALL( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/SubKit DESTINATION ${CMAKE_INSTALL_PREFIX} )

INSTALL( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/conda DESTINATION ${CMAKE_INSTALL_PREFIX} USE_SOURCE_PERMISSIONS )
INSTALL( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/SubKit DESTINATION ${CMAKE_INSTALL_PREFIX} USE_SOURCE_PERMISSIONS )
#INSTALL( FILES ${CMAKE_CURRENT_SOURCE_DIR}/runctf.sh DESTINATION ${CMAKE_INSTALL_PREFIX}/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE )
add_subdirectory(tests)
add_subdirectory(SubKit/build/workbench)
+11 −1
Original line number Diff line number Diff line
@@ -12,8 +12,18 @@ class InpBuilder(object):
    def __init__(me, inpFileName):
        me.model = Model.Model()
        me.inp = InpParse.InpParse(inpFileName)
        head, tail = os.path.split(inpFileName)
        me.filename, ext = os.path.splitext(tail)
        me.genModel()

    def getOutputFilename(me):
       """ Returns the name of the subchannel input file that will be produced by SubKit"""
       return me.filename+".inp"

    def getNumProcs(me):
       """ Returns the number of processors required for the simulation"""
       return max(1, len(me.inp.getParallelDomainIDs()))

    def genModel(me):
        #Sections and channels
        areain = 0
@@ -109,7 +119,7 @@ class InpBuilder(object):
                me.model.addChannelsToDomain(domain=domainID, channels=me.inp.getParallelDomainChannels(domainID))

        me.model.setAveragePower(qprime = me.inp.getInitialQprime())
        me.model.generateModel()
        me.model.generateModel(me.getOutputFilename())

def main():
   parser = argparse.ArgumentParser(description="Generates a CTF input deck from the simplified SubKit input file.")
+1 −2
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ elif os.path.exists(os.path.join(inCTFpath, 'wasputils/ddivalid')):
    waspPath = os.path.join(inCTFpath, 'wasputils')
elif os.path.exists(os.path.join(inCTFInstall, 'ddivalid')):
    # Thisis where wasp will be when in the install directory of an in-CTF build
    sys.pth.append(os.path.join(inCTFInstall, '../wasppy'))
    sys.path.append(os.path.join(inCTFInstall, '../wasppy'))
    waspPath = os.path.join(inCTFInstall)
else:
    raise RuntimeError("WASP package was not found.  It must be installed in SubKit/wasp/build/install to use the input mode.")
@@ -46,7 +46,6 @@ class InpParse(object):
       inpFileName (str): The YAML formatted input file that will be read
    """
    def __init__(me,inpFileName):
        #me.inpDict = yaml.safe_load(open(inpFileName).read())

        # First run the validator to check if this is valid before loading it
        validator = os.path.join(waspPath, 'ddivalid')
+5 −2
Original line number Diff line number Diff line
@@ -822,14 +822,17 @@ class Model:
      if dnbEdits   :  me.editOptions['dnb_edits']   = dnbEdits
      return None

   def generateModel(me):
   def generateModel(me, filename='deck.inp'):
      """ Call after the model is finished being built.

      Will produce a CTF input file called deck.inp that can be run with CTF.

      Args:
         filename (str): Name to be given to the generated model file

      """
      me._preGenDeckChecks()
      writeDeck(me)
      writeDeck(me, filename)

   def _getkchana(me, ch):
      """ Call to get the kchana array to be written to Card 4."""
+8 −2
Original line number Diff line number Diff line
@@ -39,7 +39,13 @@ class keyMap:
         return False


def writeDeck(model):
def writeDeck(model, filename):
   """ Creates a CTF input file

   Args:
      model (Model): The subchannel model object that describes the model
      filename (str): The name to be given to the input file
   """


   if model.runSteadyState:
@@ -782,7 +788,7 @@ def writeDeck(model):
      for l in group19Data:
         newDeckLines.append(l)

   outFile=open('deck.inp','w')
   outFile=open(filename,'w')
   for l in newDeckLines:
      outFile.write(l)
   outFile.close()
Loading