Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DNAMesh Class Reference

#include <G4DNAMesh.hh>

+ Inheritance diagram for G4DNAMesh:

Public Types

using Box = G4DNABoundingBox
 
using MolType = const G4MolecularConfiguration*
 
using Data = std::map<MolType, size_t>
 
using Voxel = std::tuple<Index, Box, Data>
 
using IndexMap = std::unordered_map<Index, G4int, G4VDNAMesh::hashFunc>
 
using VoxelVector = std::vector<Voxel>
 

Public Member Functions

 G4DNAMesh (const G4DNABoundingBox &, G4int)
 
 ~G4DNAMesh () override
 
Index GetIndex (const G4ThreeVector &position) const
 
VoxelGetVoxel (const Index &index)
 
size_t size ()
 
Index ConvertIndex (const Index &index, const G4int &) const
 
std::vector< IndexFindNeighboringVoxels (const Index &index) const
 
void Reset ()
 
DataGetVoxelMapList (const Index &index)
 
auto end ()
 
auto begin ()
 
VoxelVector::const_iterator const_end () const
 
VoxelVector::const_iterator const_begin () const
 
void PrintMesh ()
 
void PrintVoxel (const Index &index)
 
const G4DNABoundingBoxGetBoundingBox () const
 
G4DNABoundingBox GetBoundingBox (const Index &index)
 
G4int GetNumberOfType (MolType type) const
 
void InitializeVoxel (const Index &key, Data &&mapList)
 
G4double GetResolution () const
 
- Public Member Functions inherited from G4VDNAMesh
 G4VDNAMesh ()=default
 
virtual ~G4VDNAMesh ()=default
 

Detailed Description

Definition at line 41 of file G4DNAMesh.hh.

Member Typedef Documentation

◆ Box

Definition at line 44 of file G4DNAMesh.hh.

◆ Data

using G4DNAMesh::Data = std::map<MolType, size_t>

Definition at line 46 of file G4DNAMesh.hh.

◆ IndexMap

using G4DNAMesh::IndexMap = std::unordered_map<Index, G4int, G4VDNAMesh::hashFunc>

Definition at line 48 of file G4DNAMesh.hh.

◆ MolType

Definition at line 45 of file G4DNAMesh.hh.

◆ Voxel

using G4DNAMesh::Voxel = std::tuple<Index, Box, Data>

Definition at line 47 of file G4DNAMesh.hh.

◆ VoxelVector

using G4DNAMesh::VoxelVector = std::vector<Voxel>

Definition at line 49 of file G4DNAMesh.hh.

Constructor & Destructor Documentation

◆ G4DNAMesh()

G4DNAMesh::G4DNAMesh ( const G4DNABoundingBox & boundingBox,
G4int pixel )

Definition at line 53 of file G4DNAMesh.cc.

54 : fpBoundingMesh(&boundingBox)
55 , fResolution((2 * boundingBox.halfSideLengthInY() / pixel))
56{}
G4double halfSideLengthInY() const

◆ ~G4DNAMesh()

G4DNAMesh::~G4DNAMesh ( )
override

Definition at line 58 of file G4DNAMesh.cc.

58{ Reset(); }
void Reset()
Definition G4DNAMesh.cc:132

Member Function Documentation

◆ begin()

auto G4DNAMesh::begin ( )
inline

Definition at line 60 of file G4DNAMesh.hh.

60{ return fVoxelVector.begin(); }

Referenced by G4DNAGillespieDirectMethod::CreateEvents().

◆ const_begin()

VoxelVector::const_iterator G4DNAMesh::const_begin ( ) const
inline

Definition at line 62 of file G4DNAMesh.hh.

63 {
64 return fVoxelVector.begin();
65 }

◆ const_end()

VoxelVector::const_iterator G4DNAMesh::const_end ( ) const
inline

Definition at line 61 of file G4DNAMesh.hh.

61{ return fVoxelVector.end(); }

◆ ConvertIndex()

G4VDNAMesh::Index G4DNAMesh::ConvertIndex ( const Index & index,
const G4int & pixels ) const

Definition at line 213 of file G4DNAMesh.cc.

