Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I need a 2-D Triangle mesh generator with source code in FORTRAN

189 views
Skip to first unread message

Peter

unread,
Apr 12, 2004, 11:46:37 AM4/12/04
to
Hi there,

I am dealing with a remeshing problem which needs generate a new mesh
each time step. I 've been searching on internet for a while but
haven't found a good one.

I need the triangle mesh can be very nununiform and the nodes on
boundary are inputs.

Thanks for your time


Peter

Julian V. Noble

unread,
Apr 12, 2004, 3:48:30 PM4/12/04
to Peter

Although I have never done exactly this, I have done something similar.

Probably you can generate the mesh recursively, and that will be fairly
fast. If I were doing it, I would subdivide an existing triangle with
a line from the center of the longest side to the vertex opposite that
side. For all I know, that is what is done in practice. Have you googled?

--
Julian V. Noble
Professor Emeritus of Physics
j...@lessspamformother.virginia.edu
^^^^^^^^^^^^^^^^^^
http://galileo.phys.virginia.edu/~jvn/

"For there was never yet philosopher that could endure the
toothache patiently."

-- Wm. Shakespeare, Much Ado about Nothing. Act v. Sc. 1.

Roy Stogner

unread,
Apr 12, 2004, 6:47:57 PM4/12/04
to
On Mon, 12 Apr 2004 15:46:37 +0000, Peter wrote:

> I am dealing with a remeshing problem which needs generate a new mesh
> each time step. I 've been searching on internet for a while but
> haven't found a good one.
>
> I need the triangle mesh can be very nununiform and the nodes on
> boundary are inputs.

Jonathan Shewchuk's program (called simply "Triangle") at
http://www-2.cs.cmu.edu/~quake/triangle.html will probably do what you
want. The source code is in C, but C and Fortran can be made binary
compatible in both directions, with perhaps a little work writing wrapper
functions.
---
Roy

Matt Wolinsky

unread,
Apr 12, 2004, 8:27:42 PM4/12/04
to
peter...@unity.ncsu.edu (Peter) wrote in message news:<6tee70clju2k@legacy>...


Triangle

http://www-2.cs.cmu.edu/~quake/triangle.html

is supposed to be very good. It was profiled in SIAM News as being
the best general 2D triangular mesh generator out there, and the page
says it won the
2003 James Hardy Wilkinson Prize in Numerical Software.

It's in C, but should be able to be coupled with Fortran code.

Regards,

Matt

peter

unread,
Apr 13, 2004, 10:04:08 AM4/13/04
to
><a
href="http://galileo.phys.virginia.edu/~jvn/">http://galileo.phys.virginia.edu/~jvn/</a>

>
> "For there was never yet philosopher that could endure the
> toothache patiently."
>
> -- Wm. Shakespeare, Much Ado about Nothing. Act v. Sc. 1.

The boundary is changing by time. So I have to generate a total new
mesh each time step.

Regards

Peter

peter

unread,
Apr 13, 2004, 12:47:32 PM4/13/04
to
On Mon, 12 Apr 2004 22:47:57 GMT, Roy Stogner wrote:
>On Mon, 12 Apr 2004 15:46:37 +0000, Peter wrote:
>
>> I am dealing with a remeshing problem which needs generate a new
mesh
>> each time step. I 've been searching on internet for a while but
>> haven't found a good one.
>>
>> I need the triangle mesh can be very nununiform and the nodes on
>> boundary are inputs.
>
>Jonathan Shewchuk's program (called simply "Triangle") at
><a
href="http://www-2.cs.cmu.edu/~quake/triangle.html">http://www-2.cs.cmu.edu/~quake/triangle.html</a>

will probably do what you
>want. The source code is in C, but C and Fortran can be made binary
>compatible in both directions, with perhaps a little work writing
wrapper
>functions.
>---
>Roy


Well. I know there is some software that can translate FORTRAN into C
but is there any software can do the reverse work? And, I know, after
the translation, the code will become unreadable. It is kinda
difficult to modify again. So, I am willing to get a FORTRAN one
instead of a C one.

