Chombo + EB  3.0
NodeFArrayBox.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 // NodeFArrayBox.H
12 // adapted from dMartin/Chombo-IAMR/util/FluxBox.H
13 // by Dan Martin, Fri, Jan 14, 2000
14 // petermc, 1 Nov 2000
15 // 8 Jan 2001 added
16 
17 #ifndef _NODEFARRAYBOX_H_
18 #define _NODEFARRAYBOX_H_
19 
20 #include "FArrayBox.H"
21 #include "NamespaceHeader.H"
22 
23 /// A wrapper for an FArrayBox to contain NODE-centered data.
24 /** This is a class to contain NODE-centered data on a box.<br>
25  <b>Question</b>: Why not just use NODE-centered FArrayBox?<br>
26  <b>Answer</b>: We want to use LevelData<NodeFArrayBox>,
27  which requires that the underlying BoxLayout be a DisjointBoxLayout.
28  Adjacent NODE-centered boxes intersect, but adjacent CELL-centered
29  boxes do not.<br>
30  The underlying DisjointBoxLayout will be CELL-centered.
31 
32  In a LevelData<NodeFArrayBox>, some of the grids may share nodes.
33  The data on shared nodes must be the same.
34 
35  Example: A four-grid layout is shown on the left. As shown on
36  the right, the nodes marked "2" are shared by two grids, and
37  those marked "3" are shared by three grids.
38  <pre>
39  +-----+ YYYY--+
40  | | | |
41  | | | |
42  | | | |
43  +---+--+--+---+ +---2223222---+
44  | | | | 2 |
45  | | | | 2 |
46  | | | | 2 |
47  +---+------+------+ X---22222223------X
48  | | | |
49  | | | |
50  | | | |
51  +----------+ +-------YYYY
52  </pre>
53  Additional nodes may be shared if the boxes extend to the faces
54  of a domain that is periodic in one or more directions.
55  In the example above, these nodes are marked "X" and "Y".<br>
56  Horizontally periodic domain: node "X" shared by two grids.<br>
57  Vertically periodic domain: nodes "Y" shared by two grids.
58 
59  One of the most useful features of LevelData<NodeFArrayBox> is the
60  copyTo() function. THE copyTo() FUNCTION MUST BE USED WITH CAUTION
61  if the source and destination have different layouts.
62 
63  Consider an example where A and B are on layouts of one box
64  each, and these two boxes abut:
65  <pre>
66  +-------+
67  | |
68  | A |
69  | |
70  =========
71  | |
72  | B |
73  | |
74  +-------+
75  </pre>
76  If we do A.copyTo(B), then the data on the nodes of the interface
77  (marked "=") are NOT copied, because the underlying CELL-centered
78  DisjointBoxLayouts of the LevelDatas do not intersect.
79 
80  So whenever we want to use src.copyTo(dest), unless we are sure
81  that src and dest have the same layout, we do the following:
82  - define BoxLayoutData<NodeFArrayBox> destExpanded on the BoxLayout of
83  dest with each box expanded by one in each dimension;
84  - do src.copyTo(destExpanded);
85  - box by box, copy destExpanded to dest.
86 */
88 {
89 
90 public:
91 
92  /**
93  \name Constructors, destructor and defines
94  */
95  /*@{*/
96 
97  ///
98  /** Default constructor. User must subsequently call define().
99  */
100  NodeFArrayBox();
101 
102  ///
103  /** Constructs NodeFArrayBox on CELL-centered box <i>a_bx</i>
104  with <i>a_nComp</i> components using the aliased data space.
105  */
106  NodeFArrayBox(const Box& a_bx, int a_nComp, Real* a_alias = NULL);
107 
108  ///
109  /** Constructs an aliased NodeFArrayBox.
110  */
111  NodeFArrayBox(const Interval& a_comps, NodeFArrayBox& a_original);
112 
113  ///
114  /** Destructor.
115  */
116  ~NodeFArrayBox();
117 
118  ///
119  /** Defines NodeFArrayBox on CELL-centered box <i>a_bx</i>
120  with <i>a_nComp</i> components. If called more than once
121  on the same instance, the box and FAB will be resize()d.
122  */
123  void define(const Box& a_bx, int a_nComp=1);
124 
125  /**
126  Change this NodeFArrayBox so it covers the Box a_bx with a_nComps
127  components. If a_alias is not NULL, it is used as the data memory
128  (and is assumed to be large enough).
129  */
130  void resize(const Box& a_bx, int a_nComp=1, Real* a_alias=NULL);
131 
132  /*@}*/
133 
134  /**
135  \name Accessors
136  */
137  /*@{*/
138 
139  ///
140  /** Returns the CELL-centered domain where the array is defined.
141  */
142  const Box& box() const;
143 
144  ///
145  /** Returns a modifiable reference to the NODE-centered FArrayBox
146  containing the data.
147  */
148  FArrayBox& getFab();
149 
150  ///
151  /** Returns a constant reference to the NODE-centered FArrayBox
152  containing the data.
153  */
154  const FArrayBox& getFab() const;
155 
156  Real dotProduct(const NodeFArrayBox& a_fab2) const
157  {
158  return m_fab.dotProduct(a_fab2.m_fab);
159  }
160 
161  Real dotProduct(const NodeFArrayBox& a_fab2, const Box& box) const
162  {
163  return m_fab.dotProduct(a_fab2.m_fab, box);
164  }
165 
166  /*@}*/
167 
168  /**
169  \name Data modification functions
170  */
171  /*@{*/
172 
173  ///
174  /** Modifies the data in this NodeFArrayBox by copying data
175  from <i>a_src</i> into it, over the nodes that they have in common.<br>
176  If this NodeFArrayBox and <i>a_src</i> have abutting grids,
177  as shown:
178  <pre>
179  +--------+
180  | |
181  | this |
182  | |
183  ========== <- data copied here from a_src to this
184  | |
185  | a_src |
186  | |
187  +--------+
188  </pre>
189  then the data in this NodeFArrayBox WILL be modified along the
190  edge nodes where they abut -- even though this.box() and
191  <i>a_src</i>.box(), being CELL-centered, do NOT intersect.
192 
193  All components are copied.
194  */
195  void copy(const NodeFArrayBox& a_src);
196 
197  ///
198  /** Modifies the data in this NodeFArrayBox by copying the data
199  from <i>a_src</i> into it, over the intersection of:
200  - the nodes surrounding the CELL-centered box <i>a_regionFrom</i>;
201  - the nodes surrounding the CELL-centered box <i>a_regionTo</i>;
202  - the nodes containing data in this NodeFArrayBox;
203  - the nodes containing data in <i>a_src</i>.
204 
205  The components in the interval <i>a_Csrc</i> in <i>a_src</i>
206  are copied to the components in the interval <i>a_Cdest</i>
207  in this NodeFArrayBox.
208 
209  This function is required in order to have BoxLayoutData<NodeFArrayBox>.
210  */
211  void copy(const Box& a_regionFrom,
212  const Interval& a_Cdest,
213  const Box& a_regionTo,
214  const NodeFArrayBox& a_src,
215  const Interval& a_Csrc);
216 
217  /*@}*/
218 
219  /**
220  \name Linearization functions
221  */
222  /*@{*/
223 
224  ///
225  /** Returns size, in number of bytes, of a flat linear
226  representation of the data in this object in the area
227  defined by the nodes in CELL-centered box <i>a_R</i> and the
228  component Interval <i>a_comps</i>.
229 
230  This function is required in order to have BoxLayoutData<NodeFArrayBox>.
231  */
232  int size(const Box& a_R, const Interval& a_comps) const;
233 
234  ///
235  /** Writes into <i>a_buf</i> a linear representation of the internal data for
236  the nodes surrounding CELL-centered box <i>a_R</i>, over the component
237  Interval <i>a_comps</i>.
238 
239  Assumes that sufficient
240  memory for the buffer has already been allocated by the caller.
241 
242  This function is required in order to have BoxLayoutData<NodeFArrayBox>.
243  */
244  void linearOut(void* a_buf, const Box& a_R, const Interval& a_comps) const;
245 
246  ///
247  void linearIn(void* a_buf, const Box& a_R, const Interval& a_comps);
248 
249 
250  /// These functions are required for broadcast & gather.
251  void linearOut(void* a_buf) const;
252  ///
253  void linearIn(const void* const a_buf);
254  ///
255  int linearSize(void) const;
256 
257  ///
258  static int preAllocatable()
259  {
260  return 0;
261  }
262 
263  /*@}*/
264 
265 
266  ///
267  /**
268  Modifies this NodeFArrayBox so that all values of all components are set to
269  the given value, a_x. (FArrayBox inherits such a function from BaseFab.)
270  */
271  void setVal(Real a_x);
272 
273  /**
274  The setVal functions set subregions in the `BaseFab' to a constant value.
275  This most general form specifies the subbox, the starting component
276  number, and the number of components to be set.
277  */
278  void setVal(Real a_x,
279  const Box& a_bx,
280  int a_nstart,
281  int a_numcomp);
282 
283  ///
284  /** HERE
285  Returns the Lp-norm of this FAB using components
286  (a_comp : a_comp+a_numcomp-1) and within the a_subbox.
287  a_p < 0 -> ERROR
288  a_p = 0 -> infinity norm (max norm)
289  a_p = 1 -> sum of ABS(FAB)
290  a_p > 1 -> Lp-norm
291  */
292  Real norm(const Box& a_subbox,
293  int a_p = 2,
294  int a_comp = 0,
295  int a_numcomp = 1) const
296  {
297  return m_fab.norm(a_subbox, a_p, a_comp, a_numcomp);
298  }
299 
300  ///
301  /**
302  Returns the Lp-norm of this FAB using components
303  (a_comp : a_comp+a_numcomp-1).
304  a_p < 0 -> ERROR
305  a_p = 0 -> infinity norm (max norm)
306  a_p = 1 -> sum of ABS(FAB)
307  a_p > 1 -> Lp-norm
308  */
309  Real norm(int a_p = 2,
310  int a_comp = 0,
311  int a_numcomp = 1) const
312  {
313  return m_fab.norm(a_p, a_comp, a_numcomp);
314  }
315 
316 
317  ///
318  /**
319  Returns sum of pow(fab[i,c],p): i in a_subbox, a_comp <= c <
320  a_comp+a_numcomp, a_p >= 2 only
321  */
322  Real sumPow(const Box& a_subbox,
323  int a_p = 2,
324  int a_comp = 0,
325  int a_numcomp = 1) const
326 
327  {
328  return m_fab.sumPow(a_subbox, a_p, a_comp, a_numcomp);
329  }
330 
331 
332  ///
333  /**
334  Returns the minimum value of given component of this NodeFArrayBox.
335  */
336  Real min(int a_comp = 0) const
337  {
338  return m_fab.min(a_comp);
339  }
340 
341  ///
342  /**
343  Returns the minimum value of given component of this NodeFArrayBox in
344  given a_subbox.
345 
346  */
347  Real min(const Box& a_subbox,
348  int a_comp = 0) const
349  {
350  return m_fab.min(a_subbox, a_comp);
351  }
352 
353  ///
354  /**
355  Returns the maximum value of given component of this NodeFArrayBox.
356  */
357  Real max(int a_comp = 0) const
358  {
359  return m_fab.max(a_comp);
360  }
361 
362  ///
363  /**
364  Returns the maximum value of given component of this NodeFArrayBox in
365  given a_subbox.
366 
367  */
368  Real max(const Box& a_subbox,
369  int a_comp = 0) const
370 
371  {
372  return m_fab.max(a_subbox, a_comp);
373  }
374 
375  ///
376  /**
377  Finds location of minimum value in given component of this NodeFArrayBox.
378  */
379  IntVect minIndex(int a_comp = 0) const
380  {
381  return m_fab.minIndex(a_comp);
382  }
383 
384  ///
385  /**
386  Returns location of minimum value in given component of this NodeFArrayBox
387  in given a_subbox.
388  */
389  IntVect minIndex(const Box& a_subbox,
390  int a_comp = 0) const
391  {
392  return m_fab.minIndex(a_subbox, a_comp);
393  }
394 
395  ///
396  /**
397  Returns location of maximum value in given component of this NodeFArrayBox.
398  */
399  IntVect maxIndex(int a_comp = 0) const
400  {
401  return m_fab.maxIndex(a_comp);
402  }
403 
404  ///
405  /**
406  Returns location of maximum value in given component of this NodeFArrayBox
407  in given a_subbox.
408  */
409  IntVect maxIndex(const Box& a_subbox,
410  int a_comp = 0) const
411  {
412  return m_fab.maxIndex(a_subbox, a_comp);
413  }
414 
415  ///
416  /**
417  Computes a_mask array with value of 1 in cells where this NodeFArrayBox
418  has value less than a_val, 0 otherwise. a_mask is resized by this
419  function. The number of cells marked with 1 returned.
420  */
421  int maskLT(BaseFab<int>& a_mask,
422  Real a_val,
423  int a_comp = 0) const
424  {
425  return m_fab.maskLT(a_mask, a_val, a_comp);
426  }
427 
428 
429  ///
430  /**
431  Computes a_mask array with value of 1 in cells where this NodeFArrayBox
432  has value less than or equal to a_val, 0 otherwise. a_mask is
433  resized by this function. The number of cells marked with 1
434  returned.
435  */
436  int maskLE(BaseFab<int>& a_mask,
437  Real a_val,
438  int a_comp = 0) const
439  {
440  return m_fab.maskLE(a_mask, a_val, a_comp);
441  }
442 
443  ///
444  /**
445  Computes a_mask array with value of 1 in cells where this NodeFArrayBox
446  has value equal to a_val, 0 otherwise. a_mask is resized by this
447  function. The number of cells marked with 1 returned.
448 
449  */
450  int maskEQ(BaseFab<int>& a_mask,
451  Real a_val,
452  int a_comp = 0) const
453  {
454  return m_fab.maskEQ(a_mask, a_val, a_comp);
455  }
456 
457  ///
458  /**
459  Computes a_mask array with value of 1 in cells where this NodeFArrayBox
460  has value greater than a_val, 0 otherwise. a_mask is resized by this
461  function. The number of cells marked with 1 returned.
462  */
463  int maskGT(BaseFab<int>& a_mask,
464  Real a_val,
465  int a_comp = 0) const
466  {
467  return m_fab.maskGT(a_mask, a_val, a_comp);
468  }
469 
470 
471  ///
472  /**
473  Computes a_mask array with value of 1 in cells where this NodeFArrayBox
474  has value greater than or equal to a_val, 0 otherwise. a_mask is
475  resized by this function. The number of cells marked with 1 returned.
476  */
477  int maskGE(BaseFab<int>& a_mask,
478  Real a_val,
479  int a_comp = 0) const
480  {
481  return m_fab.maskGE(a_mask, a_val, a_comp);
482  }
483 
484  ///
485  /**
486  Modifies this NodeFArrayBox by replacing each value with its absolute value.
487  */
488  void abs()
489  {
490  m_fab.abs();
491  }
492 
493  ///
494  /**
495  */
496  int nComp() const
497  {
498  return m_fab.nComp();
499  }
500 
501  ///
502  /**
503  Modifies this NodeFArrayBox by replacing each value with its absolute value,
504  for components (a_comp : a_comp+a_numcomp-1).
505  */
506  void abs(int a_comp,
507  int a_numcomp = 1)
508  {
509  m_fab.abs(a_comp, a_numcomp);
510  }
511 
512  ///
513  /**
514  Modifies this NodeFArrayBox by replacing eahc value with its absolute value,
515  for components (a_comp : a_comp+a_numcomp-1) and within the a_subbox.
516  */
517  void abs (const Box& a_subbox,
518  int a_comp = 0,
519  int a_numcomp = 1)
520  {
521  m_fab.abs(a_subbox, a_comp, a_numcomp);
522  }
523 
524 
525  ///
526  /**
527  Returns sum of given component of NodeFArrayBox.
528  */
529  Real sum(int a_comp,
530  int a_numcomp = 1) const
531  {
532  return m_fab.sum(a_comp, a_numcomp);
533  }
534 
535  ///
536  /**
537  Returns sum of component of this NodeFArrayBox in given a_subbox.
538  */
539  Real sum(const Box& a_subbox,
540  int a_comp,
541  int a_numcomp = 1) const
542  {
543  return m_fab.sum(a_subbox, a_comp, a_numcomp);
544  }
545 
546 
547  ///
548  /**
549  Modifies this NodeFArrayBox by replacing each value x with a_r/x.
550  */
552  {
553  m_fab.invert(a_r);
554  return *this;
555  }
556 
557 
558  ///
559  /**
560  Modifies this NodeFArrayBox by replacing each value x with a_r/x. For
561  given range of components.
562  */
564  int a_comp,
565  int a_numcomp = 1)
566  {
567  m_fab.invert(a_r, a_comp, a_numcomp);
568  return *this;
569  }
570 
571  ///
572  /**
573  Modifies this NodeFArrayBox by replacing each value x with a_r/x. For
574  given range of components and within given a_subbox.
575  */
577  const Box& a_subbox,
578  int a_comp = 0,
579  int a_numcomp = 1)
580  {
581  m_fab.invert(a_r, a_subbox, a_comp, a_numcomp);
582  return *this;
583  }
584 
585  ///
586  /**
587  Modifies this NodeFArrayBox by replacing each value with its additive
588  inverse. For given range of components and within given a_subbox.
589  */
590  NodeFArrayBox& negate(const Box& a_subbox,
591  int a_comp = 0,
592  int a_numcomp = 1)
593  {
594  m_fab.negate(a_subbox, a_comp, a_numcomp);
595  return *this;
596  }
597 
598  ///
599  /**
600  Modifies this NodeFArrayBox by replacing each value with its additive
601  inverse. For given range of components.
602  */
603  NodeFArrayBox& negate(int a_comp,
604  int a_numcomp = 1)
605  {
606  m_fab.negate(a_comp, a_numcomp);
607  return *this;
608  }
609 
610  ///
611  /**
612  Modifies this NodeFArrayBox by replacing each value with its additive
613  inverse.
614  */
616  {
617  m_fab.negate();
618  return *this;
619  }
620 
621 
622  ///
623  /**
624  Modifies this NodeFArrayBox by adding the scalar Real a_r to all values. For
625  given range of components and within given a_subbox.
626  */
628  const Box& a_subbox,
629  int a_comp = 0,
630  int a_numcomp = 1)
631  {
632  m_fab.plus(a_r, a_subbox, a_comp, a_numcomp);
633  return *this;
634  }
635 
636  ///
637  /**
638  Modifies this NodeFArrayBox by adding the scalar Real a_r to all values. For
639  given range of components.
640  */
642  int a_comp,
643  int a_numcomp = 1)
644  {
645  m_fab.plus(a_r, a_comp, a_numcomp);
646  return *this;
647  }
648 
649  ///
650  Real& operator() (const IntVect& a_p,
651  int N = 0)
652  {
653  return m_fab(a_p,N);
654  }
655 
656  ///
657  const Real& operator() (const IntVect& a_p,
658  int N = 0) const
659  {
660  return m_fab(a_p,N);
661  }
662  ///
663  /**
664  Modifies this NodeFArrayBox by adding the scalar Real a_r to all values.
665  */
667  {
668  m_fab += a_r;
669  return *this;
670  }
671 
672  ///
673  /**
674  Modifies this NodeFArrayBox by pointwise addition of the values of the
675  argument NodeFArrayBox. You might come to grief if the domains of the
676  NodeFArrayBoxes don't match.
677  */
679  {
680  m_fab += a_x.m_fab;
681  return *this;
682  }
683 
684 
685  ///
686  /**
687  Modifies this NodeFArrayBox by adding the scalar Real a_r to all values.
688  */
690  {
691  m_fab += a_r;
692  return *this;
693  }
694 
696  {
697  return this->plus(a_r);
698  }
699 
700  ///
701  /**
702  Modifies this NodeFArrayBox by pointwise addition of the values of the
703  argument NodeFArrayBox. You might come to grief if the domains of the
704  NodeFArrayBoxes don't match. The same as += operator.
705 
706  */
708  {
709  m_fab += a_x.m_fab;
710  return *this;
711  }
712 
713  ///
714  /**
715  Modifies this NodeFArrayBox by pointwise scaled addition of the
716  argument NodeFArrayBox (a[i] <- a[i] + a_scale * a_src[i]). Uses domain
717  of the intersection of these two NodeFArrayBoxes.
718  */
720  const Real& a_scale)
721  {
722  m_fab.plus(a_src.m_fab, a_scale);
723  return *this;
724  }
725 
726  ///
727  /**
728  Modifies this NodeFArrayBox by pointwise scaled addition of the
729  argument NodeFArrayBox (a[i] <- a[i] + a_scale * a_src[i]). Uses domain
730  of the intersection of these two NodeFArrayBoxes.
731  */
733  const Real& a_scale,
734  int a_srccomp,
735  int a_destcomp,
736  int a_numcomp = 1)
737  {
738  m_fab.plus(a_src.m_fab, a_scale, a_srccomp, a_destcomp, a_numcomp);
739  return *this;
740  }
741 
742  ///
743  /**
744  Modifies this NodeFArrayBox by pointwise addition of values in the argument
745  NodeFArrayBox. Adds src's components (a_srccomp : a_srccomp+a_numcomp-1)
746  to this NodeFArrayBox's components (a_destcomp : a_destcomp+a_numcomp-1)
747  where the domains of the two NodeFArrayBoxes intersect.
748  */
750  int a_srccomp,
751  int a_destcomp,
752  int a_numcomp = 1)
753  {
754  m_fab.plus(a_src.m_fab, a_srccomp, a_destcomp, a_numcomp);
755  return *this;
756  }
757 
758  ///
759  /**
760  Modifies this NodeFArrayBox by pointwise addition of values in the argument
761  NodeFArrayBox. Adds src's components (a_srccomp : a_srccomp+a_numcomp-1)
762  to this NodeFArrayBox's components (a_destcomp : a_destcomp+numcomp-1)
763  where the domain of this NodeFArrayBox intersects the a_subbox. NOTE:
764  a_subbox must be contained in this FAB.
765  */
767  const Box& a_subbox,
768  int a_srccomp,
769  int a_destcomp,
770  int a_numcomp = 1)
771  {
772  m_fab.plus(a_src.m_fab, a_subbox, a_srccomp, a_destcomp, a_numcomp);
773  return *this;
774  }
775 
776 
777  ///
778  /**
779  Modifies this NodeFArrayBox by pointwise addition of values in the argument
780  NodeFArrayBox. Adds src's components (a_srccomp : a_srccomp+a_numcomp-1)
781  in the Box a_srcbox to this NodeFArrayBox's components (a_destcomp :
782  a_destcomp+a_numcomp-1) in the Box a_destbox. Corresponding locations
783  within the two NodeFArrayBoxes are indexed relative to a_srcbox and a_destbox,
784  and will in general not be the same. The a_srcbox and a_destbox must be
785  same size. The results are UNDEFINED if the a_src and dest NodeFArrayBoxes
786  are the same and the a_srcbox and a_destbox overlap.
787 
788  */
790  const Box& a_srcbox,
791  const Box& a_destbox,
792  int a_srccomp,
793  int a_destcomp,
794  int a_numcomp = 1)
795  {
796  m_fab.plus(a_src.m_fab, a_srcbox, a_destbox, a_srccomp, a_destcomp, a_numcomp);
797  return *this;
798  }
799 
800 
801  ///
803  const Box& a_srcbox,
804  const Box& a_destbox,
805  const Real& a_scale,
806  int a_srccomp,
807  int a_destcomp,
808  int a_numcomp = 1)
809  {
810  m_fab.plus(a_src.m_fab, a_srcbox, a_destbox, a_scale, a_srccomp, a_destcomp, a_numcomp);
811  return *this;
812  }
813 
814  ///
815  /**
816  Modifies this NodeFArrayBox by subtracting the scalar Real a_r to all values.
817  Note: use plus(-a_r) for more general operations.
818  */
820  {
821  m_fab -= a_r;
822  return *this;
823  }
824 
825  ///
826  /**
827  Modifies this NodeFArrayBox by pointwise subtraction of the values of the
828  argument NodeFArrayBox. You might come to grief if the domains of the
829  NodeFArrayBoxes don't match.
830  */
832  {
833  m_fab -= a_x.m_fab;
834  return *this;
835  }
836 
837  ///
838  /**
839  Modifies this NodeFArrayBox by pointwise subtraction of the values of the
840  argument NodeFArrayBox. You might come to grief if the domains of the
841  NodeFArrayBoxes don't match. The same as -= operator.
842  */
844  {
845  m_fab -= a_x.m_fab;
846  return *this;
847  }
848 
849  /**
850  Modifies this NodeFArrayBox by pointwise subtraction of values in the
851  argument NodeFArrayBox. Subtracts a_src's components (a_srccomp :
852  a_srccomp+a_numcomp-1) from this NodeFArrayBox's components (a_destcomp :
853  a_destcomp+a_numcomp-1) where the domains of the two NodeFArrayBoxes
854  intersect.
855  */
857  int a_srccomp,
858  int a_destcomp,
859  int a_numcomp = 1)
860  {
861  m_fab.minus(a_src.m_fab, a_srccomp, a_destcomp, a_numcomp);
862  return *this;
863  }
864 
865  /**
866  Modifies this NodeFArrayBox by pointwise subtraction of values in the
867  argument NodeFArrayBox. Subtracts a_src's components (a_srccomp :
868  a_srccomp+a_numcomp-1) from this NodeFArrayBox's components (a_destcomp :
869  a_destcomp+a_numcomp-1) where the domain of this NodeFArrayBox intersects
870  the a_subbox. NOTE: a_subbox must be contained in this FAB.
871  */
873  const Box& a_subbox,
874  int a_srccomp,
875  int a_destcomp,
876  int a_numcomp = 1)
877  {
878  m_fab.minus(a_src.m_fab, a_subbox, a_srccomp, a_destcomp, a_numcomp);
879  return *this;
880  }
881 
882 
883  ///
884  /**
885  Modifies this NodeFArrayBox by pointwise subtraction of values in the
886  argument NodeFArrayBox. Subtracts a_src's components (a_srccomp :
887  a_srccomp+a_numcomp-1) in the Box a_srcbox from this NodeFArrayBox's
888  components (a_destcomp : a_destcomp+a_numcomp-1) in the Box a_destbox.
889  Corresponding locations within the two NodeFArrayBoxes are indexed relative
890  to a_srcbox and a_destbox, and will in general not be the same. The
891  a_srcbox and a_destbox must be same size. The results are UNDEFINED
892  if the a_src and dest NodeFArrayBoxes are the same and the a_srcbox and
893  a_destbox overlap.
894  */
896  const Box& a_srcbox,
897  const Box& a_destbox,
898  int a_srccomp,
899  int a_destcomp,
900  int a_numcomp = 1)
901  {
902  m_fab.minus(a_src.m_fab, a_srcbox, a_destbox, a_srccomp, a_destcomp, a_numcomp);
903  return *this;
904  }
905 
906 
907  ///
908  /**
909  Modifies this NodeFArrayBox by multiplying all values by the scalar Real a_r.
910  */
912  {
913  m_fab *= a_r;
914  return *this;
915  }
916 
917  ///
918  /**
919  Modifies this NodeFArrayBox by multiplying all values by the scalar Real a_r.
920  */
922  {
923  m_fab *= a_r;
924  return *this;
925  }
926 
927  ///
928  /**
929  Modifies this NodeFArrayBox by multiplying all values by the scalar
930  Real a_r. For given range of components.
931  */
933  int a_comp,
934  int a_numcomp = 1)
935  {
936  m_fab.mult(a_r, a_comp, a_numcomp);
937  return *this;
938  }
939 
940 
941  ///
942  /**
943  Modifies this NodeFArrayBox by multiplying all values by the scalar
944  Real a_r. For given range of components and within given a_subbox.
945  */
947  const Box& a_subbox,
948  int a_comp = 0,
949  int a_numcomp = 1)
950  {
951  m_fab.mult(a_r, a_subbox, a_comp, a_numcomp);
952  return *this;
953  }
954 
955 
956  ///
957  /**
958  Modifies this NodeFArrayBox by pointwise multiplication of the values by the
959  argument NodeFArrayBox. You might come to grief if the domains of the
960  NodeFArrayBoxes don't match.
961  */
963  {
964  m_fab *= a_x.m_fab;
965  return *this;
966  }
967 
968  ///
969  /**
970  Modifies this NodeFArrayBox by pointwise multiplication by the values in the
971  argument NodeFArrayBox. You might come to grief if the domains of the
972  NodeFArrayBoxes don't match. The same as the *= operator.
973  */
975  {
976  m_fab *= a_x.m_fab;
977  return *this;
978  }
979 
980  ///
981  /**
982  Modifies this NodeFArrayBox by pointwise multiplication by values in the
983  argument NodeFArrayBox. Multiplies a_src's components (a_srccomp :
984  a_srccomp+a_numcomp-1) by this NodeFArrayBox's components (a_destcomp :
985  a_destcomp+a_numcomp-1) where the domains of the two NodeFArrayBoxes
986  intersect.
987  */
989  int a_srccomp,
990  int a_destcomp,
991  int a_numcomp = 1)
992  {
993  m_fab.mult(a_src.m_fab, a_srccomp, a_destcomp, a_numcomp);
994  return *this;
995  }
996 
997 
998  ///
999  /**
1000  Modifies this NodeFArrayBox by pointwise multiplication by values in the
1001  argument NodeFArrayBox. Multiplies a_src's components (a_srccomp :
1002  a_srccomp+a_numcomp-1) by this NodeFArrayBox's components (a_destcomp :
1003  a_destcomp+a_numcomp-1) where the domain of this NodeFArrayBox intersects
1004  the a_subbox. NOTE: a_subbox must be contained in this FAB.
1005  */
1007  const Box& a_subbox,
1008  int a_srccomp,
1009  int a_destcomp,
1010  int a_numcomp = 1)
1011  {
1012  m_fab.mult(a_src.m_fab, a_subbox, a_srccomp, a_destcomp, a_numcomp);
1013  return *this;
1014  }
1015 
1016  ///
1017  /**
1018  Modifies this NodeFArrayBox by pointwise multiplication by values in the
1019  argument NodeFArrayBox. Multiplies a_src's components (a_srccomp :
1020  a_srccomp+a_numcomp-1) in the Box a_srcbox by this NodeFArrayBox's
1021  components (a_destcomp : a_destcomp+a_numcomp-1) in the Box a_destbox.
1022  Corresponding locations within the two NodeFArrayBoxes are indexed relative
1023  to a_srcbox and a_destbox, and will in general not be the same. The
1024  a_srcbox and a_destbox must be same size. The results are UNDEFINED if
1025  the a_src and dest NodeFArrayBoxes are the same and the a_srcbox and a_destbox
1026  overlap.
1027  */
1029  const Box& a_srcbox,
1030  const Box& a_destbox,
1031  int a_srccomp,
1032  int a_destcomp,
1033  int a_numcomp = 1)
1034  {
1035  m_fab.mult(a_src.m_fab, a_srcbox, a_destbox, a_srccomp, a_destcomp, a_numcomp);
1036  return *this;
1037  }
1038 
1039 
1040  ///
1041  /**
1042  Modifies this NodeFArrayBox by dividing all values by the scalar Real a_r.
1043  */
1045  {
1046  m_fab /= a_r;
1047  return *this;
1048  }
1049 
1050  ///
1051  /**
1052  Modifies this NodeFArrayBox by dividing all values by the scalar Real a_r.
1053  */
1055  {
1056  m_fab /= a_r;
1057  return *this;
1058  }
1059 
1060 
1061  ///
1062  /**
1063  Modifies this NodeFArrayBox by dividing all values by the scalar Real a_r.
1064  For given range of components.
1065  */
1067  int a_comp,
1068  int a_numcomp = 1)
1069  {
1070  m_fab.divide(a_r, a_comp, a_numcomp);
1071  return *this;
1072  }
1073 
1074 
1075  ///
1076  /**
1077  Modifies this NodeFArrayBox by dividing all values by the scalar Real
1078  a_r. For given range of components and within given a_subbox.
1079  */
1081  const Box& a_subbox,
1082  int a_comp = 0,
1083  int a_numcomp = 1)
1084  {
1085  m_fab.divide(a_r, a_subbox, a_comp, a_numcomp);
1086  return *this;
1087  }
1088 
1089 
1090  ///
1091  /**
1092  Modifies this NodeFArrayBox by pointwise division of the values by the
1093  argument NodeFArrayBox. You might come to grief if the domains of the
1094  NodeFArrayBoxes don't match.
1095  */
1097  {
1098  m_fab /= a_x.m_fab;
1099  return *this;
1100  }
1101 
1102  ///
1103  /**
1104  Modifies this NodeFArrayBox by pointwise division by the values in the
1105  argument NodeFArrayBox. You might come to grief if the domains of the
1106  NodeFArrayBoxes don't match. The same as the /= operator.
1107  */
1109  {
1110  m_fab /= a_x.m_fab;
1111  return *this;
1112  }
1113 
1114  ///
1115  /**
1116  Modifies this NodeFArrayBox by pointwise division by values in the argument
1117  NodeFArrayBox. Divides this NodeFArrayBox's components (a_destcomp :
1118  a_destcomp+a_numcomp-1) by a_src's components (a_srccomp :
1119  a_srccomp+a_numcomp-1) where the domains of the two NodeFArrayBoxes intersect.
1120  */
1122  int a_srccomp,
1123  int a_destcomp,
1124  int a_numcomp = 1)
1125  {
1126  m_fab.divide(a_src.m_fab, a_srccomp, a_destcomp, a_numcomp);
1127  return *this;
1128  }
1129 
1130 
1131  ///
1132  /**
1133  Modifies this NodeFArrayBox by pointwise division by values in the argument
1134  NodeFArrayBox. Divides this NodeFArrayBox's components (a_destcomp :
1135  a_destcomp+a_numcomp-1) by a_src's components (a_srccomp :
1136  a_srccomp+a_numcomp-1) where the domain of this NodeFArrayBox intersects
1137  the a_subbox. NOTE: a_subbox must be contained in this FAB.
1138  */
1140  const Box& a_subbox,
1141  int a_srccomp,
1142  int a_destcomp,
1143  int a_numcomp = 1)
1144  {
1145  m_fab.divide(a_src.m_fab, a_subbox, a_srccomp, a_destcomp, a_numcomp);
1146  return *this;
1147  }
1148 
1149 
1150  ///
1151  /**
1152  Modifies this NodeFArrayBox by pointwise division by values in the argument
1153  NodeFArrayBox. Divides this NodeFArrayBox's components (a_destcomp :
1154  a_destcomp+a_numcomp-1) in the Box a_destbox by a_src's components
1155  (a_srccomp : a_srccomp+a_numcomp-1) in the Box a_srcbox. Corresponding
1156  locations within the two NodeFArrayBoxes are indexed relative to a_srcbox and
1157  a_destbox, and will in general not be the same. The a_srcbox and
1158  a_destbox must be same size. The results are UNDEFINED if the a_src and
1159  dest NodeFArrayBoxes are the same and the a_srcbox and a_destbox overlap.
1160  */
1162  const Box& a_srcbox,
1163  const Box& a_destbox,
1164  int a_srccomp,
1165  int a_destcomp,
1166  int a_numcomp = 1)
1167  {
1168  m_fab.divide(a_src.m_fab, a_srcbox, a_destbox, a_srccomp, a_destcomp, a_numcomp);
1169  return *this;
1170  }
1171 
1172 
1173 
1174 protected:
1175 
1176  // CELL-centered box. data are defined on the surrounding nodes.
1178 
1179  // NODE-centered data
1181 
1182 private:
1183  /// These are disallowed for performance reasons
1184 
1185  NodeFArrayBox (const NodeFArrayBox&);
1187 
1188 };
1189 
1190 #include "NamespaceFooter.H"
1191 #endif
Real norm(const Box &a_subbox, int a_p=2, int a_comp=0, int a_numcomp=1) const
Definition: NodeFArrayBox.H:292
Real norm(int a_p=2, int a_comp=0, int a_numcomp=1) const
Definition: NodeFArrayBox.H:309
NodeFArrayBox & plus(const NodeFArrayBox &a_src, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:749
void resize(const Box &a_bx, int a_nComp=1, Real *a_alias=NULL)
Real sumPow(const Box &a_subbox, int a_p=2, int a_comp=0, int a_numcomp=1) const
Definition: NodeFArrayBox.H:322
NodeFArrayBox & plus(const NodeFArrayBox &a_src, const Box &a_subbox, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:766
Real sum(int a_comp, int a_numcomp=1) const
NodeFArrayBox & minus(const NodeFArrayBox &a_src, const Box &a_subbox, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:872
int maskLT(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
Definition: NodeFArrayBox.H:421
int maskGT(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
NodeFArrayBox & plus(const NodeFArrayBox &a_src, const Real &a_scale, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:732
Real dotProduct(const FArrayBox &a_fab2) const
Return the dot product of this FArrayBox with another.
NodeFArrayBox & mult(const NodeFArrayBox &a_src, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:988
NodeFArrayBox & negate(const Box &a_subbox, int a_comp=0, int a_numcomp=1)
Definition: NodeFArrayBox.H:590
FArrayBox & negate(const Box &a_subbox, int a_comp=0, int a_numcomp=1)
FArrayBox & plus(Real a_r, const Box &a_subbox, int a_comp=0, int a_numcomp=1)
int size(const Box &a_R, const Interval &a_comps) const
NodeFArrayBox & mult(const NodeFArrayBox &a_src, const Box &a_srcbox, const Box &a_destbox, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:1028
NodeFArrayBox & mult(Real a_r, const Box &a_subbox, int a_comp=0, int a_numcomp=1)
Definition: NodeFArrayBox.H:946
static int preAllocatable()
Definition: NodeFArrayBox.H:258
int maskEQ(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
int maskGE(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
Definition: NodeFArrayBox.H:477
NodeFArrayBox & negate()
Definition: NodeFArrayBox.H:615
FArrayBox & invert(Real a_r)
void copy(const NodeFArrayBox &a_src)
NodeFArrayBox & mult(Real a_r, int a_comp, int a_numcomp=1)
Definition: NodeFArrayBox.H:932
Real sum(int a_comp, int a_numcomp=1) const
Definition: NodeFArrayBox.H:529
Real max(int a_comp=0) const
Definition: NodeFArrayBox.H:357
void abs()
Definition: NodeFArrayBox.H:488
int maskGT(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
Definition: NodeFArrayBox.H:463
Real min(const Box &a_subbox, int a_comp=0) const
Definition: NodeFArrayBox.H:347
void setVal(Real a_x)
NodeFArrayBox & plus(Real a_r, const Box &a_subbox, int a_comp=0, int a_numcomp=1)
Definition: NodeFArrayBox.H:627
NodeFArrayBox & divide(Real a_r, const Box &a_subbox, int a_comp=0, int a_numcomp=1)
Definition: NodeFArrayBox.H:1080
NodeFArrayBox & minus(const NodeFArrayBox &a_src, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:856
FArrayBox & divide(Real a_r)
IntVect maxIndex(int a_comp=0) const
int nComp() const
{ accessors}
Definition: BaseFabImplem.H:195
Box m_box
Definition: NodeFArrayBox.H:1177
NodeFArrayBox & invert(Real a_r, int a_comp, int a_numcomp=1)
Definition: NodeFArrayBox.H:563
Real min(int a_comp=0) const
int maskEQ(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
Definition: NodeFArrayBox.H:450
Real max(const Box &a_subbox, int a_comp=0) const
Definition: NodeFArrayBox.H:368
NodeFArrayBox & divide(const NodeFArrayBox &a_x)
Definition: NodeFArrayBox.H:1108
NodeFArrayBox & divide(const NodeFArrayBox &a_src, const Box &a_subbox, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:1139
void abs(const Box &a_subbox, int a_comp=0, int a_numcomp=1)
Definition: NodeFArrayBox.H:517
Structure for passing component ranges in code.
Definition: Interval.H:23
const Box & box() const
NodeFArrayBox & minus(const NodeFArrayBox &a_x)
Definition: NodeFArrayBox.H:843
int maskGE(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
virtual Real sumPow(const Box &a_subbox, int a_p=2, int a_comp=0, int a_numcomp=1) const
double Real
Definition: REAL.H:33
int maskLT(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
NodeFArrayBox & mult(const NodeFArrayBox &a_x)
Definition: NodeFArrayBox.H:974
int linearSize(void) const
NodeFArrayBox & operator-=(Real a_r)
Definition: NodeFArrayBox.H:819
NodeFArrayBox & plus(const NodeFArrayBox &a_src, const Real &a_scale)
Definition: NodeFArrayBox.H:719
FArrayBox & minus(const FArrayBox &a_x)
int maskLE(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
Definition: NodeFArrayBox.H:436
NodeFArrayBox & plus(Real a_r)
Definition: NodeFArrayBox.H:689
IntVect minIndex(int a_comp=0) const
Real dotProduct(const NodeFArrayBox &a_fab2) const
Definition: NodeFArrayBox.H:156
int nComp() const
Definition: NodeFArrayBox.H:496
Real dotProduct(const NodeFArrayBox &a_fab2, const Box &box) const
Definition: NodeFArrayBox.H:161
NodeFArrayBox & divide(const NodeFArrayBox &a_src, const Box &a_srcbox, const Box &a_destbox, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:1161
FArrayBox & getFab()
NodeFArrayBox & operator*=(Real a_r)
Definition: NodeFArrayBox.H:911
NodeFArrayBox & negate(int a_comp, int a_numcomp=1)
Definition: NodeFArrayBox.H:603
Real max(int a_comp=0) const
void abs()
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
NodeFArrayBox & plus(const NodeFArrayBox &a_src, const Box &a_srcbox, const Box &a_destbox, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:789
NodeFArrayBox & minus(const NodeFArrayBox &a_src, const Box &a_srcbox, const Box &a_destbox, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:895
NodeFArrayBox & invert(Real a_r, const Box &a_subbox, int a_comp=0, int a_numcomp=1)
Definition: NodeFArrayBox.H:576
IntVect maxIndex(const Box &a_subbox, int a_comp=0) const
Definition: NodeFArrayBox.H:409
Real & operator()(const IntVect &a_p, int N=0)
Definition: NodeFArrayBox.H:650
void define(const Box &a_bx, int a_nComp=1)
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
NodeFArrayBox & operator=(const NodeFArrayBox &)
Definition: FArrayBox.H:44
NodeFArrayBox & divide(Real a_r)
Definition: NodeFArrayBox.H:1054
NodeFArrayBox & mult(Real a_r)
Definition: NodeFArrayBox.H:921
NodeFArrayBox & plus(const NodeFArrayBox &a_x)
Definition: NodeFArrayBox.H:707
Real min(int a_comp=0) const
Definition: NodeFArrayBox.H:336
NodeFArrayBox & plus_real(Real a_r)
Definition: NodeFArrayBox.H:695
Real sum(const Box &a_subbox, int a_comp, int a_numcomp=1) const
Definition: NodeFArrayBox.H:539
NodeFArrayBox & plus(Real a_r, int a_comp, int a_numcomp=1)
Definition: NodeFArrayBox.H:641
IntVect minIndex(const Box &a_subbox, int a_comp=0) const
Definition: NodeFArrayBox.H:389
IntVect minIndex(int a_comp=0) const
Definition: NodeFArrayBox.H:379
NodeFArrayBox & divide(const NodeFArrayBox &a_src, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:1121
NodeFArrayBox & plus(const NodeFArrayBox &a_src, const Box &a_srcbox, const Box &a_destbox, const Real &a_scale, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:802
IntVect maxIndex(int a_comp=0) const
Definition: NodeFArrayBox.H:399
virtual Real norm(const Box &a_subbox, int a_p=2, int a_comp=0, int a_numcomp=1) const
NodeFArrayBox & operator+=(Real a_r)
Definition: NodeFArrayBox.H:666
void linearIn(void *a_buf, const Box &a_R, const Interval &a_comps)
NodeFArrayBox & mult(const NodeFArrayBox &a_src, const Box &a_subbox, int a_srccomp, int a_destcomp, int a_numcomp=1)
Definition: NodeFArrayBox.H:1006
FArrayBox m_fab
Definition: NodeFArrayBox.H:1180
NodeFArrayBox & divide(Real a_r, int a_comp, int a_numcomp=1)
Definition: NodeFArrayBox.H:1066
void linearOut(void *a_buf, const Box &a_R, const Interval &a_comps) const
NodeFArrayBox & operator/=(Real a_r)
Definition: NodeFArrayBox.H:1044
void abs(int a_comp, int a_numcomp=1)
Definition: NodeFArrayBox.H:506
int maskLE(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
NodeFArrayBox & invert(Real a_r)
Definition: NodeFArrayBox.H:551
A wrapper for an FArrayBox to contain NODE-centered data.
Definition: NodeFArrayBox.H:87
FArrayBox & mult(Real a_r)