Chombo + EB + MF  3.2
BaseFabImplem.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 #include <utility>
12 #ifndef _BASEFABIMPLEM_H_
13 #define _BASEFABIMPLEM_H_
14 
15 #include "BaseFabMacros.H"
16 #include "CH_Timer.H"
17 #include "SliceSpec.H"
18 #include "MayDay.H"
19 #include "parstream.H"
20 #include "BoxIterator.H"
21 #include "NamespaceHeader.H"
22 
23 //
24 // BaseFab<Real> specializations
25 //
26 
27 template < > void BaseFab<Real>::define();
28 
29 template < > void BaseFab<Real>::undefine();
30 
31 template < > void BaseFab<Real>::setVal (Real val);
32 
33 template < > void BaseFab<int>::define();
34 
35 template < > void BaseFab<int>::undefine();
36 
37 template < > int BaseFab<int>::test();
38 
39 template <class T> int BaseFab<T>::testBoxAndComp()
40 {
41  MayDay::Warning("pretty minimal test");
43  BaseFab<T> blerg;
44  blerg.define(b, 1);
45 
46  if (blerg.nComp() != 1)
47  {
48  pout() << "ncomp busted" << endl;
49  return -2;
50  }
51  if (blerg.box() != b)
52  {
53  pout() << "box return busted" << endl;
54  return -2;
55  }
56  for (int idir = 0; idir < SpaceDim; idir++)
57  {
58  if (blerg.size()[idir] != 2)
59  {
60  pout() << "size busted" <<endl;
61  return -3;
62  }
63  }
64 
65  if (blerg.smallEnd() != IntVect::Zero)
66  {
67  pout() << "smallend busted" <<endl;
68  return -4;
69  }
70  if (blerg.bigEnd() != IntVect::Unit)
71  {
72  pout() << "bigend busted" <<endl;
73  return -5;
74  }
75  return 0;
76 }///
77 template <class T> int BaseFab<T>::test()
78 {
79  int retval = testBoxAndComp();
80  return retval;
81 }
82 
83 //
84 // Implementation.=====================================
85 //
86 template <class T> inline BaseFab<T>::BaseFab(BaseFab<T>&& a_in) noexcept
87  :m_domain(std::move(a_in.m_domain)),
88  m_nvar(a_in.m_nvar),
89  m_numpts(a_in.m_numpts),
90  m_truesize(a_in.m_truesize),
91  m_dptr(a_in.m_dptr),
92  m_aliased(a_in.m_aliased)
93 {
94  a_in.m_aliased=true;
95 }
96 
97 template <class T> inline BaseFab<T>& BaseFab<T>::operator=(BaseFab<T>&& a_in) noexcept
98 {
99  m_domain = std::move(a_in.m_domain);
100  m_nvar=a_in.m_nvar;
101  m_numpts=a_in.m_numpts;
102  std::swap(m_truesize,a_in.m_truesize);
103  std::swap(m_dptr,a_in.m_dptr);
104  std::swap(m_aliased,a_in.m_aliased);
105  return *this;
106 }
107 
108 template <class T> inline BaseFab<T>::BaseFab()
109  :
110  m_domain(Box()),
111  m_nvar(0),
112  m_numpts(0),
113  m_truesize(0),
114  m_dptr(0),
115  m_aliased(false)
116 {
117 }
118 
119 template <class T> inline BaseFab<T>::BaseFab(const Box& a_bx,
120  int a_n,
121  T* a_alias)
122  :
123  m_domain(a_bx),
124  m_nvar(a_n),
125  m_numpts(a_bx.numPts()),
126  m_truesize(a_bx.numPts() * a_n),
127  m_dptr(0),
128  m_aliased(false)
129 {
130  if (a_alias != NULL)
131  {
132  m_dptr = a_alias;
133  m_aliased = true;
134  }
135  else
136  {
137  define();
138  }
139 }
140 
141 template <class T> inline BaseFab<T>::BaseFab(const Interval& a_comps,
142  BaseFab<T>& a_original)
143  :
144  m_domain(a_original.m_domain),
145  m_nvar(a_comps.size()),
146  m_numpts(a_original.m_numpts),
147  m_truesize(a_original.m_numpts * m_nvar),
148  m_dptr(a_original.dataPtr(a_comps.begin())),
149  m_aliased(true)
150 {
151 }
152 
153 template <class T> inline BaseFab<T>::~BaseFab()
154 {
155  undefine();
156 }
157 
158 template <class T> void BaseFab<T>::resize(const Box& a_b,
159  int a_n,
160  T* a_alias)
161 {
162  // m_nvar = a_n;
163  // m_domain = a_b;
164  // m_numpts = m_domain.numPts();
165  //
166  // if (m_dptr == 0)
167  // {
168  // define();
169  // }
170  // else if (m_nvar*m_numpts > m_truesize)
171  // {
172  // undefine();
173  // define();
174  // }
175 
176  undefine();
177 
178  m_nvar = a_n;
179  m_domain = a_b;
180  m_numpts = m_domain.numPts();
181  m_truesize = m_numpts * m_nvar;
182 
183  if (a_alias != NULL)
184  {
185  m_dptr = a_alias;
186  m_aliased = true;
187  }
188  else
189  {
190  m_aliased = false;
191  define();
192  }
193 }
194 
195 template <class T> inline void BaseFab<T>::define(const Interval& a_comps,
196  BaseFab<T>& a_original)
197 {
198  undefine();
199 
200  m_domain = a_original.m_domain;
201  m_numpts = a_original.m_numpts;
202  m_truesize = a_original.m_numpts*a_comps.size();
203  m_nvar = a_comps.size();
204  m_dptr = a_original.dataPtr(a_comps.begin());
205  m_aliased = true;
206  // resize(a_original.m_domain, a_comps.size(),
207  // a_original.dataPtr(a_comps.begin()));
208 }
209 
210 #ifdef USE_PROTO
211 template < class T>
212 template<unsigned int C>
213 void BaseFab<T>::define(Proto::BoxData<T,C,1,1>& a_original)
214 {
215  undefine();
216  m_domain = getBox(a_original.box());
217  m_numpts = a_original.box().size();
218  m_truesize = a_original.size();
219  m_nvar = C;
220  m_dptr = &a_original(a_original.box().low());
221  m_aliased = true;
222 }
223 #endif
224 
225 template <class T> inline void BaseFab<T>::clear()
226 {
227  undefine();
228 
229  m_domain = Box();
230  m_nvar = 0;
231  m_numpts = 0;
232 }
233 
234 template <class T> inline int BaseFab<T>::nComp() const
235 {
236  return m_nvar;
237 }
238 
239 template <class T> Arena* BaseFab<T>::s_Arena = NULL;
240 
241 template <class T> inline const Box& BaseFab<T>::box() const
242 {
243  return m_domain;
244 }
245 
246 template <class T> inline IntVect BaseFab<T>::size() const
247 {
248  return m_domain.size();
249 }
250 
251 template <class T> inline const IntVect& BaseFab<T>::smallEnd() const
252 {
253  return m_domain.smallEnd();
254 }
255 
256 template <class T> inline const IntVect& BaseFab<T>::bigEnd() const
257 {
258  return m_domain.bigEnd();
259 }
260 
261 template <class T> inline T& BaseFab<T>::operator () (const IntVect& a_p,
262  int a_n)
263 {
264  CH_assert(a_n >= 0);
265  CH_assert(a_n < m_nvar);
266  CH_assert(!(m_dptr == 0));
267  CH_assert(m_domain.contains(a_p));
268 
269  long int ind1 = m_domain.index(a_p);
270  long int ind2 = a_n * m_numpts;
271  long int ind = ind1 + ind2;
272 
273  return m_dptr[ind];
274 }
275 
276 template <class T> inline T& BaseFab<T>::operator () (const IntVect& a_p)
277 {
278  CH_assert(!(m_dptr == 0));
279  CH_assert(m_domain.contains(a_p));
280 
281  return m_dptr[m_domain.index(a_p)];
282 }
283 
284 template <class T> inline const T& BaseFab<T>::operator () (const IntVect& a_p,
285  int a_n) const
286 {
287  CH_assert(a_n >= 0);
288  CH_assert(a_n < m_nvar);
289  CH_assert(!(m_dptr == 0));
290  CH_assert(m_domain.contains(a_p));
291 
292  return m_dptr[m_domain.index(a_p) + a_n * m_numpts];
293 }
294 
295 template <class T> inline const T& BaseFab<T>::operator () (const IntVect& a_p) const
296 {
297  CH_assert(!(m_dptr == 0));
298  CH_assert(m_domain.contains(a_p));
299 
300  return m_dptr[m_domain.index(a_p)];
301 }
302 
303 template <class T> inline void BaseFab<T>::getVal(T* a_data,
304  const IntVect& a_pos,
305  int a_n,
306  int a_numcomp) const
307 {
308  const int loc = m_domain.index(a_pos);
309  const long size = m_domain.numPts();
310 
311  CH_assert(!(m_dptr == 0));
312  CH_assert(a_n >= 0 && a_n + a_numcomp <= m_nvar);
313 
314  for (int k = 0; k < a_numcomp; k++)
315  {
316  a_data[k] = m_dptr[loc+(a_n+k)*size];
317  }
318 }
319 
320 template <class T> inline void BaseFab<T>::getVal(T* a_data,
321  const IntVect& a_pos) const
322 {
323  getVal(a_data,a_pos,0,m_nvar);
324 }
325 
326 template <class T> inline const int* BaseFab<T>::loVect() const
327 {
328  return m_domain.loVect();
329 }
330 
331 template <class T> inline const int* BaseFab<T>::hiVect() const
332 {
333  return m_domain.hiVect();
334 }
335 
336 template <class T> inline const int* BaseFab<T>::nCompPtr() const
337 {
338  CH_assert(!(m_dptr == 0));
339 
340  return &m_nvar;
341 }
342 
343 template <class T> inline T* BaseFab<T>::dataPtr(int a_n)
344 {
345  CH_assert(!(m_dptr == 0));
346  CH_assert((a_n >= 0) && (a_n < m_nvar));
347 
348  return &m_dptr[a_n * m_numpts];
349 }
350 
351 template <class T> inline const T* BaseFab<T>::dataPtr(int a_n) const
352 {
353  CH_assert(!(m_dptr == 0));
354  CH_assert((a_n >= 0) && (a_n < m_nvar));
355 
356  return &m_dptr[a_n * m_numpts];
357 }
358 
359 template <class T> inline bool BaseFab<T>::contains(const BaseFab<T>& a_fab) const
360 {
361  return box().contains(a_fab.box()) && m_nvar <= a_fab.m_nvar;
362 }
363 
364 template <class T> inline bool BaseFab<T>::contains (const Box& a_bx) const
365 {
366  return box().contains(a_bx);
367 }
368 
369 template <class T> inline void BaseFab<T>::setVal(T a_x,
370  const Box& a_bx,
371  int a_nstart,
372  int a_numcomp)
373 {
374  performSetVal(a_x,a_bx,a_nstart,a_numcomp);
375 }
376 
377 template <class T> inline void BaseFab<T>::setVal(T a_x,
378  const Box& a_bx,
379  int a_n)
380 {
381  performSetVal(a_x,a_bx,a_n,1);
382 }
383 
384 template <class T> inline void BaseFab<T>::setVal(T a_x,
385  int a_n)
386 {
387  performSetVal(a_x,m_domain,a_n,1);
388 }
389 
390 template <class T> inline void BaseFab<T>::setVal(T a_x)
391 {
392  performSetVal(a_x,box(),0,m_nvar);
393 }
394 
395 template <class T>
397  const Box& a_srcbox,
398  int a_srccomp,
399  const Box& a_destbox,
400  int a_destcomp,
401  int a_numcomp)
402 {
403  CH_assert(a_srcbox.sameSize(a_destbox));
404  CH_assert(a_src.box().contains(a_srcbox));
405  CH_assert(m_domain.contains(a_destbox));
406  CH_assert(a_srccomp >= 0 && a_srccomp+a_numcomp <= a_src.nComp());
407  CH_assert(a_destcomp >= 0 && a_destcomp+a_numcomp <= m_nvar);
408 
409  performCopy(a_src,a_srcbox,a_srccomp,a_destbox,a_destcomp,a_numcomp);
410 
411  return *this;
412 }
413 
414 template <class T>
416  int a_srccomp,
417  int a_destcomp,
418  int a_numcomp)
419 {
420  CH_assert(a_srccomp >= 0 && a_srccomp + a_numcomp <= a_src.m_nvar);
421  CH_assert(a_destcomp >= 0 && a_destcomp + a_numcomp <= m_nvar);
422 
423  Box overlap(m_domain);
424  overlap &= a_src.m_domain;
425 
426  if (!overlap.isEmpty())
427  {
428  performCopy(a_src,overlap,a_srccomp,overlap,a_destcomp,a_numcomp);
429  }
430 
431  return *this;
432 }
433 
434 template <class T>
436  const Box& a_destbox)
437 {
438  CH_assert(m_nvar <= a_src.m_nvar);
439  CH_assert(m_domain.contains(a_destbox));
440 
441  Box overlap(a_destbox);
442  overlap &= a_src.m_domain;
443 
444  if (!overlap.isEmpty())
445  {
446  performCopy(a_src,overlap,0,overlap,0,m_nvar);
447  }
448 
449  return *this;
450 }
451 
452 template <class T>
454 {
455  CH_assert(m_nvar <= a_src.m_nvar);
456  CH_assert(m_domain.sameType(a_src.m_domain));
457 
458  Box overlap(m_domain);
459  overlap &= a_src.m_domain;
460 
461  if (!overlap.isEmpty())
462  {
463  performCopy(a_src,overlap,0,overlap,0,m_nvar);
464  }
465 
466  return *this;
467 }
468 
469 template <class T> inline void BaseFab<T>::copy(const Box& a_RegionFrom,
470  const Interval& a_Cdest,
471  const Box& a_RegionTo,
472  const BaseFab<T>& a_src,
473  const Interval& a_Csrc)
474 {
475  if ((this == &a_src) && (a_RegionFrom == a_RegionTo) && (a_Cdest == a_Csrc) )
476  {
477  return;
478  }
479 
480  CH_assert(a_Cdest.size() == a_Csrc.size());
481 
482  copy(a_src, a_RegionFrom, a_Csrc.begin(), a_RegionTo,
483  a_Cdest.begin(), a_Cdest.size());
484 }
485 
486 template <class T> inline BaseFab<T>& BaseFab<T>::shift(const IntVect& a_v)
487 {
488  m_domain += a_v;
489 
490  return *this;
491 }
492 
493 template <class T> inline BaseFab<T>& BaseFab<T>::shift(int a_idir,
494  int a_ncells)
495 {
496  m_domain.shift(a_idir,a_ncells);
497 
498  return *this;
499 }
500 
501 template <class T> inline BaseFab<T> & BaseFab<T>::shiftHalf(int a_idir,
502  int a_numHalfs)
503 {
504  m_domain.shiftHalf(a_idir,a_numHalfs);
505 
506  return *this;
507 }
508 
509 template <class T> inline BaseFab<T> & BaseFab<T>::shiftHalf(const IntVect& a_v)
510 {
511  m_domain.shiftHalf(a_v);
512 
513  return *this;
514 }
515 
516 template <class T> inline size_t BaseFab<T>::size(const Box& a_box,
517  const Interval& a_comps) const
518 {
519  return a_box.numPts() * (sizeof(T) * a_comps.size());
520 }
521 
522 template <class T> inline void BaseFab<T>::linearOut(void* a_buf,
523  const Box& a_R,
524  const Interval& a_comps) const
525 {
526  linearOut2(a_buf, a_R, a_comps);
527 }
528 template <class T> inline void* BaseFab<T>::linearOut2(void* a_buf,
529  const Box& a_R,
530  const Interval& a_comps) const
531 {
532  T* buffer = (T*)a_buf;
533 
534  ForAllThisCBNN(T,a_R,a_comps.begin(),a_comps.size())
535  {
536  *buffer = thisR;
537  ++buffer;
538  } EndFor;
539  return (void*)buffer;
540 }
541 
542 template <class T> inline void BaseFab<T>::linearIn(void* a_buf,
543  const Box& a_R,
544  const Interval& a_comps)
545 {
546  // pout() << "basefab::linearin box = " << a_R << "comps = (" << a_comps.begin() << "," << a_comps.end() << ")" << endl;
547  linearIn2(a_buf, a_R, a_comps);
548 }
549 
550 template <class T> inline void* BaseFab<T>::linearIn2(void* a_buf,
551  const Box& a_R,
552  const Interval& a_comps)
553 {
554  T* buffer = (T*)a_buf;
555 
556  ForAllThisBNN(T,a_R,a_comps.begin(),a_comps.size())
557  {
558  thisR = *buffer;
559  ++buffer;
560  } EndFor;
561 
562  return (void*) buffer;
563 }
564 
565 // ---------------------------------------------------------
566 // this is for broadcast & gather; the Box is in the msg
567 template <class T> inline void BaseFab<T>::linearOut(void* a_outBuf) const
568 {
569  char * bufptr = static_cast<char*>(a_outBuf) ;
570 
571  CH_XD::linearOut( bufptr ,m_domain );
572  bufptr += CH_XD::linearSize(m_domain);
573 
574  CH_XD::linearOut( bufptr ,m_nvar );
575  bufptr += sizeof(int) ;
576 
577  linearOut( bufptr ,m_domain ,interval() );
578 }
579 
580 // ---------------------------------------------------------
581 // this is for broadcast & gather; the Box is in the msg
582 template <class T> inline void BaseFab<T>::linearIn(const void* const a_buf)
583 {
584  // first get the box, then the number of components, then the data
585  char * bufptr = static_cast<char*>(const_cast<void*>(a_buf)) ;
586 
587  CH_XD::linearIn( m_domain ,bufptr );
588  bufptr += CH_XD::linearSize( m_domain );
589 
590  int ncomps;
591  CH_XD::linearIn( ncomps ,bufptr );
592  bufptr += sizeof( ncomps );
593 
594  resize(m_domain, ncomps);
595 
596  // Tried calling:
597  // linearIn( bufptr, m_domain, Interval( 0,ncomps-1 ) );
598  // but it crashed with OPT setting.
599  // So we use BoxIterator instead.
600  T* buffer = (T*)bufptr;
601  for (int icomp = 0; icomp < ncomps; icomp++)
602  {
603  for (BoxIterator bit(m_domain); bit.ok(); ++bit)
604  {
605  IntVect iv = bit();
606  (*this)(iv, icomp) = *buffer;
607  ++buffer;
608  }
609  }
610 
611  // ForAllThisBNN(T,m_domain,0,ncomps)
612  // {
613  // thisR = *buffer;
614  // ++buffer;
615  // } EndFor;
616  // return (void*) buffer;
617 }
618 
619 // ---------------------------------------------------------
620 // this is for broadcast & gather; the Box is in the msg
621 template <class T> inline int BaseFab<T>::linearSize( ) const
622 { // the linearization contains the Box, #components, and data
623  return CH_XD::linearSize(m_domain) + sizeof(int) + size(m_domain, interval());
624 }
625 
626 template <class T> inline void BaseFab<T>::define()
627 {
628  CH_assert(m_nvar > 0);
629  CH_assert(m_dptr == 0);
630  // CH_assert(m_numpts > 0); // OK if box is empty
631  CH_assert(!m_aliased);
632  //CH_assert(!(The_FAB_Arena == 0));// not a sufficient test !!!
633 
634 #ifdef CH_USE_MEMORY_TRACKING
635  if (s_Arena == NULL)
636  {
637  s_Arena = new BArena(name().c_str());
638  }
639 #else
640  if (s_Arena == NULL)
641  {
642  s_Arena = new BArena("");
643  }
644 #endif
645 
646  if (s_Arena == NULL)
647  {
648  MayDay::Error("malloc in basefab failed");
649  }
650 
651  m_truesize = m_nvar * m_numpts;
652  if (m_truesize > 0)
653  {
654  m_dptr = static_cast<T*>(s_Arena->alloc(m_truesize * sizeof(T)));
655 
656 #ifdef CH_USE_MEMORY_TRACKING
657  ch_memcount+=m_truesize * sizeof(T) + sizeof(BaseFab<T>);
658  s_Arena->bytes += m_truesize * sizeof(T) + sizeof(BaseFab<T>);
659  CH_assert(s_Arena->bytes > 0);
660  if (s_Arena->bytes > s_Arena->peak)
661  {
662  s_Arena->peak = s_Arena->bytes;
663  }
664 #endif
665  }
666  else
667  { // m_truesize == 0: allocating no space
668  m_dptr = NULL;
669  }
670 
671  //
672  // Now call T::T() on the raw memo'ry so we have valid Ts.
673  //
674  T* ptr = m_dptr;
675 
676  for (long int i = 0; i < m_truesize; i++, ptr++)
677  {
678  new (ptr) T;
679  }
680 }
681 
682 template <class T> inline void BaseFab<T>::undefine()
683 {
684  //CH_assert(!(The_FAB_Arena == 0));
685  //
686  // Call T::~T() on the to-be-destroyed memory.
687  //
688  if (m_aliased)
689  {
690  m_dptr = 0;
691  return;
692  }
693 
694  if (m_dptr == 0)
695  {
696  return;
697  }
698 
699  T* ptr = m_dptr;
700 
701  for (long int i = 0; i < m_truesize; i++, ptr++)
702  {
703  ptr->~T();
704  }
705 
706  s_Arena->free(m_dptr);
707 
708 #ifdef CH_USE_MEMORY_TRACKING
709  ch_memcount -= m_truesize * sizeof(T) + sizeof(BaseFab<T>);
710  s_Arena->bytes -= m_truesize * sizeof(T) + sizeof(BaseFab<T>);
711  CH_assert(s_Arena->bytes >= 0);
712 #endif
713 
714  m_dptr = 0;
715 }
716 
717 template <class T> inline std::string BaseFab<T>::name()
718 {
719  std::string rtn = (typeid(T)).name();
720 
721  return rtn;
722 }
723 
724 template <class T>
725 inline void BaseFab<T>::performCopy(const BaseFab<T>& a_src,
726  const Box& a_srcbox,
727  int a_srccomp,
728  const Box& a_destbox,
729  int a_destcomp,
730  int a_numcomp)
731 {
732  CH_assert(a_src.box().contains(a_srcbox));
733  CH_assert(box().contains(a_destbox));
734  CH_assert(a_destbox.sameSize(a_srcbox));
735  CH_assert(a_srccomp >= 0 && a_srccomp + a_numcomp <= a_src.nComp());
736  CH_assert(a_destcomp >= 0 && a_destcomp + a_numcomp <= nComp());
737  // CH_TIME("BaseFab::performCopy")
738  ForAllThisBNNXCBN(T, a_destbox, a_destcomp, a_numcomp, a_src, a_srcbox, a_srccomp)
739  {
740  thisR = a_srcR;
741  } EndForTX
742 }
743 
744 template <class T> inline void BaseFab<T>::performSetVal(T a_x,
745  const Box& a_bx,
746  int a_nstart,
747  int a_numcomp)
748 {
749  CH_assert(m_domain.contains(a_bx));
750  CH_assert(a_nstart >= 0 && a_nstart + a_numcomp <= m_nvar);
751 
752  if (a_bx == m_domain)
753  {
754  T* data = &m_dptr[a_nstart * m_numpts];
755 
756  for (long i = 0, N = a_numcomp * m_numpts; i < N; i++)
757  {
758  *data++ = a_x;
759  }
760  }
761  else
762  {
763  ForAllThisBNN(T,a_bx,a_nstart,a_numcomp)
764  {
765  thisR = a_x;
766  } EndFor
767  }
768 }
769 
770 template <class T>
772 {
773  return m_aliased;
774 }
775 
776 template <class T> void
778  const SliceSpec& a_sliceSpec ) const
779 {
780  bool outofbounds;
781  Box degenerateBox;
782  this->box().degenerate( degenerateBox, a_sliceSpec, &outofbounds );
783  if ( outofbounds )
784  {
785  MayDay::Error( "Tried to slice out-of-bounds." );
786  }
787  a_slice.define( degenerateBox, this->nComp() );
788  a_slice.copy( *this, degenerateBox );
789 }
790 
791 #include "NamespaceFooter.H"
792 
793 #endif
int linearSize(void) const
Definition: BaseFabImplem.H:621
std::ostream & pout()
Use this in place of std::cout for program output.
bool ok()
Definition: BoxIterator.H:281
void clear()
Definition: BaseFabImplem.H:225
const int * loVect() const
{ Fortran interface functions}
Definition: BaseFabImplem.H:326
#define CH_assert(cond)
Definition: CHArray.H:37
void setVal(T a_x, const Box &a_bx, int a_nstart, int a_numcomp)
{ data modification functions}
Definition: BaseFabImplem.H:369
bool contains(const BaseFab< T > &a_fab) const
{ comparison functions}
Definition: BaseFabImplem.H:359
virtual ~BaseFab()
Definition: BaseFabImplem.H:153
BaseFab< T > & shift(const IntVect &a_v)
{ domain modification functions}
Definition: BaseFabImplem.H:486
virtual void linearIn(void *a_buf, const Box &a_R, const Interval &a_comps)
Definition: BaseFabImplem.H:542
Definition: SliceSpec.H:41
static std::string name()
Definition: BaseFabImplem.H:717
Box m_domain
Definition: BaseFab.H:612
iterates through the IntVects of a Box
Definition: BoxIterator.H:37
int m_nvar
Definition: BaseFab.H:613
int size() const
Definition: Interval.H:75
virtual void linearOut(void *a_buf, const Box &a_R, const Interval &a_comps) const
Definition: BaseFabImplem.H:522
A Concrete Class for Dynamic Memory Management.
Definition: Arena.H:124
BaseFab< T > & operator=(BaseFab< T > &&) noexcept
move assignment
Definition: BaseFabImplem.H:97
const int SpaceDim
Definition: SPACE.H:38
BaseFab()
Definition: BaseFabImplem.H:108
const IntVect & smallEnd() const
Definition: BaseFabImplem.H:251
int nComp() const
{ accessors}
Definition: BaseFabImplem.H:234
Definition: EBInterface.H:45
void const char const int const int const int const Real const Real const int const Real const int const Real Real * C
Definition: Lapack.H:83
BaseFab< T > & shiftHalf(int a_dir, int a_numHalfs)
Definition: BaseFabImplem.H:501
bool isAliased() const
Definition: BaseFabImplem.H:771
Structure for passing component ranges in code.
Definition: Interval.H:23
static const IntVect Unit
Definition: IntVect.H:663
const char * name(const FArrayBox &a_dummySpecializationArg)
Definition: CH_HDF5.H:864
void linearOut(void *const a_outBuf, const T &inputT)
Definition: SPMDI.H:33
virtual void define(const Box &a_box, int a_comps, T *a_alias=NULL)
Definition: BaseFab.H:204
A Virtual Base Class for Dynamic Memory Managemen.
Definition: Arena.H:40
double Real
Definition: REAL.H:33
void define()
Definition: BaseFabImplem.H:626
virtual void performCopy(const BaseFab< T > &a_src, const Box &a_srcbox, int a_srccomp, const Box &a_destbox, int a_destcomp, int a_numcomp)
Definition: BaseFabImplem.H:725
BaseFab< T > & copy(const BaseFab< T > &a_src, const Box &a_srcbox, int a_srccomp, const Box &a_destbox, int a_destcomp, int a_numcomp)
Definition: BaseFabImplem.H:396
int linearSize(const T &inputT)
Definition: SPMDI.H:21
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code.
int begin() const
Definition: Interval.H:99
bool isEmpty() const
{ Comparison Functions}
Definition: Box.H:1862
const int * hiVect() const
Definition: BaseFabImplem.H:331
Definition: BaseFab.H:80
T * dataPtr(int a_n=0)
Definition: BaseFabImplem.H:343
static const IntVect Zero
Definition: IntVect.H:658
virtual void * linearOut2(void *a_buf, const Box &a_R, const Interval &a_comps) const
Same as linearOut, but returns the current location in the buffer.
Definition: BaseFabImplem.H:528
T *__restrict m_dptr
Definition: BaseFab.H:617
static void Warning(const char *const a_msg=m_nullString)
Print out message to cerr and continue.
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
bool m_aliased
Definition: BaseFab.H:618
size_t numPts() const
bool sameSize(const Box &b) const
Definition: Box.H:1912
bool contains(const IntVect &p) const
Definition: Box.H:1887
const int * nCompPtr() const
Definition: BaseFabImplem.H:336
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
void getVal(T *a_data, const IntVect &a_pos, int a_N, int a_numcomp) const
Definition: BaseFabImplem.H:303
T & operator()(const IntVect &a_p, int a_N)
Definition: BaseFabImplem.H:261
void const char const int const int * N
Definition: Lapack.H:83
void resize(const Box &a_b, int a_n=1, T *a_alias=NULL)
Definition: BaseFabImplem.H:158
void undefine()
Definition: BaseFabImplem.H:682
static int testBoxAndComp()
regression test
Definition: BaseFabImplem.H:39
void performSetVal(T a_x, const Box &a_bx, int a_nstart, int a_numcomp)
Definition: BaseFabImplem.H:744
static int test()
regression test
Definition: BaseFabImplem.H:77
void linearIn(T &a_outputT, const void *const inBuf)
Definition: SPMDI.H:27
virtual void * linearIn2(void *a_buf, const Box &a_R, const Interval &a_comps)
same as linearIn, but returns the current location in the buffer
Definition: BaseFabImplem.H:550
IntVect size() const
Definition: BaseFabImplem.H:246
void degenerate(BaseFab< T > &a_slice, const SliceSpec &a_sliceSpec) const
Definition: BaseFabImplem.H:777
long m_numpts
Definition: BaseFab.H:614
const IntVect & bigEnd() const
Definition: BaseFabImplem.H:256
const Box & box() const
Definition: BaseFabImplem.H:241