00001 #ifdef CH_LANG_CC 00002 /* 00003 * _______ __ 00004 * / ___/ / ___ __ _ / / ___ 00005 * / /__/ _ \/ _ \/ V \/ _ \/ _ \ 00006 * \___/_//_/\___/_/_/_/_.__/\___/ 00007 * Please refer to Copyright.txt, in Chombo's root directory. 00008 */ 00009 #endif 00010 00011 // NodeBC.H 00012 // adapted from GhostBC by DTGraves, Mon, July 19, 1999 00013 // petermc, 13 Feb 2001 00014 // petermc, 21 Oct 2002, removed m_inhomogeneous, which can be in 00015 // derived class of FaceNodeBC. 00016 00017 #ifndef _NODEBC_H_ 00018 #define _NODEBC_H_ 00019 00020 #include "ProblemDomain.H" 00021 #include "NodeFArrayBox.H" 00022 #include "REAL.H" 00023 #include "SPACE.H" 00024 #include "Tuple.H" 00025 #include "Interval.H" 00026 #include "Vector.H" 00027 #include "LoHiSide.H" 00028 #include "NamespaceHeader.H" 00029 00030 /// A class to encapsulate the operations of boundary conditions on a face 00031 /** FaceNodeBC is a class to encapsulate the 00032 operations of boundary conditions at a face. 00033 00034 If the solution is phi and the face normal direction is x, 00035 the boundary conditions usually used can be expressed as<br> 00036 A*dphi/dx + B*phi = C.<br> 00037 The derived class provides a function to fill A and B and C. 00038 00039 These functions are meant to be called by DomainNodeBC only. 00040 */ 00041 class FaceNodeBC 00042 { 00043 public: 00044 friend class DomainNodeBC; 00045 00046 /** 00047 \name Constructors, destructor and defines 00048 */ 00049 /*@{*/ 00050 00051 /// 00052 /** Default constructor, sets interval to (-1:-1). 00053 */ 00054 FaceNodeBC() 00055 :m_components(-1,-1) 00056 { 00057 } 00058 00059 /// 00060 /** Constructor for face on side <i>a_sd</i> in direction <i>a_idir</i>. 00061 This constructor sets the components interval to be (0:0). 00062 */ 00063 FaceNodeBC(int a_dir, Side::LoHiSide a_sd); 00064 00065 /// 00066 /** Constructor for face on side <i>a_sd</i> in direction <i>a_idir</i>, 00067 for data components <i>a_comps</i>. 00068 */ 00069 FaceNodeBC(int a_dir, Side::LoHiSide a_sd, const Interval& a_comps); 00070 00071 /// 00072 /** Destructor. 00073 */ 00074 virtual ~FaceNodeBC() 00075 { 00076 } 00077 00078 protected: 00079 00080 /// 00081 /** Virtual constructor workaround. 00082 Need this in derived class. 00083 */ 00084 virtual FaceNodeBC* new_boxBC() const = 0; 00085 00086 /// 00087 /** Defines face on side <i>a_sd</i> in direction <i>a_idir</i>. 00088 Sets the components interval to be (0:0). 00089 */ 00090 void 00091 define(int a_dir, Side::LoHiSide a_sd); 00092 00093 /// 00094 /** Defines face on side <i>a_sd</i> in direction <i>a_idir</i>, 00095 for data components <i>a_comps</i>. 00096 */ 00097 void 00098 define(int a_dir, Side::LoHiSide a_sd, const Interval& a_comps); 00099 00100 /*@}*/ 00101 00102 /** 00103 \name Functions to apply boundary conditions 00104 */ 00105 /*@{*/ 00106 00107 /// 00108 /** Apply inhomogeneous boundary conditions on this face. 00109 */ 00110 virtual void 00111 applyInhomogeneousBCs(/// NODE-centered data to be modified by boundary condition 00112 FArrayBox& a_state, 00113 /// CELL-centered physical domain 00114 const ProblemDomain& a_domain, 00115 /// mesh spacing 00116 Real a_dx) const; 00117 00118 /// 00119 /** Apply inhomogeneous boundary conditions on this face. 00120 */ 00121 virtual void 00122 applyInhomogeneousBCs(/// NODE-centered data to be modified by boundary condition 00123 FArrayBox& a_state, 00124 /// CELL-centered physical domain 00125 const Box& a_domain, 00126 /// mesh spacing 00127 Real a_dx) const; 00128 00129 /// 00130 /** Apply homogeneous boundary conditions on this face. 00131 */ 00132 virtual void 00133 applyHomogeneousBCs(/// NODE-centered data to be modified by boundary condition 00134 FArrayBox& a_state, 00135 /// CELL-centered physical domain 00136 const ProblemDomain& domain, 00137 /// mesh spacing 00138 Real a_dx) const; 00139 /// 00140 /** Apply homogeneous boundary conditions on this face. 00141 */ 00142 virtual void 00143 applyHomogeneousBCs(/// NODE-centered data to be modified by boundary condition 00144 FArrayBox& a_state, 00145 /// CELL-centered physical domain 00146 const Box& domain, 00147 /// mesh spacing 00148 Real a_dx) const; 00149 /// 00150 /** Apply boundary conditions on this face. 00151 */ 00152 virtual void 00153 applyEitherBCs(/// NODE-centered data to be modified by boundary condition 00154 FArrayBox& a_state, 00155 /// CELL-centered physical domain 00156 const ProblemDomain& domain, 00157 /// mesh spacing 00158 Real a_dx, 00159 /// flag for homogeneous boundary condition 00160 bool a_homogeneous) const; 00161 00162 /// 00163 /** Apply boundary conditions on this face. 00164 */ 00165 virtual void 00166 applyEitherBCs(/// NODE-centered data to be modified by boundary condition 00167 FArrayBox& a_state, 00168 /// CELL-centered physical domain 00169 const Box& domain, 00170 /// mesh spacing 00171 Real a_dx, 00172 /// flag for homogeneous boundary condition 00173 bool a_homogeneous) const; 00174 00175 /// 00176 /** Apply boundary condition A*dphi/dx + B*phi = C, with 00177 the coefficients having been set in fillBCValues(). 00178 */ 00179 virtual void 00180 applyBCs(/// NODEs on this boundary face 00181 const Box& a_bcbox, 00182 /// NODE-centered data to be modified by boundary condition 00183 FArrayBox& a_state, 00184 /// coefficients of dphi/dx 00185 const FArrayBox& a_neumfac, 00186 /// coefficients of phi 00187 const FArrayBox& a_dircfac, 00188 /// constant coefficients 00189 const FArrayBox& a_inhmval, 00190 /// mesh spacing 00191 Real a_dx) const; 00192 00193 /*@}*/ 00194 00195 /** 00196 \name Functions to fill in boundary-condition coefficients 00197 */ 00198 /*@{*/ 00199 00200 /// 00201 /** Set A and B and C in the boundary condition 00202 A*dphi/dx + B*phi = C.<br> 00203 The FArrayBoxes are all based on the NODEs of this face. 00204 00205 Need this function in derived class. 00206 */ 00207 virtual void 00208 fillBCValues(/// coefficients of dphi/dx 00209 FArrayBox& a_neumfac, 00210 /// coefficients of phi 00211 FArrayBox& a_dircfac, 00212 /// constant coefficients 00213 FArrayBox& a_inhmval, 00214 /// mesh spacing 00215 Real a_dx, 00216 /// CELL-centered physical domain 00217 const ProblemDomain& domain) const = 0; 00218 00219 /// 00220 /** Set A and B and C in the boundary condition 00221 A*dphi/dx + B*phi = C.<br> 00222 The FArrayBoxes are all based on the NODEs of this face. 00223 00224 Need this function in derived class. 00225 */ 00226 virtual void 00227 fillBCValues(/// coefficients of dphi/dx 00228 FArrayBox& a_neumfac, 00229 /// coefficients of phi 00230 FArrayBox& a_dircfac, 00231 /// constant coefficients 00232 FArrayBox& a_inhmval, 00233 /// mesh spacing 00234 Real a_dx, 00235 /// CELL-centered physical domain 00236 const Box& domain) const = 0; 00237 00238 /*@}*/ 00239 00240 /** low or high face 00241 */ 00242 Side::LoHiSide m_side; 00243 00244 /** dimension of face 00245 */ 00246 int m_direction; 00247 00248 /** components of data 00249 */ 00250 Interval m_components; 00251 00252 private: 00253 FaceNodeBC(const FaceNodeBC&) 00254 :m_components(-1,-1) 00255 { 00256 } 00257 00258 virtual void operator=(const FaceNodeBC&) 00259 { 00260 } 00261 }; 00262 00263 00264 /// Class to enforce boundary conditions 00265 /** This class holds a domain's worth of FaceNodeBCs, 00266 one for each face of the physical domain. 00267 The user adds a FaceNodeBC-derived class 00268 for each face to enforce boundary conditions. 00269 00270 If the solution is phi and the face normal direction is x, 00271 the boundary conditions at a face are expressed as<br> 00272 A*dphi/dx + B*phi = C. 00273 00274 The class derived from FaceNodeBC provides a function to 00275 to fill A and B and C. DomainNodeBC calls this function 00276 and fills the boundary nodes appropriately. 00277 */ 00278 class DomainNodeBC 00279 { 00280 public: 00281 00282 /** 00283 \name Constructors, destructor and defines 00284 */ 00285 /*@{*/ 00286 00287 /// 00288 /** Empty constructor. Need to assign boundary conditions for each face 00289 with calls to setFaceNodeBC(). 00290 */ 00291 DomainNodeBC(); 00292 00293 /// 00294 /** Destructor. 00295 */ 00296 ~DomainNodeBC(); 00297 00298 /// 00299 /** Assignment, copies input. 00300 */ 00301 DomainNodeBC& operator=(const DomainNodeBC&); 00302 00303 /// 00304 /** Copy constructor. 00305 */ 00306 DomainNodeBC(const DomainNodeBC&); 00307 00308 /*@}*/ 00309 00310 /** 00311 \name Access functions 00312 */ 00313 /*@{*/ 00314 00315 /// 00316 /** 00317 Retrieve FaceNodeBC for a particular face. 00318 */ 00319 const FaceNodeBC& 00320 operator() (int direction, Side::LoHiSide side) const; 00321 00322 /*@}*/ 00323 00324 /** 00325 \name Setting functions 00326 */ 00327 /*@{*/ 00328 00329 /// 00330 /** Set boundary condition object at a face. 00331 */ 00332 void 00333 setFaceNodeBC(const FaceNodeBC& a_bc); 00334 00335 /*@}*/ 00336 00337 /** 00338 \name Functions to apply boundary conditions 00339 */ 00340 /*@{*/ 00341 00342 /// 00343 /** Apply homogeneous boundary conditions on all faces of physical domain. 00344 */ 00345 void 00346 applyHomogeneousBCs(/// array on which boundary conditions will be applied 00347 NodeFArrayBox& a_state, 00348 /// CELL-centered physical domain 00349 const ProblemDomain& a_domain, 00350 /// mesh spacing 00351 Real a_dx) const; 00352 00353 /// 00354 /** Apply homogeneous boundary conditions on all faces of physical domain. 00355 */ 00356 void 00357 applyHomogeneousBCs(/// array on which boundary conditions will be applied 00358 NodeFArrayBox& a_state, 00359 /// CELL-centered physical domain 00360 const Box& a_domain, 00361 /// mesh spacing 00362 Real a_dx) const; 00363 00364 /// 00365 /** Apply inhomogeneous boundary conditions on all faces of physical domain. 00366 */ 00367 void 00368 applyInhomogeneousBCs(/// array on which boundary conditions will be applied 00369 NodeFArrayBox& a_state, 00370 /// CELL-centered physical domain 00371 const ProblemDomain& a_domain, 00372 /// mesh spacing 00373 Real a_dx) const; 00374 00375 /// 00376 /** Apply inhomogeneous boundary conditions on all faces of physical domain. 00377 */ 00378 void 00379 applyInhomogeneousBCs(/// array on which boundary conditions will be applied 00380 NodeFArrayBox& a_state, 00381 /// CELL-centered physical domain 00382 const Box& a_domain, 00383 /// mesh spacing 00384 Real a_dx) const; 00385 00386 /*@}*/ 00387 00388 protected: 00389 00390 /** Return <tt>true</tt> if the FaceNodeBC for the specified face 00391 is defined. 00392 */ 00393 bool isBCDefined(int a_dir, const Side::LoHiSide a_side) const; 00394 00395 /** Reset the FaceNodeBC for the specified face to NULL. 00396 */ 00397 void resetFaceNodeBC(const int a_dir, const Side::LoHiSide a_side); 00398 00399 Tuple<FaceNodeBC*, SpaceDim> m_loBC; 00400 Tuple<FaceNodeBC*, SpaceDim> m_hiBC; 00401 00402 private: 00403 }; 00404 00405 #include "NamespaceFooter.H" 00406 00407 #endif