C Language Reading of units and node files output by ANSYS

Source: Internet
Author: User
Tags rewind

 

In ANSYS, ewrite is used to output the selected unit to the file. Its parameter is

Ewrite, fname, ext, --, kappnd, format

The first two are file names and suffixes. kappnd indicates whether to clear the unit file for output (expressed by 0 and 1). Format indicates the output file.
The Bit Width of the part. Here, short is the default option, which indicates that the output is a six-Bit Width, while long indicates that 8 is a bit width output.
Similarly, ANSYS uses nwrite to output the selected node to the file. Its input parameters have the same meaning as the ewrite input parameters, but they do not have a bit width.
. However, in the output file of the node, the first column of the node number is 8 bits in width, and the second to fourth column is the node coordinate, each 20 is the bit width, and there is no
There are spaces.

When using the C language to read grid data, you can use the above files to read data. Generally, it is easier to know the number of nodes and the number of units.
Read C in sequenceProgram. However, this information is not provided in the output unit and node files.
However, you can use the following method to generate such a file: Read the number of units and the number of nodes in the analyticdb, write the corresponding unit and node files, and then

Add nodes and unit files.

The following is a simple example of reading a two-dimensional triangular mesh using C language (the number of write units and nodes is not counted, but calculated by the number of rows)

1 # Include < Stdio. h >
2 # Include < Stdlib. h >
3 // ANSYS's element output format
4
5 Char Nodeformat [] = " % * 8C % 20 S % 20 s " ; // Node row format
6 Char Elongformat [] = " % 8d % 8d % 8d % * 40C % 8d " ; // Long format of the triangular mesh of unit files
7 Char Eshortformat [] = " % 6D % 6D % 6D % * 30C % 6d " ; // Short format of the triangular mesh of unit files
8
9
10
11
12 Int Main ( Int Argc, Const   Char   * Argv [])
13 {
14 File * FP;
15 Char Buffer [ 200 ];
16 Char XX [ 21 ];
17 Char YY [ 21 ];
18 Int Ch;
19 Int Mat, num;
20 Int Linenum = 0 ;
21 Int A [ 3 ] = { 0 };
22 Char Nodefile [] = " Nodelist1.n " ; // Node File
23 Char Elemfile [] = " Elemlist1.e " ; // Unit File
24
25 Fp = Fopen (nodefile, " R " );
26
27 // Number of computing nodes
28 While (CH = Fgetc (FP )) ! = EOF)
29 {
30 If (CH = ' \ N ' ) Linenum ++ ;
31 }
32 Rewind (FP );
33 Printf ( " The number of nodes is % d \ n. " , Linenum );
34 // Coordinates of the read Node
35 While (Fgets (buffer, 200 , FP) ! = Null)
36 {
37 XX [ 0 ] = ' \ 0 ' ;
38 YY [ 0 ] = ' \ 0 ' ;
39 Sscanf (buffer, nodeformat, XX, YY );
40 Printf ( " % F, % F \ n " , Atof (XX), atof (yy ));
41 }
42 Fclose (FP );
43
44 Fp = Fopen (elemfile, " R " );
45 Int Linenum = 0 ;//Number of computing units

46 While (CH = Fgetc (FP )) ! = EOF)
47 {
48 If (CH = ' \ N ' ) Linenum ++ ;
49 }
50 Rewind (FP );
51 Printf ( " The number of units is % d \ n. " , Linenum );
52 // Read Unit
53 While (Fgets (buffer, 200 , FP) ! = Null)
54 {
55 Sscanf (buffer, eshortformat, & A [ 0 ], & A [ 1 ], & A [ 2 ], & Mat );
56 Printf ( " % 8d % 8d % 8d % 8d \ n " , [ 0 ], [ 1 ], [ 2 ], Mat );
57 }
58 Fclose (FP );
59
60
61 Return   0 ;
62 }
63

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.