Skip to content
Snippets Groups Projects
Commit fbccbab0 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

cleanup

parent 7b260816
No related branches found
No related tags found
No related merge requests found
...@@ -119,8 +119,8 @@ void GMSH_CutParametricPlugin::draw(void *context) ...@@ -119,8 +119,8 @@ void GMSH_CutParametricPlugin::draw(void *context)
} }
else{ else{
glBegin(GL_TRIANGLES); glBegin(GL_TRIANGLES);
for(unsigned int i = 0; i < nbU - 1; ++i){ for(int i = 0; i < nbU - 1; ++i){
for(unsigned int j = 0; j < nbV - 1; ++j){ for(int j = 0; j < nbV - 1; ++j){
int v = i * nbV + j; int v = i * nbV + j;
glVertex3d(x[v], y[v], z[v]); glVertex3d(x[v], y[v], z[v]);
glVertex3d(x[v+1], y[v+1], z[v+1]); glVertex3d(x[v+1], y[v+1], z[v+1]);
...@@ -342,7 +342,7 @@ PView *GMSH_CutParametricPlugin::execute(PView *v) ...@@ -342,7 +342,7 @@ PView *GMSH_CutParametricPlugin::execute(PView *v)
for(int k = 0; k < 9 * numSteps; ++k) res0[k] = res1[k] = 0.; for(int k = 0; k < 9 * numSteps; ++k) res0[k] = res1[k] = 0.;
if(nbU == 1 || nbV == 1 || !connect){ if(nbU == 1 || nbV == 1 || !connect){
for(int i = 0; i < x.size(); ++i){ for(unsigned int i = 0; i < x.size(); ++i){
if(i && connect){ if(i && connect){
x0 = x1; x0 = x1;
y0 = y1; y0 = y1;
...@@ -375,18 +375,10 @@ PView *GMSH_CutParametricPlugin::execute(PView *v) ...@@ -375,18 +375,10 @@ PView *GMSH_CutParametricPlugin::execute(PView *v)
for(int i = 0; i < nbU - 1; ++i){ for(int i = 0; i < nbU - 1; ++i){
for(int j = 0; j < nbV - 1; ++j){ for(int j = 0; j < nbV - 1; ++j){
int v = i * nbV + j; int v = i * nbV + j;
x0 = x[v]; x0 = x[v]; y0 = y[v]; z0 = z[v];
y0 = y[v]; x1 = x[v+1]; y1 = y[v+1]; z1 = z[v+1];
z0 = z[v]; x2 = x[v+nbV+1]; y2 = y[v+nbV+1]; z2 = z[v+nbV+1];
x1 = x[v+1]; x3 = x[v+nbV]; y3 = y[v+nbV]; z3 = z[v+nbV];
y1 = y[v+1];
z1 = z[v+1];
x2 = x[v+nbV+1];
y2 = y[v+nbV+1];
z2 = z[v+nbV+1];
x3 = x[v+nbV];
y3 = y[v+nbV];
z3 = z[v+nbV];
if(data1->getNumScalars()){ if(data1->getNumScalars()){
o.searchScalar(x0, y0, z0, res0); o.searchScalar(x0, y0, z0, res0);
......
...@@ -27,9 +27,9 @@ extern "C" ...@@ -27,9 +27,9 @@ extern "C"
std::string GMSH_NearToFarFieldPlugin::getHelp() const std::string GMSH_NearToFarFieldPlugin::getHelp() const
{ {
return "Plugin(NearToFarField) computes the far field pattern " return "Plugin(NearToFarField) computes the far field pattern "
"from the near electric and magnetic fields on a surface (regular grid) " "from the near electric and magnetic fields on a surface "
"enclosing the radiating device (antenna).\n\n" "enclosing the radiating device (antenna).\n\n"
"Parameters: the wavenumber, the far field distance (radious) and " "Parameters: the wavenumber, the far field distance (radius) and "
"angular discretisation, i.e. the number of divisions for " "angular discretisation, i.e. the number of divisions for "
"phi in [0, 2*Pi] and theta in [0, Pi].\n\n" "phi in [0, 2*Pi] and theta in [0, Pi].\n\n"
"If `View' < 0, the plugin is run on the current view.\n\n" "If `View' < 0, the plugin is run on the current view.\n\n"
...@@ -46,12 +46,12 @@ StringXNumber *GMSH_NearToFarFieldPlugin::getOption(int iopt) ...@@ -46,12 +46,12 @@ StringXNumber *GMSH_NearToFarFieldPlugin::getOption(int iopt)
return &NearToFarFieldOptions_Number[iopt]; return &NearToFarFieldOptions_Number[iopt];
} }
double GMSH_NearToFarFieldPlugin::getFarField(std::vector<element*> allElems, double GMSH_NearToFarFieldPlugin::getFarField(std::vector<element*> allElems,
std::vector<std::vector<double> > js, std::vector<std::vector<double> > ms, std::vector<std::vector<double> > js,
double k0, double r_far, double theta, double phi) std::vector<std::vector<double> > ms,
double k0, double r_far, double theta,
double phi)
{ {
// theta in [0, pi] (elevation/polar angle) // theta in [0, pi] (elevation/polar angle)
// phi in [0, 2*pi] (azimuthal angle) // phi in [0, 2*pi] (azimuthal angle)
...@@ -79,7 +79,8 @@ double GMSH_NearToFarFieldPlugin::getFarField(std::vector<element*> allElems, ...@@ -79,7 +79,8 @@ double GMSH_NearToFarFieldPlugin::getFarField(std::vector<element*> allElems,
element* e = allElems[ele] ; element* e = allElems[ele] ;
int numNodes = e->getNumNodes() ; int numNodes = e->getNumNodes() ;
std::vector<double > valN0(numNodes*numComps),valN1(numNodes*numComps), valL0(numNodes*numComps), valL1(numNodes*numComps) ; std::vector<double > valN0(numNodes*numComps), valN1(numNodes*numComps);
std::vector<double > valL0(numNodes*numComps), valL1(numNodes*numComps) ;
for(int nod = 0; nod < numNodes; nod++){ for(int nod = 0; nod < numNodes; nod++){
double x, y, z; double x, y, z;
...@@ -89,7 +90,7 @@ double GMSH_NearToFarFieldPlugin::getFarField(std::vector<element*> allElems, ...@@ -89,7 +90,7 @@ double GMSH_NearToFarFieldPlugin::getFarField(std::vector<element*> allElems,
double e_jk0rr[2] = {cos(k0*rr), sin(k0*rr)} ; double e_jk0rr[2] = {cos(k0*rr), sin(k0*rr)} ;
for(int comp = 0; comp < numComps; comp++){ for(int comp = 0; comp < numComps; comp++){
if(i < js[0].size()){ if(i < (int)js[0].size()){
valN0[numComps * nod + comp] = js[0][i] * e_jk0rr[0] - js[1][i] * e_jk0rr[1]; valN0[numComps * nod + comp] = js[0][i] * e_jk0rr[0] - js[1][i] * e_jk0rr[1];
valN1[numComps * nod + comp] = js[0][i] * e_jk0rr[1] + js[1][i] * e_jk0rr[0]; valN1[numComps * nod + comp] = js[0][i] * e_jk0rr[1] + js[1][i] * e_jk0rr[0];
valL0[numComps * nod + comp] = ms[0][i] * e_jk0rr[0] - ms[1][i] * e_jk0rr[1]; valL0[numComps * nod + comp] = ms[0][i] * e_jk0rr[0] - ms[1][i] * e_jk0rr[1];
...@@ -137,12 +138,12 @@ double GMSH_NearToFarFieldPlugin::getFarField(std::vector<element*> allElems, ...@@ -137,12 +138,12 @@ double GMSH_NearToFarFieldPlugin::getFarField(std::vector<element*> allElems,
E_phi[1] = k0_over_4pir * ( (Ls[0][1] - Z0 * Ns[0][2]) * cos_k0r + E_phi[1] = k0_over_4pir * ( (Ls[0][1] - Z0 * Ns[0][2]) * cos_k0r +
(Ls[1][1] - Z0 * Ns[1][2]) * sin_k0r ) ; (Ls[1][1] - Z0 * Ns[1][2]) * sin_k0r ) ;
double farF = 1./2./Z0 * ( (E_theta[0]*E_theta[0] + E_theta[1]*E_theta[1]) + (E_phi[0]*E_phi[0]+E_phi[1] *E_phi[1]) ) ; double farF = 1./2./Z0 * ( (E_theta[0]*E_theta[0] + E_theta[1]*E_theta[1]) +
(E_phi[0]*E_phi[0]+E_phi[1] *E_phi[1]) ) ;
return farF ; return farF ;
} }
PView *GMSH_NearToFarFieldPlugin::execute(PView * v) PView *GMSH_NearToFarFieldPlugin::execute(PView * v)
{ {
double _k0 = (double)NearToFarFieldOptions_Number[0].def; double _k0 = (double)NearToFarFieldOptions_Number[0].def;
...@@ -179,7 +180,7 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v) ...@@ -179,7 +180,7 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v)
return v; return v;
} }
// Center of the Far Field sphere // center of the Far Field sphere
double x0 = eData->getBoundingBox().center().x(); double x0 = eData->getBoundingBox().center().x();
double y0 = eData->getBoundingBox().center().y(); double y0 = eData->getBoundingBox().center().y();
double z0 = eData->getBoundingBox().center().z(); double z0 = eData->getBoundingBox().center().z();
...@@ -190,10 +191,7 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v) ...@@ -190,10 +191,7 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v)
return v; return v;
} }
// View for far field: represented on a sphere of radious determined by the size of the BoundingBox // compute surface currents on all input elements
PView *vf = new PView();
PViewDataList *dataFar = getDataList(vf);
std::vector<element*> allElems ; std::vector<element*> allElems ;
std::vector<std::vector<double> > js ; std::vector<std::vector<double> > js ;
std::vector<std::vector<double> > ms ; std::vector<std::vector<double> > ms ;
...@@ -208,8 +206,8 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v) ...@@ -208,8 +206,8 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v)
if(hData->skipElement(0, ent, ele)) continue; if(hData->skipElement(0, ent, ele)) continue;
int numComp = eData->getNumComponents(0, ent, ele); int numComp = eData->getNumComponents(0, ent, ele);
if(numComp != 3) continue ; if(numComp != 3) continue ;
int dim = eData->getDimension(0, ent, ele); int dim = eData->getDimension(0, ent, ele);
if(dim != 1 && dim != 2) continue;
int numNodes = eData->getNumNodes(0, ent, ele); int numNodes = eData->getNumNodes(0, ent, ele);
std::vector<double> x(numNodes), y(numNodes), z(numNodes); std::vector<double> x(numNodes), y(numNodes), z(numNodes);
for(int nod = 0; nod < numNodes; nod++) for(int nod = 0; nod < numNodes; nod++)
...@@ -242,9 +240,15 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v) ...@@ -242,9 +240,15 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v)
} }
} }
// ------------------------------------------------------------- if(allElems.empty()){
// Generating radiation pattern Msg::Error("No valid elements found to compute far field");
// ------------------------------------------------------------- return v;
}
// View for far field that will contain the radiation pattern
PView *vf = new PView();
PViewDataList *dataFar = getDataList(vf);
double phi, dPhi = 2*M_PI/_NbPhi ; double phi, dPhi = 2*M_PI/_NbPhi ;
double theta, dTheta = M_PI/_NbThe ; double theta, dTheta = M_PI/_NbThe ;
double ffmax = 0.0 ; double ffmax = 0.0 ;
...@@ -268,9 +272,7 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v) ...@@ -268,9 +272,7 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v)
theta = j * dTheta ; theta = j * dTheta ;
allPhi[i][j] = phi ; allPhi[i][j] = phi ;
allThe[i][j] = theta ; allThe[i][j] = theta ;
farF[i][j] = getFarField(allElems, js, ms, _k0, _r_far, theta, phi) ; farF[i][j] = getFarField(allElems, js, ms, _k0, _r_far, theta, phi) ;
ffmax = (ffmax < farF[i][j]) ? farF[i][j] : ffmax ; ffmax = (ffmax < farF[i][j]) ? farF[i][j] : ffmax ;
} }
} }
...@@ -284,8 +286,8 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v) ...@@ -284,8 +286,8 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v)
Msg::Warning("Far field pattern not normalized, max value = %g", ffmax); Msg::Warning("Far field pattern not normalized, max value = %g", ffmax);
} }
// Constructing sphere for visualization // construct sphere for visualization, centered at center of bb and with
// centered at center of bb and with radious relative to the bb size // radius relative to the bb size
double r_bb[3] = {eData->getBoundingBox().max().x()-eData->getBoundingBox().min().x(), double r_bb[3] = {eData->getBoundingBox().max().x()-eData->getBoundingBox().min().x(),
eData->getBoundingBox().max().y()-eData->getBoundingBox().min().y(), eData->getBoundingBox().max().y()-eData->getBoundingBox().min().y(),
eData->getBoundingBox().max().z()-eData->getBoundingBox().min().z()}; eData->getBoundingBox().max().z()-eData->getBoundingBox().min().z()};
...@@ -307,9 +309,12 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v) ...@@ -307,9 +309,12 @@ PView *GMSH_NearToFarFieldPlugin::execute(PView * v)
y0 + r_sph * farF[i ][j+1] * sin(allThe[i ][j+1]) * sin(allPhi[i ][j+1]), y0 + r_sph * farF[i ][j+1] * sin(allThe[i ][j+1]) * sin(allPhi[i ][j+1]),
z0 + r_sph * farF[i ][j+1] * cos(allThe[i ][j+1]) } ; z0 + r_sph * farF[i ][j+1] * cos(allThe[i ][j+1]) } ;
dataFar->SQ.push_back(P1[0]); dataFar->SQ.push_back(P2[0]); dataFar->SQ.push_back(P3[0]); dataFar->SQ.push_back(P4[0]); dataFar->SQ.push_back(P1[0]); dataFar->SQ.push_back(P2[0]);
dataFar->SQ.push_back(P1[1]); dataFar->SQ.push_back(P2[1]); dataFar->SQ.push_back(P3[1]); dataFar->SQ.push_back(P4[1]); dataFar->SQ.push_back(P3[0]); dataFar->SQ.push_back(P4[0]);
dataFar->SQ.push_back(P1[2]); dataFar->SQ.push_back(P2[2]); dataFar->SQ.push_back(P3[2]); dataFar->SQ.push_back(P4[2]); dataFar->SQ.push_back(P1[1]); dataFar->SQ.push_back(P2[1]);
dataFar->SQ.push_back(P3[1]); dataFar->SQ.push_back(P4[1]);
dataFar->SQ.push_back(P1[2]); dataFar->SQ.push_back(P2[2]);
dataFar->SQ.push_back(P3[2]); dataFar->SQ.push_back(P4[2]);
(dataFar->NbSQ)++; (dataFar->NbSQ)++;
if(!_dB){ if(!_dB){
dataFar->SQ.push_back(farF[i ][j ]); dataFar->SQ.push_back(farF[i ][j ]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment