Gradient Augmented Levelset Implementation in CPU & GPU
levelset.h (Latest change: Author:Lakshman Anumolu <acrlakshman@yahoo.co.in>, 2019-07-21 16:12:22 -0500, [commit: d791c50])
Go to the documentation of this file.
1 // Copyright 2019 Lakshman Anumolu, Raunak Bardia.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 #pragma once
33 
34 #include <string>
35 #include <vector>
36 
37 #include "gals/utilities/array.h"
38 #include "gals/utilities/grid.h"
39 #include "gals/utilities/vec_n.h"
40 
41 namespace GALS
42 {
43 namespace CPU
44 {
49 template <class T_VECTOR>
51  using T = typename T_VECTOR::value_type;
52 
54  T_VECTOR psi_interpolated;
55 
57  {
58  phi_interpolated = T();
59  psi_interpolated = T_VECTOR();
60  };
61 
63 };
64 
69 template <typename T_GRID, typename T = double>
70 class Levelset
71 {
72  public:
77  Levelset(const T_GRID& grid);
78 
81  Levelset() = delete;
82 
85  ~Levelset();
86 
91  const T_GRID& grid() const { return m_grid; }
92 
97  Array<T_GRID, T>& phi() { return m_phi; }
98 
103  const Array<T_GRID, T>& phi() const { return m_phi; }
104 
109  Array<T_GRID, Vec3<T>>& psi() { return m_psi; }
110 
115  const Array<T_GRID, Vec3<T>>& psi() const { return m_psi; }
116 
122 
128  {
129  return m_phi_mixed_derivatives;
130  }
131 
136  Array<T_GRID, T>& phiPrev() { return m_phi_prev; }
137 
142  const Array<T_GRID, T>& phiPrev() const { return m_phi_prev; }
143 
148  Array<T_GRID, Vec3<T>>& psiPrev() { return m_psi_prev; }
149 
154  const Array<T_GRID, Vec3<T>>& psiPrev() const { return m_psi_prev; }
155 
161  {
162  return m_phi_mixed_derivatives_prev;
163  }
164 
170  {
171  return m_phi_mixed_derivatives_prev;
172  }
173 
178  Array<T_GRID, T>& phiInterpPrev() { return m_phi_interp_prev; }
179 
184  const Array<T_GRID, T>& phiInterpPrev() const { return m_phi_interp_prev; }
185 
190  Array<T_GRID, Vec3<T>>& psiInterpPrev() { return m_psi_interp_prev; }
191 
196  const Array<T_GRID, Vec3<T>>& psiInterpPrev() const { return m_psi_interp_prev; }
197 
199  void print();
200 
201  private:
202  const T_GRID& m_grid;
203  Array<T_GRID, T> m_phi;
204  Array<T_GRID, Vec3<T>> m_psi;
206  Array<T_GRID, T> m_phi_prev;
207  Array<T_GRID, Vec3<T>> m_psi_prev;
209  m_phi_mixed_derivatives_prev;
210  Array<T_GRID, T> m_phi_interp_prev;
211  Array<T_GRID, Vec3<T>> m_psi_interp_prev;
212 };
213 
214 } // namespace CPU
215 } // namespace GALS
const Array< T_GRID, VecN< T, T_GRID::num_mixed_derivatives > > & phiMixedDerivativesPrev() const
Definition: levelset.h:169
Array< T_GRID, T > & phi()
Definition: levelset.h:97
Array< T_GRID, VecN< T, T_GRID::num_mixed_derivatives > > & phiMixedDerivatives()
Definition: levelset.h:121
Array< T_GRID, Vec3< T > > & psiInterpPrev()
Definition: levelset.h:190
Array< T_GRID, VecN< T, T_GRID::num_mixed_derivatives > > & phiMixedDerivativesPrev()
Definition: levelset.h:160
Array< T_GRID, Vec3< T > > & psi()
Definition: levelset.h:109
typename T_VECTOR::value_type T
Definition: levelset.h:51
const Array< T_GRID, VecN< T, T_GRID::num_mixed_derivatives > > & phiMixedDerivatives() const
Definition: levelset.h:127
const T_GRID & grid() const
Definition: levelset.h:91
Array< T_GRID, T > & phiPrev()
Definition: levelset.h:136
Array< T_GRID, Vec3< T > > & psiPrev()
Definition: levelset.h:148
const Array< T_GRID, T > & phi() const
Definition: levelset.h:103
const Array< T_GRID, Vec3< T > > & psi() const
Definition: levelset.h:115
const Array< T_GRID, Vec3< T > > & psiInterpPrev() const
Definition: levelset.h:196
const Array< T_GRID, Vec3< T > > & psiPrev() const
Definition: levelset.h:154
const Array< T_GRID, T > & phiInterpPrev() const
Definition: levelset.h:184
const Array< T_GRID, T > & phiPrev() const
Definition: levelset.h:142
Array< T_GRID, T > & phiInterpPrev()
Definition: levelset.h:178