Using Data Explorer to Visualize Data Generated by ANSYS

Érico Correia da Silva

CENAPAD-SP National Center for High Performance Computing in São Paulo
State University of Campinas - Brazil

Editor's Note: This paper is also available in Portuguese.



1 - Abstract

ANSYS is software for solving engineering problems using the finite element methodology. It has several mesh generation resources and model definitions in its pre-processor. In its solver, ANSYS provides resources for a variety of types of analysis. The post-processing provided by ANSYS is good, although it does not have the same richness of detail that can be obtained by Data Explorer. This is the motivation for creating software capable of translating the output generated by the ANSYS software into a ".dx" file.

This first version allows the creation of a ".dx" file for the stress, strain and displacement visualizations, coming from models done with ANSYS. The program ANSYS2DX which translates the output file was written using the WX windowing system and is interactive.

Together with the .dx output files, DX visual programs to manipulate these data were developed. Each visual program implements its own animation. The first one makes successive shears in the model, showing the studied datum's surface and its interior. The second one shows the transition from the initial to the strained shape. Only a minimum knowledge of DX is needed to use these visual programs.


2 - Introduction and Motivation

Data Explorer is graphic computing software used for, among other applications, scientific visualization. Because of its flexible data input format DX can be used to analyse several types of physical problems, providing the researcher a high quality result from the visual study. Data that is difficult to study without visualization resources can be totally explored using the infinite possible associations that can be made with the DX tools. Using DX, the researcher can visualize the data using animation, enriching the analysis.

As opposed to other scientific software, DX does not compute solutions to physical problems. DX is specifically used for visualization. However, it's important to know that DX can be integrated with other computational software such as ANSYS.

ANSYS is software used to solve engineering problems, using the finite element methodology. ANSYS provides lots of ways to perform analysis, from the most simple to the most complicated model, with an extreme flexibility and an incontestable advantage: ANSYS is software celebrated and widely approved by the scientific and industrial community.

Its pre-processing has many mesh generation resources, permitting a best finite elements elaboration of models. ANSYS has many types of elements that can be used according to whether the studied problem is two or three dimensional. ANSYS can be used in dynamic or static problems, in fluid analysis, in heat transfer problems and in other physical problems, where the finite elements methodology is applicable.

Like the pre-processing and the calculation capabilities, ANSYS's pre-processing module has many resources, allowing a complete visual analysis of the studied problem. Nevertheless, improved analysis can be done, using visualization software. That's the motivation for this work which has the function of studying the possibility of using DX software to visualize data generated by ANSYS providing a best result from the analysis. All this is due to the richness and details that can be obtained with the DX visual program.


3 - Implementation

All jobs were divided into two parts:

With these two ready parts, the ANSYS user can convert the results and visualize them easily, with little knowledge of DX. All of this is possible using these visual programs.


4 - Conversion Program

To simplify the work, it was decided to create the DX files from ANSYS generated reports. A converter must read ANSYS reports previously recorded in text file, and generate files that are easily imported into DX. Such a converter is named ANSYS2DX and it was implemented in C++, using a XWindows library to design a graphic interface. This first ANSYS2DX version generates graphics with tensions, strains and displacements, coming from ANSYS's models composed of 3-4 node plain elements and special ones of 8 nodes.



Picture 1- ANSYS2DX - Graphics Interface

In ANSYS models, a node may not be associated with an element. This requires special care in the generation each .dx file. This file has to have only data and the associated element nodes's coordinates. It was decided to carry all the nodes in memory and only record ones that are effectively data and element associated. For that reason, the following class node was used:

class Node : public wxObject
{
public:
	Node(long id, long nid, float x, float y, float z) : wxObject() 
	{
		fid = id;	//ANSYS's ID
		fnid = nid;	//DX's ID
		fx = x;
		fy = y;
		fz = z;
		used = 0;	
	}
	int used;
	float fx, fy, fz;
	long fid;
	long fnid;
};

The steps involved in converting ANSYS models were as follows:

Reading ANSYS reports:

