Chombo + EB + MF  3.2
FArrayBox.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 #ifndef _FARRAYBOX_H_
12 #define _FARRAYBOX_H_
13 
14 #ifndef WRAPPER
15 #include <iostream>
16 
17 // #include <Pointers.H>
18 #include "Box.H"
19 #include "BaseFab.H"
20 #endif
21 
22 #include "REAL.H"
23 #include "SPACE.H"
24 #include "NamespaceHeader.H"
25 
26 
27 ///
28 /**
29  Fortran Array Boxes (generally called FABs) are objects constructed
30  to interface with arrays in Fortran. Useful operations can be performed
31  upon FABs in C++, and they provide a convenient interface to
32  Fortran when it is necessary to retreat into that language for
33  doing arithmetic operations when performance matters.
34 
35  FArrayBox is derived from BaseFab<Real>.
36  FArrayBox adds additional useful capabilities which make sense
37  for Real types, such as I/O and L**p norms.
38 
39  The C pre-processor macro `CH_SPACEDIM' must be defined to use
40  this class. The internal precision of FArrayBox objects is
41  set by defining either `CH_USE_FLOAT' or `CH_USE_DOUBLE'
42 
43  This class does NOT provide a copy constructor or assignment operator.
44 */
45 class FArrayBox: public BaseFab<Real>
46 {
47 public:
48 
49  ///
50  /**
51  Constructs an invalid FArrayBox with no memory.
52  */
53  FArrayBox ();
54 
55  ///
56  /**
57  Constructs an initial FArrayBox with the data space allocated but not
58  inititialized. a_ncomp is the number of components (variables) at each
59  data point in the Box.
60  */
61  FArrayBox(const Box& a_box,
62  int a_ncomp,
63  Real* a_alias);
64 
65  #ifdef USE_PROTO
66  template<unsigned int C>
67  FArrayBox(const Proto::BoxData<Real, C>& a_bd)
68  : BaseFab<Real>(a_bd)
69  {
70  }
71 
72  template<unsigned int C>
73  FArrayBox(const Proto::BoxData<Real, C>& a_bd, Proto::Point a_center)
74  : BaseFab<Real>(a_bd, a_center)
75  {
76  }
77  #endif
78 
79  FArrayBox(const Box& a_box,
80  int a_ncomp);
81  ///
82  /**
83  Construct an aliaed FArrayBox. See BaseFab class for details.
84  */
85  FArrayBox(const Interval& a_comps,
86  FArrayBox& a_original)
87  :
88  BaseFab<Real>(a_comps, a_original)
89  {}
90 
91  ///
92  /**
93  Defines FArrayBox with the data space allocated but not
94  inititialized. a_ncomp is the number of components (variables) at each
95  data point in the Box.
96  */
97  virtual void define(const Box& a_box,
98  int a_ncomp,
99  Real* a_alias = NULL)
100  {
101  BaseFab<Real>::define(a_box, a_ncomp, a_alias);
102  }
103 
104  ///
105  /**
106  The (virtual) destructor.
107  */
108  virtual ~FArrayBox ();
109 
110  ///
111  /**
112  Constructs an 'aliased' BaseFab of the requested interval of the
113  argument BaseFab. This BaseFab does not allocate any memory, but
114  sets its data pointer into the memory pointed to by the argument
115  BaseFab. It is the users responsiblity to ensure this aliased
116  BaseFab is not used after the original BaseFab has deleted its data ptr
117  (resize, define(..) called, or destruction, etc.).
118 
119  This aliased BaseFab will also generate side effects (modifying the values
120  of data in one will modify the other's data).
121 
122  This aliased BaseFab will have a_comps.size() components, starting at zero.
123  */
124  virtual void define(const Interval& a_comps,
125  FArrayBox& a_original)
126  {
127  BaseFab<Real>::define(a_comps, a_original);
128  }
129 
130  ///
131  /**
132  * This is here only to make the Intel compiler stop warning about
133  * partial override.
134  */
135  virtual void define(const Interval& a_comps,
136  BaseFab<Real>& a_original)
137  {
138  BaseFab<Real>::define(a_comps, a_original);
139  }
140 
141  ///
142  /** override resize. I'm going to try and get rid of this function in the future (bvs)
143  */
144  virtual void resize(const Box& a_box,
145  int a_comps,
146  Real* a_alias = NULL)
147  {
148  BaseFab<Real>::resize(a_box, a_comps, a_alias);
149  }
150  ///
151  /**
152  Constructs FArrayBox by reading it from istream.
153  */
154  explicit FArrayBox(std::istream& a_is);
155 
156  ///
157  /**
158  Returns the Lp-norm of this FAB using components
159  (a_comp : a_comp+a_numcomp-1) and within the a_subbox.
160  a_p < 0 -> ERROR
161  a_p = 0 -> infinity norm (max norm)
162  a_p = 1 -> sum of ABS(FAB)
163  a_p > 1 -> Lp-norm
164  */
165  virtual Real norm(const Box& a_subbox,
166  int a_p = 2,
167  int a_comp = 0,
168  int a_numcomp = 1) const;
169 
170  ///
171  /**
172  Returns the Lp-norm of this FAB using components
173  (a_comp : a_comp+a_numcomp-1).
174  a_p < 0 -> ERROR
175  a_p = 0 -> infinity norm (max norm)
176  a_p = 1 -> sum of ABS(FAB)
177  a_p > 1 -> Lp-norm
178  */
179  virtual Real norm(int a_p = 2,
180  int a_comp = 0,
181  int a_numcomp = 1) const;
182 
183  ///
184  /**
185  Returns sum of pow(fab[i,c],p): i in a_subbox, a_comp <= c <
186  a_comp+a_numcomp, a_p >= 2 only
187  */
188  virtual Real sumPow(const Box& a_subbox,
189  int a_p = 2,
190  int a_comp = 0,
191  int a_numcomp = 1) const;
192 
193  /// Return the dot product of this FArrayBox with another
194  /**
195  Return the dot product of this FArrayBox and "a_fab2" over their common
196  box and all components.
197  */
198  Real dotProduct(const FArrayBox& a_fab2) const;
199 
200  /// Return the dot product of this FArrayBox with another
201  /**
202  Return the dot product of this FArrayBox and "a_fab2" over the
203  a_box box and all components.
204  */
205  Real dotProduct(const FArrayBox& a_fab2, const Box& a_box) const;
206 
207  ///
208  /**
209  Returns the minimum value of given component of this FArrayBox.
210  */
211  Real min(int a_comp = 0) const;
212 
213  ///
214  /**
215  Returns the minimum value of given component of this FArrayBox in
216  given a_subbox.
217 
218  */
219  Real min(const Box& a_subbox,
220  int a_comp = 0) const;
221 
222  ///
223  /**
224  Returns the maximum value of given component of this FArrayBox.
225  */
226  Real max(int a_comp = 0) const;
227 
228  ///
229  /**
230  Returns the maximum value of given component of this FArrayBox in
231  given a_subbox.
232 
233  */
234  Real max(const Box& a_subbox,
235  int a_comp = 0) const;
236 
237  ///
238  /**
239  Finds location of minimum value in given component of this FArrayBox.
240  */
241  IntVect minIndex(int a_comp = 0) const;
242 
243  ///
244  /**
245  Returns location of minimum value in given component of this FArrayBox
246  in given a_subbox.
247  */
248  IntVect minIndex(const Box& a_subbox,
249  int a_comp = 0) const;
250 
251  ///
252  /**
253  Returns location of maximum value in given component of this FArrayBox.
254  */
255  IntVect maxIndex(int a_comp = 0) const;
256 
257  ///
258  /**
259  Returns location of maximum value in given component of this FArrayBox
260  in given a_subbox.
261  */
262  IntVect maxIndex(const Box& a_subbox,
263  int a_comp = 0) const;
264 
265  ///
266  /**
267  Computes a_mask array with value of 1 in cells where this FArrayBox
268  has value less than a_val, 0 otherwise. a_mask is resized by this
269  function. The number of cells marked with 1 returned.
270  */
271  int maskLT(BaseFab<int>& a_mask,
272  Real a_val,
273  int a_comp = 0) const;
274 
275  ///
276  /**
277  Computes a_mask array with value of 1 in cells where this FArrayBox
278  has value less than or equal to a_val, 0 otherwise. a_mask is
279  resized by this function. The number of cells marked with 1
280  returned.
281  */
282  int maskLE(BaseFab<int>& a_mask,
283  Real a_val,
284  int a_comp = 0) const;
285  ///
286  /**
287  Computes a_mask array with value of 1 in cells where this FArrayBox
288  has value equal to a_val, 0 otherwise. a_mask is resized by this
289  function. The number of cells marked with 1 returned.
290 
291  */
292  int maskEQ(BaseFab<int>& a_mask,
293  Real a_val,
294  int a_comp = 0) const;
295  ///
296  /**
297  Computes a_mask array with value of 1 in cells where this FArrayBox
298  has value greater than a_val, 0 otherwise. a_mask is resized by this
299  function. The number of cells marked with 1 returned.
300  */
301  int maskGT(BaseFab<int>& a_mask,
302  Real a_val,
303  int a_comp = 0) const;
304 
305  ///
306  /**
307  Computes a_mask array with value of 1 in cells where this FArrayBox
308  has value greater than or equal to a_val, 0 otherwise. a_mask is
309  resized by this function. The number of cells marked with 1 returned.
310  */
311  int maskGE(BaseFab<int>& a_mask,
312  Real a_val,
313  int a_comp = 0) const;
314 
315 
316  ///
317  /**
318  Modifies this FArrayBox by replacing each value with its absolute value.
319  */
320  void abs();
321 
322  ///
323  /**
324  Modifies this FArrayBox by replacing each value with its absolute value,
325  for components (a_comp : a_comp+a_numcomp-1).
326  */
327  void abs(int a_comp,
328  int a_numcomp = 1);
329 
330  ///
331  /**
332  Modifies this FArrayBox by replacing eahc value with its absolute value,
333  for components (a_comp : a_comp+a_numcomp-1) and within the a_subbox.
334  */
335  void abs (const Box& a_subbox,
336  int a_comp = 0,
337  int a_numcomp = 1);
338 
339  ///
340  /**
341  Returns sum of given component of FArrayBox.
342  */
343  Real sum(int a_comp,
344  int a_numcomp = 1) const;
345 
346  ///
347  /**
348  Returns sum of component of this FArrayBox in given a_subbox.
349  */
350  Real sum(const Box& a_subbox,
351  int a_comp,
352  int a_numcomp = 1) const;
353 
354  ///
355  /**
356  Modifies this FArrayBox by replacing each value x with a_r/x.
357  */
358  FArrayBox& invert(Real a_r);
359 
360  ///
361  /**
362  Modifies this FArrayBox by replacing each value x with a_r/x. For
363  given range of components.
364  */
365  FArrayBox& invert(Real a_r,
366  int a_comp,
367  int a_numcomp = 1);
368 
369  ///
370  /**
371  Modifies this FArrayBox by replacing each value x with a_r/x. For
372  given range of components and within given a_subbox.
373  */
374  FArrayBox& invert(Real a_r,
375  const Box& a_subbox,
376  int a_comp = 0,
377  int a_numcomp = 1);
378 
379  ///
380  /**
381  Modifies this FArrayBox by replacing each value with its additive
382  inverse. For given range of components and within given a_subbox.
383  */
384  FArrayBox& negate(const Box& a_subbox,
385  int a_comp = 0,
386  int a_numcomp = 1);
387 
388  ///
389  /**
390  Modifies this FArrayBox by replacing each value with its additive
391  inverse. For given range of components.
392  */
393  FArrayBox& negate(int a_comp,
394  int a_numcomp = 1);
395 
396  ///
397  /**
398  Modifies this FArrayBox by replacing each value with its additive
399  inverse.
400  */
401  FArrayBox& negate();
402 
403  ///
404  /**
405  Modifies this FArrayBox by adding the scalar Real a_r to all values. For
406  given range of components and within given a_subbox.
407  */
408  FArrayBox& plus(Real a_r,
409  const Box& a_subbox,
410  int a_comp = 0,
411  int a_numcomp = 1);
412 
413  ///
414  /**
415  Modifies this FArrayBox by adding the scalar Real a_r to all values. For
416  given range of components.
417  */
418  FArrayBox& plus(Real a_r,
419  int a_comp,
420  int a_numcomp = 1);
421 
422  ///
423  /**
424  Modifies this FArrayBox by adding the scalar Real a_r to all values.
425  */
426  FArrayBox& operator += (Real a_r);
427 
428  ///
429  /**
430  Modifies this FArrayBox by pointwise addition of the values of the
431  argument FArrayBox. You might come to grief if the domains of the
432  FArrayBoxes don't match.
433  */
434  FArrayBox& operator += (const FArrayBox& a_x);
435 
436  ///
437  /**
438  Modifies this FArrayBox by adding the scalar Real a_r to all values.
439  */
440  FArrayBox& plus(Real a_r);
441 
442  FArrayBox& plus_real(Real a_r)
443  {
444  return this->plus(a_r);
445  }
446 
447  ///
448  /**
449  Modifies this FArrayBox by pointwise addition of the values of the
450  argument FArrayBox. You might come to grief if the domains of the
451  FArrayBoxes don't match. The same as += operator.
452 
453  */
454  FArrayBox& plus(const FArrayBox& a_x);
455 
456  ///
457  /**
458  Modifies this FArrayBox by pointwise scaled addition of the
459  argument FArrayBox (a[i] <- a[i] + a_scale * a_src[i]). Uses domain
460  of the intersection of these two FArrayBoxes.
461  */
462  FArrayBox& plus(const FArrayBox& a_src,
463  const Real& a_scale);
464 
465  ///
466  /**
467  Modifies this FArrayBox by pointwise scaled addition of the
468  argument FArrayBox (a[i] <- a[i] + a_scale * a_src[i]). Uses domain
469  of the intersection of these two FArrayBoxes.
470  */
471  FArrayBox& plus(const FArrayBox& a_src,
472  const Real& a_scale,
473  int a_srccomp,
474  int a_destcomp,
475  int a_numcomp = 1);
476 
477  ///
478  /**
479  Modifies this FArrayBox by pointwise addition of values in the argument
480  FArrayBox. Adds src's components (a_srccomp : a_srccomp+a_numcomp-1)
481  to this FArrayBox's components (a_destcomp : a_destcomp+a_numcomp-1)
482  where the domains of the two FArrayBoxes intersect.
483  */
484  FArrayBox& plus(const FArrayBox& a_src,
485  int a_srccomp,
486  int a_destcomp,
487  int a_numcomp = 1);
488 
489  ///
490  /**
491  Modifies this FArrayBox by pointwise addition of values in the argument
492  FArrayBox. Adds src's components (a_srccomp : a_srccomp+a_numcomp-1)
493  to this FArrayBox's components (a_destcomp : a_destcomp+numcomp-1)
494  where the domain of this FArrayBox intersects the a_subbox. NOTE:
495  a_subbox must be contained in this FAB.
496  */
497  FArrayBox& plus(const FArrayBox& a_src,
498  const Box& a_subbox,
499  int a_srccomp,
500  int a_destcomp,
501  int a_numcomp = 1);
502 
503  ///
504  /**
505  Modifies this FArrayBox by pointwise addition of values in the argument
506  FArrayBox. Adds src's components (a_srccomp : a_srccomp+a_numcomp-1)
507  in the Box a_srcbox to this FArrayBox's components (a_destcomp :
508  a_destcomp+a_numcomp-1) in the Box a_destbox. Corresponding locations
509  within the two FArrayBoxes are indexed relative to a_srcbox and a_destbox,
510  and will in general not be the same. The a_srcbox and a_destbox must be
511  same size. The results are UNDEFINED if the a_src and dest FArrayBoxes
512  are the same and the a_srcbox and a_destbox overlap.
513 
514  */
515  FArrayBox& plus(const FArrayBox& a_src,
516  const Box& a_srcbox,
517  const Box& a_destbox,
518  int a_srccomp,
519  int a_destcomp,
520  int a_numcomp = 1);
521 
522  ///
523  FArrayBox& plus(const FArrayBox& a_src,
524  const Box& a_srcbox,
525  const Box& a_destbox,
526  const Real& a_scale,
527  int a_srccomp,
528  int a_destcomp,
529  int a_numcomp = 1);
530 
531  ///
532  /**
533  Modifies this FArrayBox by subtracting the scalar Real a_r to all values.
534  Note: use plus(-a_r) for more general operations.
535  */
536  FArrayBox& operator -= (Real a_r);
537 
538  ///
539  /**
540  Modifies this FArrayBox by pointwise subtraction of the values of the
541  argument FArrayBox. You might come to grief if the domains of the
542  FArrayBoxes don't match.
543  */
544  FArrayBox& operator -= (const FArrayBox& a_x);
545 
546  ///
547  /**
548  Modifies this FArrayBox by pointwise subtraction of the values of the
549  argument FArrayBox. You might come to grief if the domains of the
550  FArrayBoxes don't match. The same as -= operator.
551  */
552  FArrayBox& minus(const FArrayBox& a_x);
553 
554  /**
555  Modifies this FArrayBox by pointwise subtraction of values in the
556  argument FArrayBox. Subtracts a_src's components (a_srccomp :
557  a_srccomp+a_numcomp-1) from this FArrayBox's components (a_destcomp :
558  a_destcomp+a_numcomp-1) where the domains of the two FArrayBoxes
559  intersect.
560  */
561  FArrayBox& minus(const FArrayBox& a_src,
562  int a_srccomp,
563  int a_destcomp,
564  int a_numcomp = 1);
565 
566  /**
567  Modifies this FArrayBox by pointwise subtraction of values in the
568  argument FArrayBox. Subtracts a_src's components (a_srccomp :
569  a_srccomp+a_numcomp-1) from this FArrayBox's components (a_destcomp :
570  a_destcomp+a_numcomp-1) where the domain of this FArrayBox intersects
571  the a_subbox. NOTE: a_subbox must be contained in this FAB.
572  */
573  FArrayBox& minus(const FArrayBox& a_src,
574  const Box& a_subbox,
575  int a_srccomp,
576  int a_destcomp,
577  int a_numcomp = 1);
578 
579  ///
580  /**
581  Modifies this FArrayBox by pointwise subtraction of values in the
582  argument FArrayBox. Subtracts a_src's components (a_srccomp :
583  a_srccomp+a_numcomp-1) in the Box a_srcbox from this FArrayBox's
584  components (a_destcomp : a_destcomp+a_numcomp-1) in the Box a_destbox.
585  Corresponding locations within the two FArrayBoxes are indexed relative
586  to a_srcbox and a_destbox, and will in general not be the same. The
587  a_srcbox and a_destbox must be same size. The results are UNDEFINED
588  if the a_src and dest FArrayBoxes are the same and the a_srcbox and
589  a_destbox overlap.
590  */
591  FArrayBox& minus(const FArrayBox& a_src,
592  const Box& a_srcbox,
593  const Box& a_destbox,
594  int a_srccomp,
595  int a_destcomp,
596  int a_numcomp = 1);
597 
598  ///
599  /**
600  Modifies this FArrayBox by multiplying all values by the scalar Real a_r.
601  */
602  FArrayBox& operator *= (Real a_r);
603 
604  ///
605  /**
606  Modifies this FArrayBox by multiplying all values by the scalar Real a_r.
607  */
608  FArrayBox& mult(Real a_r);
609 
610  ///
611  /**
612  Modifies this FArrayBox by multiplying all values by the scalar
613  Real a_r. For given range of components.
614  */
615  FArrayBox& mult(Real a_r,
616  int a_comp,
617  int a_numcomp = 1);
618 
619  ///
620  /**
621  Modifies this FArrayBox by multiplying all values by the scalar
622  Real a_r. For given range of components and within given a_subbox.
623  */
624  FArrayBox& mult(Real a_r,
625  const Box& a_subbox,
626  int a_comp = 0,
627  int a_numcomp = 1);
628 
629  ///
630  /**
631  Modifies this FArrayBox by pointwise multiplication of the values by the
632  argument FArrayBox. You might come to grief if the domains of the
633  FArrayBoxes don't match.
634  */
635  FArrayBox& operator *= (const FArrayBox& a_x);
636 
637  ///
638  /**
639  Modifies this FArrayBox by pointwise multiplication by the values in the
640  argument FArrayBox. You might come to grief if the domains of the
641  FArrayBoxes don't match. The same as the *= operator.
642  */
643  FArrayBox& mult(const FArrayBox& a_x);
644 
645  ///
646  /**
647  Modifies this FArrayBox by pointwise multiplication by values in the
648  argument FArrayBox. Multiplies a_src's components (a_srccomp :
649  a_srccomp+a_numcomp-1) by this FArrayBox's components (a_destcomp :
650  a_destcomp+a_numcomp-1) where the domains of the two FArrayBoxes
651  intersect.
652  */
653  FArrayBox& mult(const FArrayBox& a_src,
654  int a_srccomp,
655  int a_destcomp,
656  int a_numcomp = 1);
657 
658  ///
659  /**
660  Modifies this FArrayBox by pointwise multiplication by values in the
661  argument FArrayBox. Multiplies a_src's components (a_srccomp :
662  a_srccomp+a_numcomp-1) by this FArrayBox's components (a_destcomp :
663  a_destcomp+a_numcomp-1) where the domain of this FArrayBox intersects
664  the a_subbox. NOTE: a_subbox must be contained in this FAB.
665  */
666  FArrayBox& mult(const FArrayBox& a_src,
667  const Box& a_subbox,
668  int a_srccomp,
669  int a_destcomp,
670  int a_numcomp = 1);
671 
672  ///
673  /**
674  Modifies this FArrayBox by pointwise multiplication by values in the
675  argument FArrayBox. Multiplies a_src's components (a_srccomp :
676  a_srccomp+a_numcomp-1) in the Box a_srcbox by this FArrayBox's
677  components (a_destcomp : a_destcomp+a_numcomp-1) in the Box a_destbox.
678  Corresponding locations within the two FArrayBoxes are indexed relative
679  to a_srcbox and a_destbox, and will in general not be the same. The
680  a_srcbox and a_destbox must be same size. The results are UNDEFINED if
681  the a_src and dest FArrayBoxes are the same and the a_srcbox and a_destbox
682  overlap.
683  */
684  FArrayBox& mult(const FArrayBox& a_src,
685  const Box& a_srcbox,
686  const Box& a_destbox,
687  int a_srccomp,
688  int a_destcomp,
689  int a_numcomp = 1);
690 
691  ///
692  /**
693  Modifies this FArrayBox by dividing all values by the scalar Real a_r.
694  */
695  FArrayBox& operator /= (Real a_r);
696 
697  ///
698  /**
699  Modifies this FArrayBox by dividing all values by the scalar Real a_r.
700  */
701  FArrayBox& divide(Real a_r);
702 
703  ///
704  /**
705  Modifies this FArrayBox by dividing all values by the scalar Real a_r.
706  For given range of components.
707  */
708  FArrayBox& divide(Real a_r,
709  int a_comp,
710  int a_numcomp = 1);
711 
712  ///
713  /**
714  Modifies this FArrayBox by dividing all values by the scalar Real
715  a_r. For given range of components and within given a_subbox.
716  */
717  FArrayBox& divide(Real a_r,
718  const Box& a_subbox,
719  int a_comp = 0,
720  int a_numcomp = 1);
721 
722  ///
723  /**
724  Modifies this FArrayBox by pointwise division of the values by the
725  argument FArrayBox. You might come to grief if the domains of the
726  FArrayBoxes don't match.
727  */
728  FArrayBox& operator /= (const FArrayBox& a_x);
729 
730  ///
731  /**
732  Modifies this FArrayBox by pointwise division by the values in the
733  argument FArrayBox. You might come to grief if the domains of the
734  FArrayBoxes don't match. The same as the /= operator.
735  */
736  FArrayBox& divide(const FArrayBox& a_x);
737 
738  ///
739  /**
740  Modifies this FArrayBox by pointwise division by values in the argument
741  FArrayBox. Divides this FArrayBox's components (a_destcomp :
742  a_destcomp+a_numcomp-1) by a_src's components (a_srccomp :
743  a_srccomp+a_numcomp-1) where the domains of the two FArrayBoxes intersect.
744  */
745  FArrayBox& divide(const FArrayBox& a_src,
746  int a_srccomp,
747  int a_destcomp,
748  int a_numcomp = 1);
749 
750  ///
751  /**
752  Modifies this FArrayBox by pointwise division by values in the argument
753  FArrayBox. Divides this FArrayBox's components (a_destcomp :
754  a_destcomp+a_numcomp-1) by a_src's components (a_srccomp :
755  a_srccomp+a_numcomp-1) where the domain of this FArrayBox intersects
756  the a_subbox. NOTE: a_subbox must be contained in this FAB.
757  */
758  FArrayBox& divide(const FArrayBox& a_src,
759  const Box& a_subbox,
760  int a_srccomp,
761  int a_destcomp,
762  int a_numcomp = 1);
763 
764  ///
765  /**
766  Modifies this FArrayBox by pointwise division by values in the argument
767  FArrayBox. Divides this FArrayBox's components (a_destcomp :
768  a_destcomp+a_numcomp-1) in the Box a_destbox by a_src's components
769  (a_srccomp : a_srccomp+a_numcomp-1) in the Box a_srcbox. Corresponding
770  locations within the two FArrayBoxes are indexed relative to a_srcbox and
771  a_destbox, and will in general not be the same. The a_srcbox and
772  a_destbox must be same size. The results are UNDEFINED if the a_src and
773  dest FArrayBoxes are the same and the a_srcbox and a_destbox overlap.
774  */
775  FArrayBox& divide(const FArrayBox& a_src,
776  const Box& a_srcbox,
777  const Box& a_destbox,
778  int a_srccomp,
779  int a_destcomp,
780  int a_numcomp = 1);
781 
782  ///
783  Real get(const IntVect& a_iv,
784  int a_comp) const
785  {
786  return this->operator()(a_iv, a_comp);
787  }
788 
789  ///
790  void set(const IntVect& a_iv,
791  int a_comp,
792  Real a_val)
793  {
794  this->operator()(a_iv, a_comp) = a_val;
795  }
796 
797  //! Computes a_A * a_X + a_B * a_Y, placing the result in this FArrayBox.
798  FArrayBox& axby(const FArrayBox& a_X, const FArrayBox& a_Y,
799  Real a_A, Real a_B);
800 
801  //! Computes a_A * a_X + a_B * a_Y, placing the result in this FArrayBox.
802  //! This version performs this operation only for the given component
803  //! in each FArrayBox.
804  FArrayBox& axby(const FArrayBox& a_X, const FArrayBox& a_Y,
805  Real a_A, Real a_B,
806  int a_destComp, int a_xComp, int a_yComp);
807 
808 
809 
810  FArrayBox(FArrayBox&& a_in)=default;
811  FArrayBox& operator=(FArrayBox&& a_in)=default;
812 protected:
813  virtual void performCopy(const BaseFab<Real>& a_src,
814  const Box& a_srcbox,
815  int a_srccomp,
816  const Box& a_destbox,
817  int a_destcomp,
818  int a_numcomp);
819 
820 
821 private:
822  //
823  // These are disallowed.
824  //
825  //FArrayBox (const FArrayBox&);
826  //FArrayBox& operator = (const FArrayBox&);
827 };
828 
829 #include "NamespaceFooter.H"
830 #endif
FArrayBox & operator+=(Real a_r)
Real sum(int a_comp, int a_numcomp=1) const
int maskGT(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
Real dotProduct(const FArrayBox &a_fab2) const
Return the dot product of this FArrayBox with another.
FArrayBox & operator=(FArrayBox &&a_in)=default
FArrayBox & plus(Real a_r, const Box &a_subbox, int a_comp=0, int a_numcomp=1)
int maskEQ(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
FArrayBox & operator/=(Real a_r)
FArrayBox & invert(Real a_r)
void set(const IntVect &a_iv, int a_comp, Real a_val)
Definition: FArrayBox.H:790
FArrayBox & divide(Real a_r)
FArrayBox & axby(const FArrayBox &a_X, const FArrayBox &a_Y, Real a_A, Real a_B)
Computes a_A * a_X + a_B * a_Y, placing the result in this FArrayBox.
IntVect maxIndex(int a_comp=0) const
FArrayBox & negate()
Real min(int a_comp=0) const
virtual void resize(const Box &a_box, int a_comps, Real *a_alias=NULL)
Definition: FArrayBox.H:144
Structure for passing component ranges in code.
Definition: Interval.H:23
virtual void define(const Interval &a_comps, BaseFab< Real > &a_original)
Definition: FArrayBox.H:135
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
void define()
Definition: BaseFabImplem.H:672
int maskLT(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
FArrayBox & operator-=(Real a_r)
virtual ~FArrayBox()
FArrayBox & minus(const FArrayBox &a_x)
FArrayBox & operator*=(Real a_r)
IntVect minIndex(int a_comp=0) const
virtual void define(const Box &a_box, int a_ncomp, Real *a_alias=NULL)
Definition: FArrayBox.H:97
Definition: BaseFab.H:81
Real max(int a_comp=0) const
void abs()
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Real & operator()(const IntVect &a_p, int a_N)
virtual void define(const Interval &a_comps, FArrayBox &a_original)
Definition: FArrayBox.H:124
virtual void performCopy(const BaseFab< Real > &a_src, const Box &a_srcbox, int a_srccomp, const Box &a_destbox, int a_destcomp, int a_numcomp)
Definition: FArrayBox.H:45
FArrayBox & plus_real(Real a_r)
Definition: FArrayBox.H:442
void resize(const Box &a_b, int a_n=1, T *a_alias=NULL)
Definition: BaseFabImplem.H:173
FArrayBox(const Interval &a_comps, FArrayBox &a_original)
Definition: FArrayBox.H:85
virtual Real norm(const Box &a_subbox, int a_p=2, int a_comp=0, int a_numcomp=1) const
int maskLE(BaseFab< int > &a_mask, Real a_val, int a_comp=0) const
FArrayBox & mult(Real a_r)