Peano
Loading...
Searching...
No Matches
CellData.cpph
Go to the documentation of this file.
2
3template<typename inType, typename outType>
5 inType* QIn_,
8 double t_,
9 double dt_,
10 outType* QOut_,
11 tarch::MemoryLocation memoryLocation_,
12 int targetDevice_
13):
14 CellData(1, memoryLocation_, targetDevice_) {
15 QIn[0] = QIn_;
16 cellCentre[0] = cellCentre_;
17 cellSize[0] = cellSize_;
18 t[0] = t_;
19 dt[0] = dt_;
20 QOut[0] = QOut_;
21 id[0] = -1;
22}
23
24template<typename inType, typename outType>
26 int numberOfCells_,
27 tarch::MemoryLocation memoryLocation_,
28 int targetDevice_
29):
30 numberOfCells(numberOfCells_),
31 memoryLocation(memoryLocation_),
32 targetDevice(targetDevice_) {
33 QIn = tarch::allocateMemory<inType*>(numberOfCells_, memoryLocation_, targetDevice_);
34 cellCentre = tarch::allocateMemory<tarch::la::Vector<Dimensions, double>>(numberOfCells_, memoryLocation_, targetDevice_);
35 cellSize = tarch::allocateMemory<tarch::la::Vector<Dimensions, double>>(numberOfCells_, memoryLocation_, targetDevice_);
36 t = tarch::allocateMemory<double>(numberOfCells_, memoryLocation_, targetDevice_);
37 dt = tarch::allocateMemory<double>(numberOfCells_, memoryLocation_, targetDevice_);
38 id = tarch::allocateMemory<int>(numberOfCells_, memoryLocation_, targetDevice_);
39 QOut = tarch::allocateMemory<outType*>(numberOfCells_, memoryLocation_, targetDevice_);
40 maxEigenvalue = tarch::allocateMemory<double>(numberOfCells_, memoryLocation_, targetDevice_);
41}
42
43template<typename inType, typename outType>
45 tarch::freeMemory(QIn, memoryLocation, targetDevice);
46 tarch::freeMemory(cellCentre, memoryLocation, targetDevice);
47 tarch::freeMemory(cellSize, memoryLocation, targetDevice);
48 tarch::freeMemory(t, memoryLocation, targetDevice);
49 tarch::freeMemory(dt, memoryLocation, targetDevice);
50 tarch::freeMemory(QOut, memoryLocation, targetDevice);
51 tarch::freeMemory(id, memoryLocation, targetDevice);
52 tarch::freeMemory(maxEigenvalue, memoryLocation, targetDevice);
53}
54
55template<typename inType, typename outType>
57 std::ostringstream msg;
58 msg << "[";
59 for (int i = 0; i < numberOfCells; i++) {
60 msg << "(x=" << cellCentre[i] << ",h=" << cellSize[i] << ",t=" << t[i] << ",dt=" << dt[i] << ",id=" << id[i]
61 << ",lambda=" << maxEigenvalue[i] << ")";
62 }
63 msg << "]";
64 return msg.str();
65}
void freeMemory(void *data, MemoryLocation location, int device=accelerator::Device::HostDevice)
Free memory.
MemoryLocation
Definition accelerator.h:58
Representation of a number of cells which contains all information that's required to process the sto...
Definition CellData.h:77
outType ** QOut
Out values.
Definition CellData.h:116
inType ** QIn
QIn may not be const, as some kernels delete it straightaway once the input data has been handled.
Definition CellData.h:82
CellData(inType *QIn_, const tarch::la::Vector< Dimensions, double > &cellCentre_, const tarch::la::Vector< Dimensions, double > &cellSize_, double t_, double dt_, outType *QOut_, tarch::MemoryLocation memoryLocation_=tarch::MemoryLocation::Heap, int targetDevice_=tarch::accelerator::Device::HostDevice)
Construct patch data object for one single cell.
Definition CellData.cpph:4
std::string toString() const
Definition CellData.cpph:56
double * maxEigenvalue
Out values.
Definition CellData.h:121
tarch::la::Vector< Dimensions, double > * cellCentre
Definition CellData.h:83
tarch::la::Vector< Dimensions, double > * cellSize
Definition CellData.h:84
Simple vector class.
Definition Vector.h:150