CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   How to transform or "smoothen" this "line" (https://www.cfd-online.com/Forums/main/13344-how-transform-smoothen-line.html)

CH April 22, 2007 08:27

How to transform or "smoothen" this "line"
 
Hi,

I need some help to transform or "smoothen" a line....

Supposed I've got a straight line, at angle of 30deg to the horizontal. Hence it's gradient is tan(30).

If I want to "smoothen" this line such that at one end of the line, its gradient is fixed at tan(30). However, at the other other I want its gradient to be 0. What factor or transformation can I use to get a smooth curve based on this 2 criteria. Note that only the gradient of one end of the line is changed to 0, the location of the end points are fixed.

Thank you

Mani April 23, 2007 16:48

Re: How to transform or "smoothen" this "line"
 
A popular way to construct such functions is to use polynomial splines. I personally like Hermite polynomials which are used in finite elements, but are very convenient for any kind of application like the one you describe. I'd have to look up the definition of the polynomials to show you the very easy way to construct a solution by superposition, but of course there is also a more tedious way that's easier to remember: Given both endpoints and both gradients you have 4 pieces of information to obtain the 4 coefficients of a third-order polynomial. You should remember from high-school or an undergrad math class how to do this by solving a system of 4 equations.

CH April 24, 2007 22:52

Re: How to transform or "smoothen" this "line"
 
Thanks Mani.

Ya guess the simplest way will be a 3rd degree polynomial. However the problem with this mtd is that the x value is unchanged since it's a 1-d modification. Hence, the perpendicular grid spacing will change. There are also no more DOF to play around with

Moreover, I have a problem implementing the 3rd degree polynomial when I have one of the gradient at one corner to be a vertical line ie gradient = infinity. How can I get the correct coefficient? I thought of transforming the line by 90 deg so that the new gradient is 0, get the new y values, and then transforming it back. However it seems very troublesome. I wonder if there's a better mtd.

Thanks

Jonas Holdeman April 25, 2007 10:39

Re: How to transform or "smoothen" this "line"
 
If you want greater flexibility, consider parametric curves. That is, you introduce a parametric variable (call it t), and write the x- and y-coordinates of a point on the curve as x=X(t), y=Y(t) (and z=Z(t)), where the functions X(t)... are cubic functions of t (0<=t<=1). You choose the polynomial coefficients in these functions to match the slopes and endpoints. There are then parameters/coefficients left over to control the curve between the ends. Special cases are x=t with y=Y(t)=Y(x), the cubic polynomial in x, and y=t with x=X(t)=X(y), the cubic polynomial in y. Infinite slopes are no problem; you just choose the coefficients in such a way that dy/dt=0 at such a point.

There are parameterizations of the coefficients to make things easier. An example is Bezier curves, but there are others.

Jonas Holdeman April 25, 2007 10:50

Re: How to transform or "smoothen" this "line"
 
Oops, I said the business of infinite slopes wrong. To get an infinite slope at a point, you set dx/dt=0 there. Then as t changes, y changes but not x, giving an infinite slope.

Mani April 25, 2007 11:24

Re: How to transform or "smoothen" this "line"
 
I think you need to describe your application (I gather it's grid generation) in more detail. Parametric curves might be the way to go, as Jonas suggests. It may also be as simple as working with the local curvilinear coordinates instead of "x and y".


All times are GMT -4. The time now is 00:06.