The file that contains ANSYS reports is opened. Unless the header line is not found, all the other lines are ignored. That means the next line after the header line is a node, a given element or data. If the header line is not found (an inconsistent file), the file is not generated and the model cannot be visualized by DX. But if the header line is found, all the subsequent lines are read and a line with data is filed as text file named ".out". There is an exception in the case when the node report is read, an object from class Node is created an the data is stored in memory and is written to file only after all elements was readed, only if the node was used by an element. If a line reading fails, a search is done by the next line that has consistent data. This procedure is made for the lines that separate different feeds from the whole report.
To give an example, see the code below:

	while(!ifile.eof())
	{
		int nn;
		double ex, ey, ez, exy, eyz, exz;
		do
		{
			ifile.getline(stuff, 255, '\n');
		}while(strncmp(stuff, hdr, strlen(hdr)) && !ifile.eof());
		
		if(ifile.eof()) break;
		
		while(!ifile.eof() && !ifile.fail())
		{
		streampos loc = ifile.tellg();
		ifile >> nn >> ex >> ey >> ez >> exy >> eyz >> exz;
		if(ifile.fail())
		{
			ifile.seekg(loc);
			ifile.clear();
			break;
		}
		te++;
		ofile << ex <<" "<< ey <<" "<< ez <<" "<< exy <<" "<< eyz <<" "<< exz << endl;	
		}
	}

In the function elements conversion case, some care must be taken, because finite element software usually lists the connectivity counterclockwise. Instead of recording elements to the CnvElem() function, it marks each node that was found in an element. After that, they can be filed in WriteNodes ().

		while(!ifile.eof() && !ifile.fail())
		{
		streampos loc = ifile.tellg();
		ifile >> ne >> mat >> tp >> r >> e;
		if(ifile.fail())
		{
			ifile.seekg(loc);
			ifile.clear();
			break;
		}
		te++;
		for(int s = 0; s < nn; s++)
		{
			int tn;
			ifile >> tn;
			Node *node = (Node *)(Nodes.Find(tn))->Data();
			if(node)
			{
				n[s] = node->fnid;
				for(wxNode *unode = uNodes.First(); unode; unode = unode->Next())
				{
					Node *cn = ((Node *)unode->Data());
					if(node->fnid > cn->fnid)
						n[s]--;
					
				}
				node->used = 1;
			}
			else
			{
				cout << "undefined node!";
				exit(1);
			}
		}
		int tmp = n[1];
		n[1] = n[0]; n[0] = tmp;
		if(nn==8)
		{
		tmp = n[5];
		n[5] = n[4]; n[4] = tmp;
		}
		
		for(int s = 0; s < nn; s++)
		{
			ofile << n[s] <<" ";
		}
		ofile << endl;	
		}

Writing the DX data file:

