Skip to content

Commit

Permalink
Add manual specialization of start and end save coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
zer011b committed Oct 6, 2017
1 parent ad7bb14 commit 2a180f6
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 80 deletions.
280 changes: 219 additions & 61 deletions Source/Scheme/Scheme3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,6 @@ Scheme3D::Scheme3D (YeeGridLayout *layout,
{
palette = PaletteType::PALETTE_BLUE_GREEN_RED;
}
else
{
UNREACHABLE;
}

if (solverSettings.getDoUseOrthAxisX ())
{
Expand All @@ -288,10 +284,6 @@ Scheme3D::Scheme3D (YeeGridLayout *layout,
{
orthogonalAxis = OrthogonalAxis::Z;
}
else
{
UNREACHABLE;
}

dumper[FILE_TYPE_BMP] = new BMPDumper<GridCoordinate3D> ();
((BMPDumper<GridCoordinate3D> *) dumper[FILE_TYPE_BMP])->initializeHelper (palette, orthogonalAxis);
Expand Down Expand Up @@ -3395,35 +3387,35 @@ Scheme3D::initGrids ()
{
dumper[type]->init (0, CURRENT, processId, "Eps");
dumper[type]->dumpGrid (totalEps,
GridCoordinate3D (0, 0, totalEps->getSize ().getZ () / 2),
GridCoordinate3D (totalEps->getSize ().getX (), totalEps->getSize ().getY (), totalEps->getSize ().getZ () / 2 + 1));
getStartCoord (GridType::EPS, totalEps->getSize ()),
getEndCoord (GridType::EPS, totalEps->getSize ()));

dumper[type]->init (0, CURRENT, processId, "Mu");
dumper[type]->dumpGrid (totalMu,
GridCoordinate3D (0, 0, totalMu->getSize ().getZ () / 2),
GridCoordinate3D (totalMu->getSize ().getX (), totalMu->getSize ().getY (), totalMu->getSize ().getZ () / 2 + 1));
getStartCoord (GridType::MU, totalMu->getSize ()),
getEndCoord (GridType::MU, totalMu->getSize ()));

if (solverSettings.getDoUseMetamaterials ())
{
dumper[type]->init (0, CURRENT, processId, "OmegaPE");
dumper[type]->dumpGrid (totalOmegaPE,
GridCoordinate3D (0, 0, totalOmegaPE->getSize ().getZ () / 2),
GridCoordinate3D (totalOmegaPE->getSize ().getX (), totalOmegaPE->getSize ().getY (), totalOmegaPE->getSize ().getZ () / 2 + 1));
getStartCoord (GridType::OMEGAPE, totalOmegaPE->getSize ()),
getEndCoord (GridType::OMEGAPE, totalOmegaPE->getSize ()));

dumper[type]->init (0, CURRENT, processId, "OmegaPM");
dumper[type]->dumpGrid (totalOmegaPM,
GridCoordinate3D (0, 0, totalOmegaPM->getSize ().getZ () / 2),
GridCoordinate3D (totalOmegaPM->getSize ().getX (), totalOmegaPM->getSize ().getY (), totalOmegaPM->getSize ().getZ () / 2 + 1));
getStartCoord (GridType::OMEGAPM, totalOmegaPM->getSize ()),
getEndCoord (GridType::OMEGAPM, totalOmegaPM->getSize ()));

dumper[type]->init (0, CURRENT, processId, "GammaE");
dumper[type]->dumpGrid (totalGammaE,
GridCoordinate3D (0, 0, totalGammaE->getSize ().getZ () / 2),
GridCoordinate3D (totalGammaE->getSize ().getX (), totalGammaE->getSize ().getY (), totalGammaE->getSize ().getZ () / 2 + 1));
getStartCoord (GridType::GAMMAE, totalGammaE->getSize ()),
getEndCoord (GridType::GAMMAE, totalGammaE->getSize ()));

