Skip to content

Commit a78e291

Browse files
committed
compute mixed derivatives
* refer #59 Signed-off-by: Lakshman Anumolu <[email protected]>
1 parent 63f4b72 commit a78e291

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ENDIF()
3131

3232
MARK_AS_ADVANCED(BUILD_COVERAGE)
3333

34-
SET(CMAKE_CXX_STANDARD 14)
34+
SET(CMAKE_CXX_STANDARD 17)
3535
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
3636

3737
IF (BUILD_TESTS)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#### Dependencies
1010

1111
* [CMake]
12-
* Compiler that supports C++14
12+
* Compiler that supports C++17
1313

1414
```sh
1515
git clone https://github.com/acrlakshman/gradient-augmented-levelset-cuda --recursive

docs/pages/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Implementation of Gradient Augmented Levelset method in CPU and GPU.
1616
#### Dependencies
1717

1818
* [CMake]
19-
* Compiler that supports C++14
19+
* Compiler that supports C++17
2020

2121
```sh
2222
git clone https://github.com/acrlakshman/gradient-augmented-levelset-cuda --recursive

include/gals/cpu/levelset.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ class Levelset
8484
*/
8585
~Levelset();
8686

87+
/*! Compute mixed derivatives.
88+
*
89+
* Mixed derivatives of the levelset is computed using second order gradient approximation on
90+
* the levelset gradient.
91+
*
92+
* \param psi gradient of levelset.
93+
* \param phi_mixed_derivatives mixed derivatives of the levelset.
94+
*
95+
* \return Void.
96+
*/
97+
void computeMixedDerivatives(const Array<T_GRID, Vec3<T>>& psi,
98+
Array<T_GRID, VecN<T, T_GRID::num_mixed_derivatives>>& phi_mixed_derivatives);
99+
87100
/*! Return grid.
88101
*
89102
* \return grid.

src/cpu/levelset.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
///////////////////////////////////////////////////////////////////////////////
3131

3232
#include "gals/cpu/levelset.h"
33+
#include "gals/cpu/gradient.h"
3334

3435
#include <iostream>
3536

@@ -52,6 +53,32 @@ GALS::CPU::Levelset<T_GRID, T>::~Levelset()
5253
{
5354
}
5455

56+
template <typename T_GRID, typename T>
57+
void GALS::CPU::Levelset<T_GRID, T>::computeMixedDerivatives(
58+
const Array<T_GRID, Vec3<T>>& psi, Array<T_GRID, VecN<T, T_GRID::num_mixed_derivatives>>& phi_mixed_derivatives)
59+
{
60+
// For now gradient computation is hardcoded here.
61+
const Vec3<int> num_cells = psi.numCells();
62+
const T_GRID& grid = psi.grid();
63+
const Vec3<typename T_GRID::value_type> dx = grid.dX();
64+
const auto one_over_dx = grid.oneOverDX();
65+
const auto& axis_vectors = GALS::CPU::Grid<typename T_GRID::value_type, T_GRID::dim>::axis_vectors;
66+
67+
if constexpr (T_GRID::dim == 2) {
68+
int axis_x = 0, axis_y = 1;
69+
70+
for (int i = 0; i < num_cells[0]; ++i)
71+
for (int j = 0; j < num_cells[1]; ++j)
72+
for (int k = 0; k < num_cells[2]; ++k) {
73+
phi_mixed_derivatives(i, j, k)[0] =
74+
(psi(i + axis_vectors(axis_y, 0), j + axis_vectors(axis_y, 1), k + axis_vectors(axis_y, 2))[axis_x] -
75+
psi(i - axis_vectors(axis_y, 0), j - axis_vectors(axis_y, 1), k - axis_vectors(axis_y, 2))[axis_x]) *
76+
one_over_dx[axis_y] * static_cast<T>(0.5);
77+
}
78+
} else if constexpr (T_GRID::dim == 3) {
79+
}
80+
}
81+
5582
template <typename T_GRID, typename T>
5683
void GALS::CPU::Levelset<T_GRID, T>::print()
5784
{

0 commit comments

Comments
 (0)