
forums.silverfrost.com Welcome to the Silverfrost forums

View previous topic :: View next topic 
Author 
Message 
Semih
Joined: 30 Apr 2018 Posts: 8

Posted: Sat Oct 20, 2018 9:49 am Post subject: Storage of Two Data 


Hi,
I'm new in Fortran. I want to store two data. How can I do this?
Example; I have data 1,2,3,4,5,6,..
I want to store as (1,2), (3,4) (5,6) regardless of sequence(for instance, (5,6) and (6,5) have the same meaning. )
Thank you. 

Back to top 


mecej4
Joined: 31 Oct 2006 Posts: 1281

Posted: Sat Oct 20, 2018 5:17 pm Post subject: 


There is not much point to discussing various ways of storing numbers in a program before you have defined what is to be done with those numbers and how that can be done.
Are you thinking of representing unordered sets in memory? What operations will you do on those sets? What will you output from the program?
After all, a program that does no output is of almost no utility. 

Back to top 


JohnSilver
Joined: 30 Jul 2013 Posts: 1320 Location: Aerospace Valley

Posted: Sat Oct 20, 2018 8:27 pm Post subject: 


ooks like you might want to read the data in as x,y coordinates is that right ?
if so you can read in the data one by one and store them either in a single 2dimensional array xy(i,j) or nmaybe 2 xeperate vectoeìrs a(i) , y(i). As mecej4 said, depending on what yu want to do with them.
is your data in a file ?
writtn as shown as a single row ? or maybe a single column ? _________________ ''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... " 

Back to top 


mecej4
Joined: 31 Oct 2006 Posts: 1281

Posted: Sun Oct 21, 2018 1:21 am Post subject: Re: 


JohnSilver wrote:  Looks like you might want to read the data in as x,y coordinates is that right ? 
I don't think so, since Semih wrote:
Quote:  for instance, (5,6) and (6,5) have the same meaning 
If we interpret the numbers as longitude and latitude in Mercator's projection, that "meaning" would equate the North Pole with a location on the equator about 1000 km to the west of Sumatra. 

Back to top 


Semih
Joined: 30 Apr 2018 Posts: 8

Posted: Sun Oct 21, 2018 6:43 am Post subject: 


You are right, i could not state clearly the problem.
i have element connectivity data. Mesh is triangular element.
Element number___Node number 1___Node number 2___Node number 3
_____1________________26____________52____________96
_____2________________15____________52____________26
for Element 1, edges of triangle : (26,52),(52,96),(96,26)
for Element 2, edges of triangle : (15,52),(52,26),(26,15)
In a loop, I want to show that Element 1 and Element 2 have common edges. (26,52) = (52,26) 

Back to top 


JohnCampbell
Joined: 16 Feb 2006 Posts: 2172 Location: Sydney

Posted: Sun Oct 21, 2018 7:04 am Post subject: 


You basically have:
A list of "3nodes" for each element.
A list of "2nodes" for each edge.
If you sort the edge property: "2nodes" so that node_2 > node_1, you could then find all unique edge couples (eliminating duplicates),
Then develop a set of "3edges" for each element.
Also, you could develop a list of elements connected to each edge, which could be more than 2 elements.
This would develop a consistent set of inter related lists.
These could be declared as:
integer*4 elem_node_list(3,mx_elem) ! list of nodes for each triangle
integer*4 edge_node_pair(2,mx_edge) ! 2node pairs
integer*4 elem_edge_list(3,mx_elem) ! list of edges for each triangle
integer*4 edge_elem_list(mx_con,mx_edge) ! unknown max elements to an edge (can be > 2 )
mx_elem, mx_edge, mx_con can be set to large values or calculated in a multipass search.
mx_elem should be an input,
mx_edge <= 3*mx_elem,
To calculate mx_con, you could first count all elements connected to each edge, then find mx_con.
Once you have solved this, you could advance to an indexed list for elem_list which handles a variable number of elements using each edge and node_list which handles a variable number of nodes for each element.
ALLOCATE can be used to create large arrays then reALLOCATE to a minimal size, before the next stage of use of this data.
Once you have mastered this you are well on the way to equation ordering for allocating equations for each node, also using
integer*4 node_elem_list(mx_con,mx_node) ! unknown max elements to each node (can be >> 2 ) 

Back to top 


Semih
Joined: 30 Apr 2018 Posts: 8

Posted: Sun Oct 21, 2018 12:18 pm Post subject: 


Actually, what i want to ask is that
"integer*4 elem_edge_list(3,mx_elem) ! list of edges for each triangle"
Example: elem_edge_list(2,7) = ?
How do i state "list of edge" ? Array must store two nodes. 

Back to top 


JohnCampbell
Joined: 16 Feb 2006 Posts: 2172 Location: Sydney

Posted: Sun Oct 21, 2018 1:33 pm Post subject: 


The array "integer*4 edge_node_pair(2,mx_edge)" would be used to store the list of edges, as 2 nodes.
I would suggest they are stored so that :
edge_node_pair(1,edge_id) < edge_node_pair(2,edge_id)
The list of edges you generate would be listed using:
Code:  integer*4, parameter :: mx_edge = 9999 ! max number of edges
integer*4 num_edges ! number of edges
integer*4 edge_id ! edge id
integer*4 edge_node_pair(2,mx_edge) ! list of 2node edges
write (*,*) 'List of', num_edges,' edges'
do edge_id = 1,num_edges
write (*,*) edge_id, edge_node_pair(1,edge_id), edge_node_pair(2,edge_id)
end do
end 
You could expand on this to place the declarations in a module and use:
Code:  integer*4, allocatable :: edge_node_pair(:,:)
...
! calculate the number of edges then allocate space
allocate ( edge_node_pair(2,num_edges) ) 


Back to top 


Semih
Joined: 30 Apr 2018 Posts: 8

Posted: Sun Oct 21, 2018 5:11 pm Post subject: 


I understood now. Thanks a lot. 

Back to top 




You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group
