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

More functions in Model class for adpative grids

parent 64babb1b
......@@ -618,6 +618,8 @@ namespace INMOST
//set increased level for new edges
level[new_edges[0]] = level[new_edges[1]] = level[e]+1;
if( model ) model->EdgeRefinement(e,new_edges);
//for(int q = 0; q < 2; ++q)
//{
// REPORT_STR("new edges["<<q<<"]" << new_edges[q].LocalID() << " nodes " << new_edges[q].getBeg().LocalID() << "," << new_edges[q].getEnd().LocalID() << " level " << level[new_edges[q]]);
......@@ -704,6 +706,7 @@ namespace INMOST
//set increased level to new faces
for(ElementArray<Face>::size_type kt = 0; kt < new_faces.size(); ++kt)
level[new_faces[kt]] = level[f]+1;
if( model ) model->FaceRefinement(f,new_faces);
}
}
EXIT_BLOCK();
......@@ -855,7 +858,6 @@ namespace INMOST
ElementArray<Cell> new_cells = Cell::SplitCell(c,internal_faces,0);
std::sort(new_cells.begin(),new_cells.end(),Mesh::CentroidComparator(m));
//set up increased level for the new cells
for(ElementArray<Cell>::size_type kt = 0; kt < new_cells.size(); ++kt)
{
......@@ -875,6 +877,8 @@ namespace INMOST
*/
//if( !cell_set->HaveParent() )
parent.AddChild(cell_set);
if( model ) model->CellRefinement(c,new_cells);
//else assert(cell_set->GetParent() == parent);
//increment number of refined cells
ret++;
......@@ -1462,7 +1466,8 @@ namespace INMOST
//set level for new cell
level[v] = level[c]-1;
v.Centroid(x);
if( model ) model->CellCoarsening(unite_cells,v);
//~ v.Centroid(x);
//fout << v.GlobalID() << " lid " << v.LocalID();
//fout << " parent " << ElementSet(m,parent_set[v]).GetName();
//fout << " " << x[0] << " " << x[1] << " " << x[2];
......@@ -1524,6 +1529,8 @@ namespace INMOST
hanging_nodes[v].push_back(hanging[lt]);
visited = true;
numcoarsened++;
if( model ) model->FaceCoarsening(unite_faces,v);
break; //no need to visit the other cell
}
}
......@@ -1562,6 +1569,8 @@ namespace INMOST
//set level for new edge
level[v] = level[e]-1;
visited = true;
if( model ) model->EdgeCoarsening(unite_edges,v);
break; //no need to visit any other face
}
}
......
......@@ -367,5 +367,44 @@ namespace INMOST
}
}
}
void Model::CellRefinement(Cell & old_cell, ElementArray<Cell> & new_cells)
{
for(std::vector< std::pair<std::string, AbstractSubModel *> >::const_iterator it = SubModels.begin();
it != SubModels.end(); ++it)
it->second->CellRefinement(old_cell,new_cells);
}
void Model::FaceRefinement(Face & old_face, ElementArray<Face> & new_faces)
{
for(std::vector< std::pair<std::string, AbstractSubModel *> >::const_iterator it = SubModels.begin();
it != SubModels.end(); ++it)
it->second->FaceRefinement(old_face,new_faces);
}
void Model::EdgeRefinement(Edge & old_edge, ElementArray<Edge> & new_edges)
{
for(std::vector< std::pair<std::string, AbstractSubModel *> >::const_iterator it = SubModels.begin();
it != SubModels.end(); ++it)
it->second->EdgeRefinement(old_edge,new_edges);
}
void Model::CellCoarsening(ElementArray<Cell> & old_cells, Cell & new_cell)
{
for(std::vector< std::pair<std::string, AbstractSubModel *> >::const_iterator it = SubModels.begin();
it != SubModels.end(); ++it)
it->second->CellCoarsening(old_cells,new_cell);
}
void Model::FaceCoarsening(ElementArray<Face> & old_faces, Face & new_face)
{
for(std::vector< std::pair<std::string, AbstractSubModel *> >::const_iterator it = SubModels.begin();
it != SubModels.end(); ++it)
it->second->FaceCoarsening(old_faces,new_face);
}
void Model::EdgeCoarsening(ElementArray<Edge> & old_edges, Edge & new_edge)
{
for(std::vector< std::pair<std::string, AbstractSubModel *> >::const_iterator it = SubModels.begin();
it != SubModels.end(); ++it)
it->second->EdgeCoarsening(old_edges,new_edge);
}
}
#endif
......@@ -45,6 +45,15 @@ namespace INMOST
/// No algorithm by default
/// If this submodel depends on provided adpated mesh, it should update it's data
virtual void Adaptation(Mesh & m, SearchKDTree & search_old_cells) const {};
virtual void CellRefinement(Cell & old_cell, ElementArray<Cell> & new_cells) {}
virtual void FaceRefinement(Face & old_face, ElementArray<Face> & new_faces) {}
virtual void EdgeRefinement(Edge & old_edge, ElementArray<Edge> & new_edges) {}
virtual void CellCoarsening(ElementArray<Cell> & old_cells, Cell & new_cell) {}
virtual void FaceCoarsening(ElementArray<Face> & old_faces, Face & new_face) {}
virtual void EdgeCoarsening(ElementArray<Edge> & old_edges, Edge & new_edge) {}
};
/// A class to organize a model.
......@@ -153,6 +162,15 @@ namespace INMOST
/// Those model that use the adapted mesh should update their data
virtual void Adaptation(Mesh & m) const;
virtual void CellRefinement(Cell & old_cell, ElementArray<Cell> & new_cells);
virtual void FaceRefinement(Face & old_face, ElementArray<Face> & new_faces);
virtual void EdgeRefinement(Edge & old_edge, ElementArray<Edge> & new_edges);
virtual void CellCoarsening(ElementArray<Cell> & old_cells, Cell & new_cell);
virtual void FaceCoarsening(ElementArray<Face> & old_faces, Face & new_face);
virtual void EdgeCoarsening(ElementArray<Edge> & old_edges, Edge & new_edge);
void ReportErrors(const Residual & R) const;
};
}
......
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