Git Product home page Git Product logo

flurrypp's Introduction

FlurryPP

A 2D & 3D Flux Reconstruction Code in C++

Written by Jacob Crabill

Aerospace Computing Lab, Stanford University

Current Capabilities

The code is currently capable of running scalar advection/diffusion or Euler/Navier-Stokes cases on unstructured mixed grids of quadrilaterals and triangles (2D) or hexahedrons (3D) in the Gmsh format. Both linear and quadratic elements are supported in 3D, and up to 10th-order quadrilaterals in 2D, allowing for accurate representations of curved boundaries.

Local/Global CFL-based time stepping is available for ease (and safety) of use, along with both Forward Euler and RK45 time-stepping.

Convergence accleration is available with the use of P- or HP-multigrid. The use of H multigrid is only in addition to P multigrid down to order 0, and uses a somewhat novel grid-generation technique in which the solver accepts the coarsest grid level to run on, and recursively refines the mesh to generate the intermediate levels up to a final refined grid. See the tests/euler/channel test case for examples of using both MG methods.

Shock capturing has been implemented, but is still under development and is not fully tested yet. Additionally, a highly robust stabilization procedure invented by Chi-Wang Shu and further developed by Yu Lv is available; however, its usage tends to disrupt convergence of steady-state problems.

Moving grids are supported by the solver, but there are not yet any grid-motion functions implemented beyond several simple test-case functions.

Lastly, overset grids in 2D and 3D are supported by using the "artificial boundary" method, with Jay Sitaraman's TIOGA library being used for hole-blanking whenever solid bodies are embedded inside a mesh. Moving overset grids are also supported now for 2D and 3D.

Background / Goals of the Project

This is not intended to be a high-performance CFD tool, but rather a learning experience and testbed for new ideas and methods. The idea is to have a simple, easy to understand codebase which has been created from the ground up to be easy to modify in the future. As a developer of HiFiLES, I have great respect for the high-performance aspect of the code, and the thought that went into optimizing its performance for a specific application. However, I've also learned the hard way that it's rather difficult to make an established code do things that it wasn't designed to do.

Hence, Flurry was born. To start with, my goal is to create a plain 2D/3D Euler and Navier-Stokes solver on quadrilateral and/or triangular elements, mostly as a learning experience. As more long-term goals, however, I hope to implement various mesh adaptation and deformation methods, p-adaptation, h- and p-multigrid, etc., and as such the code will be structured in such a way to make that possible some day.

In the meantime, if you actually took the time to read this, then you should really check out the high-performance GPU-capable Flux Reconstruction code HiFiLES: http://github.com/HiFiLES/HiFiLES-solver This open-source code is under development by the Aerospace Computing Lab at Stanford, with new features in the works all the time (it is a research code, after all).

Quick Start

Compilation Instructions

To compile Flurry, you can use the provided makefile to compile using GNU make. First modify the config file (configfiles/default.config) or create your own with your desired compilation options, then from FlurryPP directory, type make.

See the default config file for details on all compilation options. Note that compiling with MPI requires several external libraries and header files (metis.h/metis.a, mpi.h), the location of which must be specified in the makefile. The code is known to work with OpenMPI >= 1.6.5. Additionally, you should have some form of BLAS installed, and ensure that the location of cblas.h is properly specified in the config file.

Test Cases

Several basic test cases have been created to verify the functionality of the code. The first test case is for the advection equation (in 'tests/advection'), and is simply the advection of a Gaussian bump in a periodic domain.

The other two test cases are for the inviscid Navier-Stokes (Euler) equations. One is for supersonic flow over a wedge, another is for subsonic flow over a circular cylinder, and another is for inviscid channel flow over a Gaussian bump..
Note that although Flurry does have a shock-capturing method implemented, it is still in the developmental phase, so general transonic and supersonic cases should be approached with caution. The cylinder test case uses a very coarse mesh, and is intended purely for the purpose of testing the functionality of the code on arbitrary unstructured quad meshes from Gmsh, and demonstrating the method for applying boundary conditions to Gmsh meshes.

