Skip to content
Open
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
2 changes: 1 addition & 1 deletion benchmarks/mito.lib/blocks/composition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


// cartesian coordinates in 2D
using coordinates_t = mito::geometry::cartesian::coordinates_t<2>;
using coordinates_t = mito::geometry::cartesian<2>::coordinates_t;
// the metric space type
using metric_space_t = mito::geometry::euclidean_metric_space<coordinates_t>;

Expand Down
10 changes: 5 additions & 5 deletions benchmarks/mito.lib/integration/integration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@


// cartesian coordinates in 2D
using coordinates_t = mito::geometry::coordinates_t<2, mito::geometry::CARTESIAN>;
using coordinates_t = mito::geometry::cartesian<2>::coordinates_t;
// the metric space type
using metric_space_t = mito::geometry::euclidean_metric_space<coordinates_t>;

// the function extracting the {x_0} components of a 2D vector
constexpr auto x_0 = mito::geometry::cartesian::x_0<2>;
// the function extracting the {x_1} components of a 2D vector
constexpr auto x_1 = mito::geometry::cartesian::x_1<2>;
// the {x} function in 2D
constexpr auto x_0 = mito::geometry::cartesian<2>::x;
// the {y} function in 2D
constexpr auto x_1 = mito::geometry::cartesian<2>::y;


int
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/mito.lib/operators/laplacian.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


// the type of coordinates
using coordinates_t = mito::geometry::coordinates_t<2, mito::geometry::CARTESIAN>;
using coordinates_t = mito::geometry::cartesian<2>::coordinates_t;


