Skip to content

Commit ad4483b

Browse files
updating with all changes from development
1 parent 8f685ec commit ad4483b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+7306
-650
lines changed

CMakeLists.txt

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ set(SOLVER_INCLUDE_HEADER_NAME "" CACHE STRING "the name of the header file with
7171
set(MODEL_INCLUDE_HEADER_DIR "." CACHE PATH "the location of the header file defining the model definitions")
7272
set(MODEL_INCLUDE_HEADER_NAME "" CACHE STRING "the name of the header file within MODEL_INCLUDE_HEADER_DIR")
7373
set(USE_TESTS OFF CACHE BOOL "include compilation of the tests")
74+
set(USE_FFTW3 OFF CACHE BOOL "pull fftw3 from available releases and build it with SymPhas")
7475

7576
set(MAIN_FILE "" CACHE STRING "The main file that will be compiled into an executable")
7677

@@ -94,10 +95,37 @@ if(USE_PROC)
9495
list(APPEND GROUP_NAMES_0 proc)
9596
endif()
9697

98+
99+
set(NLOHMANN_JSON_VER 3.12.0 CACHE STRING "version of nlohmann_json to use")
100+
include(FetchContent)
101+
102+
if(USE_FFTW3)
103+
set(FFTW3_VER 3.3.10 CACHE STRING "version of fftw to use")
104+
message(STATUS "getting 'FFTW' from Github with FetchContent")
105+
set(FFTW_MD5_FILE "${CMAKE_CURRENT_SOURCE_DIR}/fftw3-${FFTW_VER}.md5sum")
106+
set(FFTW_MD5_URL "https://fftw.org/fftw-${FFTW_VER}.tar.gz.md5sum")
107+
108+
file(DOWNLOAD ${FFTW_MD5_URL} ${FFTW_MD5_FILE} STATUS FFTW_DOWNLOAD_STATUS)
109+
file(READ ${FFTW_MD5_FILE} FFTW_MD5_CONTENTS)
110+
string(REGEX MATCH "^[a-fA-F0-9]+" FFTW_MD5_SUM ${FFTW_MD5_CONTENTS})
111+
file(REMOVE ${FFTW_MD5_FILE})
112+
113+
FetchContent_Declare(FFTW3
114+
URL "https://fftw.org/fftw-${FFTW_VER}.tar.gz"
115+
URL_HASH MD5=${FFTW_MD5_SUM}
116+
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
117+
FIND_PACKAGE_ARGS
118+
)
119+
FetchContent_MakeAvailable(FFTW3)
120+
else()
121+
unset(FFTW3_VER)
122+
endif()
123+
97124
if(USE_CONF)
98125
message(STATUS "getting 'nlohmann_json' from Github with FetchContent")
99-
include(FetchContent)
100-
FetchContent_Declare(nlohmann_json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
126+
FetchContent_Declare(nlohmann_json
127+
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
128+
)
101129
FetchContent_MakeAvailable(nlohmann_json)
102130

103131
list(APPEND GROUP_NAMES_0 conf)

dataprocesses/collectcenterofmass.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
#include "savecenterofmass.h"
4+
#include "datacenterofmass.h"
5+
6+
DEFINE_COLLECTION_DYNAMIC(CenterOfMass)

dataprocesses/collectdensity.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
#include "savedensity.h"
4+
#include "datadensity.h"
5+
6+
DEFINE_COLLECTION_DYNAMIC(Density)

dataprocesses/collectdgpcf.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
#include "savedgpcf.h"
4+
#include "datadgpcf.h"
5+
6+
DEFINE_COLLECTION_DYNAMIC(DGPCF)

dataprocesses/collectdomaingrowth.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
#include "savedomaingrowth.h"
4+
#include "datadomaingrowth.h"
5+
6+
DEFINE_COLLECTION_DYNAMIC(DomainGrowth)

dataprocesses/collectenergy.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
#include "saveenergy.h"
4+
#include "dataenergy.h"
5+
6+
DEFINE_COLLECTION_DYNAMIC(Energy)

dataprocesses/collectpcf.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#include "savepcf.h"
4+
#include "datapcf.h"
5+
6+
7+
DEFINE_COLLECTION_STATIC(PCF)
8+
9+
10+
11+

dataprocesses/collectresidual.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#include "saveresidual.h"
4+
#include "dataresidual.h"
5+
6+
7+
DEFINE_COLLECTION_DYNAMIC(Residual)
8+
9+
10+
11+

dataprocesses/collectsf.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#include "savesf.h"
4+
#include "datasf.h"
5+
6+
DEFINE_COLLECTION_STATIC(SF)
7+
8+
9+
10+
11+

dataprocesses/datacenterofmass.h

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#pragma once
2+
3+
#include "processdynamic.h"
4+
5+
DEFINE_ALGORITHM_POINT(CenterOfMass)
6+
DEFINE_ALGORITHM_DYNAMIC(CenterOfMass)
7+
DEFINE_DATA(CenterOfMass, POINT, ALG_POINT, ALG_DYNAMIC)
8+
9+
10+
11+
ALGORITHM_POINT_1D_DECLARATION(CenterOfMass)
12+
{
13+
axis_1d_type position{};
14+
Y sum{};
15+
for (iter_type i = 0; i < len; ++i)
16+
{
17+
position += data_y[i] * i;
18+
sum += data_y[i];
19+
}
20+
21+
double const dx = ((*(data_x + 1)) - (*data_x));
22+
position *= dx / sum;
23+
24+
return symphas::lib::to_field_data(0, position);
25+
}
26+
27+
ALGORITHM_POINT_2D_DECLARATION(CenterOfMass)
28+
{
29+
axis_2d_type position{};
30+
Y sum{};
31+
for (iter_type i = 0; i < L; ++i)
32+
{
33+
for (iter_type j = 0; j < M; ++j)
34+
{
35+
iter_type n = i + j * L;
36+
position[0] += data_y[n] * i;
37+
position[1] += data_y[n] * j;
38+
sum += data_y[n];
39+
}
40+
}
41+
42+
double const dx = ((*(data_x + 1))[0] - (*data_x)[0]);
43+
double const dy = ((*(data_x + L))[1] - (*data_x)[1]);
44+
45+
position[0] *= dx / sum;
46+
position[1] *= dy / sum;
47+
48+
return symphas::lib::to_field_data(0, position);
49+
}
50+
51+
ALGORITHM_POINT_3D_DECLARATION(CenterOfMass)
52+
{
53+
axis_3d_type position{};
54+
Y sum{};
55+
for (iter_type i = 0; i < L; ++i)
56+
{
57+
for (iter_type j = 0; j < M; ++j)
58+
{
59+
for (iter_type k = 0; k < N; ++k)
60+
{
61+
iter_type n = i + j * L + k * L * M;
62+
position[0] += data_y[n] * i;
63+
position[1] += data_y[n] * j;
64+
position[2] += data_y[n] * k;
65+
sum += data_y[n];
66+
}
67+
}
68+
}
69+
70+
double const dx = ((*(data_x + 1))[0] - (*data_x)[0]);
71+
double const dy = ((*(data_x + L))[1] - (*data_x)[1]);
72+
double const dz = ((*(data_x + L * M))[2] - (*data_x)[2]);
73+
position[0] *= dx / sum;
74+
position[1] *= dy / sum;
75+
position[2] *= dz / sum;
76+
77+
return symphas::lib::to_field_data(0, position);
78+
}
79+
80+
81+
ALGORITHM_DYNAMIC_DECLARATION(CenterOfMass)
82+
{
83+
using result_type = std::tuple<axis_nd_t<D>, int>;
84+
result_type* ys = new result_type[len];
85+
scalar_t* xs = new scalar_t[len];
86+
87+
iter_type id = 0;
88+
iter_type x_last = -1;
89+
for (iter_type i = 0; i < len; ++i)
90+
{
91+
id = (x_last == data_x[i]) ? id + 1 : 0;
92+
x_last = data_x[i];
93+
94+
xs[i] = static_cast<scalar_t>(data_x[i]);
95+
std::get<0>(ys[i]) = data_y[i]->data_y();
96+
std::get<1>(ys[i]) = id;
97+
}
98+
99+
return symphas::lib::to_field_data(xs, ys, len);
100+
}
101+
102+
103+

0 commit comments

Comments
 (0)