Skip to content
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 #14

Merged
merged 78 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
2666486
Move some implementations around
peterrum Dec 6, 2020
bb1837f
Create new file for instatiatiosn
peterrum Dec 6, 2020
7e6cf36
Move reinitialization in new files
peterrum Dec 6, 2020
c9edb35
Move implementation of compute_normal
peterrum Dec 6, 2020
8e92794
Move implementation advance_concentration
peterrum Dec 6, 2020
9eb29dd
Move implementation of compute_curvature
peterrum Dec 6, 2020
d356923
Rename variables
peterrum Dec 6, 2020
7472b3e
Introduce composition
peterrum Dec 6, 2020
6b2ee61
Create operators in constructor
peterrum Dec 6, 2020
baa724d
Remove float specialization
peterrum Dec 7, 2020
3a0e12f
Advection: Work on L:d:V
peterrum Dec 7, 2020
ea4da54
Add const
peterrum Dec 7, 2020
657b59a
Rename variables
peterrum Dec 7, 2020
01063d8
Advection: remove triangulation
peterrum Dec 7, 2020
22ad56d
Remove mapping
peterrum Dec 7, 2020
78f3db6
Advection remove fe
peterrum Dec 7, 2020
d5b1221
Introduce LevelSetOKZSolverAdvanceConcentration
peterrum Dec 7, 2020
630a3e5
Introduce VectorType
peterrum Dec 7, 2020
587275a
Extract velocity vectors
peterrum Dec 7, 2020
6bbdab5
Remove ns from advection operator
peterrum Dec 7, 2020
d9ddbef
Reshuffle code
peterrum Dec 7, 2020
16a3545
Make indices parameter
peterrum Dec 7, 2020
906e6d6
(unused) tolerance_val removed from timestepping; comments to member …
mschreter Dec 7, 2020
b46fb9f
make constant time stepping members const
mschreter Dec 7, 2020
9fb43da
Make parameter non-static
peterrum Dec 7, 2020
1929a12
Introduce LevelSetOKZSolverAdvanceConcentrationParameter::time_step_s…
peterrum Dec 7, 2020
3557dd2
Intoduce LevelSetOKZSolverAdvanceConcentrationBoundaryDescriptor
peterrum Dec 7, 2020
b861386
Fix quad index
peterrum Dec 7, 2020
a78a008
Remove timer and user new functions
peterrum Dec 7, 2020
e1395e0
Simplify stabilization code
peterrum Dec 7, 2020
a1a837f
Use iterators
peterrum Dec 7, 2020
31a0990
Set dof and quad indices in ls
peterrum Dec 7, 2020
ee5c9e2
Move constructor
peterrum Dec 7, 2020
47af9cd
Remove cyclic depdendency
peterrum Dec 7, 2020
7c13eb3
temporary constructor in time stepping class introduced; separate tim…
mschreter Dec 7, 2020
f93c92c
Set up LevelSetOKZSolverAdvanceConcentration in constructor
peterrum Dec 7, 2020
ec95ab0
Fix time advance
peterrum Dec 7, 2020
7802eb2
Make fluid type a function
peterrum Dec 7, 2020
a528252
Merg phase type maps
peterrum Dec 7, 2020
052234b
Make artificial_viscosities private
peterrum Dec 7, 2020
3f7769f
Simplify code
peterrum Dec 7, 2020
0818013
Remove ns
peterrum Dec 7, 2020
06a31b2
Sort
peterrum Dec 7, 2020
8e35f6e
Simplify code
peterrum Dec 7, 2020
b9e79e2
Remove timer
peterrum Dec 7, 2020
b631769
Simplify LevelSetOKZSolverComputeCurvature
peterrum Dec 8, 2020
7039ea8
Create vector alias
peterrum Dec 8, 2020
dc8764a
Sort fields
peterrum Dec 8, 2020
393945d
Fix index
peterrum Dec 8, 2020
e98639c
update_ghost_values() in get_maximal_velocity
mschreter Dec 8, 2020
ad4d220
Format file
peterrum Dec 8, 2020
2b90450
Extract quantities from block vector
peterrum Dec 8, 2020
fcf4957
Move implementation of constructor
peterrum Dec 8, 2020
10c9162
Move timer
peterrum Dec 8, 2020
b846aac
Remove ns
peterrum Dec 8, 2020
ae3965d
Inline function
peterrum Dec 8, 2020
a9829f0
Move timer
peterrum Dec 8, 2020
39ea6ce
Extract block components
peterrum Dec 8, 2020
d19360c
Sort variables
peterrum Dec 8, 2020
12ce3a3
Make evaluated_convection and evaluated_normal operator private
peterrum Dec 8, 2020
1606432
Introduce LevelSetOKZSolverReinitializationParameter
peterrum Dec 8, 2020
03b7a9e
Intoruce time stepper in reinit
peterrum Dec 8, 2020
5623f60
Use variables for indices
peterrum Dec 8, 2020
3077de7
Introduce alias
peterrum Dec 8, 2020
bd7ce74
Update comment
peterrum Dec 8, 2020
4bfb6fb
Enable degree_u == 1
peterrum Dec 8, 2020
3d777f2
Move template instantiation
peterrum Dec 8, 2020
c108719
Create mass_matrix_diagonal
peterrum Dec 7, 2020
a2106bf
Pass to mass_matrix_diagonal quad index
peterrum Dec 8, 2020
0b42cdf
WIP
peterrum Dec 8, 2020
a223511
Fix
peterrum Dec 8, 2020
a6cef9b
Move implementation
peterrum Dec 8, 2020
f50a334
Instantiate
peterrum Dec 8, 2020
ba2da63
Generalize indices
peterrum Dec 8, 2020
a1d58ab
Do not use concentration_subdivisions
peterrum Dec 8, 2020
027d894
Remove parameter concentration_subdivisions
peterrum Dec 8, 2020
2bdb64a
Enable simplex in LevelSetOKZSolverAdvanceConcentration
peterrum Dec 8, 2020
775ca44
Fix quadrature rule for simplex in LevelSetOKZSolverAdvanceConcentration
peterrum Dec 8, 2020
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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ DEAL_II_INITIALIZE_CACHED_VARIABLES()

