1 //
2 // PBSAM.h
3 // pbsam
4 /*
5  Copyright (c) 2015, Teresa Head-Gordon, Lisa Felberg, Enghui Yap, David Brookes
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10  * Redistributions of source code must retain the above copyright
11  notice, this list of conditions and the following disclaimer.
12  * Redistributions in binary form must reproduce the above copyright
13  notice, this list of conditions and the following disclaimer in the
14  documentation and/or other materials provided with the distribution.
15  * Neither the name of UC Berkeley nor the
16  names of its contributors may be used to endorse or promote products
17  derived from this software without specific prior written permission.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS BE LIABLE FOR ANY
23  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef PBSAM_H
32 #define PBSAM_H
33 
34 #include <memory>
35 #include <time.h>
36 //#include "PBAMStruct.h"
37 #include "PBSAMStruct.h"
38 #include "ElectrostaticsSAM.h"
39 #include "BDSAM.h"
40 
41 using namespace std;
42 
43 class PBSAM : protected PBSAMInput
44 {
45 protected:
46   shared_ptr<Setup> _setp_;
47   shared_ptr<SystemSAM> _syst_;
48   shared_ptr<Constants> _consts_;
49 
50   shared_ptr<BesselConstants> _bessl_consts_;
51   shared_ptr<BesselCalc> _bessl_calc_;
52   shared_ptr<SHCalcConstants> _sh_consts_;
53   shared_ptr<SHCalc> _sh_calc_;
54   shared_ptr<ExpansionConstants> _exp_consts_;
55 
56   shared_ptr<Solver> solvr_;
57 
58   vector<shared_ptr<IEMatrix > > imats_;
59   vector<shared_ptr<HMatrix > > h_spol_;
60   vector<shared_ptr<FMatrix > > f_spol_;
61 
62   double force_[MOL_MAX][3];
63   double torque_[MOL_MAX][3];
64   double nrg_intera_[MOL_MAX];
65 
66   int poles_;
67   double solveTol_;
68 
69 public:
70 
71   // Constructors
72   PBSAM();
73   PBSAM(string infile);
74   // For APBS
75   PBSAM(const PBAMInput& pbami, const PBSAMInput& pbsami,
76         vector<shared_ptr<BaseMolecule> > mls );
77 
78   friend PBSAMInput getPBSAMParams();
79   friend PBAMInput getPBAMParams();
80 
81   // Copy constructors
82   PBSAM( const PBSAM& pbsam ) ;
83   PBSAM( const PBSAM* pbsam ) ;
84 
85   void check_setup();
86   void check_system();
87 
88   void init_write_system();
89   void init_consts_calcs();
90   void initialize_pbsam();
91 
92   int run();
93   // for running the APBS version
94   PBAMOutput run_apbs( );
95 
96   void run_bodyapprox();
97   void run_dynamics();
98   void run_electrostatics();
99   void run_energyforce();
100 
101   shared_ptr<SystemSAM> make_subsystem(vector<int> mol_idx);
102 };
103 
104 
105 #endif
106