// FemmeDocCore.cpp : implementation of the CFemmeDocCore class // #include #include #include #include #include #include "complex.h" #include "csolv.h" #include "csolvDlg.h" #include "mesh.h" #include "spars.h" #include "FemmeDocCore.h" ///////////////////////////////////////////////////////////////////////////// // CFemmeDocCore construction/destruction CFemmeDocCore::CFemmeDocCore() { TheView=NULL; Precision=NULL; LengthUnits=NULL; ProblemType=NULL; Coords=NULL; BandWidth=NULL; NumNodes=NULL; NumEls=NULL; NumBlockProps=NULL; NumPBCs=NULL; NumLineProps=NULL; NumPointProps=NULL; NumCircProps=NULL; NumBlockLabels=NULL; meshnode=NULL; meshele=NULL; blockproplist=NULL; lineproplist=NULL; nodeproplist=NULL; circproplist=NULL; labellist=NULL; pbclist=NULL; PathName=NULL; extRo=extRi=extZo=NULL; } CFemmeDocCore::~CFemmeDocCore() { // This space for rent. } void CFemmeDocCore::CleanUp() { if (meshnode!=NULL) free(meshnode); if (meshele!=NULL) free(meshele); if (blockproplist!=NULL) free(blockproplist); if (lineproplist!=NULL) free(lineproplist); if (nodeproplist!=NULL) free(nodeproplist); if (circproplist!=NULL) free(circproplist); if (labellist!=NULL) free(labellist); if (pbclist!=NULL) free(pbclist); } ///////////////////////////////////////////////////////////////////////////// // CFemmeDocCore commands char* StripKey(char *c) { char *d; int i,k; k=(int)strlen(c); for(i=0;i0) nodeproplist=(CPointProp *)calloc(k,sizeof(CPointProp)); q[0]=NULL; } if( _strnicmp(q,"",11)==0){ PProp.V=0; PProp.qp=0; q[0]=NULL; } if( _strnicmp(q,"",4)==0){ v=StripKey(s); sscanf(v,"%lf",&PProp.V.re); q[0]=NULL; } if( _strnicmp(q,"",4)==0){ v=StripKey(s); sscanf(v,"%lf",&PProp.V.im); q[0]=NULL; } if( _strnicmp(q,"",4)==0){ v=StripKey(s); sscanf(v,"%lf",&PProp.qp.re); q[0]=NULL; } if( _strnicmp(q,"",4)==0){ v=StripKey(s); sscanf(v,"%lf",&PProp.qp.im); q[0]=NULL; } if( _strnicmp(q,"",9)==0){ nodeproplist[NumPointProps]=PProp; NumPointProps++; q[0]=NULL; } // Boundary Properties; if( _strnicmp(q,"[bdryprops]",11)==0){ v=StripKey(s); sscanf(v,"%i",&k); if (k>0) lineproplist=(CBoundaryProp *)calloc(k,sizeof(CBoundaryProp)); q[0]=NULL; } if( _strnicmp(q,"",11)==0){ BProp.BdryFormat=0; BProp.V=0; BProp.qs=0; BProp.c0=0; BProp.c1=0; q[0]=NULL; } if( _strnicmp(q,"",10)==0){ v=StripKey(s); sscanf(v,"%i",&BProp.BdryFormat); q[0]=NULL; } if( _strnicmp(q,"",4)==0){ v=StripKey(s); sscanf(v,"%lf",&BProp.V.re); q[0]=NULL; } if( _strnicmp(q,"",4)==0){ v=StripKey(s); sscanf(v,"%lf",&BProp.V.im); q[0]=NULL; } if( _strnicmp(q,"",4)==0){ v=StripKey(s); sscanf(v,"%lf",&BProp.qs.re); q[0]=NULL; } if( _strnicmp(q,"",4)==0){ v=StripKey(s); sscanf(v,"%lf",&BProp.qs.im); q[0]=NULL; } if( _strnicmp(q,"",5)==0){ v=StripKey(s); sscanf(v,"%lf",&BProp.c0.re); q[0]=NULL; } if( _strnicmp(q,"",5)==0){ v=StripKey(s); sscanf(v,"%lf",&BProp.c0.im); q[0]=NULL; } if( _strnicmp(q,"",5)==0){ v=StripKey(s); sscanf(v,"%lf",&BProp.c1.re); q[0]=NULL; } if( _strnicmp(q,"",5)==0){ v=StripKey(s); sscanf(v,"%lf",&BProp.c1.im); q[0]=NULL; } if( _strnicmp(q,"",9)==0){ lineproplist[NumLineProps]=BProp; NumLineProps++; q[0]=NULL; } // Block Properties; if( _strnicmp(q,"[blockprops]",12)==0){ v=StripKey(s); sscanf(v,"%i",&k); if (k>0) blockproplist=(CMaterialProp *)calloc(k,sizeof(CMaterialProp)); q[0]=NULL; } if( _strnicmp(q,"",12)==0){ MProp.ex=1; MProp.ey=1; MProp.ox=1; MProp.oy=1; q[0]=NULL; } if( _strnicmp(q,"",4)==0){ v=StripKey(s); sscanf(v,"%lf",&MProp.ox); q[0]=NULL; } if( _strnicmp(q,"",4)==0){ v=StripKey(s); sscanf(v,"%lf",&MProp.oy); q[0]=NULL; } if( _strnicmp(q,"",4)==0){ v=StripKey(s); sscanf(v,"%lf",&MProp.ex.re); MProp.ex.im=0; q[0]=NULL; } if( _strnicmp(q,"",4)==0){ v=StripKey(s); sscanf(v,"%lf",&MProp.ey.re); MProp.ey.im=0; q[0]=NULL; } if( _strnicmp(q,"",5)==0){ v=StripKey(s); double lt; sscanf(v,"%lf",<); lt=-atan(lt); MProp.ex=MProp.ex*exp(I*lt); q[0]=NULL; } if( _strnicmp(q,"",5)==0){ v=StripKey(s); double lt; sscanf(v,"%lf",<); lt=-atan(lt); MProp.ey=MProp.ey*exp(I*lt); q[0]=NULL; } if( _strnicmp(q,"",9)==0){ MProp.kx=MProp.ox/eo+I*Frequency*MProp.ex; MProp.ky=MProp.oy/eo+I*Frequency*MProp.ey; blockproplist[NumBlockProps]=MProp; NumBlockProps++; q[0]=NULL; } // Conductor Properties if( _strnicmp(q,"[conductorprops]",16)==0){ v=StripKey(s); sscanf(v,"%i",&k); if(k>0) circproplist=(CCircuit *)calloc(k,sizeof(CCircuit)); q[0]=NULL; } if( _strnicmp(q,"",16)==0){ CProp.V=0; CProp.q=0; CProp.CircType=0; q[0]=NULL; } if( _strnicmp(q,"",5)==0){ v=StripKey(s); sscanf(v,"%lf",&CProp.V.re); q[0]=NULL; } if( _strnicmp(q,"",5)==0){ v=StripKey(s); sscanf(v,"%lf",&CProp.V.im); q[0]=NULL; } if( _strnicmp(q,"",5)==0){ v=StripKey(s); sscanf(v,"%lf",&CProp.q.re); q[0]=NULL; } if( _strnicmp(q,"",5)==0){ v=StripKey(s); sscanf(v,"%lf",&CProp.q.im); q[0]=NULL; } if( _strnicmp(q,"",15)==0){ v=StripKey(s); sscanf(v,"%i",&CProp.CircType); q[0]=NULL; } if( _strnicmp(q,"",14)==0){ circproplist[NumCircProps]=CProp; NumCircProps++; q[0]=NULL; } // read in regional attributes if(_strnicmp(q,"[numblocklabels]",13)==0){ int i; v=StripKey(s); sscanf(v,"%i",&k); if (k>0) labellist=(CBlockLabel *)calloc(k, sizeof(CBlockLabel)); NumBlockLabels=k; for(i=0;i1){ // strip off point BC number; j=n & 0xffff; j=j-2; if (j<0) j=-1; // strip off Conductor number n= (n - (n & 0xffff))/0x10000 - 1; } else{ j=-1; n=-1; } node.bc=j; node.InConductor=n; // convert all lengths to internal working units of mm node.x*=c[LengthUnits]; node.y*=c[LengthUnits]; meshnode[i]=node; } fclose(fp); //read in periodic boundary conditions; sprintf(infile,"%s.pbc",PathName); if((fp=fopen(infile,"rt"))==NULL){ return FALSE; } fgets(s,1024,fp); sscanf(s,"%i",&NumPBCs); if (NumPBCs!=0) pbclist=(CCommonPoint *)calloc(NumPBCs,sizeof(CCommonPoint)); CCommonPoint pbc; for(i=0;i=0) { meshnode[n0].InConductor=n; meshnode[n1].InConductor=n; } } else j=-1; if (j>=0) { // search through elements to find one containing the line; // set corresponding edge equal to the bc number for(q=0,n=FALSE;q