Skip to content

Commit

Permalink
First working implementation of interior fixed edges
Browse files Browse the repository at this point in the history
  • Loading branch information
FloSewn committed Jul 1, 2024
1 parent ae01ee4 commit df40657
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 30 deletions.
1 change: 1 addition & 0 deletions src/algorithm/Edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class Edge : public ContainerEntry<Edge>
bool on_boundary() const { return has_property(EdgeProperty::on_boundary); }
bool is_interior() const { return !on_boundary(); }
bool is_ghost() const { return has_property(EdgeProperty::is_ghost); }
bool is_fixed() const { return has_property(EdgeProperty::is_fixed); }

/*------------------------------------------------------------------
| Get the next edge, that is connected to the ending vertex of
Expand Down
113 changes: 104 additions & 9 deletions src/algorithm/Front.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ using namespace CppUtils;
*********************************************************************/
class Front : public EdgeList
{
using BoolVector = std::vector<bool>;
using IntVector = std::vector<int>;
using BoolVector = std::vector<bool>;
using IDPairVector = std::vector<std::pair<std::size_t,std::size_t>>;
using VertexVector = std::vector<Vertex*>;
using EdgeVector = std::vector<Edge*>;
using BdryEdgeConn = std::vector<std::vector<EdgeVector>>;
Expand Down Expand Up @@ -61,7 +62,7 @@ class Front : public EdgeList
/*------------------------------------------------------------------
| Initialize the advancing front structure according to a given
| domain and its size function
------------------------------------------------------------------*/
------------------------------------------------------------------*
template <typename FrontInitDataImpl>
void init_front(const Domain& domain,
const FrontInitDataImpl& front_init_data,
Expand All @@ -85,7 +86,93 @@ class Front : public EdgeList
// Refine the front edges, but do not refine sub-edges!
this->refine_front_edges(domain, mesh_vertices);
// Add additional ghost edges that are opposed to
// interior fixed edges
// -------------------------------------------
// for ( const auto& e_ptr : edges_ )
// {
// if ( !e_ptr->is_fixed() )
// continue;
// Vertex& v1 = e_ptr->v1();
// Vertex& v2 = e_ptr->v2();
// Edge& e_new = this->insert_edge( e_ptr->pos(),
// v2, v1,
// e_ptr->color() );
// e_new.add_property( EdgeProperty::is_fixed );
// e_new.add_property( EdgeProperty::is_ghost );
// }
// Re-compute area of domain
compute_area();
} // Front::init_front() */

/*------------------------------------------------------------------
| Initialize the advancing front structure according to a given
| domain and its size function
------------------------------------------------------------------*/
template <typename FrontInitDataImpl>
void init_front(const Domain& domain,
const FrontInitDataImpl& front_init_data,
Vertices& mesh_vertices)
{
const EdgeVector& front_edges = front_init_data.edges();
const VertexVector& front_vertices = front_init_data.vertices();
const IDPairVector& front_vertex_ids = front_init_data.vertex_ids();
const BoolVector& is_twin_edge = front_init_data.is_twin_edge();
const IntVector& colors = front_init_data.colors();

VertexVector new_vertices {};
EdgeVector new_edges {};

// Init mesh vertices
for ( Vertex* v : front_vertices )
{
Vertex& v_new = mesh_vertices.push_back( v->xy() );
v_new.add_property( VertexProperty::on_front );
v_new.add_property( VertexProperty::on_boundary );

new_vertices.push_back( &v_new );
}

for ( size_t i_edge = 0; i_edge < front_edges.size(); ++i_edge )
{
const std::size_t i1 = front_vertex_ids[i_edge].first;
const std::size_t i2 = front_vertex_ids[i_edge].second;

Vertex* v1 = new_vertices[i1];
Vertex* v2 = new_vertices[i2];

ASSERT( v1 != nullptr, "Invalid vertex v1.");
ASSERT( v2 != nullptr, "Invalid vertex v2.");

Edge& e_new = this->add_edge( *v1, *v2, colors[i_edge] );

if ( !front_edges[i_edge]->is_fixed() )
e_new.add_property( EdgeProperty::on_boundary );
else
e_new.add_property( EdgeProperty::is_fixed );

new_edges.push_back(&e_new);
}

for ( size_t i_edge = 0; i_edge < front_edges.size(); ++i_edge )
{
if ( is_twin_edge[i_edge] )
{
Edge* twin_edge = front_edges[i_edge];
new_edges[i_edge]->twin_edge( twin_edge );
twin_edge->twin_edge( new_edges[i_edge] );
}
else
ASSERT( new_edges[i_edge]->twin_edge() == nullptr,
"Front::mark_twin_edges(): Invalid edge.");
}

// Refine the front edges, but do not refine sub-edges!
this->refine_front_edges(domain, mesh_vertices);

// Add additional ghost edges that are opposed to
// interior fixed edges
Expand All @@ -104,12 +191,10 @@ class Front : public EdgeList
e_new.add_property( EdgeProperty::is_ghost );
}



// Re-compute area of domain
compute_area();
} // Front::init_front()

} // Front::init_front()

/*------------------------------------------------------------------
| Initialize the advancing front structure from a given mesh
Expand Down Expand Up @@ -506,18 +591,28 @@ class Front : public EdgeList

// Set vertex properties
v_n.add_property( VertexProperty::on_front );
v_n.add_property( VertexProperty::on_boundary );

if ( !e.is_fixed() )
v_n.add_property( VertexProperty::on_boundary );

// Add new edge and set its properties
Edge& e_new = this->insert_edge(e.pos(), *v_cur, v_n, e.color());
e_new.add_property( EdgeProperty::on_boundary );

if ( !e.is_fixed() )
e_new.add_property( EdgeProperty::on_boundary );
else
e_new.add_property( EdgeProperty::is_fixed );

v_cur = &v_n;
}

// Add final edge and set its properties
Edge& e_new = this->insert_edge( e.pos(), *v_cur, e.v2(), e.color() );
e_new.add_property( EdgeProperty::on_boundary );

if ( !e.is_fixed() )
e_new.add_property( EdgeProperty::on_boundary );
else
e_new.add_property( EdgeProperty::is_fixed );

} // create_sub_edges()

Expand Down
Loading

0 comments on commit df40657

Please sign in to comment.