Commit 5446b0e4 authored by Kumar, Vineet's avatar Kumar, Vineet Committed by Salko Jr, Robert
Browse files

Resolve "Make reference geometry for gaps"

parent de7c13e5
Loading
Loading
Loading
Loading
+60 −5
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import BoundaryCondition as BC
import Solid
import os
import sys
import SubKit.utils.utils as utils
from subprocess import Popen, PIPE, check_call
mypath = os.path.abspath(os.path.dirname(__file__))
localWaspPath = os.path.join(mypath, "../wasp/build/install")
@@ -86,6 +87,12 @@ class InpParse(object):
            for solid in me.inpDict['solid']:
                me.solidIDs.append(solid['id']['value'])

        # Gather gap geometries
        me.gapgeoIDs = []
        if 'gap_geo' in me.inpDict:
            for geo in me.inpDict['gap_geo']:
                me.gapgeoIDs.append(geo['id']['value'])

        # Gather gap IDs in the model
        me.gapIDs = []
        if 'gap' in me.inpDict:
@@ -123,13 +130,28 @@ class InpParse(object):
        me.solidIDs = list(sorted(me.solidIDs))
        me.gapIDs = list(sorted(me.gapIDs))
        me.chgeoIDs = list(me.chgeoIDs)
        me.gapgeoIDs = list(sorted(me.gapgeoIDs))
        me.geoIDs = list(sorted(me.geoIDs))
        me.timeGroups = list(sorted(me.timeGroups))
        me.domainIDs = list(sorted(me.domainIDs))
        me.axialPowIDs = list(sorted(me.axialPowIDs))
        for secID in me.chIDsInSec:
            me.chIDsInSec[secID] = list(sorted(me.chIDsInSec[secID]))
        if sum(np.diff(me.chIDs)==1) != len(me.chIDs)-1:
        if not utils.oneToN(me.chIDs):
            raise InputError("Channel IDs are not consecutive integers")
        if not utils.oneToN(me.geoIDs):
            raise InputError("Solid geo IDs are not consecutive integers")
        if not utils.oneToN(me.solidIDs):
            raise InputError("Solid IDs are not consecutive integers")
        if me.gapIDs is not None:
            if not utils.oneToN(me.gapIDs):
                raise InputError("Gap IDs are not consecutive integers")
        if me.axialPowIDs is not None:
            if not utils.oneToN(me.axialPowIDs):
                raise InputError("Axial power IDs are not consecutive integers")
        if me.domainIDs is not None:
            if not utils.oneToN(me.domainIDs):
                raise InputError("Parallel domain IDs are not consecutive integers")

    def getInitialMassFlux(me):
        if 'mflux' in me.inpDict['initial']:
@@ -168,6 +190,13 @@ class InpParse(object):
            if ch['id']['value']==chID:
                return ch

    def _getGapGeo(me, gapgeoID):
        """ Takes the integer gap_geo ID and retrieves the dictionary for that gap geo from inpDict"""
        if 'gap_geo' in me.inpDict:
           for geo in me.inpDict['gap_geo']:
               if geo['id']['value']==gapgeoID:
                   return geo

    def _getGap(me, gapID):
        """ Takes the integer gap ID and retrieves the dictionary for that gap from inpDict"""
        if 'gap' in me.inpDict:
@@ -251,7 +280,10 @@ class InpParse(object):
        elif 'geo_ref' in chan:
            chgeoID = chan['geo_ref']['value']
            geo = me._getChGeo(chgeoID)
            return geo.get('geo')['value'][0]
            if geo.get('area'):
                return geo.get('area')['value']
            else:
                return geo['geo']['value'][0]
        else:
            return chan['geo']['value'][0]

@@ -271,7 +303,10 @@ class InpParse(object):
        elif 'geo_ref' in chan:
            chgeoID = chan['geo_ref']['value']
            geo = me._getChGeo(chgeoID)
            return geo.get('geo')['value'][1]
            if geo.get('pw'):
                return geo.get('pw')['value']
            else:
                return geo['geo']['value'][1]
        else:
            return chan['geo']['value'][1]