# Set the source files to be compiled
SET( TARGET_SRC
source/level_set_okz_preconditioner.cc
source/level_set_okz_compute_curvature.cc
source/level_set_okz_advance_concentration.cc
source/level_set_okz_compute_normal.cc
source/level_set_okz.cc
source/level_set_okz_reinitialization.cc
source/phase_field.cc
source/phase_field_local.cc
source/navier_stokes_matrix.cc
Expand Down
3 changes: 1 addition & 2 deletions include/adaflo/flow_base_algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ namespace helpers
std::set<types::boundary_id> symmetry;
std::set<types::boundary_id> no_slip;

std::set<types::boundary_id> fluid_type_plus;
std::set<types::boundary_id> fluid_type_minus;
std::map<types::boundary_id, std::shared_ptr<Function<dim>>> fluid_type;

std::pair<types::boundary_id, types::boundary_id> periodic_boundaries[dim];
};
Expand Down
104 changes: 12 additions & 92 deletions include/adaflo/level_set_okz.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

#include <adaflo/diagonal_preconditioner.h>
#include <adaflo/level_set_base.h>

#include <adaflo/level_set_okz_advance_concentration.h>
#include <adaflo/level_set_okz_compute_curvature.h>
#include <adaflo/level_set_okz_compute_normal.h>
#include <adaflo/level_set_okz_reinitialization.h>

using namespace dealii;

Expand All @@ -42,29 +45,6 @@ class LevelSetOKZSolver : public LevelSetBaseAlgorithm<dim>
virtual ~LevelSetOKZSolver()
{}

void
advance_concentration_vmult(
LinearAlgebra::distributed::Vector<double> & dst,
const LinearAlgebra::distributed::Vector<double> &src) const;

void
compute_normal_vmult(LinearAlgebra::distributed::BlockVector<double> & dst,
const LinearAlgebra::distributed::BlockVector<double> &sr) const;

void
compute_normal_vmult(LinearAlgebra::distributed::BlockVector<float> & dst,
const LinearAlgebra::distributed::BlockVector<float> &sr) const;

void
compute_curvature_vmult(LinearAlgebra::distributed::Vector<double> & dst,
const LinearAlgebra::distributed::Vector<double> &srcc,
const bool apply_diffusion) const;

void
reinitialization_vmult(LinearAlgebra::distributed::Vector<double> & dst,
const LinearAlgebra::distributed::Vector<double> &src,
const bool diffuse_only) const;

virtual void
initialize_data_structures();

Expand Down Expand Up @@ -108,63 +88,6 @@ class LevelSetOKZSolver : public LevelSetBaseAlgorithm<dim>
const LinearAlgebra::distributed::Vector<double> &src,
const std::pair<unsigned int, unsigned int> & cell_range);

