Skip to content

Commit 4600275

Browse files
committed
merge
1 parent ae31559 commit 4600275

6 files changed

Lines changed: 516 additions & 241 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
2-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -march=native")
1+
set(CMAKE_CXX_COMPILER "g++")
2+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -march=native -fopenmp")
33

44
add_executable( fmm_test
55
src/main.cpp
66
src/multipole.cpp
77
src/expansion.cpp
8+
src/lane_emden.cpp
89
)
910

src/defs.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323

2424
#include <array>
2525

26-
#define CORRECTION_ON
26+
//#define CORRECTION_ON
2727
//#define CORRECTION_OPTIMIZE
2828

2929
using real = double;
3030
using integer = long long;
3131

3232
constexpr integer NDIM = 3;
3333
constexpr integer ncrit = 8;
34-
constexpr integer nparts = 100000;
34+
constexpr integer nparts = 20000;
3535
constexpr integer nchild = 8;
3636
constexpr integer LP = 20;
3737

src/expansion.cpp

Lines changed: 32 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
2-
31
/*
4-
Copyright (c) 2016 Dominic C. Marcello
5-
6-
This program is free software: you can redistribute it and/or modify
7-
it under the terms of the GNU General Public License as published by
8-
the Free Software Foundation, either version 3 of the License, or
9-
(at your option) any later version.
2+
Copyright (c) 2016 Dominic C. Marcello
103
11-
This program is distributed in the hope that it will be useful,
12-
but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
GNU General Public License for more details.
4+
This program is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
158
16-
You should have received a copy of the GNU General Public License
17-
along with this program. If not, see <http://www.gnu.org/licenses/>.
18-
*/
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
1913
14+
You should have received a copy of the GNU General Public License
15+
along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
2017

