MaMiCo
1.2
Toggle main menu visibility
Loading...
Searching...
No Matches
coupling
datastructures
CouplingCellWithLinkedCells.h
1
#ifndef _MOLECULARDYNAMICS_COUPLING_DATASTRUCTURES_COUPLINGCELLWITHLINKEDCELLS_H_
2
#define _MOLECULARDYNAMICS_COUPLING_DATASTRUCTURES_COUPLINGCELLWITHLINKEDCELLS_H_
3
4
#include "CouplingCell.h"
5
6
namespace
coupling
{
7
namespace
datastructures {
8
template
<
class
LinkedCell,
unsigned
int
dim>
class
CouplingCellWithLinkedCells
;
9
}
// namespace datastructures
10
}
// namespace coupling
11
26
template
<
class
LinkedCell,
unsigned
int
dim>
class
coupling::datastructures::CouplingCellWithLinkedCells
:
public
coupling::datastructures::CouplingCell
<dim> {
27
public
:
33
CouplingCellWithLinkedCells
(
tarch::la::Vector<dim, unsigned int>
blockSize)
34
:
coupling
::datastructures::
CouplingCell
<dim>(),
_numberCells
(
getNumberCells
(blockSize)),
_linkedCells
(NULL) {
35
36
_linkedCells
=
new
LinkedCell*[
_numberCells
];
37
if
(
_linkedCells
== NULL) {
38
std::cout <<
"ERROR coupling::datastructures::CouplingCellWithLinkedCells: "
39
"_linkedCells == NULL"
40
<< std::endl;
41
exit(EXIT_FAILURE);
42
}
43
// set each pointer to a NULL pointer
44
for
(
unsigned
int
i = 0; i <
_numberCells
; i++) {
45
_linkedCells
[i] = NULL;
46
}
47
}
48
49
virtual
~CouplingCellWithLinkedCells
() {
50
if
(
_linkedCells
!= NULL) {
51
for
(
unsigned
int
i = 0; i <
_numberCells
; i++) {
52
_linkedCells
[i] = NULL;
53
}
54
delete
[]
_linkedCells
;
55
_linkedCells
= NULL;
56
}
57
}
58
65
void
addLinkedCell
(LinkedCell& cell,
const
size_t
index) {
_linkedCells
[index] = &cell; }
66
74
template
<
class
A>
void
iterateCells
(A& a) {
75
a.beginCellIteration();
76
for
(
unsigned
int
i = 0; i <
_numberCells
; i++) {
77
a.handleCell(*(
_linkedCells
[i]));
78
}
79
a.endCellIteration();
80
}
81
90
template
<
class
A>
void
iterateConstCells
(A& a)
const
{
91
a.beginCellIteration();
92
for
(
unsigned
int
i = 0; i <
_numberCells
; i++) {
93
a.handleCell(*(
_linkedCells
[i]));
94
}
95
a.endCellIteration();
96
}
97
98
private
:
104
unsigned
int
getNumberCells
(
tarch::la::Vector<dim, unsigned int>
blockSize)
const
{
105
unsigned
int
num = 1;
106
for
(
unsigned
int
d = 0; d < dim; d++) {
107
num = num * blockSize[d];
108
}
109
return
num;
110
}
111
113
const
size_t
_numberCells
;
114
117
LinkedCell**
_linkedCells
;
118
};
119
120
#endif
// _MOLECULARDYNAMICS_COUPLING_DATASTRUCTURES_COUPLINGCELLWITHLINKEDCELLS_H_
coupling::datastructures::CouplingCellWithLinkedCells
defines the cell type with cell-averaged quantities. Derived from the class coupling::datastructures:...
Definition
CouplingCellWithLinkedCells.h:26
coupling::datastructures::CouplingCellWithLinkedCells::addLinkedCell
void addLinkedCell(LinkedCell &cell, const size_t index)
Definition
CouplingCellWithLinkedCells.h:65
coupling::datastructures::CouplingCellWithLinkedCells::~CouplingCellWithLinkedCells
virtual ~CouplingCellWithLinkedCells()
Definition
CouplingCellWithLinkedCells.h:49
coupling::datastructures::CouplingCellWithLinkedCells::getNumberCells
unsigned int getNumberCells(tarch::la::Vector< dim, unsigned int > blockSize) const
Definition
CouplingCellWithLinkedCells.h:104
coupling::datastructures::CouplingCellWithLinkedCells::_linkedCells
LinkedCell ** _linkedCells
Definition
CouplingCellWithLinkedCells.h:117
coupling::datastructures::CouplingCellWithLinkedCells::CouplingCellWithLinkedCells
CouplingCellWithLinkedCells(tarch::la::Vector< dim, unsigned int > blockSize)
Definition
CouplingCellWithLinkedCells.h:33
coupling::datastructures::CouplingCellWithLinkedCells::iterateConstCells
void iterateConstCells(A &a) const
Definition
CouplingCellWithLinkedCells.h:90
coupling::datastructures::CouplingCellWithLinkedCells::_numberCells
const size_t _numberCells
Definition
CouplingCellWithLinkedCells.h:113
coupling::datastructures::CouplingCellWithLinkedCells::iterateCells
void iterateCells(A &a)
Definition
CouplingCellWithLinkedCells.h:74
coupling::datastructures::CouplingCell
defines the cell type with cell-averaged quantities only (no linked cells).
Definition
CouplingCell.h:29
coupling::datastructures::CouplingCell::CouplingCell
CouplingCell()
Definition
CouplingCell.h:33
tarch::la::Vector
Definition
Vector.h:25
coupling
everything necessary for coupling operations, is defined in here
Definition
AdditiveMomentumInsertion.h:15
Generated by
1.17.0