Skip to content

Commit fd4ff1a

Browse files
committed
Fix clang-format errors
1 parent fba6c9f commit fd4ff1a

Some content is hidden

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

69 files changed

+1174
-653
lines changed

.clang-format

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
IndentWidth: 2
99
TabWidth: 2
1010
UseTab: Never
11-
ColumnLimit: 100
11+
ColumnLimit: 80
1212

1313
# Allow things on a single line
1414

@@ -18,11 +18,14 @@ AllowShortFunctionsOnASingleLine: All
1818
AllowShortLambdasOnASingleLine: true
1919
AllowShortCaseLabelsOnASingleLine: true
2020

21+
# List styles: { a, b, c } or {a, b, c} ?
22+
# Cpp11BracedListStyle: false
23+
2124
# Constructor formatting
2225

2326
# ensures that : is placed on a new line
2427
BreakConstructorInitializers: BeforeColon
2528
ConstructorInitializerAllOnOneLineOrOnePerLine: false # puts each initializer on its own line
2629
AllowAllConstructorInitializersOnNextLine: false # disables grouping on the next line
27-
BinPackParameters: false # prevents squeezing multiple parameters into one line
30+
BinPackParameters: true # prevents squeezing multiple parameters into one line
2831
AlignAfterOpenBracket: Align # keeps nice vertical alignment

apps/aluminumNew/Aluminum.hpp

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ using namespace pfc;
1111
using namespace pfc::ui;
1212

