Commit 714094eb authored by SilverLife's avatar SilverLife

Chenge octree test

parent b570bd6a
......@@ -5,6 +5,7 @@
#include "inmost.h"
#include <iomanip>
#include <iostream>
#include <sstream>
#define LOG(level,msg) { if (log_level >= level) cout << msg << endl; }
#define BARRIER MPI_Barrier(MPI_COMM_WORLD);
......@@ -145,7 +146,7 @@ void NotMainProcess()
int type = type_C - '0';
//redistribute(&thegrid,type);
pre_redistribute(type);
cout << rank << ": iteration " << iteration++ << " complete. Cells: " << thegrid.mesh->NumberOfCells() << endl;
cout << ::rank << ": iteration " << iteration++ << " complete. Cells: " << thegrid.mesh->NumberOfCells() << endl;
}
if (buff[0] == 'u') // Need remove ghosts
{
......@@ -301,7 +302,6 @@ void parse_arguments(int argc, char** argv, int* n, double* R, int* L, int* log)
}
}
int iters_count = 6;
int main(int argc, char ** argv)
{
......@@ -325,13 +325,17 @@ int main(int argc, char ** argv)
::size = thegrid.mesh->GetProcessorsNumber();
::rank = thegrid.mesh->GetProcessorRank();
//dump_to_vtk();
if (rank == 0) cout << "Test start" << endl;
if (::rank == 0) cout << "Test start" << endl;
{
mx = 0.1;
my = 0.5;
double h = 0.8 / iters_count;
int iters_count = 10;
// double h = 0.8 / iters_count;
// double h = 0.03;
double h = 0.05;
int i = 0;
BARRIER
double st = Timer();
......@@ -339,11 +343,12 @@ int main(int argc, char ** argv)
double time_amr, time_red;
double a_amr = 0;
double a_red = 0;
bool forward = true;
for (int iter = 0; iter < iters_count; iter++)
{
BARRIER
ct = Timer();
if (rank == 0) LOG(1, "Iteration: " << i)
if (::rank == 0) LOG(1, "Iteration: " << i)
gridAMR(&thegrid,0);
BARRIER
tt = Timer();
......@@ -354,30 +359,37 @@ int main(int argc, char ** argv)
tt = Timer();
time_red = tt-ct;
ct = tt;
LOG(2, rank << ": iteration " << i << " complete. Cells: " << thegrid.mesh->NumberOfCells())
LOG(2, ::rank << ": iteration " << i << " complete. Cells: " << thegrid.mesh->NumberOfCells())
if (iter > 0)
{
a_amr += time_amr;
a_red += time_red;
}
if (rank == 0) LOG(1, "AMR time = " << time_amr);
if (rank == 0) LOG(1, "Red time = " << time_red);
dump_to_vtk(&thegrid);
if (::rank == 0) LOG(1, "AMR time = " << time_amr);
if (::rank == 0) LOG(1, "Red time = " << time_red);
// stringstream suffix;
// suffix << "_" << iter;
BARRIER
if (rank == 0) LOG(1, "===============");
if (::rank == 0) LOG(1, "===============");
i++;
if (forward) {
mx += h;
if (mx >= 0.9) forward = false;
} else {
mx -= h;
if (mx <= 0.1) forward = true;
}
}
BARRIER
tt = Timer() - st;
if (rank == 0) cout << "time = " << tt << endl;
if (rank == 0) cout << "Average AMR time = " << a_amr/(iters_count - 1) << endl;
if (rank == 0) cout << "Average RED time = " << a_red/(iters_count - 1) << endl;
if (rank == 0) cout << "time = " << tt << endl;
if (::rank == 0) cout << "time = " << tt << endl;
if (::rank == 0) cout << "Average AMR time = " << a_amr/(iters_count - 1) << endl;
if (::rank == 0) cout << "Average RED time = " << a_red/(iters_count - 1) << endl;
if (::rank == 0) cout << "time = " << tt << endl;
dump_to_vtk(&thegrid);
// send_dump_command();
// send_quit_command();
}
Mesh::Finalize();
......
......@@ -117,7 +117,7 @@ class CR_cells
CR_cells cr_cells;
/// Dump mesh to vtk file in folder "grids"
void dump_to_vtk(grid* g)
void dump_to_vtk(grid* g, const char* suffix)
{
//thegrid.mesh->ResolveShared(); // Resolve duplicate nodes
//thegrid.mesh->ExchangeGhost(2,NODE); // Construct Ghost cells in 2 layers connected via nodes
......@@ -127,12 +127,13 @@ void dump_to_vtk(grid* g)
std::stringstream filename;
filename << "grids/grid_";
filename << size;
filename << suffix;
if( size == 1 )
filename << ".vtk";
else
filename << ".pvtk";
g->mesh->Save(filename.str());
cout << "Process " << rank << ": dumped mesh to file" << endl;
cout << "Process " << rank << ": dumped mesh to file: " << filename.str() << endl;
}
......@@ -1591,8 +1592,8 @@ void gridCoarse(struct grid * g)
// else
// it->Integer(g->c_tags.i) = -1;
}
cr_cells.print_size();
cout << "N time: " << Timer() - tt << endl;
// cr_cells.print_size();
// cout << "N time: " << Timer() - tt << endl;
if (empty)
{
cr_cells.push(g->mesh->BeginCell()->getAsCell());
......@@ -1628,10 +1629,12 @@ void gridCoarse(struct grid * g)
}
*/
time_p += Timer() - ttt;
/*
cout << "Time Prep: " << time_p << endl;
cout << "Time Unit: " << time_u << endl;
cout << "Time Res1: " << time_r1 << endl;
cout << "Time Res2: " << time_r2 << endl;
*/
/*
while (1)
{
......
......@@ -78,7 +78,7 @@ void print_face_nodes(struct grid* g, Face face);
void print_face_edges(struct grid* g, Face face);
void print_cells_statistics(grid* g);
void command(grid* g);
void dump_to_vtk(grid* g);
void dump_to_vtk(grid* g, const char* suffix="");
void redistribute(grid* g,int type);
void print_redist_tag(struct grid* g, int rank);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment