-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# AMREX_HOME defines the directory in which we will find all the AMReX code. | ||
# If you set AMREX_HOME as an environment variable, this line will be ignored | ||
AMREX_HOME ?= ../../../amrex/ | ||
|
||
DEBUG = FALSE | ||
USE_MPI = TRUE | ||
USE_OMP = FALSE | ||
USE_CUDA = FALSE | ||
COMP = gnu | ||
DIM = 2 | ||
MAX_SPEC = 8 | ||
|
||
TINY_PROFILE = FALSE | ||
|
||
include $(AMREX_HOME)/Tools/GNUMake/Make.defs | ||
|
||
# add this back on if we add any local files | ||
#include ./Make.package | ||
#VPATH_LOCATIONS += . | ||
#INCLUDE_LOCATIONS += . | ||
|
||
#include ../../src_reactDiff/Make.package | ||
#VPATH_LOCATIONS += ../../src_reactDiff/ | ||
#INCLUDE_LOCATIONS += ../../src_reactDiff/ | ||
|
||
include ../../src_analysis/Make.package | ||
VPATH_LOCATIONS += ../../src_analysis/ | ||
INCLUDE_LOCATIONS += ../../src_analysis/ | ||
|
||
include ../../src_rng/Make.package | ||
VPATH_LOCATIONS += ../../src_rng/ | ||
INCLUDE_LOCATIONS += ../../src_rng/ | ||
|
||
include ../../src_common/Make.package | ||
VPATH_LOCATIONS += ../../src_common/ | ||
INCLUDE_LOCATIONS += ../../src_common/ | ||
|
||
include $(AMREX_HOME)/Src/Base/Make.package | ||
include $(AMREX_HOME)/Src/Boundary/Make.package | ||
include $(AMREX_HOME)/Src/LinearSolvers/MLMG/Make.package | ||
|
||
include $(AMREX_HOME)/Tools/GNUMake/Make.rules | ||
|
||
ifeq ($(findstring cgpu, $(HOST)), cgpu) | ||
CXXFLAGS += $(FFTW) | ||
endif | ||
|
||
ifeq ($(USE_CUDA),TRUE) | ||
LIBRARIES += -lcufft | ||
else | ||
LIBRARIES += -L$(FFTW_DIR) -lfftw3_mpi -lfftw3 | ||
endif | ||
|
||
MAXSPECIES := $(strip $(MAX_SPEC)) | ||
DEFINES += -DMAX_SPECIES=$(MAXSPECIES) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
|
||
#include "common_functions.H" | ||
|
||
#include <AMReX_VisMF.H> | ||
#include <AMReX_PlotFileUtil.H> | ||
#include <AMReX_ParallelDescriptor.H> | ||
#include <AMReX_MultiFabUtil.H> | ||
|
||
#include "chrono" | ||
|
||
using namespace std::chrono; | ||
using namespace amrex; | ||
|
||
// argv contains the name of the inputs file entered at the command line | ||
void main_driver(const char* argv) | ||
{ | ||
|
||
BL_PROFILE_VAR("main_driver()",main_driver); | ||
|
||
// store the current time so we can later compute total run time. | ||
Real strt_time = ParallelDescriptor::second(); | ||
|
||
std::string inputs_file = argv; | ||
|
||
// Initialize variables in namespaces | ||
InitializeCommonNamespace(); | ||
|
||
// is the problem periodic? | ||
Vector<int> is_periodic(AMREX_SPACEDIM,0); // set to 0 (not periodic) by default | ||
for (int i=0; i<AMREX_SPACEDIM; ++i) { | ||
if (bc_spec_lo[i] == -1 && bc_spec_hi[i] == -1) { | ||
is_periodic[i] = 1; | ||
} | ||
} | ||
|
||
// This defines the physical box, [-1,1] in each direction. | ||
RealBox real_box({AMREX_D_DECL(prob_lo[0],prob_lo[1],prob_lo[2])}, | ||
{AMREX_D_DECL(prob_hi[0],prob_hi[1],prob_hi[2])}); | ||
|
||
IntVect dom_lo(AMREX_D_DECL( 0, 0, 0)); | ||
IntVect dom_hi(AMREX_D_DECL(n_cells[0]-1, n_cells[1]-1, n_cells[2]-1)); | ||
Box domain(dom_lo, dom_hi); | ||
|
||
Geometry geom(domain,&real_box,CoordSys::cartesian,is_periodic.data()); | ||
|
||
// BoxArray | ||
BoxArray ba; | ||
|
||
// how boxes are distrubuted among MPI processes | ||
DistributionMapping dmap; | ||
|
||
Real dt = fixed_dt; | ||
const Real* dx = geom.CellSize(); | ||
|
||
///////////////////////////////////////// | ||
//Initialise rngs | ||
///////////////////////////////////////// | ||
if (restart < 0) { | ||
|
||
if (seed > 0) { | ||
// initializes the seed for C++ random number calls | ||
InitRandom(seed+ParallelDescriptor::MyProc(), | ||
ParallelDescriptor::NProcs(), | ||
seed+ParallelDescriptor::MyProc()); | ||
} else if (seed == 0) { | ||
// initializes the seed for C++ random number calls based on the clock | ||
auto now = time_point_cast<nanoseconds>(system_clock::now()); | ||
int randSeed = now.time_since_epoch().count(); | ||
// broadcast the same root seed to all processors | ||
ParallelDescriptor::Bcast(&randSeed,1,ParallelDescriptor::IOProcessorNumber()); | ||
InitRandom(randSeed+ParallelDescriptor::MyProc(), | ||
ParallelDescriptor::NProcs(), | ||
randSeed+ParallelDescriptor::MyProc()); | ||
} else { | ||
Abort("Must supply non-negative seed"); | ||
} | ||
|
||
} | ||
|
||
int step_start; | ||
amrex::Real time; | ||
|
||
// Initialize the boxarray "ba" from the single box "bx" | ||
ba.define(domain); | ||
|
||
// Break up boxarray "ba" into chunks no larger than "max_grid_size" along a direction | ||
// note we are converting "Vector<int> max_grid_size" to an IntVect | ||
ba.maxSize(IntVect(max_grid_size)); | ||
|
||
dmap.define(ba); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/////////////////////////////////////////// | ||
|
||
// time step loop | ||
for(int step=step_start;step<=max_step;++step) { | ||
|
||
|
||
// MultiFab memory usage | ||
const int IOProc = ParallelDescriptor::IOProcessorNumber(); | ||
|
||
amrex::Long min_fab_megabytes = amrex::TotalBytesAllocatedInFabsHWM()/1048576; | ||
amrex::Long max_fab_megabytes = min_fab_megabytes; | ||
|
||
ParallelDescriptor::ReduceLongMin(min_fab_megabytes, IOProc); | ||
ParallelDescriptor::ReduceLongMax(max_fab_megabytes, IOProc); | ||
|
||
amrex::Print() << "High-water FAB megabyte spread across MPI nodes: [" | ||
<< min_fab_megabytes << " ... " << max_fab_megabytes << "]\n"; | ||
|
||
min_fab_megabytes = amrex::TotalBytesAllocatedInFabs()/1048576; | ||
max_fab_megabytes = min_fab_megabytes; | ||
|
||
ParallelDescriptor::ReduceLongMin(min_fab_megabytes, IOProc); | ||
ParallelDescriptor::ReduceLongMax(max_fab_megabytes, IOProc); | ||
|
||
amrex::Print() << "Curent FAB megabyte spread across MPI nodes: [" | ||
<< min_fab_megabytes << " ... " << max_fab_megabytes << "]\n"; | ||
|
||
} | ||
|
||
// Call the timer again and compute the maximum difference between the start time | ||
// and stop time over all processors | ||
Real stop_time = ParallelDescriptor::second() - strt_time; | ||
ParallelDescriptor::ReduceRealMax(stop_time); | ||
amrex::Print() << "Run time = " << stop_time << std::endl; | ||
|
||
} |