@@ -15,7 +15,8 @@ using json = nlohmann::json;
1515using 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 */
2122class SeedGridFCC : public FieldModifier {
@@ -29,15 +30,10 @@ class SeedGridFCC : public FieldModifier {
2930public:
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 */
162160void from_json (const json ¶ms, 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 ¶ms, 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