Commit a3b0eb8a authored by Kirill Terekhov's avatar Kirill Terekhov

Changes related to adaptive mesh example

parent fa8e59dc
......@@ -326,6 +326,7 @@ namespace INMOST
ReleaseMarker(mark_hanging_nodes);
ReleaseMarker(mark_cell_edges);
DeleteTag(internal_face_edges);
//ExchangeData(hanging_nodes,CELL | FACE,0);
//10.jump to later schedule, and go to 7.
schedule_counter--;
}
......@@ -635,12 +636,14 @@ namespace INMOST
}
}
//jump to later schedule
//ExchangeData(hanging_nodes,CELL | FACE,0);
schedule_counter--;
}
//free created tag
DeleteTag(indicator,FACE|EDGE);
//todo:
//ResolveModification();
ResolveShared(true);
ResolveModification();
//todo:
//let the user update their data
ApplyModification();
......@@ -666,4 +669,4 @@ namespace INMOST
call_counter++;
return ret != 0;
}
}
\ No newline at end of file
}
......@@ -9,6 +9,7 @@ int main(int argc, char ** argv)
if( argc > 1 )
{
AdaptiveMesh m;
m.SetCommunicator(INMOST_MPI_COMM_WORLD);
m.Load(argv[1]);
//m.SetTopologyCheck(NEED_TEST_CLOSURE);
//m.SetTopologyCheck(PROHIBIT_MULTILINE);
......@@ -29,6 +30,8 @@ int main(int argc, char ** argv)
if( it->Coords()[d] < cmin[d] ) cmin[d] = it->Coords()[d];
}
}
m.AggregateMax(cmax,3);
m.AggregateMin(cmin,3);
r = 1;
for(int d = 0; d < 3; ++d)
{
......@@ -47,18 +50,20 @@ int main(int argc, char ** argv)
numref = 0;
for(Mesh::iteratorCell it = m.BeginCell(); it != m.EndCell(); ++it) if( m.GetLevel(it->self()) < max_levels )
{
it->Centroid(xyz);
it->Barycenter(xyz);
//refine a circle
q = 0;
for(int d = 0; d < 3; ++d)
q += (xyz[d]-cnt[d])*(xyz[d]-cnt[d]);
q = sqrt(q);
if( q < r*(k+1) && q > r*k)
//if( q < 0.02 )
{
indicator[it->self()] = 1;
numref++;
}
}
numref = m.Integrate(numref);
if( numref )
{
std::cout << "k " << k << " refcnt " << refcnt << " " << r*k << " < r < " << r*(k+1) << " numref " << numref << " cells " << m.NumberOfCells() << std::endl;
......@@ -89,7 +94,7 @@ int main(int argc, char ** argv)
numref = 0;
for(Mesh::iteratorCell it = m.BeginCell(); it != m.EndCell(); ++it) if( m.GetLevel(it->self()) > 0 )
{
it->Centroid(xyz);
it->Barycenter(xyz);
//refine a circle
q = 0;
for(int d = 0; d < 3; ++d)
......@@ -101,6 +106,7 @@ int main(int argc, char ** argv)
numref++;
}
}
numref = m.Integrate(numref);
if( numref )
{
std::cout << "k " << k << " crscnt " << refcnt << " " << r*k << " < r < " << r*(k+1) << " numcrs " << numref << " cells " << m.NumberOfCells() << std::endl;
......@@ -131,11 +137,19 @@ int main(int argc, char ** argv)
{
std::stringstream file;
file << "step_" << k << ".vtk";
file << "step_" << k << ".pvtk";
m.Save(file.str());
}
{
TagInteger tag_owner = m.CreateTag("OWN",DATA_INTEGER,CELL,NONE,1);
TagInteger tag_owner0 = m.GetTag("OWNER_PROCESSOR");
TagInteger tag_stat = m.CreateTag("STAT",DATA_INTEGER,CELL,NONE,1);
for(Mesh::iteratorCell it = m.BeginCell(); it != m.EndCell(); ++it)
{
tag_owner[*it] = tag_owner0[*it];
tag_stat[*it] = it->GetStatus();
}
std::stringstream file;
file << "step_" << k << ".pmf";
m.Save(file.str());
......@@ -143,4 +157,6 @@ int main(int argc, char ** argv)
}
}
else std::cout << "Usage: " << argv[0] << " mesh_file [max_levels=2]" << std::endl;
}
\ No newline at end of file
Mesh::Finalize();
}
......@@ -633,13 +633,32 @@ namespace INMOST
//std::cout << "ORIENTATION" << std::endl;
if( mask & FACE )
{
if( HideMarker() )
{
MarkerType hm = HideMarker();
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer e = 0; e < FaceLastLocalID(); ++e)
for(integer e = 0; e < FaceLastLocalID(); ++e)
{
if( isValidElement(FACE,e) )
{
HandleType h = ComposeHandle(FACE,e);
if( !GetMarker(h,hm) )
Face(this,h)->FixNormalOrientation();
}
}
}
else
{
if( isValidElement(FACE,e) )
Face(this,ComposeHandle(FACE,e))->FixNormalOrientation();
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer e = 0; e < FaceLastLocalID(); ++e)
{
if( isValidElement(FACE,e) )
Face(this,ComposeHandle(FACE,e))->FixNormalOrientation();
}
}
}
ShowGeometricData(ORIENTATION,FACE);
......@@ -652,13 +671,28 @@ namespace INMOST
if( (mask & etype) && !HaveGeometricData(MEASURE,etype))
{
measure_tag = CreateTag(measure_name,DATA_REAL,etype,NONE,1);
if( HideMarker() )
{
MarkerType hm = HideMarker();
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer e = 0; e < LastLocalID(etype); ++e) if( isValidElement(etype,e) )
for(integer e = 0; e < LastLocalID(etype); ++e) if( isValidElement(etype,e) )
{
HandleType h = ComposeHandle(etype,e);
if( !GetMarker(h,hm) ) GetGeometricData(h,MEASURE,static_cast<Storage::real *>(MGetDenseLink(h,measure_tag)));
}
}
else
{
HandleType h = ComposeHandle(etype,e);
GetGeometricData(h,MEASURE,static_cast<Storage::real *>(MGetDenseLink(h,measure_tag)));
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer e = 0; e < LastLocalID(etype); ++e) if( isValidElement(etype,e) )
{
HandleType h = ComposeHandle(etype,e);
GetGeometricData(h,MEASURE,static_cast<Storage::real *>(MGetDenseLink(h,measure_tag)));
}
}
ShowGeometricData(MEASURE,etype);
}
......@@ -672,13 +706,28 @@ namespace INMOST
if( (mask & etype) && !HaveGeometricData(CENTROID,etype))
{
centroid_tag = CreateTag(centroid_name,DATA_REAL,etype,NONE,GetDimensions());
if( HideMarker() )
{
MarkerType hm = HideMarker();
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer k = 0; k < LastLocalID(etype); ++k) if( isValidElement(etype,k) )
for(integer k = 0; k < LastLocalID(etype); ++k) if( isValidElement(etype,k) )
{
HandleType h = ComposeHandle(etype,k);
if( !GetMarker(h,hm) ) GetGeometricData(h,CENTROID,static_cast<Storage::real *>(MGetDenseLink(h,centroid_tag)));
}
}
else
{
HandleType h = ComposeHandle(etype,k);
GetGeometricData(h,CENTROID,static_cast<Storage::real *>(MGetDenseLink(h,centroid_tag)));
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer k = 0; k < LastLocalID(etype); ++k) if( isValidElement(etype,k) )
{
HandleType h = ComposeHandle(etype,k);
GetGeometricData(h,CENTROID,static_cast<Storage::real *>(MGetDenseLink(h,centroid_tag)));
}
}
ShowGeometricData(CENTROID,etype);
}
......@@ -692,13 +741,28 @@ namespace INMOST
if( (mask & etype) && !HaveGeometricData(BARYCENTER,etype))
{
barycenter_tag = CreateTag(barycenter_name,DATA_REAL,etype,NONE,GetDimensions());
if( HideMarker() )
{
MarkerType hm = HideMarker();
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer e = 0; e < LastLocalID(etype); ++e) if( isValidElement(etype,e) )
for(integer e = 0; e < LastLocalID(etype); ++e) if( isValidElement(etype,e) )
{
HandleType h = ComposeHandle(etype,e);
if( !GetMarker(h,hm) ) GetGeometricData(h,BARYCENTER,static_cast<Storage::real *>(MGetDenseLink(h,barycenter_tag)));
}
}
else
{
HandleType h = ComposeHandle(etype,e);
GetGeometricData(h,BARYCENTER,static_cast<Storage::real *>(MGetDenseLink(h,barycenter_tag)));
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer e = 0; e < LastLocalID(etype); ++e) if( isValidElement(etype,e) )
{
HandleType h = ComposeHandle(etype,e);
GetGeometricData(h,BARYCENTER,static_cast<Storage::real *>(MGetDenseLink(h,barycenter_tag)));
}
}
ShowGeometricData(BARYCENTER,etype);
}
......@@ -712,13 +776,28 @@ namespace INMOST
if( (mask & etype) && !HaveGeometricData(NORMAL,etype))
{
normal_tag = CreateTag(normal_name,DATA_REAL,etype,NONE,GetDimensions());
if( HideMarker() )
{
MarkerType hm = HideMarker();
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer e = 0; e < LastLocalID(etype); ++e) if( isValidElement(etype,e) )
for(integer e = 0; e < LastLocalID(etype); ++e) if( isValidElement(etype,e) )
{
HandleType h = ComposeHandle(etype,e);
if( !GetMarker(h,hm) ) GetGeometricData(h,NORMAL,static_cast<Storage::real *>(MGetDenseLink(h,normal_tag)));
}
}
else
{
HandleType h = ComposeHandle(etype,e);
GetGeometricData(h,NORMAL,static_cast<Storage::real *>(MGetDenseLink(h,normal_tag)));
#if defined(USE_OMP)
#pragma omp parallel for
#endif
for(integer e = 0; e < LastLocalID(etype); ++e) if( isValidElement(etype,e) )
{
HandleType h = ComposeHandle(etype,e);
GetGeometricData(h,NORMAL,static_cast<Storage::real *>(MGetDenseLink(h,normal_tag)));
}
}
ShowGeometricData(NORMAL,etype);
}
......
......@@ -1628,17 +1628,16 @@ namespace INMOST
Tag tag = CreateTag("TEMP_DISTANSE",DATA_REAL,CELL,CELL,2);
for(Mesh::iteratorCell it = BeginCell(); it != EndCell(); it++) if (GetMarker(*it,NewMarker()))
for(Mesh::iteratorCell it = BeginCell(); it != EndCell(); it++) if (GetMarker(*it,NewMarker()) && (it->GetStatus() == Element::Ghost || it->GetStatus() == Element::Shared) )
{
double min = 0;
int first = 0;
double mind = 1.0e+100;
Cell near_cell;
for(Mesh::iteratorCell jt = BeginCell(); jt != EndCell(); jt++) if (GetMarker(*jt,NewMarker()) == false)
for(Mesh::iteratorCell jt = BeginCell(); jt != EndCell(); jt++) if (GetMarker(*jt,NewMarker()) == false && jt->GetStatus() == Element::Owned)
{
double d = dist(it->getAsCell(), jt->getAsCell());
if (first++ == 0 || min > d)
if (mind > d)
{
min = d;
mind = d;
near_cell = jt->getAsCell();
}
}
......@@ -1647,13 +1646,13 @@ namespace INMOST
int owner2 = near_cell.IntegerDF(tag_owner);
it->RealArray(tag)[0] = owner2;
it->RealArray(tag)[1] = min;
it->RealArray(tag)[1] = mind;
}
ReduceData(tag, CELL, 0, OperationMinDistance);
ExchangeData(tag, CELL, 0);
for(Mesh::iteratorCell it = BeginCell(); it != EndCell(); it++) if (GetMarker(*it,NewMarker()))
for(Mesh::iteratorCell it = BeginCell(); it != EndCell(); it++) if (GetMarker(*it,NewMarker()) && (it->GetStatus() == Element::Ghost || it->GetStatus() == Element::Shared) )
{
int new_owner = (int)it->RealArray(tag)[0];
......@@ -1685,6 +1684,15 @@ namespace INMOST
Destroy(h);
}
}
for(ElementType etype = FACE; etype >= NODE; etype = PrevElementType(etype))
{
for(integer it = 0; it < LastLocalID(etype); ++it) if( isValidElement(etype,it) )
{
if( ElementByLocalID(etype,it).nbAdjElements(NextElementType(etype)) == 0 )
Destroy(ComposeHandle(etype,it));
}
}
RecomputeParallelStorage(ESET|CELL|FACE|EDGE|NODE);
memset(hidden_count,0,sizeof(integer)*6);
memset(hidden_count_zero,0,sizeof(integer)*6);
ReleaseMarker(hide_element);
......
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