Lastly, there are several test cases available for overset grids in both 2D and 3D to see the available functionality.

Post-Processing

Flurry currently has two options for viewing simulation data: ParaView .vtu files, and a super-simple .csv file. In both cases, the output values are the primitive variables, not the conservative variables.

ParaView is a free, cross-platform visualization tool that works quite well for visualizing CFD data, both 2D and 3D; you can get the latest version from http://www.paraview.org/.

The CSV output method, on the other hand, simply outputs the x,y,z coordinates of the solution points in each element, along with the solution vector at each point. This can either be plotted using the provided Matlab script. If you write any similar scripts for plotting in other languages (e.g. Python or Julia), please let me know so I can add them here!

Code Structure

Files

  • Flurry
    • Driver
  • Input
    • Read input file, set run parameters
  • Output
    • Write data to file for restarting, visualization, etc.
  • Geometry
    • Read mesh file / generate mesh; setup eles & faces
  • Flux
    • Routines to calculate the inviscid & viscous fluxes
  • Polynomials
    • Lagrange, Legendre, and other useful polynomials and functions

Basic Classes

  • Operators
    • Pre-computes and stores matrices for interpolation, extrapolation, etc. of polynomial bases for all elements in current solution
  • Ele
    • Each 'ele' is a single element in the mesh, and stores its solution, Jacobian, shape nodes, and global face IDs of its faces
  • Face
    • Each face stores the ID of the L/R cells & local face ID of each
    • Calculates interface flux or boundary flux
    • Passes the interface flux difference (common minus discontinuous) back to the L/R elements
  • Bound
    • Each 'bound' is just like a face, except that the 'right' element is replaced by a 'ghost' right state from boundary conditions
    • The boundary conditions are applied to the right state in such a way that a central flux between the left and right states produces the necessary common flux
  • MPI Face
    • Nearly identical to an internal face, except that communication of right-state data is handled through non-blocak MPI sends/recieves.
    • Note that, as opposed to internal faces, MPI faces are duplicated across processor boundaries
  • Overset Face
    • Similar in concept to the MPI face, all overset faces grab their right state from the solver to which they belong, after the solver has performed the interpolation from the other grid(s).
  • OverComm (Overset Communicator)
    • Handles all data communication related to overset grids, and implements some 2D hole-cutting algorithms which do not exist in Tioga.
  • SuperMesh
    • Creates a local supermesh of a target element from one or more donor elements for use with Galerkin projection (see Farrell and Maddison, 2010).
  • Solver
    • Applies the various FR operations to a solution (set of eles, faces, operators, and geometry)
  • MultiGrid
    • Sets up the additional solvers needed to run P- or HP-multigrid, and performs a V-cycle multigrid update.

Flurry++ is distributed under the GNU General Public License Version 3.

GPL3

flurrypp's People

Contributors

cottontensor avatar jacobcrabill 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flurrypp's Issues

Problem about viscous flux calculation at SPs

Hi Jacob,

I am a bit confused about the calculation of viscous flux at SPs. If the motion flag is active, the divergence would be calculated by Liang-Miyaji's method and the viscous fluxes don't need to transform back to reference domain, just as the invicid flux function do. The following is the original code.

