Skip to content

Commit

Permalink
Merge branch 'development' into LandSeaTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
AMLattanzi authored Jun 21, 2024
2 parents 54f9fd3 + 5ce79bb commit 53f30ee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 37 deletions.
51 changes: 21 additions & 30 deletions Source/ERF_read_waves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ ERF::read_waves (int lev)
{
for ( MFIter mfi(*Hwave_onegrid[lev],false); mfi.isValid(); ++mfi)
{
//auto my_H_ptr = Hwave[lev]->array(mfi);
//auto my_L_ptr = Lwave[lev]->array(mfi);

const auto & bx = mfi.validbox();

amrex::Print() << " HERE " << bx << std::endl;
// How to declare my_H_ptr directly?
amrex::Print() << " HERE " << bx << std::endl;
amrex::Array4<Real> my_H_arr = Hwave_onegrid[lev]->array(mfi);
amrex::Array4<Real> my_L_arr = Lwave_onegrid[lev]->array(mfi);

Expand All @@ -35,17 +33,17 @@ ERF::read_waves (int lev)
}


int nx=2147483647; // sanity check
int nx=2147483647;
int ny=2147483647; // sanity check

//JUST RECV
//JUST RECEIVED
if (amrex::MPMD::MyProc() == this_root) {
if (rank_offset == 0) // the first program
if (rank_offset == 0) // First program
{
MPI_Recv(&nx, 1, MPI_INT, other_root, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Recv(&ny, 1, MPI_INT, other_root, 7, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
else // the second program
else // Second program
{
MPI_Recv(&nx, 1, MPI_INT, other_root, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Recv(&ny, 1, MPI_INT, other_root, 6, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
Expand All @@ -54,17 +52,9 @@ ERF::read_waves (int lev)
ParallelDescriptor::Bcast(&nx, 1);
ParallelDescriptor::Bcast(&ny, 1);
}

if((nx)*(ny) > 0) {
int nsealm = (nx)*ny;
Print()<<nsealm<<std::endl;
Print()<<" NX = " << nx<<std::endl;
Print()<<" Ny = " << ny<<std::endl;
Print()<<" BX NPTS = " << bx.numPts() <<std::endl;
Print()<<" BX = " << bx <<std::endl;
// Print()<<" FAB NPTS = " << Hwave_onegrid[0]->array(mfi).size() <<std::endl;
Print()<<" FAB NPTS = " << (*Hwave_onegrid[0])[0].box().numPts()<<std::endl;
Print()<<" FAB = " << (*Hwave_onegrid[0])[0].box() <<std::endl;
// AMREX_ALWAYS_ASSERT_WITH_MESSAGE((nx)*ny <= bx.numPts() || bx.numPts() == 0, "total number of points being filled exceeds the size of the current box\n");

if (amrex::MPMD::MyProc() == this_root) {
if (rank_offset == 0) // the first program
Expand All @@ -78,30 +68,31 @@ ERF::read_waves (int lev)
MPI_Recv(my_L_ptr, nsealm, MPI_DOUBLE, other_root, 4, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
}
amrex::Print()<<"Just recieved "<<nsealm<<"as a double*"<<std::endl;

if(bx.contains(IntVect(192,2,0))) {
std::cout<<my_H_arr(192,92,0)<<std::endl;
std::cout<<my_L_arr(192,92,0)<<std::endl;
std::cout<<my_H_ptr[192-0+(92-0)*193]<<std::endl;
std::cout<<my_L_ptr[192-0+(92-0)*193]<<std::endl;
}
amrex::AllPrintToFile("output_HS_cpp.txt")<<FArrayBox(my_H_arr)<<std::endl;
amrex::AllPrintToFile("output_L_cpp.txt")<<FArrayBox(my_L_arr)<<std::endl;
} else {
finished_wave = true;
}
}


//May need to be Redistribute
// ParallelCopy(Hwave[lev],Hwave_onegrid[lev],0,0,1,0);
Hwave[lev]->ParallelCopy(*Hwave_onegrid[lev]);
Hwave[lev]->FillBoundary(geom[lev].periodicity());
Lwave[lev]->ParallelCopy(*Lwave_onegrid[lev]);
Lwave[lev]->FillBoundary(geom[lev].periodicity());
amrex::Print() << "HWAVE BOX " << (*Hwave[lev])[0].box() << std::endl;
for (MFIter mfi(*Hwave[lev],TilingIfNotGPU()); mfi.isValid(); ++mfi) {
Box bx = mfi.tilebox();
const Array4<Real const>& Hwave_arr = Hwave[lev]->const_array(mfi);
const Array4<int>& Lmask_arr = lmask_lev[lev][0]->array(mfi);
ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k){
if (Hwave_arr(i,j,k)<0) {
Lmask_arr(i,j,k) = 1;
} else {
Lmask_arr(i,j,k) = 0;
}
});
}

print_state(*Hwave[lev],IntVect(103,-3,0),0,IntVect(3,3,0));
print_state(*Hwave[lev],IntVect(103,88,0),0,IntVect(3,3,0));
}
#endif

12 changes: 5 additions & 7 deletions Source/TimeIntegration/ERF_MRI.H
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <functional>

template<class T>
class MRISplitIntegrator : public amrex::IntegratorBase<T>
class MRISplitIntegrator
{
private:
/**
Expand Down Expand Up @@ -90,12 +90,12 @@ public:
initialize_data(S_data);
}

void initialize (const T& S_data) override
void initialize (const T& S_data)
{
initialize_data(S_data);
}

~MRISplitIntegrator () override = default;
~MRISplitIntegrator () = default;

// Declare a default move constructor so we ensure the destructor is
// not called when we return an object of this class by value
Expand Down Expand Up @@ -184,7 +184,7 @@ public:
return rhs;
}

amrex::Real advance (T& S_old, T& S_new, amrex::Real time, const amrex::Real time_step) override
amrex::Real advance (T& S_old, T& S_new, amrex::Real time, const amrex::Real time_step)
{
BL_PROFILE_REGION("MRI_advance");
using namespace amrex;
Expand Down Expand Up @@ -348,9 +348,7 @@ public:
return timestep;
}

void time_interpolate (const T& /* S_new */, const T& /*S_old*/, amrex::Real /*timestep_fraction*/, T& /*data*/) override {}

void map_data (std::function<void(T&)> Map) override
void map_data (std::function<void(T&)> Map)
{
for (auto& F : T_store) {
Map(*F);
Expand Down

0 comments on commit 53f30ee

Please sign in to comment.