CST Data Readout
CST data readout classes and a program to export CST data.
Public Member Functions | Static Public Member Functions
CST_Readout Class Reference

#include <CST_Readout.h>

Public Member Functions

 CST_Readout (string cst_file)
 
virtual ~CST_Readout ()
 
General interface methods
int * Getnxyz ()
 
int GetElementMaterial (int element, int node=3)
 
double * GetElementMaterialProperty (int element, unsigned int materialProperty, int testnode=3)
 
void GetNodesForElement (int element, vector< int > &nodes)
 
void Node2Index (int node, int &i, int &j, int &k)
 
double * GetMaterialPropertyFromIndex (int i, int j, int k, int n, unsigned int materialProperty)
 
void Element2Index (int element, int &i, int &j, int &k)
 
void RetrieveFieldData (string TreeFieldName)
 
int GetNumberOfNodes ()
 
int GetNumberOfElements ()
 
double * GetMaterialPropertyFromIndex (float *matMatrix_cst, int i, int j, int k, int n, unsigned int materialProperty)
 
void SetPotentialName (string pot)
 
string GetPotentialName ()
 
void UsePropertyRho ()
 
Interface methods for text based export
void WriteElementComp (string path, string prefix="")
 
void WritePosLines (string path, string prefix="")
 
void WritePotentials (string TreeFieldName, string path, string prefix="")
 
Interface methods for binary export
void ExtractData (string fileName, bool isWeightingField, bool writeMaterialProp=false)
 
void SetMaterialFile (string file)
 

Static Public Member Functions

static double Round (double number, int digits)
 
static void PrintStatus (int event, int all_events, double percent=0.1)
 

Constructor & Destructor Documentation

CST_Readout::CST_Readout ( string  cst_file)
Parameters
cst_fileThe file name including the full path of the CST project to be used.
Exceptions
runtime_error
virtual CST_Readout::~CST_Readout ( )
virtual

Destructor

Exceptions
runtime_error

Member Function Documentation

void CST_Readout::Element2Index ( int  element,
int &  i,
int &  j,
int &  k 
)
void CST_Readout::ExtractData ( string  fileName,
bool  isWeightingField,
bool  writeMaterialProp = false 
)

Exported are:

  • material information from m_materialFile
  • mesh information m_xlines, m_ylines, m_zlines
  • potentials
  • material property ( $\rho$) of each node
  • element material id corresponding to materials in m_materialFile
    Parameters
    fileNameFile name including path used to write data. If file already exists it is overwritten.
    isWeightingFieldIf true only potentials are exported.
    writeMaterialPropWrite material property ( $\rho$), else it is not stored. In Garfield++ this information is not needed since the material information per element is used.
    Attention
    Consider also to call UsePropertyRho() before. If done the material is assigned based on the density $\rho$ set in CST instead of using the permittivity. In order to do so you need to give the density assigned to the materials (in CST) in the material xml file -> rho_set
    Exceptions
    runtime_error
int CST_Readout::GetElementMaterial ( int  element,
int  node = 3 
)

Calculate the material id for a certain element of the mesh. This is only used in case of the deprecated text based data export. The material assignment is based on the relative electric permittivity $\epsilon_r$ of node number 3. It is assumed that the material is isotropic and therefore the first component of the material property vector that is given by CST is used to calculate the element material. Three different types of material are known:

  • Kapton (material id = 3): $3.4 < \epsilon_r < 3.6$, nominal value: $\epsilon_r = 3.5$
  • G10 (material id = 4): $4.7 < \epsilon_r < 4.9$, nominal value: $\epsilon_r = 4.8$
  • Alumina (material id = 5): $9.3 < \epsilon_r < 9.5$, nominal value: $\epsilon_r = 9.4$
  • PEEK (material id = 6): $3.2 < \epsilon_r < 3.3$, nominal value: $\epsilon_r = 3.3$
  • PEC (material id = 1): $\epsilon_r$ <= DBL_MAX & $\epsilon_r$ >= -DBL_MAX
  • else (material id = 2) it is treated as gas.
    Parameters
    elementThe element id
    nodeGive the node number (0-7) to be considered for assigning the material (the $\epsilon_r$ value of that note is used)
double* CST_Readout::GetElementMaterialProperty ( int  element,
unsigned int  materialProperty,
int  testnode = 3 
)

Calculate an element property for an element in the mesh. In principle the calculation is done for a certain node of the element. In the example that can be found in the CST installation (GetMaterialValueAtXYZ.m) node 3 is used to calculate the property for the element. The material property is returned with 3 components that differ for anisotropic materials.

Parameters
elementThe ID of the element, which is used to calculate the material property.
materialProperty0= $\epsilon_r$, 1= $\mu$, 2= $\kappa$, 3= $\rho$
Thenode number used to calculate the material property of the given element. (see CST_Readout::GetNodesForElement for a sketch).
Remarks
You take over the array and need to delete it if you don't need it anymore.
double* CST_Readout::GetMaterialPropertyFromIndex ( int  i,
int  j,
int  k,
int  n,
unsigned int  materialProperty 
)

See CST_Readout::GetElementMaterialProperty Here not the element but its indexes in the mesh are given.

Parameters
iIndex of node 3 of the element in question in x direction.
jIndex of node 3 of the element in question in y direction.
kIndex of node 3 of the element in question in z direction.
nThe super index of the node used for the material calculation.
materialProperty0= $\epsilon_r$, 1= $\mu$, 2= $\kappa$, 3= $\rho$
Remarks
You take over the array and need to delete it if you don't need it anymore.
Exceptions
runtime_error
double* CST_Readout::GetMaterialPropertyFromIndex ( float *  matMatrix_cst,
int  i,
int  j,
int  k,
int  n,
unsigned int  materialProperty 
)

Here for a given position (node with indexes i,j,k) $\epsilon_r$ (matType=0), $\mu$ (matType=1), $\kappa$ (matType=2) or $\rho$ (matType =3) are calculated.

Parameters
matMatrix_cstThe material matrix as exported from CST.
iIndex of node 3 of the element in question in x direction.
jIndex of node 3 of the element in question in y direction.
kIndex of node 3 of the element in question in z direction.
nThe super index of the node used for the material calculation.
materialPropertySee above.
Remarks
You take over the array and need to delete it if you don't need it anymore.
Exceptions
runtime_error
void CST_Readout::GetNodesForElement ( int  element,
vector< int > &  nodes 
)

Calculate the index of all nodes of a certain element.

global coordinates 7 _ _ _ _6 t3 t2
/ /| ^ /|
^ z / / | | /
| 4 /_______/5 | | /
| | | | | /
| | 3 | /2 |/ t1
-------> | | / ------->
/ y | |/ local coordinates
/ 0--------1
/
v x
int CST_Readout::GetNumberOfElements ( )
inline
int CST_Readout::GetNumberOfNodes ( )
inline
int* CST_Readout::Getnxyz ( )
inline

Get the number x (m_nxyz[0]), y(m_nxyz[1]), and z(m_nxyz[2]) lines in the CST mesh.

string CST_Readout::GetPotentialName ( )
inline
void CST_Readout::Node2Index ( int  node,
int &  i,
int &  j,
int &  k 
)
static void CST_Readout::PrintStatus ( int  event,
int  all_events,
double  percent = 0.1 
)
static

Just print the status of reading data used for the text based export.

Parameters
eventThe current processed event.
all_eventsThe total number of events to be processed.
percentSet the frequency of printing the status. Default means every 10% a message is printed to the terminal.
void CST_Readout::RetrieveFieldData ( string  TreeFieldName)

Here the field specified by Tree3DField is read. This means Tree3DField should correspond to the name of the tree, that contains the information of the potentials in your CST project.

Exceptions
runtime_error
static double CST_Readout::Round ( double  number,
int  digits 
)
static

Round a given number to the given number of digits.

void CST_Readout::SetMaterialFile ( string  file)
inline

The xml file containing informations about the materials considered in the simulation. It should be formatted like this:

<Materials Count="3">
<Material ID="2" description="gas" eps="1" mue="1" rho="0" rho_set="1"></Material>
<Material ID="0" description="PEC" eps="1000000" mue="1000000" rho="1000000" rho_set="0"></Material>
<Material ID="1" description="kapton" eps="3.5" mue="1" rho="2.3" rho_set="2"></Material>
</Materials>
Remarks
PEC is always expected to have ID 0! The density set CST should correspond to rho_set given in the xml file - it will be used when assigning materials to elements based on the density (see ExtractData()). If you use the default option to assign the element material based on the permittivity, the only parameters used are: ID, description, eps
Exceptions
runtime_error
void CST_Readout::SetPotentialName ( string  pot)
inline

Set/Get the name of the potential in the CST file to be exported.

void CST_Readout::UsePropertyRho ( )
inline

Use this to change the material property that is used to assign a material to elements. The default property is $\epsilon_r $. When calling this method $\rho$ will used instead.

void CST_Readout::WriteElementComp ( string  path,
string  prefix = "" 
)

Here the file ELIST.lis is created in path. It contains the element number, the type of material and the nodes corresponding to the element (element,node1,node2...). The material is encoded as follows:

  • mat == 3: Kapton eps +- 0.4 = 3. ~ 4.,
  • mat == 5: Al
  • mat == 4: G10
  • mat == 3: Kapton
  • mat == 2: PEC [eps = #inf],
  • mat == 1: vacuum else
    Parameters
    pathThe path where the the file named PRNSOL.lis will be stored.
    prefixThis is the name of a subdirectory where to store the PRNSOL.lis file inside the directory specified in path.
void CST_Readout::WritePosLines ( string  path,
string  prefix = "" 
)

Here the file NODELINES.lis is created in path. It contains the positions of the nodes for all possible positions (but not for each node)

Parameters
pathThe path where the the file named PRNSOL.lis will be stored.
prefixThis is the name of a subdirectory where to store the PRNSOL.lis file inside the directory specified in path.
void CST_Readout::WritePotentials ( string  TreeFieldName,
string  path,
string  prefix = "" 
)

Here the file PRNSOL.lis is created in path. It contains the element number and the corresponding potential.

Parameters
TreeFieldNameThe name of the tree, that contains the information of the potentials in the CST project.
pathThe path where the the file named PRNSOL.lis will be stored.
prefixThis is the name of a subdirectory where to store the PRNSOL.lis file inside the directory specified in path.

The documentation for this class was generated from the following file: