Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions amr-wind/core/FieldRepo.H
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ public:
int nghost = 0,
FieldLoc floc = FieldLoc::CELL) const;

std::unique_ptr<IntScratchField> create_int_scratch_field(
const std::string& name,
int ncomp = 1,
int nghost = 0,
FieldLoc floc = FieldLoc::CELL) const;

/** Create a scratch field
*
* ScratchField is a temporary field used to compute and store intermediate
Expand All @@ -332,6 +338,9 @@ public:
std::unique_ptr<ScratchField> create_scratch_field_on_host(
int ncomp = 1, int nghost = 0, FieldLoc floc = FieldLoc::CELL) const;

std::unique_ptr<IntScratchField> create_int_scratch_field(
int ncomp = 1, int nghost = 0, FieldLoc floc = FieldLoc::CELL) const;

std::unique_ptr<IntScratchField> create_int_scratch_field_on_host(
const std::string& name,
int ncomp = 1,
Expand Down
30 changes: 30 additions & 0 deletions amr-wind/core/FieldRepo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,36 @@ std::unique_ptr<ScratchField> FieldRepo::create_scratch_field_on_host(
return create_scratch_field_on_host(
"scratch_field_host", ncomp, nghost, floc);
}
std::unique_ptr<IntScratchField> FieldRepo::create_int_scratch_field(
const std::string& name,
const int ncomp,
const int nghost,
const FieldLoc floc) const
{
BL_PROFILE("amr-wind::FieldRepo::create_int_scratch_field");
if (!m_is_initialized) {
amrex::Abort(
"Integer scratch field creation is not permitted before mesh is "
"initialized");
}
std::unique_ptr<IntScratchField> field(
new IntScratchField(*this, name, ncomp, nghost, floc));

for (int lev = 0; lev <= m_mesh.finestLevel(); ++lev) {
const auto ba =
amrex::convert(m_mesh.boxArray(lev), field_impl::index_type(floc));

field->m_data.emplace_back(
ba, m_mesh.DistributionMap(lev), ncomp, nghost, amrex::MFInfo(),
*(m_leveldata[lev]->m_int_fact));
}
return field;
}
std::unique_ptr<IntScratchField> FieldRepo::create_int_scratch_field(
const int ncomp, const int nghost, const FieldLoc floc) const
{
return create_int_scratch_field("scratch_field", ncomp, nghost, floc);
}
std::unique_ptr<IntScratchField> FieldRepo::create_int_scratch_field_on_host(
const std::string& name,
const int ncomp,
Expand Down
20 changes: 18 additions & 2 deletions amr-wind/equation_systems/DiffusionOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ DiffSolverIface<LinOp>::DiffSolverIface(
iapply.setMaxCoarseningLevel(0);

const auto& mesh = m_pdefields.repo.mesh();
if (!has_overset) {
if (!has_overset && !fields.repo.int_field_exists("terrain_blank")) {
m_solver.reset(new LinOp(
mesh.Geom(0, mesh.finestLevel()),
mesh.boxArray(0, mesh.finestLevel()),
Expand All @@ -35,7 +35,23 @@ DiffSolverIface<LinOp>::DiffSolverIface(
mesh.boxArray(0, mesh.finestLevel()),
mesh.DistributionMap(0, mesh.finestLevel()), iapply));
} else {
auto imask = fields.repo.get_int_field("mask_cell").vec_const_ptrs();
auto combo_mask =
fields.repo.create_int_scratch_field("combo_mask", 1, 1);
combo_mask->setVal(1);
if (fields.repo.int_field_exists("terrain_blank")) {
auto& terrain_blank = fields.repo.get_int_field("terrain_blank");
for (int i = 0; i < mesh.finestLevel() + 1; ++i) {
amrex::iMultiFab::Saxpy(
(*combo_mask)(i), -1, terrain_blank(i), 0, 0, 1,
amrex::IntVect(1));
}
}
const auto& overset_mask = fields.repo.get_int_field("mask_cell");
for (int i = 0; i < mesh.finestLevel() + 1; ++i) {
amrex::iMultiFab::Multiply(
(*combo_mask)(i), overset_mask(i), 0, 0, 1, 1);
}
auto imask = (*combo_mask).vec_const_ptrs();
m_solver.reset(new LinOp(
mesh.Geom(0, mesh.finestLevel()),
mesh.boxArray(0, mesh.finestLevel()),
Expand Down
47 changes: 41 additions & 6 deletions amr-wind/equation_systems/icns/icns_diffusion.H
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "amr-wind/equation_systems/DiffusionOps.H"
#include "amr-wind/equation_systems/icns/icns.H"
#include "amr-wind/utilities/console_io.H"
#include "amr-wind/core/field_ops.H"
#include "AMReX_REAL.H"

using namespace amrex::literals;
Expand Down Expand Up @@ -72,7 +73,7 @@
const auto& bchi = diffusion::get_diffuse_tensor_bc(
m_pdefields.field, amrex::Orientation::high);

if (!has_overset) {
if (!has_overset && !fields.repo.int_field_exists("terrain_blank")) {

m_solver_scalar = std::make_unique<amrex::MLABecLaplacian>(
mesh.Geom(0, mesh.finestLevel()),
Expand All @@ -89,8 +90,24 @@
amrex::FabFactory<amrex::MLABecLaplacian::FAB> const*>(),
AMREX_SPACEDIM);
} else {
auto imask =
fields.repo.get_int_field("mask_cell").vec_const_ptrs();
auto combo_mask =
fields.repo.create_int_scratch_field("combo_mask", 1, 1);
combo_mask->setVal(1);
if (fields.repo.int_field_exists("terrain_blank")) {
auto& terrain_blank =
fields.repo.get_int_field("terrain_blank");
for (int i = 0; i < mesh.finestLevel() + 1; ++i) {
amrex::iMultiFab::Saxpy(
(*combo_mask)(i), -1, terrain_blank(i), 0, 0, 1,
amrex::IntVect(1));
}
}
const auto& overset_mask = fields.repo.get_int_field("mask_cell");
for (int i = 0; i < mesh.finestLevel() + 1; ++i) {
amrex::iMultiFab::Multiply(
(*combo_mask)(i), overset_mask(i), 0, 0, 1, 1);
}
auto imask = (*combo_mask).vec_const_ptrs();
m_solver_scalar = std::make_unique<amrex::MLABecLaplacian>(
mesh.Geom(0, mesh.finestLevel()),
mesh.boxArray(0, mesh.finestLevel()),
Expand Down Expand Up @@ -290,7 +307,8 @@
m_pdefields.field, amrex::Orientation::high);

for (int i = 0; i < AMREX_SPACEDIM; ++i) {
if (!has_overset) {
if (!has_overset &&
!fields.repo.int_field_exists("terrain_blank")) {
m_solver_scalar[i] = std::make_unique<amrex::MLABecLaplacian>(
mesh.Geom(0, mesh.finestLevel()),
mesh.boxArray(0, mesh.finestLevel()),
Expand All @@ -300,8 +318,25 @@
mesh.boxArray(0, mesh.finestLevel()),
mesh.DistributionMap(0, mesh.finestLevel()), iapply);
} else {
auto imask =
fields.repo.get_int_field("mask_cell").vec_const_ptrs();
auto combo_mask =
fields.repo.create_int_scratch_field("combo_mask", 1, 1);
combo_mask->setVal(1);
if (fields.repo.int_field_exists("terrain_blank")) {
auto& terrain_blank =
fields.repo.get_int_field("terrain_blank");
for (int i = 0; i < mesh.finestLevel() + 1; ++i) {

Check warning on line 327 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

declaration shadows a local variable [clang-diagnostic-shadow]

Check warning on line 327 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

declaration shadows a local variable [-Wshadow]

Check warning on line 327 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU-SINGLE

declaration of ‘i’ shadows a previous local [-Wshadow]

Check warning on line 327 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU-SINGLE

declaration of ‘i’ shadows a previous local [-Wshadow]

Check warning on line 327 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU (ubuntu-24.04, Debug, NoOpenMP)

declaration of ‘i’ shadows a previous local [-Wshadow]

Check warning on line 327 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU (ubuntu-24.04, Release, NoOpenMP)

declaration of ‘i’ shadows a previous local [-Wshadow]

Check warning on line 327 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

declaration shadows a local variable [-Wshadow]

Check warning on line 327 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

declaration shadows a local variable [-Wshadow]

Check warning on line 327 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU (ubuntu-24.04, Debug, OpenMP)

declaration of ‘i’ shadows a previous local [-Wshadow]
amrex::iMultiFab::Saxpy(
(*combo_mask)(i), -1, terrain_blank(i), 0, 0, 1,
amrex::IntVect(1));
}
}
const auto& overset_mask =
fields.repo.get_int_field("mask_cell");
for (int i = 0; i < mesh.finestLevel() + 1; ++i) {

Check warning on line 335 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

declaration shadows a local variable [clang-diagnostic-shadow]

Check warning on line 335 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

declaration shadows a local variable [-Wshadow]

Check warning on line 335 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU-SINGLE

declaration of ‘i’ shadows a previous local [-Wshadow]

Check warning on line 335 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU-SINGLE

declaration of ‘i’ shadows a previous local [-Wshadow]

Check warning on line 335 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU (ubuntu-24.04, Debug, NoOpenMP)

declaration of ‘i’ shadows a previous local [-Wshadow]

Check warning on line 335 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU (ubuntu-24.04, Release, NoOpenMP)

declaration of ‘i’ shadows a previous local [-Wshadow]

Check warning on line 335 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

declaration shadows a local variable [-Wshadow]

Check warning on line 335 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU (macos-latest, Release, NoOpenMP)

declaration shadows a local variable [-Wshadow]

Check warning on line 335 in amr-wind/equation_systems/icns/icns_diffusion.H

View workflow job for this annotation

GitHub Actions / CPU (ubuntu-24.04, Debug, OpenMP)

declaration of ‘i’ shadows a previous local [-Wshadow]
amrex::iMultiFab::Multiply(
(*combo_mask)(i), overset_mask(i), 0, 0, 1, 1);
}
auto imask = (*combo_mask).vec_const_ptrs();
m_solver_scalar[i] = std::make_unique<amrex::MLABecLaplacian>(
mesh.Geom(0, mesh.finestLevel()),
mesh.boxArray(0, mesh.finestLevel()),
Expand Down
Loading