Skip to content

Commit 5ab838b

Browse files
committed
Refactor World
1 parent fd4ff1a commit 5ab838b

Some content is hidden

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

49 files changed

+593
-490
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
IndentWidth: 2
99
TabWidth: 2
1010
UseTab: Never
11-
ColumnLimit: 80
11+
ColumnLimit: 85
1212

1313
# Allow things on a single line
1414

apps/aluminumNew/Aluminum.hpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class Aluminum : public Model {
2020
private:
2121
std::vector<double> filterMF, opL, opN, opEps, P_F;
2222
std::vector<double> psiMF, psi, psiN, P_star_psi, temperature, stress;
23-
std::vector<std::complex<double>> psiMF_F, psi_F, psiN_F, P_psi_F,
24-
temperature_F, stress_F;
23+
std::vector<std::complex<double>> psiMF_F, psi_F, psiN_F, P_psi_F, temperature_F,
24+
stress_F;
2525
size_t mem_allocated = 0;
2626
bool m_first = true;
2727

@@ -80,12 +80,8 @@ class Aluminum : public Model {
8080
void set_x_initial(double x_initial) { params.x_initial = x_initial; }
8181
void set_m_xpos(double m_xpos) { params.m_xpos = m_xpos; }
8282
void set_alpha(double alpha) { params.alpha = alpha; }
83-
void set_alpha_farTol(double alpha_farTol) {
84-
params.alpha_farTol = alpha_farTol;
85-
}
86-
void set_alpha_highOrd(int alpha_highOrd) {
87-
params.alpha_highOrd = alpha_highOrd;
88-
}
83+
void set_alpha_farTol(double alpha_farTol) { params.alpha_farTol = alpha_farTol; }
84+
void set_alpha_highOrd(int alpha_highOrd) { params.alpha_highOrd = alpha_highOrd; }
8985
void set_tau_const(double tau_const) { params.tau_const = tau_const; }
9086
void set_lambda(double lambda) { params.lambda = lambda; }
9187
void set_stabP(double stabP) { params.stabP = stabP; }
@@ -279,19 +275,16 @@ class Aluminum : public Model {
279275
temperature[idx] = T_var;
280276
double q2_bar_N = params.q21_bar * T_var / params.T0;
281277
double q3_bar =
282-
params.q31_bar * (params.T_const + T_var) / params.T0 +
283-
params.q30_bar;
278+
params.q31_bar * (params.T_const + T_var) / params.T0 + params.q30_bar;
284279
double u = psi[idx];
285280
double v = psiMF[idx];
286-
double kernel_term_N =
287-
-(1.0 - exp(-T_var / params.T0)) * P_star_psi[idx];
281+
double kernel_term_N = -(1.0 - exp(-T_var / params.T0)) * P_star_psi[idx];
288282
psiN[idx] = params.p3_bar * u * u + params.p4_bar * u * u * u +
289-
q2_bar_N * v + q3_bar * v * v +
290-
params.q4_bar * v * v * v - kernel_term_N;
283+
q2_bar_N * v + q3_bar * v * v + params.q4_bar * v * v * v -
284+
kernel_term_N;
291285
local_FE += params.p3_bar * u * u * u / 3. +
292-
params.p4_bar * u * u * u * u / 4. +
293-
q2_bar_N * u * v / 2. + q3_bar * u * v * v / 3. +
294-
params.q4_bar * u * v * v * v / 4. +
286+
params.p4_bar * u * u * u * u / 4. + q2_bar_N * u * v / 2. +
287+
q3_bar * u * v * v / 3. + params.q4_bar * u * v * v * v / 4. +
295288
-u * kernel_term_N * u / 2. + -u * P_star_psi[idx] / 2. +
296289
params.p2_bar * u * u / 2. + params.q2_bar * u * v / 2.;
297290
idx++;

apps/aluminumNew/SeedGridFCC.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class SeedGridFCC : public FieldModifier {
3030
public:
3131
SeedGridFCC() = default;
3232

33-
SeedGridFCC(int Ny, int Nz, double X0, double radius, double amplitude,
34-
double rho, double rseed)
33+
SeedGridFCC(int Ny, int Nz, double X0, double radius, double amplitude, double rho,
34+
double rseed)
3535
: m_Nx(1), m_Ny(Ny), m_Nz(Nz), m_X0(X0), m_radius(radius),
3636
m_amplitude(amplitude), m_rho(rho), m_rseed(rseed) {}
3737

@@ -98,17 +98,17 @@ class SeedGridFCC : public FieldModifier {
9898
double Z0 = Dz / 2.0;
9999
int nseeds = Nx * Ny * Nz;
100100

101-
std::cout << "Generating " << nseeds << " regular seeds with radius "
102-
<< radius << "\n";
101+
std::cout << "Generating " << nseeds << " regular seeds with radius " << radius
102+
<< "\n";
103103

104104
std::mt19937_64 re(rseed);
105105
std::uniform_real_distribution<double> rt(-0.2 * radius, 0.2 * radius);
106106
std::uniform_real_distribution<double> rr(0.0, 8.0 * atan(1.0));
107107

108108
for (int j = 0; j < Ny; j++) {
109109
for (int k = 0; k < Nz; k++) {
110-
const std::array<double, 3> location = {
111-
X0 + rt(re), Y0 + Dy * j + rt(re), Z0 + Dz * k + rt(re)};
110+
const std::array<double, 3> location = {X0 + rt(re), Y0 + Dy * j + rt(re),
111+
Z0 + Dz * k + rt(re)};
112112
const std::array<double, 3> orientation = {rr(re), rr(re), rr(re)};
113113
const SeedFCC seed(location, orientation, radius, rho, amplitude);
114114
seeds.push_back(seed);

apps/aluminumNew/SlabFCC.hpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,10 @@ class SlabFCC : public FieldModifier {
7878
Vec3<int> high = decomp.get_inbox().high;
7979

8080
// auto Lx = w.Lx;
81-
auto Ly = w.get_size()[1];
82-
auto Lz = w.get_size()[2];
83-
auto dx = w.get_spacing()[0];
84-
auto dy = w.get_spacing()[1];
85-
auto dz = w.get_spacing()[2];
86-
auto x0 = w.get_origin()[0];
87-
auto y0 = w.get_origin()[1];
88-
auto z0 = w.get_origin()[2];
81+
auto Ly = get_size(w, 1);
82+
auto Lz = get_size(w, 2);
83+
auto [dx, dy, dz] = get_spacing(w);
84+
auto [x0, y0, z0] = get_origin(w);
8985

9086
std::vector<SeedFCC> seeds;
9187

@@ -117,13 +113,13 @@ class SlabFCC : public FieldModifier {
117113

118114
if (randomized) {
119115

120-
std::cout << "Generating " << nseeds << " random seeds up to distance "
121-
<< X0 << "\n";
116+
std::cout << "Generating " << nseeds << " random seeds up to distance " << X0
117+
<< "\n";
122118

123119
for (int j = 0; j < Ny; j++) {
124120
for (int k = 0; k < Nz; k++) {
125-
const std::array<double, 3> location = {
126-
X0 + rt(re), Y0 + Dy * j + rt(re), Z0 + Dz * k + rt(re)};
121+
const std::array<double, 3> location = {X0 + rt(re), Y0 + Dy * j + rt(re),
122+
Z0 + Dz * k + rt(re)};
127123
const std::array<double, 3> orientation = {rr(re), rr(re), rr(re)};
128124
const SeedFCC seed(location, orientation, radius, rho, amplitude);
129125
seeds.push_back(seed);
@@ -136,8 +132,8 @@ class SlabFCC : public FieldModifier {
136132

137133
for (int j = 0; j < Ny; j++) {
138134
for (int k = 0; k < Nz; k++) {
139-
const std::array<double, 3> location = {
140-
X0 + rt(re), Y0 + Dy * j + rt(re), Z0 + Dz * k + rt(re)};
135+
const std::array<double, 3> location = {X0 + rt(re), Y0 + Dy * j + rt(re),
136+
Z0 + Dz * k + rt(re)};
141137
const std::array<double, 3> orientation = orientations[j * Nz + k];
142138
const SeedFCC seed(location, orientation, radius, rho, amplitude);
143139
seeds.push_back(seed);
@@ -218,8 +214,7 @@ void from_json(const json &params, SlabFCC &ic) {
218214
<< std::endl;
219215
}
220216
if (!params.contains("orientations") || !params["orientations"].is_array()) {
221-
std::cout << "No valid orientation vector detected, randomizing."
222-
<< std::endl;
217+
std::cout << "No valid orientation vector detected, randomizing." << std::endl;
223218
}
224219
int Nz = params["Nz"];
225220
int Ny = params["Ny"];

apps/tungsten.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ class Tungsten : public Model {
157157
// calculation when T is not constant in space
158158
double opPeak = params.Bx * exp(-params.T / params.T0) * gf;
159159
// includes the lowest order n_mf term since it is a linear term
160-
double opCk =
161-
params.stabP + params.p2_bar - opPeak + params.q2_bar * fMF;
160+
double opCk = params.stabP + params.p2_bar - opPeak + params.q2_bar * fMF;
162161

163162
filterMF[idx] = fMF;
164163
opL[idx] = exp(kLap * opCk * dt);

docs/getting_started/01-basics/derivative.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ int main(int argc, char *argv[]) {
7676
for (int i = ilow[0]; i <= ihigh[0]; i++) {
7777
double x = x0 + i * dx;
7878
double diff = abs(dy[i] - cos(x));
79-
printf("i=%2d, x(i)=%5.2f, dy(x)=%5.2f, |dy(x)-dy_true(x)|=%0.5f\n", i, x,
80-
dy[i], diff);
79+
printf("i=%2d, x(i)=%5.2f, dy(x)=%5.2f, |dy(x)-dy_true(x)|=%0.5f\n", i, x, dy[i],
80+
diff);
8181
idx += 1;
8282
}
8383

examples/01_hello_world.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ int main() {
4040
// Retrieve world properties
4141
cout << "World properties:" << endl;
4242
auto size = get_size(world);
43-
cout << "Dimensions: " << size[0] << " x " << size[1] << " x " << size[2]
44-
<< endl;
43+
cout << "Dimensions: " << size[0] << " x " << size[1] << " x " << size[2] << endl;
4544
auto world_origin = get_origin(world);
4645
cout << "Origin: (" << world_origin[0] << ", " << world_origin[1] << ", "
4746
<< world_origin[2] << ")" << endl;

examples/03_parallel_fft.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ void dft_forward(const vector<double> x, vector<complex<double>> &X) {
2828
fill(X.begin(), X.end(), 0.0);
2929
for (int n = 0, N = x.size(); n < N; n++) {
3030
for (int k = 0; k < N / 2 + 1; k++) {
31-
X[k] += x[n] * complex<double>(cos(2 * pi / N * k * n),
32-
-sin(2 * pi / N * k * n));
31+
X[k] +=
32+
x[n] * complex<double>(cos(2 * pi / N * k * n), -sin(2 * pi / N * k * n));
3333
}
3434
}
3535
}

examples/04_diffusion_model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Diffusion : public Model {
6464
using Model::Model; // "Inherit" the default constructor of base class
6565

6666
private:
67-
vector<double> opL, psi; // Define linear operator opL and unknown (real) psi
67+
vector<double> opL, psi; // Define linear operator opL and unknown (real) psi
6868
vector<complex<double>> psi_F; // Define (complex) psi
6969

7070
public:

examples/05_simulator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ void print_statline(Simulator &s) {
157157
Diffusion &diffusion_model = dynamic_cast<Diffusion &>(model);
158158
double min = diffusion_model.get_psi_min();
159159
double max = diffusion_model.get_psi_max();
160-
std::cout << "n = " << n << ", t = " << t << ", min = " << min
161-
<< ", max = " << max << std::endl;
160+
std::cout << "n = " << n << ", t = " << t << ", min = " << min << ", max = " << max
161+
<< std::endl;
162162
}
163163

164164
void run_simulator(Simulator &s) {

0 commit comments

Comments
 (0)