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