1
# -*- coding: utf-8 -*-
3
#-------------------------------------------------------------------------------
5
# This file is part of Code_Saturne, a general-purpose CFD tool.
7
# Copyright (C) 1998-2011 EDF S.A.
9
# This program is free software; you can redistribute it and/or modify it under
10
# the terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 2 of the License, or (at your option) any later
14
# This program is distributed in the hope that it will be useful, but WITHOUT
15
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19
# You should have received a copy of the GNU General Public License along with
20
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
21
# Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
#-------------------------------------------------------------------------------
25
import sys,traceback,os
33
# Trick so that one doesn't have to set the PYTHONPATH variable
34
cspath = '@pkgpythondir@'
35
if os.path.isdir(cspath) and not cspath in sys.path:
36
sys.path.insert(0, cspath)
39
from cs_package import package
41
config = ConfigParser.ConfigParser()
43
config.read([pkg.get_configfile(), os.path.expanduser('~/.' + pkg.configfile)])
45
# Code_Aster installation directory
46
if not config.has_option('install', 'aster'):
47
sys.stderr.write("Cannot locate Code_Aster installation.\n")
50
aster_dir = config.get('install', 'aster')
52
# Code_Aster Python library files
53
aster_path = os.path.join(aster_dir, 'bibpyt')
55
sys.path.insert(0, aster_path)
57
from Execution.E_SUPERV import SUPERV
69
class ExecutionError(Exception):
70
'''General exception during execution'''
72
class FSI_ASTER(FSI_ORB__POA.FSI_ASTER,dsccalcium.PyDSCComponent,SUPERV):
74
To be identified as a SALOME component this Python class
75
must have the same name as the component, inherit omniorb
76
class FSI_ORB__POA.FSI_ASTER and DSC class dsccalcium.PyDSCComponent
77
that implements DSC API.
79
def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ):
81
dsccalcium.PyDSCComponent.__init__(self, orb, poa,contID,containerName,instanceName,interfaceName)
83
def init_service(self,service):
84
if service == "op0117":
85
#initialization CALCIUM ports IN
86
calcium.create_calcium_port(self.proxy,"NB_FOR","CALCIUM_integer","IN","I")
87
calcium.create_calcium_port(self.proxy,"NB_DYN","CALCIUM_integer","IN","I")
88
calcium.create_calcium_port(self.proxy,"COONOD","CALCIUM_double","IN","I")
89
calcium.create_calcium_port(self.proxy,"COOFAC","CALCIUM_double","IN","I")
90
calcium.create_calcium_port(self.proxy,"COLNOD","CALCIUM_integer","IN","I")
91
calcium.create_calcium_port(self.proxy,"COLFAC","CALCIUM_integer","IN","I")
92
calcium.create_calcium_port(self.proxy,"FORAST","CALCIUM_double","IN","I")
93
calcium.create_calcium_port(self.proxy,"NBPDTM","CALCIUM_integer","IN","I")
94
calcium.create_calcium_port(self.proxy,"NBSSIT","CALCIUM_integer","IN","I")
95
calcium.create_calcium_port(self.proxy,"EPSILO","CALCIUM_double","IN","I")
96
calcium.create_calcium_port(self.proxy,"ICVAST","CALCIUM_integer","IN","I")
97
calcium.create_calcium_port(self.proxy,"ISYNCP","CALCIUM_integer","IN","I")
98
calcium.create_calcium_port(self.proxy,"NTCHRO","CALCIUM_integer","IN","I")
99
calcium.create_calcium_port(self.proxy,"TTINIT","CALCIUM_double","IN","I")
100
calcium.create_calcium_port(self.proxy,"PDTREF","CALCIUM_double","IN","I")
101
calcium.create_calcium_port(self.proxy,"DTCALC","CALCIUM_double","IN","I")
102
#initialization CALCIUM ports OUT
103
calcium.create_calcium_port(self.proxy,"DEPAST","CALCIUM_double","OUT","I")
104
calcium.create_calcium_port(self.proxy,"VITAST","CALCIUM_double","OUT","I")
105
calcium.create_calcium_port(self.proxy,"DTAST","CALCIUM_double","OUT","I")
109
def interpstring(self,text,args):
111
self.jdc.g_context.update(args)
112
CONTEXT.set_current_step(self.jdc)
113
linecache.cache['<string>']=0,None,string.split(text,'\n'),'<string>'
114
exec text in self.jdc.const_context,self.jdc.g_context
115
CONTEXT.unset_current_step()
117
CONTEXT.unset_current_step()
119
CONTEXT.unset_current_step()
123
def op0117(self,jdc):
124
self.beginService("FSI_ASTER.op0117")
126
args={"jdc":jdc,"component":self.proxy.ptr()}
127
if not args.has_key("jdc"):
128
fcomm=open("jdc",'r')
134
fcomm=open("fort.1",'w')
139
raise ExecutionError("Error in initial execution")
141
self.interpstring(jdc,args)
143
self.endService("FSI_ASTER.op0117")
147
exc_typ,exc_val,exc_fr=sys.exc_info()
148
l=traceback.format_exception(exc_typ,exc_val,exc_fr)
149
self.endService("FSI_ASTER.op0117")
152
raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"FSI_ASTER.py",0))
156
self._orb.shutdown(0)