CST Data Readout
CST data readout classes and a program to export CST data.
/home/zenker/tmp/CSTDataExport/CST_Readout.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef CST_Readout_h
4 #define CST_Readout_h
5 #include "CSTResultReaderInterf.h"
6 #include <vector>
7 
8 using namespace std;
9 
10 #define eps0 8.85418782e-12
11 #define mue0 M_PI*4e-7
12 
84 struct material
85 {
86  float id;
87  float eps;
88  float mue;
89  float rho;
90  float rho_set;
91  string description;
92 };
93 
97 class CST_Readout {
98 private:
99  CSTProjHandle m_pHandle;
100  int uReturnVal;
101  int m_fieldType;
102  float* m_meshMatrix;
103 
108  unsigned int m_materialProperty;
109  //mesh information
110  int* m_nxyz;
111  vector<double> m_xlines;
112  vector<double> m_ylines;
113  vector<double> m_zlines;
114 
125  void GetInv(int i, int j, int k, double &inv_x, double &inv_y, double &inv_z, bool epsOrkappa = false);
129  int GetSuperIndex(int i, int j, int k){return i + j * m_nxyz[0] + k * m_nxyz[0] * m_nxyz[1];}
130  /* @{ Private interface part needed for binary file export */
131  string m_materialFile;
132  string m_potName;
133  vector<material> m_materials;
134  vector<float> m_elementMaterialProperty;
135  vector<unsigned char> m_elementMaterialId;
136  vector<float> m_potentials;
137  string m_fieldTypeNames[5];
138  static const int headerSize = 1000;
139 
143  void PrepareMaterialData();
154  void RetrieveMaterialProperties();
163  void AssignMaterialIdToElements();
164  /* @} */
165 public:
170  CST_Readout(string cst_file);
175  virtual ~CST_Readout();
179  static double Round(double number, int digits);
186  static void PrintStatus(int event, int all_events, double percent = 0.1);
191  int* Getnxyz() {
192  return m_nxyz;
193  }
211  int GetElementMaterial(int element, int node = 3);
226  double* GetElementMaterialProperty(int element, unsigned int materialProperty,
227  int testnode = 3);
244  void GetNodesForElement(int element, vector<int> &nodes);
245  void Node2Index(int node, int &i, int &j, int &k);
257  double* GetMaterialPropertyFromIndex(int i, int j, int k, int n, unsigned int materialProperty);
258  void Element2Index(int element, int &i, int &j, int &k);
265  void RetrieveFieldData(string TreeFieldName);
267  return m_nxyz[0] * m_nxyz[1] * m_nxyz[2];
268  }
270  return (m_nxyz[0] - 1) * (m_nxyz[1] - 1) * (m_nxyz[2] - 1);
271  }
284  double* GetMaterialPropertyFromIndex(float* matMatrix_cst, int i, int j, int k, int n,
285  unsigned int materialProperty);
289  void SetPotentialName(string pot){m_potName = pot;}
290  string GetPotentialName(){return m_potName;}
295  void UsePropertyRho(){m_materialProperty = 3;}
310  void WriteElementComp(string path, string prefix = "");
317  void WritePosLines(string path, string prefix = "");
325  void WritePotentials(string TreeFieldName, string path, string prefix = "");
343  void ExtractData(string fileName, bool isWeightingField, bool writeMaterialProp = false);
362  void SetMaterialFile(string file){m_materialFile = file;}
363 };
364 
365 #endif
Definition: CST_Readout.h:97
float eps
Relative electric permittivity .
Definition: CST_Readout.h:87
void UsePropertyRho()
Definition: CST_Readout.h:295
Definition: CST_Readout.h:84
string description
Material description.
Definition: CST_Readout.h:91
int GetNumberOfNodes()
Definition: CST_Readout.h:266
float id
Material id to be used to identify materials.
Definition: CST_Readout.h:86
float rho
Material density .
Definition: CST_Readout.h:89
int GetNumberOfElements()
Definition: CST_Readout.h:269
float rho_set
The density set in CST to identify the material.
Definition: CST_Readout.h:90
int * Getnxyz()
Definition: CST_Readout.h:191
string GetPotentialName()
Definition: CST_Readout.h:290
void SetPotentialName(string pot)
Definition: CST_Readout.h:289
void SetMaterialFile(string file)
Definition: CST_Readout.h:362
float mue
Relative permeability .
Definition: CST_Readout.h:88