Trisurf Monte Carlo simulator
Samo Penic
2016-07-09 eb706bf094cb94104536cd1bb827828db672df5d
Merged the difference
2 files modified
1 files added
128 ■■■■■ changed files
python/tape 10 ●●●● patch | view | raw | blame | history
python/trisurf/VTKRendering.py 76 ●●●●● patch | view | raw | blame | history
python/trisurf/tsmgr.py 42 ●●●●● patch | view | raw | blame | history
python/tape
@@ -1,6 +1,6 @@
####### Vesicle definitions ###########
# nshell is a number of divisions of dipyramid
nshell=5
nshell=10
# dmax is the max. bond length (in units l_min)
dmax=1.7
# dmin_interspecies in the min. dist. between different vertex species (in units l_min)
@@ -17,15 +17,15 @@
pressure=0.0
#Constant volume constraint (0 disable constant volume, 1 enable wiht additional vertex move, 2 enable with epsvol)
constvolswitch=2
constvolswitch=0
constvolprecision=1e-14
#Constant area constraint (0 disable constant area, 2 enable constant area with epsarea)
constareaswitch=2
constareaswitch=0
####### Polymer (brush) definitions ###########
# npoly is a number of polymers attached to npoly distinct vertices on vesicle
npoly=2
npoly=60
# nmono is a number of monomers in each polymer
nmono=10
# Spring constant between monomers of the polymer
@@ -63,7 +63,7 @@
###### Spherical harmonics ###########
# If 0 then spherical harmonics are not calculated at all.
spherical_harmonics_coefficients=21
spherical_harmonics_coefficients=0
#shut up if we are using cluster!!!
quiet=false
python/trisurf/VTKRendering.py
New file
@@ -0,0 +1,76 @@
import os,sys
from . import trisurf
if sys.version_info<(3,0):
    from vtk import *
class Renderer:
    def __init__(self,args,host):
        self.host=host
        self.args=args
        self.renderer = vtkRenderer()
        self.actor=self.lastActor()
        self.textactor=self.textActor()
        self.renderer.AddActor(self.actor)
        self.renderer.AddActor(self.textactor)
        self.renderer.SetBackground(0, 0, 0) # Set background to white
        # Create the RendererWindow
        self.renderer_window = vtkRenderWindow()
        self.renderer_window.AddRenderer(self.renderer)
# Set up a check for aborting rendering.
        # Create the RendererWindowInteractor and display the vtk_file
        interactor = vtkRenderWindowInteractor()
        interactor.SetRenderWindow(self.renderer_window)
        interactor.Initialize()
         interactor.AddObserver("TimerEvent", self.RenderUpdate)
        timerIDR = interactor.CreateRepeatingTimer(1000)
        interactor.Start()
        return
    def lastVTU(self):
        Dir=trisurf.Directory(maindir=self.host['runs'][0].maindir,simdir=self.host['runs'][0].subdir)
        filename=os.path.join("./",Dir.fullpath(),self.host['runs'][0].getLastVTU())
        return filename
    def textActor(self):
        textactor=vtkTextActor()
        textactor.SetInput(self.filename)
        tp=textactor.GetTextProperty()
        tp.SetColor(1,1,1)
        tp.SetFontSize(18)
        textactor.SetDisplayPosition(20,30)
        return textactor
    def lastActor(self):
        self.filename=self.lastVTU()
        reader=vtkXMLUnstructuredGridReader()
        reader.SetFileName(self.filename)
        reader.Update() # Needed because of GetScalarRange
        output = reader.GetOutput()
        scalar_range = output.GetScalarRange()
        mapper = vtkDataSetMapper()
        mapper.SetInput(output)
        mapper.SetScalarRange(scalar_range)
        # Create the Actor
        actor = vtkActor()
        actor.SetMapper(mapper)
        return actor
    def RenderUpdate(self, obj, event):
        if(self.lastVTU()!=self.filename):
            #print("updejt")
            self.renderer.RemoveActor(self.actor)
            self.renderer.RemoveActor(self.textactor)
            self.actor=self.lastActor()
            self.textactor=self.textActor()
            self.renderer.AddActor(self.actor)
            self.renderer.AddActor(self.textactor)
            self.renderer_window.Render()
        #self.render.RemoveActor(self.actor)
        return
python/trisurf/tsmgr.py
@@ -15,6 +15,7 @@
else:
    from urlparse import urlparse
    from vtk import *
    from . import VTKRendering
#import io
@@ -203,50 +204,11 @@
def preview_vtu(args,host):
    #only for localhost at the moment
    Dir=trisurf.Directory(maindir=host['runs'][0].maindir,simdir=host['runs'][0].subdir)
    filename=os.path.join("./",Dir.fullpath(),host['runs'][0].getLastVTU())
    print(filename)
    if sys.version_info>=(3,0):
        print("Preview works only with python 2.7")
        exit(1)
    if host['name'] == socket.gethostname():
        target_runs=getTargetRunIdxList(args)
        #if target_runs==None:
        #    target_runs=list(range(1,len(host['runs'])+1))
        #for i in target_runs:
        #    host['runs'][i-1].start()
        reader=vtkXMLUnstructuredGridReader()
        reader.SetFileName(filename)
        reader.Update() # Needed because of GetScalarRange
        output = reader.GetOutput()
        scalar_range = output.GetScalarRange()
        # Create the mapper that corresponds the objects of the vtk file
        # into graphics elements
        mapper = vtkDataSetMapper()
        mapper.SetInput(output)
        mapper.SetScalarRange(scalar_range)
        # Create the Actor
        actor = vtkActor()
        actor.SetMapper(mapper)
        # Create the Renderer
        renderer = vtkRenderer()
        renderer.AddActor(actor)
        renderer.SetBackground(0, 0, 0) # Set background to white
        # Create the RendererWindow
        renderer_window = vtkRenderWindow()
        renderer_window.AddRenderer(renderer)
        # Create the RendererWindowInteractor and display the vtk_file
        interactor = vtkRenderWindowInteractor()
        interactor.SetRenderWindow(renderer_window)
        interactor.Initialize()
        interactor.Start()
        VTKRendering.Renderer(args,host)
def getListOfHostConfigurationByHostname(hosts,host):
    rhost=[]