Skip to content

Commit

Permalink
Moved types that are not actual parameters to be varied into a new pr…
Browse files Browse the repository at this point in the history
…imitives file.
  • Loading branch information
tranqui committed Jul 8, 2024
1 parent 55dcf89 commit 4481ef5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
24 changes: 24 additions & 0 deletions src/math_primitives.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once
#include <Eigen/Eigen>

static constexpr int d = 2; // number of spatial dimensions
using Scalar = double; // type for numeric data

using Field = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
using FieldRef = Eigen::Ref<const Field>;

using HostField = Field;
using HostFieldRef = FieldRef;
using DeviceField = Scalar*;

using Gradient = std::array<Field, d>;
using HostGradient = Gradient;
using DeviceGradient = std::array<Scalar*, d>;

using Current = Gradient;
using HostCurrent = HostGradient;
using DeviceCurrent = DeviceGradient;

// Direction of index offset when derivatives are taken on staggered grids.
// See `StaggeredDerivative` in finite_differences.cuh for more info.
enum StaggeredGridDirection { Left, Central, Right };
32 changes: 4 additions & 28 deletions src/parameters.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
#pragma once
#include <Eigen/Eigen>
#include "math_primitives.h"


/// Basic constants and data types.
/// Compile-time parameters affecting algorithm implementation.

static constexpr int d = 2; // number of spatial dimensions
using Scalar = double; // type for numeric data
static constexpr int order = 2; // order of finite-difference calculations

using Field = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
using FieldRef = Eigen::Ref<const Field>;

using HostField = Field;
using HostFieldRef = FieldRef;
using DeviceField = Scalar*;

using Gradient = std::array<Field, d>;
using HostGradient = Gradient;
using DeviceGradient = std::array<Scalar*, d>;

using Current = Gradient;
using HostCurrent = HostGradient;
using DeviceCurrent = DeviceGradient;

/// Grid parameters
static constexpr int order = 2; // order of error in finite-difference approximations

namespace kernel
{
Expand All @@ -38,12 +19,8 @@ namespace kernel
static constexpr int num_ghost = 1 + order / 2; // <- minimum for fourth derivatives
}

// Direction of index offset when derivatives are taken on staggered grids.
// See StaggeredDerivative in finite_differences.cuh for more info.
enum StaggeredGridDirection { Left, Right };


/// Parameters to specific simulations.
/// Run-time parameters to specific simulations.

struct HostStencilParams
{
Expand Down Expand Up @@ -100,4 +77,3 @@ struct ActiveModelBPlusParams

using Stencil = HostStencilParams;
using Model = ActiveModelBPlusParams;

0 comments on commit 4481ef5

Please sign in to comment.