dumper[type]->init (0, CURRENT, processId, "GammaM");
dumper[type]->dumpGrid (totalGammaM,
GridCoordinate3D (0, 0, totalGammaM->getSize ().getZ () / 2),
GridCoordinate3D (totalGammaM->getSize ().getX (), totalGammaM->getSize ().getY (), totalGammaM->getSize ().getZ () / 2 + 1));
getStartCoord (GridType::GAMMAM, totalGammaM->getSize ()),
getEndCoord (GridType::GAMMAM, totalGammaM->getSize ()));
}
//
// if (solverSettings.getDoUsePML ())
Expand Down Expand Up @@ -4179,47 +4171,51 @@ Scheme3D::saveGrids (time_step t)
{
int processId = 0;

GridCoordinate3D startEx (grid_coord (yeeLayout->getLeftBorderPML ().getX () - yeeLayout->getMinExCoordFP ().getX ()) + 1,
grid_coord (yeeLayout->getLeftBorderPML ().getY () - yeeLayout->getMinExCoordFP ().getY ()) + 1,
Ex->getSize ().getZ () / 2);
GridCoordinate3D endEx (grid_coord (yeeLayout->getRightBorderPML ().getX () - yeeLayout->getMinExCoordFP ().getX ()),
grid_coord (yeeLayout->getRightBorderPML ().getY () - yeeLayout->getMinExCoordFP ().getY ()),
Ex->getSize ().getZ () / 2 + 1);

GridCoordinate3D startEy (grid_coord (yeeLayout->getLeftBorderPML ().getX () - yeeLayout->getMinEyCoordFP ().getX ()) + 1,
grid_coord (yeeLayout->getLeftBorderPML ().getY () - yeeLayout->getMinEyCoordFP ().getY ()) + 1,
Ey->getSize ().getZ () / 2);
GridCoordinate3D endEy (grid_coord (yeeLayout->getRightBorderPML ().getX () - yeeLayout->getMinEyCoordFP ().getX ()),
grid_coord (yeeLayout->getRightBorderPML ().getY () - yeeLayout->getMinEyCoordFP ().getY ()),
Ey->getSize ().getZ () / 2 + 1);

GridCoordinate3D startEz (grid_coord (yeeLayout->getLeftBorderPML ().getX () - yeeLayout->getMinEzCoordFP ().getX ()) + 1,
grid_coord (yeeLayout->getLeftBorderPML ().getY () - yeeLayout->getMinEzCoordFP ().getY ()) + 1,
Ez->getSize ().getZ () / 2);
GridCoordinate3D endEz (grid_coord (yeeLayout->getRightBorderPML ().getX () - yeeLayout->getMinEzCoordFP ().getX ()),
grid_coord (yeeLayout->getRightBorderPML ().getY () - yeeLayout->getMinEzCoordFP ().getY ()),
Ez->getSize ().getZ () / 2 + 1);

GridCoordinate3D startHx (grid_coord (yeeLayout->getLeftBorderPML ().getX () - yeeLayout->getMinHxCoordFP ().getX ()) + 1,
grid_coord (yeeLayout->getLeftBorderPML ().getY () - yeeLayout->getMinHxCoordFP ().getY ()) + 1,
Hx->getSize ().getZ () / 2);
GridCoordinate3D endHx (grid_coord (yeeLayout->getRightBorderPML ().getX () - yeeLayout->getMinHxCoordFP ().getX ()),
grid_coord (yeeLayout->getRightBorderPML ().getY () - yeeLayout->getMinHxCoordFP ().getY ()),
Hx->getSize ().getZ () / 2 + 1);

GridCoordinate3D startHy (grid_coord (yeeLayout->getLeftBorderPML ().getX () - yeeLayout->getMinHyCoordFP ().getX ()) + 1,
grid_coord (yeeLayout->getLeftBorderPML ().getY () - yeeLayout->getMinHyCoordFP ().getY ()) + 1,
Hy->getSize ().getZ () / 2);
GridCoordinate3D endHy (grid_coord (yeeLayout->getRightBorderPML ().getX () - yeeLayout->getMinHyCoordFP ().getX ()),
grid_coord (yeeLayout->getRightBorderPML ().getY () - yeeLayout->getMinHyCoordFP ().getY ()),
Hy->getSize ().getZ () / 2 + 1);

GridCoordinate3D startHz (grid_coord (yeeLayout->getLeftBorderPML ().getX () - yeeLayout->getMinHzCoordFP ().getX ()) + 1,
grid_coord (yeeLayout->getLeftBorderPML ().getY () - yeeLayout->getMinHzCoordFP ().getY ()) + 1,
Hz->getSize ().getZ () / 2);
GridCoordinate3D endHz (grid_coord (yeeLayout->getRightBorderPML ().getX () - yeeLayout->getMinHzCoordFP ().getX ()),
grid_coord (yeeLayout->getRightBorderPML ().getY () - yeeLayout->getMinHzCoordFP ().getY ()),
Hz->getSize ().getZ () / 2);
GridCoordinate3D startEx;
GridCoordinate3D endEx;
GridCoordinate3D startEy;
GridCoordinate3D endEy;
GridCoordinate3D startEz;
GridCoordinate3D endEz;
GridCoordinate3D startHx;
GridCoordinate3D endHx;
GridCoordinate3D startHy;
GridCoordinate3D endHy;
GridCoordinate3D startHz;
GridCoordinate3D endHz;

if (solverSettings.getDoUseManualStartEndDumpCoord ())
{
GridCoordinate3D start (solverSettings.getSaveStartCoordX (),
solverSettings.getSaveStartCoordY (),
solverSettings.getSaveStartCoordZ ());
GridCoordinate3D end (solverSettings.getSaveEndCoordX (),
solverSettings.getSaveEndCoordY (),
solverSettings.getSaveEndCoordZ ());

startEx = startEy = startEz = startHx = startHy = startHz = start;
endEx = endEy = endEz = endHx = endHy = endHz = end;
}
else
{
startEx = getStartCoord (GridType::EX, Ex->getTotalSize ());
endEx = getEndCoord (GridType::EX, Ex->getTotalSize ());

startEy = getStartCoord (GridType::EY, Ey->getTotalSize ());
endEy = getEndCoord (GridType::EY, Ey->getTotalSize ());

startEz = getStartCoord (GridType::EZ, Ez->getTotalSize ());
endEz = getEndCoord (GridType::EZ, Ez->getTotalSize ());

startHx = getStartCoord (GridType::HX, Hx->getTotalSize ());
endHx = getEndCoord (GridType::HX, Hx->getTotalSize ());

startHy = getStartCoord (GridType::HY, Hy->getTotalSize ());
endHy = getEndCoord (GridType::HY, Hy->getTotalSize ());

startHz = getStartCoord (GridType::HZ, Hz->getTotalSize ());
endHz = getEndCoord (GridType::HZ, Hz->getTotalSize ());
}

for (int type = FILE_TYPE_BMP; type < FILE_TYPE_COUNT; ++type)
{
Expand Down Expand Up @@ -4404,4 +4400,166 @@ void Scheme3D::additionalUpdateOfGrids (time_step t, time_step &diffT)
}
}

