@@ -175,6 +175,37 @@ extern "C" void compute_polarization_energy(double * energy)
175175 }
176176}
177177
178+ extern " C" void save_surface_functions ()
179+ {
180+ typedef SharedSurfaceFunctionMap::const_iterator surfMap_iter;
181+ for ( surfMap_iter it = functions.begin (); it != functions.end (); ++it ) {
182+ std::string fname = it->second ->name ();
183+ unsigned int dim = static_cast <unsigned int >(it->second ->nPoints ());
184+ const unsigned int shape[] = {dim};
185+ cnpy::npy_save (fname, it->second ->vector ().data (), shape, 1 , " w" , true );
186+ }
187+ }
188+
189+ extern " C" void load_surface_function (const char * name)
190+ {
191+ std::string functionName (name);
192+ cnpy::NpyArray raw_surfFunc = cnpy::npy_load (functionName);
193+ int dim = raw_surfFunc.shape [0 ];
194+ if (dim != _cavity->size ()) {
195+ throw std::runtime_error (" Inconsistent dimension of loaded surface function!" );
196+ } else {
197+ Eigen::VectorXd values = getFromRawBuffer<double >(dim, 1 , raw_surfFunc.data );
198+ SharedSurfaceFunction func ( new SurfaceFunction (functionName, dim, values) );
199+ // Append to global map
200+ SharedSurfaceFunctionMap::iterator iter = functions.lower_bound (functionName);
201+ if ( iter == functions.end () || iter->first != functionName ) {
202+ if ( iter != functions.begin () ) --iter;
203+ SharedSurfaceFunctionPair insertion = SharedSurfaceFunctionMap::value_type (functionName, func);
204+ iter = functions.insert (iter, insertion);
205+ }
206+ }
207+ }
208+
178209extern " C" void dot_surface_functions (double * result, const char * potString,
179210 const char * chgString)
180211{
0 commit comments