solver::calcViscousFlux_spts(void)
{
 double tempF[3][5];
#pragma omp parallel for collapse(2)
 for (uint spt = 0; spt < nSpts; spt++) {
   for (uint e = 0; e < nEles; e++) {
     for (uint dim = 0; dim < nDims; dim++)
       for (uint k = 0; k < nFields; k++)
         tempDU(dim,k) = dU_spts(dim,spt,e,k);

     if (params->equation == NAVIER_STOKES)
       viscousFlux(&U_spts(spt,e,0), tempDU, tempF, params);
     else
       viscousFluxAD(tempDU, tempF, params);
     /* Add physical inviscid flux at spts */
     for (uint dim = 0; dim < nDims; dim++)
       for (uint k = 0; k < nFields; k++)
         tempF[dim][k] += F_spts(dim,spt,e,k);

     /* --- Transform back to reference domain --- */
     for (uint dim1 = 0; dim1 < nDims; dim1++)
       for (uint k = 0; k < nFields; k++)
         F_spts(dim1,spt,e,k) = 0.;

     for (uint dim1 = 0; dim1 < nDims; dim1++) {
       for (uint k = 0; k < nFields; k++) {
         for (uint dim2 = 0; dim2 < nDims; dim2++) {
           F_spts(dim1,spt,e,k) += JGinv_spts(dim1,spt,e,dim2)*tempF[dim2][k];
         }
       }
     }
   }
 }
}

I added a motion branch and designed a special test (moveAx= moveAy=moveFx=moveFy=0) to check it. In this test, the residual was the same as static one. After fix:

void solver::calcViscousFlux_spts(void)
{
	double tempF[3][5];
	#pragma omp parallel for collapse(2)
	for (uint spt = 0; spt < nSpts; spt++) {
		for (uint e = 0; e < nEles; e++) {
			for (uint dim = 0; dim < nDims; dim++)
				for (uint k = 0; k < nFields; k++)
					tempDU(dim,k) = dU_spts(dim,spt,e,k);

			if (params->equation == NAVIER_STOKES)
				viscousFlux(&U_spts(spt,e,0), tempDU, tempF, params);
			else
				viscousFluxAD(tempDU, tempF, params);

			/* Add physical inviscid flux at spts */
			for (uint dim = 0; dim < nDims; dim++)
				for (uint k = 0; k < nFields; k++)
					tempF[dim][k] += F_spts(dim,spt,e,k);

			/* --- Transform back to reference domain --- */
			for (uint dim1 = 0; dim1 < nDims; dim1++)
				for (uint k = 0; k < nFields; k++)
					F_spts(dim1,spt,e,k) = 0;
										   
			if (params->motion) {
				for (uint dim1 = 0; dim1 < nDims; dim1++) 
					for (uint k = 0; k < nFields; k++) 
							F_spts(dim1,spt,e,k) =tempF[dim1][k];					
					}
				
			else {
				for (uint dim1 = 0; dim1 < nDims; dim1++) 
					for (uint k = 0; k < nFields; k++) 
						for (uint dim2 = 0; dim2 < nDims; dim2++) 
							F_spts(dim1,spt,e,k) += JGinv_spts(dim1,spt,e,dim2)*tempF[dim2][k];					 					
				}                    
			}
		}
}

So, I guess maybe something wrong with the function. Please check it.

mpi=n not compiling

In a fresh clone, I try to build with
% make release mpi=n

and get error about mpi stuff was not declared in this scope. See full listing attached.
compil.txt

I am using Ubuntu 14.04.3 LTS.

NaN Encountered in Solution Residual

After installing metis from Ubuntu 14.04.3 LTS repositories, updating makefile and compiling with
% make mpi
I get the following runtime error

% mpirun -n 1 bin/Flurry tests/advection/input_advect
[...]
Iter Var Residual

1 Res 8.896472e+110
rank 0, ele 0: minPt = -1.000000e+01,-1.000000e+01,0.000000e+00, maxPt = -9.000000e+00,-9.000000e+00,0.000000e+00
Fatal error 'NaN Encountered in Solution Residual!' at src/output.cpp:558

I also tried randomly tests/euler/vortex/input_vortex which seems to work fine.

About the output of Flurry

Hi Jacob,
I've just compiled your FlurryPP and run a Euler cylinder case, but I found there are many duplicated output when I use mpirun.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Iter Time rho rhoU rhoV rhoW rhoE deltaT CDinv CLinv CNinv CDtot CLtot CNtot
1 1.87469e-04 3.17401e+00 2.25229e-01 2.24342e-01 2.02235e-03 7.99850e+00 1.87469e-04 4.76757e-01 -3.10256e-04 -7.21911e-16 4.76757e-01 -3.10256e-04 -7.21911e-16