GridCoordinate3D
Scheme3D::getStartCoord (GridType gridType, GridCoordinate3D size)
{
GridCoordinate3D start (0, 0, 0);
if (solverSettings.getDoSaveWithoutPML ()
&& solverSettings.getDoUsePML ())
{
GridCoordinate3D leftBorder = yeeLayout->getLeftBorderPML ();
GridCoordinateFP3D min;

switch (gridType)
{
case GridType::EX:
{
min = yeeLayout->getMinExCoordFP ();
break;
}
case GridType::EY:
{
min = yeeLayout->getMinEyCoordFP ();
break;
}
case GridType::EZ:
{
min = yeeLayout->getMinEzCoordFP ();
break;
}
case GridType::HX:
{
min = yeeLayout->getMinHxCoordFP ();
break;
}
case GridType::HY:
{
min = yeeLayout->getMinHyCoordFP ();
break;
}
case GridType::HZ:
{
min = yeeLayout->getMinHzCoordFP ();
break;
}
default:
{
// do nothing
}
}

start.setX (grid_coord (leftBorder.getX () - min.getX ()) + 1);
start.setY (grid_coord (leftBorder.getY () - min.getY ()) + 1);
start.setZ (grid_coord (leftBorder.getZ () - min.getZ ()) + 1);
}

OrthogonalAxis orthogonalAxis = OrthogonalAxis::Z;
if (solverSettings.getDoUseOrthAxisX ())
{
orthogonalAxis = OrthogonalAxis::X;
}
else if (solverSettings.getDoUseOrthAxisY ())
{
orthogonalAxis = OrthogonalAxis::Y;
}
else if (solverSettings.getDoUseOrthAxisZ ())
{
orthogonalAxis = OrthogonalAxis::Z;
}

if (orthogonalAxis == OrthogonalAxis::Z)
{
return GridCoordinate3D (start.getX (), start.getY (), size.getZ () / 2);
}
else if (orthogonalAxis == OrthogonalAxis::Y)
{
return GridCoordinate3D (start.getX (), size.getY () / 2, start.getZ ());
}
else if (orthogonalAxis == OrthogonalAxis::X)
{
return GridCoordinate3D (size.getX () / 2, start.getY (), start.getZ ());
}
}