2118
#include "expansion.hpp"
2219
#include <cmath>
@@ -166,10 +163,11 @@ void expansion::invert() {
166163
expansion::~expansion() {
167164
}
168165

169-
void multipole_interaction(expansion& L1, expansion& L2, const multipole& M1, const multipole& M2, space_vector dX) {
166+
void multipole_interaction(expansion& L1, expansion& L2, const multipole& M1,
167+
const multipole& M2, space_vector dX) {
170168

171-
const real delta[3][3] = { { real(1.0), real(0.0), real(0.0) }, { real(0.0), real(1.0), real(0.0) }, { real(0.0),
172-
real(0.0), real(1.0) } };
169+
const real delta[3][3] = { { real(1.0), real(0.0), real(0.0) }, { real(0.0),
170+
real(1.0), real(0.0) }, { real(0.0), real(0.0), real(1.0) } };
173171

174172
real y0 = 0.0;
175173
for (integer d = 0; d != NDIM; ++d) {
@@ -187,16 +185,28 @@ void multipole_interaction(expansion& L1, expansion& L2, const multipole& M1, co
187185
#endif
188186
#endif
189187
D() = d0;
188+
189+
for (integer a = 0; a < 3; a++) {
190+
for (integer b = a; b < 3; b++) {
191+
for (integer c = b; c < 3; c++) {
192+
D(a, b, c) = 0.0;
193+
}
194+
}
195+
}
196+
190197
for (integer a = 0; a < 3; a++) {
191198
D(a) = dX[a] * d1;
199+
D(a, a, a) += dX[a] * d2;
192200
for (integer b = a; b < 3; b++) {
201+
D(a, a, b) += dX[b] * d2;
202+
D(b, b, a) += dX[a] * d2;
193203
D(a, b) = dX[a] * dX[b] * d2 + delta[a][b] * d1;
194204
for (integer c = b; c < 3; c++) {
195-
D(a, b, c) = dX[a] * dX[b] * dX[c] * d3;
196-
D(a, b, c) += (delta[a][b] * dX[c] + delta[b][c] * dX[a] + delta[c][a] * dX[b]) * d2;
205+
D(a, b, c) += dX[a] * dX[b] * dX[c] * d3;
197206
}
198207
}
199208
}
209+
200210
#ifdef CORRECTION_ON
201211
std::array<expansion, NDIM> D4;
202212
for (integer i = 0; i != NDIM; ++i) {
@@ -226,44 +236,27 @@ void multipole_interaction(expansion& L1, expansion& L2, const multipole& M1, co
226236

227237
L1() += M2() * D();
228238
L2() += M1() * D();
229-
for (integer a = 0; a < 3; a++) {
230-
for (integer b = 0; b < 3; b++) {
231-
L1() += M2(a, b) * D(a, b) * 0.5;
232-
L2() += M1(a, b) * D(a, b) * 0.5;
233-
}
234-
}
235-
236239
for (integer a = 0; a < 3; a++) {
237240
L1(a) += M2() * D(a);
238241
L2(a) -= M1() * D(a);
239-
}
240-
for (integer a = 0; a < 3; a++) {
241242
for (integer b = 0; b < 3; b++) {
243+
L1() += M2(a, b) * D(a, b) * 0.5;
244+
L2() += M1(a, b) * D(a, b) * 0.5;
242245
for (integer c = 0; c < 3; c++) {
243246
L1(a) += M2(c, b) * D(a, b, c) * 0.5;
244247
L2(a) -= M1(c, b) * D(a, b, c) * 0.5;
245248
}
246249
}
247-
}
248-
249-
for (integer a = 0; a < 3; a++) {
250250
for (integer b = a; b < 3; b++) {
251251
L1(a, b) += M2() * D(a, b);
252252
L2(a, b) += M1() * D(a, b);
253-
}
254-
}
255-
256-
for (integer a = 0; a < 3; a++) {
257-
for (integer b = a; b < 3; b++) {
258253
for (integer c = b; c < 3; c++) {
259254
L1(a, b, c) += M2() * D(a, b, c);
260255
L2(a, b, c) -= M1() * D(a, b, c);
261256
}
262257
}
263258
}
264259

265-
266-
267260
#ifdef CORRECTION_ON
268261
for (integer i = 0; i != NDIM; ++i) {
269262
for (integer j = 0; j != NDIM; ++j) {
@@ -277,64 +270,3 @@ void multipole_interaction(expansion& L1, expansion& L2, const multipole& M1, co
277270
}
278271
#endif
279272
}
280-
281-
/*
282-
std::array<expansion, NDIM> expansion::get_derivatives() const {
283-
std::array<expansion, NDIM> D;
284-
for (integer i = 0; i != NDIM; ++i) {
285-
D[i]() = (*this)(i);
286-
for (integer a = 0; a < NDIM; ++a) {
287-
D[i](a) = (*this)(i, a);
288-
for (integer b = a; b < NDIM; ++b) {
289-
D[i](a, b) = (*this)(i, a, b);
290-
for (integer c = b; c != NDIM; ++c) {
291-
D[i](a, b, c) = real(0.0);
292-
}
293-
}
294-
}
295-
}
296-
#ifdef CORRECTION_ON
297-
const real rinv = real(1) / r;
298-
const real D2 = -real(3.0) * std::pow(rinv, real(5));
299-
const real D3 = +real(15.) * std::pow(rinv, real(7));
300-
const real D4 = -real(105) * std::pow(rinv, real(9));
301-
std::array<expansion, NDIM> E1;
302-
for (integer i = 0; i != NDIM; ++i) {
303-
E1[i] = 0.0;
304-
for (integer j = 0; j != NDIM; ++j) {
305-
for (integer k = j; k != NDIM; ++k) {
306-
for (integer l = k; l != NDIM; ++l) {
307-
E1[i](j, k, l) += delta[i][j] * delta[k][l] * D2;
308-
E1[i](j, k, l) += delta[i][l] * delta[j][k] * D2;
309-
E1[i](j, k, l) += delta[i][k] * delta[l][j] * D2;
310-
311-
E1[i](j, k, l) += delta[i][j] * R[k] * R[l] * D3;
312-
E1[i](j, k, l) += delta[i][l] * R[j] * R[k] * D3;
313-
E1[i](j, k, l) += delta[i][k] * R[l] * R[j] * D3;
314-
315-
E1[i](j, k, l) += R[i] * R[j] * delta[k][l] * D3;
316-
E1[i](j, k, l) += R[i] * R[l] * delta[j][k] * D3;
317-
E1[i](j, k, l) += R[i] * R[k] * delta[l][j] * D3;
318-
319-
E1[i](j, k, l) += R[i] * R[j] * R[k] * R[l] * D4;
320-
321-
322-
}
323-
}
324-
}
325-
}
326-
for (integer i = 0; i != NDIM; ++i) {
327-
for (integer j = 0; j != NDIM; ++j) {
328-
for (integer k = 0; k != NDIM; ++k) {
329-
for (integer l = 0; l != NDIM; ++l) {
330-
D[i]() -= E1[i](j, k, l) * M(j, k, l) * (real(1) / real(6));
331-
D[i]() += E1[i](j, k, l) * N(j, k, l) * M() / N() * (real(1) / real(6));
332-
}
333-
}
334-
}
335-
}
336-
#endif
337-
return D;
338-
}
339-
*/
340-

0 commit comments

Comments
 (0)