template <int ls_degree, int velocity_degree>
void
local_advance_concentration(
const MatrixFree<dim, double> & data,
LinearAlgebra::distributed::Vector<double> & dst,
const LinearAlgebra::distributed::Vector<double> &src,
const std::pair<unsigned int, unsigned int> & cell_range) const;

template <int ls_degree, int velocity_degree>
void
local_advance_concentration_rhs(
const MatrixFree<dim, double> & data,
LinearAlgebra::distributed::Vector<double> & dst,
const LinearAlgebra::distributed::Vector<double> &src,
const std::pair<unsigned int, unsigned int> & cell_range);
template <int ls_degree, typename Number>
void
local_compute_normal(const MatrixFree<dim, Number> & data,
LinearAlgebra::distributed::BlockVector<Number> & dst,
const LinearAlgebra::distributed::BlockVector<Number> &src,
const std::pair<unsigned int, unsigned int> &cell_range) const;
template <int ls_degree>
void
local_compute_normal_rhs(const MatrixFree<dim, double> & data,
LinearAlgebra::distributed::BlockVector<double> & dst,
const LinearAlgebra::distributed::Vector<double> &src,
const std::pair<unsigned int, unsigned int> &cell_range) const;

// diffusion_setting: 0: both terms, 1: only mass, 2: only diffusion
template <int ls_degree, int diffusion_setting>
void
local_compute_curvature(const MatrixFree<dim, double> & data,
LinearAlgebra::distributed::Vector<double> & dst,
const LinearAlgebra::distributed::Vector<double> &src,
const std::pair<unsigned int, unsigned int> &cell_range) const;
template <int ls_degree>
void
local_compute_curvature_rhs(
const MatrixFree<dim, double> & data,
LinearAlgebra::distributed::Vector<double> & dst,
const LinearAlgebra::distributed::Vector<double> &src,
const std::pair<unsigned int, unsigned int> & cell_range) const;

template <int ls_degree, bool diffuse_only>
void
local_reinitialize(const MatrixFree<dim, double> & data,
LinearAlgebra::distributed::Vector<double> & dst,
const LinearAlgebra::distributed::Vector<double> &src,
const std::pair<unsigned int, unsigned int> & cell_range) const;

template <int ls_degree, bool diffuse_only>
void
local_reinitialize_rhs(const MatrixFree<dim, double> & data,
LinearAlgebra::distributed::Vector<double> & dst,
const LinearAlgebra::distributed::Vector<double> &src,
const std::pair<unsigned int, unsigned int> & cell_range);

void
local_projection_matrix(
const MatrixFree<dim, double> & data,
Expand All @@ -179,20 +102,17 @@ class LevelSetOKZSolver : public LevelSetBaseAlgorithm<dim>
std::shared_ptr<Threads::ThreadLocalStorage<AssemblyData::Data>> &scratch,
const std::pair<unsigned int, unsigned int> & cell_range);

AlignedVector<VectorizedArray<double>> artificial_viscosities;
AlignedVector<Tensor<1, dim, VectorizedArray<double>>> evaluated_convection;
bool first_reinit_step;
double global_max_velocity;
DiagonalPreconditioner<double> preconditioner;

// In case we can better combine float/double solvers at some point...
MatrixFree<dim, float> matrix_free_float;
AlignedVector<VectorizedArray<float>> cell_diameters_float;
// GrowingVectorMemory<LinearAlgebra::distributed::BlockVector<float> >
// vectors_normal; DiagonalPreconditioner<float> preconditioner_float;
bool first_reinit_step;
double global_max_velocity;
DiagonalPreconditioner<double> preconditioner;

std::shared_ptr<BlockMatrixExtension> projection_matrix;
std::shared_ptr<BlockILUExtension> ilu_projection_matrix;

std::unique_ptr<LevelSetOKZSolverComputeNormal<dim>> normal_operator;
std::unique_ptr<LevelSetOKZSolverComputeCurvature<dim>> curvatur_operator;
std::unique_ptr<LevelSetOKZSolverReinitialization<dim>> reinit_operator;
std::unique_ptr<LevelSetOKZSolverAdvanceConcentration<dim>> advection_operator;
};


Expand Down
183 changes: 183 additions & 0 deletions include/adaflo/level_set_okz_advance_concentration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
// --------------------------------------------------------------------------
//
// Copyright (C) 2020 by the adaflo authors
//
// This file is part of the adaflo library.
//
// The adaflo library is free software; you can use it, redistribute it,
// and/or modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version. The full text of the
// license can be found in the file LICENSE at the top level of the adaflo
// distribution.
//
// --------------------------------------------------------------------------


