|
[Sponsors] |
December 17, 2003, 09:54 |
mode of a data set
|
#1 |
Guest
Posts: n/a
|
Specifically, my problem is finite element mesh related: finding the maximum number of elements that share a common node. I guess it is basically a problem of finding the mode of a large set of numbers. Would like to know of some C/C++/Fortran code for this purpse. Thanks.
|
|
December 17, 2003, 14:50 |
Re: mode of a data set -- fortran pseudocode
|
#2 |
Guest
Posts: n/a
|
! answer by enumeration, message board reformats my post by weird rules, forces me to use double-line spacing below
subroutine max_cells_of_nodes (max_cells, num_elements, num_nodes, max_vertices, num_vertices, nodes_of_elements) implicit none ! global variable declarations follow ! global variables except for max_cells are assumed to be assigned values in calling routine before calling current routine integer :: max_cells, num_elements, num_nodes, max_vertices ! (max_vertices = maxval(num_vertices)) integer, dimension(num_elements) :: num_vertices integer, dimension(max_vertices, num_elements) :: nodes_of_elements ! local variable declarations follow integer, dimension(num_nodes) :: num_cells ! num_cells is an auxiliary array to track number of elements incident on each node integer :: element, vertex, this_node do element = 1, num_elements do vertex = 1, num_vertices(element) this_node = nodes_of_elements(vertex, element) num_cells(this_node) = num_cells(this_node)+1 end do end do max_cells = maxval(num_cells) ! max_cells is the maximum number of elements that share a common node end subroutine max_cells_of_nodes |
|
December 17, 2003, 14:59 |
Re: mode of a data set
|
#3 |
Guest
Posts: n/a
|
Check out Rainald Lohner's book:
Applied CFD Techniques: An Introduction Based on Finite Element Methods. |
|
December 19, 2003, 16:37 |
Re: mode of a data set -- fortran pseudocode
|
#4 |
Guest
Posts: n/a
|
whoops, of course there is a bug in my code that's what you get for programming in a hurry and not testing!
i forgot to initialize the num_cells array. the following statement should be inserted just before the "do element = 1, num_elements" loop: num_cells = 0 |
|
December 20, 2003, 10:18 |
Re: mode of a data set -- fortran pseudocode
|
#5 |
Guest
Posts: n/a
|
Thanks. I had noticed that in your first mail.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem in running ICEM grid in Openfoam | Tarak | OpenFOAM | 6 | September 9, 2011 18:51 |
CGNS vs Tecplot Data Format | LWhitson2 | Main CFD Forum | 3 | July 1, 2011 14:50 |
set temperature on subdomain, in transient mode | nicolas | CFX | 0 | August 16, 2006 07:42 |
Problems with installation | jonititan | OpenFOAM Installation | 4 | November 6, 2005 05:16 |
Where I could find the book or the data set. | boling | Main CFD Forum | 0 | November 21, 2003 13:47 |