Exemplo n.º 1
0
class SlidingContactTest(TestCase):
    def test_slidingContact(self):
        msml_file = test_common.MSML_EXAMPLE_DIR / 'SlidingContact/sliding_cycy.xml'
        self.app = App(exporter='nsofa', output_dir= test_common.TMP_DIR / 'slideout', 
                       executor='sequential', add_search_path=[test_common.MSML_ALPHABET_DIR])
        self.mf = self.app._load_msml_file(msml_file)
        mem = self.app.execute_msml(self.mf, ) 
        #surfacePreVolume =  mem._internal['CylinderPreSimVolume']['volume']
        #surfacePostVolume =  mem._internal['CylinderPostSimVolume']['volume']
        #print surfacePreVolume<surfacePostVolume
        #print surfacePostVolume
        
class Lungs(object):
    def __init__(self, msml_filename, p):
        self.app = App(exporter='nsofa', output_dir='batchedPressureNew' + str(p), executor='sequential')
        self.mf = self.app._load_msml_file(msml_filename)
        self._surface_pressure = p
    
    def __call__(self):
        self.app.memory_init_file = {
            "surface_pressure":self._surface_pressure 
        }
        mem = self.app.execute_msml(self.mf, ) 
        return mem._internal['volumeMeasure']['volume']
Exemplo n.º 3
0
class Lungs(object):
    def __init__(self, msml_filename, p):
        self.app = App(exporter='nsofa', output_dir=test_common.TMP_DIR / 'batchedPressureNew' + str(p), executor='sequential', 
                       add_search_path=[test_common.MSML_ALPHABET_DIR])
        self.mf = self.app._load_msml_file(msml_filename)
        self._surface_pressure = p
    
    def __call__(self):
        self.app.memory_init_file = {
            "surface_pressure":float(self._surface_pressure)
        }
        mem = self.app.execute_msml(self.mf, ) 
        return mem._internal['volumeMeasure']['volume']
Exemplo n.º 4
0
class MorphCubeTest(TestCase):
    def test_morphCube(self):
        msml_file = test_common.MSML_EXAMPLE_DIR / 'MorphCube/morphtest.xml'
        self.app = App(exporter='nsofa', output_dir= test_common.TMP_DIR / 'morphout', 
                       executor='sequential', add_search_path=[test_common.MSML_ALPHABET_DIR])
        self.mf = self.app._load_msml_file(msml_file)
        mem = self.app.execute_msml(self.mf, ) 
        #compare volume of mesh before and after morphing, volume after morphing should be less than volume before morphing
        originalVolume = mem._internal['OriginalPistonSurfaceVolume']['volume']
        morphedVolume = mem._internal['MorphedPistonSurfaceVolume']['volume']
        self.assertTrue(morphedVolume<originalVolume)
        
        #now, check the dice coefficient (should be above 0.5, below 1) 
        diceCoefficient = mem._internal['computeDice']['diceCoefficient']
        self.assertTrue(diceCoefficient>0.5 and diceCoefficient<1)
        
Exemplo n.º 5
0
 def __init__(self, msml_filename):
     self.app = App()
     self.mf = self.app._load_msml_file(msml_filename)
     self._fixed_contraint_indices = None
     self._force_constraint_indices = None
     self._force_constraint_pressure = [0.0, 0.0, 0.0]
     self._displacement_indices = []
     self._displacement_vector = [0.0, 0.0, 0.0]
Exemplo n.º 6
0
def cli_app(msmlfile, **kwargs):
    """Calls the workflow behind `msmlfile`like an CLI app.

    CLI apps

    * ... takes arguments from the command.
    * ...  provide an `--xml` for providing an XML description of the command line arguments


    :param msmlfile: path to the MSML workflow file (*.xml)
    :type msmlfile: str or path.path
    :param kwargs: various options from :py:class:`msml.frontend.App`

    :return: the memory from the executor
    :rtype: msml.run.memory.Memory
    """

    msmlfile = path(msmlfile)
    app = App(**kwargs)
    mfile = app._load_msml_file(msmlfile)
    app._prepare_msml_model(mfile)

    # grab arguments
    try:
        variables = get_arguments(mfile)

        if isinstance(app.memory_init_file, dict):
            app.memory_init_file.update(variables)
        else:
            app.memory_init_file = variables

        memory = app.execute_msml_file(msmlfile)

        return memory
    except SystemExit:
        pass
    except:
        consolecatcher._reset_stdio()
        raise
Exemplo n.º 7
0
class Liver(object):
    def __init__(self, msml_filename):
        self.app = App()
        self.mf = self.app._load_msml_file(msml_filename)
        self._fixed_contraint_indices = None
        self._force_constraint_indices = None
        self._force_constraint_pressure = [0.0, 0.0, 0.0]
        self._displacement_indices = []
        self._displacement_vector = [0.0, 0.0, 0.0]

    def __call__(self):
        self.app.memory_init_file = {
            "force_vector" : self._force_constraint_pressure,
            "force_indices" : self._force_constraint_indices,
            "fixed_indices" : self._fixed_contraint_indices,
            "disp_vector" : self._displacement_vector,
            "disp_indices" : self._displacement_indices,
            "all_indices" : range(0,106) #readed from LiverXSTet4.vtk
        }

        self.app.execute_msml(self.mf)

        # we now the name from the displacement output request
        return path(".").files("LiverXSTet4Def.vtu*.vtu")


    @property
    def displacement_indices(self):
        return self._displacement_indices

    @displacement_indices.setter
    def displacement_indices(self, value):
        self._displacement_indices = value

    @property
    def displacement_vector(self):
        return self._displacement_vector

    @displacement_vector.setter
    def displacement_vector(self, value):
        self._displacement_vector = value

    @property
    def force_constraint_indices(self):
        return self._force_constraint_indices

    @force_constraint_indices.setter
    def force_constraint_indices(self, value):
        self._force_constraint_indices = value

    @property
    def force_constraint_pressure(self):
        return self._force_constraint_pressure

    @force_constraint_pressure.setter
    def force_constraint_pressure(self, value):
        self._force_constraint_pressure = value

    @property
    def fixed_contraint_indices(self):
        return self._fixed_contraint_indices

    @fixed_contraint_indices.setter
    def fixed_contraint_indices(self, value):
        self._fixed_contraint_indices = value
 def __init__(self, msml_filename, p):
     self.app = App(exporter='nsofa', output_dir='batchedPressureNew' + str(p), executor='sequential')
     self.mf = self.app._load_msml_file(msml_filename)
     self._surface_pressure = p
Exemplo n.º 9
0
 def __init__(self, msml_filename, p):
     self.app = App(exporter='nsofa', output_dir=test_common.TMP_DIR / 'batchedPressureNew' + str(p), executor='sequential', 
                    add_search_path=[test_common.MSML_ALPHABET_DIR])
     self.mf = self.app._load_msml_file(msml_filename)
     self._surface_pressure = p
Exemplo n.º 10
0
""" Shared variables
"""

__author__ = 'Alexander Weigl <*****@*****.**>'
__date__ = '2014-04-10'

from msml.frontend import App

msml_app = App()