Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

varify the sequences of advection_step_setup and close #714

Merged
merged 6 commits into from
Dec 24, 2024
Merged
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
42 changes: 21 additions & 21 deletions src/for_2D_build/meshes/mesh_local_dynamics_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ Arrayi BaseMeshLocalDynamics::CellIndexFromSortIndex(const size_t &sort_index)
//=============================================================================================//
void InitializeDataForSingularPackage::update(const size_t package_index, Real far_field_level_set)
{
auto &phi = phi_.DataField()[package_index];
auto &near_interface_id = near_interface_id_.DataField()[package_index];
auto &phi_gradient = phi_gradient_.DataField()[package_index];
auto &kernel_weight = kernel_weight_.DataField()[package_index];
auto &kernel_gradient = kernel_gradient_.DataField()[package_index];
auto &phi = phi_.Data()[package_index];
auto &near_interface_id = near_interface_id_.Data()[package_index];
auto &phi_gradient = phi_gradient_.Data()[package_index];
auto &kernel_weight = kernel_weight_.Data()[package_index];
auto &kernel_gradient = kernel_gradient_.Data()[package_index];

mesh_data_.for_each_cell_data(
[&](int i, int j)
Expand Down Expand Up @@ -65,8 +65,8 @@ void InitializeCellNeighborhood::update(const size_t &package_index)
//=============================================================================================//
void InitializeBasicDataForAPackage::update(const size_t &package_index)
{
auto &phi = phi_.DataField()[package_index];
auto &near_interface_id = near_interface_id_.DataField()[package_index];
auto &phi = phi_.Data()[package_index];
auto &near_interface_id = near_interface_id_.Data()[package_index];
Arrayi cell_index = mesh_data_.meta_data_cell_[package_index].first;
mesh_data_.for_each_cell_data(
[&](int i, int j)
Expand Down Expand Up @@ -141,9 +141,9 @@ Vecd UpdateKernelIntegrals::computeKernelGradientIntegral(const Vecd &position)
//=============================================================================================//
void ReinitializeLevelSet::update(const size_t &package_index)
{
auto phi_data = phi_.DataField();
auto phi_data = phi_.Data();
auto &phi_addrs = phi_data[package_index];
auto &near_interface_id_addrs = near_interface_id_.DataField()[package_index];
auto &near_interface_id_addrs = near_interface_id_.Data()[package_index];
auto &neighborhood = mesh_data_.cell_neighborhood_[package_index];

mesh_data_.for_each_cell_data(
Expand All @@ -170,8 +170,8 @@ void ReinitializeLevelSet::update(const size_t &package_index)
//=============================================================================================//
void MarkNearInterface::update(const size_t &package_index)
{
auto &phi_addrs = phi_.DataField()[package_index];
auto &near_interface_id_addrs = near_interface_id_.DataField()[package_index];
auto &phi_addrs = phi_.Data()[package_index];
auto &near_interface_id_addrs = near_interface_id_.Data()[package_index];
auto neighborhood = mesh_data_.cell_neighborhood_[package_index];

// corner averages, note that the first row and first column are not used
Expand Down Expand Up @@ -220,8 +220,8 @@ void MarkNearInterface::update(const size_t &package_index)
//=============================================================================================//
void RedistanceInterface::update(const size_t &package_index)
{
auto phi_data = phi_.DataField();
auto near_interface_id_data = near_interface_id_.DataField();
auto phi_data = phi_.Data();
auto near_interface_id_data = near_interface_id_.Data();
auto &neighborhood = mesh_data_.cell_neighborhood_[package_index];
using NeighbourIndex = std::pair<size_t, Arrayi>; /**< stores shifted neighbour info: (size_t)package index, (arrayi)local grid index. */

Expand Down Expand Up @@ -250,9 +250,9 @@ void RedistanceInterface::update(const size_t &package_index)
[&](int x, int y)
{
NeighbourIndex neighbour_index = mesh_data_.NeighbourIndexShift(Arrayi(i + x, j + y), neighborhood);
auto &neighbor_phi = phi_.DataField()[neighbour_index.first];
auto &neighbor_phi_gradient = phi_gradient_.DataField()[neighbour_index.first];
auto &neighbor_near_interface_id = near_interface_id_.DataField()[neighbour_index.first];
auto &neighbor_phi = phi_.Data()[neighbour_index.first];
auto &neighbor_phi_gradient = phi_gradient_.Data()[neighbour_index.first];
auto &neighbor_near_interface_id = near_interface_id_.Data()[neighbour_index.first];
if (neighbor_near_interface_id[neighbour_index.second[0]][neighbour_index.second[1]] >= 1)
{
Real phi_p_ = neighbor_phi[neighbour_index.second[0]][neighbour_index.second[1]];
Expand All @@ -274,9 +274,9 @@ void RedistanceInterface::update(const size_t &package_index)
[&](int x, int y)
{
NeighbourIndex neighbour_index = mesh_data_.NeighbourIndexShift(Arrayi(i + x, j + y), neighborhood);
auto &neighbor_phi = phi_.DataField()[neighbour_index.first];
auto &neighbor_phi_gradient = phi_gradient_.DataField()[neighbour_index.first];
auto &neighbor_near_interface_id = near_interface_id_.DataField()[neighbour_index.first];
auto &neighbor_phi = phi_.Data()[neighbour_index.first];
auto &neighbor_phi_gradient = phi_gradient_.Data()[neighbour_index.first];
auto &neighbor_near_interface_id = near_interface_id_.Data()[neighbour_index.first];
if (neighbor_near_interface_id[neighbour_index.second[0]][neighbour_index.second[1]] <= -1)
{
Real phi_n_ = neighbor_phi[neighbour_index.second[0]][neighbour_index.second[1]];
Expand All @@ -297,8 +297,8 @@ void RedistanceInterface::update(const size_t &package_index)
//=============================================================================================//
void DiffuseLevelSetSign::update(const size_t &package_index)
{
auto phi_data = phi_.DataField();
auto near_interface_id_data = near_interface_id_.DataField();
auto phi_data = phi_.Data();
auto near_interface_id_data = near_interface_id_.Data();
auto &neighborhood = mesh_data_.cell_neighborhood_[package_index];

mesh_data_.for_each_cell_data(
Expand Down
14 changes: 7 additions & 7 deletions src/for_2D_build/meshes/mesh_with_data_packages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DataType MeshWithGridDataPackages<PKG_SIZE>::
local_data_index[n] = global_grid_index[n] - cell_index_in_this_direction * pkg_size;
}
size_t package_index = PackageIndexFromCellIndex(cell_index_on_mesh_);
auto &data = mesh_variable.DataField()[package_index];
auto &data = mesh_variable.Data()[package_index];
return data[local_data_index[0]][local_data_index[1]];
}
//=================================================================================================//
Expand All @@ -52,7 +52,7 @@ DataType MeshWithGridDataPackages<PKG_SIZE>::
Arrayi cell_index = CellIndexFromPosition(position);
size_t package_index = PackageIndexFromCellIndex(cell_index);
return isInnerDataPackage(cell_index) ? probeDataPackage(mesh_variable, package_index, cell_index, position)
: mesh_variable.DataField()[package_index][0][0];
: mesh_variable.Data()[package_index][0][0];
}
//=================================================================================================//
template <int PKG_SIZE>
Expand Down Expand Up @@ -115,7 +115,7 @@ void MeshWithGridDataPackages<PKG_SIZE>::
const FunctionByPosition &function_by_position)
{
size_t package_index = PackageIndexFromCellIndex(cell_index);
auto &pkg_data = mesh_variable.DataField()[package_index];
auto &pkg_data = mesh_variable.Data()[package_index];
for (int i = 0; i != pkg_size; ++i)
for (int j = 0; j != pkg_size; ++j)
{
Expand All @@ -131,8 +131,8 @@ void MeshWithGridDataPackages<PKG_SIZE>::
MeshVariable<OutDataType> &out_variable,
const size_t package_index)
{
auto in_variable_data = in_variable.DataField();
auto out_variable_data = out_variable.DataField();
auto in_variable_data = in_variable.Data();
auto out_variable_data = out_variable.Data();

auto &neighborhood = cell_neighborhood_[package_index];
auto &pkg_data = out_variable_data[package_index];
Expand All @@ -159,7 +159,7 @@ DataType MeshWithGridDataPackages<PKG_SIZE>::
CornerAverage(MeshVariable<DataType> &mesh_variable, Arrayi addrs_index, Arrayi corner_direction, CellNeighborhood &neighborhood)
{
DataType average = ZeroData<DataType>::value;
auto mesh_variable_data = mesh_variable.DataField();
auto mesh_variable_data = mesh_variable.Data();
for (int i = 0; i != 2; ++i)
for (int j = 0; j != 2; ++j)
{
Expand All @@ -182,7 +182,7 @@ DataType MeshWithGridDataPackages<PKG_SIZE>::
Vecd beta = Vecd::Ones() - alpha;

auto &neighborhood = cell_neighborhood_[package_index];
auto mesh_variable_data = mesh_variable.DataField();
auto mesh_variable_data = mesh_variable.Data();
NeighbourIndex neighbour_index_1 = NeighbourIndexShift(Arrayi(data_index[0], data_index[1]), neighborhood);
NeighbourIndex neighbour_index_2 = NeighbourIndexShift(Arrayi(data_index[0] + 1, data_index[1]), neighborhood);
NeighbourIndex neighbour_index_3 = NeighbourIndexShift(Arrayi(data_index[0], data_index[1] + 1), neighborhood);
Expand Down
42 changes: 21 additions & 21 deletions src/for_3D_build/meshes/mesh_local_dynamics_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Arrayi BaseMeshLocalDynamics::CellIndexFromSortIndex(const size_t &sort_index)
//=============================================================================================//
void InitializeDataForSingularPackage::update(const size_t package_index, Real far_field_level_set)
{
auto &phi = phi_.DataField()[package_index];
auto &near_interface_id = near_interface_id_.DataField()[package_index];
auto &phi_gradient = phi_gradient_.DataField()[package_index];
auto &kernel_weight = kernel_weight_.DataField()[package_index];
auto &kernel_gradient = kernel_gradient_.DataField()[package_index];
auto &phi = phi_.Data()[package_index];
auto &near_interface_id = near_interface_id_.Data()[package_index];
auto &phi_gradient = phi_gradient_.Data()[package_index];
auto &kernel_weight = kernel_weight_.Data()[package_index];
auto &kernel_gradient = kernel_gradient_.Data()[package_index];

mesh_data_.for_each_cell_data(
[&](int i, int j, int k)
Expand Down Expand Up @@ -68,8 +68,8 @@ void InitializeCellNeighborhood::update(const size_t &package_index)
//=============================================================================================//
void InitializeBasicDataForAPackage::update(const size_t &package_index)
{
auto &phi = phi_.DataField()[package_index];
auto &near_interface_id = near_interface_id_.DataField()[package_index];
auto &phi = phi_.Data()[package_index];
auto &near_interface_id = near_interface_id_.Data()[package_index];
Arrayi cell_index = mesh_data_.meta_data_cell_[package_index].first;
mesh_data_.for_each_cell_data(
[&](int i, int j, int k)
Expand Down Expand Up @@ -144,9 +144,9 @@ Vecd UpdateKernelIntegrals::computeKernelGradientIntegral(const Vecd &position)
//=============================================================================================//
void ReinitializeLevelSet::update(const size_t &package_index)
{
auto phi_data = phi_.DataField();
auto phi_data = phi_.Data();
auto &phi_addrs = phi_data[package_index];
auto &near_interface_id_addrs = near_interface_id_.DataField()[package_index];
auto &near_interface_id_addrs = near_interface_id_.Data()[package_index];
auto &neighborhood = mesh_data_.cell_neighborhood_[package_index];

mesh_data_.for_each_cell_data(
Expand Down Expand Up @@ -174,8 +174,8 @@ void ReinitializeLevelSet::update(const size_t &package_index)
//=============================================================================================//
void MarkNearInterface::update(const size_t &package_index)
{
auto &phi_addrs = phi_.DataField()[package_index];
auto &near_interface_id_addrs = near_interface_id_.DataField()[package_index];
auto &phi_addrs = phi_.Data()[package_index];
auto &near_interface_id_addrs = near_interface_id_.Data()[package_index];
auto neighborhood = mesh_data_.cell_neighborhood_[package_index];

// corner averages, note that the first row and first column are not used
Expand Down Expand Up @@ -222,8 +222,8 @@ void MarkNearInterface::update(const size_t &package_index)
//=============================================================================================//
void RedistanceInterface::update(const size_t &package_index)
{
auto phi_data = phi_.DataField();
auto near_interface_id_data = near_interface_id_.DataField();
auto phi_data = phi_.Data();
auto near_interface_id_data = near_interface_id_.Data();
auto &neighborhood = mesh_data_.cell_neighborhood_[package_index];

using NeighbourIndex = std::pair<size_t, Arrayi>; /**< stores shifted neighbour info: (size_t)package index, (arrayi)local grid index. */
Expand Down Expand Up @@ -252,9 +252,9 @@ void RedistanceInterface::update(const size_t &package_index)
[&](int x, int y, int z)
{
NeighbourIndex neighbour_index = mesh_data_.NeighbourIndexShift(Arrayi(i + x, j + y, k + z), neighborhood);
auto &neighbor_phi = phi_.DataField()[neighbour_index.first];
auto &neighbor_phi_gradient = phi_gradient_.DataField()[neighbour_index.first];
auto &neighbor_near_interface_id = near_interface_id_.DataField()[neighbour_index.first];
auto &neighbor_phi = phi_.Data()[neighbour_index.first];
auto &neighbor_phi_gradient = phi_gradient_.Data()[neighbour_index.first];
auto &neighbor_near_interface_id = near_interface_id_.Data()[neighbour_index.first];
if (neighbor_near_interface_id[neighbour_index.second[0]][neighbour_index.second[1]][neighbour_index.second[2]] >= 1)
{
Real phi_p_ = neighbor_phi[neighbour_index.second[0]][neighbour_index.second[1]][neighbour_index.second[2]];
Expand All @@ -276,9 +276,9 @@ void RedistanceInterface::update(const size_t &package_index)
[&](int x, int y, int z)
{
NeighbourIndex neighbour_index = mesh_data_.NeighbourIndexShift(Arrayi(i + x, j + y, k + z), neighborhood);
auto &neighbor_phi = phi_.DataField()[neighbour_index.first];
auto &neighbor_phi_gradient = phi_gradient_.DataField()[neighbour_index.first];
auto &neighbor_near_interface_id = near_interface_id_.DataField()[neighbour_index.first];
auto &neighbor_phi = phi_.Data()[neighbour_index.first];
auto &neighbor_phi_gradient = phi_gradient_.Data()[neighbour_index.first];
auto &neighbor_near_interface_id = near_interface_id_.Data()[neighbour_index.first];
if (neighbor_near_interface_id[neighbour_index.second[0]][neighbour_index.second[1]][neighbour_index.second[2]] <= -1)
{
Real phi_n_ = neighbor_phi[neighbour_index.second[0]][neighbour_index.second[1]][neighbour_index.second[2]];
Expand All @@ -299,8 +299,8 @@ void RedistanceInterface::update(const size_t &package_index)
//=============================================================================================//
void DiffuseLevelSetSign::update(const size_t &package_index)
{
auto phi_data = phi_.DataField();
auto near_interface_id_data = near_interface_id_.DataField();
auto phi_data = phi_.Data();
auto near_interface_id_data = near_interface_id_.Data();
auto &neighborhood = mesh_data_.cell_neighborhood_[package_index];

mesh_data_.for_each_cell_data(
Expand Down
14 changes: 7 additions & 7 deletions src/for_3D_build/meshes/mesh_with_data_packages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DataType MeshWithGridDataPackages<PKG_SIZE>::
local_data_index[n] = global_grid_index[n] - cell_index_in_this_direction * pkg_size;
}
size_t package_index = PackageIndexFromCellIndex(cell_index_on_mesh_);
auto &data = mesh_variable.DataField()[package_index];
auto &data = mesh_variable.Data()[package_index];
return data[local_data_index[0]][local_data_index[1]][local_data_index[2]];
}
//=================================================================================================//
Expand All @@ -52,7 +52,7 @@ DataType MeshWithGridDataPackages<PKG_SIZE>::
Arrayi cell_index = CellIndexFromPosition(position);
size_t package_index = PackageIndexFromCellIndex(cell_index);
return isInnerDataPackage(cell_index) ? probeDataPackage<DataType>(mesh_variable, package_index, cell_index, position)
: mesh_variable.DataField()[package_index][0][0][0];
: mesh_variable.Data()[package_index][0][0][0];
}
//=================================================================================================//
template <int PKG_SIZE>
Expand Down Expand Up @@ -116,7 +116,7 @@ void MeshWithGridDataPackages<PKG_SIZE>::
const FunctionByPosition &function_by_position)
{
size_t package_index = PackageIndexFromCellIndex(cell_index);
auto &pkg_data = mesh_variable.DataField()[package_index];
auto &pkg_data = mesh_variable.Data()[package_index];
for (int i = 0; i != pkg_size; ++i)
for (int j = 0; j != pkg_size; ++j)
for (int k = 0; k != pkg_size; ++k)
Expand All @@ -133,8 +133,8 @@ void MeshWithGridDataPackages<PKG_SIZE>::
MeshVariable<OutDataType> &out_variable,
const size_t package_index)
{
auto in_variable_data = in_variable.DataField();
auto out_variable_data = out_variable.DataField();
auto in_variable_data = in_variable.Data();
auto out_variable_data = out_variable.Data();

auto &neighborhood = cell_neighborhood_[package_index];
auto &pkg_data = out_variable_data[package_index];
Expand Down Expand Up @@ -164,7 +164,7 @@ DataType MeshWithGridDataPackages<PKG_SIZE>::
CornerAverage(MeshVariable<DataType> &mesh_variable, Arrayi addrs_index, Arrayi corner_direction, CellNeighborhood &neighborhood)
{
DataType average = ZeroData<DataType>::value;
auto mesh_variable_data = mesh_variable.DataField();
auto mesh_variable_data = mesh_variable.Data();
for (int i = 0; i != 2; ++i)
for (int j = 0; j != 2; ++j)
for (int k = 0; k != 2; ++k)
Expand All @@ -189,7 +189,7 @@ DataType MeshWithGridDataPackages<PKG_SIZE>::
Vecd beta = Vecd::Ones() - alpha;

auto &neighborhood = cell_neighborhood_[package_index];
auto mesh_variable_data = mesh_variable.DataField();
auto mesh_variable_data = mesh_variable.Data();
NeighbourIndex neighbour_index_1 = NeighbourIndexShift(Arrayi(data_index[0], data_index[1], data_index[2]), neighborhood);
NeighbourIndex neighbour_index_2 = NeighbourIndexShift(Arrayi(data_index[0] + 1, data_index[1], data_index[2]), neighborhood);
NeighbourIndex neighbour_index_3 = NeighbourIndexShift(Arrayi(data_index[0], data_index[1] + 1, data_index[2]), neighborhood);
Expand Down
Loading
Loading