Regards

Peter

beli...@aol.com

unread,
Apr 14, 2004, 9:20:16 AM4/14/04
to
peter...@unity.ncsu.edu (peter) wrote in message news:<y35sbhneuzuw@legacy>...

<SNIP>

> Well. I know there is some software that can translate FORTRAN into C
> but is there any software can do the reverse work? And, I know, after
> the translation, the code will become unreadable. It is kinda
> difficult to modify again. So, I am willing to get a FORTRAN one
> instead of a C one.

David Frank has written C2F, a Fortran 90 program (with Compaq Visual
Fortran extensions) that translates SOME C code to Fortran 90. It does
NOT translate all C. It is described at
http://www.unics.uni-hannover.de/rrzn/gehrke/c2f.html and can be
downloaded (F90 source or Windows binary) from Frank's site at
http://home.cfl.rr.com/davegemini/ .

Here is a trivial C program, followed by the Fortran 90 translation.
Adding two lines by hand, the F90 program compiles and runs. I think
the F90 code is readable. The INCLUDE files are included in the C2F
package.

I am NOT recommending C2F for production use, except as an aid to
manual translation.

#include <stdio.h>
#define N 100000

int twice(int i)
{
return 2*i;
}

void main(void)
{
/* cannot translate line below
int j = (10 > 1) ? 10 : 1;
*/
int ivec[N];
int i;
ivec[0] = 0;
for (i=1;i<N;i++)
{
ivec[i] = ivec[i-1] + twice(i);
}
printf("\n %6d",ivec[N-1]);
}

! Fortran 90 automatic translation by C2F
! --------------------------------------------------
MODULE XARR_1 ! global declarations
! --------------------------------------------------
INCLUDE 'C2F.FD'
INCLUDE 'C2F.FI'
INTEGER,PARAMETER :: N=100000

END MODULE

! --------------------------------------------------
FUNCTION twice(i) RESULT (output_4)
! --------------------------------------------------
USE XARR_1
IMPLICIT NONE
! - - - arg types - - -
INTEGER :: output_4
INTEGER :: i
! - - - local declarations - - -

! - - - begin - - -
output_4 = 2*i
RETURN

END FUNCTION

! --------------------------------------------------
PROGRAM XARR
! --------------------------------------------------
USE XARR_1
IMPLICIT NONE
! - - - local declarations - - -
INTEGER :: i,ivec(N)
integer twice ! line added manually
external twice ! line added manually
! - - - begin - - -
ivec(0+1) = 0
DO i = 1,N-1
ivec(i+1) = ivec(i-1+1) + twice(i)
END DO
WRITE (*,901,ADVANCE='NO') " ",ivec(N-1+1)

901 FORMAT (/A,I6)
END PROGRAM
INCLUDE 'C2F_LIB.F90'
! 0 Errors detected

Roy Stogner

unread,
Apr 14, 2004, 5:43:45 PM4/14/04
to
On Tue, 13 Apr 2004 16:47:32 +0000, peter wrote:

> On Mon, 12 Apr 2004 22:47:57 GMT, Roy Stogner wrote:
>
>> Jonathan Shewchuk's program (called simply "Triangle") at

>> http://www-2.cs.cmu.edu/~quake/triangle.html will probably do what


>> you want. The source code is in C, but C and Fortran can be made
>> binary compatible in both directions, with perhaps a little work
>> writing wrapper functions.
>

> Well. I know there is some software that can translate FORTRAN into C
> but is there any software can do the reverse work? And, I know, after
> the translation, the code will become unreadable. It is kinda difficult
> to modify again. So, I am willing to get a FORTRAN one instead of a C
> one.

Why translate? If the rest of your code is written in FORTRAN, but you
need to use a C function, you can call it (or a small C wrapper function,
if necessary) directly from the FORTRAN code. There are a few catches,
but you can find examples of how to work around them on the web:

http://www.chiralcomp.com/support/mixing_f77_c_cpp/
http://hpcf.nersc.gov/software/ibm/c_and_f.html
---
Roy Stogner

0 new messages