auto
Expand Down Expand Up @@ -41,10 +41,10 @@ laplacian_baseline(const coordinates_t & x)
auto
laplacian_mito(const coordinates_t & x)
{
// the function extracting the x_0 component of 2D vector
constexpr auto x0 = mito::functions::component<coordinates_t, 0>;
// the function extracting the x_1 component of a 2D vector
constexpr auto x1 = mito::functions::component<coordinates_t, 1>;
// the {x} function in 2D
constexpr auto x0 = mito::geometry::cartesian<2>::x;
// the {y} function in 2D
constexpr auto x1 = mito::geometry::cartesian<2>::y;

// a scalar field
constexpr auto f = mito::functions::pow<4>(x0 * x1);
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/mito.lib/pdes/advection_diffusion_reaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


// cartesian coordinates in 2D
using coordinates_t = mito::geometry::cartesian::coordinates_t<2>;
using coordinates_t = mito::geometry::cartesian<2>::coordinates_t;
// the metric space type
using metric_space_t = mito::geometry::euclidean_metric_space<coordinates_t>;

Expand All @@ -24,11 +24,11 @@ using linear_system_t = mito::matrix_solvers::petsc::linear_system_t;
using matrix_solver_t = mito::matrix_solvers::petsc::ksp_t;

// the x and y scalar fields in 2D
constexpr auto x = mito::geometry::cartesian::x_0<2>;
constexpr auto y = mito::geometry::cartesian::x_1<2>;
constexpr auto x = mito::geometry::cartesian<2>::x;
constexpr auto y = mito::geometry::cartesian<2>::y;
// the unit vectors in 2D
constexpr auto e_x = mito::geometry::cartesian::e_0<2>;
constexpr auto e_y = mito::geometry::cartesian::e_1<2>;
constexpr auto e_x = mito::geometry::cartesian<2>::e_x;
constexpr auto e_y = mito::geometry::cartesian<2>::e_y;

int
main()
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/mito.lib/pdes/poisson.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


// cartesian coordinates in 2D
using coordinates_t = mito::geometry::coordinates_t<2, mito::geometry::CARTESIAN>;
using coordinates_t = mito::geometry::cartesian<2>::coordinates_t;
// the metric space type
using metric_space_t = mito::geometry::euclidean_metric_space<coordinates_t>;

Expand All @@ -24,9 +24,9 @@ using linear_system_t = mito::matrix_solvers::petsc::linear_system_t;
using matrix_solver_t = mito::matrix_solvers::petsc::ksp_t;

// the x scalar field in 2D
constexpr auto x = mito::functions::component<coordinates_t, 0>;
constexpr auto x = mito::geometry::cartesian<2>::x;
// the y scalar field in 2D
constexpr auto y = mito::functions::component<coordinates_t, 1>;
constexpr auto y = mito::geometry::cartesian<2>::y;


int
Expand Down
4 changes: 2 additions & 2 deletions extensions/mito/mito.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ PYBIND11_MODULE(mito, m)
m.doc() = "pybind11 mito plugin"; // optional module docstring

// the mito cartesian coordinates interface
using coordinates_3D_t = mito::geometry::coordinates_t<3, mito::geometry::CARTESIAN>;
using coordinates_3D_t = mito::geometry::cartesian<3>::coordinates_t;
mito::py::class_<coordinates_3D_t>(m, "Coordinates3D")
// the default constructor
.def(
Expand All @@ -47,7 +47,7 @@ PYBIND11_MODULE(mito, m)


// the mito vector interface
using coordinates_2D_t = mito::geometry::coordinates_t<2, mito::geometry::CARTESIAN>;
using coordinates_2D_t = mito::geometry::cartesian<2>::coordinates_t;
mito::py::class_<coordinates_2D_t>(m, "Coordinates2D")
// the default constructor
.def(
Expand Down
121 changes: 84 additions & 37 deletions lib/mito/geometry/cartesian/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,101 @@
#pragma once


namespace mito::geometry::cartesian {
namespace mito::geometry {

// the type of cartesian coordinates in {D} dimensions
// cartesian geometry in 1D
template <int D>
using coordinates_t = cartesian_coordinates_t<D>;
struct cartesian;

// the Euclidean metric tensor field
template <int D>
constexpr auto euclidean_metric =
geometry::euclidean_metric<cartesian_coordinates_t<D>>::field();
// cartesian geometry in 1D Euclidean space
template <>
struct cartesian<1> {

// factory for cartesian coordinates
template <int D>
constexpr auto coordinates(mito::tensor::scalar_t (&&coord)[D])
{
return geometry::coordinates<cartesian_coordinates_t<D>>(std::move(coord));
}
// the type of cartesian coordinates in 1D
using coordinates_t = cartesian_coordinates_t<1>;

// the function extracting the 0-th coordinate from a cartesian coordinate set
template <int D>
requires(D > 0)
constexpr auto x_0 = functions::component<cartesian_coordinates_t<D>, 0>;
// the Euclidean metric tensor field
static constexpr auto euclidean_metric =
geometry::euclidean_metric<cartesian_coordinates_t<1>>::field();

// the function extracting the 1-st coordinate from a cartesian coordinate set
template <int D>
requires(D > 1)
constexpr auto x_1 = functions::component<cartesian_coordinates_t<D>, 1>;
// factory for cartesian coordinates
static constexpr auto coordinates(mito::tensor::scalar_t (&&coord)[1])
{
return geometry::coordinates<cartesian_coordinates_t<1>>(std::move(coord));
}

// the function extracting the 2-nd coordinate from a cartesian coordinate set
template <int D>
requires(D > 2)
constexpr auto x_2 = functions::component<cartesian_coordinates_t<D>, 1>;
// the function extracting the 0-th coordinate from a cartesian coordinate set
static constexpr auto x = functions::component<cartesian_coordinates_t<1>, 0>;

// the basis for vector fields (e_0)
template <int D>
requires(D > 0)
constexpr auto e_0 = basis<cartesian_coordinates_t<D>>::template e<0>();
// the basis for vector fields (e_0)
static constexpr auto e_x = basis<cartesian_coordinates_t<1>>::template e<0>();
};

// the basis for vector fields (e_1)
template <int D>
requires(D > 1)
constexpr auto e_1 = basis<cartesian_coordinates_t<D>>::template e<1>();
// cartesian geometry in 2D Euclidean space
template <>
struct cartesian<2> {

// the basis for vector fields (e_2)
template <int D>
requires(D > 2)
constexpr auto e_2 = basis<cartesian_coordinates_t<D>>::template e<2>();
// the type of cartesian coordinates in 2D
using coordinates_t = cartesian_coordinates_t<2>;

// the Euclidean metric tensor field
static constexpr auto euclidean_metric =
geometry::euclidean_metric<cartesian_coordinates_t<2>>::field();

// factory for cartesian coordinates
static constexpr auto coordinates(mito::tensor::scalar_t (&&coord)[2])
{
return geometry::coordinates<cartesian_coordinates_t<2>>(std::move(coord));
}

// the function extracting the 0-th coordinate from a cartesian coordinate set
static constexpr auto x = functions::component<cartesian_coordinates_t<2>, 0>;

// the function extracting the 1-st coordinate from a cartesian coordinate set
static constexpr auto y = functions::component<cartesian_coordinates_t<2>, 1>;

// the basis for vector fields (e_0)
static constexpr auto e_x = basis<cartesian_coordinates_t<2>>::template e<0>();

// the basis for vector fields (e_1)
static constexpr auto e_y = basis<cartesian_coordinates_t<2>>::template e<1>();
};

// cartesian geometry in 3D Euclidean space
template <>
struct cartesian<3> {

// the type of cartesian coordinates in 3D
using coordinates_t = cartesian_coordinates_t<3>;

// the Euclidean metric tensor field
static constexpr auto euclidean_metric =
geometry::euclidean_metric<cartesian_coordinates_t<3>>::field();

// factory for cartesian coordinates
static constexpr auto coordinates(mito::tensor::scalar_t (&&coord)[3])
{
return geometry::coordinates<cartesian_coordinates_t<3>>(std::move(coord));
}

// the function extracting the 0-th coordinate from a cartesian coordinate set
static constexpr auto x = functions::component<cartesian_coordinates_t<3>, 0>;

// the function extracting the 1-st coordinate from a cartesian coordinate set
static constexpr auto y = functions::component<cartesian_coordinates_t<3>, 1>;

// the function extracting the 2-nd coordinate from a cartesian coordinate set
static constexpr auto z = functions::component<cartesian_coordinates_t<3>, 2>;

// the basis for vector fields (e_0)
static constexpr auto e_x = basis<cartesian_coordinates_t<3>>::template e<0>();

// the basis for vector fields (e_1)
static constexpr auto e_y = basis<cartesian_coordinates_t<3>>::template e<1>();

// the basis for vector fields (e_2)
static constexpr auto e_z = basis<cartesian_coordinates_t<3>>::template e<2>();
};
}


Expand Down
34 changes: 19 additions & 15 deletions lib/mito/geometry/polar/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,32 @@
#pragma once


namespace mito::geometry::polar {
namespace mito::geometry {

// polar coordinates
using coordinates_t = polar_coordinates_t;
struct polar {

// the Euclidean metric tensor field
constexpr auto euclidean_metric = geometry::euclidean_metric<polar_coordinates_t>::field();
// polar coordinates
using coordinates_t = polar_coordinates_t;

// factory for polar coordinates
constexpr auto coordinates = &geometry::coordinates<polar_coordinates_t>;
// the Euclidean metric tensor field
static constexpr auto euclidean_metric =
geometry::euclidean_metric<polar_coordinates_t>::field();

// the function extracting the {r} coordinate from a polar coordinate set
constexpr auto r = functions::component<polar_coordinates_t, 0>;
// factory for polar coordinates
static constexpr auto coordinates = &geometry::coordinates<polar_coordinates_t>;

// the function extracting the {theta} coordinate from a polar coordinate set
constexpr auto theta = functions::component<polar_coordinates_t, 1>;
// the function extracting the {r} coordinate from a polar coordinate set
static constexpr auto r = functions::component<polar_coordinates_t, 0>;

// the basis for vector fields (e_r)
constexpr auto e_r = basis<polar_coordinates_t>::template e<0>();
// the function extracting the {theta} coordinate from a polar coordinate set
static constexpr auto theta = functions::component<polar_coordinates_t, 1>;

// the basis for vector fields (e_theta)
constexpr auto e_theta = basis<polar_coordinates_t>::template e<1>();
// the basis for vector fields (e_r)
static constexpr auto e_r = basis<polar_coordinates_t>::template e<0>();

// the basis for vector fields (e_theta)
static constexpr auto e_theta = basis<polar_coordinates_t>::template e<1>();
};

}

Expand Down
42 changes: 23 additions & 19 deletions lib/mito/geometry/spherical/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,38 @@
#pragma once


namespace mito::geometry::spherical {
namespace mito::geometry {

// spherical coordinates
using coordinates_t = spherical_coordinates_t;
struct spherical {

// the Euclidean metric tensor field
constexpr auto euclidean_metric = geometry::euclidean_metric<spherical_coordinates_t>::field();
// spherical coordinates
using coordinates_t = spherical_coordinates_t;

// factory for spherical coordinates
constexpr auto coordinates = &geometry::coordinates<spherical_coordinates_t>;
// the Euclidean metric tensor field
static constexpr auto euclidean_metric =
geometry::euclidean_metric<spherical_coordinates_t>::field();

// the function extracting the {r} coordinate from a spherical coordinate set
constexpr auto r = functions::component<spherical_coordinates_t, 0>;
// factory for spherical coordinates
static constexpr auto coordinates = &geometry::coordinates<spherical_coordinates_t>;

// the function extracting the {theta} coordinate from a spherical coordinate set
constexpr auto theta = functions::component<spherical_coordinates_t, 1>;
// the function extracting the {r} coordinate from a spherical coordinate set
static constexpr auto r = functions::component<spherical_coordinates_t, 0>;

// the function extracting the {phi} coordinate from a spherical coordinate set
constexpr auto phi = functions::component<spherical_coordinates_t, 2>;
// the function extracting the {theta} coordinate from a spherical coordinate set
static constexpr auto theta = functions::component<spherical_coordinates_t, 1>;

// the basis for vector fields (e_r)
constexpr auto e_r = basis<spherical_coordinates_t>::template e<0>();
// the function extracting the {phi} coordinate from a spherical coordinate set
static constexpr auto phi = functions::component<spherical_coordinates_t, 2>;

// the basis for vector fields (e_theta)
constexpr auto e_theta = basis<spherical_coordinates_t>::template e<1>();
// the basis for vector fields (e_r)
static constexpr auto e_r = basis<spherical_coordinates_t>::template e<0>();

// the basis for vector fields (e_phi)
constexpr auto e_phi = basis<spherical_coordinates_t>::template e<2>();
// the basis for vector fields (e_theta)
static constexpr auto e_theta = basis<spherical_coordinates_t>::template e<1>();

// the basis for vector fields (e_phi)
static constexpr auto e_phi = basis<spherical_coordinates_t>::template e<2>();
};

}

Expand Down
6 changes: 3 additions & 3 deletions lib/mito/io/vtk/vtk_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace mito::io::vtk {
const geometry::coordinates_t<3, geometry::SPHERICAL> & coord,
vtkSmartPointer<vtkPoints> & pointsVtk) -> void
{
// cartesian coordinates in 2D
using cartesian_coord_t = mito::geometry::coordinates_t<3, mito::geometry::CARTESIAN>;
// cartesian coordinates in 3D
using cartesian_coord_t = mito::geometry::cartesian<3>::coordinates_t;

// transform {coord} into cartesian coordinates
auto cartesian_coord = transform_coordinates<cartesian_coord_t>(coord);
Expand All @@ -60,7 +60,7 @@ namespace mito::io::vtk {
vtkSmartPointer<vtkPoints> & pointsVtk) -> void
{
// cartesian coordinates in 2D
using cartesian_coord_t = mito::geometry::coordinates_t<2, mito::geometry::CARTESIAN>;
using cartesian_coord_t = mito::geometry::cartesian<2>::coordinates_t;

// transform {coord} into cartesian coordinates
auto cartesian_coord = transform_coordinates<cartesian_coord_t>(coord);
Expand Down
Loading
Loading