Iter Time rho rhoU rhoV rhoW rhoE deltaT CDinv CLinv CNinv CDtot CLtot CNtot
1 1.87469e-04 3.17401e+00 2.25229e-01 2.24342e-01 2.02235e-03 7.99850e+00 1.87469e-04 4.76757e-01 -3.10256e-04 -7.21911e-16 4.76757e-01 -3.10256e-04 -7.21911e-16

Iter Time rho rhoU rhoV rhoW rhoE deltaT CDinv CLinv CNinv CDtot CLtot CNtot
1 1.87469e-04 3.17401e+00 2.25229e-01 2.24342e-01 2.02235e-03 7.99850e+00 1.87469e-04 4.76757e-01 -3.10256e-04 -7.21911e-16 4.76757e-01 -3.10256e-04 -7.21911e-16

Iter Time rho rhoU rhoV rhoW rhoE deltaT CDinv CLinv CNinv CDtot CLtot CNtot
1 1.87469e-04 3.17401e+00 2.25229e-01 2.24342e-01 2.02235e-03 7.99850e+00 1.87469e-04 4.76757e-01 -3.10256e-04 -7.21911e-16 4.76757e-01 -3.10256e-04 -7.21911e-16
10 1.87452e-03 3.08395e+00 5.06344e-01 3.48668e-01 2.77790e-03 7.77063e+00 1.87318e-04 4.69828e+00 -3.06824e-03 -7.22214e-16 4.69828e+00 -3.06824e-03 -7.22214e-16
10 1.87452e-03 3.08395e+00 5.06344e-01 3.48668e-01 2.77790e-03 7.77063e+00 1.87318e-04 4.69828e+00 -3.06824e-03 -7.22214e-16 4.69828e+00 -3.06824e-03 -7.22214e-16
10 1.87452e-03 3.08395e+00 5.06344e-01 3.48668e-01 2.77790e-03 7.77063e+00 1.87318e-04 4.69828e+00 -3.06824e-03 -7.22214e-16 4.69828e+00 -3.06824e-03 -7.22214e-16
10 1.87452e-03 3.08395e+00 5.06344e-01 3.48668e-01 2.77790e-03 7.77063e+00 1.87318e-04 4.69828e+00 -3.06824e-03 -7.22214e-16 4.69828e+00 -3.06824e-03 -7.22214e-16
20 3.74100e-03 2.90986e+00 9.42392e-01 5.85515e-01 4.47696e-03 7.32898e+00 1.86123e-04 9.13178e+00 -6.00735e-03 -7.23075e-16 9.13178e+00 -6.00735e-03 -7.23075e-16
20 3.74100e-03 2.90986e+00 9.42392e-01 5.85515e-01 4.47696e-03 7.32898e+00 1.86123e-04 9.13178e+00 -6.00735e-03 -7.23075e-16 9.13178e+00 -6.00735e-03 -7.23075e-16
20 3.74100e-03 2.90986e+00 9.42392e-01 5.85515e-01 4.47696e-03 7.32898e+00 1.86123e-04 9.13178e+00 -6.00735e-03 -7.23075e-16 9.13178e+00 -6.00735e-03 -7.23075e-16
20 3.74100e-03 2.90986e+00 9.42392e-01 5.85515e-01 4.47696e-03 7.32898e+00 1.86123e-04 9.13178e+00 -6.00735e-03 -7.23075e-16 9.13178e+00 -6.00735e-03 -7.23075e-16
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I checked in the code and found the output control "parmas->rank==0" do exists, so can you tell me how to correct that?
Thanks!

Best regards,
Maxime

Installation Error

Dear Mr. Crabill

I intend to install FlurryPP on Ubuntu 14.04, but when I executed "make" command I faced the following error:

