Compare commits
4 Commits
cjy-dystop
...
yx_new_spl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
588fb675a0 | ||
| aabe74c098 | |||
|
|
f147f79ffa | ||
|
|
8abac8dd88 |
@@ -66,7 +66,8 @@ if os.path.exists(File_directory):
|
|||||||
## Prompt whether to overwrite the existing directory
|
## Prompt whether to overwrite the existing directory
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
inputvalue = input()
|
## inputvalue = input()
|
||||||
|
inputvalue = "continue"
|
||||||
## If the user agrees to overwrite, proceed and remove the existing directory
|
## If the user agrees to overwrite, proceed and remove the existing directory
|
||||||
if ( inputvalue == "continue" ):
|
if ( inputvalue == "continue" ):
|
||||||
print( " Continue the calculation !!! " )
|
print( " Continue the calculation !!! " )
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,7 @@ using namespace std;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
|
#include <memory.h>
|
||||||
#include "MyList.h"
|
#include "MyList.h"
|
||||||
#include "Block.h"
|
#include "Block.h"
|
||||||
#include "Parallel.h"
|
#include "Parallel.h"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,213 +1,244 @@
|
|||||||
|
|
||||||
#ifndef PARALLEL_H
|
#ifndef PARALLEL_H
|
||||||
#define PARALLEL_H
|
#define PARALLEL_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <new>
|
#include <new>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
#include <memory.h>
|
||||||
#include "Parallel_bam.h"
|
#include "Parallel_bam.h"
|
||||||
#include "var.h"
|
#include "var.h"
|
||||||
#include "MPatch.h"
|
#include "MPatch.h"
|
||||||
#include "Block.h"
|
#include "Block.h"
|
||||||
#include "MyList.h"
|
#include "MyList.h"
|
||||||
#include "macrodef.h" //need dim; ghost_width; CONTRACT
|
#include "macrodef.h" //need dim; ghost_width; CONTRACT
|
||||||
namespace Parallel
|
namespace Parallel
|
||||||
{
|
{
|
||||||
struct gridseg
|
struct gridseg
|
||||||
{
|
{
|
||||||
double llb[dim];
|
double llb[dim];
|
||||||
double uub[dim];
|
double uub[dim];
|
||||||
int shape[dim];
|
int shape[dim];
|
||||||
double illb[dim], iuub[dim]; // only use for OutBdLow2Hi
|
double illb[dim], iuub[dim]; // only use for OutBdLow2Hi
|
||||||
Block *Bg;
|
Block *Bg;
|
||||||
};
|
};
|
||||||
int partition1(int &nx, int split_size, int min_width, int cpusize, int shape); // special for 1 diemnsion
|
int partition1(int &nx, int split_size, int min_width, int cpusize, int shape); // special for 1 diemnsion
|
||||||
int partition2(int *nxy, int split_size, int *min_width, int cpusize, int *shape); // special for 2 diemnsions
|
int partition2(int *nxy, int split_size, int *min_width, int cpusize, int *shape); // special for 2 diemnsions
|
||||||
int partition3(int *nxyz, int split_size, int *min_width, int cpusize, int *shape);
|
int partition3(int *nxyz, int split_size, int *min_width, int cpusize, int *shape);
|
||||||
MyList<Block> *distribute(MyList<Patch> *PatchLIST, int cpusize, int ingfsi, int fngfs, bool periodic, int nodes = 0); // produce corresponding Blocks
|
MyList<Block> *distribute(MyList<Patch> *PatchLIST, int cpusize, int ingfsi, int fngfs, bool periodic, int nodes = 0); // produce corresponding Blocks
|
||||||
void KillBlocks(MyList<Patch> *PatchLIST);
|
|
||||||
|
MyList<Block> *distribute_hard(MyList<Patch> *PatchLIST, int cpusize, int ingfsi, int fngfs, bool periodic, int nodes = 0); // produce corresponding Blocks
|
||||||
void setfunction(MyList<Block> *BlL, var *vn, double func(double x, double y, double z));
|
Block* splitHotspotBlock(MyList<Block>* &BlL, int _dim,
|
||||||
void setfunction(int rank, MyList<Block> *BlL, var *vn, double func(double x, double y, double z));
|
int ib0_orig, int ib3_orig,
|
||||||
void writefile(double time, int nx, int ny, int nz, double xmin, double xmax, double ymin, double ymax,
|
int jb1_orig, int jb4_orig,
|
||||||
double zmin, double zmax, char *filename, double *data_out);
|
int kb2_orig, int kb5_orig,
|
||||||
void writefile(double time, int nx, int ny, double xmin, double xmax, double ymin, double ymax,
|
Patch* PP, int r_1, int r_2,
|
||||||
char *filename, double *datain);
|
int ingfsi, int fngfsi, bool periodic,
|
||||||
void getarrayindex(int DIM, int *shape, int *index, int n);
|
Block* &split_first_block, Block* &split_last_block);
|
||||||
int getarraylocation(int DIM, int *shape, int *index);
|
|
||||||
void copy(int DIM, double *llbout, double *uubout, int *Dshape, double *DD, double *llbin, double *uubin,
|
Block* splitHotspotBlock(MyList<Block>* &BlL, int _dim,
|
||||||
int *shape, double *datain, double *llb, double *uub);
|
int ib0_orig, int ib3_orig,
|
||||||
void Dump_CPU_Data(MyList<Block> *BlL, MyList<var> *DumpList, char *tag, double time, double dT);
|
int jb1_orig, int jb4_orig,
|
||||||
void Dump_Data(MyList<Patch> *PL, MyList<var> *DumpList, char *tag, double time, double dT);
|
int kb2_orig, int kb5_orig,
|
||||||
void Dump_Data(Patch *PP, MyList<var> *DumpList, char *tag, double time, double dT, int grd);
|
Patch* PP, int r_1, int r_2, int r_3, int r_4,
|
||||||
double *Collect_Data(Patch *PP, var *VP);
|
int ingfsi, int fngfsi, bool periodic,
|
||||||
void d2Dump_Data(MyList<Patch> *PL, MyList<var> *DumpList, char *tag, double time, double dT);
|
Block* &split_first_block, Block* &split_last_block);
|
||||||
void d2Dump_Data(Patch *PP, MyList<var> *DumpList, char *tag, double time, double dT, int grd);
|
Block* createMappedBlock(MyList<Block>* &BlL, int _dim, int* shape, double* bbox,
|
||||||
void Dump_Data0(Patch *PP, MyList<var> *DumpList, char *tag, double time, double dT);
|
int block_id, int ingfsi, int fngfsi, int lev);
|
||||||
double global_interp(int DIM, int *ext, double **CoX, double *datain,
|
void KillBlocks(MyList<Patch> *PatchLIST);
|
||||||
double *poX, int ordn, double *SoA, int Symmetry);
|
|
||||||
double global_interp(int DIM, int *ext, double **CoX, double *datain,
|
void setfunction(MyList<Block> *BlL, var *vn, double func(double x, double y, double z));
|
||||||
double *poX, int ordn);
|
void setfunction(int rank, MyList<Block> *BlL, var *vn, double func(double x, double y, double z));
|
||||||
double Lagrangian_Int(double x, int npts, double *xpts, double *funcvals);
|
void writefile(double time, int nx, int ny, int nz, double xmin, double xmax, double ymin, double ymax,
|
||||||
double LagrangePoly(double x, int pt, int npts, double *xpts);
|
double zmin, double zmax, char *filename, double *data_out);
|
||||||
MyList<gridseg> *build_complete_gsl(Patch *Pat);
|
void writefile(double time, int nx, int ny, double xmin, double xmax, double ymin, double ymax,
|
||||||
MyList<gridseg> *build_complete_gsl(MyList<Patch> *PatL);
|
char *filename, double *datain);
|
||||||
MyList<gridseg> *build_complete_gsl_virtual(MyList<Patch> *PatL);
|
void getarrayindex(int DIM, int *shape, int *index, int n);
|
||||||
MyList<gridseg> *build_complete_gsl_virtual2(MyList<Patch> *PatL); // - buffer
|
int getarraylocation(int DIM, int *shape, int *index);
|
||||||
MyList<gridseg> *build_owned_gsl0(Patch *Pat, int rank_in); // - ghost without extension, special for Sync usage
|
void copy(int DIM, double *llbout, double *uubout, int *Dshape, double *DD, double *llbin, double *uubin,
|
||||||
MyList<gridseg> *build_owned_gsl1(Patch *Pat, int rank_in); // - ghost, similar to build_owned_gsl0 but extend one point on left side for vertex grid
|
int *shape, double *datain, double *llb, double *uub);
|
||||||
MyList<gridseg> *build_owned_gsl2(Patch *Pat, int rank_in); // - buffer - ghost
|
void Dump_CPU_Data(MyList<Block> *BlL, MyList<var> *DumpList, char *tag, double time, double dT);
|
||||||
MyList<gridseg> *build_owned_gsl3(Patch *Pat, int rank_in, int Symmetry); // - ghost - BD ghost
|
void Dump_Data(MyList<Patch> *PL, MyList<var> *DumpList, char *tag, double time, double dT);
|
||||||
MyList<gridseg> *build_owned_gsl4(Patch *Pat, int rank_in, int Symmetry); // - buffer - ghost - BD ghost
|
void Dump_Data(Patch *PP, MyList<var> *DumpList, char *tag, double time, double dT, int grd);
|
||||||
MyList<gridseg> *build_owned_gsl5(Patch *Pat, int rank_in); // similar to build_owned_gsl2 but no extension
|
double *Collect_Data(Patch *PP, var *VP);
|
||||||
MyList<gridseg> *build_owned_gsl(MyList<Patch> *PatL, int rank_in, int type, int Symmetry);
|
void d2Dump_Data(MyList<Patch> *PL, MyList<var> *DumpList, char *tag, double time, double dT);
|
||||||
void build_gstl(MyList<gridseg> *srci, MyList<gridseg> *dsti, MyList<gridseg> **out_src, MyList<gridseg> **out_dst);
|
void d2Dump_Data(Patch *PP, MyList<var> *DumpList, char *tag, double time, double dT, int grd);
|
||||||
int data_packer(double *data, MyList<gridseg> *src, MyList<gridseg> *dst, int rank_in, int dir,
|
void Dump_Data0(Patch *PP, MyList<var> *DumpList, char *tag, double time, double dT);
|
||||||
MyList<var> *VarLists, MyList<var> *VarListd, int Symmetry);
|
double global_interp(int DIM, int *ext, double **CoX, double *datain,
|
||||||
void transfer(MyList<gridseg> **src, MyList<gridseg> **dst,
|
double *poX, int ordn, double *SoA, int Symmetry);
|
||||||
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
|
double global_interp(int DIM, int *ext, double **CoX, double *datain,
|
||||||
int Symmetry);
|
double *poX, int ordn);
|
||||||
int data_packermix(double *data, MyList<gridseg> *src, MyList<gridseg> *dst, int rank_in, int dir,
|
double Lagrangian_Int(double x, int npts, double *xpts, double *funcvals);
|
||||||
MyList<var> *VarLists, MyList<var> *VarListd, int Symmetry);
|
double LagrangePoly(double x, int pt, int npts, double *xpts);
|
||||||
void transfermix(MyList<gridseg> **src, MyList<gridseg> **dst,
|
MyList<gridseg> *build_complete_gsl(Patch *Pat);
|
||||||
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
|
MyList<gridseg> *build_complete_gsl(MyList<Patch> *PatL);
|
||||||
int Symmetry);
|
MyList<gridseg> *build_complete_gsl_virtual(MyList<Patch> *PatL);
|
||||||
void Sync(Patch *Pat, MyList<var> *VarList, int Symmetry);
|
MyList<gridseg> *build_complete_gsl_virtual2(MyList<Patch> *PatL); // - buffer
|
||||||
void Sync(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry);
|
MyList<gridseg> *build_owned_gsl0(Patch *Pat, int rank_in); // - ghost without extension, special for Sync usage
|
||||||
void Sync_merged(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry);
|
MyList<gridseg> *build_owned_gsl1(Patch *Pat, int rank_in); // - ghost, similar to build_owned_gsl0 but extend one point on left side for vertex grid
|
||||||
|
MyList<gridseg> *build_owned_gsl2(Patch *Pat, int rank_in); // - buffer - ghost
|
||||||
struct SyncCache {
|
MyList<gridseg> *build_owned_gsl3(Patch *Pat, int rank_in, int Symmetry); // - ghost - BD ghost
|
||||||
bool valid;
|
MyList<gridseg> *build_owned_gsl4(Patch *Pat, int rank_in, int Symmetry); // - buffer - ghost - BD ghost
|
||||||
int cpusize;
|
MyList<gridseg> *build_owned_gsl5(Patch *Pat, int rank_in); // similar to build_owned_gsl2 but no extension
|
||||||
MyList<gridseg> **combined_src;
|
MyList<gridseg> *build_owned_gsl(MyList<Patch> *PatL, int rank_in, int type, int Symmetry);
|
||||||
MyList<gridseg> **combined_dst;
|
void build_gstl(MyList<gridseg> *srci, MyList<gridseg> *dsti, MyList<gridseg> **out_src, MyList<gridseg> **out_dst);
|
||||||
int *send_lengths;
|
int data_packer(double *data, MyList<gridseg> *src, MyList<gridseg> *dst, int rank_in, int dir,
|
||||||
int *recv_lengths;
|
MyList<var> *VarLists, MyList<var> *VarListd, int Symmetry);
|
||||||
double **send_bufs;
|
void transfer(MyList<gridseg> **src, MyList<gridseg> **dst,
|
||||||
double **recv_bufs;
|
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
|
||||||
int *send_buf_caps;
|
int Symmetry);
|
||||||
int *recv_buf_caps;
|
int data_packermix(double *data, MyList<gridseg> *src, MyList<gridseg> *dst, int rank_in, int dir,
|
||||||
MPI_Request *reqs;
|
MyList<var> *VarLists, MyList<var> *VarListd, int Symmetry);
|
||||||
MPI_Status *stats;
|
void transfermix(MyList<gridseg> **src, MyList<gridseg> **dst,
|
||||||
int max_reqs;
|
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /*target */,
|
||||||
bool lengths_valid;
|
int Symmetry);
|
||||||
SyncCache();
|
void Sync(Patch *Pat, MyList<var> *VarList, int Symmetry);
|
||||||
void invalidate();
|
void Sync(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry);
|
||||||
void destroy();
|
void Sync_merged(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry);
|
||||||
};
|
|
||||||
|
struct SyncCache {
|
||||||
void Sync_cached(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry, SyncCache &cache);
|
bool valid;
|
||||||
void transfer_cached(MyList<gridseg> **src, MyList<gridseg> **dst,
|
int cpusize;
|
||||||
MyList<var> *VarList1, MyList<var> *VarList2,
|
MyList<gridseg> **combined_src;
|
||||||
int Symmetry, SyncCache &cache);
|
MyList<gridseg> **combined_dst;
|
||||||
|
int *send_lengths;
|
||||||
struct AsyncSyncState {
|
int *recv_lengths;
|
||||||
int req_no;
|
double **send_bufs;
|
||||||
bool active;
|
double **recv_bufs;
|
||||||
AsyncSyncState() : req_no(0), active(false) {}
|
int *send_buf_caps;
|
||||||
};
|
int *recv_buf_caps;
|
||||||
|
MPI_Request *reqs;
|
||||||
void Sync_start(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry,
|
MPI_Status *stats;
|
||||||
SyncCache &cache, AsyncSyncState &state);
|
int max_reqs;
|
||||||
void Sync_finish(SyncCache &cache, AsyncSyncState &state,
|
bool lengths_valid;
|
||||||
MyList<var> *VarList, int Symmetry);
|
SyncCache();
|
||||||
void OutBdLow2Hi(Patch *Patc, Patch *Patf,
|
void invalidate();
|
||||||
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
void destroy();
|
||||||
int Symmetry);
|
};
|
||||||
void OutBdLow2Hi(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
|
||||||
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
void Sync_cached(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry, SyncCache &cache);
|
||||||
int Symmetry);
|
void transfer_cached(MyList<gridseg> **src, MyList<gridseg> **dst,
|
||||||
void OutBdLow2Himix(Patch *Patc, Patch *Patf,
|
MyList<var> *VarList1, MyList<var> *VarList2,
|
||||||
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
int Symmetry, SyncCache &cache);
|
||||||
int Symmetry);
|
|
||||||
void OutBdLow2Himix(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
struct AsyncSyncState {
|
||||||
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
int req_no;
|
||||||
int Symmetry);
|
bool active;
|
||||||
void Restrict_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
AsyncSyncState() : req_no(0), active(false) {}
|
||||||
MyList<var> *VarList1, MyList<var> *VarList2,
|
};
|
||||||
int Symmetry, SyncCache &cache);
|
|
||||||
void OutBdLow2Hi_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
void Sync_start(MyList<Patch> *PatL, MyList<var> *VarList, int Symmetry,
|
||||||
MyList<var> *VarList1, MyList<var> *VarList2,
|
SyncCache &cache, AsyncSyncState &state);
|
||||||
int Symmetry, SyncCache &cache);
|
void Sync_finish(SyncCache &cache, AsyncSyncState &state,
|
||||||
void OutBdLow2Himix_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
MyList<var> *VarList, int Symmetry);
|
||||||
MyList<var> *VarList1, MyList<var> *VarList2,
|
void OutBdLow2Hi(Patch *Patc, Patch *Patf,
|
||||||
int Symmetry, SyncCache &cache);
|
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
||||||
void Prolong(Patch *Patc, Patch *Patf,
|
int Symmetry);
|
||||||
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
void OutBdLow2Hi(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
||||||
int Symmetry);
|
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
||||||
void Prolongint(Patch *Patc, Patch *Patf,
|
int Symmetry);
|
||||||
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
void OutBdLow2Himix(Patch *Patc, Patch *Patf,
|
||||||
int Symmetry);
|
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
||||||
void Restrict(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
int Symmetry);
|
||||||
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
void OutBdLow2Himix(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
||||||
int Symmetry);
|
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
||||||
void Restrict_after(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
int Symmetry);
|
||||||
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
void Restrict_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
||||||
int Symmetry); // for -ghost - BDghost
|
MyList<var> *VarList1, MyList<var> *VarList2,
|
||||||
MyList<Parallel::gridseg> *build_PhysBD_gsl(Patch *Pat);
|
int Symmetry, SyncCache &cache);
|
||||||
MyList<Parallel::gridseg> *build_ghost_gsl(MyList<Patch> *PatL);
|
void OutBdLow2Hi_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
||||||
MyList<Parallel::gridseg> *build_ghost_gsl(Patch *Pat);
|
MyList<var> *VarList1, MyList<var> *VarList2,
|
||||||
MyList<Parallel::gridseg> *build_buffer_gsl(Patch *Pat);
|
int Symmetry, SyncCache &cache);
|
||||||
MyList<Parallel::gridseg> *build_buffer_gsl(MyList<Patch> *PatL);
|
void OutBdLow2Himix_cached(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
||||||
MyList<Parallel::gridseg> *gsl_subtract(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
|
MyList<var> *VarList1, MyList<var> *VarList2,
|
||||||
MyList<Parallel::gridseg> *gs_subtract(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
|
int Symmetry, SyncCache &cache);
|
||||||
MyList<Parallel::gridseg> *gsl_and(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
|
void Prolong(Patch *Patc, Patch *Patf,
|
||||||
MyList<Parallel::gridseg> *gs_and(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
|
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
||||||
MyList<Parallel::gridseg> *clone_gsl(MyList<Parallel::gridseg> *p, bool first_only);
|
int Symmetry);
|
||||||
MyList<Parallel::gridseg> *build_bulk_gsl(Patch *Pat); // similar to build_owned_gsl0 but does not care rank issue
|
void Prolongint(Patch *Patc, Patch *Patf,
|
||||||
MyList<Parallel::gridseg> *build_bulk_gsl(Block *bp, Patch *Pat);
|
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
||||||
void build_PhysBD_gstl(Patch *Pat, MyList<Parallel::gridseg> *srci, MyList<Parallel::gridseg> *dsti,
|
int Symmetry);
|
||||||
MyList<Parallel::gridseg> **out_src, MyList<Parallel::gridseg> **out_dst);
|
void Restrict(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
||||||
void PeriodicBD(Patch *Pat, MyList<var> *VarList, int Symmetry);
|
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
||||||
double L2Norm(Patch *Pat, var *vf);
|
int Symmetry);
|
||||||
void checkgsl(MyList<Parallel::gridseg> *pp, bool first_only);
|
void Restrict_after(MyList<Patch> *PatcL, MyList<Patch> *PatfL,
|
||||||
void checkvarl(MyList<var> *pp, bool first_only);
|
MyList<var> *VarList1 /* source */, MyList<var> *VarList2 /* target */,
|
||||||
MyList<Parallel::gridseg> *divide_gsl(MyList<Parallel::gridseg> *p, Patch *Pat);
|
int Symmetry); // for -ghost - BDghost
|
||||||
MyList<Parallel::gridseg> *divide_gs(MyList<Parallel::gridseg> *p, Patch *Pat);
|
MyList<Parallel::gridseg> *build_PhysBD_gsl(Patch *Pat);
|
||||||
void prepare_inter_time_level(Patch *Pat,
|
MyList<Parallel::gridseg> *build_ghost_gsl(MyList<Patch> *PatL);
|
||||||
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
|
MyList<Parallel::gridseg> *build_ghost_gsl(Patch *Pat);
|
||||||
MyList<var> *VarList3 /* target (t+a*dt) */, int tindex);
|
MyList<Parallel::gridseg> *build_buffer_gsl(Patch *Pat);
|
||||||
void prepare_inter_time_level(Patch *Pat,
|
MyList<Parallel::gridseg> *build_buffer_gsl(MyList<Patch> *PatL);
|
||||||
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
|
MyList<Parallel::gridseg> *gsl_subtract(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
|
||||||
MyList<var> *VarList3 /* source (t-dt) */, MyList<var> *VarList4 /* target (t+a*dt) */, int tindex);
|
MyList<Parallel::gridseg> *gs_subtract(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
|
||||||
void prepare_inter_time_level(MyList<Patch> *PatL,
|
MyList<Parallel::gridseg> *gsl_and(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
|
||||||
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
|
MyList<Parallel::gridseg> *gs_and(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
|
||||||
MyList<var> *VarList3 /* target (t+a*dt) */, int tindex);
|
MyList<Parallel::gridseg> *clone_gsl(MyList<Parallel::gridseg> *p, bool first_only);
|
||||||
void prepare_inter_time_level(MyList<Patch> *Pat,
|
MyList<Parallel::gridseg> *build_bulk_gsl(Patch *Pat); // similar to build_owned_gsl0 but does not care rank issue
|
||||||
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
|
MyList<Parallel::gridseg> *build_bulk_gsl(Block *bp, Patch *Pat);
|
||||||
MyList<var> *VarList3 /* source (t-dt) */, MyList<var> *VarList4 /* target (t+a*dt) */, int tindex);
|
void build_PhysBD_gstl(Patch *Pat, MyList<Parallel::gridseg> *srci, MyList<Parallel::gridseg> *dsti,
|
||||||
void merge_gsl(MyList<gridseg> *&A, const double ratio);
|
MyList<Parallel::gridseg> **out_src, MyList<Parallel::gridseg> **out_dst);
|
||||||
bool merge_gs(MyList<gridseg> *D, MyList<gridseg> *B, MyList<gridseg> *&C, const double ratio);
|
void PeriodicBD(Patch *Pat, MyList<var> *VarList, int Symmetry);
|
||||||
// Add ghost region to tangent plane
|
double L2Norm(Patch *Pat, var *vf);
|
||||||
// we assume the grids have the same resolution
|
void checkgsl(MyList<Parallel::gridseg> *pp, bool first_only);
|
||||||
void add_ghost_touch(MyList<gridseg> *&A);
|
void checkvarl(MyList<var> *pp, bool first_only);
|
||||||
void cut_gsl(MyList<gridseg> *&A);
|
MyList<Parallel::gridseg> *divide_gsl(MyList<Parallel::gridseg> *p, Patch *Pat);
|
||||||
bool cut_gs(MyList<gridseg> *D, MyList<gridseg> *B, MyList<gridseg> *&C);
|
MyList<Parallel::gridseg> *divide_gs(MyList<Parallel::gridseg> *p, Patch *Pat);
|
||||||
MyList<Parallel::gridseg> *gs_subtract_virtual(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
|
void prepare_inter_time_level(Patch *Pat,
|
||||||
void fill_level_data(MyList<Patch> *PatLd, MyList<Patch> *PatLs, MyList<Patch> *PatcL,
|
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
|
||||||
MyList<var> *OldList, MyList<var> *StateList, MyList<var> *FutureList,
|
MyList<var> *VarList3 /* target (t+a*dt) */, int tindex);
|
||||||
MyList<var> *tmList, int Symmetry, bool BB, bool CC);
|
void prepare_inter_time_level(Patch *Pat,
|
||||||
bool PatList_Interp_Points(MyList<Patch> *PatL, MyList<var> *VarList,
|
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
|
||||||
int NN, double **XX,
|
MyList<var> *VarList3 /* source (t-dt) */, MyList<var> *VarList4 /* target (t+a*dt) */, int tindex);
|
||||||
double *Shellf, int Symmetry);
|
void prepare_inter_time_level(MyList<Patch> *PatL,
|
||||||
void aligncheck(double *bbox0, double *bboxl, int lev, double *DH0, int *shape);
|
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
|
||||||
bool point_locat_gsl(double *pox, MyList<Parallel::gridseg> *gsl);
|
MyList<var> *VarList3 /* target (t+a*dt) */, int tindex);
|
||||||
void checkpatchlist(MyList<Patch> *PatL, bool buflog);
|
void prepare_inter_time_level(MyList<Patch> *Pat,
|
||||||
|
MyList<var> *VarList1 /* source (t+dt) */, MyList<var> *VarList2 /* source (t) */,
|
||||||
double L2Norm(Patch *Pat, var *vf, MPI_Comm Comm_here);
|
MyList<var> *VarList3 /* source (t-dt) */, MyList<var> *VarList4 /* target (t+a*dt) */, int tindex);
|
||||||
bool PatList_Interp_Points(MyList<Patch> *PatL, MyList<var> *VarList,
|
void merge_gsl(MyList<gridseg> *&A, const double ratio);
|
||||||
int NN, double **XX,
|
bool merge_gs(MyList<gridseg> *D, MyList<gridseg> *B, MyList<gridseg> *&C, const double ratio);
|
||||||
double *Shellf, int Symmetry, MPI_Comm Comm_here);
|
// Add ghost region to tangent plane
|
||||||
#if (PSTR == 1 || PSTR == 2 || PSTR == 3)
|
// we assume the grids have the same resolution
|
||||||
MyList<Block> *distribute(MyList<Patch> *PatchLIST, int cpusize, int ingfsi, int fngfsi,
|
void add_ghost_touch(MyList<gridseg> *&A);
|
||||||
bool periodic, int start_rank, int end_rank, int nodes = 0);
|
void cut_gsl(MyList<gridseg> *&A);
|
||||||
#endif
|
bool cut_gs(MyList<gridseg> *D, MyList<gridseg> *B, MyList<gridseg> *&C);
|
||||||
}
|
MyList<Parallel::gridseg> *gs_subtract_virtual(MyList<Parallel::gridseg> *A, MyList<Parallel::gridseg> *B);
|
||||||
#endif /*PARALLEL_H */
|
void fill_level_data(MyList<Patch> *PatLd, MyList<Patch> *PatLs, MyList<Patch> *PatcL,
|
||||||
|
MyList<var> *OldList, MyList<var> *StateList, MyList<var> *FutureList,
|
||||||
|
MyList<var> *tmList, int Symmetry, bool BB, bool CC);
|
||||||
|
bool PatList_Interp_Points(MyList<Patch> *PatL, MyList<var> *VarList,
|
||||||
|
int NN, double **XX,
|
||||||
|
double *Shellf, int Symmetry);
|
||||||
|
void aligncheck(double *bbox0, double *bboxl, int lev, double *DH0, int *shape);
|
||||||
|
bool point_locat_gsl(double *pox, MyList<Parallel::gridseg> *gsl);
|
||||||
|
void checkpatchlist(MyList<Patch> *PatL, bool buflog);
|
||||||
|
|
||||||
|
double L2Norm(Patch *Pat, var *vf, MPI_Comm Comm_here);
|
||||||
|
bool PatList_Interp_Points(MyList<Patch> *PatL, MyList<var> *VarList,
|
||||||
|
int NN, double **XX,
|
||||||
|
double *Shellf, int Symmetry, MPI_Comm Comm_here);
|
||||||
|
#if (PSTR == 1 || PSTR == 2 || PSTR == 3)
|
||||||
|
MyList<Block> *distribute(MyList<Patch> *PatchLIST, int cpusize, int ingfsi, int fngfsi,
|
||||||
|
bool periodic, int start_rank, int end_rank, int nodes = 0);
|
||||||
|
|
||||||
|
// Redistribute blocks with time statistics for load balancing
|
||||||
|
MyList<Block> *distribute(MyList<Patch> *PatchLIST, MyList<Block> *OldBlockL,
|
||||||
|
int cpusize, int ingfsi, int fngfsi,
|
||||||
|
bool periodic, int start_rank, int end_rank, int nodes = 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Dynamic load balancing: split blocks for heavy ranks
|
||||||
|
void split_heavy_blocks(MyList<Patch> *PatL, int *heavy_ranks, int num_heavy,
|
||||||
|
int split_factor, int cpusize, int ingfsi, int fngfsi);
|
||||||
|
|
||||||
|
// Check if load balancing is needed based on interpolation times
|
||||||
|
bool check_load_balance_need(double *rank_times, int nprocs, int &num_heavy, int *heavy_ranks);
|
||||||
|
}
|
||||||
|
#endif /*PARALLEL_H */
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,92 +1,107 @@
|
|||||||
|
|
||||||
#ifndef CGH_H
|
#ifndef CGH_H
|
||||||
#define CGH_H
|
#define CGH_H
|
||||||
|
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
#include "MyList.h"
|
#include "MyList.h"
|
||||||
#include "MPatch.h"
|
#include "MPatch.h"
|
||||||
#include "macrodef.h"
|
#include "macrodef.h"
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include "Parallel.h"
|
#include "Parallel.h"
|
||||||
|
|
||||||
class cgh
|
class cgh
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int levels, movls, BH_num_in;
|
int levels, movls, BH_num_in;
|
||||||
// information of boxes
|
// information of boxes
|
||||||
int *grids;
|
int *grids;
|
||||||
double ***bbox;
|
double ***bbox;
|
||||||
int ***shape;
|
int ***shape;
|
||||||
double ***handle;
|
double ***handle;
|
||||||
double ***Porgls;
|
double ***Porgls;
|
||||||
double *Lt;
|
double *Lt;
|
||||||
|
|
||||||
// information of Patch list
|
// information of Patch list
|
||||||
MyList<Patch> **PatL;
|
MyList<Patch> **PatL;
|
||||||
|
|
||||||
// information of OutBdLow2Hi point list and Restrict point list
|
// information of OutBdLow2Hi point list and Restrict point list
|
||||||
#if (RPB == 1)
|
#if (RPB == 1)
|
||||||
MyList<Parallel::pointstru_bam> **bdsul, **rsul;
|
MyList<Parallel::pointstru_bam> **bdsul, **rsul;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (PSTR == 1 || PSTR == 2 || PSTR == 3)
|
#if (PSTR == 1 || PSTR == 2 || PSTR == 3)
|
||||||
int mylev;
|
int mylev;
|
||||||
int *start_rank, *end_rank;
|
int *start_rank, *end_rank;
|
||||||
MPI_Comm *Commlev;
|
MPI_Comm *Commlev;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int ingfs, fngfs;
|
int ingfs, fngfs;
|
||||||
static constexpr double ratio = 0.75;
|
static constexpr double ratio = 0.75;
|
||||||
int trfls;
|
int trfls;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cgh(int ingfsi, int fngfsi, int Symmetry, char *filename, int checkrun, monitor *ErrorMonitor);
|
cgh(int ingfsi, int fngfsi, int Symmetry, char *filename, int checkrun, monitor *ErrorMonitor);
|
||||||
|
|
||||||
~cgh();
|
~cgh();
|
||||||
|
|
||||||
void compose_cgh(int nprocs);
|
void compose_cgh(int nprocs);
|
||||||
void sethandle(monitor *ErrorMonitor);
|
void sethandle(monitor *ErrorMonitor);
|
||||||
void checkPatchList(MyList<Patch> *PatL, bool buflog);
|
void checkPatchList(MyList<Patch> *PatL, bool buflog);
|
||||||
void Regrid(int Symmetry, int BH_num, double **Porgbr, double **Porg0,
|
void Regrid(int Symmetry, int BH_num, double **Porgbr, double **Porg0,
|
||||||
MyList<var> *OldList, MyList<var> *StateList,
|
MyList<var> *OldList, MyList<var> *StateList,
|
||||||
MyList<var> *FutureList, MyList<var> *tmList, bool BB,
|
MyList<var> *FutureList, MyList<var> *tmList, bool BB,
|
||||||
monitor *ErrorMonitor);
|
monitor *ErrorMonitor);
|
||||||
void Regrid_fake(int Symmetry, int BH_num, double **Porgbr, double **Porg0,
|
void Regrid_fake(int Symmetry, int BH_num, double **Porgbr, double **Porg0,
|
||||||
MyList<var> *OldList, MyList<var> *StateList,
|
MyList<var> *OldList, MyList<var> *StateList,
|
||||||
MyList<var> *FutureList, MyList<var> *tmList, bool BB,
|
MyList<var> *FutureList, MyList<var> *tmList, bool BB,
|
||||||
monitor *ErrorMonitor);
|
monitor *ErrorMonitor);
|
||||||
void recompose_cgh(int nprocs, bool *lev_flag,
|
void recompose_cgh(int nprocs, bool *lev_flag,
|
||||||
MyList<var> *OldList, MyList<var> *StateList,
|
MyList<var> *OldList, MyList<var> *StateList,
|
||||||
MyList<var> *FutureList, MyList<var> *tmList,
|
MyList<var> *FutureList, MyList<var> *tmList,
|
||||||
int Symmetry, bool BB);
|
int Symmetry, bool BB);
|
||||||
void recompose_cgh_fake(int nprocs, bool *lev_flag,
|
void recompose_cgh_fake(int nprocs, bool *lev_flag,
|
||||||
MyList<var> *OldList, MyList<var> *StateList,
|
MyList<var> *OldList, MyList<var> *StateList,
|
||||||
MyList<var> *FutureList, MyList<var> *tmList,
|
MyList<var> *FutureList, MyList<var> *tmList,
|
||||||
int Symmetry, bool BB);
|
int Symmetry, bool BB);
|
||||||
void read_bbox(int Symmetry, char *filename);
|
void read_bbox(int Symmetry, char *filename);
|
||||||
MyList<Patch> *construct_patchlist(int lev, int Symmetry);
|
MyList<Patch> *construct_patchlist(int lev, int Symmetry);
|
||||||
bool Interp_One_Point(MyList<var> *VarList,
|
bool Interp_One_Point(MyList<var> *VarList,
|
||||||
double *XX, /*input global Cartesian coordinate*/
|
double *XX, /*input global Cartesian coordinate*/
|
||||||
double *Shellf, int Symmetry);
|
double *Shellf, int Symmetry);
|
||||||
void recompose_cgh_Onelevel(int nprocs, int lev,
|
void recompose_cgh_Onelevel(int nprocs, int lev,
|
||||||
MyList<var> *OldList, MyList<var> *StateList,
|
MyList<var> *OldList, MyList<var> *StateList,
|
||||||
MyList<var> *FutureList, MyList<var> *tmList,
|
MyList<var> *FutureList, MyList<var> *tmList,
|
||||||
int Symmetry, bool BB);
|
int Symmetry, bool BB);
|
||||||
void Regrid_Onelevel(int lev, int Symmetry, int BH_num, double **Porgbr, double **Porg0,
|
void Regrid_Onelevel(int lev, int Symmetry, int BH_num, double **Porgbr, double **Porg0,
|
||||||
MyList<var> *OldList, MyList<var> *StateList,
|
MyList<var> *OldList, MyList<var> *StateList,
|
||||||
MyList<var> *FutureList, MyList<var> *tmList, bool BB,
|
MyList<var> *FutureList, MyList<var> *tmList, bool BB,
|
||||||
monitor *ErrorMonitor);
|
monitor *ErrorMonitor);
|
||||||
void Regrid_Onelevel_aux(int lev, int Symmetry, int BH_num, double **Porgbr, double **Porg0,
|
void Regrid_Onelevel_aux(int lev, int Symmetry, int BH_num, double **Porgbr, double **Porg0,
|
||||||
MyList<var> *OldList, MyList<var> *StateList,
|
MyList<var> *OldList, MyList<var> *StateList,
|
||||||
MyList<var> *FutureList, MyList<var> *tmList, bool BB,
|
MyList<var> *FutureList, MyList<var> *tmList, bool BB,
|
||||||
monitor *ErrorMonitor);
|
monitor *ErrorMonitor);
|
||||||
void settrfls(const int lev);
|
void settrfls(const int lev);
|
||||||
|
|
||||||
#if (PSTR == 1 || PSTR == 2 || PSTR == 3)
|
#if (PSTR == 1 || PSTR == 2 || PSTR == 3)
|
||||||
void construct_mylev(int nprocs);
|
void construct_mylev(int nprocs);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
// Load balancing support
|
||||||
#endif /* CGH_H */
|
bool enable_load_balance; // Enable load balancing
|
||||||
|
int load_balance_check_interval; // Check interval (in time steps)
|
||||||
|
int current_time_step; // Current time step counter
|
||||||
|
double *rank_interp_times; // Store interpolation times for each rank
|
||||||
|
int *heavy_ranks; // Store heavy rank numbers
|
||||||
|
int num_heavy_ranks; // Number of heavy ranks
|
||||||
|
|
||||||
|
void init_load_balance(int nprocs);
|
||||||
|
void update_interp_time(int rank, double time);
|
||||||
|
bool check_and_rebalance(int nprocs, int lev,
|
||||||
|
MyList<var> *OldList, MyList<var> *StateList,
|
||||||
|
MyList<var> *FutureList, MyList<var> *tmList,
|
||||||
|
int Symmetry, bool BB);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* CGH_H */
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user