00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00039
00040
#ifndef simulationCore_h
00041
#define simulationCore_h
00042
00043
00044
#include <iostream>
00045
#include <map>
00046
#include <list>
00047
#include <cassert>
00048
#include <string>
00049
#include "constants.h"
00050
#include "config.h"
00051
#include "crusde_api.h"
00052
#include "exceptions.h"
00053
00054
using namespace std;
00055
00056
class LoadHistoryPlugin;
00057
class InputHandler;
00058
class Plugin;
00059
class DataOutPlugin;
00060
class LoadPlugin;
00061
class GreenPlugin;
00062
class ExperimentManager;
00063
class PluginManager;
00064
00066
00071 struct s_parameters {
00072 multimap<string, double*>
load;
00073 multimap<string, double*>
green;
00074 multimap<string, double*>
kernel;
00075 multimap<string, double*>
datahandler;
00076 multimap<string, double*>
postprocessor;
00077 multimap<string, double*>
loadhistory;
00078 };
00079
00080
extern void Debug(
char* format, ... );
00081
00083
00094 class SimulationCore
00095 {
00096
00097 InputHandler *
com_port;
00098 ExperimentManager *
exp_man;
00099 PluginManager *
plugin_man;
00101 Plugin *
pl_kernel;
00102 DataOutPlugin *
pl_out;
00103 GreenPlugin *
pl_green;
00104 LoadPlugin *
pl_load;
00105 LoadHistoryPlugin *
pl_history;
00106 list<Plugin*>
pl_list_postprocessor;
00108
00109 int x_west;
00110 int x_east;
00111 int y_south;
00112 int y_north;
00113 int gridsize;
00114
00115 int modeltime;
00116 int num_timesteps;
00117 int stepsize;
00118 int quadrant;
00119 int dimensions;
00120
00121 int x_index;
00122 int y_index;
00123 int z_index;
00124
00125 map<int*, int>
add_field_map;
00126
00127 double **
model_data;
00128
00129 string
load_file;
00130 string
obs_file;
00131
00132 list<Plugin*>::iterator
pl_iter;
00133
00134 list<Plugin*>
requested_plugin_list;
00139 list<Plugin*>
pl_list_postprocess;
00141 string
root_dir;
00142
00143
static SimulationCore *
pSimulationCore;
00145
00146
SimulationCore(
int argc,
char** argv)
throw(
SeriousException);
00148
SimulationCore(
const SimulationCore& x);
00150
SimulationCore const &
operator=(
SimulationCore const &rvalue);
00151
00152
public:
00153
static s_parameters s_params;
00154
00156
~SimulationCore();
00157
00158
void exec();
00159
void init();
00160
void terminate();
00161
00162
void abort(string msg);
00163
00169 static SimulationCore*
SimulationCore::instance(
int argc,
char** argv)
throw(){
00170
if(!
pSimulationCore){
00171
try{
00172
pSimulationCore =
new SimulationCore(argc, argv);
00173 }
00174
catch(
SeriousException e)
00175 {
00176 cerr<<e.what()<<
"\nAborting..."<<endl;
00177
delete pSimulationCore;
00178 exit(2);
00179 }
00180
catch(...)
00181 {
00182 cerr<<
"An unrecognized error occured while trying to build the SimulationCore.\nAborting..."<<endl;
00183
delete pSimulationCore;
00184 exit(2);
00185 }
00186 }
00187
00188
return pSimulationCore;
00189 }
00190
00195 static SimulationCore*
SimulationCore::instance() throw() {
00196
if(
pSimulationCore)
00197
return pSimulationCore;
00198
else{
00199 cerr <<
"call instance(argc, argv) first! "<< endl;
00200 exit(1);
00201 }
00202 }
00203
00204 GreenPlugin* greenPlugin(){
return pl_green;}
00205 LoadPlugin* loadPlugin(){
return pl_load;}
00206 DataOutPlugin* dataOutPlugin(){
return pl_out;}
00207 LoadHistoryPlugin* loadHistoryPlugin(){
return pl_history;}
00208
00209
const char* loadFile();
00210
const char* outFile();
00211
const char* observeFile();
00212
00213
int sizeX();
00214
int sizeY();
00215
int sizeT();
00216
int gridSize();
00217
int minX();
00218
int minY();
00219
int modelTime();
00220
int stepSize();
00221
int xIndex();
00222
int yIndex();
00223
int zIndex();
00224
00225
int getDimensions();
00226
int displacementDimensions();
00227
double constrainLoadHeight(
double,
int);
00228
00229
int getQuadrant();
00230
void setQuadrant(
int);
00231
void setModelData(
double**);
00232
double** getModelData();
00233
void runExperimentManager();
00234
void runPluginManager();
00235
PluginManager* pluginManager();
00236 list<string> getRegisteredParameters(PluginCategory cat);
00237
void deleteRegistrees();
00238 list<string> getRequestedNames();
00239
void deleteRequests();
00240
00241
00242
green_exec_function addGreenPlugin(string plugin)
throw (
FileNotFound, runtime_error);
00243
load_exec_function addLoadPlugin(string plugin)
throw (
FileNotFound, runtime_error);
00244
run_function addKernelPlugin(string plugin)
throw (
FileNotFound, runtime_error);
00245
run_function addPostprocessorPlugin(string plugin)
throw (
FileNotFound, runtime_error);
00246
loadhistory_exec_function addLoadHistoryPlugin(string plugin)
throw (
FileNotFound, runtime_error);
00247
00248
void registerOutputField(
int *output_index, FieldName field);
00249 };
00250
00251
#endif // simulationCore_h