chombo-discharge
CD_DataOpsImplem.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2021 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_DataOpsImplem_H
13 #define CD_DataOpsImplem_H
14 
15 // Chombo includes
16 #include <CH_Timer.H>
17 
18 // Our includes
19 #include <CD_NamespaceHeader.H>
20 
21 template <typename T>
22 void
23 DataOps::setValue(LevelData<MFInterfaceFAB<T>>& a_lhs, const T& a_value)
24 {
25  CH_TIME("DataOps::setValue");
26 
27  const DisjointBoxLayout& dbl = a_lhs.disjointBoxLayout();
28  const DataIterator& dit = dbl.dataIterator();
29 
30  const int nbox = dit.size();
31 
32 #pragma omp parallel for schedule(runtime)
33  for (int mybox = 0; mybox < nbox; mybox++) {
34  const DataIndex& din = dit[mybox];
35 
36  a_lhs[din].setVal(a_value);
37  }
38 }
39 
40 template <typename T>
41 int
42 DataOps::sgn(const T a_value)
43 {
44  return ((a_value > 0.0) - (a_value < 0.0));
45 }
46 
47 template <typename T>
48 void
49 DataOps::copy(EBAMRData<T>& a_dst, const EBAMRData<T>& a_src, const Interval a_dstInterv, const Interval a_srcInterv)
50 {
51  CH_TIME("DataOps::copy(EBAMRData)");
52 
53  CH_assert(a_dst.size() == a_src.size());
54  CH_assert(a_dstInterv.size() == a_srcInterv.size());
55 
56  for (int lvl = 0; lvl < a_dst.size(); lvl++) {
57  CH_assert(a_dst[lvl]->nComp() > a_dstInterv.end());
58  CH_assert(a_src[lvl]->nComp() > a_srcInterv.end());
59 
60  a_src[lvl]->localCopyTo(a_srcInterv, *a_dst[lvl], a_dstInterv);
61  }
62 }
63 
64 #include <CD_NamespaceFooter.H>
65 
66 #endif
static int sgn(const T a_value)
Sign function. Returns +/- if the value is > 0 or < 0.
Definition: CD_DataOpsImplem.H:42
static void setValue(LevelData< MFInterfaceFAB< T >> &a_lhs, const T &a_value)
Set value in an MFInterfaceFAB data holder.
Definition: CD_DataOpsImplem.H:23
static void copy(MFAMRCellData &a_dst, const MFAMRCellData &a_src)
Copy data from one data holder to another.
Definition: CD_DataOps.cpp:1118
Default class for holding LevelData<T> data across an EBAMR realm.
Definition: CD_EBAMRData.H:40
int size() const noexcept
Get size of m_data.
Definition: CD_EBAMRDataImplem.H:66
Class for holding BaseIVFAB<T> on the interface between two phases.
Definition: CD_MFInterfaceFAB.H:30