Geant4-11
G4DNAUpdateSystemModel.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
28#include "G4Molecule.hh"
30#include "G4UnitsTable.hh"
31#include "G4MoleculeCounter.hh"
33#include "G4Scheduler.hh"
36 , fpMesh(nullptr)
37 , fVerbose(0)
38 , fGlobalTime(DBL_MAX)
39{}
40
43{
44 // kill normal molecule
45 auto& node = fpMesh->GetVoxelMapList(index);
46 auto iter = node.find(type);
47 if(iter != node.end())
48 {
49 if(iter->second <= 0)
50 {
51 G4cout << "G4DNAUpdateSystemModel::KillMolecule::molecule : "
52 << type->GetName() << " index : " << index
53 << " number : " << iter->second << G4endl;
54 assert(false);
55 }
56 iter->second--;
57 if(G4VMoleculeCounter::Instance()->InUse())
58 {
60 }
61 }
62 else
63 {
64 auto pScavengerMaterial = dynamic_cast<G4DNAScavengerMaterial*>(
66 if(pScavengerMaterial != nullptr)
67 {
69 type, fGlobalTime);
70 }
71 else
72 {
73 G4cout << "index : " << index << " " << type->GetName() << G4endl;
74 G4cout << "This molecule is not belong scavengers or particle-base"
75 << G4endl;
76 assert(false);
77 }
78 }
79}
80
82{
83 auto& node = fpMesh->GetVoxelMapList(index);
84
85 auto iter = node.find(type);
86 if(iter != node.end())
87 {
88 if(iter->second <= 0)
89 {
90 G4cout << "G4DNAUpdateSystemModel::KillMolecule::molecule : "
91 << type->GetName() << " index : " << index
92 << " number : " << iter->second << G4endl;
93 assert(false);
94 }
95 iter->second--;
96 }
97 else
98 {
99 G4cout << "index : " << index << " " << type->GetName() << G4endl;
100 G4cout << "This molecule is not belong particle-base" << G4endl;
101 assert(false);
102 }
103}
104
106{
107 // for scavenger
108 auto pScavengerMaterial = dynamic_cast<G4DNAScavengerMaterial*>(
110 if(pScavengerMaterial != nullptr && pScavengerMaterial->find(type))
111 {
113 type, fGlobalTime);
114 return;
115 }
116 // for molecule
117 auto& node = fpMesh->GetVoxelMapList(index);
118 auto iter = node.find(type);
119 if(iter != node.end())
120 {
121 iter->second++;
122 }
123 else
124 {
125 node[type] = 1;
126 }
127
129 {
131 }
132}
133
135{
136 // for molecule
137 auto& node = fpMesh->GetVoxelMapList(index);
138 auto iter = node.find(type);
139 if(iter != node.end())
140 {
141 iter->second++;
142 }
143 else
144 {
145 node[type] = 1;
146 }
147}
148
150 const ReactionData& data)
151{
152 auto reactant1 = data.GetReactant1();
153 auto reactant2 = data.GetReactant2();
154#ifdef G4VERBOSE
155 if(fVerbose != 0)
156 {
157 G4cout << "At time : " << std::setw(7) << G4BestUnit(fGlobalTime, "Time")
158 << " Reaction : " << reactant1->GetName() << " + "
159 << reactant2->GetName() << " -> ";
160 }
161#endif
162 const G4int nbProducts = data.GetNbProducts();
163 if(nbProducts != 0)
164 {
165 for(size_t j = 0; j < (size_t) nbProducts; ++j)
166 {
167#ifdef G4VERBOSE
168 if((fVerbose != 0) && j != 0)
169 {
170 G4cout << " + ";
171 }
172 if(fVerbose != 0)
173 {
174 G4cout << data.GetProduct(j)->GetName();
175 // for test
176 // G4cout<<" fGlobalTime : "<<fGlobalTime;
177 // end fortest
178 }
179#endif
180 CreateMolecule(index, data.GetProduct(j));
181 //#define DEBUG 1
182
183#ifdef DEBUG
184 if(G4MoleculeCounter::Instance()->InUse())
185 if(fpMesh->GetNumberOfType(data.GetProduct(j)) !=
186 G4MoleculeCounter::Instance()->GetCurrentNumberOf(
187 data.GetProduct(j)))
188 {
189 G4cout << "*********G4DNAUpdateSystemModel::DEBUG::GetNumberOfType("
190 << data.GetProduct(j)->GetName()
191 << ") : " << fpMesh->GetNumberOfType(data.GetProduct(j))
192 << G4endl;
193 G4cout << "G4MoleculeCounter::GetCurrentNumberOf ("
194 << data.GetProduct(j)->GetName() << ") : "
195 << G4MoleculeCounter::Instance()->GetCurrentNumberOf(
196 data.GetProduct(j))
197 << G4endl;
199 throw;
200 }
201
202#endif
203 }
204 }
205 else
206 {
207#ifdef G4VERBOSE
208 if(fVerbose != 0)
209 {
210 G4cout << "No product";
211 // for test
212 // G4cout<<" fGlobalTime : "<<fGlobalTime;
213 // end fortest
214 }
215#endif
216 }
217#ifdef G4VERBOSE
218 if(fVerbose != 0)
219 {
220 G4cout << G4endl;
221 }
222#endif
223 KillMolecule(index, reactant1);
224#ifdef DEBUG
225 if(G4MoleculeCounter::Instance()->InUse())
226 if(fpMesh->GetNumberOfType(reactant1) !=
227 G4MoleculeCounter::Instance()->GetCurrentNumberOf(reactant1))
228 {
229 G4cout << "*********G4DNAUpdateSystemModel::DEBUG::GetNumberOfType("
230 << reactant1->GetName()
231 << ") : " << fpMesh->GetNumberOfType(reactant1) << G4endl;
232 G4cout << "G4MoleculeCounter::GetCurrentNumberOf ("
233 << reactant1->GetName() << ") : "
234 << G4MoleculeCounter::Instance()->GetCurrentNumberOf(reactant1)
235 << G4endl;
237 throw;
238 }
239#endif
240 KillMolecule(index, reactant2);
241#ifdef DEBUG
242
243 if(G4MoleculeCounter::Instance()->InUse())
244 if(fpMesh->GetNumberOfType(reactant2) !=
245 G4MoleculeCounter::Instance()->GetCurrentNumberOf(reactant2))
246 {
247 G4cout << "*********G4DNAUpdateSystemModel::DEBUG::GetNumberOfType("
248 << reactant2->GetName()
249 << ") : " << fpMesh->GetNumberOfType(reactant2) << G4endl;
250 G4cout << "G4MoleculeCounter::GetCurrentNumberOf ("
251 << reactant2->GetName() << ") : "
252 << G4MoleculeCounter::Instance()->GetCurrentNumberOf(reactant2)
253 << G4endl;
255 throw;
256 }
257#endif
258}
259
261 const JumpingData& data)
262{
263 auto reactant = std::get<0>(data);
264 auto JunpToIndex = std::get<1>(data);
265#ifdef G4VERBOSE
266 if(fVerbose > 1)
267 {
268 G4cout << "At time : " << std::setw(7) << G4BestUnit(fGlobalTime, "Time")
269 << " Jumping : " << reactant->GetName() << " from " << index
270 << " -> " << JunpToIndex << G4endl;
271 }
272#endif
273 JumpTo(index, reactant);
274 JumpIn(JunpToIndex, reactant);
275}
#define G4BestUnit(a, b)
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4Voxel::MapList & GetVoxelMapList(Key key)
Definition: G4DNAMesh.cc:37
G4int GetNumberOfType(G4Voxel::MolType type) const
Definition: G4DNAMesh.cc:78
Reactant * GetProduct(G4int i) const
void ReduceNumberMoleculePerVolumeUnitForMaterialConf(MolType, G4double)
void AddNumberMoleculePerVolumeUnitForMaterialConf(MolType, G4double)
void JumpIn(const Index &index, MolType)
void JumpTo(const Index &index, MolType type)
std::pair< MolType, Index > JumpingData
void CreateMolecule(const Index &index, MolType)
void KillMolecule(const Index &index, MolType type)
void UpdateSystem(const Index &index, const ReactionData &data)
const G4String & GetName() const
static G4MoleculeCounter * Instance()
static G4Scheduler * Instance()
Definition: G4Scheduler.cc:101
G4VScavengerMaterial * GetScavengerMaterial() const
Definition: G4Scheduler.hh:194
virtual void RemoveAMoleculeAtTime(Reactant *, G4double time, const G4ThreeVector *position=nullptr, int number=1)=0
static G4VMoleculeCounter * Instance()
virtual void AddAMoleculeAtTime(Reactant *, G4double time, const G4ThreeVector *position=nullptr, int number=1)=0
#define DBL_MAX
Definition: templates.hh:62