GridCoordinate3D
Scheme3D::getEndCoord (GridType gridType, GridCoordinate3D size)
{
GridCoordinate3D end = size;
if (solverSettings.getDoSaveWithoutPML ()
&& solverSettings.getDoUsePML ())
{
GridCoordinate3D rightBorder = yeeLayout->getRightBorderPML ();
GridCoordinateFP3D min;

switch (gridType)
{
case GridType::EX:
{
min = yeeLayout->getMinExCoordFP ();
break;
}
case GridType::EY:
{
min = yeeLayout->getMinEyCoordFP ();
break;
}
case GridType::EZ:
{
min = yeeLayout->getMinEzCoordFP ();
break;
}
case GridType::HX:
{
min = yeeLayout->getMinHxCoordFP ();
break;
}
case GridType::HY:
{
min = yeeLayout->getMinHyCoordFP ();
break;
}
case GridType::HZ:
{
min = yeeLayout->getMinHzCoordFP ();
break;
}
default:
{
// do nothing
}
}

end.setX (grid_coord (rightBorder.getX () - min.getX ()));
end.setY (grid_coord (rightBorder.getY () - min.getY ()));
end.setZ (grid_coord (rightBorder.getZ () - min.getZ ()));
}

OrthogonalAxis orthogonalAxis = OrthogonalAxis::Z;
if (solverSettings.getDoUseOrthAxisX ())
{
orthogonalAxis = OrthogonalAxis::X;
}
else if (solverSettings.getDoUseOrthAxisY ())
{
orthogonalAxis = OrthogonalAxis::Y;
}
else if (solverSettings.getDoUseOrthAxisZ ())
{
orthogonalAxis = OrthogonalAxis::Z;
}

if (orthogonalAxis == OrthogonalAxis::Z)
{
return GridCoordinate3D (end.getX (), end.getY (), size.getZ () / 2 + 1);
}
else if (orthogonalAxis == OrthogonalAxis::Y)
{
return GridCoordinate3D (end.getX (), size.getY () / 2 + 1, end.getZ ());
}
else if (orthogonalAxis == OrthogonalAxis::X)
{
return GridCoordinate3D (size.getX () / 2 + 1, end.getY (), end.getZ ());
}
}

#endif /* GRID_3D */
3 changes: 3 additions & 0 deletions Source/Scheme/Scheme3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ class Scheme3D: public Scheme

void additionalUpdateOfGrids (time_step, time_step &);

GridCoordinate3D getStartCoord (GridType, GridCoordinate3D);
GridCoordinate3D getEndCoord (GridType, GridCoordinate3D);

public:

