Commit ffe8de78 authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

update N-S turek test

parent f3cc075f
...@@ -44,7 +44,9 @@ int main(int argc,char ** argv) ...@@ -44,7 +44,9 @@ int main(int argc,char ** argv)
Mesh * m = new Mesh(); // Create an empty mesh Mesh * m = new Mesh(); // Create an empty mesh
{ // Load the mesh { // Load the mesh
ttt = Timer(); ttt = Timer();
m->SetCommunicator(INMOST_MPI_COMM_WORLD); // Set the MPI communicator for the mesh //~ m->SetParallelFileStrategy(0);
//~ m->SetParallelStrategy(1);
//~ m->SetCommunicator(INMOST_MPI_COMM_WORLD); // Set the MPI communicator for the mesh
if( m->GetProcessorRank() == 0 ) std::cout << "Processors: " << m->GetProcessorsNumber() << std::endl; if( m->GetProcessorRank() == 0 ) std::cout << "Processors: " << m->GetProcessorsNumber() << std::endl;
if( m->isParallelFileFormat(argv[1]) ) //The format is if( m->isParallelFileFormat(argv[1]) ) //The format is
{ {
...@@ -341,8 +343,10 @@ int main(int argc,char ** argv) ...@@ -341,8 +343,10 @@ int main(int argc,char ** argv)
if( R.Norm() < 1.0e-4 ) break; if( R.Norm() < 1.0e-4 ) break;
//Solver S(Solver::INNER_ILU2); //Solver S(Solver::INNER_ILU2);
Solver S(Solver::INNER_MPTILUC); //~ Solver S(Solver::INNER_MPTILUC);
Solver S(Solver::K3BIILU2);
//Solver S("superlu"); //Solver S("superlu");
S.SetParameter("verbosity","1");
S.SetParameter("relative_tolerance", "1.0e-14"); S.SetParameter("relative_tolerance", "1.0e-14");
S.SetParameter("absolute_tolerance", "1.0e-12"); S.SetParameter("absolute_tolerance", "1.0e-12");
S.SetParameter("drop_tolerance", "1.0e-2"); S.SetParameter("drop_tolerance", "1.0e-2");
......
...@@ -32,7 +32,7 @@ int main(int argc, char ** argv) ...@@ -32,7 +32,7 @@ int main(int argc, char ** argv)
if( argc < 2 ) if( argc < 2 )
{ {
std::cout << "Usage: " << argv[0] << " mesh [mesh_out=grid_out.pmf] [Umax=2.25]" << std::endl; std::cout << "Usage: " << argv[0] << " mesh [mesh_out=grid_out.pmf] [Umax=2.25] [fix_cylinder=false]" << std::endl;
return 0; return 0;
} }
...@@ -50,8 +50,10 @@ int main(int argc, char ** argv) ...@@ -50,8 +50,10 @@ int main(int argc, char ** argv)
std::string fout = "grid_out.pmf"; std::string fout = "grid_out.pmf";
double Umax = 2.25; double Umax = 2.25;
bool fix_cylinder = false;
if( argc > 2 ) fout = std::string(argv[2]); if( argc > 2 ) fout = std::string(argv[2]);
if( argc > 3 ) Umax = atof(argv[3]); if( argc > 3 ) Umax = atof(argv[3]);
if( argc > 4 ) fix_cylinder = atoi(argv[4]);
...@@ -84,14 +86,111 @@ int main(int argc, char ** argv) ...@@ -84,14 +86,111 @@ int main(int argc, char ** argv)
for(Mesh::iteratorFace it = m->BeginFace(); it != m->EndFace(); ++it) if( it->Boundary() ) for(Mesh::iteratorFace it = m->BeginFace(); it != m->EndFace(); ++it) if( it->Boundary() )
it->FixNormalOrientation(); it->FixNormalOrientation();
{ // prepare geometrical data on the mesh
Mesh::GeomParam table;
table[CENTROID] = CELL | FACE; //Compute averaged center of mass
table[NORMAL] = FACE; //Compute normals
table[MEASURE] = CELL | FACE; //Compute volumes and areas
table[BARYCENTER] = CELL | FACE; //Compute volumetric center of mass
m->RemoveGeometricData(table); //Ask to precompute the data
}
if( fix_cylinder )
{
MarkerType cylinder = m->CreateMarker();
for(Mesh::iteratorFace it = m->BeginFace(); it != m->EndFace(); ++it) if( it->Boundary() )
{
double n[3], c[3];
it->UnitNormal(n);
it->Centroid(c);
if( fabs(n[0]-1) < 1.0e-3 && c[0] > 2.5-eps) // outflow
{
}
else if( fabs(n[0]+1) < 1.0e-3 && c[0] < 0.0+eps) //inflow
{
}
else //no-slip walls
{
if( fabs(n[2]) < 0.7 && c[0] > 0.45-eps && c[0] < 0.55+eps && c[1] > 0.15-eps && c[1] < 0.25+eps )
it->SetMarker(cylinder);
}
}
for(Mesh::iteratorNode it = m->BeginNode(); it != m->EndNode(); ++it)
if( it->nbAdjElements(FACE,cylinder) ) it->SetMarker(cylinder);
TagRealArray vec_t = m->CreateTag("vec_t",DATA_REAL,FACE,FACE,2);
std::cout << "project boundary nodes onto cylinder " << std::endl;
for(Mesh::iteratorNode it = m->BeginNode(); it != m->EndNode(); ++it) if( it->GetMarker(cylinder) )
{
double x = it->Coords()[0], y = it->Coords()[1], dx, dy;
double r = sqrt((x-0.5)*(x-0.5) + (y-0.2)*(y-0.2));
if( r )
{
dx = (0.05/r-1.0)*(x-0.5);
dy = (0.05/r-1.0)*(y-0.2);
//std::cout << "at " << x << "," << y << " r " << r << " dx " << dx << " dy " << dy << std::endl;
it->Coords()[0] += dx;
it->Coords()[1] += dy;
}
else std::cout << "node at center of cylinder: " << x << "," << y << std::endl;
}
std::cout << "project centers of boundary faces onto cylinder " << std::endl;
int iter = 0;
while(iter < 1000)
{
double A = 0, err = 0, fA;
for(Mesh::iteratorFace it = m->BeginFace(); it != m->EndFace(); ++it) if( it->GetMarker(cylinder) )
{
double cnt[3], dx, dy;
it->Centroid(cnt);
double r = sqrt((cnt[0]-0.5)*(cnt[0]-0.5) + (cnt[1]-0.2)*(cnt[1]-0.2));
if( r )
{
dx = (0.05/r-1.0)*(cnt[0]-0.5);
dy = (0.05/r-1.0)*(cnt[1]-0.2);
//std::cout << "at " << cnt[0] << "," << cnt[1] << " r " << r << " dx " << dx << " dy " << dy << std::endl;
vec_t[*it][0] = dx;
vec_t[*it][1] = dy;
fA = it->Area();
err += sqrt(dx*dx+dy*dy)*fA;
A += fA;
}
else std::cout << " face center is at center of cylinder: " << cnt[0] << "," << cnt[1] << std::endl;
}
err = err/A;
if( iter % 50 == 0 )
std::cout << "iter " << iter << " error: " << err << " area " << A << std::endl;
if( err < 1.0e-8 ) break;
for(Mesh::iteratorNode it = m->BeginNode(); it != m->EndNode(); ++it) if( it->GetMarker(cylinder) )
{
ElementArray<Face> faces = it->getFaces(cylinder);
double dxy[2] = {0,0}, dxyA = 0;
for(ElementArray<Face>::iterator jt = faces.begin(); jt != faces.end(); ++jt)
{
fA = jt->Area();
dxy[0] += vec_t[*jt][0]*fA;
dxy[1] += vec_t[*jt][1]*fA;
dxyA += fA;
}
dxy[0] /= dxyA;
dxy[1] /= dxyA;
it->Coords()[0] += dxy[0];
it->Coords()[1] += dxy[1];
}
iter++;
}
m->DeleteTag(vec_t);
m->ReleaseMarker(cylinder,FACE);
}
for(Mesh::iteratorFace it = m->BeginFace(); it != m->EndFace(); ++it) if( it->Boundary() ) for(Mesh::iteratorFace it = m->BeginFace(); it != m->EndFace(); ++it) if( it->Boundary() )
{ {
double n[3], c[3]; double n[3], c[3];
it->UnitNormal(n); it->UnitNormal(n);
it->Barycenter(c); it->Centroid(c);
bcphi[*it][0] = 1; bcphi[*it][0] = 1;
bcphi[*it][1] = 0; bcphi[*it][1] = 0;
bcphi[*it][2] = 0; bcphi[*it][2] = 0;
......
This diff is collapsed.
...@@ -34,10 +34,10 @@ static bool allow_pivot = true; ...@@ -34,10 +34,10 @@ static bool allow_pivot = true;
#define ESTIMATOR #define ESTIMATOR
#define ESTIMATOR_REFINE #define ESTIMATOR_REFINE
#define PREMATURE_DROPPING //~ #define PREMATURE_DROPPING
//#define EQUALIZE_1NORM //#define EQUALIZE_1NORM
//#define EQUALIZE_2NORM //~ #define EQUALIZE_2NORM
#define EQUALIZE_IDOMINANCE #define EQUALIZE_IDOMINANCE
#define PIVOT_THRESHOLD #define PIVOT_THRESHOLD
...@@ -51,9 +51,9 @@ static bool allow_pivot = true; ...@@ -51,9 +51,9 @@ static bool allow_pivot = true;
//#define PIVOT_COND_DEFAULT 0.1/tau //#define PIVOT_COND_DEFAULT 0.1/tau
#define PIVOT_COND_DEFAULT 1.0e+2 #define PIVOT_COND_DEFAULT 1.0e+2
#define PIVOT_DIAG_DEFAULT 1.0e+5 #define PIVOT_DIAG_DEFAULT 1.0e+5
#define SCHUR_DROPPING_LF //~ #define SCHUR_DROPPING_LF
#define SCHUR_DROPPING_EU //~ #define SCHUR_DROPPING_EU
#define SCHUR_DROPPING_S //~ #define SCHUR_DROPPING_S
#define DIAGONAL_PIVOT #define DIAGONAL_PIVOT
#define CONDITION_PIVOT #define CONDITION_PIVOT
...@@ -2448,7 +2448,7 @@ static bool allow_pivot = true; ...@@ -2448,7 +2448,7 @@ static bool allow_pivot = true;
NuL_tmp = NuL1_new; NuL_tmp = NuL1_new;
#endif #endif
#if defined(CONDITION_PIVOT) #if defined(CONDITION_PIVOT)
if(allow_pivot && !block_pivot && (NuU_tmp > pivot_cond || NuL_tmp > pivot_cond || NuD > pivot_cond) ) if(allow_pivot && !block_pivot && (NuU_tmp > pivot_cond || NuL_tmp > pivot_cond || NuD > pivot_diag) )
{ {
//restore condition number //restore condition number
NuL1 = NuU1_old; NuL1 = NuU1_old;
...@@ -2497,7 +2497,7 @@ static bool allow_pivot = true; ...@@ -2497,7 +2497,7 @@ static bool allow_pivot = true;
#if defined(ILUC2) #if defined(ILUC2)
U2_Address[k].first = static_cast<INMOST_DATA_ENUM_TYPE>(LU2_Entries.size()); U2_Address[k].first = static_cast<INMOST_DATA_ENUM_TYPE>(LU2_Entries.size());
#endif #endif
/*
Unum = Unorm = 0; Unum = Unorm = 0;
Ui = LineIndecesU[k]; Ui = LineIndecesU[k];
...@@ -2509,20 +2509,20 @@ static bool allow_pivot = true; ...@@ -2509,20 +2509,20 @@ static bool allow_pivot = true;
Ui = LineIndecesU[Ui]; Ui = LineIndecesU[Ui];
} }
if( Unum ) Unorm = sqrt(Unorm/Unum); if( Unum ) Unorm = sqrt(Unorm/Unum);
*/
//Unorm = std::min(1.0,Unorm); //Unorm = std::min(1.0,Unorm);
Ui = LineIndecesU[k]; Ui = LineIndecesU[k];
while (Ui != EOL) while (Ui != EOL)
{ {
u = fabs(LineValuesU[Ui]); u = fabs(LineValuesU[Ui]);
if (u*NuU > tau)// *Unorm) // apply dropping rule if (u*NuU > tau )//*Unorm) // apply dropping rule
//if (u*NuU*NuU_acc*NuD*NuD_acc > tau) // apply dropping rule //if (u*NuU*NuU_acc*NuD*NuD_acc > tau) // apply dropping rule
//if (u*NuU_acc*NuD_acc > tau) // apply dropping rule //if (u*NuU_acc*NuD_acc > tau) // apply dropping rule
//if( u > tau*Unorm ) //if( u > tau*Unorm )
LU_Entries.push_back(Sparse::Row::make_entry(Ui, LineValuesU[Ui])); LU_Entries.push_back(Sparse::Row::make_entry(Ui, LineValuesU[Ui]));
#if defined(ILUC2) #if defined(ILUC2)
else if (u*NuU > tau2)// *Unorm) else if (u*NuU > tau2 )//*Unorm)
//else if (u*NuU*NuU_acc*NuD*NuD_acc > tau2) //else if (u*NuU*NuU_acc*NuD*NuD_acc > tau2)
//else if (u*NuU_acc*NuD_acc > tau2) //else if (u*NuU_acc*NuD_acc > tau2)
//else if( u > tau2*Unorm ) //else if( u > tau2*Unorm )
...@@ -2543,7 +2543,7 @@ static bool allow_pivot = true; ...@@ -2543,7 +2543,7 @@ static bool allow_pivot = true;
#if defined(ILUC2) #if defined(ILUC2)
L2_Address[k].first = static_cast<INMOST_DATA_ENUM_TYPE>(LU2_Entries.size()); L2_Address[k].first = static_cast<INMOST_DATA_ENUM_TYPE>(LU2_Entries.size());
#endif #endif
/*
Lnum = Lnorm = 0; Lnum = Lnorm = 0;
Li = LineIndecesL[k]; Li = LineIndecesL[k];
...@@ -2555,20 +2555,20 @@ static bool allow_pivot = true; ...@@ -2555,20 +2555,20 @@ static bool allow_pivot = true;
Li = LineIndecesL[Li]; Li = LineIndecesL[Li];
} }
if( Lnum ) Lnorm = sqrt(Lnorm/Lnum); if( Lnum ) Lnorm = sqrt(Lnorm/Lnum);
*/
//Lnorm = std::min(1.0,Lnorm); //Lnorm = std::min(1.0,Lnorm);
Li = LineIndecesL[k]; Li = LineIndecesL[k];
while (Li != EOL) while (Li != EOL)
{ {
u = fabs(LineValuesL[Li]); u = fabs(LineValuesL[Li]);
if (u*NuL > tau) // *Lnorm) //apply dropping if (u*NuL > tau )//*Lnorm) //apply dropping
//if (u*NuL*NuL_acc*NuD*NuD_acc > tau) //apply dropping //if (u*NuL*NuL_acc*NuD*NuD_acc > tau) //apply dropping
//if (u*NuL_acc*NuD_acc > tau) //apply dropping //if (u*NuL_acc*NuD_acc > tau) //apply dropping
//if( u > tau*Lnorm ) //if( u > tau*Lnorm )
LU_Entries.push_back(Sparse::Row::make_entry(Li, LineValuesL[Li])); LU_Entries.push_back(Sparse::Row::make_entry(Li, LineValuesL[Li]));
#if defined(ILUC2) #if defined(ILUC2)
else if (u*NuL > tau2)// *Lnorm) else if (u*NuL > tau2 )//*Lnorm)
//else if (u*NuL*NuL_acc*NuD*NuD_acc > tau2) //else if (u*NuL*NuL_acc*NuD*NuD_acc > tau2)
//else if (u*NuL_acc*NuD_acc > tau2) //else if (u*NuL_acc*NuD_acc > tau2)
//else if( u > tau2*Lnorm ) //else if( u > tau2*Lnorm )
......
...@@ -35,8 +35,8 @@ using namespace INMOST; ...@@ -35,8 +35,8 @@ using namespace INMOST;
//#define PREMATURE_DROPPING //#define PREMATURE_DROPPING
//#define EQUALIZE_1NORM //#define EQUALIZE_1NORM
//#define EQUALIZE_2NORM #define EQUALIZE_2NORM
#define EQUALIZE_IDOMINANCE //#define EQUALIZE_IDOMINANCE
#define PIVOT_THRESHOLD #define PIVOT_THRESHOLD
#define PIVOT_THRESHOLD_VALUE 1.0e-9 #define PIVOT_THRESHOLD_VALUE 1.0e-9
......
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