Skip to content

Commit f64f788

Browse files
author
Roberto Di Remigio
committed
Should finally correct all errors due to simultaneous opening of PEDRA.OUT and cavity.off
We generate a unique suffix for these files so that the file opened is always one and only one per run. The .off file is now generated C++-side
1 parent e981de8 commit f64f788

22 files changed

+286
-239
lines changed

cmake/custom/compilers/GNU.Fortran.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Overrides contents of all variables previously set by CMake
22
if(NOT DEFINED ENV{FCFLAGS})
33
if(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
4-
set(CMAKE_Fortran_FLAGS "-DVAR_GFORTRAN -DGFORTRAN=445 -fimplicit-none -fPIC -fautomatic")
4+
set(CMAKE_Fortran_FLAGS "-DVAR_GFORTRAN -DGFORTRAN=445 -fimplicit-none -fPIC -fautomatic -fmax-errors=1")
55
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -fbacktrace -Wall -Wextra ${Fcheck_all}")
66
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-all-loops -ftree-vectorize")
77
endif()

cmake/lib/config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
import shutil
1010

1111

12+
def module_exists(module_name):
13+
try:
14+
__import__(module_name)
15+
except ImportError:
16+
return False
17+
else:
18+
return True
19+
20+
1221
def check_cmake_exists(cmake_command):
1322
"""
1423
Check whether CMake is installed. If not, print

cmake/update.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@ def gen_setup(config, relative_path, setup_script_name):
138138
s.append('\nimport os')
139139
s.append('import sys')
140140

141-
s.append("\nsys.path.append('%s')" % os.path.join(relative_path, 'lib', 'docopt'))
142-
s.append("\nsys.path.append('%s')" % os.path.join(relative_path, 'lib'))
143-
s.append('from config import configure')
141+
s.append("\nsys.path.insert(0, '{0}')".format(relative_path))
142+
s.append("sys.path.insert(0, '{0}')".format(os.path.join(relative_path, 'lib')))
143+
s.append("sys.path.insert(0, '{0}')".format(os.path.join(relative_path, 'lib', 'docopt')))
144+
145+
s.append('import config')
144146
s.append('import docopt')
145147

146148
s.append('\n\noptions = """')
@@ -171,16 +173,29 @@ def gen_setup(config, relative_path, setup_script_name):
171173

172174
s.append(gen_cmake_command(config))
173175

174-
s.append("\n\ntry:")
176+
s.append("\n")
177+
s.append("# parse command line args")
178+
s.append("try:")
175179
s.append(" arguments = docopt.docopt(options, argv=None)")
176180
s.append("except docopt.DocoptExit:")
177181
s.append(r" sys.stderr.write('ERROR: bad input to %s\n' % sys.argv[0])")
178182
s.append(" sys.stderr.write(options)")
179183
s.append(" sys.exit(-1)")
180-
s.append("\nroot_directory = os.path.dirname(os.path.realpath(__file__))")
184+
s.append("\n")
185+
s.append("# use extensions to validate/post-process args")
186+
s.append("if config.module_exists('extensions'):")
187+
s.append(" import extensions")
188+
s.append(" arguments = extensions.postprocess_args(sys.argv, arguments)")
189+
s.append("\n")
190+
s.append("root_directory = os.path.dirname(os.path.realpath(__file__))")
191+
s.append("\n")
181192
s.append("build_path = arguments['<builddir>']")
193+
s.append("\n")
194+
s.append("# create cmake command")
182195
s.append("cmake_command = '%s %s' % (gen_cmake_command(options, arguments), root_directory)")
183-
s.append("configure(root_directory, build_path, cmake_command, arguments['--show'])")
196+
s.append("\n")
197+
s.append("# run cmake")
198+
s.append("config.configure(root_directory, build_path, cmake_command, arguments['--show'])")
184199

185200
return s
186201

doc/gfx/cavity.png

193 Bytes
Loading

doc/gfx/dielectric_profile.png

-240 Bytes
Loading

doc/gfx/green.png

-119 Bytes
Loading

doc/gfx/pedra.png

-287 Bytes
Loading

doc/gfx/utils.png

-62 Bytes
Loading

src/cavity/Cavity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void Cavity::loadCavity(const std::string & fname)
152152
vertices.resize(Eigen::NoChange, nv); // BOGUS!!!
153153
arcs.resize(Eigen::NoChange, nv); // BOGUS!!
154154
// Populate vertices and arcs
155-
elements_.push_back(Element(nv,
155+
elements_.push_back(Element(nv, 0,
156156
elementArea_(i),
157157
elementCenter_.col(i),
158158
elementNormal_.col(i),

src/cavity/Element.hpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
/*
33
* PCMSolver, an API for the Polarizable Continuum Model
44
* Copyright (C) 2013-2015 Roberto Di Remigio, Luca Frediani and contributors
5-
*
5+
*
66
* This file is part of PCMSolver.
7-
*
7+
*
88
* PCMSolver is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Lesser General Public License as published by
1010
* the Free Software Foundation, either version 3 of the License, or
1111
* (at your option) any later version.
12-
*
12+
*
1313
* PCMSolver is distributed in the hope that it will be useful,
1414
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1515
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
* GNU Lesser General Public License for more details.
17-
*
17+
*
1818
* You should have received a copy of the GNU Lesser General Public License
1919
* along with PCMSolver. If not, see <http://www.gnu.org/licenses/>.
20-
*
20+
*
2121
* For information on the complete list of contributors to the
2222
* PCMSolver API, see: <http://pcmsolver.github.io/pcmsolver-doc>
2323
*/
@@ -46,13 +46,14 @@
4646
class Element
4747
{
4848
public:
49-
Element(int nv, double w, const Eigen::Vector3d & c, const Eigen::Vector3d & n,
49+
Element(int nv, int isphe, double w, const Eigen::Vector3d & c, const Eigen::Vector3d & n,
5050
bool i, const Sphere & s, const Eigen::Matrix3Xd & v, const Eigen::Matrix3Xd & a) :
51-
nVertices_(nv), area_(w), center_(c), normal_(n), irreducible_(i),
51+
nVertices_(nv), iSphere_(isphe), area_(w), center_(c), normal_(n), irreducible_(i),
5252
sphere_(s), vertices_(v), arcs_(a) {}
5353
virtual ~Element() {}
5454

5555
int nVertices() const { return nVertices_; }
56+
int iSphere() const { return iSphere_; }
5657
double area() const { return area_; }
5758
Eigen::Vector3d center() const { return center_; }
5859
Eigen::Vector3d normal() const { return normal_; }
@@ -79,6 +80,8 @@ class Element
7980
private:
8081
/// Number of vertices of the finite element
8182
int nVertices_;
83+
/// Index of the sphere the finite element belongs to
84+
int iSphere_;
8285
/// Area of the finite element
8386
double area_;
8487
/// Center of the finite element

0 commit comments

Comments
 (0)