CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

mode of a data set

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 17, 2003, 09:54
Default mode of a data set
  #1
m malik
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.
  Reply With Quote

Old   December 17, 2003, 14:50
Default Re: mode of a data set -- fortran pseudocode
  #2
Ananda Himansu
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
  Reply With Quote

Old   December 17, 2003, 14:59
Default Re: mode of a data set
  #3
Nashat
Guest
 
Posts: n/a
Check out Rainald Lohner's book:

Applied CFD Techniques: An Introduction Based on Finite Element Methods.

  Reply With Quote

Old   December 19, 2003, 16:37
Default Re: mode of a data set -- fortran pseudocode
  #4
Ananda Himansu
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
  Reply With Quote

Old   December 20, 2003, 10:18
Default Re: mode of a data set -- fortran pseudocode
  #5
m malik
Guest
 
Posts: n/a
Thanks. I had noticed that in your first mail.
  Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


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