~gabrib/cbc.solve/swingWithDolfin1.2

« back to all changes in this revision

Viewing changes to cbc/swing/fsinewton/utils/output.py

  • Committer: Gabriel Balaban
  • Date: 2013-08-05 02:30:48 UTC
  • Revision ID: gabrib@simula.no-20130805023048-5kbvvzay0q1dcpas
add

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
__license__  = "GNU GPL Version 3 or any later version"
6
6
from dolfin import *
7
7
import misc_func as mf
8
 
from mesh_mapping import FunctionMapper 
 
8
from function_mapper import FunctionMapper 
9
9
 
10
10
class FSIPlotter(object):
11
 
    """Continuous plotting of fsi functions"""
 
11
    """Continuous plotting of FSI functions"""
12
12
    def __init__(self,U1):
13
13
        (U1_F,P1_F,L1_U,D1_S,U1_S,D1_F,L1_D) = U1.split()
14
14
 
19
19
        self.plotmodes = [None,None,None,"displacement",None,"displacement"]
20
20
 
21
21
        #Pass the arguments to the continuous plotting object
22
 
        self.plotter = ContinuousPlotter(self.plotfunctions,self.plottitles,self.plotmodes)
 
22
        self.plotter = ContinuousPlotter(self.plotfunctions, self.plottitles, self.plotmodes)
23
23
 
24
24
    def plot(self):
25
25
        self.plotter.plot(self.plotfunctions)
42
42
        for locfunc,newfunc,title,mode in zip(self.localfunctions,functions,self.title,self.modes):
43
43
            locfunc.assign(newfunc)
44
44
            if mode is None:
45
 
                plot(locfunc,autoposition=False, title = title)
 
45
                plot(locfunc, autoposition=False, title = title)
46
46
            else:
47
 
                plot(locfunc,autoposition=False, title = title, mode = mode)
48
 
 
 
47
                plot(locfunc, autoposition=False, title = title, mode = mode)
49
48
 
50
49
class FSIStorer(object):
51
50
    """Store FSI functions in a persistant form"""
52
 
    def __init__(self,store, U):
 
51
    def __init__(self, store, U):
53
52
        import os
54
53
        if not os.path.exists("%s/timeseries/"%store):
55
54
                     os.makedirs("%s/timeseries/"%store)
69
68
                          "D_F":File("%s/vtk/D_F.pvd"%store),
70
69
                          "L_D":File("%s/vtk/L_D.pvd"%store)}
71
70
        
72
 
        U_F, P_F, L_U, D_S, U_S, D_F, L_D = split(U)
73
 
        self.functionMapper = FunctionMapper(function = U_F,
74
 
                                             mapping = D_F)
 
71
        U_F, P_F, L_U, D_S, U_S, D_F, L_D = U.split()
 
72
        U_F2 = Function(U_F.function_space().collapse())
 
73
        U_F2.assign(U_F)
 
74
        
 
75
        D_F2 = Function(D_F.function_space().collapse())
 
76
        D_F2.assign(D_F)
 
77
        
 
78
 
 
79
        self.functionMapper = FunctionMapper(function = U_F2,
 
80
                                             mapping = D_F2)
75
81
    
76
82
    def store_solution(self, U, t):
77
83
        """Store the current solution in a dictionary with the time as the key"""
90
96
        #loop over every FSI Function and save a timeseries and VTK file
91
97
        for k in self.timeseries.keys():
92
98
            self.timeseries[k].store(Usave[k].vector(),t)           
93
 
            self.vtkfiles[k] << Usave[k],t
 
 
b'\\ No newline at end of file'
 
99
            self.vtkfiles[k] << Usave[k], t
 
 
b'\\ No newline at end of file'