├── tests ├── sim_rising_bubble.output ├── sim_spurious_currents.output ├── run_test.cmake ├── sharp_interfaces_util.h ├── README ├── poiseuille_stokes.prm ├── poiseuille_ns_proj.prm ├── poiseuille_ns.prm ├── couette.prm ├── beltrami_2d.prm ├── beltrami_2d_proj.prm ├── beltrami_3d.prm ├── beltrami_2d_augp.prm ├── beltrami_2d_augp_proj.prm ├── flow_past_cylinder.prm ├── 1d_flow.prm ├── flow_past_square_cylinder.prm ├── beltrami_3d_augp.prm ├── simplex_channel.prm ├── 1d_flow_damped.prm ├── spurious_currents_ls.prm ├── sim_spurious_currents.prm ├── spurious_currents_pf.prm ├── rising_bubble_ls.prm ├── rising_bubble_ls_q3.prm ├── sim_rising_bubble.prm ├── rising_bubble_ls_adap.prm ├── simplex_bubble.prm ├── rising_bubble_pf.prm ├── spurious_currents_ls_3d.prm ├── rising_bubble_ls_augp.prm ├── phasefield_poiseuille.prm ├── rising_bubble_ls_expl.prm ├── rising_bubble_ls_picard.prm ├── rising_bubble_ls_imex.prm ├── simplex_channel_0.msh ├── poiseuille_stokes.output ├── couette.output ├── spurious_currents_ls_3d.output ├── simplex_bubble_0.msh ├── 1d_flow.cc ├── couette.cc └── sim_rising_bubble.cc ├── .gitignore ├── .github └── workflows │ ├── indentation.yml │ └── tests.yml ├── authors.txt ├── applications ├── drivencavity.prm ├── periodic_channel.prm ├── CMakeLists.txt ├── micro_particle.prm └── micro_particle_node.prm ├── include └── adaflo │ ├── diagonal_preconditioner.h │ ├── level_set_okz_matrix.h │ ├── level_set_okz.h │ ├── level_set_okz_preconditioner.h │ ├── parameters.h │ ├── level_set_okz_compute_normal.h │ ├── phase_field.h │ ├── level_set_okz_compute_curvature.h │ ├── level_set_okz_template_instantations.h │ ├── level_set_base.h │ ├── level_set_okz_reinitialization.h │ ├── level_set_okz_advance_concentration.h │ ├── block_matrix_extension.h │ └── util.h ├── todo.txt ├── CMakeLists.txt ├── source └── diagonal_preconditioner.cc ├── .clang-format └── README.md /tests/sim_rising_bubble.output: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/sim_spurious_currents.output: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/CMakeCache.txt 2 | **/CMakeFiles 3 | **/Makefile 4 | libadaflo.* 5 | **/CTestTestfile.cmake 6 | **/cmake_install.cmake 7 | *~ 8 | applications/drivencavity 9 | applications/micro_particle 10 | applications/periodic_channel 11 | tests/beltrami 12 | tests/flow_past_cylinder 13 | tests/phasefield_poiseuille 14 | tests/poiseuille 15 | tests/rising_bubble 16 | tests/spurious_currents 17 | tests/output-* 18 | Testing/ 19 | -------------------------------------------------------------------------------- /tests/run_test.cmake: -------------------------------------------------------------------------------- 1 | EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} 2 | --build ${BINARY_DIR} --target ${TESTNAME}.diff 3 | RESULT_VARIABLE _result_code 4 | OUTPUT_VARIABLE _output 5 | ) 6 | 7 | IF("${_result_code}" STREQUAL "0") 8 | MESSAGE("${TESTNAME}: success.") 9 | 10 | ELSE() 11 | 12 | MESSAGE("*** ${ERROR}: ***") 13 | MESSAGE(${_output}) 14 | MESSAGE(FATAL_ERROR "*** Test aborted.") 15 | ENDIF() 16 | -------------------------------------------------------------------------------- /.github/workflows/indentation.yml: -------------------------------------------------------------------------------- 1 | name: Indent 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | - uses: DoozyX/clang-format-lint-action@v0.16.2 18 | with: 19 | source: '.' 20 | exclude: '' 21 | extensions: 'h,cc' 22 | clangFormatVersion: 16 23 | inplace: true 24 | - run: | 25 | git diff 26 | git diff-files --quiet || exit $? 27 | -------------------------------------------------------------------------------- /tests/sharp_interfaces_util.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2021 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | #include 17 | -------------------------------------------------------------------------------- /authors.txt: -------------------------------------------------------------------------------- 1 | AUTHORS of ADAFLO 2 | 3 | Martin Kronbichler 4 | (2008-2012: Uppsala University) 5 | (2013-: Technical University of Munich 6 | Main author, contributed Navier-Stokes solver, level set solver, phase field 7 | solver, matrix-free implementation of matrix-vector products in solvers, 8 | preconditioners 9 | 10 | Ababacar Diagne 11 | (2012-2016: Uppsala University) 12 | Modular extension of level set framework (together with M. Kronbichler), 13 | MPI parallelization of program (together with M. Kronbichler), 14 | Adaptive time stepping based on bubble velocity 15 | 16 | Hanna Holmgren 17 | (2013-2018: Uppsala University) 18 | Many bug fixes in level set part, initial support for moving contact lines 19 | 20 | Peter Munch 21 | (2020-: Technical University of Munich) 22 | Modularity and additional functionality of level set algorithms, a large 23 | number of cleanups, adaptations to evolution in deal.II library 24 | 25 | Magdalena Schreter 26 | (2020-: Universität Innsbruck) 27 | Modularity and additional functionality of level set algorithms 28 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: GitHub CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | schedule: 9 | - cron: '0 0 * * *' 10 | 11 | concurrency: 12 | group: ${ {github.event_name }}-${{ github.workflow }}-${{ github.ref }} 13 | cancel-in-progress: ${{github.event_name == 'pull_request'}} 14 | 15 | env: 16 | COMPILE_JOBS: 2 17 | 18 | jobs: 19 | build: 20 | name: Build ${{ matrix.build_type }}-dealii:${{ matrix.dealii_version }} 21 | runs-on: ubuntu-latest 22 | 23 | strategy: 24 | fail-fast: false 25 | matrix: 26 | build_type: ["Release", "Debug"] 27 | dealii_version: ["master"] 28 | 29 | container: 30 | image: dealii/dealii:${{ matrix.dealii_version }}-focal 31 | options: --user root 32 | 33 | steps: 34 | - uses: actions/checkout@v2 35 | 36 | - name: Compile 37 | run: | 38 | mkdir build 39 | cd build 40 | cmake ../ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} 41 | make -j${{ env.COMPILE_JOBS }} 42 | 43 | -------------------------------------------------------------------------------- /applications/drivencavity.prm: -------------------------------------------------------------------------------- 1 | # $Id: beltrami_3d.prm 283 2014-09-04 11:33:56Z martinkr $ 2 | # 3 | # Listing of Parameters 4 | # 5 | subsection Time stepping 6 | set step size = 0.01 7 | end 8 | subsection Navier-Stokes 9 | set physical type = incompressible stationary 10 | set dimension = 3 11 | set global refinements = 40 12 | set adaptive refinements = 0 13 | set velocity degree = 3 14 | set viscosity = 0.01 15 | subsection Solver 16 | set linearization scheme = coupled implicit Newton 17 | set NL max iterations = 40 18 | set NL tolerance = 1.e-12 19 | set lin max iterations = 30 20 | set lin tolerance = 1.e-5 21 | set tau grad div = 0.0 22 | set lin pressure mass preconditioner = diagonal 23 | set lin velocity preconditioner = amg linear 24 | set lin its before inner solvers = 50 25 | end 26 | end 27 | subsection Output options 28 | set output filename = output_cavity/dat 29 | set output verbosity = 3 30 | set output frequency = 2 31 | set output vtk files = 1 32 | end 33 | -------------------------------------------------------------------------------- /applications/periodic_channel.prm: -------------------------------------------------------------------------------- 1 | # $Id: beltrami_3d.prm 283 2014-09-04 11:33:56Z martinkr $ 2 | # 3 | # Listing of Parameters 4 | # 5 | subsection Time stepping 6 | set step size = 0.1 7 | set end time = 1000 8 | end 9 | subsection Navier-Stokes 10 | set physical type = incompressible 11 | set dimension = 3 12 | set global refinements = 32 13 | set adaptive refinements = 0 14 | set velocity degree = 3 15 | set viscosity = 0.001472 16 | subsection Solver 17 | set linearization scheme = coupled velocity semi-implicit 18 | set NL max iterations = 3 19 | set NL tolerance = 1.e-4 20 | set lin max iterations = 50 21 | set lin tolerance = 1.e-5 22 | set tau grad div = 1 23 | set lin pressure mass preconditioner = diagonal 24 | set lin velocity preconditioner = amg linear 25 | set lin its before inner solvers = 50 26 | end 27 | end 28 | subsection Output options 29 | set output filename = output/channel 30 | set output verbosity = 3 31 | set output frequency = 10 32 | set output vtk files = 1 33 | end 34 | -------------------------------------------------------------------------------- /tests/README: -------------------------------------------------------------------------------- 1 | To create new tests in adaflo, consider the following hints: 2 | 3 | 1. You add a new source file named "test_me.cc" 4 | 2. You add one or more parameter files that test various aspects while running the code compiled by "test_me.cc". The parameter files need to start with the same string and can then extend over that. The extension must be .prm. These parameter files determine the actual name of the test, TEST_NAME. If you want to associate two parameter files, you can name them e.g. "test_me_1.prm" and "test_me_2.prm". 5 | 3. To each parameter file, add a text file with the same name as the parameter file and .output extension, e.g. "test_me_1.output" and "test_me_2.output", that show the expected output from the test. We currently only test for the output we obtain. 6 | 7 | 8 | When making changes to the code, make sure to run the tests to see whether you change functionality. If you change functionality and have verified that the new output is 'more correct' or 'more appropriate', copy the output of the test, typically found in output-TEST_NAME/screen-output after running the test, to the file TEST_NAME.output 9 | 10 | When adding new files, these might not always be detected by cmake. Run "cmake" in the adaflo base directory to re-create a list of tests. 11 | -------------------------------------------------------------------------------- /applications/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | 16 | PROJECT(adaflo_examples) 17 | 18 | INCLUDE_DIRECTORIES( 19 | include 20 | ${CMAKE_SOURCE_DIR}/include 21 | ) 22 | 23 | SET( SOURCE_FILES 24 | micro_particle.cc 25 | drivencavity.cc 26 | periodic_channel.cc 27 | ) 28 | 29 | FOREACH ( sourcefile ${SOURCE_FILES} ) 30 | # string replace: cut off .cc from files 31 | STRING( REPLACE ".cc" "" testname ${sourcefile} ) 32 | ADD_EXECUTABLE( ${testname} ${sourcefile}) 33 | DEAL_II_SETUP_TARGET(${testname}) 34 | TARGET_LINK_LIBRARIES(${testname} adaflo) 35 | ENDFOREACH ( sourcefile ${APP_SOURCES} ) 36 | -------------------------------------------------------------------------------- /tests/poiseuille_stokes.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # 16 | # Listing of Parameters 17 | subsection Navier-Stokes 18 | set physical type = stokes 19 | set dimension = 2 20 | set global refinements = 6 21 | set velocity degree = 2 22 | set viscosity = 0.1 23 | subsection Solver 24 | set linearization scheme = coupled implicit Newton 25 | set NL max iterations = 10 26 | set NL tolerance = 1.e-12 27 | set lin max iterations = 50 28 | set lin tolerance = 1.e-5 29 | set lin relative tolerance = 1 30 | set lin velocity preconditioner = amg linear 31 | set lin its before inner solvers = 50 32 | end 33 | end 34 | subsection Output options 35 | set output verbosity = 2 36 | set output filename = output-poiseuille_stokes/data 37 | end 38 | -------------------------------------------------------------------------------- /tests/poiseuille_ns_proj.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # 16 | # Listing of Parameters 17 | subsection Time stepping 18 | set end time = 20 19 | set step size = 0.1 20 | end 21 | subsection Navier-Stokes 22 | set physical type = incompressible 23 | set dimension = 2 24 | set global refinements = 4 25 | set velocity degree = 2 26 | set viscosity = 0.5 27 | subsection Solver 28 | set linearization scheme = projection 29 | set NL max iterations = 10 30 | set NL tolerance = 1.e-12 31 | set lin max iterations = 50 32 | set lin tolerance = 1.e-5 33 | set lin relative tolerance = 1 34 | set lin velocity preconditioner = amg 35 | set lin its before inner solvers = 50 36 | end 37 | end 38 | subsection Output options 39 | set output verbosity = 2 40 | set output vtk files = 1 41 | set output filename = output-poiseuille_ns_proj/data 42 | end 43 | -------------------------------------------------------------------------------- /tests/poiseuille_ns.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # 16 | # Listing of Parameters 17 | subsection Time stepping 18 | set end time = 20 19 | set step size = 0.5 20 | end 21 | subsection Navier-Stokes 22 | set physical type = incompressible 23 | set dimension = 2 24 | set global refinements = 4 25 | set velocity degree = 2 26 | set viscosity = 0.5 27 | subsection Solver 28 | set linearization scheme = coupled implicit Newton 29 | set NL max iterations = 10 30 | set NL tolerance = 1.e-12 31 | set lin max iterations = 50 32 | set lin tolerance = 1.e-5 33 | set lin relative tolerance = 1 34 | set lin velocity preconditioner = amg 35 | set lin its before inner solvers = 50 36 | end 37 | end 38 | subsection Output options 39 | set output verbosity = 2 40 | set output vtk files = 0 41 | set output filename = output-poiseuille_ns/data 42 | end 43 | -------------------------------------------------------------------------------- /tests/couette.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # 16 | # Listing of Parameters 17 | subsection Time stepping 18 | set end time = 1.0 19 | set step size = 0.5 20 | end 21 | subsection Navier-Stokes 22 | set physical type = incompressible 23 | set dimension = 2 24 | set global refinements = 4 25 | set velocity degree = 2 26 | set viscosity = 0.5 27 | subsection Solver 28 | set linearization scheme = coupled implicit Newton 29 | set NL max iterations = 10 30 | set NL tolerance = 1.e-12 31 | set lin max iterations = 50 32 | set lin tolerance = 1.e-5 33 | set lin relative tolerance = 1 34 | set lin velocity preconditioner = amg 35 | set lin its before inner solvers = 50 36 | end 37 | end 38 | subsection Output options 39 | set output verbosity = 2 40 | set output frequency = 0.5 41 | set output vtk files = 1 42 | set output filename = output-couette/data 43 | end 44 | -------------------------------------------------------------------------------- /tests/beltrami_2d.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | subsection Time stepping 17 | set scheme = bdf_2 18 | set end time = 0.4 19 | set step size = 0.01 20 | end 21 | subsection Navier-Stokes 22 | set dimension = 2 23 | set global refinements = 4 24 | set velocity degree = 4 25 | set viscosity = 1 26 | subsection Solver 27 | set linearization scheme = coupled implicit Newton 28 | set NL max iterations = 10 29 | set NL tolerance = 1.e-9 30 | set lin max iterations = 30 31 | set lin tolerance = 1.e-5 32 | set tau grad div = 0.0 33 | set lin pressure mass preconditioner = diagonal 34 | set lin velocity preconditioner = amg linear 35 | set lin its before inner solvers = 50 36 | end 37 | end 38 | subsection Output options 39 | set output verbosity = 3 40 | set output filename = output-beltrami_2d/data 41 | set output frequency = 0.04 42 | set output vtk files = 0 43 | end 44 | -------------------------------------------------------------------------------- /tests/beltrami_2d_proj.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | subsection Time stepping 17 | set scheme = bdf_2 18 | set end time = 0.3 19 | set step size = 0.01 20 | end 21 | subsection Navier-Stokes 22 | set dimension = 2 23 | set global refinements = 4 24 | set velocity degree = 3 25 | set viscosity = 0.1 26 | subsection Solver 27 | set linearization scheme = projection 28 | set NL max iterations = 10 29 | set NL tolerance = 1.e-9 30 | set lin max iterations = 50 31 | set lin tolerance = 1.e-5 32 | set tau grad div = 0.0 33 | set lin pressure mass preconditioner = diagonal 34 | set lin velocity preconditioner = amg linear 35 | set lin its before inner solvers = 50 36 | end 37 | end 38 | subsection Output options 39 | set output verbosity = 3 40 | set output filename = output-beltrami_2d_proj/data 41 | set output frequency = 0.01 42 | set output vtk files = 0 43 | end 44 | -------------------------------------------------------------------------------- /tests/beltrami_3d.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 3 18 | subsection Time stepping 19 | set scheme = bdf_2 20 | set end time = 1 21 | set step size = 0.05 22 | end 23 | subsection Navier-Stokes 24 | set dimension = 3 25 | set global refinements = 3 26 | set velocity degree = 2 27 | set viscosity = 1 28 | subsection Solver 29 | set linearization scheme = coupled implicit Newton 30 | set NL max iterations = 10 31 | set NL tolerance = 1.e-9 32 | set lin max iterations = 30 33 | set lin tolerance = 1.e-5 34 | set tau grad div = 0.0 35 | set lin pressure mass preconditioner = diagonal 36 | set lin velocity preconditioner = ilu scalar 37 | set lin its before inner solvers = 50 38 | end 39 | end 40 | subsection Output options 41 | set output filename = output-beltrami_3d/data 42 | set output verbosity = 3 43 | set output frequency = 0.2 44 | set output vtk files = 0 45 | end 46 | -------------------------------------------------------------------------------- /applications/micro_particle.prm: -------------------------------------------------------------------------------- 1 | # $Id: static_bubble.prm -1 $ 2 | # 3 | # Listing of Parameters 4 | # --------------------- 5 | # 6 | subsection Problem-specific 7 | set two-phase method = level set okz 8 | end 9 | subsection Two phase 10 | set density = 30 11 | set density difference = 90 12 | set viscosity = 10 13 | set viscosity difference = 90 14 | set surface tension = 100 15 | set epsilon = 2 16 | set gravity = 0.98 17 | set concentration subdivisions = 3 18 | set grad pressure compatible = 1 19 | set localize surface tension = 1 20 | set curvature correction = 1 21 | set number reinit steps = 3 22 | set number initial reinit steps = 0 23 | end 24 | subsection Time stepping 25 | set scheme = bdf_2 26 | set end time = 1 27 | set step size = 0.0002 28 | set max step size = 0.001 29 | set min step size = 0.0002 30 | set CFL number = 0.85 31 | set CFL number capillary = 1 32 | end 33 | subsection Navier-Stokes 34 | set dimension = 3 35 | set global refinements = 1 36 | set adaptive refinements = 1 37 | set velocity degree = 2 38 | set augmented Taylor-Hood elements = 0 39 | subsection Solver 40 | set NL max iterations = 20 41 | set NL tolerance = 1.e-7 42 | set lin max iterations = 30 43 | set lin tolerance = 1.e-4 44 | set lin velocity preconditioner = amg linear 45 | set lin its before inner solvers = 50 46 | end 47 | end 48 | subsection Output options 49 | set output filename = output/micro_particle 50 | set output verbosity = 1 51 | set output frequency = 0.01 52 | set output vtk files = 1 53 | end 54 | -------------------------------------------------------------------------------- /applications/micro_particle_node.prm: -------------------------------------------------------------------------------- 1 | # $Id: static_bubble.prm -1 $ 2 | # 3 | # Listing of Parameters 4 | # --------------------- 5 | # 6 | subsection Problem-specific 7 | set two-phase method = level set okz 8 | end 9 | subsection Two phase 10 | set density = 30 11 | set density difference = 270 12 | set viscosity = 20 13 | set viscosity difference = 380 14 | set surface tension = 100 15 | set epsilon = 2 16 | set gravity = 0.98 17 | set concentration subdivisions = 3 18 | set grad pressure compatible = 1 19 | set localize surface tension = 1 20 | set curvature correction = 1 21 | set number reinit steps = 3 22 | set number initial reinit steps = 0 23 | end 24 | subsection Time stepping 25 | set scheme = bdf_2 26 | set end time = 1.65 27 | set step size = 0.0001 28 | set max step size = 0.008 29 | set min step size = 0.0002 30 | set CFL number = 0.85 31 | set CFL number capillary = 1 32 | end 33 | subsection Navier-Stokes 34 | set dimension = 3 35 | set global refinements = 1 36 | set adaptive refinements = 2 37 | set velocity degree = 2 38 | set augmented Taylor-Hood elements = 0 39 | subsection Solver 40 | set NL max iterations = 25 41 | set NL tolerance = 1.e-6 42 | set lin max iterations = 30 43 | set lin tolerance = 1.e-4 44 | set lin velocity preconditioner = ilu 45 | set lin its before inner solvers = 50 46 | end 47 | end 48 | subsection Output options 49 | set output filename = output/micro_particle 50 | set output verbosity = 1 51 | set output frequency = 0.01 52 | set output vtk files = 1 53 | end 54 | -------------------------------------------------------------------------------- /tests/beltrami_2d_augp.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | subsection Time stepping 17 | set scheme = bdf_2 18 | set end time = 0.2 19 | set step size = 0.01 20 | end 21 | subsection Navier-Stokes 22 | set dimension = 2 23 | set global refinements = 4 24 | set velocity degree = 4 25 | set augmented Taylor-Hood elements = 1 26 | set viscosity = 1 27 | subsection Solver 28 | set linearization scheme = coupled implicit Newton 29 | set NL max iterations = 10 30 | set NL tolerance = 1.e-9 31 | set lin max iterations = 30 32 | set lin tolerance = 1.e-5 33 | set tau grad div = 0.0 34 | set lin pressure mass preconditioner = ilu 35 | set lin velocity preconditioner = amg 36 | set lin its before inner solvers = 50 37 | end 38 | end 39 | subsection Output options 40 | set output verbosity = 1 41 | set output filename = output-beltrami_2d_augp/data 42 | set output vtk files = 0 43 | set output frequency = 0.04 44 | end 45 | -------------------------------------------------------------------------------- /tests/beltrami_2d_augp_proj.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # mpirun: 3 17 | subsection Time stepping 18 | set scheme = bdf_2 19 | set end time = 0.2 20 | set step size = 0.01 21 | end 22 | subsection Navier-Stokes 23 | set dimension = 2 24 | set global refinements = 4 25 | set velocity degree = 2 26 | set augmented Taylor-Hood elements = 1 27 | set viscosity = 1 28 | subsection Solver 29 | set linearization scheme = projection 30 | set NL max iterations = 10 31 | set NL tolerance = 1.e-9 32 | set lin max iterations = 30 33 | set lin tolerance = 1.e-5 34 | set tau grad div = 0.0 35 | set lin pressure mass preconditioner = ilu 36 | set lin velocity preconditioner = amg 37 | set lin its before inner solvers = 50 38 | end 39 | end 40 | subsection Output options 41 | set output verbosity = 3 42 | set output filename = output-beltrami_2d_augp/data 43 | set output vtk files = 0 44 | set output frequency = 0.04 45 | end 46 | -------------------------------------------------------------------------------- /tests/flow_past_cylinder.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | subsection Time stepping 17 | set scheme = bdf_2 18 | set end time = 5. 19 | set step size = 0.02 20 | end 21 | subsection Navier-Stokes 22 | set physical type = incompressible 23 | set dimension = 2 24 | set global refinements = 2 25 | set velocity degree = 3 26 | set viscosity = 0.005 27 | subsection Solver 28 | set linearization scheme = coupled implicit Newton 29 | set NL max iterations = 10 30 | set NL tolerance = 1.e-9 31 | set lin max iterations = 30 32 | set lin tolerance = 1.e-5 33 | set lin relative tolerance = 1 34 | set lin velocity preconditioner = ilu scalar 35 | set lin pressure mass preconditioner = ilu 36 | set lin its before inner solvers = 30 37 | end 38 | end 39 | subsection Output options 40 | set output verbosity = 2 41 | set output frequency = 1 42 | set output filename = output-flow_past_cylinder/data 43 | set output vtk files = 0 44 | end 45 | -------------------------------------------------------------------------------- /tests/1d_flow.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | subsection Time stepping 17 | set scheme = bdf_2 18 | set end time = 1 19 | set step size = 0.01 20 | end 21 | subsection Navier-Stokes 22 | set physical type = incompressible 23 | set dimension = 1 24 | set velocity degree = 2 25 | set density = 1.0 26 | set viscosity = 0.01 27 | subsection Solver 28 | set linearization scheme = coupled implicit Newton 29 | set NL max iterations = 10 30 | set NL tolerance = 1.e-9 31 | set lin max iterations = 30 32 | set lin tolerance = 1.e-5 33 | set lin relative tolerance = 1 34 | set lin velocity preconditioner = ilu scalar 35 | set lin pressure mass preconditioner = ilu 36 | set lin its before inner solvers = 30 37 | set tau grad div = 1.e-5 38 | end 39 | end 40 | subsection Output options 41 | set output verbosity = 2 42 | set output frequency = 0.02 43 | set output filename = output-1d_flow/data 44 | set output vtk files = 1 45 | end 46 | -------------------------------------------------------------------------------- /tests/flow_past_square_cylinder.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | subsection Time stepping 17 | set scheme = bdf_2 18 | set end time = 8. 19 | set step size = 0.05 20 | end 21 | subsection Navier-Stokes 22 | set physical type = incompressible 23 | set dimension = 3 24 | set global refinements = 0 25 | set velocity degree = 2 26 | set viscosity = 0.001 27 | subsection Solver 28 | set linearization scheme = coupled implicit Newton 29 | set NL max iterations = 10 30 | set NL tolerance = 1.e-9 31 | set lin max iterations = 30 32 | set lin tolerance = 1.e-5 33 | set lin relative tolerance = 1 34 | set lin velocity preconditioner = ilu scalar 35 | set lin pressure mass preconditioner = ilu 36 | set lin its before inner solvers = 30 37 | end 38 | end 39 | subsection Output options 40 | set output verbosity = 2 41 | set output frequency = 1 42 | set output filename = output-flow_past_square_cylinder/data 43 | set output vtk files = 1 44 | end 45 | -------------------------------------------------------------------------------- /tests/beltrami_3d_augp.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 3 18 | subsection Time stepping 19 | set scheme = bdf_2 20 | set end time = 0.5 21 | set step size = 0.05 22 | end 23 | subsection Navier-Stokes 24 | set dimension = 3 25 | set global refinements = 2 26 | set velocity degree = 2 27 | set augmented Taylor-Hood elements = 1 28 | set viscosity = 1 29 | subsection Solver 30 | set linearization scheme = coupled implicit Newton 31 | set NL max iterations = 10 32 | set NL tolerance = 1.e-9 33 | set lin max iterations = 30 34 | set lin tolerance = 1.e-5 35 | set tau grad div = 0.0 36 | set lin pressure mass preconditioner = diagonal 37 | set lin velocity preconditioner = amg linear 38 | set lin its before inner solvers = 50 39 | end 40 | end 41 | subsection Output options 42 | set output filename = output-beltrami_3d/data 43 | set output verbosity = 3 44 | set output frequency = 0.2 45 | set output vtk files = 0 46 | end 47 | -------------------------------------------------------------------------------- /tests/simplex_channel.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2020 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | subsection Time stepping 17 | set scheme = bdf_2 18 | set end time = 5. 19 | set step size = 0.02 20 | end 21 | subsection Navier-Stokes 22 | set physical type = incompressible 23 | set dimension = 2 24 | set global refinements = 2 25 | set velocity degree = 2 26 | set viscosity = 0.005 27 | set simplex mesh = 1 28 | subsection Solver 29 | set linearization scheme = coupled implicit Newton 30 | set NL max iterations = 10 31 | set NL tolerance = 1.e-9 32 | set lin max iterations = 30 33 | set lin tolerance = 1.e-5 34 | set lin relative tolerance = 1 35 | set lin velocity preconditioner = ilu scalar 36 | set lin pressure mass preconditioner = ilu 37 | set lin its before inner solvers = 30 38 | end 39 | end 40 | subsection Output options 41 | set output verbosity = 2 42 | set output frequency = 1 43 | set output filename = output-simplex_channel/data 44 | set output vtk files = 0 45 | end 46 | -------------------------------------------------------------------------------- /tests/1d_flow_damped.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | subsection Time stepping 17 | set scheme = bdf_2 18 | set end time = 1 19 | set step size = 0.01 20 | end 21 | subsection Navier-Stokes 22 | set physical type = incompressible 23 | set dimension = 1 24 | set velocity degree = 2 25 | set density = 1.0 26 | set viscosity = 0.01 27 | set damping = 0.01 28 | subsection Solver 29 | set linearization scheme = coupled implicit Newton 30 | set NL max iterations = 10 31 | set NL tolerance = 1.e-9 32 | set lin max iterations = 30 33 | set lin tolerance = 1.e-5 34 | set lin relative tolerance = 1 35 | set lin velocity preconditioner = ilu scalar 36 | set lin pressure mass preconditioner = ilu 37 | set lin its before inner solvers = 30 38 | set tau grad div = 1.e-5 39 | end 40 | end 41 | subsection Output options 42 | set output verbosity = 2 43 | set output frequency = 0.02 44 | set output filename = output-1d_flow_damped/data 45 | set output vtk files = 1 46 | end 47 | -------------------------------------------------------------------------------- /tests/spurious_currents_ls.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | subsection Problem-specific 18 | set two-phase method = level set okz 19 | end 20 | subsection Two phase 21 | set density = 1. 22 | set density difference = 0. 23 | set viscosity = 0.1 24 | set viscosity difference = 0 25 | set surface tension = 1.0 26 | set epsilon = 1.5 27 | set gravity = 0. 28 | set concentration subdivisions = 3 29 | set grad pressure compatible = 1 30 | set localize surface tension = 1 31 | set curvature correction = 1 32 | set number reinit steps = 2 33 | set number initial reinit steps = 0 34 | end 35 | subsection Time stepping 36 | set scheme = bdf_2 37 | set end time = 0.3 38 | set step size = 0.01 39 | end 40 | subsection Navier-Stokes 41 | set dimension = 2 42 | set global refinements = 80 43 | set adaptive refinements = 0 44 | set velocity degree = 2 45 | subsection Solver 46 | set NL max iterations = 10 47 | set NL tolerance = 1.e-9 48 | set lin max iterations = 500 49 | set lin tolerance = 1.e-6 50 | set lin its before inner solvers = 50 51 | end 52 | end 53 | subsection Output options 54 | set output filename = output-spurious_currents_ls/data 55 | set output verbosity = 1 56 | set output frequency = 0.01 57 | set output vtk files = 1 58 | end 59 | -------------------------------------------------------------------------------- /tests/sim_spurious_currents.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 2 18 | subsection Problem-specific 19 | set two-phase method = sharp level set 20 | end 21 | subsection Two phase 22 | set density = 1. 23 | set density difference = 0. 24 | set viscosity = 0.1 25 | set viscosity difference = 0 26 | set surface tension = 1.0 27 | set epsilon = 1.5 28 | set gravity = 0. 29 | set concentration subdivisions = 3 30 | set grad pressure compatible = 1 31 | set localize surface tension = 1 32 | set curvature correction = 1 33 | set number reinit steps = 2 34 | set number initial reinit steps = 0 35 | end 36 | subsection Time stepping 37 | set scheme = bdf_2 38 | set end time = 0.3 39 | set step size = 0.01 40 | end 41 | subsection Navier-Stokes 42 | set dimension = 2 43 | set global refinements = 80 44 | set adaptive refinements = 0 45 | set velocity degree = 2 46 | subsection Solver 47 | set NL max iterations = 10 48 | set NL tolerance = 1.e-9 49 | set lin max iterations = 500 50 | set lin tolerance = 1.e-6 51 | set lin its before inner solvers = 50 52 | end 53 | end 54 | subsection Output options 55 | set output filename = output-sharp_interfaces_06/data 56 | set output verbosity = 1 57 | set output frequency = 0.01 58 | set output vtk files = 1 59 | end -------------------------------------------------------------------------------- /tests/spurious_currents_pf.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | subsection Problem-specific 18 | set two-phase method = phase field 19 | end 20 | subsection Two phase 21 | set density = 1. 22 | set density difference = 0. 23 | set viscosity = 0.1 24 | set viscosity difference = 0 25 | set surface tension = 1.0 26 | set epsilon = 1.5 27 | set diffusion length = 0.1 28 | set gravity = 0. 29 | set concentration subdivisions = 1 30 | set grad pressure compatible = 1 31 | set localize surface tension = 1 32 | set curvature correction = 1 33 | set number reinit steps = 2 34 | set number initial reinit steps = 0 35 | end 36 | subsection Time stepping 37 | set scheme = bdf_2 38 | set end time = 0.3 39 | set step size = 0.01 40 | end 41 | subsection Navier-Stokes 42 | set dimension = 2 43 | set global refinements = 80 44 | set adaptive refinements = 0 45 | set velocity degree = 2 46 | subsection Solver 47 | set NL max iterations = 10 48 | set NL tolerance = 1.e-9 49 | set lin max iterations = 500 50 | set lin tolerance = 1.e-6 51 | set lin its before inner solvers = 50 52 | end 53 | end 54 | subsection Output options 55 | set output filename = output-spurious_currents_pf/data 56 | set output verbosity = 1 57 | set output frequency = 0.05 58 | set output vtk files = 0 59 | end 60 | -------------------------------------------------------------------------------- /tests/rising_bubble_ls.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 2 18 | subsection Problem-specific 19 | set two-phase method = level set okz 20 | end 21 | subsection Two phase 22 | set density = 1. 23 | set density difference = -0.9 24 | set viscosity = 0.01 25 | set viscosity difference = -0.009 26 | set surface tension = 0.0245 27 | set epsilon = 1.5 28 | set gravity = 0.98 29 | set concentration subdivisions = 4 30 | set grad pressure compatible = 1 31 | set localize surface tension = 1 32 | set curvature correction = 1 33 | set number reinit steps = 2 34 | set number initial reinit steps = 2 35 | end 36 | subsection Time stepping 37 | set scheme = bdf_2 38 | set end time = 1 39 | set step size = 0.02 40 | end 41 | subsection Navier-Stokes 42 | set dimension = 2 43 | set global refinements = 3 44 | set adaptive refinements = 0 45 | set velocity degree = 2 46 | subsection Solver 47 | set NL max iterations = 10 48 | set NL tolerance = 1.e-9 49 | set lin max iterations = 30 50 | set lin tolerance = 1.e-4 51 | set lin velocity preconditioner = ilu 52 | set lin its before inner solvers = 50 53 | end 54 | end 55 | subsection Output options 56 | set output filename = output-rising_bubble_ls/data 57 | set output verbosity = 1 58 | set output frequency = 0.02 59 | set output vtk files = 1 60 | end 61 | -------------------------------------------------------------------------------- /tests/rising_bubble_ls_q3.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 2 18 | subsection Problem-specific 19 | set two-phase method = level set okz 20 | end 21 | subsection Two phase 22 | set density = 1. 23 | set density difference = -0.9 24 | set viscosity = 0.01 25 | set viscosity difference = -0.009 26 | set surface tension = 0.0245 27 | set epsilon = 1.5 28 | set gravity = 0.98 29 | set concentration subdivisions = 4 30 | set grad pressure compatible = 1 31 | set localize surface tension = 1 32 | set curvature correction = 1 33 | set number reinit steps = 2 34 | set number initial reinit steps = 2 35 | end 36 | subsection Time stepping 37 | set scheme = bdf_2 38 | set end time = 1 39 | set step size = 0.02 40 | end 41 | subsection Navier-Stokes 42 | set dimension = 2 43 | set global refinements = 2 44 | set adaptive refinements = 0 45 | set velocity degree = 3 46 | subsection Solver 47 | set NL max iterations = 10 48 | set NL tolerance = 1.e-9 49 | set lin max iterations = 30 50 | set lin tolerance = 1.e-4 51 | set lin velocity preconditioner = ilu 52 | set lin its before inner solvers = 50 53 | end 54 | end 55 | subsection Output options 56 | set output filename = output-rising_bubble_ls/data 57 | set output verbosity = 1 58 | set output frequency = 0.1 59 | set output vtk files = 0 60 | end 61 | -------------------------------------------------------------------------------- /tests/sim_rising_bubble.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 2 18 | subsection Problem-specific 19 | set two-phase method = sharp level set 20 | end 21 | subsection Two phase 22 | set density = 1. 23 | set density difference = -0.9 24 | set viscosity = 0.01 25 | set viscosity difference = -0.009 26 | set surface tension = 0.0245 27 | set epsilon = 1.5 28 | set gravity = 0.98 29 | set concentration subdivisions = 4 30 | set grad pressure compatible = 1 31 | set localize surface tension = 1 32 | set curvature correction = 1 33 | set number reinit steps = 2 34 | set number initial reinit steps = 2 35 | end 36 | subsection Time stepping 37 | set scheme = bdf_2 38 | set end time = 1 39 | set step size = 0.02 40 | end 41 | subsection Navier-Stokes 42 | set dimension = 2 43 | set global refinements = 3 44 | set adaptive refinements = 0 45 | set velocity degree = 2 46 | subsection Solver 47 | set NL max iterations = 10 48 | set NL tolerance = 1.e-9 49 | set lin max iterations = 30 50 | set lin tolerance = 1.e-4 51 | set lin velocity preconditioner = ilu 52 | set lin its before inner solvers = 50 53 | end 54 | end 55 | subsection Output options 56 | set output filename = output-sharp_interfaces_04/data 57 | set output verbosity = 1 58 | set output frequency = 0.02 59 | set output vtk files = 1 60 | end 61 | -------------------------------------------------------------------------------- /tests/rising_bubble_ls_adap.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 2 18 | subsection Problem-specific 19 | set two-phase method = level set okz 20 | end 21 | subsection Two phase 22 | set density = 1. 23 | set density difference = -0.9 24 | set viscosity = 0.01 25 | set viscosity difference = -0.009 26 | set surface tension = 0.0245 27 | set epsilon = 1.5 28 | set gravity = 0.98 29 | set concentration subdivisions = 4 30 | set grad pressure compatible = 1 31 | set localize surface tension = 1 32 | set curvature correction = 1 33 | set number reinit steps = 2 34 | set number initial reinit steps = 2 35 | end 36 | subsection Time stepping 37 | set scheme = bdf_2 38 | set end time = 1.2 39 | set step size = 0.02 40 | end 41 | subsection Navier-Stokes 42 | set dimension = 2 43 | set global refinements = 1 44 | set adaptive refinements = 2 45 | set velocity degree = 2 46 | subsection Solver 47 | set NL max iterations = 10 48 | set NL tolerance = 1.e-9 49 | set lin max iterations = 30 50 | set lin tolerance = 1.e-4 51 | set lin velocity preconditioner = ilu 52 | set lin its before inner solvers = 50 53 | end 54 | end 55 | subsection Output options 56 | set output filename = output-rising_bubble_ls_adap/data 57 | set output verbosity = 1 58 | set output frequency = 0.1 59 | set output vtk files = 0 60 | end 61 | -------------------------------------------------------------------------------- /tests/simplex_bubble.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 2 18 | subsection Problem-specific 19 | set two-phase method = level set okz 20 | end 21 | subsection Two phase 22 | set density = 1. 23 | set density difference = -0.9 24 | set viscosity = 0.01 25 | set viscosity difference = -0.009 26 | set surface tension = 0.0245 27 | set epsilon = 1.5 28 | set gravity = 0.98 29 | set concentration subdivisions = 1 30 | set grad pressure compatible = 1 31 | set localize surface tension = 1 32 | set curvature correction = 1 33 | set number reinit steps = 2 34 | set number initial reinit steps = 2 35 | end 36 | subsection Time stepping 37 | set scheme = bdf_2 38 | set end time = 2 39 | set step size = 0.02 40 | end 41 | subsection Navier-Stokes 42 | set dimension = 2 43 | set global refinements = 3 44 | set adaptive refinements = 0 45 | set velocity degree = 2 46 | set simplex mesh = 1 47 | subsection Solver 48 | set NL max iterations = 10 49 | set NL tolerance = 1.e-9 50 | set lin max iterations = 30 51 | set lin tolerance = 1.e-4 52 | set lin velocity preconditioner = ilu 53 | set lin its before inner solvers = 50 54 | end 55 | end 56 | subsection Output options 57 | set output filename = output-simplex_bubble/data 58 | set output verbosity = 1 59 | set output frequency = 0.1 60 | set output vtk files = 1 61 | end 62 | -------------------------------------------------------------------------------- /tests/rising_bubble_pf.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 2 18 | subsection Problem-specific 19 | set two-phase method = phase field 20 | end 21 | subsection Two phase 22 | set density = 1. 23 | set density difference = -0.9 24 | set viscosity = 0.01 25 | set viscosity difference = -0.009 26 | set surface tension = 0.0245 27 | set epsilon = 2 28 | set diffusion length = 0.03 29 | set gravity = 0.98 30 | set concentration subdivisions = 1 31 | set grad pressure compatible = 1 32 | set localize surface tension = 1 33 | set curvature correction = 1 34 | set number reinit steps = 2 35 | set number initial reinit steps = 2 36 | end 37 | subsection Time stepping 38 | set scheme = bdf_2 39 | set end time = 1 40 | set step size = 0.02 41 | end 42 | subsection Navier-Stokes 43 | set dimension = 2 44 | set global refinements = 3 45 | set adaptive refinements = 0 46 | set velocity degree = 2 47 | subsection Solver 48 | set NL max iterations = 10 49 | set NL tolerance = 1.e-9 50 | set lin max iterations = 30 51 | set lin tolerance = 1.e-4 52 | set lin velocity preconditioner = ilu 53 | set lin its before inner solvers = 50 54 | end 55 | end 56 | subsection Output options 57 | set output filename = output-rising_bubble_pf/data 58 | set output verbosity = 1 59 | set output frequency = 0.1 60 | set output vtk files = 0 61 | end 62 | -------------------------------------------------------------------------------- /tests/spurious_currents_ls_3d.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | subsection Problem-specific 18 | set two-phase method = level set okz 19 | end 20 | subsection Two phase 21 | set density = 1. 22 | set density difference = -0.9 23 | set viscosity = 0.1 24 | set viscosity difference = -0.09 25 | set surface tension = 1.0 26 | set epsilon = 1.0 27 | set gravity = 0. 28 | set concentration subdivisions = 3 29 | set grad pressure compatible = 1 30 | set localize surface tension = 1 31 | set curvature correction = 1 32 | set number reinit steps = 2 33 | set number initial reinit steps = 0 34 | end 35 | subsection Time stepping 36 | set scheme = bdf_2 37 | set end time = 0.3 38 | set step size = 0.05 39 | end 40 | subsection Navier-Stokes 41 | set dimension = 3 42 | set global refinements = 15 43 | set adaptive refinements = 2 44 | set velocity degree = 2 45 | set augmented Taylor-Hood elements = 1 46 | subsection Solver 47 | set NL max iterations = 10 48 | set NL tolerance = 1.e-8 49 | set lin max iterations = 30 50 | set lin tolerance = 1.e-5 51 | set lin velocity preconditioner = ilu 52 | set lin its before inner solvers = 50 53 | end 54 | end 55 | subsection Output options 56 | set output filename = output-spurious_currents_ls/data 57 | set output verbosity = 1 58 | set output frequency = 0.05 59 | set output vtk files = 0 60 | end 61 | -------------------------------------------------------------------------------- /tests/rising_bubble_ls_augp.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 3 18 | subsection Problem-specific 19 | set two-phase method = level set okz 20 | end 21 | subsection Two phase 22 | set density = 1. 23 | set density difference = -0.9 24 | set viscosity = 0.01 25 | set viscosity difference = -0.009 26 | set surface tension = 0.0245 27 | set epsilon = 1.5 28 | set gravity = 0.98 29 | set concentration subdivisions = 4 30 | set grad pressure compatible = 1 31 | set localize surface tension = 1 32 | set curvature correction = 1 33 | set number reinit steps = 2 34 | set number initial reinit steps = 2 35 | end 36 | subsection Time stepping 37 | set scheme = bdf_2 38 | set end time = 1 39 | set step size = 0.02 40 | end 41 | subsection Navier-Stokes 42 | set dimension = 2 43 | set global refinements = 1 44 | set adaptive refinements = 2 45 | set velocity degree = 2 46 | set augmented Taylor-Hood elements = 1 47 | subsection Solver 48 | set NL max iterations = 10 49 | set NL tolerance = 1.e-9 50 | set lin max iterations = 30 51 | set lin tolerance = 1.e-4 52 | set lin velocity preconditioner = ilu 53 | set lin its before inner solvers = 50 54 | end 55 | end 56 | subsection Output options 57 | set output filename = output-rising_bubble_ls_augp/data 58 | set output verbosity = 1 59 | set output frequency = 0.1 60 | set output vtk files = 0 61 | end 62 | -------------------------------------------------------------------------------- /tests/phasefield_poiseuille.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | subsection Two phase 17 | set density = 1. 18 | set density difference = -0.2 19 | set viscosity = 0.3 20 | set viscosity difference = 0.700 # oil viscosity: 0.00334 N/m^2, water: 0.001 N/m^2 21 | set surface tension = 1 22 | set epsilon = 2.88 23 | set gravity = 0. 24 | set diffusion length = 0.06 25 | set contact angle = 0.766 26 | set pressure constraint = 0 27 | set Cahn-Hilliard do Newton = 1 28 | set concentration subdivisions = 1 29 | end 30 | subsection Time stepping 31 | set scheme = bdf_2 32 | set end time = 6. 33 | set step size = 0.2 34 | end 35 | subsection Navier-Stokes 36 | set physical type = incompressible 37 | set dimension = 2 38 | set global refinements = 5 39 | set velocity degree = 2 40 | set viscosity = 0.1 41 | subsection Solver 42 | set linearization scheme = coupled implicit Newton 43 | set NL max iterations = 10 44 | set NL tolerance = 1.e-10 45 | set lin max iterations = 50 46 | set lin tolerance = 1.e-4 47 | set lin relative tolerance = 1 48 | set lin velocity preconditioner = amg linear 49 | set lin its before inner solvers = 50 50 | end 51 | end 52 | subsection Output options 53 | set output filename = output-phasefield_poiseuille/data 54 | set output frequency = 0.1 55 | set output verbosity = 1 56 | set output vtk files = 0 57 | end 58 | -------------------------------------------------------------------------------- /tests/rising_bubble_ls_expl.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 2 18 | subsection Problem-specific 19 | set two-phase method = level set okz 20 | end 21 | subsection Two phase 22 | set density = 1. 23 | set density difference = -0.9 24 | set viscosity = 0.01 25 | set viscosity difference = -0.009 26 | set surface tension = 0.0245 27 | set epsilon = 1.5 28 | set gravity = 0.98 29 | set concentration subdivisions = 3 30 | set grad pressure compatible = 1 31 | set localize surface tension = 1 32 | set curvature correction = 1 33 | set number reinit steps = 2 34 | set number initial reinit steps = 2 35 | end 36 | subsection Time stepping 37 | set scheme = bdf_2 38 | set end time = 1 39 | set step size = 0.02 40 | end 41 | subsection Navier-Stokes 42 | set dimension = 2 43 | set global refinements = 3 44 | set adaptive refinements = 0 45 | set velocity degree = 2 46 | subsection Solver 47 | set linearization scheme = coupled velocity explicit 48 | set NL max iterations = 1 49 | set NL tolerance = 1.e-9 50 | set lin max iterations = 50 51 | set lin tolerance = 1.e-4 52 | set lin velocity preconditioner = ilu 53 | set lin its before inner solvers = 50 54 | end 55 | end 56 | subsection Output options 57 | set output filename = output-rising_bubble_ls_expl/data 58 | set output verbosity = 1 59 | set output frequency = 0.1 60 | set output vtk files = 0 61 | end 62 | -------------------------------------------------------------------------------- /tests/rising_bubble_ls_picard.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 2 18 | subsection Problem-specific 19 | set two-phase method = level set okz 20 | end 21 | subsection Two phase 22 | set density = 1. 23 | set density difference = -0.9 24 | set viscosity = 0.01 25 | set viscosity difference = -0.009 26 | set surface tension = 0.0245 27 | set epsilon = 1.5 28 | set gravity = 0.98 29 | set concentration subdivisions = 3 30 | set grad pressure compatible = 1 31 | set localize surface tension = 1 32 | set curvature correction = 1 33 | set number reinit steps = 2 34 | set number initial reinit steps = 2 35 | end 36 | subsection Time stepping 37 | set scheme = bdf_2 38 | set end time = 1 39 | set step size = 0.02 40 | end 41 | subsection Navier-Stokes 42 | set dimension = 2 43 | set global refinements = 3 44 | set adaptive refinements = 0 45 | set velocity degree = 2 46 | subsection Solver 47 | set linearization scheme = coupled implicit Picard 48 | set NL max iterations = 10 49 | set NL tolerance = 1.e-9 50 | set lin max iterations = 30 51 | set lin tolerance = 1.e-3 52 | set lin velocity preconditioner = ilu 53 | set lin its before inner solvers = 50 54 | end 55 | end 56 | subsection Output options 57 | set output filename = output-rising_bubble_ls_prm/data 58 | set output verbosity = 1 59 | set output frequency = 0.1 60 | set output vtk files = 0 61 | end 62 | -------------------------------------------------------------------------------- /tests/rising_bubble_ls_imex.prm: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | # Listing of Parameters 16 | # 17 | # mpirun: 2 18 | subsection Problem-specific 19 | set two-phase method = level set okz 20 | end 21 | subsection Two phase 22 | set density = 1. 23 | set density difference = -0.9 24 | set viscosity = 0.01 25 | set viscosity difference = -0.009 26 | set surface tension = 0.0245 27 | set epsilon = 1.5 28 | set gravity = 0.98 29 | set concentration subdivisions = 3 30 | set grad pressure compatible = 1 31 | set localize surface tension = 1 32 | set curvature correction = 1 33 | set number reinit steps = 2 34 | set number initial reinit steps = 2 35 | end 36 | subsection Time stepping 37 | set scheme = bdf_2 38 | set end time = 1 39 | set step size = 0.02 40 | end 41 | subsection Navier-Stokes 42 | set dimension = 2 43 | set global refinements = 3 44 | set adaptive refinements = 0 45 | set velocity degree = 2 46 | subsection Solver 47 | set linearization scheme = coupled velocity semi-implicit 48 | set NL max iterations = 1 49 | set NL tolerance = 1.e-9 50 | set lin max iterations = 50 51 | set lin tolerance = 1.e-4 52 | set lin velocity preconditioner = ilu 53 | set lin its before inner solvers = 50 54 | end 55 | end 56 | subsection Output options 57 | set output filename = output-rising_bubble_ls_imex/data 58 | set output verbosity = 1 59 | set output frequency = 0.1 60 | set output vtk files = 0 61 | end 62 | -------------------------------------------------------------------------------- /include/adaflo/diagonal_preconditioner.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2011 - 2016 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | #ifndef __adaflo_diagonal_preconditioner_h 17 | #define __adaflo_diagonal_preconditioner_h 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | 26 | namespace adaflo 27 | { 28 | using namespace dealii; 29 | 30 | template 31 | class DiagonalPreconditioner 32 | { 33 | public: 34 | DiagonalPreconditioner() 35 | {} 36 | 37 | DiagonalPreconditioner( 38 | const LinearAlgebra::distributed::Vector &diagonal_vector_in); 39 | DiagonalPreconditioner( 40 | const LinearAlgebra::distributed::BlockVector &diagonal_vector_in); 41 | void 42 | reinit(const LinearAlgebra::distributed::Vector &diagonal_vector_in); 43 | void 44 | reinit(const LinearAlgebra::distributed::BlockVector &diagonal_vector_in); 45 | void 46 | vmult(LinearAlgebra::distributed::Vector &dst, 47 | const LinearAlgebra::distributed::Vector &src) const; 48 | void 49 | vmult(LinearAlgebra::distributed::BlockVector &dst, 50 | const LinearAlgebra::distributed::BlockVector &src) const; 51 | const LinearAlgebra::distributed::Vector & 52 | get_inverse_vector() const 53 | { 54 | return inverse_diagonal_vector; 55 | } 56 | const LinearAlgebra::distributed::Vector & 57 | get_vector() const 58 | { 59 | return diagonal_vector; 60 | } 61 | 62 | private: 63 | LinearAlgebra::distributed::Vector diagonal_vector; 64 | LinearAlgebra::distributed::Vector inverse_diagonal_vector; 65 | LinearAlgebra::distributed::BlockVector inverse_diagonal_block_vector; 66 | }; 67 | } // namespace adaflo 68 | 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /include/adaflo/level_set_okz_matrix.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2008 - 2016 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | #ifndef __adaflo_level_set_okz_matrix_h 17 | #define __adaflo_level_set_okz_matrix_h 18 | 19 | #include 20 | 21 | #include 22 | 23 | 24 | namespace adaflo 25 | { 26 | using namespace dealii; 27 | 28 | 29 | /** 30 | * A matrix-based level set solver based on the conservative level set method 31 | * by Olsson, Kreiss and Zahedi. 32 | */ 33 | template 34 | class LevelSetOKZMatrixSolver : public LevelSetBaseAlgorithm 35 | { 36 | public: 37 | LevelSetOKZMatrixSolver(const FlowParameters ¶meters, 38 | Triangulation &triangulation); 39 | virtual ~LevelSetOKZMatrixSolver() 40 | {} 41 | 42 | virtual void 43 | initialize_data_structures() override; 44 | 45 | virtual void 46 | transform_distance_function( 47 | LinearAlgebra::distributed::Vector &vector) const override; 48 | 49 | private: 50 | // compute the force term and variable density/viscosity for the 51 | // Navier--Stokes equations 52 | virtual void 53 | compute_force() override; 54 | 55 | // advection step 56 | virtual void 57 | advance_concentration() override; 58 | 59 | // computes normal direction vector by projection of level set gradient (not 60 | // scaled to have norm 1!) 61 | virtual void 62 | compute_normal(const bool fast_computation) override; 63 | 64 | // computes curvature by projecting the divergence of the normal vector 65 | // (scaled to norm 1 now) 66 | virtual void 67 | compute_curvature(const bool diffuse_large_values = false) override; 68 | 69 | // performs reinitialization 70 | virtual void 71 | reinitialize(const unsigned int stab_steps, 72 | const unsigned int diff_steps = 0, 73 | const bool diffuse_cells_with_large_curvature_only = false) override; 74 | 75 | virtual void 76 | compute_heaviside() override; 77 | 78 | bool normal_calculated; 79 | double global_max_velocity; 80 | 81 | TrilinosWrappers::SparseMatrix system_matrix; 82 | }; 83 | } // namespace adaflo 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /todo.txt: -------------------------------------------------------------------------------- 1 | 2 | **** 3 | Improving stability of level set OKZ algorithm: Our simulations often crash 4 | because the curvature gets very bad, which is in turn caused by the interface 5 | profile that gets some small oscillations. 6 | There are two things that we need to improve: 7 | 8 | - We need to introduce a mechanism to detect the bad curvature case. If 9 | necessary, we need a more rigorous reinitialization (this should only 10 | happen in the case when we have a bad profile). 11 | 12 | **** 13 | 14 | 15 | - Include the possibility to re-try a time step in case something goes wrong. Need to use a slightly modified version of init_time_step for that. 16 | 17 | - Make algorithm more robust. Robustness is steered by time step size on the one hand but also various parameters 18 | * capillary time step limit due to the splitting between level set and flow equations 19 | * diffusion added to equations for normal computation (function local_compute_normal) 20 | * diffusion added to equations for curvature computation 21 | * wider interface (epsilon=2 instead of 1.5) 22 | We should have a setting which is more robust but less accurate due to too high diffusion and another one with less diffusion, which is done through the parameter file. In particular the normal and curvature computation are important. 23 | 24 | 25 | 26 | Longer-term plan: 27 | ---------------- 28 | 29 | - Need faster algorithms for the level set part in 3D. One limitation is that the conservative level set method needs a lot of resolution to represent the interface in a good way and that the interface shape can get distorted. Therefore, a standard level set method should be implement. It should be based on discontinuous Galerkin that only uses first derivatives and can make all evaluations in an explicit stepping scheme. We would need to explicitly compute CFL numbers. With this, one should easily be able to only compute the level set function in a narrow band on Q_-2 or Q_-3 elements and use 'dummy' values further away (either by manual data structures or hp::DoFHandler, when it finally works in parallel). To get good mass conservation, further measures in the reinitialization (and advection) step are required. One way would be to combine this with a DG0 element (like VOF) and use this as a constraint in the reinitialization. MK thinks that this should be doable without distorting the interface too much. Curvatures and normals can be computed as usual by two projection steps (without diffusion but by using DG flux functions). 30 | 31 | - Other time stepping, not only BDF-2: Possibilities implicit/explicit Runge-Kutta method (order 3?), generalized alpha 32 | 33 | - Navier-Stokes solver could get another preconditioner for the velocity where we use first a 'geometric' transfer from Q_p onto Q_1 elements. 34 | 35 | - Navier-Stokes smoothers based on matrix-free overlapping Schwarz tools 36 | 37 | - Block multigrid with overlapping Schwarz smoother as suggested in a paper by Kanschat and Mao (Journal of Numerical Mathematics, 2014). 38 | 39 | - XFEM discretization as an additional option 40 | -------------------------------------------------------------------------------- /tests/simplex_channel_0.msh: -------------------------------------------------------------------------------- 1 | $MeshFormat 2 | 4.1 0 8 3 | $EndMeshFormat 4 | $Entities 5 | 4 4 1 0 6 | 1 0 0 0 0 7 | 2 5 0 0 0 8 | 3 5 1 0 0 9 | 4 0 1 0 0 10 | 1 -9.999999983634211e-08 -1e-07 -1e-07 5.0000001 1e-07 1e-07 0 2 1 -2 11 | 2 4.9999999 -9.999999994736442e-08 -1e-07 5.0000001 1.0000001 1e-07 0 2 2 -3 12 | 3 -9.999999983634211e-08 0.9999999000000001 -1e-07 5.0000001 1.0000001 1e-07 0 2 3 -4 13 | 4 -1e-07 -9.999999994736442e-08 -1e-07 1e-07 1.0000001 1e-07 0 2 4 -1 14 | 1 -9.999999983634211e-08 -9.999999994736442e-08 -1e-07 5.0000001 1.0000001 1e-07 0 4 1 2 3 4 15 | $EndEntities 16 | $Nodes 17 | 9 36 1 36 18 | 0 1 0 1 19 | 1 20 | 0 0 0 21 | 0 2 0 1 22 | 2 23 | 5 0 0 24 | 0 3 0 1 25 | 3 26 | 5 1 0 27 | 0 4 0 1 28 | 4 29 | 0 1 0 30 | 1 1 0 9 31 | 5 32 | 6 33 | 7 34 | 8 35 | 9 36 | 10 37 | 11 38 | 12 39 | 13 40 | 0.4999999999999999 0 0 41 | 0.9999999999999999 0 0 42 | 1.500000000000001 0 0 43 | 2.000000000000002 0 0 44 | 2.500000000000004 0 0 45 | 3.000000000000004 0 0 46 | 3.500000000000006 0 0 47 | 4.000000000000007 0 0 48 | 4.500000000000004 0 0 49 | 1 2 0 1 50 | 14 51 | 5 0.5 0 52 | 1 3 0 9 53 | 15 54 | 16 55 | 17 56 | 18 57 | 19 58 | 20 59 | 21 60 | 22 61 | 23 62 | 4.5 1 0 63 | 4 1 0 64 | 3.499999999999999 1 0 65 | 2.999999999999998 1 0 66 | 2.499999999999996 1 0 67 | 1.999999999999996 1 0 68 | 1.499999999999994 1 0 69 | 0.9999999999999929 1 0 70 | 0.4999999999999956 1 0 71 | 1 4 0 1 72 | 24 73 | 0 0.5 0 74 | 2 1 0 12 75 | 25 76 | 26 77 | 27 78 | 28 79 | 29 80 | 30 81 | 31 82 | 32 83 | 33 84 | 34 85 | 35 86 | 36 87 | 0.7499999999999942 0.5669872981077837 0 88 | 3.750000000000001 0.522763674106805 0 89 | 1.749999999999999 0.4818764784438391 0 90 | 2.750619411092471 0.5238365255897381 0 91 | 4.250000000000005 0.4330127018922162 0 92 | 3.250073739415771 0.4909308623933017 0 93 | 1.246432192107358 0.4775246023861555 0 94 | 2.250103235182078 0.5009521673389296 0 95 | 4.671274166920488 0.6331588584183429 0 96 | 0.3287258330795111 0.3668411415816571 0 97 | 0.2899060668618043 0.7110089675965722 0 98 | 4.710093933138196 0.2889910324034278 0 99 | $EndNodes 100 | $Elements 101 | 9 74 1 74 102 | 0 1 15 1 103 | 1 1 104 | 0 2 15 1 105 | 2 2 106 | 0 3 15 1 107 | 3 3 108 | 0 4 15 1 109 | 4 4 110 | 1 1 1 10 111 | 5 1 5 112 | 6 5 6 113 | 7 6 7 114 | 8 7 8 115 | 9 8 9 116 | 10 9 10 117 | 11 10 11 118 | 12 11 12 119 | 13 12 13 120 | 14 13 2 121 | 1 2 1 2 122 | 15 2 14 123 | 16 14 3 124 | 1 3 1 10 125 | 17 3 15 126 | 18 15 16 127 | 19 16 17 128 | 20 17 18 129 | 21 18 19 130 | 22 19 20 131 | 23 20 21 132 | 24 21 22 133 | 25 22 23 134 | 26 23 4 135 | 1 4 1 2 136 | 27 4 24 137 | 28 24 1 138 | 2 1 2 46 139 | 29 6 25 5 140 | 30 16 29 15 141 | 31 12 26 11 142 | 32 21 27 20 143 | 33 10 28 9 144 | 34 27 32 20 145 | 35 21 31 27 146 | 36 20 32 19 147 | 37 22 31 21 148 | 38 18 30 17 149 | 39 10 30 28 150 | 40 26 30 11 151 | 41 26 29 16 152 | 42 12 29 26 153 | 43 6 31 25 154 | 44 28 32 9 155 | 45 17 30 26 156 | 46 28 30 18 157 | 47 25 31 22 158 | 48 19 32 28 159 | 49 25 34 5 160 | 50 29 33 15 161 | 51 11 30 10 162 | 52 7 31 6 163 | 53 27 31 7 164 | 54 9 32 8 165 | 55 8 32 27 166 | 56 13 29 12 167 | 57 17 26 16 168 | 58 19 28 18 169 | 59 23 25 22 170 | 60 8 27 7 171 | 61 1 34 24 172 | 62 5 34 1 173 | 63 15 33 3 174 | 64 3 33 14 175 | 65 23 35 25 176 | 66 13 36 29 177 | 67 25 35 34 178 | 68 29 36 33 179 | 69 14 36 2 180 | 70 24 35 4 181 | 71 2 36 13 182 | 72 4 35 23 183 | 73 34 35 24 184 | 74 33 36 14 185 | $EndElements 186 | -------------------------------------------------------------------------------- /tests/poiseuille_stokes.output: -------------------------------------------------------------------------------- 1 | Running a 2D channel flow problem using BDF-2, Q2/Q1 elements 2 | Number of active cells: 16384. 3 | Number of degrees of freedom (velocity/pressure): 149059 (132354 + 16705). 4 | Approximate size last cell: 0.015625 5 | Maximum velocity now: 5 6 | 7 | Time step #1, advancing from t_n-1 = 0 to t = 0.01 (dt = 0.01). 8 | 9 | Nonlin Res Prec Upd Increment Lin Iter Lin Res 10 | ____________________________________________________________ 11 | 3.722e-01 AMGl 9.85e+02 33 2.30e-06 12 | 2.298e-06 --- 3.54e-03 33 2.06e-11 13 | 2.055e-11 --- 4.13e-08 11 3.91e-13 14 | 3.957e-13 converged. 15 | 16 | -- Statistics -- min avg max avg/call p_min p_max 17 | -- Statistics -- memory [MB] : 229 229 229 0 0 18 | -- Statistics -- nln solver : 2.57 2.57 2.57 2.57 0 0 19 | -- Statistics -- lin solver : 2.06 2.06 2.06 0.687 0 0 20 | -- Statistics -- mat-vec : 0.157 0.157 0.157 0.00196 0 0 21 | -- Statistics -- full prec : 1.56 1.56 1.56 0.0195 0 0 22 | -- Statistics -- velocity : 1.46 1.46 1.46 0.0183 0 0 23 | -- Statistics -- div matrix: 0.0735 0.0735 0.0735 0.000919 0 0 24 | -- Statistics -- pres mass : 0.027 0.027 0.027 0.000338 0 0 25 | -- Statistics -- pres Poiss: 0 0 0 0 0 0 26 | 27 | L2-Errors: ||e_p||_L2 = 5.388e-12, ||e_u||_L2 = 9.525e-12 28 | 29 | 30 | +---------------------------------------------+------------+------------+ 31 | | Total CPU time elapsed since start | 4.22s | | 32 | | | | | 33 | | Section | no. calls | CPU time | % of total | 34 | +---------------------------------+-----------+------------+------------+ 35 | | Compute errors. | 1 | 0.076s | 1.8% | 36 | | NS apply boundary conditions. | 1 | 0.004s | 0.095% | 37 | | NS assemble nonlinear residual. | 4 | 0.004s | 0.095% | 38 | | NS assemble preconditioner. | 1 | 0.144s | 3.4% | 39 | | NS build preconditioner. | 1 | 0.352s | 8.3% | 40 | | NS distribute DoFs. | 1 | 0.04s | 0.95% | 41 | | NS setup matrix and vectors. | 1 | 0.14s | 3.3% | 42 | | NS solve system. | 3 | 2.05s | 49% | 43 | | Setup grid and initial condition| 1 | 0s | 0% | 44 | +---------------------------------+-----------+------------+------------+ 45 | 46 | 47 | 48 | +---------------------------------------------+------------+------------+ 49 | | Total wallclock time elapsed since start | 4.25s | | 50 | | | | | 51 | | Section | no. calls | wall time | % of total | 52 | +---------------------------------+-----------+------------+------------+ 53 | | Compute errors. | 1 | 0.0738s | 1.7% | 54 | | NS apply boundary conditions. | 1 | 0.00652s | 0.15% | 55 | | NS assemble nonlinear residual. | 4 | 0.0105s | 0.25% | 56 | | NS assemble preconditioner. | 1 | 0.142s | 3.3% | 57 | | NS build preconditioner. | 1 | 0.357s | 8.4% | 58 | | NS distribute DoFs. | 1 | 0.0438s | 1% | 59 | | NS setup matrix and vectors. | 1 | 0.147s | 3.4% | 60 | | NS solve system. | 3 | 2.06s | 48% | 61 | | Setup grid and initial condition| 1 | 0.000426s | 0.01% | 62 | +---------------------------------+-----------+------------+------------+ 63 | 64 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- 2 | # 3 | # Copyright (C) 2013 - 2016 by the adaflo authors 4 | # 5 | # This file is part of the adaflo library. 6 | # 7 | # The adaflo library is free software; you can use it, redistribute it, 8 | # and/or modify it under the terms of the GNU Lesser General Public License 9 | # as published by the Free Software Foundation; either version 2.1 of the 10 | # License, or (at your option) any later version. The full text of the 11 | # license can be found in the file LICENSE at the top level of the adaflo 12 | # distribution. 13 | # 14 | # -------------------------------------------------------------------------- 15 | 16 | MESSAGE("====================================================") 17 | MESSAGE("=============== Configuring ADAFLO =================") 18 | MESSAGE("========= An adaptive parallel flow solver =========") 19 | MESSAGE("====================================================") 20 | 21 | 22 | # this is the standard deal.II search mechanism, including check for Trilinos and p4est 23 | 24 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) 25 | 26 | FIND_PACKAGE(deal.II 9.3 QUIET 27 | HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} 28 | ) 29 | IF(NOT ${deal.II_FOUND}) 30 | MESSAGE(FATAL_ERROR "\n" 31 | "*** Could not locate deal.II. ***\n\n" 32 | "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" 33 | "or set an environment variable \"DEAL_II_DIR\" that contains this path." 34 | ) 35 | ENDIF() 36 | 37 | IF(NOT DEAL_II_WITH_TRILINOS OR NOT DEAL_II_WITH_P4EST) 38 | MESSAGE(FATAL_ERROR 39 | "\nadaflo requires a deal.II installation built with support for Trilinos and p4est but one or both of these appears to be missing!\n" 40 | ) 41 | IF(NOT DEAL_II_WITH_TRILINOS) 42 | MESSAGE(FATAL_ERROR 43 | "\n-- deal.II was built without support for Trilinos!\n" 44 | ) 45 | ENDIF() 46 | 47 | IF(NOT DEAL_II_WITH_P4EST) 48 | MESSAGE(FATAL_ERROR 49 | "\n-- deal.II was built without support for p4est!\n" 50 | ) 51 | ENDIF() 52 | ENDIF() 53 | 54 | DEAL_II_INITIALIZE_CACHED_VARIABLES() 55 | 56 | # Set the source files to be compiled 57 | SET( TARGET_SRC 58 | source/level_set_okz_preconditioner.cc 59 | source/level_set_okz_compute_curvature.cc 60 | source/level_set_okz_advance_concentration.cc 61 | source/level_set_okz_compute_normal.cc 62 | source/level_set_okz.cc 63 | source/level_set_okz_reinitialization.cc 64 | source/phase_field.cc 65 | source/phase_field_local.cc 66 | source/navier_stokes_matrix.cc 67 | source/navier_stokes_preconditioner.cc 68 | source/navier_stokes.cc 69 | source/level_set_okz_matrix.cc 70 | source/parameters.cc 71 | source/time_stepping.cc 72 | source/flow_base_algorithm.cc 73 | source/diagonal_preconditioner.cc 74 | source/two_phase_base.cc 75 | source/level_set_base.cc) 76 | 77 | # Set the include directory and the name of the project 78 | INCLUDE_DIRECTORIES(include) 79 | 80 | PROJECT(adaflo) 81 | 82 | ADD_LIBRARY(adaflo ${TARGET_SRC}) 83 | 84 | 85 | # Define custom targets to easily switch the build type: 86 | ADD_CUSTOM_TARGET(debug 87 | COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} 88 | COMMENT "Switch CMAKE_BUILD_TYPE to Debug, now type 'make' to build" 89 | ) 90 | 91 | ADD_CUSTOM_TARGET(release 92 | COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} 93 | COMMENT "Switch CMAKE_BUILD_TYPE to Release, now type 'make' to build" 94 | ) 95 | 96 | DEAL_II_INITIALIZE_CACHED_VARIABLES() 97 | 98 | DEAL_II_SETUP_TARGET(adaflo) 99 | 100 | ADD_SUBDIRECTORY(applications) 101 | 102 | # Set up unit tests 103 | IF(EXISTS ${CMAKE_SOURCE_DIR}/tests/CMakeLists.txt) 104 | ENABLE_TESTING() 105 | ADD_SUBDIRECTORY(tests) 106 | ENDIF() 107 | 108 | 109 | MESSAGE("====================================================") 110 | -------------------------------------------------------------------------------- /tests/couette.output: -------------------------------------------------------------------------------- 1 | Running a 2D Couette problem using BDF-2, Q2/Q1 elements 2 | Number of active cells: 1024. 3 | Number of degrees of freedom (velocity/pressure): 9619 (8514 + 1105). 4 | Approximate size last cell: 0.0625 5 | 6 | Time step #1, advancing from t_n-1 = 0 to t = 0.5 (dt = 0.5). 7 | 8 | Nonlin Res Prec Upd Increment Lin Iter Lin Res 9 | ____________________________________________________________ 10 | 1.601e+01 AMG 5.83e+01 18 9.29e-06 11 | 9.320e-06 --- 1.17e-03 23 5.66e-11 12 | 5.675e-11 --- 6.02e-09 10 4.10e-13 13 | 4.122e-13 converged. 14 | 15 | -- Statistics -- min avg max avg/call p_min p_max 16 | -- Statistics -- memory [MB] : 292 293 294 2 0 17 | -- Statistics -- nln solver : 0.613 0.613 0.613 0.613 0 1 18 | -- Statistics -- lin solver : 0.488 0.488 0.488 0.163 0 2 19 | -- Statistics -- mat-vec : 0.096 0.0961 0.0961 0.00169 0 1 20 | -- Statistics -- full prec : 0.374 0.375 0.375 0.00657 1 0 21 | -- Statistics -- velocity : 0.339 0.339 0.339 0.00595 1 0 22 | -- Statistics -- div matrix: 0.0274 0.0275 0.0276 0.000483 3 2 23 | -- Statistics -- pres mass : 0.000549 0.000561 0.000569 9.84e-06 1 3 24 | -- Statistics -- pres Poiss: 0.00682 0.00702 0.00719 0.000123 1 0 25 | 26 | 27 | Time step #2, advancing from t_n-1 = 0.5 to t = 1 (dt = 0.5). 28 | 29 | Nonlin Res Prec Upd Increment Lin Iter Lin Res 30 | ____________________________________________________________ 31 | 1.930e-01 AMG 1.60e+01 19 1.44e-06 32 | 1.444e-06 --- 1.86e-04 21 1.41e-11 33 | 1.414e-11 --- 1.14e-09 7 3.41e-13 34 | 3.437e-13 converged. 35 | 36 | 37 | 38 | +-----------------------------------------------+------------+------------+ 39 | | Total CPU time elapsed since start | 1.54s | | 40 | | | | | 41 | | Section | no. calls | CPU time | % of total | 42 | +-----------------------------------+-----------+------------+------------+ 43 | | NS apply boundary conditions. | 2 | 0.0283s | 1.8% | 44 | | NS assemble nonlinear residual. | 8 | 0.0194s | 1.3% | 45 | | NS assemble preconditioner. | 2 | 0.131s | 8.5% | 46 | | NS build preconditioner. | 2 | 0.0935s | 6.1% | 47 | | NS distribute DoFs. | 1 | 0.0428s | 2.8% | 48 | | NS setup matrix and vectors. | 1 | 0.0395s | 2.6% | 49 | | NS solve system. | 6 | 0.939s | 61% | 50 | | Setup grid and initial condition. | 1 | 0.00847s | 0.55% | 51 | +-----------------------------------+-----------+------------+------------+ 52 | 53 | 54 | 55 | +-----------------------------------------------+------------+------------+ 56 | | Total wallclock time elapsed since start | 1.54s | | 57 | | | | | 58 | | Section | no. calls | wall time | % of total | 59 | +-----------------------------------+-----------+------------+------------+ 60 | | NS apply boundary conditions. | 2 | 0.0283s | 1.8% | 61 | | NS assemble nonlinear residual. | 8 | 0.0196s | 1.3% | 62 | | NS assemble preconditioner. | 2 | 0.131s | 8.5% | 63 | | NS build preconditioner. | 2 | 0.0959s | 6.2% | 64 | | NS distribute DoFs. | 1 | 0.0428s | 2.8% | 65 | | NS setup matrix and vectors. | 1 | 0.0396s | 2.6% | 66 | | NS solve system. | 6 | 0.94s | 61% | 67 | | Setup grid and initial condition. | 1 | 0.00849s | 0.55% | 68 | +-----------------------------------+-----------+------------+------------+ 69 | 70 | -------------------------------------------------------------------------------- /tests/spurious_currents_ls_3d.output: -------------------------------------------------------------------------------- 1 | 2 | Number of active cells: 3375. 3 | Number of Navier-Stokes degrees of freedom: 96844 (89373 + 7471). 4 | Number of level set degrees of freedom: 97336. 5 | Mesh size (largest/smallest element length at finest level): 0.333333 / 0.333333 6 | 7 | Number of active cells: 9514. 8 | Number of Navier-Stokes degrees of freedom: 274815 (254079 + 20736). 9 | Number of level set degrees of freedom: 276862. 10 | Mesh size (largest/smallest element length at finest level): 0.166667 / 0.166667 11 | 12 | Number of active cells: 20014. 13 | Number of Navier-Stokes degrees of freedom: 572541 (529479 + 43062). 14 | Number of level set degrees of freedom: 578926. 15 | Mesh size (largest/smallest element length at finest level): 0.0833333 / 0.0833333 16 | 17 | Number of active cells: 9598. 18 | Number of Navier-Stokes degrees of freedom: 281763 (260595 + 21168). 19 | Number of level set degrees of freedom: 282676. 20 | Mesh size (largest/smallest element length at finest level): 0.0833333 / 0.0833333 21 | reinitialize () 22 | 23 | Time step #1, advancing from t_n-1 = 0 to t = 0.05 (dt = 0.05). 24 | Concentration advance: advect [0/0] and reinitialize (13 + 13) 25 | Residual/iterations: [0.176/ILU/30] [8.07e-06/25] [4.78e-09/conv.] 26 | Error in pressure jump: -0.51229699 % 27 | Size spurious currents, absolute: 0.00068641172 28 | 29 | Time step #2, advancing from t_n-1 = 0.05 to t = 0.1 (dt = 0.05). 30 | Concentration advance: advect [5.67e-05/8] and reinitialize (12 + 12) 31 | Residual/iterations: [0.000235/ILU/29] [3.77e-09/conv.] 32 | Error in pressure jump: -0.51939436 % 33 | Size spurious currents, absolute: 0.00090036878 34 | 35 | Time step #3, advancing from t_n-1 = 0.1 to t = 0.15 (dt = 0.05). 36 | Concentration advance: advect [6.61e-05/8] and reinitialize (11 + 11) 37 | Residual/iterations: [7.36e-05/21] [4.93e-09/conv.] 38 | Error in pressure jump: -0.52625009 % 39 | Size spurious currents, absolute: 0.00095537366 40 | 41 | Time step #4, advancing from t_n-1 = 0.15 to t = 0.2 (dt = 0.05). 42 | Concentration advance: advect [6.24e-05/7] and reinitialize (11 + 11) 43 | Residual/iterations: [4.36e-05/24] [3.42e-09/conv.] 44 | Error in pressure jump: -0.53246464 % 45 | Size spurious currents, absolute: 0.00093348997 46 | 47 | Time step #5, advancing from t_n-1 = 0.2 to t = 0.25 (dt = 0.05). 48 | Concentration advance: advect [5.62e-05/7] and reinitialize (11 + 11) 49 | Residual/iterations: [3.76e-05/23] [4.35e-09/conv.] 50 | Error in pressure jump: -0.53820334 % 51 | Size spurious currents, absolute: 0.00099661352 52 | 53 | Time step #6, advancing from t_n-1 = 0.25 to t = 0.3 (dt = 0.05). 54 | Concentration advance: advect [4.96e-05/6] and reinitialize (11 + 11) 55 | Residual/iterations: [2.98e-05/23] [3.73e-09/conv.] 56 | Error in pressure jump: -0.54357363 % 57 | Size spurious currents, absolute: 0.001041771 58 | 59 | 60 | +---------------------------------------------+------------+------------+ 61 | | Total wallclock time elapsed since start | 75.8s | | 62 | | | | | 63 | | Section | no. calls | wall time | % of total | 64 | +---------------------------------+-----------+------------+------------+ 65 | | LS advance concentration. | 6 | 1.81s | 2.4% | 66 | | LS compute Heaviside. | 7 | 0.104s | 0.14% | 67 | | LS compute curvature. | 6 | 2.52s | 3.3% | 68 | | LS compute force. | 6 | 0.163s | 0.21% | 69 | | LS compute normal. | 15 | 10.4s | 14% | 70 | | LS reinitialization step. | 12 | 3.06s | 4% | 71 | | NS apply boundary conditions. | 12 | 0.136s | 0.18% | 72 | | NS assemble nonlinear residual. | 13 | 0.231s | 0.3% | 73 | | NS assemble preconditioner. | 2 | 3.31s | 4.4% | 74 | | NS build preconditioner. | 2 | 3.93s | 5.2% | 75 | | NS distribute DoFs. | 4 | 18.2s | 24% | 76 | | NS setup matrix and vectors. | 4 | 4.18s | 5.5% | 77 | | NS solve system. | 7 | 11.6s | 15% | 78 | | Probe grid refinement. | 3 | 0.214s | 0.28% | 79 | | Refine grid. | 3 | 34.1s | 45% | 80 | | TP setup problem. | 1 | 39.8s | 52% | 81 | +---------------------------------+-----------+------------+------------+ 82 | 83 | -------------------------------------------------------------------------------- /include/adaflo/level_set_okz.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2008 - 2016 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | 17 | #ifndef __adaflo_level_set_okz_h 18 | #define __adaflo_level_set_okz_h 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | namespace adaflo 29 | { 30 | using namespace dealii; 31 | 32 | 33 | // forward declarations 34 | class BlockMatrixExtension; 35 | class BlockILUExtension; 36 | namespace AssemblyData 37 | { 38 | struct Data; 39 | } 40 | 41 | 42 | 43 | template 44 | class LevelSetOKZSolver : public LevelSetBaseAlgorithm 45 | { 46 | public: 47 | LevelSetOKZSolver(const FlowParameters ¶meters, 48 | Triangulation &triangulation); 49 | virtual ~LevelSetOKZSolver() 50 | {} 51 | 52 | virtual void 53 | initialize_data_structures() override; 54 | 55 | virtual void 56 | transform_distance_function( 57 | LinearAlgebra::distributed::Vector &vector) const override; 58 | 59 | private: 60 | // compute the force term and variable density/viscosity for the 61 | // Navier--Stokes equations 62 | virtual void 63 | compute_force() override; 64 | 65 | // advection step 66 | virtual void 67 | advance_concentration() override; 68 | 69 | // computes normal direction vector by projection of level set gradient (not 70 | // scaled to have norm 1!) 71 | virtual void 72 | compute_normal(const bool fast_computation) override; 73 | 74 | // computes curvature by projecting the divergence of the normal vector 75 | // (scaled to norm 1 now) 76 | virtual void 77 | compute_curvature(const bool diffuse_large_values = false) override; 78 | 79 | // performs reinitialization 80 | virtual void 81 | reinitialize(const unsigned int stab_steps, 82 | const unsigned int diff_steps = 0, 83 | const bool diffuse_cells_with_large_curvature_only = false) override; 84 | 85 | virtual void 86 | compute_heaviside() override; 87 | 88 | // matrix-free worker operations for various operations 89 | template 90 | void 91 | local_compute_force(const MatrixFree &data, 92 | LinearAlgebra::distributed::Vector &dst, 93 | const LinearAlgebra::distributed::Vector &src, 94 | const std::pair &cell_range); 95 | 96 | void 97 | local_projection_matrix( 98 | const MatrixFree &data, 99 | std::shared_ptr> &scratch, 100 | const unsigned int &, 101 | const std::pair &cell_range); 102 | 103 | template 104 | void 105 | local_projection_matrix( 106 | const MatrixFree &data, 107 | std::shared_ptr> &scratch, 108 | const std::pair &cell_range); 109 | 110 | bool first_reinit_step; 111 | double global_max_velocity; 112 | DiagonalPreconditioner preconditioner; 113 | 114 | std::shared_ptr projection_matrix; 115 | std::shared_ptr ilu_projection_matrix; 116 | 117 | std::unique_ptr> normal_operator; 118 | std::unique_ptr> curvatur_operator; 119 | std::unique_ptr> reinit_operator; 120 | std::unique_ptr> advection_operator; 121 | }; 122 | } // namespace adaflo 123 | 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /include/adaflo/level_set_okz_preconditioner.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2020 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | 17 | #ifndef __adaflo_level_set_okz_preconditioner_h 18 | #define __adaflo_level_set_okz_preconditioner_h 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | 26 | namespace adaflo 27 | { 28 | using namespace dealii; 29 | 30 | 31 | template > 34 | inline void 35 | initialize_mass_matrix_diagonal( 36 | const MatrixFree &matrix_free, 37 | const AffineConstraints &hanging_node_constraints, 38 | const unsigned int dof_index, 39 | const unsigned int quad_index, 40 | DiagonalPreconditioner &preconditioner) 41 | { 42 | LinearAlgebra::distributed::Vector diagonal; 43 | matrix_free.initialize_dof_vector(diagonal, dof_index); 44 | 45 | const auto &dof_handler = matrix_free.get_dof_handler(dof_index); 46 | const auto &fe = dof_handler.get_fe(); 47 | const auto &quadrature = matrix_free.get_quadrature(quad_index); 48 | const auto &mapping = *matrix_free.get_mapping_info().mapping; 49 | 50 | { 51 | diagonal = 0; 52 | FEValues fe_values(mapping, fe, quadrature, update_values | update_JxW_values); 53 | Vector local_rhs(fe.dofs_per_cell); 54 | std::vector local_dof_indices(fe.dofs_per_cell); 55 | 56 | for (const auto &cell : dof_handler.active_cell_iterators()) 57 | if (cell->is_locally_owned()) 58 | { 59 | fe_values.reinit(cell); 60 | for (unsigned int i = 0; i < fe.dofs_per_cell; ++i) 61 | { 62 | Number value = 0; 63 | for (const auto q : fe_values.quadrature_point_indices()) 64 | value += fe_values.shape_value(i, q) * fe_values.shape_value(i, q) * 65 | fe_values.JxW(q); 66 | local_rhs(i) = value; 67 | } 68 | cell->get_dof_indices(local_dof_indices); 69 | hanging_node_constraints.distribute_local_to_global(local_rhs, 70 | local_dof_indices, 71 | diagonal); 72 | } 73 | diagonal.compress(VectorOperation::add); 74 | preconditioner.reinit(diagonal); 75 | } 76 | } 77 | 78 | 79 | 80 | namespace AssemblyData 81 | { 82 | struct Data 83 | { 84 | Data() 85 | { 86 | AssertThrow(false, ExcNotImplemented()); 87 | } 88 | 89 | Data(const unsigned int size) 90 | : matrices(VectorizedArray::size(), FullMatrix(size, size)) 91 | , dof_indices(size) 92 | {} 93 | 94 | Data(const Data &other) 95 | : matrices(other.matrices) 96 | , dof_indices(other.dof_indices) 97 | {} 98 | 99 | std::vector> matrices; 100 | std::vector dof_indices; 101 | }; 102 | } // namespace AssemblyData 103 | 104 | 105 | 106 | template > 109 | void 110 | initialize_projection_matrix( 111 | const MatrixFree &matrix_free, 112 | const AffineConstraints &constraints_normals, 113 | const unsigned int dof_index, 114 | const unsigned int quad_index, 115 | const Number &epsilon_used, 116 | const Number &epsilon, 117 | const AlignedVector &cell_diameters, 118 | BlockMatrixExtension &projection_matrix, 119 | BlockILUExtension &ilu_projection_matrix); 120 | } // namespace adaflo 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /source/diagonal_preconditioner.cc: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2011 - 2016 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | #include 17 | 18 | using namespace dealii; 19 | 20 | template 21 | adaflo::DiagonalPreconditioner::DiagonalPreconditioner( 22 | const LinearAlgebra::distributed::Vector &diagonal_vector_in) 23 | { 24 | reinit(diagonal_vector_in); 25 | } 26 | 27 | 28 | 29 | template 30 | adaflo::DiagonalPreconditioner::DiagonalPreconditioner( 31 | const LinearAlgebra::distributed::BlockVector &diagonal_vector_in) 32 | { 33 | reinit(diagonal_vector_in); 34 | } 35 | 36 | 37 | 38 | template 39 | void 40 | adaflo::DiagonalPreconditioner::reinit( 41 | const LinearAlgebra::distributed::Vector &diagonal_vector_in) 42 | { 43 | inverse_diagonal_block_vector.reinit(0); 44 | diagonal_vector = diagonal_vector_in; 45 | inverse_diagonal_vector.reinit(diagonal_vector, true); 46 | const double linfty_norm = diagonal_vector.linfty_norm(); 47 | for (unsigned int i = 0; i < diagonal_vector.locally_owned_size(); ++i) 48 | if (std::abs(diagonal_vector.local_element(i)) > 1e-10 * linfty_norm) 49 | inverse_diagonal_vector.local_element(i) = 1. / diagonal_vector.local_element(i); 50 | else 51 | inverse_diagonal_vector.local_element(i) = 1.; 52 | diagonal_vector.zero_out_ghost_values(); 53 | inverse_diagonal_vector.zero_out_ghost_values(); 54 | } 55 | 56 | 57 | 58 | template 59 | void 60 | adaflo::DiagonalPreconditioner::reinit( 61 | const LinearAlgebra::distributed::BlockVector &diagonal_vector_in) 62 | { 63 | diagonal_vector.reinit(0); 64 | inverse_diagonal_vector.reinit(0); 65 | inverse_diagonal_block_vector = diagonal_vector_in; 66 | const double linfty_norm = inverse_diagonal_block_vector.linfty_norm(); 67 | for (unsigned int bl = 0; bl < inverse_diagonal_block_vector.n_blocks(); ++bl) 68 | for (unsigned int i = 0; 69 | i < inverse_diagonal_block_vector.block(bl).locally_owned_size(); 70 | ++i) 71 | if (std::abs(inverse_diagonal_block_vector.block(bl).local_element(i)) > 72 | 1e-10 * linfty_norm) 73 | inverse_diagonal_block_vector.block(bl).local_element(i) = 74 | 1. / inverse_diagonal_block_vector.block(bl).local_element(i); 75 | else 76 | inverse_diagonal_block_vector.block(bl).local_element(i) = 1.; 77 | inverse_diagonal_block_vector.zero_out_ghost_values(); 78 | } 79 | 80 | 81 | 82 | template 83 | void 84 | adaflo::DiagonalPreconditioner::vmult( 85 | LinearAlgebra::distributed::Vector &dst, 86 | const LinearAlgebra::distributed::Vector &src) const 87 | { 88 | AssertDimension(diagonal_vector.size(), src.size()); 89 | AssertDimension(inverse_diagonal_block_vector.size(), 0); 90 | for (unsigned int i = 0; i < inverse_diagonal_vector.locally_owned_size(); ++i) 91 | { 92 | dst.local_element(i) = 93 | src.local_element(i) * inverse_diagonal_vector.local_element(i); 94 | } 95 | } 96 | 97 | 98 | 99 | template 100 | void 101 | adaflo::DiagonalPreconditioner::vmult( 102 | LinearAlgebra::distributed::BlockVector &dst, 103 | const LinearAlgebra::distributed::BlockVector &src) const 104 | { 105 | if (inverse_diagonal_block_vector.n_blocks() > 0) 106 | { 107 | AssertDimension(inverse_diagonal_block_vector.size(), src.size()); 108 | AssertDimension(inverse_diagonal_vector.size(), 0); 109 | dst = src; 110 | dst.scale(inverse_diagonal_block_vector); 111 | } 112 | else 113 | { 114 | for (unsigned int block = 0; block < src.n_blocks(); ++block) 115 | AssertDimension(inverse_diagonal_vector.size(), dst.block(block).size()); 116 | const unsigned int n_blocks = src.n_blocks(); 117 | for (unsigned int i = 0; i < inverse_diagonal_vector.locally_owned_size(); ++i) 118 | for (unsigned int block = 0; block < n_blocks; ++block) 119 | { 120 | dst.block(block).local_element(i) = src.block(block).local_element(i) * 121 | inverse_diagonal_vector.local_element(i); 122 | } 123 | } 124 | } 125 | 126 | 127 | 128 | template class adaflo::DiagonalPreconditioner; 129 | template class adaflo::DiagonalPreconditioner; 130 | -------------------------------------------------------------------------------- /include/adaflo/parameters.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2009 - 2016 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | #ifndef __adaflo_parameters_h 17 | #define __adaflo_parameters_h 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | namespace adaflo 27 | { 28 | using namespace dealii; 29 | 30 | struct FlowParameters 31 | { 32 | // allows to defer construction to a derived class. Handle with care, as 33 | // parameters are not default-initialized 34 | FlowParameters(); 35 | 36 | FlowParameters(const std::string ¶meter_filename); 37 | 38 | static void 39 | declare_parameters(ParameterHandler &prm); 40 | 41 | void 42 | parse_parameters(const std::string parameter_filename, ParameterHandler &prm); 43 | 44 | void 45 | parse_parameters(ParameterHandler &prm); 46 | 47 | void 48 | check_for_file(const std::string ¶meter_filename, ParameterHandler &prm) const; 49 | 50 | unsigned int dimension; 51 | unsigned int global_refinements; 52 | unsigned int adaptive_refinements; 53 | bool use_anisotropic_refinement; 54 | bool use_simplex_mesh; 55 | 56 | enum PhysicalType 57 | { 58 | incompressible, 59 | incompressible_stationary, 60 | stokes 61 | } physical_type; 62 | 63 | std::map get_beta_formulation_convective_term_momentum_balance = 64 | { 65 | {"conservative", 1.0}, 66 | {"convective", 0.0}, 67 | {"skew-symmetric", 0.5}, 68 | }; 69 | double beta_convective_term_momentum_balance; 70 | unsigned int velocity_degree; 71 | bool augmented_taylor_hood; 72 | double viscosity; 73 | double density; 74 | double damping; 75 | double tau_grad_div; 76 | unsigned int max_nl_iteration; 77 | double tol_nl_iteration; 78 | enum Linearization 79 | { 80 | coupled_implicit_newton, 81 | coupled_implicit_picard, 82 | coupled_velocity_semi_implicit, 83 | coupled_velocity_explicit, 84 | projection 85 | } linearization; 86 | 87 | unsigned int max_lin_iteration; 88 | double tol_lin_iteration; 89 | bool rel_lin_iteration; 90 | enum PreconditionVelocity 91 | { 92 | u_ilu, 93 | u_ilu_scalar, 94 | u_amg_linear, 95 | u_amg 96 | } precondition_velocity; 97 | enum PreconditionPressure 98 | { 99 | p_mass_diag, 100 | p_mass_ilu 101 | } precondition_pressure; 102 | unsigned int iterations_before_inner_solvers; 103 | 104 | std::string output_filename; 105 | unsigned int output_verbosity; 106 | double output_frequency; 107 | unsigned int print_solution_fields; 108 | bool output_wall_times; 109 | bool output_memory; 110 | 111 | TimeSteppingParameters::Scheme time_step_scheme; 112 | double start_time; 113 | double end_time; 114 | double time_step_size_start; 115 | double time_stepping_cfl; 116 | double time_stepping_coef2; 117 | double time_step_tolerance; 118 | double time_step_size_max; 119 | double time_step_size_min; 120 | 121 | // Two-phase specific parameters 122 | double density_diff; 123 | double viscosity_diff; 124 | 125 | double surface_tension; 126 | double gravity; 127 | double epsilon; 128 | double diffusion_length; // only useful in Cahn-Hilliard 129 | double contact_angle; // only useful in Cahn-Hilliard 130 | 131 | bool pressure_constraint; 132 | 133 | unsigned int concentration_subdivisions; 134 | unsigned int curvature_correction; // only for level set 135 | bool interpolate_grad_onto_pressure; // only for level set 136 | bool surface_tension_from_heaviside; // only for level set 137 | bool approximate_projections; // only for level set 138 | bool ch_do_newton; // only for Cahn-Hilliard 139 | bool do_iteration; // only for Cahn-Hilliard 140 | unsigned int n_reinit_steps; // only for level set 141 | unsigned int n_initial_reinit_steps; // only for level set 142 | bool convection_stabilization; 143 | }; 144 | } // namespace adaflo 145 | 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /include/adaflo/level_set_okz_compute_normal.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2020 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | 17 | #ifndef __adaflo_level_set_compute_normal_h 18 | #define __adaflo_level_set_compute_normal_h 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | namespace adaflo 30 | { 31 | using namespace dealii; 32 | 33 | 34 | /** 35 | * Parameters of the advection-concentration operator. 36 | */ 37 | struct LevelSetOKZSolverComputeNormalParameter 38 | { 39 | /** 40 | * TODO 41 | */ 42 | unsigned int dof_index_ls; 43 | 44 | /** 45 | * TODO 46 | */ 47 | unsigned int dof_index_normal; 48 | 49 | /** 50 | * TODO 51 | */ 52 | unsigned int quad_index; 53 | 54 | /** 55 | * TODO 56 | */ 57 | double epsilon; 58 | 59 | /** 60 | * TODO 61 | */ 62 | bool approximate_projections; 63 | /** 64 | * TODO 65 | */ 66 | double damping_scale_factor = 4.0; 67 | }; 68 | 69 | template 70 | class LevelSetOKZSolverComputeNormal 71 | { 72 | public: 73 | using VectorType = LinearAlgebra::distributed::Vector; 74 | using BlockVectorType = LinearAlgebra::distributed::BlockVector; 75 | 76 | LevelSetOKZSolverComputeNormal( 77 | BlockVectorType &normal_vector_field, 78 | BlockVectorType &normal_vector_rhs, 79 | const VectorType &level_set_field, 80 | const AlignedVector> &cell_diameters, 81 | const double &epsilon_used, 82 | const double &minimal_edge_length, 83 | const AffineConstraints &constraints_normals, 84 | const LevelSetOKZSolverComputeNormalParameter ¶meters, 85 | const MatrixFree &matrix_free, 86 | const DiagonalPreconditioner &preconditioner, 87 | const std::shared_ptr &projection_matrix, 88 | const std::shared_ptr &ilu_projection_matrix); 89 | 90 | virtual ~LevelSetOKZSolverComputeNormal() = default; 91 | 92 | virtual void 93 | compute_normal(const bool fast_computation); 94 | 95 | void 96 | compute_normal_vmult(BlockVectorType &dst, const BlockVectorType &sr) const; 97 | 98 | private: 99 | template 100 | void 101 | local_compute_normal(const MatrixFree &data, 102 | LinearAlgebra::distributed::BlockVector &dst, 103 | const LinearAlgebra::distributed::BlockVector &src, 104 | const std::pair &cell_range) const; 105 | 106 | template 107 | void 108 | local_compute_normal_rhs( 109 | const MatrixFree &data, 110 | BlockVectorType &dst, 111 | const VectorType &src, 112 | const std::pair &cell_range) const; 113 | 114 | /** 115 | * Parameters 116 | */ 117 | const LevelSetOKZSolverComputeNormalParameter parameters; // [i] 118 | 119 | /** 120 | * Vector section 121 | */ 122 | BlockVectorType &normal_vector_field; // [o] 123 | BlockVectorType &normal_vector_rhs; // [-] 124 | const VectorType &level_set_solution; // [i] 125 | 126 | /** 127 | * MatrixFree 128 | */ 129 | const MatrixFree &matrix_free; // [i] 130 | const AffineConstraints &constraints_normals; // [i] 131 | 132 | /** 133 | * Physics section 134 | */ 135 | const AlignedVector> &cell_diameters; // [i] 136 | const double &epsilon_used; // [i] 137 | const double &minimal_edge_length; // [i] 138 | 139 | /** 140 | * Solver section 141 | */ 142 | const DiagonalPreconditioner &preconditioner; // [i] 143 | const std::shared_ptr &projection_matrix; // [i] 144 | const std::shared_ptr &ilu_projection_matrix; // [i] 145 | }; 146 | } // namespace adaflo 147 | 148 | #endif 149 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | # 2 | # Similar clang-format options as in deal.II 3 | # 4 | 5 | AccessModifierOffset: -2 6 | 7 | AlignAfterOpenBracket: Align 8 | AlignConsecutiveAssignments: true 9 | AlignConsecutiveDeclarations: true 10 | AlignEscapedNewlines: Left 11 | AlignOperands: true 12 | AlignTrailingComments: true 13 | 14 | AllowAllParametersOfDeclarationOnNextLine: false 15 | AllowShortBlocksOnASingleLine: false 16 | AllowShortCaseLabelsOnASingleLine: false 17 | AllowShortFunctionsOnASingleLine: None 18 | AllowShortIfStatementsOnASingleLine: false 19 | AllowShortLoopsOnASingleLine: false 20 | 21 | AlwaysBreakAfterReturnType: All 22 | AlwaysBreakBeforeMultilineStrings: false 23 | AlwaysBreakTemplateDeclarations: true 24 | 25 | BinPackArguments: false 26 | BinPackParameters: false 27 | 28 | BraceWrapping: 29 | AfterClass: true 30 | AfterControlStatement: true 31 | AfterEnum: true 32 | AfterExternBlock: true 33 | AfterFunction: true 34 | AfterNamespace: true 35 | AfterStruct: true 36 | AfterUnion: true 37 | BeforeCatch: true 38 | BeforeElse: true 39 | IndentBraces: true 40 | SplitEmptyFunction: false 41 | SplitEmptyRecord: false 42 | SplitEmptyNamespace: false 43 | 44 | BreakBeforeBinaryOperators: None 45 | BreakBeforeBraces: Custom 46 | BreakBeforeInheritanceComma: false 47 | BreakBeforeTernaryOperators: false 48 | BreakConstructorInitializers: BeforeComma 49 | BreakStringLiterals: false 50 | 51 | ColumnLimit: 90 52 | 53 | CompactNamespaces: false 54 | 55 | ConstructorInitializerIndentWidth: 2 56 | 57 | ContinuationIndentWidth: 2 58 | 59 | Cpp11BracedListStyle: true 60 | 61 | DerivePointerAlignment: false 62 | 63 | FixNamespaceComments: true 64 | 65 | IncludeBlocks: Regroup 66 | IncludeCategories: 67 | # config.h must always be first: 68 | - Regex: "deal.II/base/config.h" 69 | Priority: -1 70 | # deal.II folders in sorted order: 71 | - Regex: "deal.II/algorithms/.*\\.h" 72 | Priority: 110 73 | - Regex: "deal.II/base/.*\\.h" 74 | Priority: 120 75 | - Regex: "deal.II/boost_adaptors/.*\\.h" 76 | Priority: 125 77 | - Regex: "deal.II/differentiation/.*\\.h" 78 | Priority: 130 79 | - Regex: "deal.II/distributed/.*\\.h" 80 | Priority: 140 81 | - Regex: "deal.II/dofs/.*\\.h" 82 | Priority: 150 83 | - Regex: "deal.II/fe/.*\\.h" 84 | Priority: 160 85 | - Regex: "deal.II/gmsh/.*\\.h" 86 | Priority: 170 87 | - Regex: "deal.II/grid/.*\\.h" 88 | Priority: 180 89 | - Regex: "deal.II/hp/.*\\.h" 90 | Priority: 190 91 | - Regex: "deal.II/integrators/.*\\.h" 92 | Priority: 200 93 | - Regex: "deal.II/lac/.*\\.h" 94 | Priority: 210 95 | - Regex: "deal.II/matrix_free/.*\\.h" 96 | Priority: 220 97 | - Regex: "deal.II/meshworker/.*\\.h" 98 | Priority: 230 99 | - Regex: "deal.II/multigrid/.*\\.h" 100 | Priority: 240 101 | - Regex: "deal.II/non_matching/.*\\.h" 102 | Priority: 250 103 | - Regex: "deal.II/numerics/.*\\.h" 104 | Priority: 260 105 | - Regex: "deal.II/opencascade/.*\\.h" 106 | Priority: 270 107 | - Regex: "deal.II/optimization/.*\\.h" 108 | Priority: 280 109 | - Regex: "deal.II/particles/.*\\.h" 110 | Priority: 290 111 | - Regex: "deal.II/physics/.*\\.h" 112 | Priority: 300 113 | - Regex: "deal.II/simplex/.*\\.h" 114 | Priority: 310 115 | - Regex: "deal.II/sundials/.*\\.h" 116 | Priority: 320 117 | # put boost right after deal: 118 | - Regex: "" 119 | Priority: 500 120 | # try to group PETSc headers: 121 | - Regex: "" 122 | Priority: 1000 123 | # try to catch all third party headers and put them after deal.II but before 124 | # standard headers: 125 | - Regex: "<.*\\.(h|hpp|hxx)>" 126 | Priority: 2000 127 | # match all standard headers. Things like '#include ' should be 128 | # surrounded by #ifdef checks (which will not be merged by clang-format) so they 129 | # should not be caught here 130 | - Regex: "<[a-z_]+>" 131 | Priority: 100000 132 | # make sure that "../tests.h" appears before all other local include files 133 | # such that replacing Assert in tests also applies to the testing header files. 134 | - Regex: "\\.\\./tests\\.h" 135 | Priority: 200000 136 | 137 | IndentCaseLabels: true 138 | IndentPPDirectives: AfterHash 139 | IndentWidth: 2 140 | 141 | IndentWrappedFunctionNames: false 142 | 143 | KeepEmptyLinesAtTheStartOfBlocks: false 144 | 145 | Language: Cpp 146 | 147 | MaxEmptyLinesToKeep: 3 148 | 149 | NamespaceIndentation: All 150 | 151 | PenaltyBreakBeforeFirstCallParameter: 90 152 | 153 | PointerAlignment: Right 154 | 155 | ReflowComments: true 156 | CommentPragmas: '( \| |\*--|
  • |@ref | @p |@param |@name |@returns |@warning |@ingroup |@author |@date |@related |@relates |@relatesalso |@deprecated |@image |@return |@brief |@attention |@copydoc |@addtogroup |@todo |@tparam |@see |@note |@skip |@skipline |@until |@line |@dontinclude |@include)' 157 | 158 | SortIncludes: true 159 | SortUsingDeclarations: true 160 | 161 | SpaceAfterCStyleCast: false 162 | SpaceAfterTemplateKeyword: true 163 | SpaceBeforeAssignmentOperators: true 164 | SpaceBeforeParens: ControlStatements 165 | SpaceInEmptyParentheses: false 166 | SpacesBeforeTrailingComments: 1 167 | SpacesInAngles: false 168 | SpacesInCStyleCastParentheses: false 169 | SpacesInContainerLiterals: false 170 | SpacesInParentheses: false 171 | SpacesInSquareBrackets: false 172 | 173 | Standard: Cpp11 174 | 175 | TabWidth: 2 176 | 177 | UseTab: Never 178 | -------------------------------------------------------------------------------- /include/adaflo/phase_field.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2008 - 2016 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | #ifndef __adaflo_phase_field_h_ 17 | #define __adaflo_phase_field_h_ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | namespace dealii 36 | { 37 | namespace TrilinosWrappers 38 | { 39 | class PreconditionAMG; 40 | } 41 | } // namespace dealii 42 | 43 | 44 | namespace adaflo 45 | { 46 | using namespace dealii; 47 | 48 | 49 | template 50 | class PhaseFieldSolver : public TwoPhaseBaseAlgorithm 51 | { 52 | public: 53 | PhaseFieldSolver(const FlowParameters ¶meters, Triangulation &triangulation); 54 | 55 | virtual ~PhaseFieldSolver() 56 | {} 57 | 58 | virtual void 59 | distribute_dofs() override; 60 | virtual void 61 | initialize_data_structures() override; 62 | virtual std::pair 63 | advance_time_step() override; 64 | 65 | void 66 | vmult(LinearAlgebra::distributed::BlockVector &dst, 67 | const LinearAlgebra::distributed::BlockVector &src) const; 68 | void 69 | mass_vmult(LinearAlgebra::distributed::Vector &dst, 70 | const LinearAlgebra::distributed::Vector &src) const; 71 | 72 | const LinearAlgebra::distributed::Vector *velocity_vector; 73 | 74 | virtual void 75 | transform_distance_function( 76 | LinearAlgebra::distributed::Vector &vector) const override; 77 | 78 | protected: 79 | virtual void 80 | compute_force(); 81 | virtual void 82 | advance_cahn_hilliard(); 83 | 84 | double 85 | compute_residual(); 86 | 87 | virtual void 88 | print_n_dofs() const override; 89 | 90 | // compute the density on faces needed for the Navier-Stokes preconditioner 91 | // with FE_Q_DG0 elements 92 | void 93 | compute_density_on_faces(); 94 | 95 | void 96 | create_cahn_hilliard_preconditioner(); 97 | void 98 | solve_cahn_hilliard(); 99 | 100 | virtual bool 101 | mark_cells_for_refinement() override; 102 | 103 | // matrix-free worker operations for various operations 104 | template 105 | void 106 | local_compute_force(const MatrixFree &data, 107 | LinearAlgebra::distributed::Vector &dst, 108 | const LinearAlgebra::distributed::Vector &src, 109 | const std::pair &cell_range); 110 | 111 | template 112 | void 113 | local_residual(const MatrixFree &data, 114 | LinearAlgebra::distributed::BlockVector &dst, 115 | const LinearAlgebra::distributed::BlockVector &src, 116 | const std::pair &cell_range) const; 117 | 118 | template 119 | void 120 | local_vmult(const MatrixFree &data, 121 | LinearAlgebra::distributed::BlockVector &dst, 122 | const LinearAlgebra::distributed::BlockVector &src, 123 | const std::pair &cell_range) const; 124 | 125 | template 126 | void 127 | local_mass(const MatrixFree &data, 128 | LinearAlgebra::distributed::Vector &dst, 129 | const LinearAlgebra::distributed::Vector &src, 130 | const std::pair &cell_range) const; 131 | 132 | template 133 | void 134 | apply_contact_bc(LinearAlgebra::distributed::BlockVector &dst, 135 | const LinearAlgebra::distributed::BlockVector &src) const; 136 | 137 | const FlowParameters ¶meters; 138 | 139 | TrilinosWrappers::SparseMatrix preconditioner_matrix; 140 | std::shared_ptr amg_preconditioner; 141 | 142 | FullMatrix interpolation_concentration_pressure; 143 | 144 | mutable AlignedVector>> evaluated_convection; 145 | mutable AlignedVector> evaluated_phi; 146 | mutable std::vector face_evaluated_c; 147 | std::vector face_indices; 148 | std::vector face_JxW; 149 | Table<2, double> face_matrix; 150 | }; 151 | } // namespace adaflo 152 | 153 | #endif 154 | -------------------------------------------------------------------------------- /include/adaflo/level_set_okz_compute_curvature.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2020 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | 17 | #ifndef __adaflo_level_compute_curvature_h 18 | #define __adaflo_level_compute_curvature_h 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | namespace adaflo 32 | { 33 | using namespace dealii; 34 | 35 | /** 36 | * Parameters of the advection-concentration operator. 37 | */ 38 | struct LevelSetOKZSolverComputeCurvatureParameter 39 | { 40 | /** 41 | * TODO 42 | */ 43 | unsigned int dof_index_ls; 44 | 45 | /** 46 | * TODO 47 | */ 48 | unsigned int dof_index_curvature; 49 | 50 | /** 51 | * TODO 52 | */ 53 | unsigned int dof_index_normal; 54 | 55 | /** 56 | * TODO 57 | */ 58 | unsigned int quad_index; 59 | 60 | /** 61 | * TODO 62 | */ 63 | double epsilon; 64 | 65 | /** 66 | * TODO 67 | */ 68 | bool approximate_projections; 69 | 70 | /** 71 | * TODO 72 | */ 73 | bool curvature_correction; 74 | }; 75 | 76 | template 77 | class LevelSetOKZSolverComputeCurvature 78 | { 79 | public: 80 | LevelSetOKZSolverComputeCurvature( 81 | const AlignedVector> &cell_diameters, 82 | const LinearAlgebra::distributed::BlockVector &normal_vector_field, 83 | const AffineConstraints &constraints_curvature, 84 | const AffineConstraints &constraints, 85 | const double &epsilon_used, 86 | LinearAlgebra::distributed::Vector &system_rhs, 87 | const LevelSetOKZSolverComputeCurvatureParameter ¶meters, 88 | LinearAlgebra::distributed::Vector &solution_curvature, 89 | const LinearAlgebra::distributed::Vector &solution_ls, 90 | const MatrixFree &matrix_free, 91 | const DiagonalPreconditioner &preconditioner, 92 | std::shared_ptr &projection_matrix, 93 | std::shared_ptr &ilu_projection_matrix); 94 | 95 | virtual ~LevelSetOKZSolverComputeCurvature() = default; 96 | 97 | virtual void 98 | compute_curvature(const bool diffuse_large_values = false); 99 | 100 | void 101 | compute_curvature_vmult(LinearAlgebra::distributed::Vector &dst, 102 | const LinearAlgebra::distributed::Vector &srcc, 103 | const bool apply_diffusion) const; 104 | 105 | private: 106 | // diffusion_setting: 0: both terms, 1: only mass, 2: only diffusion 107 | template 108 | void 109 | local_compute_curvature( 110 | const MatrixFree &data, 111 | LinearAlgebra::distributed::Vector &dst, 112 | const LinearAlgebra::distributed::Vector &src, 113 | const std::pair &cell_range) const; 114 | template 115 | void 116 | local_compute_curvature_rhs( 117 | const MatrixFree &data, 118 | LinearAlgebra::distributed::Vector &dst, 119 | const LinearAlgebra::distributed::Vector &src, 120 | const std::pair &cell_range) const; 121 | 122 | /** 123 | * Parameters 124 | */ 125 | const LevelSetOKZSolverComputeCurvatureParameter parameters; // [i] 126 | 127 | /** 128 | * Vector section 129 | */ 130 | LinearAlgebra::distributed::Vector &solution_curvature; // [i] 131 | LinearAlgebra::distributed::Vector &rhs; // [-] 132 | const LinearAlgebra::distributed::Vector &solution_ls; // [i] 133 | const LinearAlgebra::distributed::BlockVector &normal_vector_field; // [i] 134 | 135 | /** 136 | * MatrixFree 137 | */ 138 | const MatrixFree &matrix_free; // [i] 139 | const AffineConstraints &constraints_curvature; // [i] 140 | const AffineConstraints &constraints; // [i] 141 | 142 | /** 143 | * Physics section 144 | */ 145 | const AlignedVector> &cell_diameters; // [i] 146 | const double &epsilon_used; // [i] 147 | 148 | /** 149 | * Solver section 150 | */ 151 | const DiagonalPreconditioner &preconditioner; // [i] 152 | std::shared_ptr &projection_matrix; // [i] 153 | std::shared_ptr &ilu_projection_matrix; // [i] 154 | }; 155 | } // namespace adaflo 156 | 157 | #endif 158 | -------------------------------------------------------------------------------- /include/adaflo/level_set_okz_template_instantations.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2020 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | 17 | #ifndef __adaflo_level_set_okz_template_instantiations_h 18 | #define __adaflo_level_set_okz_template_instantiations_h 19 | 20 | #define EXPAND_OPERATIONS(OPERATION) \ 21 | if (this->navier_stokes.get_dof_handler_u().get_fe().reference_cell() != \ 22 | ReferenceCells::get_hypercube()) \ 23 | { \ 24 | OPERATION(-1, -1); \ 25 | } \ 26 | else \ 27 | { \ 28 | const unsigned int degree_u = \ 29 | this->navier_stokes.get_dof_handler_u().get_fe().degree; \ 30 | const unsigned int ls_degree = this->parameters.concentration_subdivisions; \ 31 | \ 32 | AssertThrow(degree_u >= 2 && degree_u <= 5, ExcNotImplemented()); \ 33 | AssertThrow(ls_degree >= 1 && ls_degree <= 4, ExcNotImplemented()); \ 34 | if (ls_degree == 1) \ 35 | { \ 36 | if (degree_u == 2) \ 37 | OPERATION(1, 2); \ 38 | else if (degree_u == 3) \ 39 | OPERATION(1, 3); \ 40 | else if (degree_u == 4) \ 41 | OPERATION(1, 4); \ 42 | else if (degree_u == 5) \ 43 | OPERATION(1, 5); \ 44 | } \ 45 | else if (ls_degree == 2) \ 46 | { \ 47 | if (degree_u == 2) \ 48 | OPERATION(2, 2); \ 49 | else if (degree_u == 3) \ 50 | OPERATION(2, 3); \ 51 | else if (degree_u == 4) \ 52 | OPERATION(2, 4); \ 53 | else if (degree_u == 5) \ 54 | OPERATION(2, 5); \ 55 | } \ 56 | else if (ls_degree == 3) \ 57 | { \ 58 | if (degree_u == 2) \ 59 | OPERATION(3, 2); \ 60 | else if (degree_u == 3) \ 61 | OPERATION(3, 3); \ 62 | else if (degree_u == 4) \ 63 | OPERATION(3, 4); \ 64 | else if (degree_u == 5) \ 65 | OPERATION(3, 5); \ 66 | } \ 67 | else if (ls_degree == 4) \ 68 | { \ 69 | if (degree_u == 2) \ 70 | OPERATION(4, 2); \ 71 | else if (degree_u == 3) \ 72 | OPERATION(4, 3); \ 73 | else if (degree_u == 4) \ 74 | OPERATION(4, 4); \ 75 | else if (degree_u == 5) \ 76 | OPERATION(4, 5); \ 77 | } \ 78 | } 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /include/adaflo/level_set_base.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2011 - 2016 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | #ifndef __adaflo_level_set_base_h 17 | #define __adaflo_level_set_base_h 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | namespace adaflo 27 | { 28 | using namespace dealii; 29 | 30 | template 31 | class LevelSetBaseAlgorithm : public TwoPhaseBaseAlgorithm 32 | { 33 | public: 34 | LevelSetBaseAlgorithm(const FlowParameters ¶meters, 35 | Triangulation &triangulation); 36 | virtual ~LevelSetBaseAlgorithm() 37 | {} 38 | 39 | virtual void 40 | setup_problem(const Function &initial_velocity_field, 41 | const Function &initial_distance_function = 42 | Functions::ZeroFunction()) override; 43 | virtual void 44 | initialize_data_structures() override; 45 | 46 | virtual std::pair 47 | advance_time_step() override; // perform one time step 48 | 49 | // write whole solution to file 50 | virtual void 51 | output_solution(const std::string output_name, 52 | const unsigned int n_subdivisions = 0) const override; 53 | 54 | double old_residual; 55 | 56 | protected: 57 | virtual void 58 | evaluate_heaviside_function(FEValues &fe_values, 59 | std::vector &cell_heaviside, 60 | std::vector> &cell_delta) const override 61 | { 62 | for (unsigned int d = 0; d < dim; ++d) 63 | { 64 | // We extract the heaviside and the normal vector. This latter one 65 | // will be used to compute the area in 3D and perimeter in 2D. 66 | 67 | fe_values.get_function_values(normal_vector_field.block(d), cell_heaviside); 68 | for (unsigned int q = 0; q < cell_heaviside.size(); ++q) 69 | cell_delta[q][d] = cell_heaviside[q]; 70 | } 71 | fe_values.get_function_values(heaviside, cell_heaviside); 72 | } 73 | 74 | // adaptive grid refinement around the interface (based on values of 75 | // concentration gradient) 76 | virtual bool 77 | mark_cells_for_refinement() override; 78 | 79 | // compute the force term and variable density/viscosity for the 80 | // Navier--Stokes equations 81 | virtual void 82 | compute_force() = 0; 83 | 84 | // compute the density on faces needed for the Navier-Stokes preconditioner 85 | // with FE_Q_DG0 elements 86 | void 87 | compute_density_on_faces(); 88 | 89 | // advection step 90 | virtual void 91 | advance_concentration() = 0; 92 | 93 | virtual void 94 | compute_normal(const bool fast_computation) = 0; 95 | 96 | virtual void 97 | compute_curvature(const bool diffuse_large_values = false) = 0; 98 | 99 | // performs reinitialization 100 | virtual void 101 | reinitialize(const unsigned int stab_steps, 102 | const unsigned int diff_steps = 0, 103 | const bool diffuse_cells_with_large_curvature_only = false) = 0; 104 | 105 | virtual void 106 | compute_heaviside() = 0; 107 | 108 | LinearAlgebra::distributed::Vector heaviside; 109 | 110 | LinearAlgebra::distributed::BlockVector normal_vector_field; 111 | LinearAlgebra::distributed::BlockVector normal_vector_rhs; 112 | 113 | FullMatrix interpolation_concentration_pressure; 114 | 115 | unsigned int last_smoothing_step, last_refine_step; 116 | }; 117 | 118 | 119 | 120 | // this is the integral of the sqrt-formed discrete delta function described 121 | // in Peskin (The immersed boundary method, Acta Numerica 11:479--517, 2002) 122 | inline double 123 | discrete_heaviside(const double x) 124 | { 125 | if (x > 0) 126 | return 1. - discrete_heaviside(-x); 127 | else if (x < -2.) 128 | return 0; 129 | else if (x < -1.) 130 | { 131 | return (1. / 8. * (5. * x + x * x) + 132 | 1. / 32. * (-3. - 2. * x) * std::sqrt(-7. - 12. * x - 4. * x * x) - 133 | 1. / 16 * std::asin(std::sqrt(2.) * (x + 3. / 2.)) + 23. / 32. - 134 | numbers::PI / 64.); 135 | } 136 | else 137 | { 138 | return (1. / 8. * (3. * x + x * x) - 139 | 1. / 32. * (-1. - 2. * x) * std::sqrt(1. - 4. * x - 4. * x * x) + 140 | 1. / 16 * std::asin(std::sqrt(2.) * (x + 1. / 2.)) + 15. / 32. - 141 | numbers::PI / 64.); 142 | } 143 | } 144 | 145 | 146 | // and this is the actual delta function from Peskin 147 | inline double 148 | discrete_delta(const double x) 149 | { 150 | if (x > 0) 151 | return discrete_delta(-x); 152 | else if (x < -2.) 153 | return 0; 154 | else if (x < -1.) 155 | return 1. / 8. * (5. + 2. * x - std::sqrt(-7. - 12. * x - 4. * x * x)); 156 | else 157 | return 1. / 8. * (3. + 2. * x + std::sqrt(1. - 4. * x - 4. * x * x)); 158 | } 159 | 160 | 161 | // this is a cutoff function 162 | inline double 163 | cutoff_function(const double x) 164 | { 165 | const double beta = 5., gamma = 7.; 166 | const double abx = std::fabs(x); 167 | if (abx < beta) 168 | return 1; 169 | else if (abx < gamma) 170 | return (abx - gamma) * (abx - gamma) * (2 * abx + gamma - 3 * beta) / 171 | ((gamma - beta) * (gamma - beta) * (gamma - beta)); 172 | else 173 | return 0; 174 | } 175 | } // namespace adaflo 176 | 177 | #endif 178 | -------------------------------------------------------------------------------- /include/adaflo/level_set_okz_reinitialization.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2020 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | 17 | #ifndef __adaflo_level_set_reinitialization_h 18 | #define __adaflo_level_set_reinitialization_h 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | namespace adaflo 32 | { 33 | using namespace dealii; 34 | 35 | 36 | /** 37 | * Parameters of the reinitialization operator. 38 | */ 39 | struct LevelSetOKZSolverReinitializationParameter 40 | { 41 | /** 42 | * TODO 43 | */ 44 | unsigned int dof_index_ls; 45 | 46 | /** 47 | * TODO 48 | */ 49 | unsigned int dof_index_normal; 50 | 51 | /** 52 | * TODO 53 | */ 54 | unsigned int quad_index; 55 | 56 | /** 57 | * TODO 58 | */ 59 | bool do_iteration; 60 | 61 | /** 62 | * TODO 63 | */ 64 | TimeSteppingParameters time; 65 | }; 66 | 67 | template 68 | class LevelSetOKZSolverReinitialization 69 | { 70 | public: 71 | using VectorType = LinearAlgebra::distributed::Vector; 72 | using BlockVectorType = LinearAlgebra::distributed::BlockVector; 73 | 74 | LevelSetOKZSolverReinitialization( 75 | const BlockVectorType &normal_vector_field, 76 | const AlignedVector> &cell_diameters, 77 | const double &epsilon_used, 78 | const double &minimal_edge_length, 79 | const AffineConstraints &constraints, 80 | VectorType &solution_update, 81 | VectorType &solution, 82 | VectorType &system_rhs, 83 | const ConditionalOStream &pcout, 84 | const DiagonalPreconditioner &preconditioner, 85 | const std::pair &last_concentration_range, 86 | const LevelSetOKZSolverReinitializationParameter ¶meters, 87 | bool &first_reinit_step, 88 | const MatrixFree &matrix_free) 89 | : parameters(parameters) 90 | , solution(solution) 91 | , solution_update(solution_update) 92 | , system_rhs(system_rhs) 93 | , normal_vector_field(normal_vector_field) 94 | , matrix_free(matrix_free) 95 | , constraints(constraints) 96 | , cell_diameters(cell_diameters) 97 | , epsilon_used(epsilon_used) 98 | , minimal_edge_length(minimal_edge_length) 99 | , last_concentration_range(last_concentration_range) 100 | , first_reinit_step(first_reinit_step) 101 | , pcout(pcout) 102 | , time_stepping(parameters.time) 103 | , preconditioner(preconditioner) 104 | {} 105 | 106 | // performs reinitialization 107 | void 108 | reinitialize( 109 | const double dt, 110 | const unsigned int stab_steps, 111 | const unsigned int diff_steps = 0, 112 | const std::function &compute_normal = [](const bool) {}); 113 | 114 | void 115 | reinitialization_vmult(VectorType &dst, 116 | const VectorType &src, 117 | const bool diffuse_only) const; 118 | 119 | private: 120 | template 121 | void 122 | local_reinitialize(const MatrixFree &data, 123 | VectorType &dst, 124 | const VectorType &src, 125 | const std::pair &cell_range) const; 126 | 127 | template 128 | void 129 | local_reinitialize_rhs(const MatrixFree &data, 130 | VectorType &dst, 131 | const VectorType &src, 132 | const std::pair &cell_range); 133 | 134 | /** 135 | * Parameters 136 | */ 137 | const LevelSetOKZSolverReinitializationParameter parameters; 138 | 139 | /** 140 | * Vector section 141 | */ 142 | VectorType &solution; // [o] 143 | VectorType &solution_update; // [-] 144 | VectorType &system_rhs; // [-] 145 | 146 | const BlockVectorType &normal_vector_field; // [i]; 147 | 148 | /** 149 | * MatrixFree 150 | */ 151 | const MatrixFree &matrix_free; // [i] 152 | const AffineConstraints &constraints; // [i] 153 | 154 | const AlignedVector> &cell_diameters; // [i] 155 | const double &epsilon_used; // [i] 156 | const double &minimal_edge_length; // [i] 157 | const std::pair &last_concentration_range; // [i] 158 | bool &first_reinit_step; // [?] 159 | AlignedVector>> evaluated_normal; // [-] 160 | 161 | /** 162 | * Utility 163 | */ 164 | const ConditionalOStream &pcout; // [i] 165 | TimeStepping time_stepping; // [-] 166 | 167 | /** 168 | * Solver section 169 | */ 170 | const DiagonalPreconditioner &preconditioner; // [i] 171 | }; 172 | } // namespace adaflo 173 | 174 | #endif 175 | -------------------------------------------------------------------------------- /tests/simplex_bubble_0.msh: -------------------------------------------------------------------------------- 1 | $MeshFormat 2 | 4.1 0 8 3 | $EndMeshFormat 4 | $Entities 5 | 4 4 1 0 6 | 1 0 0 0 0 7 | 2 1 0 0 0 8 | 3 1 2 0 0 9 | 4 0 2 0 0 10 | 1 -9.999999994736442e-08 -1e-07 -1e-07 1.0000001 1e-07 1e-07 0 2 1 -2 11 | 2 0.9999999000000001 -9.999999994736442e-08 -1e-07 1.0000001 2.0000001 1e-07 0 2 2 -3 12 | 3 -9.999999994736442e-08 1.9999999 -1e-07 1.0000001 2.0000001 1e-07 0 2 3 -4 13 | 4 -1e-07 -9.999999994736442e-08 -1e-07 1e-07 2.0000001 1e-07 0 2 4 -1 14 | 1 -9.999999994736442e-08 -9.999999994736442e-08 -1e-07 1.0000001 2.0000001 1e-07 0 4 1 2 3 4 15 | $EndEntities 16 | $Nodes 17 | 9 71 1 71 18 | 0 1 0 1 19 | 1 20 | 0 0 0 21 | 0 2 0 1 22 | 2 23 | 1 0 0 24 | 0 3 0 1 25 | 3 26 | 1 2 0 27 | 0 4 0 1 28 | 4 29 | 0 2 0 30 | 1 1 0 4 31 | 5 32 | 6 33 | 7 34 | 8 35 | 0.2000000000000003 0 0 36 | 0.400000000000001 0 0 37 | 0.6000000000000009 0 0 38 | 0.8000000000000004 0 0 39 | 1 2 0 8 40 | 9 41 | 10 42 | 11 43 | 12 44 | 13 45 | 14 46 | 15 47 | 16 48 | 1 0.2222222222222227 0 49 | 1 0.4444444444444451 0 50 | 1 0.6666666666666683 0 51 | 1 0.8888888888888914 0 52 | 1 1.111111111111113 0 53 | 1 1.333333333333335 0 54 | 1 1.555555555555557 0 55 | 1 1.777777777777778 0 56 | 1 3 0 4 57 | 17 58 | 18 59 | 19 60 | 20 61 | 0.7999999999999996 2 0 62 | 0.599999999999999 2 0 63 | 0.3999999999999991 2 0 64 | 0.1999999999999996 2 0 65 | 1 4 0 8 66 | 21 67 | 22 68 | 23 69 | 24 70 | 25 71 | 26 72 | 27 73 | 28 74 | 0 1.777777777777777 0 75 | 0 1.555555555555555 0 76 | 0 1.333333333333332 0 77 | 0 1.111111111111108 0 78 | 0 0.8888888888888871 0 79 | 0 0.6666666666666652 0 80 | 0 0.4444444444444433 0 81 | 0 0.2222222222222219 0 82 | 2 1 0 43 83 | 29 84 | 30 85 | 31 86 | 32 87 | 33 88 | 34 89 | 35 90 | 36 91 | 37 92 | 38 93 | 39 94 | 40 95 | 41 96 | 42 97 | 43 98 | 44 99 | 45 100 | 46 101 | 47 102 | 48 103 | 49 104 | 50 105 | 51 106 | 52 107 | 53 108 | 54 109 | 55 110 | 56 111 | 57 112 | 58 113 | 59 114 | 60 115 | 61 116 | 62 117 | 63 118 | 64 119 | 65 120 | 66 121 | 67 122 | 68 123 | 69 124 | 70 125 | 71 126 | 0.500204549543777 1.836968703403502 0 127 | 0.4997925291569011 0.1628917864881421 0 128 | 0.8009014793865801 1.219910100947746 0 129 | 0.1858443322694863 0.777662592131417 0 130 | 0.8077626249629203 0.7775756408808039 0 131 | 0.1875084534637197 1.23040774718219 0 132 | 0.8284584489899596 1.685454778258512 0 133 | 0.1717299116792679 0.3148714719907376 0 134 | 0.2022165522753777 1.674746498329199 0 135 | 0.7981237167788773 0.3248893116658338 0 136 | 0.8067677731472925 0.5541145291281443 0 137 | 0.6162947048307184 0.6661019592714306 0 138 | 0.6203039397350845 0.8800371293777591 0 139 | 0.4243324169446679 0.7767991663731144 0 140 | 0.424891779934066 0.5555240510241197 0 141 | 0.4347122329991159 0.9984208046637348 0 142 | 0.607472191605393 0.4566577145146186 0 143 | 0.1929006866288092 1.446869958984087 0 144 | 0.377993743796353 1.343123014902157 0 145 | 0.3912481398547105 1.544675813402685 0 146 | 0.5731505591650576 1.443468904848986 0 147 | 0.5667946848908031 1.223639228700108 0 148 | 0.1976662325727319 0.5512988158307606 0 149 | 0.8026471916006364 1.450061983577824 0 150 | 0.8119604958230693 0.989913119621008 0 151 | 0.2053224692974828 1.005484430545764 0 152 | 0.3069296299045916 1.845389461258956 0 153 | 0.6999999999999993 1.830982858534665 0 154 | 0.5990290346513707 1.642977401534424 0 155 | 0.6931236734219088 0.1543870786138011 0 156 | 0.3000000000000007 0.1690171414653344 0 157 | 0.4005772519638537 0.3571707359926833 0 158 | 0.6469345665669306 1.062384076662071 0 159 | 0.3544663168894949 1.160215045198791 0 160 | 0.1416623242029431 0.1486072028937598 0 161 | 0.8583376757970569 1.85139279710624 0 162 | 0.8582746773992718 0.1426732883270538 0 163 | 0.1418292364359938 1.859582747473187 0 164 | 0.3999255812459656 1.708951575585753 0 165 | 0.6024881187986153 0.2899341706350708 0 166 | 0.6877055230418867 1.334448901263718 0 167 | 0.3086858884993494 0.6658685579810097 0 168 | 0.3088544032611781 0.887032014500222 0 169 | $EndNodes 170 | $Elements 171 | 9 144 1 144 172 | 0 1 15 1 173 | 1 1 174 | 0 2 15 1 175 | 2 2 176 | 0 3 15 1 177 | 3 3 178 | 0 4 15 1 179 | 4 4 180 | 1 1 1 5 181 | 5 1 5 182 | 6 5 6 183 | 7 6 7 184 | 8 7 8 185 | 9 8 2 186 | 1 2 1 9 187 | 10 2 9 188 | 11 9 10 189 | 12 10 11 190 | 13 11 12 191 | 14 12 13 192 | 15 13 14 193 | 16 14 15 194 | 17 15 16 195 | 18 16 3 196 | 1 3 1 5 197 | 19 3 17 198 | 20 17 18 199 | 21 18 19 200 | 22 19 20 201 | 23 20 4 202 | 1 4 1 9 203 | 24 4 21 204 | 25 21 22 205 | 26 22 23 206 | 27 23 24 207 | 28 24 25 208 | 29 25 26 209 | 30 26 27 210 | 31 27 28 211 | 32 28 1 212 | 2 1 2 112 213 | 33 52 57 49 214 | 34 51 60 43 215 | 35 36 60 51 216 | 36 35 57 52 217 | 37 44 61 50 218 | 38 50 62 44 219 | 39 43 60 45 220 | 40 49 57 48 221 | 41 46 48 37 222 | 42 43 45 40 223 | 43 22 46 37 224 | 44 10 39 38 225 | 45 36 51 27 226 | 46 39 45 38 227 | 47 47 48 46 228 | 48 22 37 21 229 | 49 10 38 9 230 | 50 16 35 15 231 | 51 28 36 27 232 | 52 14 52 31 233 | 53 40 45 39 234 | 54 35 52 15 235 | 55 47 49 48 236 | 56 11 39 10 237 | 57 23 46 22 238 | 58 27 51 26 239 | 59 33 39 11 240 | 60 26 51 32 241 | 61 34 46 23 242 | 62 34 47 46 243 | 63 33 40 39 244 | 64 42 43 40 245 | 65 31 53 13 246 | 66 15 52 14 247 | 67 13 53 12 248 | 68 24 34 23 249 | 69 12 33 11 250 | 70 24 54 34 251 | 71 26 32 25 252 | 72 14 31 13 253 | 73 32 54 25 254 | 74 25 54 24 255 | 75 41 42 40 256 | 76 33 41 40 257 | 77 12 53 33 258 | 78 41 44 42 259 | 79 33 53 41 260 | 80 47 50 49 261 | 81 57 67 48 262 | 82 60 68 45 263 | 83 19 29 18 264 | 84 7 30 6 265 | 85 50 61 31 266 | 86 6 59 5 267 | 87 8 58 7 268 | 88 18 56 17 269 | 89 20 55 19 270 | 90 44 62 54 271 | 91 29 56 18 272 | 92 19 55 29 273 | 93 30 59 6 274 | 94 7 58 30 275 | 95 29 57 56 276 | 96 30 60 59 277 | 97 31 61 53 278 | 98 54 62 34 279 | 99 41 61 44 280 | 100 47 62 50 281 | 101 1 63 28 282 | 102 9 65 2 283 | 103 3 64 16 284 | 104 21 66 4 285 | 105 56 57 35 286 | 106 59 60 36 287 | 107 5 63 1 288 | 108 17 64 3 289 | 109 2 65 8 290 | 110 4 66 20 291 | 111 48 67 37 292 | 112 49 69 52 293 | 113 29 67 57 294 | 114 45 68 38 295 | 115 30 68 60 296 | 116 43 70 51 297 | 117 31 69 50 298 | 118 37 66 21 299 | 119 38 65 9 300 | 120 16 64 35 301 | 121 28 63 36 302 | 122 54 71 44 303 | 123 37 67 55 304 | 124 38 68 58 305 | 125 53 61 41 306 | 126 34 62 47 307 | 127 52 69 31 308 | 128 51 70 32 309 | 129 42 70 43 310 | 130 32 71 54 311 | 131 55 66 37 312 | 132 58 65 38 313 | 133 35 64 56 314 | 134 36 63 59 315 | 135 50 69 49 316 | 136 42 71 70 317 | 137 70 71 32 318 | 138 44 71 42 319 | 139 20 66 55 320 | 140 8 65 58 321 | 141 59 63 5 322 | 142 56 64 17 323 | 143 55 67 29 324 | 144 58 68 30 325 | $EndElements 326 | -------------------------------------------------------------------------------- /include/adaflo/level_set_okz_advance_concentration.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2020 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | 17 | #ifndef __adaflo_level_set_advance_concentration_h 18 | #define __adaflo_level_set_advance_concentration_h 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | 30 | namespace adaflo 31 | { 32 | using namespace dealii; 33 | 34 | /** 35 | * Parameters of the advection-concentration operator. 36 | */ 37 | struct LevelSetOKZSolverAdvanceConcentrationParameter 38 | { 39 | /** 40 | * TODO 41 | */ 42 | unsigned int dof_index_ls; 43 | 44 | /** 45 | * TODO 46 | */ 47 | unsigned int dof_index_vel; 48 | 49 | /** 50 | * TODO 51 | */ 52 | unsigned int quad_index; 53 | 54 | /** 55 | * TODO 56 | */ 57 | bool convection_stabilization; 58 | 59 | /** 60 | * TODO 61 | */ 62 | bool do_iteration; 63 | 64 | /** 65 | * TODO 66 | */ 67 | double tol_nl_iteration; 68 | 69 | /** 70 | * TODO 71 | */ 72 | TimeSteppingParameters time; 73 | }; 74 | 75 | /** 76 | * Boundary descriptors of the advection-concentration operator. 77 | */ 78 | template 79 | struct LevelSetOKZSolverAdvanceConcentrationBoundaryDescriptor 80 | { 81 | /** 82 | * TODO 83 | */ 84 | std::map>> dirichlet; 85 | 86 | /** 87 | * TODO 88 | */ 89 | std::set symmetry; 90 | }; 91 | 92 | template 93 | class LevelSetOKZSolverAdvanceConcentration 94 | { 95 | public: 96 | using VectorType = LinearAlgebra::distributed::Vector; 97 | 98 | LevelSetOKZSolverAdvanceConcentration( 99 | VectorType &solution, 100 | const VectorType &solution_old, 101 | const VectorType &solution_old_old, 102 | VectorType &increment, 103 | VectorType &rhs, 104 | const VectorType &vel_solution, 105 | const VectorType &vel_solution_old, 106 | const VectorType &vel_solution_old_old, 107 | const AlignedVector> &cell_diameters, 108 | const AffineConstraints &constraints, 109 | const ConditionalOStream &pcout, 110 | const LevelSetOKZSolverAdvanceConcentrationBoundaryDescriptor &boundary, 111 | const MatrixFree &matrix_free, 112 | const LevelSetOKZSolverAdvanceConcentrationParameter ¶meters, 113 | const DiagonalPreconditioner &preconditioner); 114 | 115 | virtual ~LevelSetOKZSolverAdvanceConcentration() = default; 116 | 117 | virtual void 118 | advance_concentration(const double dt); 119 | 120 | void 121 | advance_concentration_vmult(VectorType &dst, const VectorType &src) const; 122 | 123 | private: 124 | template 125 | void 126 | local_advance_concentration( 127 | const MatrixFree &data, 128 | VectorType &dst, 129 | const VectorType &src, 130 | const std::pair &cell_range) const; 131 | 132 | template 133 | void 134 | local_advance_concentration_rhs( 135 | const MatrixFree &data, 136 | VectorType &dst, 137 | const VectorType &src, 138 | const std::pair &cell_range); 139 | 140 | /** 141 | * Parameters 142 | */ 143 | const LevelSetOKZSolverAdvanceConcentrationParameter parameters; // [i] 144 | 145 | /** 146 | * Vector section 147 | */ 148 | VectorType &solution; // [o] new ls solution 149 | const VectorType &solution_old; // [i] old ls solution 150 | const VectorType &solution_old_old; // [i] old ls solution 151 | VectorType &increment; // [-] temp 152 | VectorType &rhs; // [-] temp 153 | 154 | const VectorType &vel_solution; // [i] new velocity solution 155 | const VectorType &vel_solution_old; // [i] old velocity solution 156 | const VectorType &vel_solution_old_old; // [i] old velocity solution 157 | 158 | /** 159 | * MatrixFree 160 | */ 161 | const MatrixFree &matrix_free; // [i] 162 | const AffineConstraints &constraints; // [i] 163 | 164 | /** 165 | * Utility 166 | */ 167 | const ConditionalOStream &pcout; // [i] 168 | TimeStepping time_stepping; // [i] 169 | 170 | /** 171 | * Physics section 172 | */ 173 | double global_omega_diameter; // [i] 174 | const AlignedVector> &cell_diameters; // [i] 175 | const LevelSetOKZSolverAdvanceConcentrationBoundaryDescriptor boundary; // [i] 176 | AlignedVector> artificial_viscosities; // [-] 177 | double global_max_velocity; // [o] 178 | AlignedVector>> evaluated_convection; // [o] 179 | 180 | /** 181 | * Solver section 182 | */ 183 | const DiagonalPreconditioner &preconditioner; // [i] preconditioner 184 | }; 185 | } // namespace adaflo 186 | 187 | #endif 188 | -------------------------------------------------------------------------------- /include/adaflo/block_matrix_extension.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2015 - 2016 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | #ifndef __adaflo_block_matrix_extension_h 17 | #define __adaflo_block_matrix_extension_h 18 | 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | namespace adaflo 26 | { 27 | using namespace dealii; 28 | 29 | class BlockMatrixExtension : public TrilinosWrappers::SparseMatrix 30 | { 31 | public: 32 | using TrilinosWrappers::SparseMatrix::vmult; 33 | 34 | void 35 | vmult(LinearAlgebra::distributed::BlockVector &dst, 36 | const LinearAlgebra::distributed::BlockVector &src) const 37 | { 38 | const Epetra_CrsMatrix &matrix = this->trilinos_matrix(); 39 | AssertDimension(size_type(dst.block(0).end() - dst.block(0).begin()), 40 | static_cast(matrix.RangeMap().NumMyPoints())); 41 | AssertDimension(size_type(src.block(0).end() - src.block(0).begin()), 42 | static_cast(matrix.DomainMap().NumMyPoints())); 43 | AssertDimension(dst.n_blocks(), src.n_blocks()); 44 | Assert(dst.n_blocks() < 16, ExcNotImplemented()); 45 | double *dst_ptrs[16], *src_ptrs[16]; 46 | for (unsigned int i = 0; i < dst.n_blocks(); ++i) 47 | { 48 | dst_ptrs[i] = dst.block(i).begin(); 49 | src_ptrs[i] = const_cast(src.block(i).begin()); 50 | } 51 | 52 | Epetra_MultiVector tril_dst(View, matrix.RangeMap(), dst_ptrs, dst.n_blocks()); 53 | Epetra_MultiVector tril_src(View, matrix.DomainMap(), src_ptrs, src.n_blocks()); 54 | 55 | const int ierr = matrix.Multiply(false, tril_src, tril_dst); 56 | Assert(ierr == 0, ExcTrilinosError(ierr)); 57 | (void)ierr; // removes -Wunused-variable in optimized mode 58 | } 59 | }; 60 | 61 | 62 | class BlockILUExtension : public TrilinosWrappers::PreconditionILU 63 | { 64 | public: 65 | using TrilinosWrappers::PreconditionBase::vmult; 66 | 67 | void 68 | vmult(LinearAlgebra::distributed::BlockVector &dst, 69 | const LinearAlgebra::distributed::BlockVector &src) const 70 | { 71 | Assert(preconditioner.get() != 0, ExcNotInitialized()); 72 | const Epetra_Operator &prec = *this->preconditioner; 73 | AssertDimension(size_type(dst.block(0).end() - dst.block(0).begin()), 74 | static_cast(prec.OperatorRangeMap().NumMyPoints())); 75 | AssertDimension(size_type(src.block(0).end() - src.block(0).begin()), 76 | static_cast(prec.OperatorDomainMap().NumMyPoints())); 77 | AssertDimension(dst.n_blocks(), src.n_blocks()); 78 | AssertThrow(dst.n_blocks() < 16, ExcNotImplemented()); 79 | double *dst_ptrs[16], *src_ptrs[16]; 80 | for (unsigned int i = 0; i < dst.n_blocks(); ++i) 81 | { 82 | dst_ptrs[i] = dst.block(i).begin(); 83 | src_ptrs[i] = const_cast(src.block(i).begin()); 84 | } 85 | 86 | Epetra_MultiVector tril_dst(View, 87 | prec.OperatorRangeMap(), 88 | dst_ptrs, 89 | dst.n_blocks()); 90 | Epetra_MultiVector tril_src(View, 91 | prec.OperatorDomainMap(), 92 | src_ptrs, 93 | src.n_blocks()); 94 | 95 | const int ierr = prec.ApplyInverse(tril_src, tril_dst); 96 | Assert(ierr == 0, ExcTrilinosError(ierr)); 97 | (void)ierr; // removes -Wunused-variable in optimized mode 98 | } 99 | }; 100 | 101 | 102 | 103 | template 104 | class ComponentILUExtension : public TrilinosWrappers::PreconditionILU 105 | { 106 | public: 107 | void 108 | initialize(const TrilinosWrappers::SparseMatrix &matrix, 109 | const TrilinosWrappers::PreconditionILU::AdditionalData &data, 110 | const std::vector &index_by_component) 111 | { 112 | this->dealii::TrilinosWrappers::PreconditionILU::initialize(matrix, data); 113 | this->index_by_component = index_by_component; 114 | src_cpy = 115 | std::make_unique(matrix.trilinos_matrix().DomainMap(), dim); 116 | dst_cpy = 117 | std::make_unique(matrix.trilinos_matrix().RangeMap(), dim); 118 | } 119 | 120 | // Application to a vector src, stored in dst (do not call the method vmult 121 | // in order to avoid overloading a virtual function in deal.II) 122 | void 123 | multiply(LinearAlgebra::distributed::Vector &dst, 124 | const LinearAlgebra::distributed::Vector &src) const 125 | { 126 | Assert(preconditioner.get() != 0, ExcNotInitialized()); 127 | const Epetra_Operator &prec = *this->preconditioner; 128 | const unsigned int local_size = index_by_component.size() / dim; 129 | AssertDimension((int)local_size, src_cpy->MyLength()); 130 | AssertDimension(size_type(dst.end() - dst.begin()), 131 | static_cast(prec.OperatorRangeMap().NumMyPoints()) * 132 | dim); 133 | AssertDimension(size_type(src.end() - src.begin()), 134 | static_cast(prec.OperatorDomainMap().NumMyPoints()) * 135 | dim); 136 | 137 | for (unsigned int i = 0; i < local_size; ++i) 138 | for (unsigned int d = 0; d < dim; ++d) 139 | (*src_cpy)[d][i] = src.local_element(index_by_component[i * dim + d]); 140 | 141 | const int ierr = prec.ApplyInverse(*src_cpy, *dst_cpy); 142 | Assert(ierr == 0, ExcTrilinosError(ierr)); 143 | (void)ierr; 144 | 145 | for (unsigned int i = 0; i < local_size; ++i) 146 | for (unsigned int d = 0; d < dim; ++d) 147 | dst.local_element(index_by_component[i * dim + d]) = (*dst_cpy)[d][i]; 148 | } 149 | 150 | private: 151 | std::vector index_by_component; 152 | mutable std::unique_ptr src_cpy, dst_cpy; 153 | }; 154 | } // namespace adaflo 155 | 156 | #endif 157 | -------------------------------------------------------------------------------- /tests/1d_flow.cc: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2021 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | #include 38 | 39 | #include 40 | #include 41 | 42 | #include 43 | #include 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | using namespace dealii; 50 | using namespace adaflo; 51 | 52 | /** 53 | * Simple test case for 1d Navier-Stokes 54 | * 55 | * 56 | * velocity(t=0) = 2 57 | * L=2.5 58 | * (pressure=2) +-------------------------------+ (p=1) 59 | * |--> x 60 | * 61 | */ 62 | 63 | 64 | template 65 | class ChannelFlow 66 | { 67 | public: 68 | ChannelFlow(const FlowParameters ¶meters); 69 | void 70 | run(); 71 | 72 | private: 73 | void 74 | output_results() const; 75 | 76 | ConditionalOStream pcout; 77 | 78 | mutable TimerOutput timer; 79 | 80 | Triangulation triangulation; 81 | NavierStokes navier_stokes; 82 | }; 83 | 84 | template 85 | ChannelFlow::ChannelFlow(const FlowParameters ¶meters) 86 | : pcout(std::cout, (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)) 87 | , timer(pcout, TimerOutput::summary, TimerOutput::cpu_and_wall_times) 88 | , navier_stokes(parameters, triangulation, &timer) 89 | {} 90 | 91 | template 92 | void 93 | ChannelFlow::output_results() const 94 | { 95 | timer.enter_subsection("Generate output."); 96 | 97 | navier_stokes.output_solution(navier_stokes.get_parameters().output_filename); 98 | 99 | timer.leave_subsection(); 100 | } 101 | 102 | 103 | template 104 | void 105 | create_triangulation(Triangulation &tria) 106 | { 107 | AssertThrow(dim == 1, ExcNotImplemented()); 108 | GridGenerator::hyper_rectangle(tria, Point(0.0), Point(2.5)); 109 | tria.refine_global(10); 110 | 111 | for (const auto &cell : tria.cell_iterators()) 112 | for (auto &face : cell->face_iterators()) 113 | if (face->at_boundary()) 114 | { 115 | if (std::abs(face->center()[0]) < 1e-12) 116 | face->set_boundary_id(0); 117 | else if (std::abs(face->center()[0] - 2.5) < 1e-12) 118 | face->set_boundary_id(1); 119 | } 120 | } 121 | 122 | 123 | 124 | template 125 | void 126 | ChannelFlow::run() 127 | { 128 | timer.enter_subsection("Setup grid and initial condition."); 129 | pcout << "Running a " << dim << "D flow " 130 | << "using " << navier_stokes.time_stepping.name() << ", Q" 131 | << navier_stokes.get_fe_u().degree << "/Q" << navier_stokes.get_fe_p().degree 132 | << " elements" << std::endl; 133 | 134 | create_triangulation(triangulation); 135 | 136 | navier_stokes.set_open_boundary_with_normal_flux( 137 | 0, std::make_shared>(2)); 138 | navier_stokes.set_open_boundary_with_normal_flux( 139 | 1, std::make_shared>(1)); 140 | 141 | timer.leave_subsection(); 142 | 143 | navier_stokes.setup_problem(Functions::ConstantFunction(2)); 144 | navier_stokes.print_n_dofs(); 145 | 146 | output_results(); 147 | 148 | while (navier_stokes.time_stepping.at_end() == false) 149 | { 150 | navier_stokes.advance_time_step(); 151 | if (navier_stokes.time_stepping.at_tick( 152 | navier_stokes.get_parameters().output_frequency)) 153 | output_results(); 154 | } 155 | 156 | if (!navier_stokes.time_stepping.at_tick( 157 | navier_stokes.get_parameters().output_frequency)) 158 | output_results(); 159 | } 160 | 161 | 162 | 163 | int 164 | main(int argc, char **argv) 165 | { 166 | try 167 | { 168 | using namespace dealii; 169 | 170 | Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, 171 | argv, 172 | numbers::invalid_unsigned_int); 173 | deallog.depth_console(0); 174 | 175 | AssertDimension(Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD), 1); 176 | 177 | std::string paramfile; 178 | if (argc > 1) 179 | paramfile = argv[1]; 180 | else 181 | paramfile = "1d_flow.prm"; 182 | 183 | FlowParameters parameters(paramfile); 184 | if (parameters.dimension == 1) 185 | { 186 | ChannelFlow<1> channel(parameters); 187 | channel.run(); 188 | } 189 | else 190 | { 191 | AssertThrow(false, ExcMessage("Invalid dimension. Only 1D supported.")); 192 | } 193 | } 194 | catch (std::exception &exc) 195 | { 196 | std::cerr << std::endl 197 | << std::endl 198 | << "----------------------------------------------------" << std::endl; 199 | std::cerr << "Exception on processing: " << std::endl 200 | << exc.what() << std::endl 201 | << "Aborting!" << std::endl 202 | << "----------------------------------------------------" << std::endl; 203 | 204 | return 1; 205 | } 206 | catch (...) 207 | { 208 | std::cerr << std::endl 209 | << std::endl 210 | << "----------------------------------------------------" << std::endl; 211 | std::cerr << "Unknown exception!" << std::endl 212 | << "Aborting!" << std::endl 213 | << "----------------------------------------------------" << std::endl; 214 | return 1; 215 | } 216 | 217 | return 0; 218 | } 219 | -------------------------------------------------------------------------------- /tests/couette.cc: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2021 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | 40 | #include 41 | #include 42 | 43 | #include 44 | #include 45 | 46 | #include 47 | #include 48 | #include 49 | 50 | using namespace dealii; 51 | using namespace adaflo; 52 | 53 | template 54 | class CouetteProblem 55 | { 56 | public: 57 | CouetteProblem(const FlowParameters ¶meters); 58 | void 59 | run(); 60 | 61 | private: 62 | void 63 | compute_errors() const; 64 | void 65 | output_results() const; 66 | 67 | ConditionalOStream pcout; 68 | 69 | mutable TimerOutput timer; 70 | 71 | parallel::distributed::Triangulation triangulation; 72 | NavierStokes navier_stokes; 73 | const double nu; 74 | }; 75 | 76 | 77 | 78 | template 79 | CouetteProblem::CouetteProblem(const FlowParameters ¶meters) 80 | : pcout(std::cout, (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)) 81 | , timer(pcout, TimerOutput::summary, TimerOutput::cpu_and_wall_times) 82 | , triangulation(MPI_COMM_WORLD) 83 | , navier_stokes(parameters, triangulation, &timer) 84 | , nu(parameters.viscosity) 85 | {} 86 | 87 | 88 | 89 | template 90 | void 91 | CouetteProblem::output_results() const 92 | { 93 | navier_stokes.output_solution(navier_stokes.get_parameters().output_filename); 94 | } 95 | 96 | 97 | 98 | template 99 | void 100 | CouetteProblem::run() 101 | { 102 | AssertDimension(dim, 2); 103 | 104 | timer.enter_subsection("Setup grid and initial condition."); 105 | pcout << "Running a " << dim << "D Couette problem " 106 | << "using " << navier_stokes.time_stepping.name() << ", Q" 107 | << navier_stokes.get_fe_u().degree << "/Q" << navier_stokes.get_fe_p().degree 108 | << " elements" << std::endl; 109 | 110 | std::vector subdivisions(dim, 1); 111 | subdivisions[0] = 4; 112 | 113 | const Point bottom_left = (dim == 2 ? Point(-2, -1) : Point(-2, -1, -1)); 114 | const Point top_right = (dim == 2 ? Point(2, 0) : Point(2, 0, 0)); 115 | 116 | GridGenerator::subdivided_hyper_rectangle(triangulation, 117 | subdivisions, 118 | bottom_left, 119 | top_right); 120 | 121 | // no need to check for owned cells here: on level 0 everything is locally 122 | // owned 123 | for (const auto &cell : triangulation.active_cell_iterators()) 124 | for (const auto &face : cell->face_iterators()) 125 | if (face->at_boundary() && std::abs(face->center()[0] - 2) < 1e-13) 126 | face->set_boundary_id(1); // left 127 | else if (face->at_boundary() && std::abs(face->center()[0] + 2) < 1e-13) 128 | face->set_boundary_id(2); // right 129 | else if (face->at_boundary() && std::abs(face->center()[1]) < 1e-13) 130 | face->set_boundary_id(3); // top 131 | 132 | 133 | navier_stokes.set_no_slip_boundary(0); 134 | 135 | const std::vector vel = {2, 0}; 136 | navier_stokes.set_velocity_dirichlet_boundary( 137 | 3, std::make_shared>(vel)); 138 | 139 | navier_stokes.set_open_boundary_with_normal_flux( 140 | 1, std::make_shared>()); 141 | navier_stokes.set_open_boundary_with_normal_flux( 142 | 2, std::make_shared>()); 143 | timer.leave_subsection(); 144 | 145 | navier_stokes.setup_problem(Functions::ZeroFunction(dim)); 146 | navier_stokes.print_n_dofs(); 147 | output_results(); 148 | 149 | if (navier_stokes.get_parameters().physical_type == FlowParameters::incompressible) 150 | while (navier_stokes.time_stepping.at_end() == false) 151 | { 152 | navier_stokes.advance_time_step(); 153 | output_results(); 154 | } 155 | else 156 | navier_stokes.advance_time_step(); 157 | } 158 | 159 | 160 | 161 | int 162 | main(int argc, char **argv) 163 | { 164 | try 165 | { 166 | using namespace dealii; 167 | 168 | Utilities::MPI::MPI_InitFinalize mpi_initialization( 169 | argc, argv, 1); // numbers::invalid_unsigned_int); 170 | deallog.depth_console(0); 171 | 172 | std::string paramfile; 173 | if (argc > 1) 174 | paramfile = argv[1]; 175 | else 176 | paramfile = "couette.prm"; 177 | 178 | FlowParameters parameters(paramfile); 179 | Assert(parameters.dimension == 2, ExcNotImplemented()); 180 | 181 | CouetteProblem<2> channel(parameters); 182 | channel.run(); 183 | } 184 | catch (std::exception &exc) 185 | { 186 | std::cerr << std::endl 187 | << std::endl 188 | << "----------------------------------------------------" << std::endl; 189 | std::cerr << "Exception on processing: " << std::endl 190 | << exc.what() << std::endl 191 | << "Aborting!" << std::endl 192 | << "----------------------------------------------------" << std::endl; 193 | 194 | return 1; 195 | } 196 | catch (...) 197 | { 198 | std::cerr << std::endl 199 | << std::endl 200 | << "----------------------------------------------------" << std::endl; 201 | std::cerr << "Unknown exception!" << std::endl 202 | << "Aborting!" << std::endl 203 | << "----------------------------------------------------" << std::endl; 204 | return 1; 205 | } 206 | 207 | return 0; 208 | } 209 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | adaflo: An adaptive finite element flow solver 2 | =============================================== 3 | 4 | adaflo is an adaptive finite element solver for incompressible fluid flow and 5 | two-phase flow based on the level set method. adaflo is based on the deal.II 6 | finite library, github.com/dealii/dealii, and makes use of advanced 7 | technologies such as parallel adaptive mesh refinement, fast integration based 8 | on sum factorization, and state-of-the-art preconditioning techniques. 9 | 10 | # Algorithms 11 | 12 | The algorithms used in adaflo are described in the following publication: 13 | [Journal link](http://hpc.sagepub.com/content/early/2016/10/05/1094342016671790) 14 | [DOI](http://dx.doi.org/10.1177/1094342016671790) 15 | ``` 16 | @article{KronbichlerDiagneHolmgren2016, 17 | author = {Kronbichler, Martin and Diagne, Ababacar and Holmgren, Hanna}, 18 | title = {A fast massively parallel two-phase flow solver for microfluidic chip simulation}, 19 | volume = {32}, 20 | number = {2}, 21 | pages = {266--287}, 22 | year = {2018}, 23 | doi = {10.1177/1094342016671790}, 24 | abstract ={This work presents a parallel finite element solver of incompressible 25 | two-phase flow targeting large-scale simulations of three-dimensional dynamics in 26 | high-throughput microfluidic separation devices. The method relies on a conservative 27 | level set formulation for representing the fluid-fluid interface and uses adaptive 28 | mesh refinement on forests of octrees. An implicit time stepping with efficient 29 | block solvers for the incompressible Navier–Stokes equations discretized with 30 | Taylor-Hood and augmented Taylor-Hood finite elements is presented. A matrix-free 31 | implementation is used that reduces the solution time for the Navier-Stokes system 32 | by a factor of approximately three compared to the best matrix-based algorithms. 33 | Scalability of the chosen algorithms up to 32,768 cores and a billion degrees of 34 | freedom is shown.}, 35 | journal = {International Journal of High Performance Computing Applications} 36 | } 37 | ``` 38 | 39 | 40 | # Getting started 41 | 42 | ### Prerequisites 43 | 44 | To use adaflo, a standard development environment with a relatively recent C++ 45 | compiler, MPI, and cmake is assumed. Furthermore, the following external 46 | software packages are needed: 47 | 48 | * deal.II, using at least version 8.4.0, see www.dealii.org. deal.II must be 49 | configured to also include the following external packages (no direct access 50 | to this packages is necessary, except for the interface through deal.II): 51 | 52 | * p4est for providing parallel adaptive mesh management on forests of 53 | quad-trees (2D) or oct-trees (3D). For obtaining p4est, see 54 | http://www.p4est.org. p4est of at least version 0.3.4.2 is needed for 55 | adaflo. Installation of p4est can be done via a script provided by deal.II: 56 | ``` 57 | /path/to/dealii/doc/external-libs/p4est-setup.sh p4est-1.1.tar.gz /path/to/p4est/install 58 | ``` 59 | (the last argument specifies the desired installation directory for p4est, 60 | e.g. $HOME/sw/p4est). 61 | 62 | * Trilinos for overlapping Schwarz preconditioners (ILU) and algebraic 63 | multigrid (ML). For obtaining Trilinos, see http://www.trilinos.org. adaflo 64 | has been tested against several Trilinos versions. All versions between 11.4 65 | and 12.6 that work together with deal.II should work with adaflo. This is 66 | because adaflo uses the stable Epetra stack. For options regarding the 67 | installation of Trilinos, see the respective instructions at the deal.II 68 | homepage: https://dealii.org/developer/external-libs/trilinos.html 69 | 70 | Given these dependencies, the configuration of deal.II can be done 71 | through the following script: 72 | ``` 73 | cmake \ 74 | -D CMAKE_CXX_FLAGS="-march=native" \ 75 | -D CMAKE_INSTALL_PREFIX="/path/to/dealii/install/" \ 76 | -D DEAL_II_WITH_MPI="ON" \ 77 | -D DEAL_II_WITH_LAPACK="ON" \ 78 | -D DEAL_II_WITH_P4EST="ON" \ 79 | -D P4EST_DIR="/path/to/p4est/install/" \ 80 | -D DEAL_II_WITH_TRILINOS="ON" \ 81 | -D TRILINOS_DIR="/path/to/trilinos/install" \ 82 | ../deal.II 83 | ``` 84 | 85 | Since the algorithms in adaflo make intensive use of advanced processor 86 | instruction sets (e.g. vectorization through AVX or similar), it is 87 | recommended to enable processor-specific optimizations either manually (second 88 | line, `-march=native`), or through the deal.II configuration option `-D 89 | DEAL_II_ALLOW_PLATFORM_INTROSPECTION="ON"`. The path on the third line 90 | specifies the desired installation directory of deal.II, and the last line 91 | points to the location of the source code of deal.II relative to the folder 92 | where the cmake script is run. After configuration, run 93 | 94 | ``` 95 | make -j8 96 | make install 97 | ``` 98 | 99 | to compile deal.II and install it in the given directory. After installation, 100 | the deal.II source and build folder are no longer necessary (unless you find 101 | bugs in deal.II and need to modify that code). Note that it is also possible 102 | to build adaflo against a build folder of deal.II. 103 | 104 | 105 | ### Configuration of adaflo 106 | 107 | The adaflo configuration makes use of scripts from the deal.II library. For 108 | setting up adaflo, it is usually enough to run the two commands in the top 109 | level directory of adaflo: 110 | 111 | ``` 112 | cmake -D DEAL_II_DIR=/path/to/dealii/install . 113 | make -j8 114 | ``` 115 | 116 | # Design of adaflo 117 | 118 | adaflo is based on core functionality in the folders `include/adaflo` and 119 | `source`. It contains an interface to parameter files, an incompressible 120 | Navier-Stokes solver, a level set two-phase flow solver based on 121 | the conservative level set method by Olsson, Kreiss and Zahedi, and a phase 122 | field two-phase flow solver. This core functionality is collected in a library 123 | `libadaflo.so` (or `libadaflo.dylib`) against which actual applications can be 124 | linked. 125 | 126 | In addition, a set of tests are include in the subfolder `tests/`. These 127 | currently include single-fluid tests of a Beltrami(3D)/Taylor(2D) flow and 128 | Poiseuille flow, and two-phase flow tests for a rising bubble and spurious 129 | currents. While these are fully functional cases and can be used as a basis 130 | for studying new problem cases, they also serve as unit tests for ensuring 131 | proper functionality of adaflo. 132 | 133 | Finally, somewhat larger configurations are included in the `applications` 134 | subfolder. 135 | 136 | ### Setting up a new problem in adaflo 137 | 138 | Problems in adaflo are controlled on two levels: 139 | 140 | * A user-written C++ file that specifies the computational domain (grid) and 141 | boundary conditions. This gives the user control over the (limited) deal.II 142 | mesh generation capabilities, or alternatively allows for reading meshes 143 | from mesh generators such as the ucd format created by Cubit. In addition, 144 | curved manifolds can be set this way to make the flow solver and grid 145 | refinement align along these curves. 146 | 147 | * An input file with parameters for the fluids (density, viscosity), settings 148 | of the mesh (number of adaptive mesh levels), the time stepping, and solver 149 | settings (solver strategy, number of iterations). 150 | 151 | New problems are typically set up by taking one of the provided examples in 152 | the `applications` or `tests` folders and modifying as necessary. 153 | -------------------------------------------------------------------------------- /include/adaflo/util.h: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2020 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | #ifndef __adaflo_util_h_ 17 | #define __adaflo_util_h_ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | 25 | 26 | namespace adaflo 27 | { 28 | using namespace dealii; 29 | 30 | /** 31 | * Return the locally-owned subdomain of an arbitrary mesh type. Use this 32 | * function to be able to code that is independent if a serial or a parallel 33 | * triangulation is used. 34 | */ 35 | template 36 | unsigned int 37 | locally_owned_subdomain(const MeshType &mesh) 38 | { 39 | const auto *tria_parallel = 40 | dynamic_cast *>( 42 | &(mesh.get_triangulation())); 43 | 44 | return tria_parallel != nullptr ? tria_parallel->locally_owned_subdomain() : 0; 45 | } 46 | 47 | template 48 | void 49 | compute_cell_diameters(const MatrixFree &matrix_free, 50 | const unsigned int dof_index, 51 | AlignedVector> &cell_diameters, 52 | double &cell_diameter_min, 53 | double &cell_diameter_max) 54 | { 55 | cell_diameters.resize(matrix_free.n_cell_batches()); 56 | 57 | cell_diameter_min = std::numeric_limits::max(); 58 | cell_diameter_max = 0.0; 59 | 60 | // to find the cell diameters, we compute the maximum and minimum eigenvalue 61 | // of the Jacobian transformation from the unit to the real cell. We check 62 | // all face centers and the center of the cell and take the respective 63 | // minimum and maximum there to cover most of the cell geometry 64 | std::vector> face_centers; 65 | { 66 | Point center; 67 | for (unsigned int d = 0; d < dim; ++d) 68 | center[d] = 0.5; 69 | for (unsigned int d = 0; d < dim; ++d) 70 | { 71 | Point p1 = center; 72 | p1[d] = 0; 73 | face_centers.push_back(p1); 74 | p1[d] = 1.; 75 | face_centers.push_back(p1); 76 | } 77 | face_centers.push_back(center); 78 | } 79 | 80 | const auto &dof_handler = matrix_free.get_dof_handler(dof_index); 81 | const auto &triangulation = dof_handler.get_triangulation(); 82 | 83 | LAPACKFullMatrix mat(dim, dim); 84 | FEValues fe_values(*matrix_free.get_mapping_info().mapping, 85 | dof_handler.get_fe(), 86 | Quadrature(face_centers), 87 | update_jacobians); 88 | for (unsigned int cell = 0; cell < matrix_free.n_cell_batches(); ++cell) 89 | { 90 | VectorizedArray diameter = VectorizedArray(); 91 | for (unsigned int v = 0; v < matrix_free.n_active_entries_per_cell_batch(cell); 92 | ++v) 93 | { 94 | typename DoFHandler::active_cell_iterator dcell = 95 | matrix_free.get_cell_iterator(cell, v, dof_index); 96 | fe_values.reinit(dcell); 97 | for (unsigned int q = 0; q < fe_values.n_quadrature_points; ++q) 98 | { 99 | mat = 0; 100 | for (unsigned int d = 0; d < dim; ++d) 101 | for (unsigned int e = 0; e < dim; ++e) 102 | mat(d, e) = fe_values.jacobian(q)[d][e]; 103 | mat.compute_eigenvalues(); 104 | for (unsigned int d = 0; d < dim; ++d) 105 | { 106 | diameter[v] = std::max(diameter[v], std::abs(mat.eigenvalue(d))); 107 | cell_diameter_min = 108 | std::min(cell_diameter_min, std::abs(mat.eigenvalue(d))); 109 | } 110 | } 111 | if (1U + dcell->level() == triangulation.n_global_levels()) 112 | cell_diameter_max = std::max(diameter[v], cell_diameter_max); 113 | } 114 | cell_diameters[cell] = diameter; 115 | } 116 | cell_diameter_min = 117 | -Utilities::MPI::max(-cell_diameter_min, triangulation.get_communicator()); 118 | cell_diameter_max = 119 | Utilities::MPI::max(cell_diameter_max, triangulation.get_communicator()); 120 | } 121 | 122 | /** 123 | * If dim == 1, convert a VectorizedArray to a vector (rank 1 tensor). 124 | * This function is useful to obtain equal, vector-valued return types of 125 | * FEEvaluation-operations for dim == 1 and dim > 1. 126 | */ 127 | template > 128 | static Tensor<1, dim, VectorizedArrayType> 129 | convert_to_vector(const VectorizedArrayType &in) 130 | { 131 | Assert(dim == 1, ExcMessage("This operation is not permitted for dim>1.")); 132 | 133 | Tensor<1, dim, VectorizedArrayType> vec; 134 | 135 | vec[0] = in; 136 | 137 | return vec; 138 | } 139 | 140 | /** 141 | * This function overloads the previous convert_to_vector function, when 142 | * the input argument is already given as a rank 1 tensor. 143 | */ 144 | template > 145 | static Tensor<1, dim, VectorizedArrayType> 146 | convert_to_vector(const Tensor<1, dim, VectorizedArrayType> &in) 147 | { 148 | return in; 149 | } 150 | 151 | /** 152 | * If dim == 1, convert a tensor of rank-1 to a tensor of rank. This function 153 | * is useful to obtain equal, tensor-rank-valued return types of 154 | * FEEvaluation-operations for dim == 1 and dim > 1. 155 | */ 156 | template > 157 | static Tensor 158 | convert_to_tensor(const Tensor &in) 159 | { 160 | Assert(dim == 1, ExcMessage("This operation is not permitted for dim>1.")); 161 | 162 | if (rank_ == 2) 163 | { 164 | Tensor<2, dim, VectorizedArrayType> tens; 165 | 166 | tens[0][0] = in[0]; 167 | return tens; 168 | } 169 | else 170 | { 171 | Assert(false, ExcNotImplemented()); 172 | } 173 | } 174 | 175 | /** 176 | * This function overloads the previous convert_to_tensor function, when the input 177 | * tensor already has the desired tensor rank. 178 | */ 179 | template > 180 | static Tensor 181 | convert_to_tensor(const Tensor &in) 182 | { 183 | return in; 184 | } 185 | } // namespace adaflo 186 | 187 | #endif 188 | -------------------------------------------------------------------------------- /tests/sim_rising_bubble.cc: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2021 by the adaflo authors 4 | // 5 | // This file is part of the adaflo library. 6 | // 7 | // The adaflo library is free software; you can use it, redistribute it, 8 | // and/or modify it under the terms of the GNU Lesser General Public License 9 | // as published by the Free Software Foundation; either version 2.1 of the 10 | // License, or (at your option) any later version. The full text of the 11 | // license can be found in the file LICENSE at the top level of the adaflo 12 | // distribution. 13 | // 14 | // -------------------------------------------------------------------------- 15 | 16 | // runs a simulation on a static bubble where the velocities ideally should be 17 | // zero but where we actually get some velocities which are due to 18 | // inaccuracies in the scheme 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "sharp_interfaces_util.h" 34 | 35 | 36 | using namespace dealii; 37 | using namespace adaflo; 38 | 39 | 40 | struct TwoPhaseParameters : public FlowParameters 41 | { 42 | TwoPhaseParameters(const std::string ¶meter_filename) 43 | { 44 | ParameterHandler prm; 45 | FlowParameters::declare_parameters(prm); 46 | prm.enter_subsection("Problem-specific"); 47 | prm.declare_entry("two-phase method", 48 | "front tracking", 49 | Patterns::Selection( 50 | "front tracking|mixed level set|sharp level set|level set"), 51 | "Defines the two-phase method to be used"); 52 | prm.leave_subsection(); 53 | check_for_file(parameter_filename, prm); 54 | parse_parameters(parameter_filename, prm); 55 | prm.enter_subsection("Problem-specific"); 56 | solver_method = prm.get("two-phase method"); 57 | prm.leave_subsection(); 58 | } 59 | 60 | std::string solver_method; 61 | }; 62 | 63 | 64 | 65 | template 66 | class InitialValuesLS : public Function 67 | { 68 | public: 69 | InitialValuesLS() 70 | : Function(1, 0) 71 | {} 72 | 73 | double 74 | value(const Point &p, const unsigned int /*component*/) const override 75 | { 76 | const double radius = 0.25; 77 | Point distance_from_origin = p; 78 | for (unsigned int i = 0; i < dim; ++i) 79 | distance_from_origin[i] = 0.5; 80 | return p.distance(distance_from_origin) - radius; 81 | } 82 | }; 83 | 84 | 85 | 86 | template 87 | class MicroFluidicProblem 88 | { 89 | public: 90 | MicroFluidicProblem(const TwoPhaseParameters ¶meters); 91 | void 92 | run(); 93 | 94 | private: 95 | MPI_Comm mpi_communicator; 96 | ConditionalOStream pcout; 97 | 98 | mutable TimerOutput timer; 99 | 100 | TwoPhaseParameters parameters; 101 | parallel::distributed::Triangulation triangulation; 102 | }; 103 | 104 | template 105 | MicroFluidicProblem::MicroFluidicProblem(const TwoPhaseParameters ¶meters) 106 | : mpi_communicator(MPI_COMM_WORLD) 107 | , pcout(std::cout, Utilities::MPI::this_mpi_process(mpi_communicator) == 0) 108 | , timer(pcout, TimerOutput::summary, TimerOutput::cpu_and_wall_times) 109 | , parameters(parameters) 110 | , triangulation(mpi_communicator) 111 | {} 112 | 113 | template 114 | void 115 | MicroFluidicProblem::run() 116 | { 117 | std::vector subdivisions(dim, 5); 118 | subdivisions[dim - 1] = 10; 119 | 120 | const Point bottom_left; 121 | const Point top_right = (dim == 2 ? Point(1, 2) : Point(1, 1, 2)); 122 | GridGenerator::subdivided_hyper_rectangle(triangulation, 123 | subdivisions, 124 | bottom_left, 125 | top_right); 126 | 127 | typename parallel::distributed::Triangulation::active_cell_iterator 128 | cell = triangulation.begin(), 129 | endc = triangulation.end(); 130 | 131 | for (; cell != endc; ++cell) 132 | for (unsigned int face = 0; face < GeometryInfo::faces_per_cell; ++face) 133 | if (cell->face(face)->at_boundary() && 134 | (std::fabs(cell->face(face)->center()[0] - 1) < 1e-14 || 135 | std::fabs(cell->face(face)->center()[0]) < 1e-14)) 136 | cell->face(face)->set_boundary_id(2); 137 | 138 | AssertThrow(parameters.global_refinements < 12, ExcInternalError()); 139 | 140 | NavierStokes navier_stokes_solver(parameters, triangulation, &timer); 141 | 142 | navier_stokes_solver.set_no_slip_boundary(0); 143 | navier_stokes_solver.fix_pressure_constant(0); 144 | navier_stokes_solver.set_symmetry_boundary(2); 145 | // navier_stokes_solver.boundary->fluid_type[0] = 146 | // std::make_shared>(1.0); 147 | 148 | navier_stokes_solver.setup_problem(Functions::ZeroFunction(dim)); 149 | navier_stokes_solver.print_n_dofs(); 150 | 151 | Triangulation surface_mesh; 152 | GridGenerator::hyper_sphere(surface_mesh, Point(0.5, 0.5), 0.25); 153 | surface_mesh.refine_global(5); 154 | 155 | std::unique_ptr solver; 156 | 157 | if (parameters.solver_method == "front tracking") 158 | solver = 159 | std::make_unique>(navier_stokes_solver, surface_mesh); 160 | else if (parameters.solver_method == "mixed level set") 161 | solver = std::make_unique>(navier_stokes_solver, 162 | surface_mesh, 163 | InitialValuesLS()); 164 | else if (parameters.solver_method == "sharp level set") 165 | solver = std::make_unique>(navier_stokes_solver, 166 | InitialValuesLS()); 167 | else if (parameters.solver_method == "level set") 168 | solver = std::make_unique>(navier_stokes_solver, 169 | InitialValuesLS(), 170 | false); 171 | else 172 | AssertThrow(false, ExcNotImplemented()); 173 | 174 | solver->output_solution(parameters.output_filename); 175 | 176 | while (navier_stokes_solver.time_stepping.at_end() == false) 177 | { 178 | solver->advance_time_step(); 179 | 180 | solver->output_solution(parameters.output_filename); 181 | } 182 | } 183 | 184 | int 185 | main(int argc, char **argv) 186 | { 187 | using namespace dealii; 188 | 189 | 190 | try 191 | { 192 | deallog.depth_console(0); 193 | Utilities::MPI::MPI_InitFinalize mpi_init(argc, argv, -1); 194 | 195 | std::string paramfile; 196 | if (argc > 1) 197 | paramfile = argv[1]; 198 | else 199 | paramfile = "sharp_interfaces_04.prm"; 200 | 201 | TwoPhaseParameters parameters(paramfile); 202 | if (parameters.dimension == 2) 203 | { 204 | MicroFluidicProblem<2> flow_problem(parameters); 205 | flow_problem.run(); 206 | } 207 | else 208 | AssertThrow(false, ExcNotImplemented()); 209 | } 210 | catch (std::exception &exc) 211 | { 212 | std::cerr << std::endl 213 | << std::endl 214 | << "----------------------------------------------------" << std::endl; 215 | std::cerr << "Exception on processing: " << std::endl 216 | << exc.what() << std::endl 217 | << "Aborting!" << std::endl 218 | << "----------------------------------------------------" << std::endl; 219 | 220 | return 1; 221 | } 222 | catch (...) 223 | { 224 | std::cerr << std::endl 225 | << std::endl 226 | << "----------------------------------------------------" << std::endl; 227 | std::cerr << "Unknown exception!" << std::endl 228 | << "Aborting!" << std::endl 229 | << "----------------------------------------------------" << std::endl; 230 | return 1; 231 | } 232 | 233 | return 0; 234 | } 235 | --------------------------------------------------------------------------------