From bd6e9a0733a7e3f1cbc445a96ee7a3353ed145f6 Mon Sep 17 00:00:00 2001 From: AlexanderSinn Date: Wed, 20 Dec 2023 12:20:58 +0100 Subject: [PATCH 1/2] add zyx geometry for laser input --- src/laser/MultiLaser.cpp | 54 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index c389dcc559..535a78437b 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -273,10 +273,12 @@ MultiLaser::GetEnvelopeFromFile (const amrex::Geometry& gm) { const std::vector axis_labels = laser.axisLabels(); if (axis_labels[0] == "t" && axis_labels[1] == "y" && axis_labels[2] == "x") { m_file_geometry = "xyt"; + } else if (axis_labels[0] == "z" && axis_labels[1] == "y" && axis_labels[2] == "x") { + m_file_geometry = "xyz"; } else if (axis_labels[0] == "t" && axis_labels[1] == "r") { m_file_geometry = "rt"; } else { - amrex::Abort("Incorrect axis labels in laser file, must be either t, y, x or t, r"); + amrex::Abort("Incorrect axis labels in laser file, must be either tyx, zyx or tr"); } const std::shared_ptr data = laser_comp.loadChunk(); @@ -360,6 +362,56 @@ MultiLaser::GetEnvelopeFromFile (const amrex::Geometry& gm) { } } } // End of 3 loops (1 per dimension) over laser array from simulation + } else if (m_file_geometry == "xyz") { + // Calculate the min and max of the grid from laser file + amrex::Real zmin_laser = offset[0] + position[0]*spacing[0]; + amrex::Real ymin_laser = offset[1] + position[1]*spacing[1]; + amrex::Real xmin_laser = offset[2] + position[2]*spacing[2]; + AMREX_ALWAYS_ASSERT(position[0] == 0 && position[1] == 0 && position[2] == 0); + + + for (int k = kmin; k <= domain.bigEnd(2); ++k) { + for (int j = jmin; j <= domain.bigEnd(1); ++j) { + for (int i = imin; i <= domain.bigEnd(0); ++i) { + + const amrex::Real x = (i-imin)*dx + xmin; + const amrex::Real xmid = (x - xmin_laser)/spacing[2]; + amrex::Real sx_cell[interp_order_xy+1]; + const int i_cell = compute_shape_factor(sx_cell, xmid); + + const amrex::Real y = (j-jmin)*dy + ymin; + const amrex::Real ymid = (y - ymin_laser)/spacing[1]; + amrex::Real sy_cell[interp_order_xy+1]; + const int j_cell = compute_shape_factor(sy_cell, ymid); + + const amrex::Real z = (k-kmin)*dz + zmin; + const amrex::Real zmid = (z - zmin_laser)/spacing[0]; + amrex::Real sz_cell[interp_order_xy+1]; + const int k_cell = compute_shape_factor(sz_cell, zmid); + + laser_arr(i, j, k, 0) = 0._rt; + laser_arr(i, j, k, 1) = 0._rt; + for (int iz=0; iz<=interp_order_xy; iz++){ + for (int iy=0; iy<=interp_order_xy; iy++){ + for (int ix=0; ix<=interp_order_xy; ix++){ + if (i_cell+ix >= 0 && i_cell+ix < static_cast(extent[2]) && + j_cell+iy >= 0 && j_cell+iy < static_cast(extent[1]) && + k_cell+iz >= 0 && k_cell+iz < static_cast(extent[0])) { + laser_arr(i, j, k, 0) += sx_cell[ix] * sy_cell[iy] * sz_cell[iz] * + static_cast( + input_file_arr(i_cell+ix, j_cell+iy, k_cell+iz).real() * unitSI + ); + laser_arr(i, j, k, 1) += sx_cell[ix] * sy_cell[iy] * sz_cell[iz] * + static_cast( + input_file_arr(i_cell+ix, j_cell+iy, k_cell+iz).imag() * unitSI + ); + } + } + } + } // End of 3 loops (1 per dimension) over laser array from file + } + } + } // End of 3 loops (1 per dimension) over laser array from simulation } else if (m_file_geometry == "rt") { // extent = {nmodes, nt, nr} From be92612b08946167a490a0ddfcd80fb3204fa925 Mon Sep 17 00:00:00 2001 From: AlexanderSinn Date: Wed, 20 Dec 2023 15:57:58 +0100 Subject: [PATCH 2/2] remove assert --- src/laser/MultiLaser.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/laser/MultiLaser.cpp b/src/laser/MultiLaser.cpp index 535a78437b..8e57c982b8 100644 --- a/src/laser/MultiLaser.cpp +++ b/src/laser/MultiLaser.cpp @@ -367,8 +367,6 @@ MultiLaser::GetEnvelopeFromFile (const amrex::Geometry& gm) { amrex::Real zmin_laser = offset[0] + position[0]*spacing[0]; amrex::Real ymin_laser = offset[1] + position[1]*spacing[1]; amrex::Real xmin_laser = offset[2] + position[2]*spacing[2]; - AMREX_ALWAYS_ASSERT(position[0] == 0 && position[1] == 0 && position[2] == 0); - for (int k = kmin; k <= domain.bigEnd(2); ++k) { for (int j = jmin; j <= domain.bigEnd(1); ++j) {