GithubHelp home page GithubHelp logo

jannisteunissen / octree-mg Goto Github PK

View Code? Open in Web Editor NEW
25.0 5.0 6.0 688 KB

MPI geometric multigrid solver for quadtree/octree grids

Makefile 0.68% Fortran 97.00% C 0.03% Shell 0.36% C++ 0.07% Perl 0.02% Raku 0.73% Assembly 1.11%
mpi multigrid octree pde quadtree

octree-mg's Introduction

Octree-mg

The octree-mg library implements parallel geometric multigrid methods on quadtree/octree grids, which can be used to solve elliptic PDEs such as Poissons's equation. The provided solvers can be used in existing adaptive-mesh-refinement (AMR) frameworks that employ quadtree/octree grids.

The code is described in detail in the publication A geometric multigrid library for quadtree/octree AMR grids coupled to MPI-AMRVAC, also available at arXiv.

Usage

Type make in the top folder, and run the programs in the tests folder.

Including the library in other projects

You can either include a full copy of octree-mg using e.g. git submodules of subtrees, or include it as a single Fortran module, see the folder single_module.

Features

  • MPI parallelization
  • The same code can be used in 2D/3D (compiled into two different libraries)
  • Support for adaptively refined grids, with a consistent discretization near refinement boundaries
  • Rectangular grids can easily be created (e.g. 512 x 256 x 256 cells).
  • Operators with sparse stencils (5/7-point in 2D/3D) are supported
  • Support for periodic, Dirichlet, Neumann, and continuous boundary conditions
  • Coarse grids are automatically created

Restrictions

  • One layer of ghost cells is used, and diagonal ghost cells are currently not set. This means stencils with diagonal elements are not possible.
  • Point-wise smoothers are employed, so currently a requirement is that dx, dy and dz are similar

Using the free-space solver in MPI-AMRVAC

The "single-module" version of this library is included in MPI-AMRVAC, but it does not include the free-space module. An example of how to do this can be found under tests/multigrid/free_space_3d in the MPI-AMRVAC folder, see in particular the file local.make.

octree-mg's People

Contributors

jannisteunissen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

octree-mg's Issues

ghost cell update

Hi

Sorry to bother you again.

I am interested to build a simulation code for incompressible flow based on this library. In the simulation, all variables live in 'leaves', and the ghost cells are necessary for calculation (such as gradient) for interior cells. Since ghost cells do not have all neighboor cells avaiable, they cannot be calculated according the governing equations, but rely on interpolation from neighboor boxes. To interpolate, I tried calling mg_restrict followed by mg_fill_ghost_cells, but the ghost cells are not filled.

I then went back to experiment with the test example "test_refinement.f90". I revised this example so that the set_solution is only done for the interior cells of leaves, and output the i_sol field in Tecplot format. The ghost cells are also zero from what I can see. The revised `set_solution' is attached in the following.

Could you please help? Thank you very much

==================

` subroutine set_solution(mg)
use mpi
type(mg_t), intent(inout) :: mg
integer :: n, id, lvl, nc
real(dp) :: r(NDIM), sol
integer ic, iwrk, i,j,k, irank, ierr
real(dp) x,y,z

do lvl = mg%lowest_lvl, mg%highest_lvl
   nc = mg%box_size_lvl(lvl)
   do n = 1, size(mg%lvls(lvl)%my_leaves)
      id = mg%lvls(lvl)%my_leaves(n)
      do KJI_DO(1, nc)
         r = mg%boxes(id)%r_min + ([IJK] - 0.5_dp) * mg%dr(:, lvl)
         sol = product(sin(2 * pi * n_modes * r))
         mg%boxes(id)%cc(IJK, i_sol) = sol
      end do; CLOSE_DO
   end do
end do

! Set ghost cells for the solution. Because they depend on coarse-grid
! values, first restrict the solution.
call mg_restrict(mg, i_sol)
call mg_fill_ghost_cells(mg, i_sol)

if(mg%my_rank ==0) then
write(,) 'Writing Tecplot file'
open(1, file = 'out.dat', status = 'REPLACE')
write(1,*) 'Variables = x, y, z, u'
close(1)
end if

do irank = 0, mg%n_cpu-1
if(mg%my_rank == irank) then
open(1, file = 'out.dat', position="append", &
status="old", action="write")
do lvl = mg%lowest_lvl, mg%highest_lvl
nc = mg%box_size_lvl(lvl)
do n = 1, size(mg%lvls(lvl)%my_leaves)
id = mg%lvls(lvl)%my_leaves(n)
write(1,) 'zone i = ', nc+2, ' j = ', nc+2, ' k = ',nc+2
do k = 0, nc+1
do j = 0, nc+1
do i = 0, nc+1
x = mg%boxes(id)%r_min(1) + (real(i,8) - 0.5_dp) * mg%boxes(id)%dr(1)
y = mg%boxes(id)%r_min(2) + (real(j,8) - 0.5_dp) * mg%boxes(id)%dr(2)
z = mg%boxes(id)%r_min(3) + (real(k,8) - 0.5_dp) * mg%boxes(id)%dr(3)
write(1,
) x, y, z, mg%boxes(id)%cc(i,j,k,i_sol)
end do
end do
end do
end do
end do
close(1)
end if
call MPI_Barrier( MPI_COMM_WORLD,ierr)
end do

end subroutine set_solution`

how is the 2:1 balance implemented

Hi

According to the paper on this code, 2:1 balance is imposed. Could you please whice subroutine implemented the 2:1 balance?

Thanks

add topic tags

I suggest adding the topics pde, quadtree, octtree, multigrid, mpi in the About section

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.