**process z7p#
Description#
This post-processing provides an interface for user defined post-processing operations using the
z7p scripting language (see also the “local” version of this
post-processing). The z7p must define the following functions:
A function that returns the names of input variables
ARRAY<STRING> input() { ... }
A function that returns the names of output variables
ARRAY<STRING> output() { ... }
The function that computes output variables
void compute() { ... }
A function returning material coefficients (optional)
ARRAY<STRING> coefficients() { ... }
Initialization (optional)
void initialize() { ... }
Memory Deallocation or extra results dumping (optional)
void destroy() { ... }
Additional functions and declarations as needed.
Syntax#
**process z7p script.z7p
Examples#
The following example can be found at $Z7PATH/TESTS/Program_test/Post_test/INP/arm2_glob.inp
***global_post_processing
**output_number 1-3
**elset ALL_ELEMENT
**file integ
**process z7p arm2_glob.z7p
The script arm2_glob.z7p:
ARRAY<STRING> input()
{
ARRAY<STRING> i; // declare an array of strings to store input variables' names
i.resize(4); // resize the array
i[0]="sig11"; i[1]="sig22"; i[2]="sig33"; i[3]="sig12"; // give the names of variables to read from database
return(i);
}
ARRAY<STRING> output()
{
ARRAY<STRING> o; // declare an array of strings to store output variables' names
o.resize(1); // resize the array
o[0]="z7pmises"; // give the names of output variables
return(o);
}
void initialize()
{
global double max_mises,min_mises; // these variables should be defined global
// to be able to use them outside the scope of this function
max_mises=-MAX_DOUBLE; min_mises=MAX_DOUBLE;
}
void destroy()
{
// this function prints the minimum and maximum of stress over all maps
// done here because compute() is called for each map
Zfstream f;
endl.print();
("Max Mises ="+max_mises+endl).print();
("Min Mises ="+min_mises+endl).print();
cflush();
f.open("arm2_glob.post",18);
f<<max_mises<<" "<<min_mises<<endl; // output min and max to post file
f.close();
}
void compute()
{
int i,j;
TENSOR2 sigma;
double mises;
for(i=0;i<!ape;i=i+1) { // loop over POST_ELEMENT array
for(j=0;j<ape[i].nb_idata();j=j+1) { // loop over Gauss points
sigma.reassign(4,ape[i].idata(j).data,0); // sigma points to the values of input
// stored in ape[i].idata(j).data
mises=sigma.mises(); // compute von Mises equivalent stress
ape[i].idata(j).out[0]=mises; // fill output with mises value
if(mises<min_mises) min_mises=mises;
if(mises>max_mises) max_mises=mises;
}
}
}
Note
Some variables are pre-defined to simplify the use of the script.
Variables |
description |
|---|---|
|
array of POST_ELEMENT |
|
array of POST_NODE |
To access data of POST_ELEMENT:
ape[i].nb_idata(): number of Gauss points for POST_ELEMENT i.ape[i].idata(j): an object handling j-th Gauss point data for POST_ELEMENT i.ape[i].idata(j).data: an array for input data.ape[i].idata(j).out: an array for output data.
ape[i].nb_ndata(): number of nodes for POST_ELEMENT i.ape[i].ndata(j): an object handling j-th node data for POST_ELEMENT i.
To access data of POST_NODE:
apn[i].data(0): represents the data associated with POST_NODE i for the selected map. For global post-processing, only one map is accessed at a time.apn[i].data(0).data: input data.apn[i].data(0).out: output data.
Note
For nodal values, the compute() function from the example above can be written as:
void compute()
{
int i,j;
TENSOR2 sigma;
global double max_mises,min_mises;
double mises;
for(i=0;i<!apn;i=i+1) {
("node # "+i+endl).print(); cflush();
sigma.reassign(4,apn[i].data(0).data,0);
mises=sigma.mises();
apn[i].data(0).out[0]=mises;
if(mises<min_mises) min_mises=mises;
if(mises>max_mises) max_mises=mises;
}
}
The list of material coefficients can be declared in the Zprogram script as
ARRAY<STRING> coefficients()
{
ARRAY<STRING> c; // declare an array of string
c.resize(2); // resize the array
c[0]="coeff1"; // give the name for each coeff
c[1]="coeff2";
return(c); // return the array
}
To get the values of the coefficients in the script, use parentheses like coeff1(), coeff2().
The material file can be given as shown in the example below
***post_processing_data
**process z7p
coeff1 10.
coeff2 temperature
10. 0.
20. 200.
***return
An example with material coefficients is provided in
$Z7PATH/TESTS/Program_test/Post_test/INP/grav.inp.