# stretch elliptic mesh to fit a circle

I've generated a 2D O-mesh around an airfoil. Unfortunately, the mesh O shape is not a perfect circle as you can see in the figure below (in the figure I plotted only the mesh nodes in blue). The red circle is obtained using the smallest enclosing circle algorithm. My goal is to stretch the mesh nodes so the outer nodes of the mesh coincide with the red circle (In other words, I want to change the computational domain to a prefect circle (red circle)). How can I achieve that?

I appreciate any help.

Note: In my case, for some reason it is not possible to generate a perfect O mesh in the first place. So this is not an option.

• What if you remove the last not so perfect circle and replace it with the red one that you plot here? Is that creating some huge errors for you? Oct 24, 2019 at 16:53
• @AloneProgrammer: Yes that might be an option but I have to project the outer points on the circle. What I want really is something like dynamic mesh that will stretch the all the nodes to fit the circle. Oct 24, 2019 at 16:56
• I'm not sure what do you mean by stretching?! You want a deformation model? That would be too complicated I believe... You need two types of forces as expanding and shrinking forces and based on those force fields your points should deform until reaching a certain tolerance to stop the algorithm. But, if I was in your shoe, I just removed the last mesh and replace it with red circle initially, to at least see if it really creates big errors or not. Oct 24, 2019 at 16:59
• @AloneProgrammer: Yes, exactly a deformation model. Since I am beginner, I don't know if there are some libraries for this purpose. Oct 24, 2019 at 17:02
• As a beginner, It would be tough to start with mesh deformation. Generally, mesh deformation is considered an advanced technique in computational sciences, but I just post a framework below which might help you to write your own mesh deformation algorithm. Oct 24, 2019 at 19:28

Let's say you have set of points $$\mathbf{P}_{i}$$, which is the vertices of last O-mesh. You can simulate the deformation or movement of last O-mesh by using second law's of Newton or Langevin equation:

$$\frac{\partial^{2} \mathbf{P}_{i}}{\partial t^{2}} + \gamma \frac{\partial \mathbf{P}_{i}}{\partial t} = \alpha \mathbf{f}_{int} + \beta \mathbf{f}_{ext} + \delta \mathbf{f}_{rigidity}$$

Where $$\gamma$$ is viscous term, $$\mathbf{f}_{int}$$ and $$\mathbf{f}_{ext}$$ are internal force that wants to shrink the O-mesh and external force that want to expand the O-mesh respectively, as well as $$\alpha$$ and $$\beta$$ are the strength of internal and external forces respectively. Finally $$\delta$$ amd $$\mathbf{f}_{rigidity}$$ are rigidity coefficient and rigidity force that do not let to have a high deformation.

The external force could be modeled by assuming a spring attached to your red circle and initial configuration of your O-mesh as:

$$\mathbf{f}_{ext} = - k ||\mathbf{P}_{i} - \mathbf{P}^{*}|| \mathbf{n}$$

Where $$k$$ is spring constant and $$\mathbf{P}^{*}$$ is the vertex of red circle at the intersection of normal direction from $$\mathbf{P}_{i}$$ to the red circle and $$\mathbf{n}$$ is that normal direction.

Internal force $$\mathbf{f}_{int}$$ should be approximated by calculating the gradient of distance function of red circle. For example, define a function as:

$$\phi(\mathbf{P}_{i})= \begin{cases} 1,& \text{if } \mathbf{P}_{i} \text{is outside red circle}\\ 0, & \text{otherwise} \end{cases}$$

Then spatial gradient of $$\phi$$ could be used as an approximation for internal force: $$\mathbf{f}_{int} = -\nabla \phi$$

Finally the rigidity force $$\mathbf{f}_{rigidity}$$ can be approximated by:

$$\mathbf{f}_{rigidity}(\mathbf{P}_{i}) = \hat{\mathbf{P}} - \mathbf{P}_{i}$$

Where $$\hat{\mathbf{P}} = \mathbf{P}_{i} + \frac{\sum_{j \in \mathcal{N}_{A}} \Delta l_{ij} (\frac{\mathbf{P}_{i} - \mathbf{P}_{j}}{||\mathbf{P}_{i} - \mathbf{P}_{j}||})}{|\mathcal{N}_{A}|}$$ and $$\mathcal{N}_{A}$$ are the group of neighboring vertices of $$\mathbf{P}_{i}$$ and $$\Delta l_{ij} = \hat{l}_{ij} - l_{ij}$$, where $$\hat{l}_{ij}$$ is initial distance of neighboring vertices at $$t = 0$$ and $$l_{ij}$$ is the current distance of neighboring vertices from $$i$$ to $$j$$.

By using this description and discretizing it by using finite difference you should be able to deform your O-mesh to fit it into that red circle. Keep in mind that there is no intrinsic values for $$\gamma$$, $$\alpha$$, $$\beta$$, and $$\delta$$. You should find them by experimenting different values. But, when you have large $$\gamma$$ your solution would have minimum oscillation due to high damping coefficient. On the other hand if you increase $$\alpha$$ it tends to shrink and if you increase the $$\beta$$ it tends to expand. Finally, increasing $$\delta$$ would prevent the mesh to be deformed too much.

I'm not sure this is the solution that you are looking for or not and as I said in my comments it would be pretty complicated.

• Just a question about the dista,ce function $\phi(\textbf{P}_i$). All the points are by definition inside the red circle because it was obtained by the smallest enclosing circle algorithm. Does that mean the internal force is everywhere 0? Oct 24, 2019 at 19:37
• The distance function in fact distinguish between inside and outside of your red circle. But, when you deform the vertices they might go outside of your red circle in one iteration but the internal force or this distance function (or you can call it distance potential if you want), will bring the vertices that went outside of red circle back inside in the next iteration. It doesn't mean that your current situation all the points are inside red circle, it takes account for possible situation that vertices will go outside because of large deformations. Oct 24, 2019 at 19:39
• Now, I think, programming this will take a lot of time and it might be error prone, Now using the theory you introduced, I will check some libraries, like cgal-swig-binding for the implementation of this algorithm. Oct 24, 2019 at 19:43
• @Navaro You won't find the implementation of this algorithm anywhere, cause initially it just started for commercial purposes (not at all related to your problem). It's my 3 years of experience working on this algorithm... Oct 24, 2019 at 19:45
• @Navaro CGAL has some deformation algorithm available doc.cgal.org/latest/Surface_mesh_deformation/index.html but you need a lot of changing to make a fitting deformation algorithm out of it... Oct 24, 2019 at 19:46