Skip to content

Commit

Permalink
move some InitEB functions out of the WarpX class
Browse files Browse the repository at this point in the history
  • Loading branch information
lucafedeli88 committed Jul 22, 2024
1 parent c6bb95a commit 0e51a77
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
33 changes: 33 additions & 0 deletions Source/EmbeddedBoundary/WarpXInitEB.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Copyright 2021 Lorenzo Giacomel, Luca Fedeli
*
* This file is part of WarpX.
*
* License: BSD-3-Clause-LBNL
*/

#ifndef WARPX_EMBEDDEDBOUNDARY_WARPXINITEB_H
#define WARPX_EMBEDDEDBOUNDARY_WARPXINITEB_H

#include <AMReX_MultiFab.H>
#include <AMReX_REAL.H>

#include <array>
#include <memory>

namespace warpx::embedded_boundary
{

/**
* \brief Scale the edges lengths by the mesh width to obtain the real lengths.
*/
void ScaleEdges (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& edge_lengths,
const std::array<amrex::Real,3>& cell_size);
/**
* \brief Scale the edges areas by the mesh width to obtain the real areas.
*/
void ScaleAreas (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& face_areas,
const std::array<amrex::Real,3>& cell_size);

}

#endif //WARPX_EMBEDDEDBOUNDARY_WARPXINITEB_H
11 changes: 8 additions & 3 deletions Source/EmbeddedBoundary/WarpXInitEB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* License: BSD-3-Clause-LBNL
*/

#include "WarpX.H"
# include "WarpX.H"

#ifdef AMREX_USE_EB

# include "WarpXInit.H"
# include "Utils/Parser/ParserUtils.H"
# include "Utils/TextMsg.H"

Expand Down Expand Up @@ -43,6 +45,9 @@
#endif

#ifdef AMREX_USE_EB

using namespace warpx::embedded_boundary;

namespace {
class ParserIF
: public amrex::GPUable
Expand Down Expand Up @@ -240,7 +245,7 @@ WarpX::ComputeFaceAreas (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& face


void
WarpX::ScaleEdges (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& edge_lengths,
ScaleEdges (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& edge_lengths,
const std::array<amrex::Real,3>& cell_size) {
BL_PROFILE("ScaleEdges");

Expand All @@ -265,7 +270,7 @@ WarpX::ScaleEdges (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& edge_lengt
}

void
WarpX::ScaleAreas(std::array< std::unique_ptr<amrex::MultiFab>, 3 >& face_areas,
ScaleAreas(std::array< std::unique_ptr<amrex::MultiFab>, 3 >& face_areas,
const std::array<amrex::Real,3>& cell_size) {
BL_PROFILE("ScaleAreas");

Expand Down
7 changes: 5 additions & 2 deletions Source/Initialization/WarpXInitData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#endif
#include "Diagnostics/MultiDiagnostics.H"
#include "Diagnostics/ReducedDiags/MultiReducedDiags.H"
#ifdef AMREX_USE_EB
# include "EmbeddedBoundary/WarpXInitEB.H"
#endif
#include "FieldSolver/Fields.H"
#include "FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.H"
#include "FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.H"
Expand Down Expand Up @@ -1292,9 +1295,9 @@ void WarpX::InitializeEBGridData (int lev)
auto const eb_fact = fieldEBFactory(lev);

ComputeEdgeLengths(m_edge_lengths[lev], eb_fact);
ScaleEdges(m_edge_lengths[lev], CellSize(lev));
warpx::embedded_boundary::ScaleEdges(m_edge_lengths[lev], CellSize(lev));
ComputeFaceAreas(m_face_areas[lev], eb_fact);
ScaleAreas(m_face_areas[lev], CellSize(lev));
warpx::embedded_boundary::ScaleAreas(m_face_areas[lev], CellSize(lev));

if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::ECT) {
MarkCells();
Expand Down
10 changes: 0 additions & 10 deletions Source/WarpX.H
Original file line number Diff line number Diff line change
Expand Up @@ -1130,16 +1130,6 @@ public:
const amrex::EBFArrayBoxFactory& eb_fact);

/**
* \brief Scale the edges lengths by the mesh width to obtain the real lengths.
*/
static void ScaleEdges (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& edge_lengths,
const std::array<amrex::Real,3>& cell_size);
/**
* \brief Scale the edges areas by the mesh width to obtain the real areas.
*/
static void ScaleAreas (std::array< std::unique_ptr<amrex::MultiFab>, 3 >& face_areas,
const std::array<amrex::Real,3>& cell_size);
/**
* \brief Initialize information for cell extensions.
* The flags convention for m_flag_info_face is as follows
* - 0 for unstable cells
Expand Down

0 comments on commit 0e51a77

Please sign in to comment.