Skip to content

Commit aa5ccf7

Browse files
authored
PEC_Insulator cleanup (BLAST-WarpX#6426)
This cleans up the variable names used in the PEC_Insulator class to increase clarity and readability. It also adds accessors allowing checks of whether there are E or B fields being set by the boundary condition.
1 parent cb6c1fd commit aa5ccf7

File tree

2 files changed

+195
-112
lines changed

2 files changed

+195
-112
lines changed

Source/BoundaryConditions/PEC_Insulator.H

Lines changed: 84 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,18 @@ public:
8484
* \param[in] time current time of the simulation
8585
* \param[in] split_pml_field whether pml the multifab is the regular Efield or split pml field
8686
* \param[in] E_like whether the field is E like or B like
87-
* \param[in] set_fields_x_lo the flags for the field along x at the lower boundary
88-
* \param[in] set_fields_y_lo the flags for the field along y at the lower boundary
89-
* \param[in] set_fields_z_lo the flags for the field along z at the lower boundary
90-
* \param[in] set_fields_x_hi the flags for the field along x at the upper boundary
91-
* \param[in] set_fields_y_hi the flags for the field along y at the upper boundary
92-
* \param[in] set_fields_z_hi the flags for the field along z at the upper boundary
93-
* \param[in] Fx_parsers_lo the parsers for the field along x at the lower boundary
94-
* \param[in] Fy_parsers_lo the parsers for the field along y at the lower boundary
95-
* \param[in] Fz_parsers_lo the parsers for the field along z at the lower boundary
96-
* \param[in] Fx_parsers_hi the parsers for the field along x at the upper boundary
97-
* \param[in] Fy_parsers_hi the parsers for the field along y at the upper boundary
98-
* \param[in] Fz_parsers_hi the parsers for the field along z at the upper boundary
87+
* \param[in] set_Fx_lo the flags for the x-field at the lower boundaries
88+
* \param[in] set_Fy_lo the flags for the y-field at the lower boundaries
89+
* \param[in] set_Fz_lo the flags for the z-field at the lower boundaries
90+
* \param[in] set_Fx_hi the flags for the x-field at the upper boundaries
91+
* \param[in] set_Fy_hi the flags for the y-field at the upper boundaries
92+
* \param[in] set_Fz_hi the flags for the z-field at the upper boundaries
93+
* \param[in] Fx_parsers_lo the parsers for the x-field at the lower boundaries
94+
* \param[in] Fy_parsers_lo the parsers for the y-field at the lower boundaries
95+
* \param[in] Fz_parsers_lo the parsers for the z-field at the lower boundaries
96+
* \param[in] Fx_parsers_hi the parsers for the x-field at the upper boundaries
97+
* \param[in] Fy_parsers_hi the parsers for the y-field at the upper boundaries
98+
* \param[in] Fz_parsers_hi the parsers for the z-field at the upper boundaries
9999
*/
100100
void
101101
ApplyPEC_InsulatortoField (std::array<amrex::MultiFab*, 3> field,
@@ -109,19 +109,49 @@ public:
109109
amrex::Real time,
110110
bool split_pml_field,
111111
bool E_like,
112-
amrex::Vector<int> const & set_fields_x_lo,
113-
amrex::Vector<int> const & set_fields_y_lo,
114-
amrex::Vector<int> const & set_fields_z_lo,
115-
amrex::Vector<int> const & set_fields_x_hi,
116-
amrex::Vector<int> const & set_fields_y_hi,
117-
amrex::Vector<int> const & set_fields_z_hi,
112+
amrex::Vector<int> const & set_Fx_lo,
113+
amrex::Vector<int> const & set_Fy_lo,
114+
amrex::Vector<int> const & set_Fz_lo,
115+
amrex::Vector<int> const & set_Fx_hi,
116+
amrex::Vector<int> const & set_Fy_hi,
117+
amrex::Vector<int> const & set_Fz_hi,
118118
amrex::Vector<amrex::ParserExecutor<3>> const & Fx_parsers_lo,
119119
amrex::Vector<amrex::ParserExecutor<3>> const & Fy_parsers_lo,
120120
amrex::Vector<amrex::ParserExecutor<3>> const & Fz_parsers_lo,
121121
amrex::Vector<amrex::ParserExecutor<3>> const & Fx_parsers_hi,
122122
amrex::Vector<amrex::ParserExecutor<3>> const & Fy_parsers_hi,
123123
amrex::Vector<amrex::ParserExecutor<3>> const & Fz_parsers_hi);
124124

125+
/* \brief Returns whether any E field is set on a boundary
126+
* \param[in] idim dimension to check
127+
* \param[in] iside side to check, 0 is lower, 1 is upper
128+
* \return whether the E field is set on the boundary
129+
*/
130+
int IsESet(int idim, int iside) const { return ( iside == 1 ? m_set_E_hi[idim] : m_set_E_lo[idim] ); }
131+
132+
/* \brief Returns whether any B field is set on a boundary
133+
* \param[in] idim dimension to check
134+
* \param[in] iside side to check, 0 is lower, 1 is upper
135+
* \return whether the B field is set on the boundary
136+
*/
137+
int IsBSet(int idim, int iside) const { return ( iside == 1 ? m_set_B_hi[idim] : m_set_B_lo[idim] ); }
138+
139+
/* \brief Returns whether the E field is set on a boundary
140+
* \param[in] idim dimension to check
141+
* \param[in] iside side to check, 0 is lower, 1 is upper
142+
* \param[in] ifield which field to check, 0, 1, or 2
143+
* \return whether the E field is set on the boundary
144+
*/
145+
int IsESet(int idim, int iside, int ifield) const;
146+
147+
/* \brief Returns whether the B field is set on a boundary
148+
* \param[in] idim dimension to check
149+
* \param[in] iside side to check, 0 is lower, 1 is upper
150+
* \param[in] ifield which field to check, 0, 1, or 2
151+
* \return whether the B field is set on the boundary
152+
*/
153+
int IsBSet(int idim, int iside, int ifield) const;
154+
125155
private:
126156

127157
/* \brief Read in the parsers for the tangential fields, returning whether
@@ -139,49 +169,64 @@ private:
139169
std::string const & coord1,
140170
std::string const & coord2);
141171

172+
// Parsers specifying the region of each boundary that is insulator
142173
amrex::Vector<std::unique_ptr<amrex::Parser>> m_insulator_area_lo;
143174
amrex::Vector<std::unique_ptr<amrex::Parser>> m_insulator_area_hi;
144175

145176
amrex::Vector<amrex::ParserExecutor<2>> m_area_parsers_lo;
146177
amrex::Vector<amrex::ParserExecutor<2>> m_area_parsers_hi;
147178

179+
// Flags whether any B fields are specified on each boundary
148180
amrex::Vector<int> m_set_B_lo = {0, 0, 0};
149181
amrex::Vector<int> m_set_B_hi = {0, 0, 0};
150182

183+
// Parsers for the two B fields tangential to each boundary
151184
amrex::Vector<std::unique_ptr<amrex::Parser>> m_parsers_B1_lo;
152185
amrex::Vector<std::unique_ptr<amrex::Parser>> m_parsers_B2_lo;
153186
amrex::Vector<std::unique_ptr<amrex::Parser>> m_parsers_B1_hi;
154187
amrex::Vector<std::unique_ptr<amrex::Parser>> m_parsers_B2_hi;
155188

189+
// Flags whether any E fields are specified on each boundary
156190
amrex::Vector<int> m_set_E_lo = {0, 0, 0};
157191
amrex::Vector<int> m_set_E_hi = {0, 0, 0};
158192

193+
// Parsers for the two B fields tangential to each boundary
159194
amrex::Vector<std::unique_ptr<amrex::Parser>> m_parsers_E1_lo;
160195
amrex::Vector<std::unique_ptr<amrex::Parser>> m_parsers_E2_lo;
161196
amrex::Vector<std::unique_ptr<amrex::Parser>> m_parsers_E1_hi;
162197
amrex::Vector<std::unique_ptr<amrex::Parser>> m_parsers_E2_hi;
163198

164-
amrex::Vector<int> m_set_Bfields_x_lo;
165-
amrex::Vector<int> m_set_Bfields_y_lo;
166-
amrex::Vector<int> m_set_Bfields_z_lo;
167-
168-
amrex::Vector<int> m_set_Bfields_x_hi;
169-
amrex::Vector<int> m_set_Bfields_y_hi;
170-
amrex::Vector<int> m_set_Bfields_z_hi;
171-
172-
amrex::Vector<amrex::ParserExecutor<3>> m_Bx_parsers_lo, m_By_parsers_lo, m_Bz_parsers_lo;
173-
amrex::Vector<amrex::ParserExecutor<3>> m_Bx_parsers_hi, m_By_parsers_hi, m_Bz_parsers_hi;
174-
175-
amrex::Vector<int> m_set_Efields_x_lo;
176-
amrex::Vector<int> m_set_Efields_y_lo;
177-
amrex::Vector<int> m_set_Efields_z_lo;
178-
179-
amrex::Vector<int> m_set_Efields_x_hi;
180-
amrex::Vector<int> m_set_Efields_y_hi;
181-
amrex::Vector<int> m_set_Efields_z_hi;
182-
183-
amrex::Vector<amrex::ParserExecutor<3>> m_Ex_parsers_lo, m_Ey_parsers_lo, m_Ez_parsers_lo;
184-
amrex::Vector<amrex::ParserExecutor<3>> m_Ex_parsers_hi, m_Ey_parsers_hi, m_Ez_parsers_hi;
199+
// For each B field, the flags specifying whether it is set on each boundary
200+
amrex::Vector<int> m_set_Bx_lo;
201+
amrex::Vector<int> m_set_By_lo;
202+
amrex::Vector<int> m_set_Bz_lo;
203+
amrex::Vector<int> m_set_Bx_hi;
204+
amrex::Vector<int> m_set_By_hi;
205+
amrex::Vector<int> m_set_Bz_hi;
206+
207+
// For each B field, the parsers for the field value on each boundary
208+
amrex::Vector<amrex::ParserExecutor<3>> m_Bx_parsers_lo;
209+
amrex::Vector<amrex::ParserExecutor<3>> m_By_parsers_lo;
210+
amrex::Vector<amrex::ParserExecutor<3>> m_Bz_parsers_lo;
211+
amrex::Vector<amrex::ParserExecutor<3>> m_Bx_parsers_hi;
212+
amrex::Vector<amrex::ParserExecutor<3>> m_By_parsers_hi;
213+
amrex::Vector<amrex::ParserExecutor<3>> m_Bz_parsers_hi;
214+
215+
// For each E field, the flags specifying whether it is set on each boundary
216+
amrex::Vector<int> m_set_Ex_lo;
217+
amrex::Vector<int> m_set_Ey_lo;
218+
amrex::Vector<int> m_set_Ez_lo;
219+
amrex::Vector<int> m_set_Ex_hi;
220+
amrex::Vector<int> m_set_Ey_hi;
221+
amrex::Vector<int> m_set_Ez_hi;
222+
223+
// For each E field, the parsers for the field value on each boundary
224+
amrex::Vector<amrex::ParserExecutor<3>> m_Ex_parsers_lo;
225+
amrex::Vector<amrex::ParserExecutor<3>> m_Ey_parsers_lo;
226+
amrex::Vector<amrex::ParserExecutor<3>> m_Ez_parsers_lo;
227+
amrex::Vector<amrex::ParserExecutor<3>> m_Ex_parsers_hi;
228+
amrex::Vector<amrex::ParserExecutor<3>> m_Ey_parsers_hi;
229+
amrex::Vector<amrex::ParserExecutor<3>> m_Ez_parsers_hi;
185230

186231
};
187232
#endif // PEC_INSULATOR_H_

0 commit comments

Comments
 (0)