Beispiel #1
0
void Operator::CalcPEC_Range(unsigned int startX, unsigned int stopX, unsigned int* counter)
{
	double coord[3];
	unsigned int pos[3];
	for (pos[0]=startX; pos[0]<=stopX; ++pos[0])
	{
		for (pos[1]=0; pos[1]<numLines[1]; ++pos[1])
		{
			for (pos[2]=0; pos[2]<numLines[2]; ++pos[2])
			{
				for (int n=0; n<3; ++n)
				{
					GetYeeCoords(n,pos,coord,false);
					CSProperties* prop = CSX->GetPropertyByCoordPriority(coord, (CSProperties::PropertyType)(CSProperties::MATERIAL | CSProperties::METAL), true);
					if (prop)
					{
						if (prop->GetType()==CSProperties::METAL) //set to PEC
						{
							SetVV(n,pos[0],pos[1],pos[2], 0 );
							SetVI(n,pos[0],pos[1],pos[2], 0 );
							++counter[n];
						}
					}
				}
			}
		}
	}
}
Beispiel #2
0
void Operator::CalcPEC_Curves()
{
	//special treatment for primitives of type curve (treated as wires)
	double p1[3];
	double p2[3];
	struct Grid_Path path;
	vector<CSProperties*> vec_prop = CSX->GetPropertyByType(CSProperties::METAL);
	for (size_t p=0; p<vec_prop.size(); ++p)
	{
		CSProperties* prop = vec_prop.at(p);
		for (size_t n=0; n<prop->GetQtyPrimitives(); ++n)
		{
			CSPrimitives* prim = prop->GetPrimitive(n);
			CSPrimCurve* curv = prim->ToCurve();
			if (curv)
			{
				for (size_t i=1; i<curv->GetNumberOfPoints(); ++i)
				{
					curv->GetPoint(i-1,p1);
					curv->GetPoint(i,p2);
					path = FindPath(p1,p2);
					if (path.dir.size()>0)
						prim->SetPrimitiveUsed(true);
					for (size_t t=0; t<path.dir.size(); ++t)
					{
						SetVV(path.dir.at(t),path.posPath[0].at(t),path.posPath[1].at(t),path.posPath[2].at(t), 0 );
						SetVI(path.dir.at(t),path.posPath[0].at(t),path.posPath[1].at(t),path.posPath[2].at(t), 0 );
						++m_Nr_PEC[path.dir.at(t)];
					}
				}
			}
		}
	}
}
Beispiel #3
0
void QCSXCAD::Delete()
{
	CSPrimitives* prim = CSTree->GetCurrentPrimitive();
	if (prim!=NULL)
	{
		if (QMessageBox::question(this,tr("Delete Primitive"),tr("Delete current Primitive (ID: %1)?").arg(prim->GetID()),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes)
		{
			CSTree->DeletePrimItem(prim);
			DeletePrimitive(prim);
			setModified();
		}
		return;
	}
	CSProperties* prop = CSTree->GetCurrentProperty();
	if (prop!=NULL)
	{
		size_t qtyPrim=prop->GetQtyPrimitives();
		if (qtyPrim>0)
		{
			if (QMessageBox::question(this,tr("Delete Property"),tr("\"%1\" contains Primitive(s)!!\n Delete anyway?").arg(prop->GetName().c_str()),QMessageBox::Yes,QMessageBox::No)!=QMessageBox::Yes)
				return;
		}
		else if (QMessageBox::question(this,tr("Delete Property"),tr("Delete current Property?"),QMessageBox::Yes,QMessageBox::No)!=QMessageBox::Yes)
			return;
		CSTree->DeletePropItem(prop);
		DeleteProperty(prop);
		setModified();
	}
}
bool Operator_Ext_Cylinder::BuildExtension()
{
	delete[] vv_R0;
	vv_R0=NULL;
	delete[] vi_R0;
	vi_R0=NULL;

	//if r=0 is not included -> obviously no special treatment for r=0
	//if alpha direction is not closed, PEC-BC at r=0 necessary and already set...
	if (CC_R0_included==false)
		return true;

	vv_R0 = new FDTD_FLOAT[m_Op->GetNumberOfLines(2,true)];
	vi_R0 = new FDTD_FLOAT[m_Op->GetNumberOfLines(2,true)];

	unsigned int pos[3];
	double coord[3];
	double inEC[4];
	double dT = m_Op->GetTimestep();
	pos[0]=0;
	vector<CSPrimitives*> vPrims_metal = m_Op->GetPrimitivesBoundBox(pos[0], -1, -1, (CSProperties::PropertyType)(CSProperties::MATERIAL | CSProperties::METAL));
	for (pos[2]=0; pos[2]<m_Op->GetNumberOfLines(2,true); ++pos[2])
	{
		double C=0;
		double G=0;
		vector<CSPrimitives*> vPrims_mat   = m_Op->GetPrimitivesBoundBox(pos[0], -1, pos[2], CSProperties::MATERIAL);
		for (pos[1]=0; pos[1]<m_Op->GetNumberOfLines(1,true)-2; ++pos[1])
		{
			m_Op_Cyl->Calc_ECPos(2,pos,inEC,vPrims_mat);
			C+=inEC[0];
			G+=inEC[1];
		}
		m_Op->SetVV(2,0,0,pos[2], 1);
		vv_R0[pos[2]] = (1-dT*G/2/C)/(1+dT*G/2/C);
		vi_R0[pos[2]] = (dT/C)/(1+dT*G/2/C);

		for (unsigned int i=0; i<m_Op->GetNumberOfLines(1,true); ++i)
		{
			m_Op->EC_C[2][m_Op->MainOp->SetPos(0,i,pos[2])] = C;
			m_Op->EC_G[2][m_Op->MainOp->SetPos(0,i,pos[2])] = G;
		}

		//search for metal on z-axis
		m_Op_Cyl->GetYeeCoords(2,pos,coord,false);
		CSProperties* prop = m_Op->CSX->GetPropertyByCoordPriority(coord, vPrims_metal, true);
		if (prop)
		{
			if (prop->GetType()==CSProperties::METAL) //set to PEC
			{
				m_Op->SetVV(2,0,0,pos[2], 0);
				vv_R0[pos[2]] = 0;
				vi_R0[pos[2]] = 0;
				m_Op->EC_C[2][m_Op->MainOp->SetPos(0,0,pos[2])] = 0;
				m_Op->EC_G[2][m_Op->MainOp->SetPos(0,0,pos[2])] = 0;
			}
		}
	}
	return true;
}
Beispiel #5
0
void QCSXCAD::SetVisibility2All(bool value)
{
	for (size_t n=0; n<vProperties.size();++n)
	{
		CSProperties* prop = vProperties.at(n);
		prop->SetVisibility(value);
		CSTree->RefreshItem(GetIndex(prop));
		if (value) StructureVTK->SetPropOpacity(prop->GetUniqueID(),prop->GetFillColor().a);
		else StructureVTK->SetPropOpacity(prop->GetUniqueID(),0);
	}
}
Beispiel #6
0
void QCSXCAD::ShowHide()
{
	CSProperties* prop = CSTree->GetCurrentProperty();
	if (prop!=NULL)
	{
		prop->SetVisibility(!prop->GetVisibility());
		CSTree->RefreshItem(GetIndex(prop));
		if (prop->GetVisibility()) StructureVTK->SetPropOpacity(prop->GetUniqueID(),prop->GetFillColor().a);
		else StructureVTK->SetPropOpacity(prop->GetUniqueID(),0);
	}
}
Beispiel #7
0
void QCSXCAD::ExportGeometry(QString dirname, int type)
{
	if (dirname.isEmpty())
		dirname = QFileDialog::getExistingDirectory(this, tr("Choose directory to save data"));
	if (dirname.isEmpty())
		return;
	int QtyProp = GetQtyProperties();
	for (int i=0;i<QtyProp;++i)
	{
		CSProperties* prop = GetProperty(i);
		if (prop==NULL) continue;

		 unsigned int uID = prop->GetUniqueID();

		 if (prop->GetVisibility()==true)
		 {
			QString filename(dirname);
			filename.append("/");
			filename.append(QString::fromUtf8(prop->GetName().c_str()));
			switch (type)
			{
			case 0:
				StructureVTK->ExportProperty2PolyDataVTK(uID,filename,clGrid.GetDeltaUnit());
				break;
			case 1:
				StructureVTK->ExportProperty2STL(uID,filename,clGrid.GetDeltaUnit());
				break;
			case 2:
				StructureVTK->ExportProperty2PLY(uID,filename,clGrid.GetDeltaUnit());
				break;
			default:
				QMessageBox::warning(this, "Export Dialog","Unkown export type, skipping...");
				return;
				break;
			}
		 }
	 }
}
Beispiel #8
0
bool Operator_Ext_Mur_ABC::BuildExtension()
{
	if (m_ny<0)
	{
		cerr << "Operator_Ext_Mur_ABC::BuildExtension: Warning, Extension not initialized! Use SetDirection!! Abort build!!" << endl;
		return false;
	}
	double dT = m_Op->GetTimestep();
	unsigned int pos[] = {0,0,0};
	pos[m_ny] = m_LineNr;
	double delta = fabs(m_Op->GetEdgeLength(m_ny,pos));
	double coord[] = {0,0,0};
	coord[0] = m_Op->GetDiscLine(0,pos[0]);
	coord[1] = m_Op->GetDiscLine(1,pos[1]);
	coord[2] = m_Op->GetDiscLine(2,pos[2]);

	double eps,mue;
	double c0t;

	if (m_LineNr==0)
		coord[m_ny] = m_Op->GetDiscLine(m_ny,pos[m_ny]) + delta/2 / m_Op->GetGridDelta();
	else
		coord[m_ny] = m_Op->GetDiscLine(m_ny,pos[m_ny]) - delta/2 / m_Op->GetGridDelta();

	for (pos[m_nyP]=0; pos[m_nyP]<m_numLines[0]; ++pos[m_nyP])
	{
		coord[m_nyP] = m_Op->GetDiscLine(m_nyP,pos[m_nyP]);
		for (pos[m_nyPP]=0; pos[m_nyPP]<m_numLines[1]; ++pos[m_nyPP])
		{
			coord[m_nyPP] = m_Op->GetDiscLine(m_nyPP,pos[m_nyPP]);
			CSProperties* prop = m_Op->GetGeometryCSX()->GetPropertyByCoordPriority(coord, CSProperties::MATERIAL, false);
			if (prop)
			{
				CSPropMaterial* mat = prop->ToMaterial();

				//nP
				eps = mat->GetEpsilonWeighted(m_nyP,coord);
				mue = mat->GetMueWeighted(m_nyP,coord);
				if (m_v_phase>0.0)
					c0t = m_v_phase * dT;
				else
					c0t = __C0__ * dT / sqrt(eps*mue);
				m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] = (c0t - delta) / (c0t + delta);

				//nPP
				eps = mat->GetEpsilonWeighted(m_nyPP,coord);
				mue = mat->GetMueWeighted(m_nyPP,coord);
				if (m_v_phase>0.0)
					c0t = m_v_phase * dT;
				else
					c0t = __C0__ * dT / sqrt(eps*mue);
				m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] = (c0t - delta) / (c0t + delta);

			}
			else
			{
				if (m_v_phase>0.0)
					c0t = m_v_phase * dT;
				else
					c0t = __C0__ * dT;
				m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] = (c0t - delta) / (c0t + delta);
				m_Mur_Coeff_nyPP[pos[m_nyP]][pos[m_nyPP]] = m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]];
			}
//			cerr << m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] << " : " << m_Mur_Coeff_nyP[pos[m_nyP]][pos[m_nyPP]] << endl;
		}
	}
//	cerr << "Operator_Ext_Mur_ABC::BuildExtension(): " << m_ny << " @ " << m_LineNr << endl;
	return true;
}