-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Level set: composition (II) #26
Changes from all commits
b79b3c5
240da41
e5dc601
7496f51
5228896
44dc62d
f3cb70a
e996eb2
97ee84b
3438aff
4d780d5
91fe4a4
91abb20
62cf354
6ee1fb5
20e23b2
fe4f8e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,6 @@ class LevelSetOKZSolverReinitialization | |
using BlockVectorType = LinearAlgebra::distributed::BlockVector<double>; | ||
|
||
LevelSetOKZSolverReinitialization( | ||
LevelSetOKZSolverComputeNormal<dim> & normal_operator, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to pass the normal operator to the constructor. |
||
const BlockVectorType & normal_vector_field, | ||
const AlignedVector<VectorizedArray<double>> & cell_diameters, | ||
const double & epsilon_used, | ||
|
@@ -84,7 +83,6 @@ class LevelSetOKZSolverReinitialization | |
bool & first_reinit_step, | ||
const MatrixFree<dim, double> & matrix_free) | ||
: parameters(parameters) | ||
, normal_operator(normal_operator) | ||
, solution(solution) | ||
, solution_update(solution_update) | ||
, system_rhs(system_rhs) | ||
|
@@ -102,11 +100,11 @@ class LevelSetOKZSolverReinitialization | |
{} | ||
|
||
// performs reinitialization | ||
virtual void | ||
reinitialize(const double dt, | ||
const unsigned int stab_steps, | ||
const unsigned int diff_steps = 0, | ||
const bool diffuse_cells_with_large_curvature_only = false); | ||
void | ||
reinitialize(const double dt, | ||
const unsigned int stab_steps, | ||
const unsigned int diff_steps = 0, | ||
const std::function<void(bool)> &compute_normal = [](const bool) {}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead a lambda with the effect. |
||
|
||
void | ||
reinitialization_vmult(VectorType & dst, | ||
|
@@ -133,11 +131,6 @@ class LevelSetOKZSolverReinitialization | |
*/ | ||
const LevelSetOKZSolverReinitializationParameter parameters; | ||
|
||
/** | ||
* Other operators. | ||
*/ | ||
LevelSetOKZSolverComputeNormal<dim> &normal_operator; | ||
|
||
/** | ||
* Vector section | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
|
||
#include <deal.II/distributed/tria.h> | ||
|
||
#include <deal.II/matrix_free/matrix_free.h> | ||
|
||
using namespace dealii; | ||
|
||
/** | ||
|
@@ -52,4 +54,78 @@ locally_owned_subdomain(const MeshType &mesh) | |
return tria_parallel != nullptr ? tria_parallel->locally_owned_subdomain() : 0; | ||
} | ||
|
||
template <int dim> | ||
void | ||
compute_cell_diameters(const MatrixFree<dim, double> & matrix_free, | ||
const unsigned int dof_index, | ||
AlignedVector<VectorizedArray<double>> &cell_diameters, | ||
double & cell_diameter_min, | ||
double & cell_diameter_max) | ||
Comment on lines
+57
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mschreter FYI :) |
||
{ | ||
cell_diameters.resize(matrix_free.n_cell_batches()); | ||
|
||
cell_diameter_min = std::numeric_limits<double>::max(); | ||
cell_diameter_max = 0.0; | ||
|
||
// to find the cell diameters, we compute the maximum and minimum eigenvalue | ||
// of the Jacobian transformation from the unit to the real cell. We check | ||
// all face centers and the center of the cell and take the respective | ||
// minimum and maximum there to cover most of the cell geometry | ||
std::vector<Point<dim>> face_centers; | ||
{ | ||
Point<dim> center; | ||
for (unsigned int d = 0; d < dim; ++d) | ||
center[d] = 0.5; | ||
for (unsigned int d = 0; d < dim; ++d) | ||
{ | ||
Point<dim> p1 = center; | ||
p1[d] = 0; | ||
face_centers.push_back(p1); | ||
p1[d] = 1.; | ||
face_centers.push_back(p1); | ||
} | ||
face_centers.push_back(center); | ||
} | ||
|
||
const auto &dof_handler = matrix_free.get_dof_handler(dof_index); | ||
const auto &triangulation = dof_handler.get_triangulation(); | ||
|
||
LAPACKFullMatrix<double> mat(dim, dim); | ||
FEValues<dim> fe_values(*matrix_free.get_mapping_info().mapping, | ||
dof_handler.get_fe(), | ||
Quadrature<dim>(face_centers), | ||
update_jacobians); | ||
for (unsigned int cell = 0; cell < matrix_free.n_cell_batches(); ++cell) | ||
{ | ||
VectorizedArray<double> diameter = VectorizedArray<double>(); | ||
for (unsigned int v = 0; v < matrix_free.n_active_entries_per_cell_batch(cell); ++v) | ||
{ | ||
typename DoFHandler<dim>::active_cell_iterator dcell = | ||
matrix_free.get_cell_iterator(cell, v, dof_index); | ||
fe_values.reinit(dcell); | ||
for (unsigned int q = 0; q < fe_values.n_quadrature_points; ++q) | ||
{ | ||
mat = 0; | ||
for (unsigned int d = 0; d < dim; ++d) | ||
for (unsigned int e = 0; e < dim; ++e) | ||
mat(d, e) = fe_values.jacobian(q)[d][e]; | ||
mat.compute_eigenvalues(); | ||
for (unsigned int d = 0; d < dim; ++d) | ||
{ | ||
diameter[v] = std::max(diameter[v], std::abs(mat.eigenvalue(d))); | ||
cell_diameter_min = | ||
std::min(cell_diameter_min, std::abs(mat.eigenvalue(d))); | ||
} | ||
} | ||
if (1U + dcell->level() == triangulation.n_global_levels()) | ||
cell_diameter_max = std::max(diameter[v], cell_diameter_max); | ||
} | ||
cell_diameters[cell] = diameter; | ||
} | ||
cell_diameter_min = | ||
-Utilities::MPI::max(-cell_diameter_min, get_communicator(triangulation)); | ||
cell_diameter_max = | ||
Utilities::MPI::max(cell_diameter_max, get_communicator(triangulation)); | ||
} | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The curvature operator does not need the normal operator anymore.