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 // NodeFArrayBox.H 00012 // adapted from dMartin/Chombo-IAMR/util/FluxBox.H 00013 // by Dan Martin, Fri, Jan 14, 2000 00014 // petermc, 1 Nov 2000 00015 // 8 Jan 2001 added 00016 00017 #ifndef _NODEFARRAYBOX_H_ 00018 #define _NODEFARRAYBOX_H_ 00019 00020 #include "FArrayBox.H" 00021 #include "NamespaceHeader.H" 00022 00023 /// A wrapper for an FArrayBox to contain NODE-centered data. 00024 /** This is a class to contain NODE-centered data on a box.<br> 00025 <b>Question</b>: Why not just use NODE-centered FArrayBox?<br> 00026 <b>Answer</b>: We want to use LevelData<NodeFArrayBox>, 00027 which requires that the underlying BoxLayout be a DisjointBoxLayout. 00028 Adjacent NODE-centered boxes intersect, but adjacent CELL-centered 00029 boxes do not.<br> 00030 The underlying DisjointBoxLayout will be CELL-centered. 00031 00032 In a LevelData<NodeFArrayBox>, some of the grids may share nodes. 00033 The data on shared nodes must be the same. 00034 00035 Example: A four-grid layout is shown on the left. As shown on 00036 the right, the nodes marked "2" are shared by two grids, and 00037 those marked "3" are shared by three grids. 00038 <pre> 00039 : : : 00040 : +-----+ : YYYY--+ : 00041 : | | : | | : 00042 : | A | : | A | : 00043 : | | : | | : 00044 : +---+--+--+---+ : +---2223222---+ : 00045 : | | | : | 2 | : 00046 : | B | C | : | B 2 C | : 00047 : | | | : | 2 | : 00048 : +---+------+------+ : X---22222223------X : 00049 : | | : | | : 00050 : | D | : | D | : 00051 : | | : | | : 00052 : +----------+ : +-------YYYY : 00053 : : : 00054 </pre> 00055 Additional nodes may be shared if the boxes extend to the faces 00056 of a domain that is periodic in one or more directions. 00057 In the example above, these nodes are marked "X" and "Y".<br> 00058 Horizontally periodic domain: node "X" shared by two grids, C and D.<br> 00059 Vertically periodic domain: nodes "Y" shared by two grids, A and D. 00060 00061 <b>Using copyTo:</b> 00062 00063 One of the most useful features of LevelData<NodeFArrayBox> is the 00064 copyTo() function. THE copyTo() FUNCTION MUST BE USED WITH CAUTION 00065 if the source and destination have different layouts. 00066 00067 Consider an example where A and B are on layouts of one box 00068 each, and these two boxes abut: 00069 <pre> 00070 +-------+ 00071 | | 00072 | A | 00073 | | 00074 ========= 00075 | | 00076 | B | 00077 | | 00078 +-------+ 00079 </pre> 00080 If we do A.copyTo(B), then the data on the nodes of the interface 00081 (marked "=") are NOT copied, because the underlying CELL-centered 00082 DisjointBoxLayouts of the LevelDatas do not intersect. 00083 00084 In general, doing <tt>src.copyTo(dest)</tt>: 00085 if LevelData<NodeFArrayBox> <tt>src</tt> and 00086 LevelData<NodeFArrayBox> <tt>dest</tt> 00087 do NOT have identical underlying boxes in their layouts, 00088 then <tt>src.copyTo(dest)</tt> will NOT copy the interface nodes. 00089 00090 Here are two different ways to make sure the interface nodes are copied: 00091 00092 1. Do copyTo to a BoxLayoutData<NodeFArrayBox> defined on 00093 the BoxLayout of <tt>dest</tt> with each box expanded 00094 by 1 in each dimension. 00095 That is: 00096 <pre> 00097 BoxLayout destExpandedLayout; 00098 destExpandedLayout.deepCopy(dest.disjointBoxLayout()); 00099 destExpandedLayout.grow(1); 00100 destExpandedLayout.closeNoSort(); 00101 src.copyTo(destExpanded); 00102 for (DataIterator dit = dest.dataIterator(); dit.ok(); ++dit) 00103 { 00104 dest[dit].copy(destExpanded[dit]); 00105 } 00106 </pre> 00107 00108 2. Define <tt>src</tt> with ghost vector IntVect::Unit, and in copyTo, 00109 use a Copier with ghost vector IntVect::Unit. 00110 That is: 00111 <pre> 00112 Copier myCopier; 00113 myCopier.ghostDefine(src.disjointBoxLayout(), 00114 dest.disjointBoxLayout(), 00115 src.disjointBoxLayout().physDomain(), 00116 IntVect::Unit); 00117 src.copyTo(dest, myCopier); 00118 </pre> 00119 For this to work, <tt>src</tt> must have been defined with ghost vector 00120 IntVect::Unit (at least). 00121 */ 00122 class NodeFArrayBox 00123 { 00124 00125 public: 00126 00127 /** 00128 \name Constructors, destructor and defines 00129 */ 00130 /*@{*/ 00131 00132 /// 00133 /** Default constructor. User must subsequently call define(). 00134 */ 00135 NodeFArrayBox(); 00136 00137 /// 00138 /** Constructs NodeFArrayBox on CELL-centered box <i>a_bx</i> 00139 with <i>a_nComp</i>. If a_alias is not null this oject does not delete it in the destructor. 00140 */ 00141 NodeFArrayBox(const Box& a_bx, int a_nComp, Real* a_alias = NULL); 00142 00143 /// 00144 /**Constructs NodeFArrayBox on CELL-centered box <i>a_bx</i> for just a scalar. 00145 */ 00146 NodeFArrayBox(const Box& a_bx) {define(a_bx,1);} 00147 /// 00148 /** Constructs an aliased NodeFArrayBox. 00149 */ 00150 NodeFArrayBox(const Interval& a_comps, NodeFArrayBox& a_original); 00151 00152 NodeFArrayBox(NodeFArrayBox&& a_in)=default; 00153 NodeFArrayBox& operator=(NodeFArrayBox&& a_in)=default; 00154 /// 00155 /** Destructor. 00156 */ 00157 ~NodeFArrayBox(); 00158 00159 /// 00160 /** Defines NodeFArrayBox on CELL-centered box <i>a_bx</i> 00161 with <i>a_nComp</i> components. If called more than once 00162 on the same instance, the box and FAB will be resize()d. 00163 */ 00164 void define(const Box& a_bx, int a_nComp=1); 00165 00166 /// 00167 /** alias Defines NodeFArrayBox on CELL-centered box <i>a_bx</i> 00168 with <i>a_nComp</i> components. If called more than once 00169 on the same instance, the box and FAB will be resize()d. 00170 Class is not responsible for data pointed to by a_dataPtr 00171 */ 00172 void define(const Box& a_bx, int a_nComp, Real* a_dataPtr); 00173 /** 00174 Change this NodeFArrayBox so it covers the Box a_bx with a_nComps 00175 components. If a_alias is not NULL, it is used as the data memory 00176 (and is assumed to be large enough). 00177 */ 00178 /* 00179 void resize(const Box& a_bx, int a_nComp=1, Real* a_alias=NULL); 00180 */ 00181 /*@}*/ 00182 00183 /** 00184 \name Accessors 00185 */ 00186 /*@{*/ 00187 00188 /// 00189 /** Returns the CELL-centered domain where the array is defined. 00190 */ 00191 const Box& box() const; 00192 00193 /// 00194 /** Returns a modifiable reference to the NODE-centered FArrayBox 00195 containing the data. 00196 */ 00197 FArrayBox& getFab(); 00198 00199 /// 00200 /** Returns a constant reference to the NODE-centered FArrayBox 00201 containing the data. 00202 */ 00203 const FArrayBox& getFab() const; 00204 00205 Real dotProduct(const NodeFArrayBox& a_fab2) const 00206 { 00207 return m_fab.dotProduct(a_fab2.m_fab); 00208 } 00209 00210 Real dotProduct(const NodeFArrayBox& a_fab2, const Box& box) const 00211 { 00212 return m_fab.dotProduct(a_fab2.m_fab, box); 00213 } 00214 00215 /*@}*/ 00216 00217 /** 00218 \name Data modification functions 00219 */ 00220 /*@{*/ 00221 00222 /// 00223 /** Modifies the data in this NodeFArrayBox by copying data 00224 from <i>a_src</i> into it, over the nodes that they have in common.<br> 00225 If this NodeFArrayBox and <i>a_src</i> have abutting grids, 00226 as shown: 00227 <pre> 00228 +--------+ 00229 | | 00230 | this | 00231 | | 00232 ========== <- data copied here from a_src to this 00233 | | 00234 | a_src | 00235 | | 00236 +--------+ 00237 </pre> 00238 then the data in this NodeFArrayBox WILL be modified along the 00239 edge nodes where they abut -- even though this.box() and 00240 <i>a_src</i>.box(), being CELL-centered, do NOT intersect. 00241 00242 All components are copied. 00243 */ 00244 void copy(const NodeFArrayBox& a_src); 00245 00246 /// 00247 /** Modifies the data in this NodeFArrayBox by copying the data 00248 from <i>a_src</i> into it, over the intersection of: 00249 - the nodes surrounding the CELL-centered box <i>a_regionFrom</i>; 00250 - the nodes surrounding the CELL-centered box <i>a_regionTo</i>; 00251 - the nodes containing data in this NodeFArrayBox; 00252 - the nodes containing data in <i>a_src</i>. 00253 00254 The components in the interval <i>a_Csrc</i> in <i>a_src</i> 00255 are copied to the components in the interval <i>a_Cdest</i> 00256 in this NodeFArrayBox. 00257 00258 This function is required in order to have BoxLayoutData<NodeFArrayBox>. 00259 */ 00260 void copy(const Box& a_regionFrom, 00261 const Interval& a_Cdest, 00262 const Box& a_regionTo, 00263 const NodeFArrayBox& a_src, 00264 const Interval& a_Csrc); 00265 00266 /*@}*/ 00267 00268 /** 00269 \name Linearization functions 00270 */ 00271 /*@{*/ 00272 00273 /// 00274 /** Returns size, in number of bytes, of a flat linear 00275 representation of the data in this object in the area 00276 defined by the nodes in CELL-centered box <i>a_R</i> and the 00277 component Interval <i>a_comps</i>. 00278 00279 This function is required in order to have BoxLayoutData<NodeFArrayBox>. 00280 */ 00281 size_t size(const Box& a_R, const Interval& a_comps) const; 00282 00283 /// 00284 /** Writes into <i>a_buf</i> a linear representation of the internal data for 00285 the nodes surrounding CELL-centered box <i>a_R</i>, over the component 00286 Interval <i>a_comps</i>. 00287 00288 Assumes that sufficient 00289 memory for the buffer has already been allocated by the caller. 00290 00291 This function is required in order to have BoxLayoutData<NodeFArrayBox>. 00292 */ 00293 void linearOut(void* a_buf, const Box& a_R, const Interval& a_comps) const; 00294 00295 /// 00296 void linearIn(void* a_buf, const Box& a_R, const Interval& a_comps); 00297 00298 /// These functions are required for broadcast & gather. 00299 void linearOut(void* a_buf) const; 00300 /// 00301 void linearIn(const void* const a_buf); 00302 /// 00303 int linearSize(void) const; 00304 00305 /// 00306 static int preAllocatable() 00307 { 00308 return 0; 00309 } 00310 00311 /*@}*/ 00312 00313 /// 00314 /** 00315 Modifies this NodeFArrayBox so that all values of all components are set to 00316 the given value, a_x. (FArrayBox inherits such a function from BaseFab.) 00317 */ 00318 void setVal(Real a_x); 00319 00320 /** 00321 The setVal functions set subregions in the `BaseFab' to a constant value. 00322 This most general form specifies the subbox, the starting component 00323 number, and the number of components to be set. 00324 */ 00325 void setVal(Real a_x, 00326 const Box& a_bx, 00327 int a_nstart, 00328 int a_numcomp); 00329 00330 /// 00331 /** HERE 00332 Returns the Lp-norm of this FAB using components 00333 (a_comp : a_comp+a_numcomp-1) and within the a_subbox. 00334 a_p < 0 -> ERROR 00335 a_p = 0 -> infinity norm (max norm) 00336 a_p = 1 -> sum of ABS(FAB) 00337 a_p > 1 -> Lp-norm 00338 */ 00339 Real norm(const Box& a_subbox, 00340 int a_p = 2, 00341 int a_comp = 0, 00342 int a_numcomp = 1) const 00343 { 00344 return m_fab.norm(a_subbox, a_p, a_comp, a_numcomp); 00345 } 00346 00347 /// 00348 /** 00349 Returns the Lp-norm of this FAB using components 00350 (a_comp : a_comp+a_numcomp-1). 00351 a_p < 0 -> ERROR 00352 a_p = 0 -> infinity norm (max norm) 00353 a_p = 1 -> sum of ABS(FAB) 00354 a_p > 1 -> Lp-norm 00355 */ 00356 Real norm(int a_p = 2, 00357 int a_comp = 0, 00358 int a_numcomp = 1) const 00359 { 00360 return m_fab.norm(a_p, a_comp, a_numcomp); 00361 } 00362 00363 /// 00364 /** 00365 Returns sum of pow(fab[i,c],p): i in a_subbox, a_comp <= c < 00366 a_comp+a_numcomp, a_p >= 2 only 00367 */ 00368 Real sumPow(const Box& a_subbox, 00369 int a_p = 2, 00370 int a_comp = 0, 00371 int a_numcomp = 1) const 00372 00373 { 00374 return m_fab.sumPow(a_subbox, a_p, a_comp, a_numcomp); 00375 } 00376 00377 /// 00378 /** 00379 Returns the minimum value of given component of this NodeFArrayBox. 00380 */ 00381 Real min(int a_comp = 0) const 00382 { 00383 return m_fab.min(a_comp); 00384 } 00385 00386 /// 00387 /** 00388 Returns the minimum value of given component of this NodeFArrayBox in 00389 given a_subbox. 00390 00391 */ 00392 Real min(const Box& a_subbox, 00393 int a_comp = 0) const 00394 { 00395 return m_fab.min(a_subbox, a_comp); 00396 } 00397 00398 /// 00399 /** 00400 Returns the maximum value of given component of this NodeFArrayBox. 00401 */ 00402 Real max(int a_comp = 0) const 00403 { 00404 return m_fab.max(a_comp); 00405 } 00406 00407 /// 00408 /** 00409 Returns the maximum value of given component of this NodeFArrayBox in 00410 given a_subbox. 00411 00412 */ 00413 Real max(const Box& a_subbox, 00414 int a_comp = 0) const 00415 00416 { 00417 return m_fab.max(a_subbox, a_comp); 00418 } 00419 00420 /// 00421 /** 00422 Finds location of minimum value in given component of this NodeFArrayBox. 00423 */ 00424 IntVect minIndex(int a_comp = 0) const 00425 { 00426 return m_fab.minIndex(a_comp); 00427 } 00428 00429 /// 00430 /** 00431 Returns location of minimum value in given component of this NodeFArrayBox 00432 in given a_subbox. 00433 */ 00434 IntVect minIndex(const Box& a_subbox, 00435 int a_comp = 0) const 00436 { 00437 return m_fab.minIndex(a_subbox, a_comp); 00438 } 00439 00440 /// 00441 /** 00442 Returns location of maximum value in given component of this NodeFArrayBox. 00443 */ 00444 IntVect maxIndex(int a_comp = 0) const 00445 { 00446 return m_fab.maxIndex(a_comp); 00447 } 00448 00449 /// 00450 /** 00451 Returns location of maximum value in given component of this NodeFArrayBox 00452 in given a_subbox. 00453 */ 00454 IntVect maxIndex(const Box& a_subbox, 00455 int a_comp = 0) const 00456 { 00457 return m_fab.maxIndex(a_subbox, a_comp); 00458 } 00459 00460 /// 00461 /** 00462 Computes a_mask array with value of 1 in cells where this NodeFArrayBox 00463 has value less than a_val, 0 otherwise. a_mask is resized by this 00464 function. The number of cells marked with 1 returned. 00465 */ 00466 int maskLT(BaseFab<int>& a_mask, 00467 Real a_val, 00468 int a_comp = 0) const 00469 { 00470 return m_fab.maskLT(a_mask, a_val, a_comp); 00471 } 00472 00473 /// 00474 /** 00475 Computes a_mask array with value of 1 in cells where this NodeFArrayBox 00476 has value less than or equal to a_val, 0 otherwise. a_mask is 00477 resized by this function. The number of cells marked with 1 00478 returned. 00479 */ 00480 int maskLE(BaseFab<int>& a_mask, 00481 Real a_val, 00482 int a_comp = 0) const 00483 { 00484 return m_fab.maskLE(a_mask, a_val, a_comp); 00485 } 00486 00487 /// 00488 /** 00489 Computes a_mask array with value of 1 in cells where this NodeFArrayBox 00490 has value equal to a_val, 0 otherwise. a_mask is resized by this 00491 function. The number of cells marked with 1 returned. 00492 00493 */ 00494 int maskEQ(BaseFab<int>& a_mask, 00495 Real a_val, 00496 int a_comp = 0) const 00497 { 00498 return m_fab.maskEQ(a_mask, a_val, a_comp); 00499 } 00500 00501 /// 00502 /** 00503 Computes a_mask array with value of 1 in cells where this NodeFArrayBox 00504 has value greater than a_val, 0 otherwise. a_mask is resized by this 00505 function. The number of cells marked with 1 returned. 00506 */ 00507 int maskGT(BaseFab<int>& a_mask, 00508 Real a_val, 00509 int a_comp = 0) const 00510 { 00511 return m_fab.maskGT(a_mask, a_val, a_comp); 00512 } 00513 00514 /// 00515 /** 00516 Computes a_mask array with value of 1 in cells where this NodeFArrayBox 00517 has value greater than or equal to a_val, 0 otherwise. a_mask is 00518 resized by this function. The number of cells marked with 1 returned. 00519 */ 00520 int maskGE(BaseFab<int>& a_mask, 00521 Real a_val, 00522 int a_comp = 0) const 00523 { 00524 return m_fab.maskGE(a_mask, a_val, a_comp); 00525 } 00526 00527 /// 00528 /** 00529 Modifies this NodeFArrayBox by replacing each value with its absolute value. 00530 */ 00531 void abs() 00532 { 00533 m_fab.abs(); 00534 } 00535 00536 /// 00537 /** 00538 */ 00539 int nComp() const 00540 { 00541 return m_fab.nComp(); 00542 } 00543 00544 /// 00545 /** 00546 Modifies this NodeFArrayBox by replacing each value with its absolute value, 00547 for components (a_comp : a_comp+a_numcomp-1). 00548 */ 00549 void abs(int a_comp, 00550 int a_numcomp = 1) 00551 { 00552 m_fab.abs(a_comp, a_numcomp); 00553 } 00554 00555 /// 00556 /** 00557 Modifies this NodeFArrayBox by replacing eahc value with its absolute value, 00558 for components (a_comp : a_comp+a_numcomp-1) and within the a_subbox. 00559 */ 00560 void abs (const Box& a_subbox, 00561 int a_comp = 0, 00562 int a_numcomp = 1) 00563 { 00564 m_fab.abs(a_subbox, a_comp, a_numcomp); 00565 } 00566 00567 /// 00568 /** 00569 Returns sum of given component of NodeFArrayBox. 00570 */ 00571 Real sum(int a_comp, 00572 int a_numcomp = 1) const 00573 { 00574 return m_fab.sum(a_comp, a_numcomp); 00575 } 00576 00577 /// 00578 /** 00579 Returns sum of component of this NodeFArrayBox in given a_subbox. 00580 */ 00581 Real sum(const Box& a_subbox, 00582 int a_comp, 00583 int a_numcomp = 1) const 00584 { 00585 return m_fab.sum(a_subbox, a_comp, a_numcomp); 00586 } 00587 00588 /// 00589 /** 00590 Modifies this NodeFArrayBox by replacing each value x with a_r/x. 00591 */ 00592 NodeFArrayBox& invert(Real a_r) 00593 { 00594 m_fab.invert(a_r); 00595 return *this; 00596 } 00597 00598 /// 00599 /** 00600 Modifies this NodeFArrayBox by replacing each value x with a_r/x. For 00601 given range of components. 00602 */ 00603 NodeFArrayBox& invert(Real a_r, 00604 int a_comp, 00605 int a_numcomp = 1) 00606 { 00607 m_fab.invert(a_r, a_comp, a_numcomp); 00608 return *this; 00609 } 00610 00611 /// 00612 /** 00613 Modifies this NodeFArrayBox by replacing each value x with a_r/x. For 00614 given range of components and within given a_subbox. 00615 */ 00616 NodeFArrayBox& invert(Real a_r, 00617 const Box& a_subbox, 00618 int a_comp = 0, 00619 int a_numcomp = 1) 00620 { 00621 m_fab.invert(a_r, a_subbox, a_comp, a_numcomp); 00622 return *this; 00623 } 00624 00625 /// 00626 /** 00627 Modifies this NodeFArrayBox by replacing each value with its additive 00628 inverse. For given range of components and within given a_subbox. 00629 */ 00630 NodeFArrayBox& negate(const Box& a_subbox, 00631 int a_comp = 0, 00632 int a_numcomp = 1) 00633 { 00634 m_fab.negate(a_subbox, a_comp, a_numcomp); 00635 return *this; 00636 } 00637 00638 /// 00639 /** 00640 Modifies this NodeFArrayBox by replacing each value with its additive 00641 inverse. For given range of components. 00642 */ 00643 NodeFArrayBox& negate(int a_comp, 00644 int a_numcomp = 1) 00645 { 00646 m_fab.negate(a_comp, a_numcomp); 00647 return *this; 00648 } 00649 00650 /// 00651 /** 00652 Modifies this NodeFArrayBox by replacing each value with its additive 00653 inverse. 00654 */ 00655 NodeFArrayBox& negate() 00656 { 00657 m_fab.negate(); 00658 return *this; 00659 } 00660 00661 /// 00662 /** 00663 Modifies this NodeFArrayBox by adding the scalar Real a_r to all values. For 00664 given range of components and within given a_subbox. 00665 */ 00666 NodeFArrayBox& plus(Real a_r, 00667 const Box& a_subbox, 00668 int a_comp = 0, 00669 int a_numcomp = 1) 00670 { 00671 m_fab.plus(a_r, a_subbox, a_comp, a_numcomp); 00672 return *this; 00673 } 00674 00675 /// 00676 /** 00677 Modifies this NodeFArrayBox by adding the scalar Real a_r to all values. For 00678 given range of components. 00679 */ 00680 NodeFArrayBox& plus(Real a_r, 00681 int a_comp, 00682 int a_numcomp = 1) 00683 { 00684 m_fab.plus(a_r, a_comp, a_numcomp); 00685 return *this; 00686 } 00687 00688 /// 00689 Real& operator() (const IntVect& a_p, 00690 int N = 0) 00691 { 00692 return m_fab(a_p,N); 00693 } 00694 00695 /// 00696 const Real& operator() (const IntVect& a_p, 00697 int N = 0) const 00698 { 00699 return m_fab(a_p,N); 00700 } 00701 /// 00702 /** 00703 Modifies this NodeFArrayBox by adding the scalar Real a_r to all values. 00704 */ 00705 NodeFArrayBox& operator += (Real a_r) 00706 { 00707 m_fab += a_r; 00708 return *this; 00709 } 00710 00711 /// 00712 /** 00713 Modifies this NodeFArrayBox by pointwise addition of the values of the 00714 argument NodeFArrayBox. You might come to grief if the domains of the 00715 NodeFArrayBoxes don't match. 00716 */ 00717 NodeFArrayBox& operator += (const NodeFArrayBox& a_x) 00718 { 00719 m_fab += a_x.m_fab; 00720 return *this; 00721 } 00722 00723 /// 00724 /** 00725 Modifies this NodeFArrayBox by adding the scalar Real a_r to all values. 00726 */ 00727 NodeFArrayBox& plus(Real a_r) 00728 { 00729 m_fab += a_r; 00730 return *this; 00731 } 00732 00733 NodeFArrayBox& plus_real(Real a_r) 00734 { 00735 return this->plus(a_r); 00736 } 00737 00738 /// 00739 /** 00740 Modifies this NodeFArrayBox by pointwise addition of the values of the 00741 argument NodeFArrayBox. You might come to grief if the domains of the 00742 NodeFArrayBoxes don't match. The same as += operator. 00743 00744 */ 00745 NodeFArrayBox& plus(const NodeFArrayBox& a_x) 00746 { 00747 m_fab += a_x.m_fab; 00748 return *this; 00749 } 00750 00751 /// 00752 /** 00753 Modifies this NodeFArrayBox by pointwise scaled addition of the 00754 argument NodeFArrayBox (a[i] <- a[i] + a_scale * a_src[i]). Uses domain 00755 of the intersection of these two NodeFArrayBoxes. 00756 */ 00757 NodeFArrayBox& plus(const NodeFArrayBox& a_src, 00758 const Real& a_scale) 00759 { 00760 m_fab.plus(a_src.m_fab, a_scale); 00761 return *this; 00762 } 00763 00764 /// 00765 /** 00766 Modifies this NodeFArrayBox by pointwise scaled addition of the 00767 argument NodeFArrayBox (a[i] <- a[i] + a_scale * a_src[i]). Uses domain 00768 of the intersection of these two NodeFArrayBoxes. 00769 */ 00770 NodeFArrayBox& plus(const NodeFArrayBox& a_src, 00771 const Real& a_scale, 00772 int a_srccomp, 00773 int a_destcomp, 00774 int a_numcomp = 1) 00775 { 00776 m_fab.plus(a_src.m_fab, a_scale, a_srccomp, a_destcomp, a_numcomp); 00777 return *this; 00778 } 00779 00780 /// 00781 /** 00782 Modifies this NodeFArrayBox by pointwise addition of values in the argument 00783 NodeFArrayBox. Adds src's components (a_srccomp : a_srccomp+a_numcomp-1) 00784 to this NodeFArrayBox's components (a_destcomp : a_destcomp+a_numcomp-1) 00785 where the domains of the two NodeFArrayBoxes intersect. 00786 */ 00787 NodeFArrayBox& plus(const NodeFArrayBox& a_src, 00788 int a_srccomp, 00789 int a_destcomp, 00790 int a_numcomp = 1) 00791 { 00792 m_fab.plus(a_src.m_fab, a_srccomp, a_destcomp, a_numcomp); 00793 return *this; 00794 } 00795 00796 /// 00797 /** 00798 Modifies this NodeFArrayBox by pointwise addition of values in the argument 00799 NodeFArrayBox. Adds src's components (a_srccomp : a_srccomp+a_numcomp-1) 00800 to this NodeFArrayBox's components (a_destcomp : a_destcomp+numcomp-1) 00801 where the domain of this NodeFArrayBox intersects the a_subbox. NOTE: 00802 a_subbox must be contained in this FAB. 00803 */ 00804 NodeFArrayBox& plus(const NodeFArrayBox& a_src, 00805 const Box& a_subbox, 00806 int a_srccomp, 00807 int a_destcomp, 00808 int a_numcomp = 1) 00809 { 00810 m_fab.plus(a_src.m_fab, a_subbox, a_srccomp, a_destcomp, a_numcomp); 00811 return *this; 00812 } 00813 00814 /// 00815 /** 00816 Modifies this NodeFArrayBox by pointwise addition of values in the argument 00817 NodeFArrayBox. Adds src's components (a_srccomp : a_srccomp+a_numcomp-1) 00818 in the Box a_srcbox to this NodeFArrayBox's components (a_destcomp : 00819 a_destcomp+a_numcomp-1) in the Box a_destbox. Corresponding locations 00820 within the two NodeFArrayBoxes are indexed relative to a_srcbox and a_destbox, 00821 and will in general not be the same. The a_srcbox and a_destbox must be 00822 same size. The results are UNDEFINED if the a_src and dest NodeFArrayBoxes 00823 are the same and the a_srcbox and a_destbox overlap. 00824 00825 */ 00826 NodeFArrayBox& plus(const NodeFArrayBox& a_src, 00827 const Box& a_srcbox, 00828 const Box& a_destbox, 00829 int a_srccomp, 00830 int a_destcomp, 00831 int a_numcomp = 1) 00832 { 00833 m_fab.plus(a_src.m_fab, a_srcbox, a_destbox, a_srccomp, a_destcomp, a_numcomp); 00834 return *this; 00835 } 00836 00837 /// 00838 NodeFArrayBox& plus(const NodeFArrayBox& a_src, 00839 const Box& a_srcbox, 00840 const Box& a_destbox, 00841 const Real& a_scale, 00842 int a_srccomp, 00843 int a_destcomp, 00844 int a_numcomp = 1) 00845 { 00846 m_fab.plus(a_src.m_fab, a_srcbox, a_destbox, a_scale, a_srccomp, a_destcomp, a_numcomp); 00847 return *this; 00848 } 00849 00850 /// 00851 /** 00852 Modifies this NodeFArrayBox by subtracting the scalar Real a_r to all values. 00853 Note: use plus(-a_r) for more general operations. 00854 */ 00855 NodeFArrayBox& operator -= (Real a_r) 00856 { 00857 m_fab -= a_r; 00858 return *this; 00859 } 00860 00861 /// 00862 /** 00863 Modifies this NodeFArrayBox by pointwise subtraction of the values of the 00864 argument NodeFArrayBox. You might come to grief if the domains of the 00865 NodeFArrayBoxes don't match. 00866 */ 00867 NodeFArrayBox& operator -= (const NodeFArrayBox& a_x) 00868 { 00869 m_fab -= a_x.m_fab; 00870 return *this; 00871 } 00872 00873 /// 00874 /** 00875 Modifies this NodeFArrayBox by pointwise subtraction of the values of the 00876 argument NodeFArrayBox. You might come to grief if the domains of the 00877 NodeFArrayBoxes don't match. The same as -= operator. 00878 */ 00879 NodeFArrayBox& minus(const NodeFArrayBox& a_x) 00880 { 00881 m_fab -= a_x.m_fab; 00882 return *this; 00883 } 00884 00885 /** 00886 Modifies this NodeFArrayBox by pointwise subtraction of values in the 00887 argument NodeFArrayBox. Subtracts a_src's components (a_srccomp : 00888 a_srccomp+a_numcomp-1) from this NodeFArrayBox's components (a_destcomp : 00889 a_destcomp+a_numcomp-1) where the domains of the two NodeFArrayBoxes 00890 intersect. 00891 */ 00892 NodeFArrayBox& minus(const NodeFArrayBox& a_src, 00893 int a_srccomp, 00894 int a_destcomp, 00895 int a_numcomp = 1) 00896 { 00897 m_fab.minus(a_src.m_fab, a_srccomp, a_destcomp, a_numcomp); 00898 return *this; 00899 } 00900 00901 /** 00902 Modifies this NodeFArrayBox by pointwise subtraction of values in the 00903 argument NodeFArrayBox. Subtracts a_src's components (a_srccomp : 00904 a_srccomp+a_numcomp-1) from this NodeFArrayBox's components (a_destcomp : 00905 a_destcomp+a_numcomp-1) where the domain of this NodeFArrayBox intersects 00906 the a_subbox. NOTE: a_subbox must be contained in this FAB. 00907 */ 00908 NodeFArrayBox& minus(const NodeFArrayBox& a_src, 00909 const Box& a_subbox, 00910 int a_srccomp, 00911 int a_destcomp, 00912 int a_numcomp = 1) 00913 { 00914 m_fab.minus(a_src.m_fab, a_subbox, a_srccomp, a_destcomp, a_numcomp); 00915 return *this; 00916 } 00917 00918 /// 00919 /** 00920 Modifies this NodeFArrayBox by pointwise subtraction of values in the 00921 argument NodeFArrayBox. Subtracts a_src's components (a_srccomp : 00922 a_srccomp+a_numcomp-1) in the Box a_srcbox from this NodeFArrayBox's 00923 components (a_destcomp : a_destcomp+a_numcomp-1) in the Box a_destbox. 00924 Corresponding locations within the two NodeFArrayBoxes are indexed relative 00925 to a_srcbox and a_destbox, and will in general not be the same. The 00926 a_srcbox and a_destbox must be same size. The results are UNDEFINED 00927 if the a_src and dest NodeFArrayBoxes are the same and the a_srcbox and 00928 a_destbox overlap. 00929 */ 00930 NodeFArrayBox& minus(const NodeFArrayBox& a_src, 00931 const Box& a_srcbox, 00932 const Box& a_destbox, 00933 int a_srccomp, 00934 int a_destcomp, 00935 int a_numcomp = 1) 00936 { 00937 m_fab.minus(a_src.m_fab, a_srcbox, a_destbox, a_srccomp, a_destcomp, a_numcomp); 00938 return *this; 00939 } 00940 00941 /// 00942 /** 00943 Modifies this NodeFArrayBox by multiplying all values by the scalar Real a_r. 00944 */ 00945 NodeFArrayBox& operator *= (Real a_r) 00946 { 00947 m_fab *= a_r; 00948 return *this; 00949 } 00950 00951 /// 00952 /** 00953 Modifies this NodeFArrayBox by multiplying all values by the scalar Real a_r. 00954 */ 00955 NodeFArrayBox& mult(Real a_r) 00956 { 00957 m_fab *= a_r; 00958 return *this; 00959 } 00960 00961 /// 00962 /** 00963 Modifies this NodeFArrayBox by multiplying all values by the scalar 00964 Real a_r. For given range of components. 00965 */ 00966 NodeFArrayBox& mult(Real a_r, 00967 int a_comp, 00968 int a_numcomp = 1) 00969 { 00970 m_fab.mult(a_r, a_comp, a_numcomp); 00971 return *this; 00972 } 00973 00974 /// 00975 /** 00976 Modifies this NodeFArrayBox by multiplying all values by the scalar 00977 Real a_r. For given range of components and within given a_subbox. 00978 */ 00979 NodeFArrayBox& mult(Real a_r, 00980 const Box& a_subbox, 00981 int a_comp = 0, 00982 int a_numcomp = 1) 00983 { 00984 m_fab.mult(a_r, a_subbox, a_comp, a_numcomp); 00985 return *this; 00986 } 00987 00988 /// 00989 /** 00990 Modifies this NodeFArrayBox by pointwise multiplication of the values by the 00991 argument NodeFArrayBox. You might come to grief if the domains of the 00992 NodeFArrayBoxes don't match. 00993 */ 00994 NodeFArrayBox& operator *= (const NodeFArrayBox& a_x) 00995 { 00996 m_fab *= a_x.m_fab; 00997 return *this; 00998 } 00999 01000 /// 01001 /** 01002 Modifies this NodeFArrayBox by pointwise multiplication by the values in the 01003 argument NodeFArrayBox. You might come to grief if the domains of the 01004 NodeFArrayBoxes don't match. The same as the *= operator. 01005 */ 01006 NodeFArrayBox& mult(const NodeFArrayBox& a_x) 01007 { 01008 m_fab *= a_x.m_fab; 01009 return *this; 01010 } 01011 01012 /// 01013 /** 01014 Modifies this NodeFArrayBox by pointwise multiplication by values in the 01015 argument NodeFArrayBox. Multiplies a_src's components (a_srccomp : 01016 a_srccomp+a_numcomp-1) by this NodeFArrayBox's components (a_destcomp : 01017 a_destcomp+a_numcomp-1) where the domains of the two NodeFArrayBoxes 01018 intersect. 01019 */ 01020 NodeFArrayBox& mult(const NodeFArrayBox& a_src, 01021 int a_srccomp, 01022 int a_destcomp, 01023 int a_numcomp = 1) 01024 { 01025 m_fab.mult(a_src.m_fab, a_srccomp, a_destcomp, a_numcomp); 01026 return *this; 01027 } 01028 01029 /// 01030 /** 01031 Modifies this NodeFArrayBox by pointwise multiplication by values in the 01032 argument NodeFArrayBox. Multiplies a_src's components (a_srccomp : 01033 a_srccomp+a_numcomp-1) by this NodeFArrayBox's components (a_destcomp : 01034 a_destcomp+a_numcomp-1) where the domain of this NodeFArrayBox intersects 01035 the a_subbox. NOTE: a_subbox must be contained in this FAB. 01036 */ 01037 NodeFArrayBox& mult(const NodeFArrayBox& a_src, 01038 const Box& a_subbox, 01039 int a_srccomp, 01040 int a_destcomp, 01041 int a_numcomp = 1) 01042 { 01043 m_fab.mult(a_src.m_fab, a_subbox, a_srccomp, a_destcomp, a_numcomp); 01044 return *this; 01045 } 01046 01047 /// 01048 /** 01049 Modifies this NodeFArrayBox by pointwise multiplication by values in the 01050 argument NodeFArrayBox. Multiplies a_src's components (a_srccomp : 01051 a_srccomp+a_numcomp-1) in the Box a_srcbox by this NodeFArrayBox's 01052 components (a_destcomp : a_destcomp+a_numcomp-1) in the Box a_destbox. 01053 Corresponding locations within the two NodeFArrayBoxes are indexed relative 01054 to a_srcbox and a_destbox, and will in general not be the same. The 01055 a_srcbox and a_destbox must be same size. The results are UNDEFINED if 01056 the a_src and dest NodeFArrayBoxes are the same and the a_srcbox and a_destbox 01057 overlap. 01058 */ 01059 NodeFArrayBox& mult(const NodeFArrayBox& a_src, 01060 const Box& a_srcbox, 01061 const Box& a_destbox, 01062 int a_srccomp, 01063 int a_destcomp, 01064 int a_numcomp = 1) 01065 { 01066 m_fab.mult(a_src.m_fab, a_srcbox, a_destbox, a_srccomp, a_destcomp, a_numcomp); 01067 return *this; 01068 } 01069 01070 /// 01071 /** 01072 Modifies this NodeFArrayBox by dividing all values by the scalar Real a_r. 01073 */ 01074 NodeFArrayBox& operator /= (Real a_r) 01075 { 01076 m_fab /= a_r; 01077 return *this; 01078 } 01079 01080 /// 01081 /** 01082 Modifies this NodeFArrayBox by dividing all values by the scalar Real a_r. 01083 */ 01084 NodeFArrayBox& divide(Real a_r) 01085 { 01086 m_fab /= a_r; 01087 return *this; 01088 } 01089 01090 /// 01091 /** 01092 Modifies this NodeFArrayBox by dividing all values by the scalar Real a_r. 01093 For given range of components. 01094 */ 01095 NodeFArrayBox& divide(Real a_r, 01096 int a_comp, 01097 int a_numcomp = 1) 01098 { 01099 m_fab.divide(a_r, a_comp, a_numcomp); 01100 return *this; 01101 } 01102 01103 /// 01104 /** 01105 Modifies this NodeFArrayBox by dividing all values by the scalar Real 01106 a_r. For given range of components and within given a_subbox. 01107 */ 01108 NodeFArrayBox& divide(Real a_r, 01109 const Box& a_subbox, 01110 int a_comp = 0, 01111 int a_numcomp = 1) 01112 { 01113 m_fab.divide(a_r, a_subbox, a_comp, a_numcomp); 01114 return *this; 01115 } 01116 01117 /// 01118 /** 01119 Modifies this NodeFArrayBox by pointwise division of the values by the 01120 argument NodeFArrayBox. You might come to grief if the domains of the 01121 NodeFArrayBoxes don't match. 01122 */ 01123 NodeFArrayBox& operator /= (const NodeFArrayBox& a_x) 01124 { 01125 m_fab /= a_x.m_fab; 01126 return *this; 01127 } 01128 01129 /// 01130 /** 01131 Modifies this NodeFArrayBox by pointwise division by the values in the 01132 argument NodeFArrayBox. You might come to grief if the domains of the 01133 NodeFArrayBoxes don't match. The same as the /= operator. 01134 */ 01135 NodeFArrayBox& divide(const NodeFArrayBox& a_x) 01136 { 01137 m_fab /= a_x.m_fab; 01138 return *this; 01139 } 01140 01141 /// 01142 /** 01143 Modifies this NodeFArrayBox by pointwise division by values in the argument 01144 NodeFArrayBox. Divides this NodeFArrayBox's components (a_destcomp : 01145 a_destcomp+a_numcomp-1) by a_src's components (a_srccomp : 01146 a_srccomp+a_numcomp-1) where the domains of the two NodeFArrayBoxes intersect. 01147 */ 01148 NodeFArrayBox& divide(const NodeFArrayBox& a_src, 01149 int a_srccomp, 01150 int a_destcomp, 01151 int a_numcomp = 1) 01152 { 01153 m_fab.divide(a_src.m_fab, a_srccomp, a_destcomp, a_numcomp); 01154 return *this; 01155 } 01156 01157 /// 01158 /** 01159 Modifies this NodeFArrayBox by pointwise division by values in the argument 01160 NodeFArrayBox. Divides this NodeFArrayBox's components (a_destcomp : 01161 a_destcomp+a_numcomp-1) by a_src's components (a_srccomp : 01162 a_srccomp+a_numcomp-1) where the domain of this NodeFArrayBox intersects 01163 the a_subbox. NOTE: a_subbox must be contained in this FAB. 01164 */ 01165 NodeFArrayBox& divide(const NodeFArrayBox& a_src, 01166 const Box& a_subbox, 01167 int a_srccomp, 01168 int a_destcomp, 01169 int a_numcomp = 1) 01170 { 01171 m_fab.divide(a_src.m_fab, a_subbox, a_srccomp, a_destcomp, a_numcomp); 01172 return *this; 01173 } 01174 01175 /// 01176 /** 01177 Modifies this NodeFArrayBox by pointwise division by values in the argument 01178 NodeFArrayBox. Divides this NodeFArrayBox's components (a_destcomp : 01179 a_destcomp+a_numcomp-1) in the Box a_destbox by a_src's components 01180 (a_srccomp : a_srccomp+a_numcomp-1) in the Box a_srcbox. Corresponding 01181 locations within the two NodeFArrayBoxes are indexed relative to a_srcbox and 01182 a_destbox, and will in general not be the same. The a_srcbox and 01183 a_destbox must be same size. The results are UNDEFINED if the a_src and 01184 dest NodeFArrayBoxes are the same and the a_srcbox and a_destbox overlap. 01185 */ 01186 NodeFArrayBox& divide(const NodeFArrayBox& a_src, 01187 const Box& a_srcbox, 01188 const Box& a_destbox, 01189 int a_srccomp, 01190 int a_destcomp, 01191 int a_numcomp = 1) 01192 { 01193 m_fab.divide(a_src.m_fab, a_srcbox, a_destbox, a_srccomp, a_destcomp, a_numcomp); 01194 return *this; 01195 } 01196 /** 01197 Returns the lower corner of the domain. Instead of returning them in 01198 the form of IntVects, as in smallEnd and bigEnd, it returns the values 01199 as a pointer to an array of constant integers. This is useful when 01200 interfacing to Fortran subroutines. It should not be used in any other 01201 context!!! 01202 */ 01203 inline const int* loVect() const 01204 { 01205 return m_fab.loVect(); 01206 } 01207 01208 /** 01209 Returns the upper corner of the domain. Instead of returning them in 01210 the form of IntVects, as in smallEnd and bigEnd, it returns the values 01211 as a pointer to an array of constant integers. This is useful when 01212 interfacing to Fortran subroutines. It should not be used in any other 01213 context!!! 01214 */ 01215 inline const int* hiVect() const 01216 { 01217 return m_fab.hiVect(); 01218 } 01219 01220 /** 01221 Returns a pointer to an integer that contains the number of components 01222 in the BaseFab. This is useful when interfacing to Fortran subroutines. 01223 It should not be used in any other context!!! 01224 */ 01225 const int* nCompPtr() const 01226 { 01227 return m_fab.nCompPtr(); 01228 } 01229 /** 01230 Returns a pointer to an object of type T that is the value of the a_nth 01231 component associated with the cell at the low end of the domain. This 01232 is commonly used to get a pointer to data in the array which is then 01233 handed off to a Fortran subroutine. It should not be used in any other 01234 context!!! Remember that data is stored in Fortran array order, with 01235 the component index coming last. In other words, `dataPtr' returns a 01236 pointer to all the a_nth components. 01237 */ 01238 Real* dataPtr(int a_n = 0) 01239 { 01240 return m_fab.dataPtr(a_n); 01241 } 01242 01243 /** 01244 Returns a constant pointer to an object of type T that is the value of 01245 the a_nth component associated with the cell at the low end of the domain. 01246 This is commonly used to get a pointer to data in the array which is 01247 then handed off to a Fortran subroutine. It should not be used in any 01248 other context!!! Remember that data is stored in Fortran array order, 01249 with the component index coming last. In other words, `dataPtr' returns 01250 a pointer to all the a_nth components. 01251 */ 01252 const Real* dataPtr(int a_n = 0) const 01253 { 01254 return m_fab.dataPtr(a_n); 01255 } 01256 01257 01258 void shift(const IntVect& iv) 01259 { 01260 m_box.shift(iv); 01261 m_fab.shift(iv); 01262 } 01263 01264 protected: 01265 // CELL-centered box. data are defined on the surrounding nodes. 01266 Box m_box; 01267 01268 // NODE-centered data 01269 FArrayBox m_fab; 01270 01271 private: 01272 /// These are disallowed for performance reasons 01273 01274 //NodeFArrayBox (const NodeFArrayBox&); 01275 //NodeFArrayBox& operator = (const NodeFArrayBox&); 01276 01277 }; 01278 01279 #include "NamespaceFooter.H" 01280 #endif