diff --git a/FDTD/operator.cpp b/FDTD/operator.cpp index 89f541c..be4228e 100644 --- a/FDTD/operator.cpp +++ b/FDTD/operator.cpp @@ -125,6 +125,93 @@ bool Operator::SnapToMesh(double* dcoord, unsigned int* uicoord, bool lower) return ok; } +struct Operator::Grid_Path Operator::FindPath(double start[], double stop[]) +{ + struct Grid_Path path; + double dV[] = {stop[0]-start[0],stop[1]-start[1],stop[2]-start[2]}; + + unsigned int uiStart[3],uiStop[3],currPos[3],pos[3]; + SnapToMesh(start,uiStart); + SnapToMesh(stop,uiStop); + currPos[0]=uiStart[0]; + currPos[1]=uiStart[1]; + currPos[2]=uiStart[2]; + double meshStart[] = {discLines[0][uiStart[0]], discLines[1][uiStart[1]], discLines[2][uiStart[2]]}; + double meshStop[] = {discLines[0][uiStop[0]], discLines[1][uiStop[1]], discLines[2][uiStop[2]]}; + + double foot,dist,minFoot,minDist,minDir; + unsigned int minPos[3]; + double startFoot,stopFoot,currFoot; + Point_Line_Distance(meshStart,start,stop,startFoot,dist); + Point_Line_Distance(meshStop,start,stop,stopFoot,dist); + currFoot=startFoot; + + double P[3]; + +// cerr << "start pos " << discLines[0][currPos[0]] << " " << discLines[1][currPos[1]] << " " << discLines[2][currPos[2]] << endl; +// +// FDTD_FLOAT**** array = Create_N_3DArray(numLines); + + while (minFoot=0) + { + P[n] = discLines[n][currPos[n]-1]; + Point_Line_Distance(P,start,stop,foot,dist); + if ((foot>currFoot) && (distcurrFoot) && (dist vec_prop = CSX->GetPropertyByType(CSProperties::METAL); + for (size_t p=0;pGetQtyPrimitives();++n) + { + CSPrimitives* prim = prop->GetPrimitive(n); + CSPrimCurve* curv = prim->ToCurve(); + if (curv) + { + for (size_t i=1;iGetNumberOfPoints();++i) + { + curv->GetPoint(i-1,p1); + curv->GetPoint(i,p2); + path = FindPath(p1,p2); + cerr << p1[0] << " " << p1[1] << " " << p1[2] << endl; + cerr << p2[0] << " " << p2[1] << " " << p2[2] << endl; + for (size_t t=0;t posPath[3]; + vector dir; + }; + struct Grid_Path FindPath(double start[], double stop[]); + ContinuousStructure* CSX; double gridDelta; diff --git a/examples/FDTD_examples.cpp b/examples/FDTD_examples.cpp index 4be87c3..88bfa02 100644 --- a/examples/FDTD_examples.cpp +++ b/examples/FDTD_examples.cpp @@ -147,11 +147,13 @@ void BuildPlaneWave(const char* filename) CSPropMaterial* mat2 = new CSPropMaterial(CSX.GetParameterSet()); mat2->SetEpsilon(2); CSX.AddProperty(mat2); - box = new CSPrimBox(CSX.GetParameterSet(),mat2); - box->SetCoord(0,width/-2.0);box->SetCoord(1,width/2.0); - box->SetCoord(2,hight/-2.0);box->SetCoord(3,hight/2.0); - box->SetCoord(4,length/-4.0);box->SetCoord(5,length/4.0); - CSX.AddPrimitive(box); + CSPrimCylindricalShell* cylshell = new CSPrimCylindricalShell(CSX.GetParameterSet(),mat2); + cylshell->SetRadius(length/4.0); + cylshell->SetShellWidth(200.0); + cylshell->SetCoord(0,0.0);cylshell->SetCoord(1,0.0); + cylshell->SetCoord(2,hight/-2.0);cylshell->SetCoord(3,hight/2.0); + cylshell->SetCoord(4,0.0);cylshell->SetCoord(5,0.0); + CSX.AddPrimitive(cylshell); CSPropElectrode* elec = new CSPropElectrode(CSX.GetParameterSet()); elec->SetExcitation(1,1); @@ -490,7 +492,7 @@ void BuildCoaxial_Cartesian(const char* filename) //E-field dump CSPropDumpBox* Edump = new CSPropDumpBox(CSX.GetParameterSet()); Edump->SetDumpType(0); - Edump->SetDumpMode(2); + Edump->SetDumpMode(0); Edump->SetName("Et_"); CSX.AddProperty(Edump); box = new CSPrimBox(CSX.GetParameterSet(),Edump); @@ -609,10 +611,11 @@ void BuildHelix(const char* filename) ContinuousStructure CSX; double feed_length=10; - double wire_rad = 0.7; + double wire_rad = sqrt(1.4/PI); double coil_rad = 10; double coil_length = 50; int coil_turns = 8; + int coil_res = 10; double delta[] = {0.5,0.5,0.5}; CSPrimBox* box = NULL; @@ -628,33 +631,61 @@ void BuildHelix(const char* filename) copper->SetName("copper"); CSX.AddProperty(copper); - CSPrimUserDefined* helix = new CSPrimUserDefined(CSX.GetParameterSet(),copper); - helix->SetCoordSystem(CSPrimUserDefined::CYLINDER_SYSTEM); - helix->SetFunction("(r>(rad_coil-rad_wire))&(r0)&(zSetRadius(wire_rad); - cyl->SetCoord(0,coil_rad); cyl->SetCoord(1,coil_rad+feed_length); - cyl->SetCoord(2,0.0); cyl->SetCoord(3,0.0); - cyl->SetCoord(4,0.0); cyl->SetCoord(5,0.0); - CSX.AddPrimitive(cyl); - cyl = new CSPrimCylinder(CSX.GetParameterSet(),copper); - cyl->SetRadius(wire_rad); - cyl->SetCoord(0,coil_rad); cyl->SetCoord(1,coil_rad+feed_length); - cyl->SetCoord(2,0.0); cyl->SetCoord(3,0.0); - cyl->SetCoord(4,coil_length); cyl->SetCoord(5,coil_length); - CSX.AddPrimitive(cyl); +// CSPropMetal* pec = new CSPropMetal(CSX.GetParameterSet()); +// CSX.AddProperty(pec); +// CSPrimCurve* curve = new CSPrimCurve(CSX.GetParameterSet(),pec); + CSPrimWire* curve = new CSPrimWire(CSX.GetParameterSet(),copper); + curve->SetWireRadius("rad_wire"); + double p[3]; + double dt = 1.0/coil_res; + double height=0; + for (int n=0;nAddPoint(p); + } + height += coil_length/(double)coil_turns; + } +// exit(0); + CSX.AddPrimitive(curve); - double kappa_resist = (coil_length)/50/1e-3; +// CSPrimUserDefined* helix = new CSPrimUserDefined(CSX.GetParameterSet(),copper); +// helix->SetCoordSystem(CSPrimUserDefined::CYLINDER_SYSTEM); +// helix->SetFunction("(r>(rad_coil-rad_wire))&(r0)&(zSetCoord(0,coil_rad); box->SetCoord(1,coil_rad+feed_length); + box->SetCoord(2,-0.5); box->SetCoord(3,0.5); + box->SetCoord(4,-0.5); box->SetCoord(5,0.5); + CSX.AddPrimitive(box); + box = new CSPrimBox(CSX.GetParameterSet(),copper); + box->SetCoord(0,coil_rad); box->SetCoord(1,coil_rad+feed_length); + box->SetCoord(2,-0.5); box->SetCoord(3,0.5); + box->SetCoord(4,coil_length-0.5); box->SetCoord(5,coil_length+0.5); + CSX.AddPrimitive(box); + box = new CSPrimBox(CSX.GetParameterSet(),copper); + box->SetCoord(0,coil_rad+feed_length-0.5); box->SetCoord(1,coil_rad+feed_length+0.5); + box->SetCoord(2,-0.5); box->SetCoord(3,0.5); + box->SetCoord(4,0.0); box->SetCoord(5,coil_length);///2.0-delta[2]); + CSX.AddPrimitive(box); + + double kappa_resist = (coil_length/3.0)/50/1e-3; CSPropMaterial* Src_Resist = new CSPropMaterial(CSX.GetParameterSet()); Src_Resist->SetKappa(kappa_resist,2); Src_Resist->SetIsotropy(false); Src_Resist->SetName("resist"); CSX.AddProperty(Src_Resist); box = new CSPrimBox(CSX.GetParameterSet(),Src_Resist); + box->SetPriority(100); box->SetCoord(0,coil_rad+feed_length-0.5); box->SetCoord(1,coil_rad+feed_length+0.5); box->SetCoord(2,-0.5); box->SetCoord(3,0.5); - box->SetCoord(4,0.0); box->SetCoord(5,coil_length);///2.0-delta[2]); + box->SetCoord(4,coil_length/3.0); box->SetCoord(5,coil_length/3.0*2.0);///2.0-delta[2]); CSX.AddPrimitive(box); // box = new CSPrimBox(CSX.GetParameterSet(),Src_Resist); // box->SetCoord(0,coil_rad+feed_length-0.5); box->SetCoord(1,coil_rad+feed_length+0.5); @@ -670,7 +701,7 @@ void BuildHelix(const char* filename) box = new CSPrimBox(CSX.GetParameterSet(),elec); box->SetCoord(0,coil_rad+feed_length+0.5); box->SetCoord(1,coil_rad+feed_length-0.5); box->SetCoord(2,-0.5); box->SetCoord(3,0.5); - box->SetCoord(4,0.0); box->SetCoord(5,coil_length); + box->SetCoord(4,coil_length/3.0); box->SetCoord(5,coil_length/3.0*2.0);///2.0-delta[2]); CSX.AddPrimitive(box); // CSPropMetal* elec_mat = new CSPropMetal(CSX.GetParameterSet()); @@ -743,7 +774,7 @@ void BuildHelix(const char* filename) CSX.AddPrimitive(box); //current calc - double curr_dist = 1; + double curr_dist = 2; CSPropProbeBox* curr = new CSPropProbeBox(CSX.GetParameterSet()); curr->SetProbeType(1); curr->SetName("i1"); @@ -814,6 +845,7 @@ void BuildHelix(const char* filename) TiXmlElement FDTD_Opts("FDTD"); FDTD_Opts.SetAttribute("NumberOfTimesteps",maxIter); + FDTD_Opts.SetDoubleAttribute("endCriteria",1e-8); TiXmlElement Excite("Excitation"); Excite.SetAttribute("Type",Excit_Type); diff --git a/examples/Helix.xml b/examples/Helix.xml index 9a473ef..9299cca 100644 --- a/examples/Helix.xml +++ b/examples/Helix.xml @@ -1,20 +1,20 @@ - + - + -35,-25,-20,-15,-12,-11,-10.5,-10,-9.5,-9,-8.5,-8,-7.5,-7,-6.5,-6,-5.5,-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,12,13.5,15,17,18,19,19.5,20,20.5,21,22,23,25,27.5,30,35,45 -35,-25,-20,-15,-12,-11,-10.5,-10,-9.5,-9,-8.5,-8,-7.5,-7,-6.5,-6,-5.5,-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,12,13,15,17.5,20,25,35 -25,-15,-10,-5,-2,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12,12.5,13,13.5,14,14.5,15,15.5,16,16.5,17,17.5,18,18.5,19,19.5,20,20.5,21,21.5,22,22.5,23,23.5,24,24.5,25,25.5,26,26.5,27,27.5,28,28.5,29,29.5,30,30.5,31,31.5,32,32.5,33,33.5,34,34.5,35,35.5,36,36.5,37,37.5,38,38.5,39,39.5,40,40.5,41,41.5,42,42.5,43,43.5,44,44.5,45,45.5,46,46.5,47,47.5,48,48.5,49,49.5,50,50.5,51,52,53,55,57.5,60,65,75 - - - - + + + + @@ -32,7 +32,7 @@ - + @@ -67,41 +67,131 @@ - - - (r>(rad_coil-rad_wire))&(r<rad_coil+rad_wire)&(sqrt(pow(x-r*cos(2*pi*z*turns/coil_length),2)+pow(y-r*sin(2*pi*z*turns/coil_length),2))<(2*rad_wire))&(z>0)&(z<coil_length) - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - + + + + + - + - + - - - + + + diff --git a/main.cpp b/main.cpp index ca5c195..950c4fa 100644 --- a/main.cpp +++ b/main.cpp @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) const char* file=fileHelix; -// FDTD.DebugMaterial(); + FDTD.DebugMaterial(); // FDTD.DebugOperator(); #endif diff --git a/openEMS.pro b/openEMS.pro index 52df9c1..43c0d75 100644 --- a/openEMS.pro +++ b/openEMS.pro @@ -8,7 +8,6 @@ CONFIG -= app_bundle TEMPLATE = app OBJECTS_DIR = obj INCLUDEPATH += ../CSXCAD \ - ../fparser \ ../tinyxml LIBS += -L../CSXCAD \ -lCSXCAD \