g++ -c -o obj/global.o src/global.cpp
In file included from /usr/include/c++/4.8/chrono:35:0,
from src/../include/global.hpp:19,
from src/global.cpp:16:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the
^
src/global.cpp:22:17: fatal error: mpi.h: No such file or directory
#include "mpi.h"
^
compilation terminated.
make: *** [obj/global.o] Error 1

I greatly appreciate if you could guide me about this issue.

Kind Regards,
Bijan

About getting started

Dear Dr. Jacob,
I followed the instruction :

$ make release mpi=n
I got this message:

`make: *** No rule to make targetrelease'. Stop.
I don't know how to continue. Waiting your reply. Thank you in advance.
Regards,
Yasien

Segment error when test a Euler vortex example

Hi, Jacob, this is Yaojie, a PhD student from China. I am using FlurryPP now. It's an awesome work.
Recently, I got a bug when I ran the examples in the test folder /tests/euler/vortex. It's like this:

yu@yu:~/testcases/TestFlurry/euler/vortex$ Flurry input_vortex

========================================================
--------- Flux Reconstruction in C++ ---------

Geo: Creating 20x20x1 cartesian mesh
Geo: Number of elements globally: 400
Geo: Processing element connectivity
Geo: Processing periodic boundaries
Geo: Setting up elements
Geo: Setting up internal faces
Geo: Setting up boundary faces
Solver: Setting up FR operators
Solver: Setting up elements & faces
Solver: Setting up MPI face communications
Solver: Initializing Solution... done.
Writing ParaView file DeformVortex_000000000.vtu... done.
[yu:16892] *** Process received signal ***
[yu:16892] Signal: Segmentation fault (11)
[yu:16892] Signal code: Address not mapped (1)
[yu:16892] Failing at address: (nil)
[yu:16892] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0x10d10) [0x7fc7516b2d10]
[yu:16892] [ 1] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZNSsC1ERKSs+0x18) [0x7fc751ea2b38]
[yu:16892] [ 2] Flurry() [0x4a4520]
[yu:16892] [ 3] Flurry() [0x4aa06a]
[yu:16892] [ 4] Flurry() [0x40c762]
[yu:16892] [ 5] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7fc7512f8a40]
[yu:16892] [ 6] Flurry() [0x40ce09]
[yu:16892] *** End of error message ***

I didn't change any thing in the input file. Have you seen this bug in your test?

Compilation error related to METIS

Hi

During compilation I got the following error message. The METIS version is 5.1.0. I think static_casting might solve the problem but instead of casting each variable I would like to know if you know a quick fix and which version of METIS you used for compilation.

src/geo.cpp: In member function ‘void geo::partitionMesh()’:
src/geo.cpp:2468:84: error: cannot convert ‘int*’ to ‘idx_t* {aka long int*}’ for argument ‘1’ to ‘int METIS_PartMeshDual(idx_t*, idx_t*, idx_t*, idx_t*, idx_t*, idx_t*, idx_t*, idx_t*, real_t*, idx_t*, idx_t*, idx_t*, idx_t*)’
                      &ncommon,&nproc,NULL,options,&objval,epart.data(),npart.data());
                                                                                    ^
src/geo.cpp: In member function ‘void geo::getMpiPartitions()’:
src/geo.cpp:2620:84: error: cannot convert ‘int*’ to ‘idx_t* {aka long int*}’ for argument ‘1’ to ‘int METIS_PartMeshDual(idx_t*, idx_t*, idx_t*, idx_t*, idx_t*, idx_t*, idx_t*, idx_t*, real_t*, idx_t*, idx_t*, idx_t*, idx_t*)’
                      &ncommon,&nproc,NULL,options,&objval,epart.data(),npart.data());

dynamic grid error when running viscous flow test

Hi, Jacob. Recently, I am running a unsteady deforming cylinder case. I found the Euler equations works pretty well. However, the viscous test is unstable. I guess there may be some wrong in viscous module when the grid move. Have your ever tested a viscous dynamic grid case?

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.