virtual void performSteps () CXX11_OVERRIDE;
Expand Down
28 changes: 9 additions & 19 deletions Source/Settings/Settings.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ SETTINGS_ELEM_FIELD_TYPE_INT(numCudaThreadsY, getNumCudaThreadsY, int, 1, "--num
SETTINGS_ELEM_FIELD_TYPE_INT(numCudaThreadsZ, getNumCudaThreadsZ, int, 1, "--num-cuda-threads-z", "Number of GPU threads by z coordinate to use in computations")
SETTINGS_ELEM_FIELD_TYPE_NONE(doUseParallelGrid, getDoUseParallelGrid, bool, false, "--parallel-grid", "Use parallel grid (if fdtd3d is built with it)")
SETTINGS_ELEM_FIELD_TYPE_NONE(doUseManualVirtualTopology, getDoUseManualVirtualTopology, bool, false, "--manual-topology", "Use manual topology for parallel grid")
SETTINGS_ELEM_FIELD_TYPE_STRING(fileWithAvailableTopologies, getFileWithAvailableTopologies, std::string, "", "--available-topologies", "File with available topologies for current architecture")

SETTINGS_ELEM_FIELD_TYPE_INT(topologySizeX, getTopologySizeX, int, 1, "--topology-sizex", "Size by x coordinate of virtual topology")
SETTINGS_ELEM_FIELD_TYPE_INT(topologySizeY, getTopologySizeY, int, 1, "--topology-sizey", "Size by y coordinate of virtual topology")
Expand Down Expand Up @@ -136,6 +135,15 @@ SETTINGS_ELEM_FIELD_TYPE_NONE(doSaveAsTXT, getDoSaveAsTXT, bool, false, "--save-
SETTINGS_ELEM_FIELD_TYPE_NONE(doSaveTFSFEInc, getDoSaveTFSFEInc, bool, false, "--save-tfsf-e-incident", "Save TF/SF EInc")
SETTINGS_ELEM_FIELD_TYPE_NONE(doSaveTFSFHInc, getDoSaveTFSFHInc, bool, false, "--save-tfsf-h-incident", "Save TF/SF HInc")

SETTINGS_ELEM_FIELD_TYPE_NONE(doUseManualStartEndDumpCoord, getDoUseManualStartEndDumpCoord, bool, false, "--manual-save-coords", "Use manual save start and end coordinates")
SETTINGS_ELEM_FIELD_TYPE_INT(saveStartCoordX, getSaveStartCoordX, int, 0, "--save-start-coord-x", "Start x coordinate to save from")
SETTINGS_ELEM_FIELD_TYPE_INT(saveStartCoordY, getSaveStartCoordY, int, 0, "--save-start-coord-y", "Start y coordinate to save from")
SETTINGS_ELEM_FIELD_TYPE_INT(saveStartCoordZ, getSaveStartCoordZ, int, 0, "--save-start-coord-z", "Start z coordinate to save from")
SETTINGS_ELEM_FIELD_TYPE_INT(saveEndCoordX, getSaveEndCoordX, int, 0, "--save-end-coord-x", "End x coordinate to save from")
SETTINGS_ELEM_FIELD_TYPE_INT(saveEndCoordY, getSaveEndCoordY, int, 0, "--save-end-coord-y", "End y coordinate to save from")
SETTINGS_ELEM_FIELD_TYPE_INT(saveEndCoordZ, getSaveEndCoordZ, int, 0, "--save-end-coord-z", "End z coordinate to save from")
SETTINGS_ELEM_FIELD_TYPE_NONE(doSaveWithoutPML, getDoSaveWithoutPML, bool, false, "--save-no-pml", "Save without PML")

/*
* Load flags
*/
Expand Down Expand Up @@ -209,24 +217,6 @@ SETTINGS_ELEM_OPTION_TYPE_STRING("--cmd-from-file", "Load command line from file

SETTINGS_ELEM_OPTION_TYPE_STRING("--save-cmd-to-file", "Save command line to file")

/*
* TODO: add
* --load-from-file
* --save-Ex-only
* --save-Ey-only
* --save-Ez-only
* --save-Hx-only
* --save-Hy-only
* --save-Hz-only
* --save-as-bmp
* --save-as-dat
* --save-as-txt
* --dumper-pallete
* --dumper-start-coord
* --dumper-end-coord
* --dumper-orth-axis
*/

#undef SETTINGS_ELEM_OPTION_TYPE_NONE
#undef SETTINGS_ELEM_OPTION_TYPE_STRING
#undef SETTINGS_ELEM_FIELD_TYPE_NONE
Expand Down

0 comments on commit 2a180f6

Please sign in to comment.