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 #include <cstdlib>
00044 #include <iostream>
00045 #include <map>
00046 #include <vector>
00047 #include <list>
00048 #include <cassert>
00049 #include <string>
00050 #include "constants.h"
00051 #include "config.h"
00052 #include "crusde_api.h"
00053 #include "exceptions.h"
00054
00055 using namespace std;
00056
00057 class LoadHistoryPlugin;
00058 class InputHandler;
00059 class Plugin;
00060 class DataOutPlugin;
00061 class LoadPlugin;
00062 class GreensFunction;
00063 class ExperimentManager;
00064 class PluginManager;
00065 class LoadFunction;
00066 class ParamWrapper;
00067
00069
00074 struct s_parameters {
00075 map< unsigned int, multimap< string, ParamWrapper* > > load;
00076 map< unsigned int, multimap< string, ParamWrapper* > > loadhistory;
00077 map< unsigned int, multimap< string, ParamWrapper* > > crustaldecay;
00078 multimap<string, ParamWrapper* > green;
00079 multimap<string, ParamWrapper* > kernel;
00080 multimap<string, ParamWrapper* > datahandler;
00081 multimap<string, ParamWrapper* > postprocessor;
00082 };
00083
00085
00096 class SimulationCore
00097 {
00098
00099 InputHandler *com_port;
00100 ExperimentManager *exp_man;
00101 PluginManager *plugin_man;
00103 Plugin *pl_kernel;
00104 DataOutPlugin *pl_out;
00105 GreensFunction *greens_function;
00106 LoadFunction *load_function;
00108 unsigned int load_function_component;
00109
00110
00111 int x_west;
00112 int x_east;
00113 int y_south;
00114 int y_north;
00115 int gridsize;
00116
00117 int modelstep;
00118 int modeltime;
00119 int num_timesteps;
00120 int num_timeincrement;
00121 int stepsize;
00122 int quadrant;
00123 int dimensions;
00124
00125 int x_index;
00126 int y_index;
00127 int z_index;
00128
00129 map<int*, int> add_field_map;
00130
00131 double **model_data;
00132
00133 list<Plugin*>::iterator pl_iter;
00134
00135 list<Plugin*> requested_plugin_list;
00140 list<Plugin*> pl_list_postprocess;
00142 string root_dir;
00143
00144 int operator_space_x;
00145 int operator_space_y;
00146 bool operator_space_set;
00147
00148 unsigned int num_load_components;
00149
00150 bool quiet;
00151
00152 static SimulationCore *pSimulationCore;
00154
00155 SimulationCore(int argc, char** argv) throw(SeriousException);
00157 SimulationCore(const SimulationCore& x);
00159 SimulationCore const &operator=(SimulationCore const &rvalue);
00160
00161
00162
00163
00164 public:
00165 static s_parameters s_params;
00166
00168 ~SimulationCore();
00169
00170 void exec();
00171 void init();
00172 void terminate();
00173
00174 void abort(string msg);
00175
00181 static SimulationCore* instance(int argc, char** argv) throw(){
00182 if(!pSimulationCore){
00183 try{
00184 pSimulationCore = new SimulationCore(argc, argv);
00185 }
00186 catch(SeriousException e)
00187 {
00188 crusde_error("%s \nAborting...", e.what());
00189 }
00190 catch(...)
00191 {
00192 crusde_error("An unrecognized error occured while trying to build the SimulationCore.\nAborting...");
00193 }
00194 }
00195
00196 return pSimulationCore;
00197 }
00198
00203 static SimulationCore* instance() throw() {
00204 if(pSimulationCore)
00205 return pSimulationCore;
00206 else{
00207
00208 cerr << "Call instance(argc, argv) first!" << endl;
00209 return NULL;
00210 }
00211 }
00212
00213 GreensFunction* greensFunction(){ return greens_function;}
00214 LoadFunction* loadFunction(){ return load_function;}
00215 DataOutPlugin* dataOutPlugin(){ return pl_out;}
00216
00217
00218 unsigned int getLoadFunctionComponent();
00219 void setLoadFunctionComponent(unsigned int i);
00220
00221 unsigned int getNumberOfLoadComponents();
00222
00223 void registerParam(ParamWrapper *param, const char* name, PluginCategory category);
00224
00225 const char* outFile();
00226
00227 int sizeX();
00228 int sizeY();
00229 int sizeT();
00230 int gridSize();
00231 int minX();
00232 int minY();
00233 int modelTime();
00234 int modelStep();
00235 int stepSize();
00236 int xIndex();
00237 int yIndex();
00238 int zIndex();
00239
00240 int getDimensions();
00241 int getTimesteps();
00242 int displacementDimensions();
00243
00244
00245 int getQuadrant();
00246 void setQuadrant(int);
00247 void setModelData(double**);
00248 double** getModelData();
00249 void runExperimentManager();
00250 void runPluginManager();
00251 void installPlugin(string);
00252 PluginManager* pluginManager();
00253 list<string> getRegisteredParameters(PluginCategory cat);
00254 void deleteRegistrees();
00255 list<string> getRequestedNames();
00256 void deleteRequests();
00257
00258 int getOperatorSpaceX();
00259 int getOperatorSpaceY();
00260 void setOperatorSpace(int, int);
00261 bool operatorSpaceIsSet();
00262
00263 string getPluginFilename(string, string) throw (DatabaseError);
00264 void registerOutputField(int *output_index, FieldName field);
00265
00266 string currentJob();
00267
00268 void setQuiet(bool);
00269 bool isQuiet();
00270
00271
00272 green_exec_function addGreenPlugin(string plugin) throw (FileNotFound, runtime_error);
00273 load_exec_function addLoadPlugin(string plugin) throw (FileNotFound, runtime_error);
00274 run_function addKernelPlugin(string plugin) throw (FileNotFound, runtime_error);
00275 run_function addPostprocessorPlugin(string plugin) throw (FileNotFound, runtime_error);
00276 loadhistory_exec_function addLoadHistoryPlugin(string plugin) throw (FileNotFound, runtime_error);
00277 crustaldecay_exec_function addCrustalDecayPlugin(string plugin) throw (FileNotFound, runtime_error);
00278
00279 };
00280
00281 #endif // simulationCore_h