215{
216 G4int xmax = std::floor(
217 (fpBoundingMesh->Getxhi() - fpBoundingMesh->Getxlo()) / fResolution);
218 G4int ymax = std::floor(
219 (fpBoundingMesh->Getyhi() - fpBoundingMesh->Getylo()) / fResolution);
220 G4int zmax = std::floor(
221 (fpBoundingMesh->Getzhi() - fpBoundingMesh->Getzlo()) / fResolution);
222 auto dx = (G4int) (index.x * pixels / xmax);
223 auto dy = (G4int) (index.y * pixels / ymax);
224 auto dz = (G4int) (index.z * pixels / zmax);
225 if(dx < 0 || dy < 0 || dz < 0)
226 {
227 G4ExceptionDescription exceptionDescription;
228 exceptionDescription << "the old index: " << index
229 << " to new index : " << Index(dx, dx, dx);
230 G4Exception("G4DNAMesh::CheckIndex", "G4DNAMesh013", FatalErrorInArgument,
231 exceptionDescription);
232 }
233 return Index{ dx, dy, dz };
234}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
int G4int
Definition G4Types.hh:85
G4double Getxlo() const
G4double Getyhi() const
G4double Getylo() const
G4double Getxhi() const
G4double Getzlo() const
G4double Getzhi() const

◆ end()

auto G4DNAMesh::end ( )
inline

Definition at line 59 of file G4DNAMesh.hh.

59{ return fVoxelVector.end(); }

Referenced by G4DNAGillespieDirectMethod::CreateEvents().

◆ FindNeighboringVoxels()

std::vector< G4DNAMesh::Index > G4DNAMesh::FindNeighboringVoxels ( const Index & index) const

Definition at line 144 of file G4DNAMesh.cc.

145{
146 std::vector<Index> neighbors;
147 neighbors.reserve(6);
148 auto xMax = (G4int) (std::floor(
149 (fpBoundingMesh->Getxhi() - fpBoundingMesh->Getxlo()) / fResolution));
150 auto yMax = (G4int) (std::floor(
151 (fpBoundingMesh->Getyhi() - fpBoundingMesh->Getylo()) / fResolution));
152 auto zMax = (G4int) (std::floor(
153 (fpBoundingMesh->Getzhi() - fpBoundingMesh->Getzlo()) / fResolution));
154
155 if(index.x - 1 >= 0)
156 {
157 neighbors.emplace_back(index.x - 1, index.y, index.z);
158 }
159 if(index.y - 1 >= 0)
160 {
161 neighbors.emplace_back(index.x, index.y - 1, index.z);
162 }
163 if(index.z - 1 >= 0)
164 {
165 neighbors.emplace_back(index.x, index.y, index.z - 1);
166 }
167 if(index.x + 1 < xMax)
168 {
169 neighbors.emplace_back(index.x + 1, index.y, index.z);
170 }
171 if(index.y + 1 < yMax)
172 {
173 neighbors.emplace_back(index.x, index.y + 1, index.z);
174 }
175 if(index.z + 1 < zMax)
176 {
177 neighbors.emplace_back(index.x, index.y, index.z + 1);
178 }
179
180 return neighbors;
181}

◆ GetBoundingBox() [1/2]

const G4DNABoundingBox & G4DNAMesh::GetBoundingBox ( ) const

Definition at line 138 of file G4DNAMesh.cc.

139{
140 return *fpBoundingMesh;
141}

Referenced by GetVoxel().

◆ GetBoundingBox() [2/2]

G4DNABoundingBox G4DNAMesh::GetBoundingBox ( const Index & index)

Definition at line 121 of file G4DNAMesh.cc.

122{
123 auto xlo = fpBoundingMesh->Getxlo() + index.x * fResolution;
124 auto ylo = fpBoundingMesh->Getylo() + index.y * fResolution;
125 auto zlo = fpBoundingMesh->Getzlo() + index.z * fResolution;
126 auto xhi = fpBoundingMesh->Getxlo() + (index.x + 1) * fResolution;
127 auto yhi = fpBoundingMesh->Getylo() + (index.y + 1) * fResolution;
128 auto zhi = fpBoundingMesh->Getzlo() + (index.z + 1) * fResolution;
129 return G4DNABoundingBox({ xhi, xlo, yhi, ylo, zhi, zlo });
130}

◆ GetIndex()

G4DNAMesh::Index G4DNAMesh::GetIndex ( const G4ThreeVector & position) const

Definition at line 185 of file G4DNAMesh.cc.

186{
187 if(!fpBoundingMesh->contains(position))
188 {
189 G4ExceptionDescription exceptionDescription;
190 exceptionDescription << "the position: " << position
191 << " is not in the box : " << *fpBoundingMesh;
192 G4Exception("G4DNAMesh::GetKey", "G4DNAMesh010", FatalErrorInArgument,
193 exceptionDescription);
194 }
195
196 G4int dx =
197 std::floor((position.x() - fpBoundingMesh->Getxlo()) / fResolution);
198 G4int dy =
199 std::floor((position.y() - fpBoundingMesh->Getylo()) / fResolution);
200 G4int dz =
201 std::floor((position.z() - fpBoundingMesh->Getzlo()) / fResolution);
202 if(dx < 0 || dy < 0 || dz < 0)
203 {
204 G4ExceptionDescription exceptionDescription;
205 exceptionDescription << "the old index: " << position
206 << " to new index : " << Index(dx, dx, dx);
207 G4Exception("G4DNAMesh::CheckIndex", "G4DNAMesh015", FatalErrorInArgument,
208 exceptionDescription);
209 }
210 return Index{ dx, dy, dz };
211}
G4bool contains(const G4DNABoundingBox &other) const

