Skip to content

Commit

Permalink
gitignore and namespace update
Browse files Browse the repository at this point in the history
  • Loading branch information
UCaromel committed Sep 18, 2024
1 parent 187a9d0 commit c492585
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,3 @@ perf.*
.vscode
.phare*
PHARE_REPORT.zip
.cache
.envrc
PHAREenv/
49 changes: 23 additions & 26 deletions src/amr/data/field/initializers/field_user_initializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,30 @@
#include <tuple>
#include <memory>

namespace PHARE
namespace PHARE::core
{
namespace core{
class FieldUserFunctionInitializer {
public:
template<typename Field, typename GridLayout>
void static initialize(Field& field, GridLayout const& layout,
initializer::InitFunction<GridLayout::dimension> const& init)
{
auto const indices = layout.ghostStartToEndIndices(field, /*includeEnd=*/true);
auto const coords = layout.template indexesToCoordVectors</*WithField=*/true>(
indices, field, [](auto& gridLayout, auto& field_, auto const&... args) {
return gridLayout.fieldNodeCoordinates(field_, gridLayout.origin(), args...);
});

std::shared_ptr<Span<double>> gridPtr // keep grid data alive
= std::apply([&](auto&... args) { return init(args...); }, coords);
Span<double>& grid = *gridPtr;

for (std::size_t cell_idx = 0; cell_idx < indices.size(); cell_idx++)
std::apply([&](auto&... args) { field(args...) = grid[cell_idx]; },
indices[cell_idx]);
}
};

} // namespace core
class FieldUserFunctionInitializer
{
public:
template<typename Field, typename GridLayout>
void static initialize(Field& field, GridLayout const& layout,
initializer::InitFunction<GridLayout::dimension> const& init)
{
auto const indices = layout.ghostStartToEndIndices(field, /*includeEnd=*/true);
auto const coords = layout.template indexesToCoordVectors</*WithField=*/true>(
indices, field, [](auto& gridLayout, auto& field_, auto const&... args) {
return gridLayout.fieldNodeCoordinates(field_, gridLayout.origin(), args...);
});

std::shared_ptr<Span<double>> gridPtr // keep grid data alive
= std::apply([&](auto&... args) { return init(args...); }, coords);
Span<double>& grid = *gridPtr;

for (std::size_t cell_idx = 0; cell_idx < indices.size(); cell_idx++)
std::apply([&](auto&... args) { field(args...) = grid[cell_idx]; }, indices[cell_idx]);
}
};

} // namespace PHARE
} // namespace PHARE::core

#endif

0 comments on commit c492585

Please sign in to comment.