@@ -499,13 +534,33 @@ class InpParse(object):
        """ Returns the gap length for the passed gap ID """
        assert(gapID in me.getGapIDs())
        gap = me._getGap(gapID)
        if 'length' in gap:
            return gap['length']['value']
        elif 'geo_ref' in gap:
            gapgeoID = gap['geo_ref']['value']
            geo = me._getGapGeo(gapgeoID)
            if geo.get('length'):
                return geo.get('length')['value']
            else:
                return geo['geo']['value'][0]
        else:
            return gap['geo']['value'][0]

    def getGapWidth(me,gapID):
        """ Returns the gap width for the passed gap ID """
        assert(gapID in me.getGapIDs())
        gap = me._getGap(gapID)
        if 'width' in gap:
            return gap['width']['value']
        elif 'geo_ref' in gap:
            gapgeoID = gap['geo_ref']['value']
            geo = me._getGapGeo(gapgeoID)
            if geo.get('width'):
                return geo.get('width')['value']
            else:
                return geo['geo']['value'][1]
        else:
            return gap['geo']['value'][1]

    def getGapChannels(me,gapID):
        """ Returns the list of connected channels for the passed gap ID """
+120 −13
Original line number Diff line number Diff line
@@ -300,9 +300,11 @@ ch_geo{
         MaxOccurs=1
      }
    }
   ChildExactlyOne=[area, geo]
   ChildExactlyOne=[pw, geo]
   geo{
      Description="Channel geometric parameters of the channel geometry object. It should be two values with the first one being nominal channel flow area and the second one being the nominal channel wetted perimeter."
      MinOccurs=1
       Description="A shortcut to writing 'area' and 'pw' separately.  Accepts two values, which should be flow area and wetted perimeter."
       MinOccurs=0
       MaxOccurs=1
       value{
          ValType="Real"
@@ -310,6 +312,28 @@ ch_geo{
          MaxOccurs=2
      }
    }
    area{
       Description="Area of the channel geometric object."
       MinOccurs=0
       MaxOccurs=1
       ChildExactlyOne="../pw"
       value{
          ValType="Real"
          MinOccurs=1
          MaxOccurs=1
       }
    }
    pw{
       Description="Wetted perimeter of the channel geometric object."
       MinOccurs=0
       MaxOccurs=1
       ChildExactlyOne="../area"
       value{
          ValType="Real"
          MinOccurs=1
          MaxOccurs=1
       }
    }
}