1313
/**
14-
* @brief Aluminum model class for OpenPFC. This class is used to define the model.
14+
* @brief Aluminum model class for OpenPFC. This class is used to define the
15+
* model.
1516
*
1617
*/
1718
class Aluminum : public Model {
1819

1920
private:
2021
std::vector<double> filterMF, opL, opN, opEps, P_F;
2122
std::vector<double> psiMF, psi, psiN, P_star_psi, temperature, stress;
22-
std::vector<std::complex<double>> psiMF_F, psi_F, psiN_F, P_psi_F, temperature_F, stress_F;
23+
std::vector<std::complex<double>> psiMF_F, psi_F, psiN_F, P_psi_F,
24+
temperature_F, stress_F;
2325
size_t mem_allocated = 0;
2426
bool m_first = true;
2527

@@ -78,8 +80,12 @@ class Aluminum : public Model {
7880
void set_x_initial(double x_initial) { params.x_initial = x_initial; }
7981
void set_m_xpos(double m_xpos) { params.m_xpos = m_xpos; }
8082
void set_alpha(double alpha) { params.alpha = alpha; }
81-
void set_alpha_farTol(double alpha_farTol) { params.alpha_farTol = alpha_farTol; }
82-
void set_alpha_highOrd(int alpha_highOrd) { params.alpha_highOrd = alpha_highOrd; }
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+
}
8389
void set_tau_const(double tau_const) { params.tau_const = tau_const; }
8490
void set_lambda(double lambda) { params.lambda = lambda; }
8591
void set_stabP(double stabP) { params.stabP = stabP; }
@@ -207,7 +213,8 @@ class Aluminum : public Model {
207213

208214
P_F[idx] = params.Bx * exp(-params.tau_const) * peak;
209215

210-
double opCk = params.stabP + params.p2_bar - P_F[idx] + params.q2_bar_L * fMF;
216+
double opCk =
217+
params.stabP + params.p2_bar - P_F[idx] + params.q2_bar_L * fMF;
211218

212219
filterMF[idx] = fMF;
213220
opL[idx] = exp(kLap * opCk * dt);
@@ -267,18 +274,26 @@ class Aluminum : public Model {
267274
for (int i = low[0]; i <= high[0]; i++) {
268275
double x = x0 + i * dx;
269276
double dist = x + fullruns - (x > steppoint) * l;
270-
double T_var = params.G_grid * (dist - params.x_initial - params.V_grid * t);
277+
double T_var =
278+
params.G_grid * (dist - params.x_initial - params.V_grid * t);
271279
temperature[idx] = T_var;
272280
double q2_bar_N = params.q21_bar * T_var / params.T0;
273-
double q3_bar = params.q31_bar * (params.T_const + T_var) / params.T0 + params.q30_bar;
281+
double q3_bar =
282+
params.q31_bar * (params.T_const + T_var) / params.T0 +
283+
params.q30_bar;
274284
double u = psi[idx];
275285
double v = psiMF[idx];
276-
double kernel_term_N = -(1.0 - exp(-T_var / params.T0)) * P_star_psi[idx];
277-
psiN[idx] = params.p3_bar * u * u + params.p4_bar * u * u * u + q2_bar_N * v + q3_bar * v * v +
286+
double kernel_term_N =
287+
-(1.0 - exp(-T_var / params.T0)) * P_star_psi[idx];
288+
psiN[idx] = params.p3_bar * u * u + params.p4_bar * u * u * u +
289+
q2_bar_N * v + q3_bar * v * v +
278290
params.q4_bar * v * v * v - kernel_term_N;
279-
local_FE += params.p3_bar * u * u * u / 3. + params.p4_bar * u * u * u * u / 4. + q2_bar_N * u * v / 2. +
280-
q3_bar * u * v * v / 3. + params.q4_bar * u * v * v * v / 4. + -u * kernel_term_N * u / 2. +
281-
-u * P_star_psi[idx] / 2. + params.p2_bar * u * u / 2. + params.q2_bar * u * v / 2.;
291+
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. +
295+
-u * kernel_term_N * u / 2. + -u * P_star_psi[idx] / 2. +
296+
params.p2_bar * u * u / 2. + params.q2_bar * u * v / 2.;
282297
idx++;
283298
}
284299
}
@@ -443,11 +458,10 @@ void from_json(const json &j, Aluminum &m) {
443458
j.at("q31_bar").get_to(p.q31_bar);
444459
j.at("q40_bar").get_to(p.q40_bar);
445460
/*
446-
p.q20_bar = p.q20 + 2.0 * p.shift_s * p.q30 + 3.0 * pow(p.shift_s, 2) * p.q40;
447-
p.q21_bar = p.q21 + 2.0 * p.shift_s * p.q31;
448-
p.q30_bar = p.shift_u * (p.q30 + 3.0 * p.shift_s * p.q40);
449-
p.q31_bar = p.shift_u * p.q31;
450-
p.q40_bar = pow(p.shift_u, 2) * p.q40;
461+
p.q20_bar = p.q20 + 2.0 * p.shift_s * p.q30 + 3.0 * pow(p.shift_s, 2) *
462+
p.q40; p.q21_bar = p.q21 + 2.0 * p.shift_s * p.q31; p.q30_bar = p.shift_u *
463+
(p.q30 + 3.0 * p.shift_s * p.q40); p.q31_bar = p.shift_u * p.q31; p.q40_bar
464+
= pow(p.shift_u, 2) * p.q40;
451465
*/
452466
p.q2_bar = p.q21_bar * p.tau_const + p.q20_bar;
453467
p.q2_bar_L = p.q2_bar;
@@ -473,7 +487,8 @@ void step(Simulator &s, Aluminum &m) {
473487
// auto moving = dynamic_cast< MovingBC& >(*bc);
474488
// double newxpos = moving.get_xpos();
475489
// m.set_m_xpos(newxpos);
476-
// if (m.rank0) std::cout << "Updated xpos to " << m.params.m_xpos << std::endl;
490+
// if (m.rank0) std::cout << "Updated xpos to " << m.params.m_xpos <<
491+
// std::endl;
477492
}
478493
}
479494

apps/aluminumNew/SeedFCC.hpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ class SeedFCC {
9898
* @return vec32
9999
*/
100100
vec32 bounding_box(const vec3 &location, double radius) {
101-
const vec3 low = {location[0] - radius, location[1] - radius, location[2] - radius};
102-
const vec3 high = {location[0] + radius, location[1] + radius, location[2] + radius};
101+
const vec3 low = {location[0] - radius, location[1] - radius,
102+
location[2] - radius};
103+
const vec3 high = {location[0] + radius, location[1] + radius,
104+
location[2] + radius};
103105
const vec32 bbox = {low, high};
104106
return bbox;
105107
}
@@ -113,8 +115,9 @@ class SeedFCC {
113115
*/
114116
inline bool is_inside_bbox(const vec3 &location) const {
115117
const vec32 bbox = get_bbox();
116-
return (location[0] > bbox[0][0]) && (location[0] < bbox[1][0]) && (location[1] > bbox[0][1]) &&
117-
(location[1] < bbox[1][1]) && (location[2] > bbox[0][2]) && (location[2] < bbox[1][2]);
118+
return (location[0] > bbox[0][0]) && (location[0] < bbox[1][0]) &&
119+
(location[1] > bbox[0][1]) && (location[1] < bbox[1][1]) &&
120+
(location[2] > bbox[0][2]) && (location[2] < bbox[1][2]);
118121
}
119122

120123
double get_radius() const { return radius_; }
@@ -134,9 +137,11 @@ class SeedFCC {
134137
* @param rho Density of the seed
135138
* @param amplitude Amplitude of the seed
136139
*/
137-
SeedFCC(const vec3 &location, const vec3 &orientation, const double radius, const double rho, const double amplitude)
138-
: location_(location), orientation_(orientation), q_(rotate(orientation)), bbox_(bounding_box(location, radius)),
139-
rho_(rho), radius_(radius), amplitude_(amplitude) {}
140+
SeedFCC(const vec3 &location, const vec3 &orientation, const double radius,
141+
const double rho, const double amplitude)
142+
: location_(location), orientation_(orientation), q_(rotate(orientation)),
143+
bbox_(bounding_box(location, radius)), rho_(rho), radius_(radius),
144+
amplitude_(amplitude) {}
140145

141146
/**
142147
* @brief Check if a point is inside the seed.

apps/aluminumNew/SeedGridFCC.hpp

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ using json = nlohmann::json;
1515
using namespace pfc;
1616

1717
/**
18-
* @brief SeedGridFCC is a FieldModifier that seeds the model with a grid of FCC seeds.
18+
* @brief SeedGridFCC is a FieldModifier that seeds the model with a grid of FCC
19+
* seeds.
1920
*
2021
*/
2122
class SeedGridFCC : public FieldModifier {
@@ -29,15 +30,10 @@ class SeedGridFCC : public FieldModifier {
2930
public:
3031
SeedGridFCC() = default;
3132

32-
SeedGridFCC(int Ny, int Nz, double X0, double radius, double amplitude, double rho, double rseed)
33-
: m_Nx(1),
34-
m_Ny(Ny),
35-
m_Nz(Nz),
36-
m_X0(X0),
37-
m_radius(radius),
38-
m_amplitude(amplitude),
39-
m_rho(rho),
40-
m_rseed(rseed) {}
33+
SeedGridFCC(int Ny, int Nz, double X0, double radius, double amplitude,
34+
double rho, double rseed)
35+
: m_Nx(1), m_Ny(Ny), m_Nz(Nz), m_X0(X0), m_radius(radius),
36+
m_amplitude(amplitude), m_rho(rho), m_rseed(rseed) {}
4137

4238
// getters
4339
int get_Nx() const { return m_Nx; }
@@ -102,15 +98,17 @@ class SeedGridFCC : public FieldModifier {
10298
double Z0 = Dz / 2.0;
10399
int nseeds = Nx * Ny * Nz;
104100

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

107104
std::mt19937_64 re(rseed);
108105
std::uniform_real_distribution<double> rt(-0.2 * radius, 0.2 * radius);
109106
std::uniform_real_distribution<double> rr(0.0, 8.0 * atan(1.0));
110107

111108
for (int j = 0; j < Ny; j++) {
112109
for (int k = 0; k < Nz; k++) {
113-
const std::array<double, 3> location = {X0 + rt(re), Y0 + Dy * j + rt(re), Z0 + Dz * k + rt(re)};
110+
const std::array<double, 3> location = {
111+
X0 + rt(re), Y0 + Dy * j + rt(re), Z0 + Dz * k + rt(re)};
114112
const std::array<double, 3> orientation = {rr(re), rr(re), rr(re)};
115113
const SeedFCC seed(location, orientation, radius, rho, amplitude);
116114
seeds.push_back(seed);
@@ -150,39 +148,46 @@ class SeedGridFCC : public FieldModifier {
150148
* { "type": "seed_grid_fcc", "X0": 130.0, "Ny": 2, "Nz": 1, "radius": 120,
151149
* "amplitude": 0.4, "rho": -0.036, "rseed": 42 }
152150
*
153-
* The "type" field is required and must be "seed_grid_fcc". The "rseed" field is
154-
* optional and defaults to 0. All other fields are required. The "Ny" and "Nz"
155-
* fields are the number of seeds in the y and z directions, respectively. The
156-
* "X0" field is the x-coordinate of the center of the first seed. The "radius"
157-
* field is the radius of the seeds. The "amplitude" field is the amplitude of
158-
* the seed. The "rho" field is the background density. The "rseed" field is the
159-
* random seed.
151+
* The "type" field is required and must be "seed_grid_fcc". The "rseed" field
152+
* is optional and defaults to 0. All other fields are required. The "Ny" and
153+
* "Nz" fields are the number of seeds in the y and z directions, respectively.
154+
* The "X0" field is the x-coordinate of the center of the first seed. The
155+
* "radius" field is the radius of the seeds. The "amplitude" field is the
156+
* amplitude of the seed. The "rho" field is the background density. The "rseed"
157+
* field is the random seed.
160158
*
161159
*/
162160
void from_json(const json &params, SeedGridFCC &ic) {
163161
std::cout << "Parsing SeedGridFCC from json" << std::endl;
164162

165163
// check for required fields
166164
if (!params.contains("amplitude") || !params["amplitude"].is_number()) {
167-
throw std::invalid_argument("Reading SeedGridFCC failed: missing or invalid 'amplitude' field.");
165+
throw std::invalid_argument(
166+
"Reading SeedGridFCC failed: missing or invalid 'amplitude' field.");
168167
}
169168
if (!params.contains("radius") || !params["radius"].is_number()) {
170-
throw std::invalid_argument("Reading SeedGridFCC failed: missing or invalid 'radius' field.");
169+
throw std::invalid_argument(
170+
"Reading SeedGridFCC failed: missing or invalid 'radius' field.");
171171
}
172172
if (!params.contains("rho") || !params["rho"].is_number()) {
173-
throw std::invalid_argument("Reading SeedGridFCC failed: missing or invalid 'rho' field.");
173+
throw std::invalid_argument(
174+
"Reading SeedGridFCC failed: missing or invalid 'rho' field.");
174175
}
175176
if (!params.contains("Ny") || !params["Ny"].is_number()) {
176-
throw std::invalid_argument("Reading SeedGridFCC failed: missing or invalid 'Ny' field.");
177+
throw std::invalid_argument(
178+
"Reading SeedGridFCC failed: missing or invalid 'Ny' field.");
177179
}
178180
if (!params.contains("Nz") || !params["Nz"].is_number()) {
179-
throw std::invalid_argument("Reading SeedGridFCC failed: missing or invalid 'Nz' field.");
181+
throw std::invalid_argument(
182+
"Reading SeedGridFCC failed: missing or invalid 'Nz' field.");
180183
}
181184
if (!params.contains("X0") || !params["X0"].is_number()) {
182-
throw std::invalid_argument("Reading SeedGridFCC failed: missing or invalid 'X0' field.");
185+
throw std::invalid_argument(
186+
"Reading SeedGridFCC failed: missing or invalid 'X0' field.");
183187
}
184188
if (!params.contains("rseed") || !params["rseed"].is_number()) {
185-
std::cout << "No valid random seed detected, using default value 0." << std::endl;
189+
std::cout << "No valid random seed detected, using default value 0."
190+
<< std::endl;
186191
}
187192

188193
ic.set_Ny(params["Ny"]);
@@ -191,7 +196,8 @@ void from_json(const json &params, SeedGridFCC &ic) {
191196
ic.set_radius(params["radius"]);
192197
ic.set_amplitude(params["amplitude"]);
193198
ic.set_rho(params["rho"]);
194-
if (params.contains("rseed") && params["rseed"].is_number()) ic.set_rseed(params["rseed"]);
199+
if (params.contains("rseed") && params["rseed"].is_number())
200+
ic.set_rseed(params["rseed"]);
195201
}
196202

197203
#endif // SEEDGRIDFCC_HPP

0 commit comments

Comments
 (0)