1 /*
2  * PCMSolver, an API for the Polarizable Continuum Model
3  * Copyright (C) 2020 Roberto Di Remigio, Luca Frediani and contributors.
4  *
5  * This file is part of PCMSolver.
6  *
7  * PCMSolver is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * PCMSolver is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with PCMSolver.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  * For information on the complete list of contributors to the
21  * PCMSolver API, see: <http://pcmsolver.readthedocs.io/>
22  */
23 
24 #pragma once
25 
26 #include <iosfwd>
27 #include <string>
28 #include <vector>
29 
30 #include "Config.hpp"
31 
32 /*! \file GePolCavity.hpp*/
33 
34 namespace pcm {
35 struct CavityData;
36 } // namespace pcm
37 
38 #include "ICavity.hpp"
39 
40 namespace pcm {
41 namespace cavity {
42 /*! \class GePolCavity
43  *  \brief A class for GePol cavity.
44  *  \author Krzysztof Mozgawa, Roberto Di Remigio
45  *  \date 2011, 2016
46  *
47  *  This class is an interface to the Fortran code PEDRA for the generation
48  *  of cavities according to the GePol algorithm.
49  */
50 class GePolCavity final : public ICavity {
51 public:
GePolCavity()52   GePolCavity() {}
53   GePolCavity(const Molecule & molec,
54               double a,
55               double pr,
56               double minR,
57               const std::string & suffix = "");
58   GePolCavity(const Sphere & sph,
59               double a,
60               double pr,
61               double minR,
62               const std::string & suffix = "");
63   GePolCavity(const std::vector<Sphere> & sph,
64               double a,
65               double pr,
66               double minR,
67               const std::string & suffix = "");
68 
69 private:
70   double averageArea;
71   double probeRadius;
72   double minimalRadius;
73   int addedSpheres;
74   int pruned_;
75   virtual std::ostream & printCavity(std::ostream & os) override;
makeCavity()76   virtual void makeCavity() override {
77     build(std::string("PEDRA.OUT"), 10000, 200, 25000);
78   }
79   /*! \brief Driver for PEDRA Fortran module.
80    *  \param[in]  suffix for the cavity.off and PEDRA.OUT files, the PID will also be
81    * added
82    *  \param[in]   maxts maximum number of tesserae
83    *  \param[in]   maxsp maximum number of spheres (original + added)
84    *  \param[in] maxvert maximum number of vertices
85    */
86   void build(const std::string & suffix, int maxts, int maxsp, int maxvert);
87   /*! \brief Writes the cavity.off file for visualizing the cavity
88    *  \param[in]  suffix for the cavity.off
89    *  The full name of the visualization file will be cavity.off_suffix_PID
90    */
91   void writeOFF(const std::string & suffix);
92 };
93 
94 /*! \fn extern "C" void generatecavity_cpp(int * maxts, int * maxsph, int * maxvert,
95  *                                 double * xtscor, double * ytscor, double * ztscor,
96  * double * ar,
97  *                                 double * xsphcor, double * ysphcor, double *
98  * zsphcor, double * rsph,
99  *                                 int * nts, int * ntsirr, int * nesfp, int *
100  * addsph,
101  *                                 double * xe, double * ye, double * ze, double *
102  * rin,
103  *                                 double * avgArea, double * rsolv, double * ret,
104  *                                 int * nr_gen, int * gen1, int * gen2, int * gen3,
105  *                                 int * nvert, double * vert, double * centr)
106  *  \param[in] maxts maximum number of tesserae allowed
107  *  \param[in] maxsph maximum number of spheres allowed
108  *  \param[in] maxvert maximum number of vertices allowed
109  *  \param[out] xtscor x-coordinate of tesserae centers (dimension maxts)
110  *  \param[out] ytscor y-coordinate of tesserae centers (dimension maxts)
111  *  \param[out] ztscor z-coordinate of tesserae centers (dimension maxts)
112  *  \param[out] ar area of the tessera (dimension maxts)
113  *  \param[out] xsphcor x-coordinate of the sphere center the tessera belongs to
114  * (dimension maxts)
115  *  \param[out] ysphcor y-coordinate of the sphere center the tessera belongs to
116  * (dimension maxts)
117  *  \param[out] zsphcor z-coordinate of the sphere center the tessera belongs to
118  * (dimension maxts)
119  *  \param[out] rsph radii of the sphere the tessera belongs to, i.e. its curvature
120  * (dimension maxts)
121  *  \param[out] nts number of generated tesserae
122  *  \param[out] ntsirr number of generated irreducible tesserae
123  *  \param[out] nesfp number of spheres (original + added)
124  *  \param[out] addsph number of added spheres
125  *  \param[out] xe x-coordinate of the sphere center (dimension nSpheres_ +
126  * maxAddedSpheres)
127  *  \param[out] ye y-coordinate of the sphere center (dimension nSpheres_ +
128  * maxAddedSpheres)
129  *  \param[out] ze z-coordinate of the sphere center (dimension nSpheres_ +
130  * maxAddedSpheres)
131  *  \param[out] rin radius of the spheres (dimension nSpheres_ + maxAddedSpheres)
132  *  \param[in] masses atomic masses (for inertia tensor formation in PEDRA)
133  *  \param[in] avgArea average tesserae area
134  *  \param[in] rsolv solvent probe radius
135  *  \param[in] ret minimal radius for an added sphere
136  *  \param[in] nr_gen number of symmetry generators
137  *  \param[in] gen1 first generator
138  *  \param[in] gen2 second generator
139  *  \param[in] gen3 third generator
140  *  \param[out] nvert number of vertices per tessera
141  *  \param[out] vert coordinates of tesserae vertices
142  *  \param[out] centr centers of arcs defining the edges of the tesserae
143  */
144 extern "C" void generatecavity_cpp(int * maxts,
145                                    int * maxsph,
146                                    int * maxvert,
147                                    double * xtscor,
148                                    double * ytscor,
149                                    double * ztscor,
150                                    double * ar,
151                                    double * xsphcor,
152                                    double * ysphcor,
153                                    double * zsphcor,
154                                    double * rsph,
155                                    int * nts,
156                                    int * ntsirr,
157                                    int * nesfp,
158                                    int * addsph,
159                                    double * xe,
160                                    double * ye,
161                                    double * ze,
162                                    double * rin,
163                                    double * masses,
164                                    double * avgArea,
165                                    double * rsolv,
166                                    double * ret,
167                                    int * nr_gen,
168                                    int * gen1,
169                                    int * gen2,
170                                    int * gen3,
171                                    int * nvert,
172                                    double * vert,
173                                    double * centr,
174                                    int * isphe,
175                                    const char * pedra,
176                                    int * len_f_pedra);
177 
178 ICavity * createGePolCavity(const CavityData & data);
179 } // namespace cavity
180 } // namespace pcm
181