Commit f4860bab authored by Kirill Terekhov's avatar Kirill Terekhov

Update examples

parent 89fa45b0
Pipeline #129 failed with stages
in 2 minutes and 30 seconds
This diff is collapsed.
This diff is collapsed.
......@@ -24,11 +24,6 @@ typedef Storage::enumerator enumerator;
typedef Storage::real_array real_array;
typedef Storage::var_array var_array;
const real reg_abs = 1.0e-12; //regularize abs(x) as sqrt(x*x+reg_abs)
const real reg_div = 1.0e-15; //regularize (|x|+reg_div)/(|x|+|y|+2*reg_div) to reduce to 1/2 when |x| ~= |y| ~= 0
int main(int argc,char ** argv)
{
......@@ -44,13 +39,15 @@ int main(int argc,char ** argv)
{ // Load the mesh
ttt = Timer();
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
{
m->Load(argv[1]); // Load mesh from the parallel file format
repartition = true; // Ask to repartition the mesh
}
else if( m->GetProcessorRank() == 0 ) m->Load(argv[1]); // Load mesh from the serial file format
else if( m->GetProcessorRank() == 0 )
m->Load(argv[1]); // Load mesh from the serial file format
BARRIER
if( m->GetProcessorRank() == 0 ) std::cout << "Load the mesh: " << Timer()-ttt << std::endl;
}
......@@ -452,4 +449,4 @@ int main(int argc,char ** argv)
#endif
Solver::Finalize(); // Finalize solver and close MPI activity
return 0;
}
\ No newline at end of file
}
This diff is collapsed.
......@@ -16,6 +16,7 @@ endif(USE_SOLVER AND USE_MESH)
if(USE_AUTODIFF AND USE_SOLVER AND USE_MESH)
add_subdirectory(ADFVDiscr)
add_subdirectory(ADMFD)
add_subdirectory(ADVDIFF)
add_subdirectory(MFD-ES)
endif(USE_AUTODIFF AND USE_SOLVER AND USE_MESH)
#add_subdirectory(OctreeCutcell)
......
......@@ -16,33 +16,33 @@ using namespace INMOST;
#define BARRIER
#endif
void make_vec(Storage::real v1[3], Storage::real v2[3], Storage::real out[3])
void make_vec(double v1[3], double v2[3], double out[3])
{
out[0] = v1[0] - v2[0];
out[1] = v1[1] - v2[1];
out[2] = v1[2] - v2[2];
}
Storage::real dot_prod(Storage::real v1[3], Storage::real v2[3])
double dot_prod(double v1[3], double v2[3])
{
return v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2];
}
Storage::real transmissibility(Storage::real vec[3], Storage::real K, Storage::real normal_face[3])
double transmissibility(double vec[3], double K, double normal_face[3])
{
Storage::real Kn[3];
double Kn[3];
Kn[0] = K * normal_face[0], Kn[1] = K * normal_face[1], Kn[2] = K * normal_face[2];
return dot_prod(vec,Kn);
}
Storage::real func(Storage::real x[3], Storage::real tmp)
double func(double x[3], double tmp)
{
// return x[0] + 2 * x[1] + 3 * x[2];
return sin (M_PI * x[0]) * sin (M_PI * x[1]) * sin (M_PI * x[2]);
(void) tmp;
}
Storage::real func_rhs(Storage::real x[3], Storage::real tmp)
double func_rhs(double x[3], double tmp)
{
// return 0;
return -3 * tmp * M_PI * M_PI * sin (M_PI * x[0]) * sin (M_PI * x[1]) * sin (M_PI * x[2]);
......@@ -176,10 +176,10 @@ int main(int argc,char ** argv)
Cell r2 = face->FrontCell();
if( ((!r1->isValid() || (s1 = r1->GetStatus()) == Element::Ghost)?0:1) +
((!r2->isValid() || (s2 = r2->GetStatus()) == Element::Ghost)?0:1) == 0) continue;
Storage::real f_nrm[3], r1_cnt[3], r2_cnt[3], f_cnt[3], d1[3], Coef;
Storage::real f_area = face->Area(); // Get the face area
double f_nrm[3], r1_cnt[3], r2_cnt[3], f_cnt[3], d1[3], Coef;
double f_area = face->Area(); // Get the face area
Storage::integer id1 = r1->Integer(id), id2;
Storage::real K1 = r1->Real(tensor_K), K2, Kav;
double K1 = r1->Real(tensor_K), K2, Kav;
face->Normal(f_nrm); // Get the face normal
f_nrm[0] /= f_area;
f_nrm[1] /= f_area;
......@@ -188,7 +188,7 @@ int main(int argc,char ** argv)
face->Barycenter(f_cnt); // Get the barycenter of the face
if( !r2->isValid() ) // boundary condition
{
Storage::real bnd_pnt[3], dist;
double bnd_pnt[3], dist;
make_vec(f_cnt,r1_cnt,d1);
dist = dot_prod(f_nrm,d1) / dot_prod(f_nrm,f_nrm);
// bnd_pnt is a projection of the cell center to the face
......@@ -266,7 +266,7 @@ int main(int argc,char ** argv)
Tag error = m->CreateTag("error",DATA_REAL,CELL,NONE,1);
Storage::real err_C = 0.0, err_L2 = 0.0;
double err_C = 0.0, err_L2 = 0.0;
//for( Mesh::iteratorCell cell = m->BeginCell(); cell != m->EndCell(); ++cell )
#if defined(USE_OMP)
#pragma omp parallel for
......@@ -276,12 +276,12 @@ int main(int argc,char ** argv)
Cell cell(m,ComposeHandle(CELL,ci));
if( cell->GetStatus() != Element::Ghost )
{
Storage::real exact = cell->Mean(func, 0); // Compute the mean value of the function over the cell
Storage::real err = fabs (x[cell->Integer(id)] - exact);
double exact = cell->Mean(func, 0); // Compute the mean value of the function over the cell
double err = fabs (x[cell->Integer(id)] - exact);
if (err > err_C)
err_C = err;
err_L2 += err * err * cell->Volume();
cell->Real(error) = err;
cell->Real(error) = err;
// x[cell->Integer(id)] = err;
}
}
......
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