You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
131 lines
3.7 KiB
131 lines
3.7 KiB
// PORTMESH.H
|
|
#ifndef PORTMESH_H
|
|
#define PORTMESH_H
|
|
#include "counter.h"
|
|
#include "node.h"
|
|
#include "path.h"
|
|
#include "edge.h"
|
|
#include "face.h"
|
|
#include "tree.h"
|
|
#include "coord.h"
|
|
#include "material.h"
|
|
#include "array.h"
|
|
#include <map>
|
|
#include "vtkwriter.h"
|
|
|
|
class portMesh{
|
|
friend class FemGrp;
|
|
|
|
private:
|
|
char portName[StrLenShort];
|
|
int faceCNT;
|
|
int edgeCNT;
|
|
int nodeCNT;
|
|
int objCNT;
|
|
int* objMAP;
|
|
fp_t modeIMP;
|
|
fp_t magE;
|
|
fp_t impZ;
|
|
fp_t gamma;
|
|
Path vline;
|
|
Coordinate coord;
|
|
face** fcArray;
|
|
node** ndArray;
|
|
map<int, int>* globToLocMap_; // global to local (2D) node mapping
|
|
Tree<edge> portEdgeTree;
|
|
vtr PortDirection_vtr;
|
|
|
|
public:
|
|
// constructor
|
|
portMesh();
|
|
~portMesh();
|
|
|
|
Tree<edge> *getportEdgeTreePtr(){return &portEdgeTree;}
|
|
void insertportEdge(edge eg){portEdgeTree.insertNode(eg);}
|
|
|
|
// Set Functions
|
|
void allocGlobToLocMap(){globToLocMap_ = new map<int, int>;}
|
|
void setMagE(fp_t cval){magE= cval;}
|
|
void setmodeIMP(fp_t rval){modeIMP = rval;}
|
|
void setImpZ(fp_t cval){impZ= cval;}
|
|
void setName(char *buffer){sprintf(portName, "%s", buffer);}
|
|
void setNodeCnt(int nodeCnt);
|
|
void setFaceCnt(int faceCnt);
|
|
|
|
// Get functions
|
|
map<int, int>& getGlobToLocMap(){return *globToLocMap_;}
|
|
int getEdgeCnt(){return edgeCNT;}
|
|
int getFaceCnt(){return faceCNT;}
|
|
fp_t getmagE(){return magE;}
|
|
fp_t getmodeIMP(){return modeIMP;}
|
|
fp_t getimpZ(){return impZ;}
|
|
char* getName(){return portName;}
|
|
int getobjMAP(int );
|
|
node** getNodeArray(){return ndArray;}
|
|
face** getFaceArray(){return fcArray;}
|
|
vtr getPortDirection(){return PortDirection_vtr;}
|
|
|
|
void allocFaceArray(){fcArray = new face*[faceCNT];}
|
|
|
|
void makeObjMap();
|
|
void makeCoordSystem();
|
|
void makeRHS(fp_t, int, int *, portCounter); // this is for guiding ports
|
|
void makeRHS_E();
|
|
void makeRHS_H();
|
|
|
|
void writeMesh(Material *, fp_t); // write out 2d mesh
|
|
void writeMesh(Material* propMat);
|
|
|
|
// vline operations
|
|
void readVline(fp_t );
|
|
void readVline(fp_t , fp_t& , fp_t& , fp_t& );
|
|
void writeVtk();
|
|
|
|
void fill_TEM_Port(double freq_Hz, double eps_r,
|
|
double vpx, double vpy, double vpz,
|
|
double portx, double porty, double portz);
|
|
|
|
|
|
static inline double dot(const vtr& a, const vtr& b)
|
|
{
|
|
return a.getx()*b.getx() + a.gety()*b.gety() + a.getz()*b.getz();
|
|
}
|
|
|
|
static inline vtr cross(const vtr& a, const vtr& b)
|
|
{
|
|
return vtr(a.gety()*b.getz() - a.getz()*b.gety(),
|
|
a.getz()*b.getx() - a.getx()*b.getz(),
|
|
a.getx()*b.gety() - a.gety()*b.getx());
|
|
}
|
|
|
|
static inline double norm(const vtr& a)
|
|
{
|
|
return std::sqrt(dot(a,a));
|
|
}
|
|
|
|
static inline vtr normalize(const vtr& a)
|
|
{
|
|
double n=norm(a); return (n>0)? (a*(1.0/n)) : vtr(0,0,0);
|
|
}
|
|
|
|
// Triangle area (used for power normalization)
|
|
static inline double tri_area(const vtr& r0, const vtr& r1, const vtr& r2)
|
|
{
|
|
return 0.5 * norm( cross(r1 - r0, r2 - r0) );
|
|
}
|
|
|
|
|
|
std::complex<double> modeImpedance;
|
|
|
|
void makeRHS_TEM(double freq_Hz, double eps_r,
|
|
double Ex_dir_x, double Ex_dir_y, double Ex_dir_z, // desired E direction (normal to PEC pair)
|
|
double PortDir_x, double PortDir_y, double PortDir_z); // propagation (+S)
|
|
|
|
private:
|
|
vtr findFaceNormal(face& Face);
|
|
void findNodes(node** vNode, node** eNode);
|
|
void insertOBJ(int );
|
|
};
|
|
#endif
|
|
|
|
|
|
|