|
| 1 | +/** |
| 2 | + * PCMSolver, an API for the Polarizable Continuum Model |
| 3 | + * Copyright (C) 2016 Roberto Di Remigio, Luca Frediani and collaborators. |
| 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 | +#include "Collocation.hpp" |
| 25 | + |
| 26 | +#include "Config.hpp" |
| 27 | + |
| 28 | +#include <Eigen/Core> |
| 29 | + |
| 30 | +#include "cavity/Element.hpp" |
| 31 | +#include "green/IGreensFunction.hpp" |
| 32 | +#include "BIOperatorData.hpp" |
| 33 | +#include "utils/Factory.hpp" |
| 34 | + |
| 35 | +namespace integrator { |
| 36 | +Collocation::Collocation() : factor_(1.07) {} |
| 37 | + |
| 38 | +Collocation::Collocation(double fac) : factor_(fac) {} |
| 39 | + |
| 40 | +Eigen::MatrixXd Collocation::computeS_impl(const std::vector<Element> & elems, |
| 41 | + const IGreensFunction & gf) const { |
| 42 | + PCMSolverIndex cavitySize = elems.size(); |
| 43 | + Eigen::MatrixXd S = Eigen::MatrixXd::Zero(cavitySize, cavitySize); |
| 44 | + for (PCMSolverIndex i = 0; i < cavitySize; ++i) { |
| 45 | + Element source = elems[i]; |
| 46 | + S(i, i) = gf.singleLayer(source, factor_); |
| 47 | + for (PCMSolverIndex j = 0; j < cavitySize; ++j) { |
| 48 | + Element probe = elems[j]; |
| 49 | + if (i != j) |
| 50 | + S(i, j) = gf.kernelS(source.center(), probe.center()); |
| 51 | + } |
| 52 | + } |
| 53 | + return S; |
| 54 | +} |
| 55 | + |
| 56 | +Eigen::MatrixXd Collocation::computeD_impl(const std::vector<Element> & elems, |
| 57 | + const IGreensFunction & gf) const { |
| 58 | + PCMSolverIndex cavitySize = elems.size(); |
| 59 | + Eigen::MatrixXd D = Eigen::MatrixXd::Zero(cavitySize, cavitySize); |
| 60 | + for (PCMSolverIndex i = 0; i < cavitySize; ++i) { |
| 61 | + Element source = elems[i]; |
| 62 | + D(i, i) = gf.doubleLayer(source, factor_); |
| 63 | + for (PCMSolverIndex j = 0; j < cavitySize; ++j) { |
| 64 | + Element probe = elems[j]; |
| 65 | + if (i != j) |
| 66 | + D(i, j) = |
| 67 | + gf.kernelD(probe.normal().normalized(), source.center(), probe.center()); |
| 68 | + } |
| 69 | + } |
| 70 | + return D; |
| 71 | +} |
| 72 | +} // namespace integrator |
| 73 | + |
| 74 | +namespace { |
| 75 | +BoundaryIntegralOperator * createCollocation(const biOperatorData & data) { |
| 76 | + return new integrator::Collocation(data.scaling); |
| 77 | +} |
| 78 | +const std::string COLLOCATION("COLLOCATION"); |
| 79 | +const bool registeredCollocation = |
| 80 | + Factory<BoundaryIntegralOperator, biOperatorData>::TheFactory().registerObject( |
| 81 | + COLLOCATION, createCollocation); |
| 82 | +} |
0 commit comments