Each one of the functions that work with ANSYS's reports, returns important values for generating the .dx file. Values like the number of nodes, the number of elements, etc. See the code that generates the DX file below:

	long nn = CnvNodes();
	long ne = CnvElems();
	long nnw = WriteNodes();
	long nd = CnvData(nn);
	long nscomp = CnvSComp(nn);
	long necomp = CnvEComp();
	long nvu = CnvVecU();

	if(nn > nnw)
	{
		ne = CnvElems();	
	}
	else if(nn < nnw)
	{
		cout << "error : number of nodes < number of written nodes";
		exit(1);
	}
        filebuf  ofb;

	char *fn = dxf->GetValue();
	ofb.open(fn, ios::out);

	ostream ofile(&ofb);

	ofile << "object 1 class array type float rank 1 shape 3 items " 
		<< nnw << " data file " << fnname <<", 0"<< endl;
	ofile << "attribute \"dep\" string \"positions\"" << endl;
	ofile << "#" << endl;
	ofile << "object 2 class array type int rank 1 shape "<< ((rb->GetSelection())? 8 : 4) <<" items " 
		<< ne << " data file " << felname <<", 0"<< endl;
	ofile << "attribute \"element type\" string " << ((rb->GetSelection())? "\"cubes\"" : "\"quads\"") << endl;
	ofile << "attribute \"ref\" string \"positions\"" << endl;
	ofile << "#" << endl;
	if(nd)
	{
	    ofile << "object 3 class array type float rank 1 shape 5 items "
		    << nd << " data file " << fdname <<", 0"<< endl;
	    ofile << "attribute \"dep\" string \"positions\"" << endl;
	    ofile << "#" << endl;
	    ofile << "object \"sprin\" class field" << endl;
	    ofile << "component \"data\" value 3" << endl;
	    ofile << "component \"positions\" value 1" << endl;
	    ofile << "component \"connections\" value 2" << endl;
	    ofile << "attribute \"name\" string \"sprin\"" << endl;
	    ofile << "#" << endl;
	}
	if(nscomp)
	{
	    ofile << "object 4 class array type float rank 1 shape 6 items "
		    << nscomp << " data file " << fscname <<", 0"<< endl;
	    ofile << "attribute \"dep\" string \"positions\"" << endl;
	    ofile << "#" << endl;
	    ofile << "object \"scomp\" class field" << endl;
	    ofile << "component \"data\" value 4" << endl;
	    ofile << "component \"positions\" value 1" << endl;
	    ofile << "component \"connections\" value 2" << endl;
	    ofile << "attribute \"name\" string \"scomp\"" << endl;
	    ofile << "#" << endl;
	}
	if(necomp)
	{
	    ofile << "object 5 class array type float rank 1 shape 6 items "
		    << necomp << " data file " << fecname <<", 0"<< endl;
	    ofile << "attribute \"dep\" string \"positions\"" << endl;
	    ofile << "#" << endl;
	    ofile << "object \"ecomp\" class field" << endl;
	    ofile << "component \"data\" value 5" << endl;
	    ofile << "component \"positions\" value 1" << endl;
	    ofile << "component \"connections\" value 2" << endl;
	    ofile << "attribute \"name\" string \"ecomp\"" << endl;
	    ofile << "#" << endl;
	}
	if(nvu)
	{
	    ofile << "object 6 class array type float rank 1 shape 3 items "
		    << nvu << " data file " << fvuname <<", 0"<< endl;
	    ofile << "attribute \"dep\" string \"positions\"" << endl;
	    ofile << "#" << endl;
	    ofile << "object \"vecu\" class field" << endl;
	    ofile << "component \"data\" value 6" << endl;
	    ofile << "component \"positions\" value 1" << endl;
	    ofile << "component \"connections\" value 2" << endl;
	    ofile << "attribute \"name\" string \"vecu\"" << endl;
	    ofile << "#" << endl;
	}
	ofile << "end" << endl;

The code above generates a file like this one:

object 1 class array type float rank 1 shape 3 items 5520 data file MANCN.out, 0
attribute "dep" string "positions"
#
object 2 class array type int rank 1 shape 8 items 3440 data file MANCE.out, 0
attribute "element type" string "cubes"
attribute "ref" string "positions"
#
object 3 class array type float rank 1 shape 5 items 5520 data file MANCSPRIN.out, 0
attribute "dep" string "positions"
#
object "sprin" class field
component "data" value 3
component "positions" value 1
component "connections" value 2
attribute "name" string "sprin"
#
object 4 class array type float rank 1 shape 6 items 5520 data file MANCSCOMP.out, 0
attribute "dep" string "positions"
#
object "scomp" class field
component "data" value 4
component "positions" value 1
component "connections" value 2
attribute "name" string "scomp"
#
object 5 class array type float rank 1 shape 6 items 5520 data file MANCECOMP.out, 0
attribute "dep" string "positions"
#
object "ecomp" class field
component "data" value 5
component "positions" value 1
component "connections" value 2
attribute "name" string "ecomp"
#
object 6 class array type float rank 1 shape 3 items 5520 data file MANCALLU.out, 0
attribute "dep" string "positions"
#
object "vecu" class field
component "data" value 6
component "positions" value 1
component "connections" value 2
attribute "name" string "vecu"
#
end

The .dx file generated has the following structure:

Each field has a rank 1 array as a component data, thus, each field's data has many columns. Each column can be selected and analyzed, using the "select(x,n)" function, in the Compute tool.


5 - DX Visual Programs

Two visualizations were developed for unexperienced DX users to work easily with ANSYS generated data. Users that know DX well can use these visualizations like as a reference, facilitating visual software development.

