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

Fixes #5

Adapting mesh_file.cpp to new comparator's behavior.
parent c5f557ac
...@@ -146,11 +146,23 @@ Storage::real tensor_K_mat_rotOxy(Storage::integer mat) ...@@ -146,11 +146,23 @@ Storage::real tensor_K_mat_rotOxy(Storage::integer mat)
int main(int argc,char ** argv) int main(int argc,char ** argv)
{ {
Mesh::Initialize(&argc,&argv);
Solver::Initialize(&argc,&argv,"database.txt"); Solver::Initialize(&argc,&argv,"database.txt");
#if defined(USE_PARTITIONER) #if defined(USE_PARTITIONER)
Partitioner::Initialize(&argc,&argv); Partitioner::Initialize(&argc,&argv);
#endif #endif
{
Mesh m;
//m.SetFileOption("VERBOSITY","2");
m.Load(argv[1]);
m.Save("dump.pvtk");
}
Solver::Finalize();
Partitioner::Finalize();
Mesh::Finalize();
return 0;
if( argc > 1 ) if( argc > 1 )
{ {
Tag phi, tensor_K, id, mat; Tag phi, tensor_K, id, mat;
......
...@@ -372,8 +372,25 @@ namespace INMOST ...@@ -372,8 +372,25 @@ namespace INMOST
#if defined(USE_MPI_P2P) #if defined(USE_MPI_P2P)
if( m_state == Mesh::Parallel ) if( m_state == Mesh::Parallel )
{ {
MPI_Free_mem(shared_space); int test = 0;
MPI_Win_free(&window); MPI_Finalized(&test);
if( !test )
{
MPI_Free_mem(shared_space);
MPI_Win_free(&window);
}
else
{
std::cout << "Cannot release memory and window allocated by MPI" << std::endl;
std::cout << "since MPI was already finalized. Most likely this" << std::endl;
std::cout << "happens when you define class Mesh in main() function" << std::endl;
std::cout << "so that destructor get called after Mesh::Finalize()" << std::endl;
std::cout << "Please enclose area where you use Mesh class" << std::endl;
std::cout << "with scopes, so that destructor get called when" << std::endl;
std::cout << "execution goes out of the scope or dynamically" << std::endl;
std::cout << "allocate and explicitly delete Mesh class." << std::endl;
std::cout << "Thank you!" << std::endl;
}
//~ MPI_Comm_free(&comm); //~ MPI_Comm_free(&comm);
} }
#endif //USE_MPI_P2P #endif //USE_MPI_P2P
......
...@@ -581,7 +581,12 @@ ecl_exit_loop: ...@@ -581,7 +581,12 @@ ecl_exit_loop:
if( !old_nodes.empty() ) if( !old_nodes.empty() )
{ {
std::vector<HandleType>::iterator it = std::lower_bound(old_nodes.begin(),old_nodes.end(),node_xyz,CentroidComparator(this)); std::vector<HandleType>::iterator it = std::lower_bound(old_nodes.begin(),old_nodes.end(),node_xyz,CentroidComparator(this));
if( it != old_nodes.end() ) find = static_cast<int>(it - old_nodes.begin()); if( it != old_nodes.end() )
{
Storage::real_array c = RealArrayDF(*it,CoordsTag());
if( CentroidComparator(this).Compare(node_xyz,c.data()) == 0 )
find = static_cast<int>(it - old_nodes.begin());
}
} }
if( find == -1 ) newnodes[numnode++] = CreateNode(node_xyz)->GetHandle(); if( find == -1 ) newnodes[numnode++] = CreateNode(node_xyz)->GetHandle();
else newnodes[numnode++] = old_nodes[find]; else newnodes[numnode++] = old_nodes[find];
...@@ -793,7 +798,14 @@ ecl_exit_loop: ...@@ -793,7 +798,14 @@ ecl_exit_loop:
old_nodes[qq++] = *it; old_nodes[qq++] = *it;
} }
if( !old_nodes.empty() ) if( !old_nodes.empty() )
{
std::sort(old_nodes.begin(),old_nodes.end(),CentroidComparator(this)); std::sort(old_nodes.begin(),old_nodes.end(),CentroidComparator(this));
//for(std::vector<HandleType>::iterator it = old_nodes.begin(); it != old_nodes.end(); ++it)
//{
// Storage::real_array c = RealArrayDF(*it,CoordsTag());
// REPORT_VAL("coord: ",c[0] << " " << c[1] << " " << c[2]);
//}
}
FILE * f = fopen(File.c_str(),"r"); FILE * f = fopen(File.c_str(),"r");
...@@ -1335,7 +1347,12 @@ ecl_exit_loop: ...@@ -1335,7 +1347,12 @@ ecl_exit_loop:
if( !old_nodes.empty() ) if( !old_nodes.empty() )
{ {
std::vector<HandleType>::iterator it = std::lower_bound(old_nodes.begin(),old_nodes.end(),coords,CentroidComparator(this)); std::vector<HandleType>::iterator it = std::lower_bound(old_nodes.begin(),old_nodes.end(),coords,CentroidComparator(this));
if( it != old_nodes.end() ) find = static_cast<int>(it - old_nodes.begin()); if( it != old_nodes.end() )
{
Storage::real_array c = RealArrayDF(*it,CoordsTag());
if( CentroidComparator(this).Compare(c.data(),coords) == 0 )
find = static_cast<int>(it - old_nodes.begin());
}
} }
if( find == -1 ) if( find == -1 )
newnodes[i] = CreateNode(coords)->GetHandle(); newnodes[i] = CreateNode(coords)->GetHandle();
...@@ -1365,7 +1382,12 @@ ecl_exit_loop: ...@@ -1365,7 +1382,12 @@ ecl_exit_loop:
if( !old_nodes.empty() ) if( !old_nodes.empty() )
{ {
std::vector<HandleType>::iterator it = std::lower_bound(old_nodes.begin(),old_nodes.end(),coords,CentroidComparator(this)); std::vector<HandleType>::iterator it = std::lower_bound(old_nodes.begin(),old_nodes.end(),coords,CentroidComparator(this));
if( it != old_nodes.end() ) find = static_cast<int>(it - old_nodes.begin()); if( it != old_nodes.end() )
{
Storage::real_array c = RealArrayDF(*it,CoordsTag());
if( CentroidComparator(this).Compare(c.data(),coords) == 0 )
find = static_cast<int>(it - old_nodes.begin());
}
} }
if( find == -1 ) newnodes[i] = CreateNode(coords)->GetHandle(); if( find == -1 ) newnodes[i] = CreateNode(coords)->GetHandle();
else newnodes[i] = old_nodes[find]; else newnodes[i] = old_nodes[find];
...@@ -2105,7 +2127,12 @@ ecl_exit_loop: ...@@ -2105,7 +2127,12 @@ ecl_exit_loop:
if( !old_nodes.empty() ) if( !old_nodes.empty() )
{ {
std::vector<HandleType>::iterator it = std::lower_bound(old_nodes.begin(),old_nodes.end(),xyz,CentroidComparator(this)); std::vector<HandleType>::iterator it = std::lower_bound(old_nodes.begin(),old_nodes.end(),xyz,CentroidComparator(this));
if( it != old_nodes.end() ) find = static_cast<int>(it - old_nodes.begin()); if( it != old_nodes.end() )
{
Storage::real_array c = RealArrayDF(*it,CoordsTag());
if( CentroidComparator(this).Compare(xyz,c.data()) == 0 )
find = static_cast<int>(it - old_nodes.begin());
}
} }
if( find == -1 ) newnodes[i] = CreateNode(xyz)->GetHandle(); if( find == -1 ) newnodes[i] = CreateNode(xyz)->GetHandle();
else newnodes[i] = old_nodes[find]; else newnodes[i] = old_nodes[find];
...@@ -2471,7 +2498,12 @@ read_node_num_link: ...@@ -2471,7 +2498,12 @@ read_node_num_link:
if( !old_nodes.empty() ) if( !old_nodes.empty() )
{ {
std::vector<HandleType>::iterator it = std::lower_bound(old_nodes.begin(),old_nodes.end(),xyz,CentroidComparator(this)); std::vector<HandleType>::iterator it = std::lower_bound(old_nodes.begin(),old_nodes.end(),xyz,CentroidComparator(this));
if( it != old_nodes.end() ) find = static_cast<int>(it - old_nodes.begin()); if( it != old_nodes.end() )
{
Storage::real_array c = RealArrayDF(*it,CoordsTag());
if( CentroidComparator(this).Compare(xyz,c.data()) == 0 )
find = static_cast<int>(it - old_nodes.begin());
}
} }
if( find == -1 ) newnodes[nodenum] = CreateNode(xyz)->GetHandle(); if( find == -1 ) newnodes[nodenum] = CreateNode(xyz)->GetHandle();
else newnodes[nodenum] = old_nodes[find]; else newnodes[nodenum] = old_nodes[find];
...@@ -3236,7 +3268,12 @@ read_elem_num_link: ...@@ -3236,7 +3268,12 @@ read_elem_num_link:
if( !old_nodes.empty() ) if( !old_nodes.empty() )
{ {
std::vector<HandleType>::iterator it = std::lower_bound(old_nodes.begin(),old_nodes.end(),coords,CentroidComparator(this)); std::vector<HandleType>::iterator it = std::lower_bound(old_nodes.begin(),old_nodes.end(),coords,CentroidComparator(this));
if( it != old_nodes.end() ) find = static_cast<int>(it - old_nodes.begin()); if( it != old_nodes.end() )
{
Storage::real_array c = RealArrayDF(*it,CoordsTag());
if( CentroidComparator(this).Compare(coords,c.data()) == 0 )
find = static_cast<int>(it - old_nodes.begin());
}
} }
if( find == -1 ) new_nodes[i] = CreateNode(coords)->GetHandle(); if( find == -1 ) new_nodes[i] = CreateNode(coords)->GetHandle();
else new_nodes[i] = old_nodes[find]; else new_nodes[i] = old_nodes[find];
......
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