delphi_cb
 All Classes Namespaces Files Functions Variables Macros
space.h
1 #ifndef SPACE_H
2 #define SPACE_H
3 
4 #include <iostream>
5 #include <iomanip>
6 #include <fstream>
7 #include <string>
8 #include <memory>
9 //#include <deque>
10 
11 #include <cmath> // std::abs
12 
13 #include "../interface/interface_abstractmodule.h"
14 #include "../misc/misc_timer.h"
15 #include "../delphi/delphi_constants.h"
16 #include "../io/io.h"
17 #include "../interface/interface_datacontainer.h"
18 #include "space_templates.h"
19 #include <stdio.h>
20 #include <stdlib.h>
21 
22 using namespace std;
23 
24 class CDelphiSpace:virtual public IAbstractModule
25 {
26 private: // In DATA CONTAINER
27  shared_ptr<CTimer> pTimer;
28 
29  /*********************************************************************************************
30  * *
31  * references to the variables obtained from the data container *
32  * *
33  ********************************************************************************************/
34 
35  //++++++++++++++ const references to read-only variables from data container +++++++++++++++//
36 
37  const delphi_integer& iNatom; // natom
38  const delphi_real& fScale; // scale
39  const delphi_integer& iGrid; // igrid (modified in setFocusBndy)
40  const delphi_integer& iNObject; // nobject
41 
42  const bool& bUniformDiel; //
43  //const bool& bVerbose; // removed
44  const bool& bOnlyMol; //
45  const bool& isolv; //
46  const bool& irea; //
47  const bool& logs; //
48  const bool& lognl; //
49  const bool& isen; //
50  const bool& isch; //
51  const bool& isite; //
52  const bool& ibem; //
53  const bool& ibctyp;
54  const bool& isitsf;
55 
56 
57 
58  //const bool& bDebug; //
59 
60  //const int& iTestGloble; //
61  //const int& ibmx; //ibmx is removed
62  //const int& iGaussian;
63  const delphi_integer& iNMedia;
64  const delphi_integer& numbmol;
65 
66  const delphi_integer& scrgfrm;
67  //const delphi_integer& ndistr;
68  const SGrid<delphi_real>& cOldMid;
69 
70  const delphi_real& fIonStrenth;
71  const delphi_real& fExternRadius;
72  const delphi_real& fRMax;
73  const vector < delphi_real >& fRadPrb_v;
74  const delphi_real* fRadPrb;
75 
76 
77  const vector <CAtomPdb>& delphipdb; //delphipdb
78 
79  const vector <string> & dataobject_v;
80 
81 
82 
83 
84  //++++++++++++++++ reference to read-and-write variables from data container +++++++++++++++//
85 
86  delphi_integer ndistr; // ndistr
87 
88  delphi_integer& iBoundNum; // ibnum
89  delphi_real& rdmx; // rdmx
90  delphi_integer& nqass;
91  delphi_integer& nqgrd;
92  bool& iacs; //
93  bool& isrf;
94  SGrid<delphi_real>& cMin;
95  SGrid<delphi_real>& cMax;
96  delphi_real& qnet;
97  delphi_real& qmin;
98  delphi_real& qplus;
99  SGrid<delphi_real>& cqmin;
100  SGrid<delphi_real>& cqplus;
101 
102  vector <delphi_real>& medeps;
103  vector < SGrid<delphi_real> >& xn1_v; //prgfgAtomCoordA
104  vector < SGrid<delphi_real> >& xn2_v; //prgfgAtomCoordG
105 
106  vector <bool>& bDebMap_v; //idebmap
107 
108  vector < SGrid<delphi_integer> >& iEpsMap_v; //iepsmap
109 
110  vector <delphi_integer>& iAtomMed_v; //iatmmed
111  vector < SExtrema<delphi_real> >& sLimObject; //limobject
112 
113  vector <SGrid <delphi_integer> >& ibgrd_v; //ibgrd
114 
115  vector < SGrid <delphi_real> >& scspos_v;
116 
117  vector < SGrid <delphi_real> >& chgpos_v;
118 
119  vector <delphi_integer>& crgatn_v;
120  vector <delphi_integer>& nqgrdtonqass_v;
121  vector <delphi_real>& atmeps_v;
122  vector< SGridValue<delphi_real> >& atmcrg_v;
123  vector< SGridValue<delphi_real> >& chrgv2_v;
124 
125  vector < SGrid <delphi_real> >& scsnor_v;
126  vector < delphi_integer >& atsurf_v;
127  vector < delphi_integer >& atndx_v;
128 
129 
130 
131  //+++++++++++++++++++ NON-refereces: +++++++++++++++++++++++++++++++++++++++++++++
132  struct delphipdb_struc
133  {
135  delphi_real charge;
136  delphi_real radius;
137  };
138 
139  delphipdb_struc * sDelPhiPDB;
140 
141 
142 
143 
144  //################# semi global variables in this class #########################
145 
146  bool space_debug;
147  delphi_integer iBoundNumsurf,extot,iall,lcb, mcb, ncb, lcb1, mcb1, ncb1;
148  delphi_real radpmax,grdi, cbai, sideinter, sidemin;
149  SGrid <delphi_real> mnxyz, xyzo, mxxyz;
150  SGrid <delphi_integer> lmncb1, lmncb;;
152  delphi_integer iGaussian;
153  delphi_integer extracrg;
154 
155  vector <delphi_integer> iab1_v, iab2_v, icume, ast, cbn1_v, cbn2_v, cbal, icbn;
156  vector <delphi_real> r0,r02,rs2;
157  vector < SGrid <delphi_real> > expos;
158  vector < SExtrema<delphi_real> > sLimGridUnit;
159 
160 
161  vector < SGrid <delphi_real> > vert, vnorm, vnorm2;
162  vector < SGrid <delphi_integer> > vindx;
163  vector <delphi_integer> vtlen, vtlst, vtpnt;
164 
165  delphi_integer ** tmlst;
166 
167  //SGrid <delphi_real> * scsnor;
168  //delphi_integer * atsurf;
169  //delphi_integer * atndx;
170 
171 
172 
173  SGrid<delphi_real> * xn1;
174  SGrid<delphi_real> * xn2;
175 
176  SGrid <delphi_integer> * ibgrd; //ibgrd
177  SGridValue <delphi_real> * atmcrg;
178  SGridValue <delphi_real> * chrgv2;
179  SGrid <delphi_real> * scspos;
180  SGrid <delphi_real> * chgpos;
181 
182  SGrid <delphi_real> * scsnor;
183  delphi_integer * atsurf;
184  delphi_integer * atndx;
185 
186 
187 
188  delphi_integer * crgatn;
189  delphi_integer * nqgrdtonqass;
190  delphi_real * atmeps;
191 
192 
193  SGrid <delphi_integer> *** egrid;
194  //bool *** bDebMap;
195  bool *** idebmap;
196  SGrid <delphi_integer> *** iepsmp;
197  delphi_integer *** cbn1, *** cbn2, *** iab1, *** iab2;
198  delphi_integer * iAtomMed;
199 
200 
201  SGrid <delphi_real> sgrid_temp_real;
202 
203  SGrid <delphi_integer> sgrid_temp_int;
204 
205 
206 /*
207  template <class T> T *** getKey_Ptr3( vector <T> v_1d, const int& iRows, const int& iColumns, const int& iPages)
208  {
209  //if (!keyExists(strKey)) throw CInexistentKey(strKey);
210 
211  //vector<T> * nConstVectorPtr = any_cast< vector<T> >(&myData[strKey]);
212 
213  //if (nConstVectorPtr->size() != (unsigned int)iRows*iColumns*iPages) throw CUnmatchSize(strKey);
214  cout << "in getkey_ptr3: " << endl;
215  if (v_1d.size() != (unsigned int)iRows*iColumns*iPages) cerr << "error while getting ptr" << endl;
216 
217  T * nConstDataPtr = v_1d.data();
218 
219  T *** prg3D = new T ** [iRows];
220 
221  for (int i = 0; i < iRows; i++)
222  {
223  prg3D[i] = new T * [iColumns];
224 
225  for (int j = 0; j < iColumns; j++)
226  prg3D[i][j] = &nConstDataPtr[i*iColumns*iPages+j*iPages];
227  }
228 
229  return prg3D;
230  }
231 */
232 
233  //############### Functions in other files: ######################
234  void epsmak();
235  void setout();
236  void VdwToMs();
237  void VdwToMs_piece(bool & , const delphi_integer& , const delphi_integer& , const delphi_integer& , const delphi_integer& , const delphi_real& , const SGrid <delphi_real>& , delphi_integer * , delphi_integer * , delphi_integer & ,delphi_real & );
238  void sas();
239  void cube();
240  void cubedata(delphi_real, delphi_real );
241  void indverdata(delphi_real);
242  void indver(delphi_integer);
243  void sclbp();
244  void msrf();
245  void crgarr();
246 
247 
248  SGrid <int> int_coord( const int& a, const int& b, const int& c);
249 
250  SGrid <float> coord( const float& a, const float& b, const float& c);
251 
252  SGrid <int> Float2Int( const SGrid <float>& a );
253 
254  int Float2Int(const float& a);
255 
256  SGrid <float> Int2Float( const SGrid <int>& a );
257 
258  float Int2Float(const int& a);
259 
260  shared_ptr<IDataContainer> test_pdc;
261 
262 
263 
264 public:
265  SGrid <delphi_integer> *** iEpsMap;
266  CDelphiSpace(shared_ptr<IDataContainer> pdc,shared_ptr<CTimer> pt):
267 /*********************************************************************************************
268 * *
269 * references to the variables obtained from the data container *
270 * *
271 ********************************************************************************************/
272 
273  //++++++++++++++ const references to read-only variables from data container +++++++++++++++//
274  IAbstractModule(pdc),
275  pTimer(pt),
276 
277  iNatom (pdc->getKey_constRef<delphi_integer>("natom")),
278  fScale (pdc->getKey_constRef<delphi_real>("scale")),
279  iGrid (pdc->getKey_constRef<delphi_integer>("igrid")),
280  iNObject (pdc->getKey_constRef<delphi_integer>("nobject")),
281  //ndistr (pdc->getKey_constRef<delphi_integer>("ndistr")),
282  bUniformDiel (pdc->getKey_constRef<bool>("uniformdiel")),
283  bOnlyMol (pdc->getKey_constRef<bool>("ionlymol")),
284  isolv (pdc->getKey_constRef<bool>("isolv")),
285  irea (pdc->getKey_constRef<bool>("irea")),
286  logs (pdc->getKey_constRef<bool>("logs")),
287  lognl (pdc->getKey_constRef<bool>("lognl")),
288  isen (pdc->getKey_constRef<bool>("isen")),
289  isch (pdc->getKey_constRef<bool>("isch")),
290 
291  isite (pdc->getKey_constRef<bool>("isite")),
292  ibem (pdc->getKey_constRef<bool>("ibem")),
293  ibctyp (pdc->getKey_constRef<int>("ibctyp")),
294  isitsf (pdc->getKey_constRef<bool>("isitsf")),
295 
296 
297 
298  //bDebug (pdc->getKey_constRef<bool>("debug")),
299 
300  //iTestGloble (pdc->getKey_constRef<int>(" ")),
301  //iGaussian (pdc->getKey_constRef<int>(" ")),
302  iNMedia (pdc->getKey_constRef<delphi_integer>("nmedia")),
303  numbmol (pdc->getKey_constRef<delphi_integer>("numbmol")),
304  scrgfrm (pdc->getKey_constRef<delphi_integer>("scrgfrm")),
305 
306  //ndistr (pdc->getKey_constRef<delphi_integer>("ndistr")),
307 
308  //fRMid (pdc->getKey_constRef<delphi_real>("rmid")),
309  cOldMid(pdc->getKey_constRef< SGrid<delphi_real> >("oldmid")),
310  fIonStrenth (pdc->getKey_constRef<delphi_real>("rionst")),
311  fExternRadius (pdc->getKey_constRef<delphi_real>("exrad")),
312  fRMax (pdc->getKey_constRef<delphi_real>("rdmx")),
313  fRadPrb_v (pdc->getKey_constRef<vector <delphi_real> >("radprb")),
314 
315  delphipdb (pdc->getKey_constRef<vector <CAtomPdb> >("delphipdb")),
316 
317  dataobject_v(pdc->getKey_constRef< vector<string> >("dataobject")),
318 
319  //++++++++++++++++ reference to read-and-write variables from data container +++++++++++++++//
320 
321  iBoundNum (pdc->getKey_Ref<delphi_integer>("ibnum")),
322  rdmx (pdc->getKey_Ref<delphi_real>("rdmx")),
323  nqass (pdc->getKey_Ref<delphi_integer>("nqass")),
324  nqgrd (pdc->getKey_Ref<delphi_integer>("nqgrd")),
325  iacs(pdc->getKey_Ref< bool >("iacs")),
326  isrf(pdc->getKey_Ref< bool >("isrf")),
327  cMin(pdc->getKey_Ref< SGrid<delphi_real> >("cmin")),
328  cMax(pdc->getKey_Ref< SGrid<delphi_real> >("cmax")),
329  qnet(pdc->getKey_Ref< delphi_real >("qnet")),
330  qmin(pdc->getKey_Ref< delphi_real >("qmin")),
331  qplus(pdc->getKey_Ref< delphi_real >("qplus")),
332  cqmin(pdc->getKey_Ref< SGrid<delphi_real> >("cqmin")),
333  cqplus(pdc->getKey_Ref< SGrid<delphi_real> >("cqplus")),
334  medeps(pdc->getKey_Ref < vector < delphi_real > >("medeps")),
335  xn1_v(pdc->getKey_Ref< vector< SGrid<delphi_real> > >("xn1")),
336  xn2_v(pdc->getKey_Ref< vector< SGrid<delphi_real> > >("xn2")),
337  bDebMap_v( pdc->getKey_Ref< vector< bool > >("idebmap")),
338  iEpsMap_v( pdc->getKey_Ref< vector< SGrid<delphi_integer> > > ("iepsmp")),
339  iAtomMed_v(pdc->getKey_Ref< vector<delphi_integer> >("iatmmed")),
340  sLimObject(pdc->getKey_Ref< vector < SExtrema<delphi_real> > >("limobject")),
341  ibgrd_v(pdc->getKey_Ref< vector< SGrid<delphi_integer> > >("ibgrd")),
342  scspos_v(pdc->getKey_Ref< vector< SGrid<delphi_real> > >("scspos")),
343  chgpos_v(pdc->getKey_Ref< vector< SGrid<delphi_real> > >("chgpos")),
344  crgatn_v(pdc->getKey_Ref< vector< delphi_integer > >("crgatn")),
345  nqgrdtonqass_v(pdc->getKey_Ref< vector< delphi_integer > >("nqgrdtonqass")),
346  atmeps_v(pdc->getKey_Ref< vector< delphi_real > >("atmeps")),
347  atmcrg_v(pdc->getKey_Ref< vector< SGridValue<delphi_real> > >("atmcrg")),
348  chrgv2_v(pdc->getKey_Ref< vector< SGridValue<delphi_real> > >("chrgv2")),
349 
350  scsnor_v(pdc->getKey_Ref< vector< SGrid<delphi_real> > >("scsnor")),
351  atsurf_v(pdc->getKey_Ref< vector< delphi_integer > >("atsurf")),
352  atndx_v(pdc->getKey_Ref< vector< delphi_integer > >("atndx"))
353 
354  {
355  //bDebMap_v=pdc->getKey_Ref< vector< bool > >("idebmap");
356  bDebMap_v.assign(iGrid*iGrid*iGrid, true);
357 
358  //iEpsMap_v.assign(iGrid*iGrid*iGrid, {0,0,0});
359 
360  iAtomMed=&iAtomMed_v[-1];
361 
362 
363  sDelPhiPDB = new delphipdb_struc [iNatom+1];
364  //bDebMap=get_pt3d <bool> (iGrid,iGrid,iGrid);
365  //get_pt3d <bool> (bDebMap,iGrid,iGrid,iGrid);
366 
367  //egrid = get_pt3d <SGrid <delphi_integer> > (iGrid,iGrid,iGrid);
368 
369  iGaussian=0;
370  ndistr = 0;
371 
372 
373  test_pdc=pdc;
374 
375  /*
376  delphi_integer ** tmlst;
377  SGrid <delphi_integer> *** egrid;
378  bool *** idebmap;
379  SGrid <delphi_integer> *** iepsmp;
380  delphi_integer *** cbn1, *** cbn2, *** iab1, *** iab2;
381  */
382 
383  // initialize all the pointers to be NULL:
384  tmlst=NULL;
385  egrid=NULL;
386  idebmap=NULL;
387  iepsmp=NULL;
388  iab1=NULL;
389  iab2=NULL;
390  cbn1=NULL;
391  cbn2=NULL;
392 
393  };
394 
395 
396  ~CDelphiSpace() {
397  delete [] sDelPhiPDB ;
398  //free_pt3d <bool> (idebmap,iGrid+1,iGrid+1,iGrid+1);
399  //free_pt3d <SGrid <delphi_integer> > (iEpsMap,iGrid+1,iGrid+1,iGrid+1);
400 
401  };
402 
403 
404  virtual void validateInput();
405 
406  virtual void run();
407 
408 };
409 
410 #endif // SPACE_H
Definition: space.h:24
Definition: interface_abstractmodule.h:23