123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #include <iostream>
- #include <fstream>
-
- #include "dipolesource.h"
- #include "layeredearth.h"
- #include "receiverpoints.h"
- #include "emearth1d.h"
- #include "WireAntenna.h"
- #include "PolygonalWireAntenna.h"
-
- #if LEMMAUSEVTK
- #include "vtkRenderer.h"
- #include "vtkRenderWindow.h"
- #include "vtkRenderWindowInteractor.h"
- #include "vtkRenderLargeImage.h"
- #include "vtkPNGWriter.h"
- #endif
-
-
-
-
- #include "timer.h"
-
- using namespace Lemma;
-
- double randDouble(double low, double high) {
-
- double temp;
-
- if (low > high) {
- temp = low;
- low = high;
- high = temp;
- }
-
- temp = (rand() / (static_cast<double>(RAND_MAX) + 1.0))
- * (high - low) + low;
- return temp;
- }
-
-
- int main() {
-
-
- jsw_timer timer;
-
-
- srand(time(0));
-
- PolygonalWireAntenna *pa = PolygonalWireAntenna::New();
- pa->SetNumberOfFrequencies(1);
- pa->SetFrequency(0, 1000);
- pa->SetNumberOfPoints(5);
- pa->SetPoint(0, Vector3r( 0, 0, -.001));
- pa->SetPoint(1, Vector3r( 100, 0, -.001));
- pa->SetPoint(2, Vector3r( 100, 100, -.001));
- pa->SetPoint(3, Vector3r( 0, 100, -.001));
- pa->SetPoint(4, Vector3r( 0, 0, -.001));
- pa->SetCurrent(1.);
- pa->SetNumberOfTurns(1);
-
-
-
-
-
-
-
-
-
- WireAntenna *wire = WireAntenna::New();
- wire->SetNumberOfPoints(5);
- wire->SetPoint(0, Vector3r( 0, 0, -1e-3));
- wire->SetPoint(1, Vector3r( 10, 0, -1e-3));
- wire->SetPoint(2, Vector3r( 10, 10, -1e-3));
- wire->SetPoint(3, Vector3r( 0, 10, -1e-3));
- wire->SetPoint(4, Vector3r( 0, 0, -1e-3));
-
-
- wire->SetCurrent(1.);
- wire->SetNumberOfFrequencies(1);
- wire->SetFrequency(0, 1000);
- wire->SetNumberOfTurns(1);
-
-
-
- VectorXcr sigma(2);
- sigma << Complex(0.,0), Complex(.1,0);
- VectorXr thick(1);
- thick << 10;
- LayeredEarthEM *earth = LayeredEarthEM::New();
- earth->SetNumberOfLayers(2);
- earth->SetLayerConductivity(sigma);
-
-
-
- ReceiverPoints *receivers = ReceiverPoints::New();
- Vector3r loc;
- Real ox = 50.561 ;
- Real oy = 105.235 ;
- Real depth = -3.75e1;
- Real depth2 = depth;
- Real dx = 1.;
- int nz = 1;
- receivers->SetNumberOfReceivers(nz);
- int ir = 0;
- for (int iz=0; iz<nz; ++iz) {
- loc << ox, oy, depth;
- receivers->SetLocation(ir, loc);
- depth += dx;
- ++ ir;
- }
-
-
- EMEarth1D *EmEarth = EMEarth1D::New();
-
- EmEarth->AttachWireAntenna(pa);
- EmEarth->AttachLayeredEarthEM(earth);
- EmEarth->AttachReceiverPoints(receivers);
- EmEarth->SetFieldsToCalculate(H);
-
-
-
- timer.begin();
- EmEarth->CalculateWireAntennaFields();
- Real paTime = timer.end();
- std::cout << "Polygonal wire antennae time: " << paTime << "\n";
-
-
-
-
-
-
-
- depth = depth2;
- std::fstream real("reale_lay.dat", std::ios::out);
- std::fstream imag("image_lay.dat", std::ios::out);
- std::fstream hreal("real_lay.dat", std::ios::out);
- std::fstream himag("imag_lay.dat", std::ios::out);
- for (int iz=0; iz<nz; ++iz) {
- Vector3cr temp = receivers->GetEfield(0,iz);
- real << ox << "\t" << oy << "\t" << depth << "\t"
- << temp(0).real() << "\t" << temp(1).real()
- << "\t" << temp(2).real() << std::endl;
- imag << ox << "\t" << oy << "\t" << depth << "\t"
- << std::imag(temp(0)) << "\t" << std::imag(temp(1))
- << "\t" << std::imag(temp(2)) << std::endl;
- temp = receivers->GetHfield(0, iz);
- hreal << ox << "\t" << oy << "\t" << depth << "\t"
- << std::real(temp(0)) << "\t" << std::real(temp(1))
- << "\t" << std::real(temp(2)) << std::endl;
- himag << ox << "\t" << oy << "\t" << depth << "\t"
- << std::imag(temp(0)) << "\t" << std::imag(temp(1))
- << "\t" << std::imag(temp(2)) << std::endl;
- depth += dx;
- }
- real.close();
- imag.close();
- hreal.close();
- himag.close();
- EmEarth->Delete();
- receivers->Delete();
- earth->Delete();
-
-
- #if LEMMAUSEVTK
-
- vtkRenderer *renderer = vtkRenderer::New();
- vtkRenderWindow *renWin = vtkRenderWindow::New();
- vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
-
-
- vtkLineSource *vline = vtkLineSource::New();
- vtkTubeFilter *vTube = vtkTubeFilter::New();
- vtkPolyDataMapper *vMapper = vtkPolyDataMapper::New();
- vtkActor *vActor = vtkActor::New();
- vline->SetPoint1(0,0,0);
- vline->SetPoint2(10,0,0);
-
- vTube->SetInputConnection(vline->GetOutputPort());
- vTube->SetRadius(.2);
- vTube->SetNumberOfSides(6);
- vMapper->SetInputConnection(vTube->GetOutputPort());
- vActor->SetMapper(vMapper);
- vActor->GetProperty()->SetColor(0.0, .0, 1.0);
- vActor->GetProperty()->SetOpacity(.15);
- renderer->AddActor(vActor);
-
- vtkLineSource *vline2 = vtkLineSource::New();
- vtkTubeFilter *vTube2 = vtkTubeFilter::New();
- vtkPolyDataMapper *vMapper2 = vtkPolyDataMapper::New();
- vtkActor *vActor2 = vtkActor::New();
- vline2->SetPoint1(10,0,0);
- vline2->SetPoint2(10,10,0);
-
- vTube2->SetInputConnection(vline2->GetOutputPort());
- vTube2->SetRadius(.2);
- vTube2->SetNumberOfSides(6);
- vMapper2->SetInputConnection(vTube2->GetOutputPort());
- vActor2->SetMapper(vMapper2);
- vActor2->GetProperty()->SetColor(0.0, .0, 1.0);
- vActor2->GetProperty()->SetOpacity(.15);
- renderer->AddActor(vActor2);
-
- vtkLineSource *vline3 = vtkLineSource::New();
- vtkTubeFilter *vTube3 = vtkTubeFilter::New();
- vtkPolyDataMapper *vMapper3 = vtkPolyDataMapper::New();
- vtkActor *vActor3 = vtkActor::New();
- vline3->SetPoint1(10,10,0);
- vline3->SetPoint2(0,10,0);
-
- vTube3->SetInputConnection(vline3->GetOutputPort());
- vTube3->SetRadius(.2);
- vTube3->SetNumberOfSides(6);
- vMapper3->SetInputConnection(vTube3->GetOutputPort());
- vActor3->SetMapper(vMapper3);
- vActor3->GetProperty()->SetColor(0.0, .0, 1.0);
- vActor3->GetProperty()->SetOpacity(.15);
- renderer->AddActor(vActor3);
-
- vtkLineSource *vline4 = vtkLineSource::New();
- vtkTubeFilter *vTube4 = vtkTubeFilter::New();
- vtkPolyDataMapper *vMapper4 = vtkPolyDataMapper::New();
- vtkActor *vActor4 = vtkActor::New();
- vline4->SetPoint1(0,10,0);
- vline4->SetPoint2(0,0,0);
-
- vTube4->SetInputConnection(vline4->GetOutputPort());
- vTube4->SetRadius(.2);
- vTube4->SetNumberOfSides(6);
- vMapper4->SetInputConnection(vTube4->GetOutputPort());
- vActor4->SetMapper(vMapper4);
- vActor4->GetProperty()->SetColor(0.0, .0, 1.0);
- vActor4->GetProperty()->SetOpacity(.15);
- renderer->AddActor(vActor4);
-
- loc << 50, 50, -1e-3;
- pa->ApproximateWithElectricDipoles(loc);
-
- vtkActor **pdipActors = new vtkActor*[pa->GetNumberOfDipoles()];
- std::cout << "Wire approximated with " << pa->GetNumberOfDipoles() << std::endl;
- for (int id=0; id<pa->GetNumberOfDipoles(); ++id) {
- pdipActors[id] = pa->GetVtkActor(id);
- renderer->AddActor(pdipActors[id]);
- }
-
-
-
-
- renderer->SetBackground(1,1,1);
-
-
- renWin->AddRenderer(renderer);
- renWin->SetWindowName("Wire antennae");
-
- iren->SetRenderWindow(renWin);
- iren->Initialize();
- iren->Start();
- iren->Render();
-
- #if 0
- cout << "Enter File name?: ";
- std::string pngName;
- std::cin >> pngName;
- vtkPNGWriter *pngwrite = vtkPNGWriter::New();
- vtkRenderLargeImage *renlarge = vtkRenderLargeImage::New();
- renlarge->SetInput(renderer);
- renlarge->SetMagnification(2);
- pngwrite->SetInputConnection(renlarge->GetOutputPort());
- pngName.append(".png");
- pngwrite->SetFileName(pngName.c_str());
- pngwrite->Write();
- #endif
-
- #endif
-
-
-
-
-
- return 0;
- }
|