Finite Element Method  2D Mesh Generator  Metfem2D
Generator Optimization via the Metropolis method
Boundary mesh elements
The Metropolis algorithm^{[1}^{, 2}^{]} applied to boundary nodes slightly differs from the above– described case and could be summarize in the following steps:

Find all the boundary or edge nodes i. e. nodes for which p_{k, edge} ∈ Γ.

Find triangles in the closest neighbourhood of the considered p_{k,edge} node. Then calculate an area of each triangle A_{l,edge}.

Calculate the force acting on each boundary node and coming only from nodes connected to it (as previously).

J 
F_{k} = 

∑

F_{boundary} δ r_{jk} versor(r_{jk})


j=1 
where J denotes the total number of nodes linked to the kth node and δr_{jk} is defined as previously. Let us impose the following constrain on the motion of the kth node in order to keep it in the boundary Γ. The force must be tangential to the boundary Γ so the boundary projection of the force F_{k} must be found:
F_{k, Γ} = versor(L_{Γ}) (L_{Γ} ⋅ F_{k}) / L_{Γ}

where L_{Γ} denotes a vector lying along boundary Γ.

Similarly, find an area of each triangle A^{new}_{l,edge} after shifting p_{k,edge} → p^{new}_{k,edge} according to the force F_{k}.

Adopt the Metropolis energetic condition to the boundary case i.e.
δE =

∑
_{l}

(
(A^{new}_{l, edge}  A)^{2}  (A_{l, edge}  A)^{2}
)

l = 1, 2, …, L.

If
e^{δE⁄T} > r
the new configuration is accepted otherwise is rejected. T denotes temperature and a random number r ∈ U(0; 1) as previously.

The main point of this part is to ensure that the boundary nodes are moved just along the boundary Γ.
References