◆ GetNumberOfType()

G4int G4DNAMesh::GetNumberOfType ( G4DNAMesh::MolType type) const

Definition at line 84 of file G4DNAMesh.cc.

85{
86 G4int output = 0;
87
88 for(const auto& iter : fVoxelVector)
89 {
90 auto data = std::get<2>(iter);
91 auto it = data.find(type);
92 if(it != data.end())
93 {
94 output += it->second;
95 }
96 }
97 return output;
98}

◆ GetResolution()

G4double G4DNAMesh::GetResolution ( ) const

Definition at line 183 of file G4DNAMesh.cc.

183{ return fResolution; }

◆ GetVoxel()

G4DNAMesh::Voxel & G4DNAMesh::GetVoxel ( const Index & index)

Definition at line 36 of file G4DNAMesh.cc.

37{
38 auto iter = fIndexMap.find(key);
39 if(iter == fIndexMap.end())
40 {
41 auto box = GetBoundingBox(key);
42 Data mapList;
43 G4DNAMesh::Voxel& voxel =
44 fVoxelVector.emplace_back(std::make_tuple(key, box, std::move(mapList)));
45 fIndexMap[key] = G4int(fVoxelVector.size() - 1);
46 return voxel;
47 }
48
49 auto index = fIndexMap[key];
50 return fVoxelVector[index];
51}
std::tuple< Index, Box, Data > Voxel
Definition G4DNAMesh.hh:47
std::map< MolType, size_t > Data
Definition G4DNAMesh.hh:46
const G4DNABoundingBox & GetBoundingBox() const
Definition G4DNAMesh.cc:138

Referenced by G4DNAGillespieDirectMethod::CreateEvent(), GetVoxelMapList(), and InitializeVoxel().

◆ GetVoxelMapList()

G4DNAMesh::Data & G4DNAMesh::GetVoxelMapList ( const Index & index)

Definition at line 60 of file G4DNAMesh.cc.

61{
62 auto& pVoxel = GetVoxel(key);
63 return std::get<2>(pVoxel);
64}
Voxel & GetVoxel(const Index &index)
Definition G4DNAMesh.cc:36

Referenced by PrintVoxel().

◆ InitializeVoxel()

void G4DNAMesh::InitializeVoxel ( const Index & key,
Data && mapList )

Definition at line 115 of file G4DNAMesh.cc.

116{
117 auto& pVoxel = GetVoxel(index);
118 std::get<2>(pVoxel) = std::move(mapList);
119}

◆ PrintMesh()

void G4DNAMesh::PrintMesh ( )

Definition at line 66 of file G4DNAMesh.cc.

67{
68 G4cout << "*********PrintMesh::Size : " << fVoxelVector.size() << G4endl;
69 for(const auto& iter : fVoxelVector)
70 {
71 auto data = std::get<2>(iter);
72 G4cout << "Index : " << std::get<0>(iter)
73 << " number of type : " << std::get<2>(iter).size() << G4endl;
74 for(const auto& it : data)
75 {
76 G4cout << "_____________" << it.first->GetName() << " : " << it.second
77 << G4endl;
78 }
79 G4cout << G4endl;
80 }
81 G4cout << G4endl;
82}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

◆ PrintVoxel()

void G4DNAMesh::PrintVoxel ( const Index & index)

Definition at line 100 of file G4DNAMesh.cc.

101{
102 G4cout << "*********PrintVoxel::";
103 G4cout << " index : " << index
104 << " number of type : " << this->GetVoxelMapList(index).size()
105 << G4endl;
106
107 for(const auto& it : this->GetVoxelMapList(index))
108 {
109 G4cout << "_____________" << it.first->GetName() << " : " << it.second
110 << G4endl;
111 }
112 G4cout << G4endl;
113}
Data & GetVoxelMapList(const Index &index)
Definition G4DNAMesh.cc:60

Referenced by G4DNAGillespieDirectMethod::CreateEvents().

◆ Reset()

void G4DNAMesh::Reset ( )

Definition at line 132 of file G4DNAMesh.cc.

133{
134 fIndexMap.clear();
135 fVoxelVector.clear();
136}

Referenced by ~G4DNAMesh().

◆ size()

size_t G4DNAMesh::size ( )
inline

Definition at line 54 of file G4DNAMesh.hh.

54{ return fVoxelVector.size(); };

The documentation for this class was generated from the following files: