Skip to content

Commit 015ba7c

Browse files
committed
clean up
1 parent ca9c9cd commit 015ba7c

6 files changed

Lines changed: 9 additions & 141 deletions

File tree

.ci/azure-pipelines-amdgpu.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ jobs:
110110
CCACHE_BASEDIR: $(Build.SourcesDirectory)
111111
CCACHE_NOHASHDIR: 1
112112
inputs:
113-
cmakeArgs: '--build . --parallel 16 --target StarCluster'
113+
cmakeArgs: '--build . --parallel 16 --target GravRadParticle3D'
114114

115115
- task: CMake@1
116116
displayName: 'Run CTest'
117117
inputs:
118-
cmakeArgs: '-E chdir . ctest -R StarCluster -T Test --output-on-failure'
118+
cmakeArgs: '-E chdir . ctest -R GravRadParticle3D -T Test --output-on-failure'
119119

120120
- task: PublishTestResults@2
121121
inputs:

.ci/azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ jobs:
109109
CCACHE_BASEDIR: $(Build.SourcesDirectory)
110110
CCACHE_NOHASHDIR: 1
111111
inputs:
112-
cmakeArgs: '--build . --parallel 16 --target StarCluster'
112+
cmakeArgs: '--build . --parallel 16 --target GravRadParticle3D'
113113

114114
- task: CMake@1
115115
displayName: 'Run CTest'
116116
inputs:
117-
cmakeArgs: '-E chdir . ctest -R StarCluster -T Test --output-on-failure'
117+
cmakeArgs: '-E chdir . ctest -R GravRadParticle3D -T Test --output-on-failure'
118118

119119
- task: PublishTestResults@2
120120
inputs:

inputs/SphericalCollapse.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ amr.grid_eff = 1.0
2222

2323
hydro.reconstruction_order = 3 # PPM
2424
cfl = 0.25
25-
max_timesteps = 1
25+
max_timesteps = 50000
2626
stop_time = 0.05
2727

2828
derived_vars = gpot
@@ -34,5 +34,3 @@ do_tracers = 0 # turn on tracer particles
3434
ascent_interval = 100
3535
plotfile_interval = 200
3636
checkpoint_interval = 1000
37-
38-
density_floor_expr = "0.1 * (1.0 - sqrt(x*x + y*y + z*z))"

inputs/StarCluster.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ amr.grid_eff = 0.7 # default
2222

2323
hydro.reconstruction_order = 3 # PPM
2424
cfl = 0.2
25-
max_timesteps = 1
25+
max_timesteps = 300
2626
stop_time = 0.5 # t_ff = 0.55
2727

2828
gravity.Gconst = 1.0 #gravitational constant
@@ -46,5 +46,3 @@ derived_vars = log_density
4646

4747
amrex.throw_exception = 0
4848
amrex.signal_handling = 1
49-
50-
density_floor_expr = "1.0 - (sqrt(x*x + y*y + z*z)/10.0)"

src/problems/SphericalCollapse/testSphericalCollapse.cpp

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77
/// \brief Defines a test problem for pressureless spherical collapse.
88
///
99
#include "hydro/hydro_system.hpp"
10-
#include "math/interpolate.hpp"
11-
#include <limits>
1210

1311
#include "AMReX_BLassert.H"
1412
#include "AMReX_MultiFab.H"
1513
#include "AMReX_ParmParse.H"
1614
#include "QuokkaSimulation.hpp"
17-
#include "util/fextract.hpp"
18-
#ifdef HAVE_PYTHON
19-
#include "util/matplotlibcpp.h"
20-
#endif
15+
#include "util/BC.hpp"
2116

2217
struct GlobalConfig {
2318
static int num_particles;
@@ -143,13 +138,6 @@ template <> void QuokkaSimulation<CollapseProblem>::ComputeDerivedVar(int lev, s
143138
}
144139
}
145140

146-
// A GPU helper function to set up the density floor
147-
auto localDensityFloor(amrex::Real x, amrex::Real y, amrex::Real z) -> amrex::Real
148-
{
149-
// density_floor_expr = "0.1 * (1.0 - sqrt(x*x + y*y + z*z))"
150-
return 0.1 * (1.0 - std::sqrt(x * x + y * y + z * z));
151-
}
152-
153141
auto problem_main() -> int
154142
{
155143
amrex::ParmParse const pp("problem");
@@ -158,64 +146,13 @@ auto problem_main() -> int
158146

159147
// Problem initialization
160148
QuokkaSimulation<CollapseProblem> sim;
161-
sim.densityFloor_ = 1.0e-5;
162149

163150
// initialize
164151
sim.setInitialConditions();
165152

166-
// read output variables
167-
auto [position, values] = fextract(sim.state_new_cc_[0], sim.Geom(0), 2, 0.0, true); // z direction
168-
const int nz = static_cast<int>(position.size());
169-
170-
// extract density and check floor
171-
std::vector<double> zs(nz);
172-
std::vector<double> rho_z(nz);
173-
std::vector<double> custom_floor_z(nz);
174-
amrex::Real min_density = std::numeric_limits<amrex::Real>::max();
175-
amrex::Real min_density_ratio = std::numeric_limits<amrex::Real>::max();
176-
for (int i = 0; i < nz; ++i) {
177-
amrex::Real const z = position[i];
178-
custom_floor_z.at(i) = localDensityFloor(0.0, 0.0, z); // note that the real x and y are 0.5 * delta_x
179-
amrex::Real const rho = values.at(HydroSystem<CollapseProblem>::density_index)[i];
180-
zs.at(i) = z;
181-
rho_z.at(i) = rho;
182-
min_density = std::min(min_density, rho);
183-
min_density_ratio = std::min(min_density_ratio, rho / custom_floor_z.at(i));
184-
}
185-
186-
// Check that custom floor is working: min_density_ratio should not be smaller than 0.98
187-
int status = 0;
188-
if (min_density_ratio > 0.99) {
189-
amrex::Print() << "Custom density floor test PASSED: min density ratio = " << min_density_ratio << " > 0.99\n";
190-
} else {
191-
amrex::Print() << "Custom density floor test FAILED: min density ratio = " << min_density_ratio << " < 0.99\n";
192-
status = 1;
193-
}
194-
195-
#ifdef HAVE_PYTHON
196-
// Plot results
197-
matplotlibcpp::clf();
198-
199-
std::map<std::string, std::string> rho_args;
200-
std::map<std::string, std::string> custom_floor_args;
201-
rho_args["label"] = "rho";
202-
rho_args["linestyle"] = "-";
203-
rho_args["color"] = "C0";
204-
custom_floor_args["label"] = "custom floor";
205-
custom_floor_args["linestyle"] = "--";
206-
custom_floor_args["color"] = "C1";
207-
matplotlibcpp::plot(zs, rho_z, rho_args);
208-
matplotlibcpp::plot(zs, custom_floor_z, custom_floor_args);
209-
matplotlibcpp::ylim(1.0e-3, 11.0);
210-
matplotlibcpp::yscale("log");
211-
212-
matplotlibcpp::legend();
213-
matplotlibcpp::title("Spherical Collapse with custom floor");
214-
matplotlibcpp::save("./spherical_collapse_density_floor_z.pdf");
215-
#endif // HAVE_PYTHON
216-
217153
// evolve
218154
sim.evolve();
219155

156+
int const status = 0;
220157
return status;
221158
}

src/problems/StarCluster/testStarCluster.cpp

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
#include "AMReX_Print.H"
2525
#include "AMReX_SPACE.H"
2626
#include "AMReX_TableData.H"
27-
#include "util/fextract.hpp"
28-
#ifdef HAVE_PYTHON
29-
#include "util/matplotlibcpp.h"
30-
#endif
3127

3228
#include "QuokkaSimulation.hpp"
3329
#include "hydro/EOS.hpp"
@@ -212,17 +208,6 @@ template <> void QuokkaSimulation<StarCluster>::ComputeDerivedVar(int lev, std::
212208
}
213209
}
214210

215-
// A GPU helper function to set up the density floor
216-
auto localDensityFloor(amrex::Real x, amrex::Real y, amrex::Real z) -> amrex::Real
217-
{
218-
amrex::Real r = std::sqrt(x * x + y * y + z * z);
219-
const Real rho_base_floor = 0.001;
220-
const Real rho_peak = 1.0;
221-
const Real r_max = 10.0;
222-
amrex::Real custom_floor = std::max(rho_base_floor, rho_peak * (1.0 - (r / r_max)));
223-
return custom_floor;
224-
}
225-
226211
auto problem_main() -> int
227212
{
228213
// read problem parameters
@@ -251,59 +236,9 @@ auto problem_main() -> int
251236
// initialize
252237
sim.setInitialConditions();
253238

254-
// read output variables
255-
auto [position, values] = fextract(sim.state_new_cc_[0], sim.Geom(0), 2, 0.0, true); // z direction
256-
const int nz = static_cast<int>(position.size());
257-
258-
// extract density and check floor
259-
std::vector<double> zs(nz);
260-
std::vector<double> rho_z(nz);
261-
std::vector<double> custom_floor_z(nz);
262-
amrex::Real min_density = std::numeric_limits<amrex::Real>::max();
263-
amrex::Real min_density_ratio = std::numeric_limits<amrex::Real>::max();
264-
for (int i = 0; i < nz; ++i) {
265-
amrex::Real const z = position[i];
266-
custom_floor_z.at(i) = localDensityFloor(0.0, 0.0, z); // note that the real x and y are 0.5 * delta_x
267-
amrex::Real const rho = values.at(HydroSystem<StarCluster>::density_index)[i];
268-
zs.at(i) = z;
269-
rho_z.at(i) = rho;
270-
min_density = std::min(min_density, rho);
271-
min_density_ratio = std::min(min_density_ratio, rho / custom_floor_z.at(i));
272-
}
273-
274-
// Check that custom floor is working: min_density_ratio should not be smaller than 1
275-
int status = 0;
276-
if (min_density_ratio > 0.99) {
277-
amrex::Print() << "Custom density floor test PASSED: min density ratio = " << min_density_ratio << " > 0.99\n";
278-
} else {
279-
amrex::Print() << "Custom density floor test FAILED: min density ratio = " << min_density_ratio << " < 0.99\n";
280-
status = 1;
281-
}
282-
283-
#ifdef HAVE_PYTHON
284-
// Plot results
285-
matplotlibcpp::clf();
286-
287-
std::map<std::string, std::string> rho_args;
288-
std::map<std::string, std::string> custom_floor_args;
289-
rho_args["label"] = "rho";
290-
rho_args["linestyle"] = "-";
291-
rho_args["color"] = "C0";
292-
custom_floor_args["label"] = "custom floor";
293-
custom_floor_args["linestyle"] = "--";
294-
custom_floor_args["color"] = "C1";
295-
matplotlibcpp::plot(zs, rho_z, rho_args);
296-
matplotlibcpp::plot(zs, custom_floor_z, custom_floor_args);
297-
matplotlibcpp::ylim(0.001, 1.1);
298-
299-
matplotlibcpp::legend();
300-
matplotlibcpp::title("With custom floor");
301-
matplotlibcpp::save("./star_cluster_density_floor_z.pdf");
302-
#endif // HAVE_PYTHON
303-
304239
// evolve
305240
sim.evolve();
306241

307-
amrex::Print() << "Finished." << '\n';
242+
int const status = 0;
308243
return status;
309244
}

0 commit comments

Comments
 (0)