forked from AMReX-Astro/Castro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRadMultiGroup.cpp
More file actions
167 lines (135 loc) · 4.39 KB
/
Copy pathRadMultiGroup.cpp
File metadata and controls
167 lines (135 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#ifndef RADIATION
#define RADIATION
#endif
#include <Radiation.H>
#include <RAD_F.H>
#include <AMReX_ParmParse.H>
#include <iostream>
#ifdef _OPENMP
#include <omp.h>
#endif
using namespace amrex;
void Radiation::get_groups(int verbose)
{
group_print_factor = 1.0;
group_units = " (units are Hz)";
Vector<Real> dlognugroup;
xnu.resize(nGroups+1, 0.0); // Bounds of the frequency group
nugroup.resize(nGroups, 1.0); // Geometric center of the frequency group
dnugroup.resize(nGroups, 0.0); // Width of the frequency group
dlognugroup.resize(nGroups, 0.0); // Log of the width of the frequency group
ParmParse pp("radiation");
if (nGroups > 1) {
Real lowest;
pp.get("lowestGroupHz", lowest);
Real groupGrowFactor;
if (pp.query("groupGrowFactor", groupGrowFactor)) {
xnu[0] = lowest;
Real firstGroupWidthHz;
pp.get("firstGroupWidthHz", firstGroupWidthHz);
dnugroup[0] = firstGroupWidthHz;
xnu[1] = xnu[0] + dnugroup[0];
if (lowest == 0.0) {
nugroup[0] = 0.5*dnugroup[0];
dlognugroup[0] = 2.0 * (log(xnu[1]) - log(nugroup[0]));
}
else {
nugroup[0] = sqrt(xnu[0]*xnu[1]);
dlognugroup[0] = log(xnu[1]) - log(xnu[0]);
}
for (int i=1; i<nGroups; i++) {
dnugroup[i] = dnugroup[i-1] * groupGrowFactor;
xnu[i+1] = xnu[i] + dnugroup[i];
nugroup[i] = sqrt(xnu[i]*xnu[i+1]);
dlognugroup[i] = log(xnu[i+1]) - log(xnu[i]);
}
}
else {
Real highest;
pp.get("highestGroupHz", highest);
Real loglowest = log10(lowest);
Real loghighest = log10(highest);
Real dlognu = (loghighest - loglowest) / Real(nGroups);
for (int i=0; i<nGroups; i++) {
xnu[i] = pow(10.0, loglowest+i*dlognu);
nugroup[i] = pow(10.0, loglowest+(i+0.5)*dlognu);
}
xnu[nGroups] = highest;
for (int i=0; i<nGroups; i++) {
dnugroup[i] = xnu[i+1] - xnu[i];
dlognugroup[i] = log(xnu[i+1]) - log(xnu[i]);
}
}
}
int nG0 = 0, nG1 = 0;
if (SolverType == MGFLDSolver) {
BL_FORT_PROC_CALL(CA_INITGROUPS3,ca_initgroups3)
(nugroup.dataPtr(), dnugroup.dataPtr(), dlognugroup.dataPtr(), xnu.dataPtr(),
nGroups, nG0, nG1);
}
else if (xnu.size() > 0) {
BL_FORT_PROC_CALL(CA_INITGROUPS2,ca_initgroups2)
(nugroup.dataPtr(), dnugroup.dataPtr(), xnu.dataPtr(), nGroups);
}
else {
BL_FORT_PROC_CALL(CA_INITGROUPS,ca_initgroups)
(nugroup.dataPtr(), dnugroup.dataPtr(), nGroups, nG0, nG1);
}
if (ParallelDescriptor::IOProcessor()) {
std::ofstream groupfile;
groupfile.open("group_structure.dat");
groupfile << "# total number of groups = " << nGroups << std::endl;
groupfile << "# group center, group weight" << group_units << std::endl;
groupfile.precision(10);
for (int i = 0; i < nGroups; i++) {
groupfile.width(15);
groupfile << nugroup[i] * group_print_factor << "\t";
groupfile.width(15);
groupfile << dnugroup[i] * group_print_factor << std::endl;
}
groupfile << std::endl;
if (xnu.size() > 0) {
groupfile << "# group lower boundaries" << std::endl;
for (int i = 0; i < xnu.size(); i++) {
groupfile << "group(" << i << ") = "
<< xnu[i] * group_print_factor << std::endl;
}
}
if (dlognugroup.size() > 0) {
groupfile << std::endl;
groupfile << "# group width in log space" << std::endl;
for (int i = 0; i < dlognugroup.size(); i++) {
groupfile << "group(" << i << ") = "
<< dlognugroup[i] << std::endl;
}
}
groupfile.close();
if (verbose >= 1) {
write_groups(std::cout);
}
}
}
void Radiation::write_groups(ostream& os)
{
os << "# total number of groups = " << nGroups << std::endl;
if (nGroups > 1) {
os << "# group center, group weight" << group_units << std::endl;
int oldprec = os.precision(10);
for (int i = 0; i < nGroups; i++) {
os.width(3);
os << i << ": ";
os.width(15);
os << nugroup[i] * group_print_factor << ", ";
os.width(15);
os << dnugroup[i] * group_print_factor << std::endl;
}
os.precision(oldprec);
}
if (xnu.size() > 0) {
os << "# group lower boundaries" << std::endl;
for (int i = 0; i < xnu.size(); i++) {
os << "group(" << i << ") = "
<< xnu[i] * group_print_factor << std::endl;
}
}
}