00001 #define EXTERN
00002 #include "globalt.h"
00003
00004 #include "stochdrivert.h"
00005 #include "trfelinit.h"
00006 #include "connectsifel.h"
00007
00008 #define CTL_Connect
00009 #include "../../ctl/include/ctl/ci/simuTRFEL.ci"
00010
00011
00012 Ctlinterface::Ctlinterface()
00013 {
00014 }
00015
00016
00017
00018
00019
00020 Ctlinterface::Ctlinterface(const string& input)
00021 {
00022 stochdrivert stochd;
00023
00024 Stt = NULL;
00025 Kmat = NULL;
00026 Cmat = NULL;
00027 Jmat = NULL;
00028 Bmat = NULL;
00029 Lbt = NULL;
00030 Lbat = NULL;
00031 Qbt = NULL;
00032 Qbat = NULL;
00033 Ltt = NULL;
00034 Ltat = NULL;
00035 Lqt = NULL;
00036 Qqt = NULL;
00037 Qqat = NULL;
00038 Lqat = NULL;
00039 Ltett = NULL;
00040 Lht = NULL;
00041 Qht = NULL;
00042 G2d = NULL;
00043
00044 static char *argv[3];
00045
00046 argv[0] = "trfel";
00047 argv[1] = input.c_str();
00048 argv[2] = NULL;
00049
00050
00051 trfel_init (2,argv,&stochd);
00052 }
00053
00054
00055
00056
00057
00058
00059
00060 Ctlinterface::Ctlinterface( const string& input, const std::vector<double>& params )
00061 {
00062
00063 }
00064
00065
00066
00067
00068
00069
00070
00071
00072 void Ctlinterface::~Ctlinterface()
00073 {
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 fclose(Outt);
00103 }
00104
00105
00106
00107
00108
00109
00110 void Ctlinterface::set_params( const std::vector<double>& params )
00111 {
00112 Stochdt->importvalues(params.begin());
00113 }
00114
00115
00116
00117
00118
00119
00120
00121 int Ctlinterface::solve()
00122 {
00123 long i,li,ret, j;
00124 double newtime,dt,end_time;
00125 np_glob_vec np_gv;
00126 long lcid = 0;
00127
00128
00129 approximation();
00130 nonstat_solver_init (lcid, np_gv);
00131
00132 dt = Tp->timecont.initialtimeincr ();
00133
00134 end_time = Tp->timecont.endtime ();
00135
00136 li = i = np_gv.istep;
00137 j = 0;
00138
00139 bool breakloop = false;
00140
00141
00142
00143 do{
00144 i++;
00145
00146 newtime = Tp->time = Tp->timecont.newtime();
00147
00148 dt = Tp->timecont.actualbacktimeincr ();
00149
00150 if(Tp->tprob == nonstationary_problem)
00151
00152
00153 ret = one_step_linear(lcid, newtime, dt, i, li, np_gv);
00154
00155 if(Tp->tprob == nonlinear_nonstationary_problem)
00156
00157
00158 ret = one_step_nonlinear(lcid, newtime, dt, i, li, np_gv);
00159
00160
00161 if (Tp->adaptivityflag && Tp->time < end_time)
00162 if (i%2 == 0)
00163 breakloop = Adat->run (2, true);
00164 j++;
00165
00166 }while(Tp->time < end_time && breakloop == false);
00167
00168 return (Tp->time-end_time < 0.0);
00169 }
00170
00171
00172
00173
00174
00175
00176 void Ctlinterface::get_state( std::vector<double>& state ) const
00177 {
00178 Stochdt->exportvalues(state.begin());
00179 }
00180
00181 struct connectDetail
00182 {
00183 CTL_Constructor(1, (const std::string&), 1);
00184 };
00185
00186 void CTL_connect()
00187 {
00188 ctl::connect<simuCI, Ctlinterface, connectDetail>();
00189 }