#ifndef __adaflo_level_set_advance_concentration_h
#define __adaflo_level_set_advance_concentration_h

#include <deal.II/lac/la_parallel_vector.h>

#include <deal.II/matrix_free/matrix_free.h>

#include <adaflo/diagonal_preconditioner.h>
#include <adaflo/navier_stokes.h>
#include <adaflo/time_stepping.h>
#include <adaflo/util.h>

using namespace dealii;

/**
* Parameters of the advection-concentration operator.
*/
struct LevelSetOKZSolverAdvanceConcentrationParameter
{
/**
* TODO
*/
unsigned int dof_index_ls;

/**
* TODO
*/
unsigned int dof_index_vel;

/**
* TODO
*/
unsigned int quad_index;

/**
* TODO
*/
bool convection_stabilization;

/**
* TODO
*/
bool do_iteration;

/**
* TODO
*/
double tol_nl_iteration;

/**
* TODO
*/
TimeSteppingParameters time;
};

/**
* Boundary descriptors of the advection-concentration operator.
*/
template <int dim>
struct LevelSetOKZSolverAdvanceConcentrationBoundaryDescriptor
{
/**
* TODO
*/
std::map<types::boundary_id, std::shared_ptr<Function<dim>>> dirichlet;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/**
* TODO
*/
std::set<types::boundary_id> symmetry;
};

template <int dim>
class LevelSetOKZSolverAdvanceConcentration
{
public:
using VectorType = LinearAlgebra::distributed::Vector<double>;

LevelSetOKZSolverAdvanceConcentration(
VectorType & solution,
const VectorType & solution_old,
const VectorType & solution_old_old,
VectorType & increment,
VectorType & rhs,
const VectorType & vel_solution,
const VectorType & vel_solution_old,
const VectorType & vel_solution_old_old,
const double & global_omega_diameter,
const AlignedVector<VectorizedArray<double>> &cell_diameters,
const AffineConstraints<double> & constraints,
const ConditionalOStream & pcout,
const LevelSetOKZSolverAdvanceConcentrationBoundaryDescriptor<dim> &boundary,
const MatrixFree<dim> & matrix_free,
const LevelSetOKZSolverAdvanceConcentrationParameter & parameters,
double & global_max_velocity,
const DiagonalPreconditioner<double> &preconditioner);

virtual void
advance_concentration(const double dt);

void
advance_concentration_vmult(VectorType &dst, const VectorType &src) const;

private:
template <int ls_degree, int velocity_degree>
void
local_advance_concentration(
const MatrixFree<dim, double> & data,
VectorType & dst,
const VectorType & src,
const std::pair<unsigned int, unsigned int> &cell_range) const;

template <int ls_degree, int velocity_degree>
void
local_advance_concentration_rhs(
const MatrixFree<dim, double> & data,
VectorType & dst,
const VectorType & src,
const std::pair<unsigned int, unsigned int> &cell_range);

/**
* Parameters
*/
const LevelSetOKZSolverAdvanceConcentrationParameter parameters; // [i]

/**
* Vector section
*/
VectorType & solution; // [o] new ls solution
const VectorType &solution_old; // [i] old ls solution
const VectorType &solution_old_old; // [i] old ls solution
VectorType & increment; // [-] temp
VectorType & rhs; // [-] temp

const VectorType &vel_solution; // [i] new velocity solution
const VectorType &vel_solution_old; // [i] old velocity solution
const VectorType &vel_solution_old_old; // [i] old velocity solution

/**
* MatrixFree
*/
const MatrixFree<dim> & matrix_free; // [i]
const AffineConstraints<double> &constraints; // [i]

/**
* Utility
*/
const ConditionalOStream &pcout; // [i]
TimeStepping time_stepping; // [i]

/**
* Physics section
*/
const double & global_omega_diameter; // [i]
const AlignedVector<VectorizedArray<double>> &cell_diameters; // [i]
const LevelSetOKZSolverAdvanceConcentrationBoundaryDescriptor<dim> boundary; // [i]
AlignedVector<VectorizedArray<double>> artificial_viscosities; // [-]
double & global_max_velocity; // [o]
AlignedVector<Tensor<1, dim, VectorizedArray<double>>> evaluated_convection; // [o]

/**
* Solver section
*/
const DiagonalPreconditioner<double> &preconditioner; // [i] preconditioner
};

#endif
Loading