# IDs have to go from 1 to N without skips.  This ensures 1 and N are there.
@@ -321,7 +345,7 @@ ch{
   MinOccurs=1
   MaxOccurs=NoLimit
   id{
      Description="Stopping criteria for the l:math:`\infty`-norm of relative pressure changes between solution checkpoints."
      Description="ID of the channel"
      MinOccurs=1
      MaxOccurs=1
      value{
@@ -560,10 +584,61 @@ section{
   }
}

ChildUniqueness="gap_geo/id/value"
gap_geo{
   Description="Use to specify a reference gap geometry which can be referenced when defining gaps."
   MinOccurs=0
   MaxOccurs=NoLimit
   id{
      Description="ID of the gap geometry object."
      MinOccurs=1
      MaxOccurs=1
      value{
         ValType="String"
         MinOccurs=1
         MaxOccurs=1
      }
    }
   ChildExactlyOne=[length, geo]
   ChildExactlyOne=[width, geo]
   geo{
      Description="Gap geometric parameters of the gap geometry object. It should be two values with the first one being length of the gap and the second one being the width of the gap."
      MinOccurs=0
      MaxOccurs=1
      value{
         ValType="Real"
         MinOccurs=2
         MaxOccurs=2
      }
    }
   length{
      Description="Length of the gap geometric object."
      MinOccurs=0
      MaxOccurs=1
      ChildExactlyOne="../width"
      value{
         ValType="Real"
         MinOccurs=1
         MaxOccurs=1
      }
   }
   width{
      Description="Width of the gap geometric object."
      MinOccurs=0
      MaxOccurs=1
      ChildExactlyOne="../length"
      value{
         ValType="Real"
         MinOccurs=1
         MaxOccurs=1
      }
   }
}

ChildUniqueness="gap/id/value"
ChildAtMostOne=["gap/id/value"=1]
gap{
   Description="Declares a gap in the model."
   Description="Declares a gap in the model. There are three different ways in which the gap geometry can be defined. The first, is by specifying each individual geometric parameter alongside their respective keyword (length and width), the second, is by pointing to a reference gap geometric object defined in geo_ref, and the third, is by listing all the gap geometry parameters at once using the 'geo' keyword."
   MinOccurs=0
   MaxOccurs=NoLimit
   id{
@@ -574,8 +649,11 @@ gap{
         MinOccurs=1
         MaxOccurs=1
         ValType=Int
         MinValInc=1
      }
   }
   ChildExactlyOne=[length, geo, geo_ref]
   ChildExactlyOne=[width, geo, geo_ref]
   chconn{
      Description="A pair of the connected channel IDs for the gap."
      ### Appearance="The channel IDs must be defined in the ch block."
@@ -588,9 +666,11 @@ gap{
      }
   }
   length{
      MinOccurs=0
      Description="The length of the gap defined as the distance between the channel centroids."
      MinOccurs=1
      MinOccurs=0
      MaxOccurs=1
      ChildExactlyOne="../width"
      value{
         MinOccurs=1
         MaxOccurs=1
@@ -598,15 +678,39 @@ gap{
      }
   }
   width{
      MinOccurs=0
      Description="The width of the gap defined as the distance across the other direction."
      MinOccurs=1
      MinOccurs=0
      MaxOccurs=1
      ChildExactlyOne="../length"
      value{
         MinOccurs=1
         MaxOccurs=1
         ValType=Real
      }
   }
   geo{
      Description="A shortcut to writing 'length' and 'width' separately.  Accepts two values, which should be length and width of the gap"
      MinOccurs=0
      MaxOccurs=1
      value{
         ValType="Real"
         MinOccurs=2
         MaxOccurs=2
      }
   }
   geo_ref{
      Description="ID of the gap geometry object defined in the gap_geo block."
      ### Appearance="ID must be defined in the gap_geo block"
      MinOccurs=0
      MaxOccurs=1
      value{
         ValType="String"
         ExistsIn="/gap_geo/id/value"
         MinOccurs=1
         MaxOccurs=1
      }
   }
}

ChildAtMostOne=["solid_geo/id/value"=1]
@@ -623,6 +727,7 @@ solid_geo{
         MinOccurs=1
         MaxOccurs=1
         ValType=Int
         MinValInc=1
      }
   }
   type{
@@ -693,6 +798,7 @@ solid{
         MaxOccurs=1
         MinValInc=1
         ValType=Int
         MinValInc=1
      }
   }
   geo{
@@ -763,6 +869,7 @@ axialpow{
         MinOccurs=1
         MaxOccurs=1
         ValType=Int
         MinValInc=1
      }
   }
   z{
@@ -873,7 +980,7 @@ domain{
         MinOccurs=1
         MaxOccurs=1
         ValType=Int
         #IncreaseOver("../..")=Strict
         MinValInc=1
      }
   }
   chans{
+93 −3
Original line number Diff line number Diff line
@@ -441,6 +441,26 @@ geo
:Range: >=1
:Note: ID must exist in the 'solid_geo' block

area
----
:Description: Flow area of the channel.
:Min Occurance: 1
:Max Occurance: 1
:Units: m**2
:Type: Real
:Range: n/a
:Note: n/a

pw
--
:Description: Wetted perimeter of the channel.
:Min Occurance: 1
:Max Occurance: 1
:Units: n/a
:Type: Real
:Range: n/a
:Note: n/a

ch
==
:Description: Defines a channel in the model. There are three different ways in which the channel geometry can be defined. The first, is by specifying each individual geometric parameter alongside their respective keyword (e.g., area, pw), the second, is by pointing to a reference channel geometric object defined in geo_ref, and the third, is by listing all the channel geometry parameters at once using the 'geo' keyword. The Channel mesh parameters can be specified individually or listed all at once under the 'mesh' keyword.
@@ -493,13 +513,13 @@ geo

geo_ref
-------
:Description: ID of the channel geometry object defined in the ch_geo block.
:Description: ID of the gap geometry object defined in the gap_geo block.
:Min Occurance: 1
:Max Occurance: 1
:Units: n/a
:Type: "String"
:Range: n/a
:Note: ID must be defined in the ch_geo block
:Note: ID must be defined in the gap_geo block

x
-
@@ -671,9 +691,59 @@ dz
:Range: n/a
:Note: n/a

gap_geo
=======
:Description: Use to specify a reference gap geometry which can be referenced when defining gaps.
:Min Occurance: 0
:Max Occurance: NoLimit
:Units: n/a
:Type: n/a
:Range: n/a
:Note: n/a

id
--
:Description: Specify the parallel domain ID.
:Min Occurance: 1
:Max Occurance: 1
:Units: n/a
:Type: Int
:Range: >=1
:Note: ID can be string or integer type

geo
---
:Description: ID of the solid reference geometry defined in the solid_geo block.
:Min Occurance: 1
:Max Occurance: 1
:Units: n/a
:Type: Int
:Range: >=1
:Note: ID must exist in the 'solid_geo' block

length
------
:Description: The length of the gap defined as the distance between the channel centroids.
:Min Occurance: 1
:Max Occurance: 1
:Units: n/a
:Type: Real
:Range: n/a
:Note: n/a

width
-----
:Description: The width of the gap defined as the distance across the other direction.
:Min Occurance: 1
:Max Occurance: 1
:Units: n/a
:Type: Real
:Range: n/a
:Note: n/a

gap
===
:Description: Declares a gap in the model.
:Description: Declares a gap in the model. There are three different ways in which the gap geometry can be defined. The first, is by specifying each individual geometric parameter alongside their respective keyword (length and width), the second, is by pointing to a reference gap geometric object defined in geo_ref, and the third, is by listing all the gap geometry parameters at once using the 'geo' keyword.
:Min Occurance: 0
:Max Occurance: NoLimit
:Units: n/a
@@ -721,6 +791,26 @@ width
:Range: n/a
:Note: n/a

geo
---
:Description: ID of the solid reference geometry defined in the solid_geo block.
:Min Occurance: 1
:Max Occurance: 1
:Units: n/a
:Type: Int
:Range: >=1
:Note: ID must exist in the 'solid_geo' block

geo_ref
-------
:Description: ID of the gap geometry object defined in the gap_geo block.
:Min Occurance: 1
:Max Occurance: 1
:Units: n/a
:Type: "String"
:Range: n/a
:Note: ID must be defined in the gap_geo block

solid_geo
=========
:Description: Specify a reference solid geometry which can be referenced when defining solids.
+6 −3
Original line number Diff line number Diff line
@@ -11,13 +11,16 @@ section id 1
   num_levels 10

ch_geo id 1
   geo 8.787782e-5 2.984513e-2
   area 8.787782e-5
   pw   2.984513e-2

ch_geo id 2
   geo 4.393891e-5 1.492257e-2
   area 4.393891e-5
   pw   1.492257e-2

ch_geo id 3
   geo 2.196945e-5 7.461283e-3
   area 2.196945e-5
   pw   7.461283e-3

ch id 1
   area  2.196945e-5 # m**2
+51 −50
Original line number Diff line number Diff line
@@ -11,13 +11,19 @@ section id 1
   num_levels 72

ch_geo id "interior"
   geo 0.18675e-3 0.45484e-1
   area 0.18675e-3
   pw   0.45484e-1

ch_geo id "side"
   geo 0.11766e-3 0.41487e-1
   area 0.11766e-3
   pw   0.41487e-1

ch_geo id "corner"
   geo 0.50497e-4 0.28346e-1
   area 0.50497e-4
   pw   0.28346e-1

ch_geo id 1
   geo 0.11766e-3 0.41487e-1

ch id 1
   area  0.50497e-4 # m**2
@@ -33,7 +39,7 @@ ch id 2
   mesh -0.93726e-2 0.24079e-1 0.18745e-1 0.10668e-1

ch id 3
   geo_ref "side"
   geo_ref 1
   mesh 0.93726e-2 0.24079e-1 0.18745e-1 0.10668e-1

ch id 4
@@ -91,6 +97,24 @@ ch id 16
#===================================================
# Gaps
#===================================================
gap_geo id 1
   length 0.147e-1
   width  0.343e-2

gap_geo id 2
   length 0.187e-1
   width  0.343e-2

gap_geo id 3
   length 0.147e-1
   width  0.427e-2

gap_geo id 4
   length 0.187e-1
   width  0.427e-2

gap_geo id "interior"
   geo 0.187e-1 0.427e-2

gap id 1
   chconn 1 2
@@ -98,96 +122,73 @@ gap id 1
   width 0.343e-2 # m
gap id 2
   chconn 1 5
   length 0.147e-1
   width 0.343e-2
   geo 0.147e-1 0.343e-2
gap id 3
   chconn 2 3
   length 0.187e-1
   width 0.343e-2
   geo 0.187e-1 0.343e-2
gap id 4
   chconn 2 6
   length 0.147e-1
   width 0.427e-2
   geo_ref 3
gap id 5
   chconn 3 4
   length 0.147e-1
   width 0.343e-2
   geo_ref 1
gap id 6
   chconn 3 7
   length 0.147e-1
   width 0.427e-2
   geo_ref 3
gap id 7
   chconn 4 8
   length 0.147e-1
   width 0.343e-2
   geo_ref 1
gap id 8
   chconn 5 6
   length 0.147e-1
   width 0.427e-2
   geo_ref 3
gap id 9
   chconn 5 9
   length 0.187e-1
   width 0.343e-2
   geo_ref 2
gap id 10
   chconn 6 7
   length 0.187e-1
   width 0.427e-2
   geo_ref 4
gap id 11
   chconn 6 10
   length 0.187e-1
   width 0.427e-2
   geo_ref 4
gap id 12
   chconn 7 8
   length 0.147e-1
   width 0.427e-2
   geo_ref 3
gap id 13
   chconn 7 11
   length 0.187e-1
   width 0.427e-2
   geo_ref 4
gap id 14
   chconn 8 12
   length 0.187e-1
   width 0.343e-2
   geo_ref 2
gap id 15
   chconn 9 10
   length 0.147e-1
   width 0.427e-2
   geo_ref 3
gap id 16
   chconn 9 13
   length 0.147e-1
   width 0.343e-2
   geo_ref 1
gap id 17
   chconn 10 11
   length 0.187e-1
   width 0.427e-2
   geo_ref "interior"
gap id 18
   chconn 10 14
   length 0.147e-1
   width 0.427e-2
   geo_ref 3
gap id 19
   chconn 11 12
   length 0.147e-1
   width 0.427e-2
   geo_ref 3
gap id 20
   chconn 11 15
   length 0.147e-1
   width 0.427e-2
   geo_ref 3
gap id 21
   chconn 12 16
   length 0.147e-1
   width 0.343e-2
   geo_ref 1
gap id 22
   chconn 13 14
   length 0.147e-1
   width 0.343e-2
   geo_ref 1
gap id 23
   chconn 14 15
   length 0.187e-1
   width 0.343e-2
   geo_ref 2
gap id 24
   chconn 15 16
   length 0.147e-1
   width 0.343e-2
   geo_ref 1

#===================================================
# Solid geometries