Commit 54c987b3 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Improve memory cleaning in sphere

parent 656a4df5
Loading
Loading
Loading
Loading
+23 −13
Original line number Diff line number Diff line
@@ -14,9 +14,6 @@ using namespace std;
//! \brief C++ implementation of SPH
void sphere() {
	complex<double> arg, s0, tfsas;
	complex<double> **tqspe, **tqsps;
	double **tqse, **tqss;
	double *argi, *args, *gaps;
	double th, ph;
	printf("INFO: making legacy configuration ...\n");
	ScattererConfiguration *conf = ScattererConfiguration::from_dedfb("../../test_data/sphere/DEDFB");
@@ -28,6 +25,7 @@ void sphere() {
	GeometryConfiguration *gconf = GeometryConfiguration::from_legacy("../../test_data/sphere/DSPH");
	if (sconf->number_of_spheres == gconf->number_of_spheres) {
		int isq, ibf;
		double *argi, *args, *gaps;
		double cost, sint, cosp, sinp;
		double costs, sints, cosps, sinps;
		double scan;
@@ -48,6 +46,18 @@ void sphere() {
			cmul[i] = new double[4];
			cmullr[i] = new double[4];
		}
		complex<double> **tqspe, **tqsps;
		double **tqse, **tqss;
		tqse = new double*[2];
		tqss = new double*[2];
		tqspe = new std::complex<double>*[2];
		tqsps = new std::complex<double>*[2];
		for (int ti = 0; ti < 2; ti++) {
			tqse[ti] = new double[2]();
			tqss[ti] = new double[2]();
			tqspe[ti] = new std::complex<double>[2]();
			tqsps[ti] = new std::complex<double>[2]();
		}
		double frx = 0.0, fry = 0.0, frz = 0.0;
		double cfmp, cfsp, sfmp, sfsp;
		complex<double> *vint = new complex<double>[16];
@@ -272,16 +282,6 @@ void sphere() {
				printf("DEBUG: TFSAS = (%lE,%lE)\n", tfsas.real(), tfsas.imag());
				double sqk = vk * vk * sconf->exdc;
				aps(zpv, gconf->l_max, nsph, c1, sqk, gaps);
				tqse = new double*[2];
				tqss = new double*[2];
				tqspe = new std::complex<double>*[2];
				tqsps = new std::complex<double>*[2];
				for (int ti = 0; ti < 2; ti++) {
					tqse[ti] = new double[2];
					tqss[ti] = new double[2];
					tqspe[ti] = new std::complex<double>[2];
					tqsps[ti] = new std::complex<double>[2];
				}
				rabas(gconf->in_pol, gconf->l_max, nsph, c1, tqse, tqspe, tqss, tqsps);
				for (int i170 = 1; i170 <= nsph; i170++) {
					if (c1->iog[i170 - 1] >= i170) {
@@ -546,6 +546,16 @@ void sphere() {
		}
		delete[] cmul;
		delete[] cmullr;
		for (int ti = 1; ti > -1; ti--) {
			delete[] tqse[ti];
			delete[] tqss[ti];
			delete[] tqspe[ti];
			delete[] tqsps[ti];
		}
		delete[] tqse;
		delete[] tqss;
		delete[] tqspe;
		delete[] tqsps;
		printf("Done.\n");
	} else { // NSPH mismatch between geometry and scatterer configurations.
		throw UnrecognizedConfigurationException(