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