The first visualization is very interactive and has a Control Panel (picture #2) with several DX interactors, that permit a good level of user/visualization interaction. The researcher can select what field is to be visualized and what type of detail is to be seen. This first visual program makes successives shears in the studied model. Through the Control Panel,the axes in which the shears will be done can be selected.



Picture 2-Control Panel of first visual program

The second visualization is not as interactive as the first one. This visualization implements an animation that shows a model passing from the initial shape to a strained shape.

Both visualizations are easily analyzed by DX users. They both are divided into many Execution Groups:

A resource used frequently in the above is the following arrangement of tools:



Picture 3- Tools

Before going to Transmiter, in the end of Execution Group, data pass through a Route that is linked to an on-off type Selector. From this Route one of the two exits is linked to the Transmiter and associated to the on-position. The other one is turned off. This allows the user to visualize what is in the Selector's on position. This facilitates visualization interaction for a beginner, just using the Control Panel.

Data Reading, Dimension Evaluation and Transverse Plane will be detailed. The other parts are simple tool associations, like the Clip Plane, AutoColor, ShowBoundary, etc.


5.1 - Data Reading

In data reading , the input file can be selected through a File Selector that is linked to two imports. One is for read scalar fields, that will be visualized with AutoColor. The other one is for reading displacements. This is a vector field. It will be visualized with AutoGlyph.



Picture 4- Data Reading

There is a Selector that is linked to two Switches. One of them, which is linked to Import, shows the field that should be read from the file. The second one has a list of data that can be selected from each field. Thus, if the user selects "stress", the first one will result in "scomp" (field's name in the ".dx" file) and the second one will result in the following string:

	{"Sx" "Sy" "Sz" "Sxy" "Syz" "Sxz"}

This string list will be the string data from another Selector, that will indicate the selected field item to be visualized. A Compute linked to this last Selector and to the Import that deals with scalar fields, is used to extract the data from the field be visualized with the following formula:

	select(a,b)

onde:
a = output from Import
b = output from the last selector


5.2 - Calculation of Dimensions

After the user has selected the item to be visualized with the sequence of Selectors, Switch and Import (description above), calculate the length of the model to make the animation of the sequence of shears. The positions of the field to be visualized are Mark'd. Using Compute and Statistics the length is calculated by subtracting the minimum from the maximum coordinate for the axes along which the shears will be made.



Picture 5- Calculation of Dimensions


5.3 - Transversal Plane

This Execution Group computes one point on the plane of the shear, and the plane's normal vector.

These formulas are used:

	[(c==0)?b+(a*d):0,(c==1)?b+(a*d):0,(c==2)?b+(a*d):0]

where:
a = 1/20 of the length of the model
b = minimum coordinate
c = axis to effect the shear(0 = x, 1 = y, 2 = z)
d = Sequence (result from Sequencer, from 0 to 20)

	[(a==0)?1:0,(a==1)?1:0,(a==2)?1:0]

where:
a = axis to effect the shear



Picture 6- Transversal Plane


5.4 - Animation to visualize the displacements

The visual program that produces an animation that shows the model going from the initial position to the displaced position is very similar to the program that makes consecutive shears on the model. The biggest difference is the lack of most of interface resources for the user.

In this second visualization the Execution Groups that calculate the transversal plane (for shears) were omitted, as were the groups which use this plane. On the other hand, two Execution Groups were added: one to show the scalar field just on the boundary and other to change the coordinates of each point, adding to the node's position the displacement of this node multiplied by a factor from the Sequencer (specifically, a value ranging from 0 to 22.)


6 - Results

To test and show what is possible using DX to visualize models calculated with ANSYS, conversions were made of models with 2D elements and of models with 3D elements. For each element converted, DX was used in the presentation of animation or details that were much richer than the graphic results obtained with ANSYS. It is good to remember that you can't evaluate the ANSYS graphic output just with the images below. On other hand, to get the quality in the images below it's not necessary to have a great deal of knowledge about ANSYS or DX.



Table 1 - ANSYS Models(left) e DX visualizations(right)



7 - Conclusion

The biggest characteristic of ANSYS2DX it is, without a question, the simplicity of the idea. A program to make conversions using text files, as in this case, can be easily written in any language, not especifically C++. C++ was chosen just because it's the beginning of a large project. In later stages, a greater number of diverse data that ANSYS can give us will be treated, and if it's possible, ANSYS2DX will be expanded to convert time dependent results.

The present work can serve as a reference in the development of other types of converters that integrate Data Explorer with other software packages.


Related files


Source code of ANSYS2DX
First visual program and its configuration file
Second visual program and its configuration file


CENAPAD-SP Aug/1996