Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radiation basics #11

Merged
merged 39 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f4d62b9
lapack bs
AstroBarker Jan 28, 2023
0d2388d
dump rad
AstroBarker Mar 22, 2023
4a4976a
merge main
AstroBarker Jul 28, 2023
7d0c6f0
add todo
AstroBarker Jul 28, 2023
0857dcb
readme todo
AstroBarker Jul 28, 2023
74e8f13
typo
AstroBarker Jul 28, 2023
ed1f06e
bug in CRTP
AstroBarker Jul 28, 2023
bfdd8eb
comment
AstroBarker Jul 28, 2023
2e1831e
radiation progress
AstroBarker Jul 29, 2023
f597e20
update cmake have different default machine
AstroBarker Aug 20, 2023
9482f9a
merge
AstroBarker Aug 20, 2023
5712f61
fix: typos
AstroBarker Aug 20, 2023
6a34c8f
fix typos, standardize some ifndef header guards
AstroBarker Aug 20, 2023
c072896
Merge branch 'main' into rad
AstroBarker Nov 11, 2023
85028cd
todo etc
AstroBarker Nov 11, 2023
ccc0db2
feat: rad LLF Riemann solver, some tweak for making fluid work with rad
AstroBarker Jan 26, 2024
fdf5ea1
feat: first pass at rad timestepper
AstroBarker Jan 26, 2024
c9091ba
Merge branch 'main' into rad
AstroBarker Jan 27, 2024
516a907
wip: rad test
AstroBarker Jan 27, 2024
58c6864
merge main
AstroBarker Jan 28, 2024
39956f6
fix: typo
AstroBarker Jan 28, 2024
8a6fdf4
fix: big basis fix for TCI
AstroBarker Jan 28, 2024
fcd4c1f
some rad fixes and changes
AstroBarker Jan 28, 2024
d413898
some rad fixes. next: source terms
AstroBarker Jan 28, 2024
bedfacb
dump of broken things
AstroBarker Feb 18, 2024
4fe6324
Update README.md
AstroBarker Feb 18, 2024
3c3d74f
docs: readme
AstroBarker Feb 18, 2024
852155b
Update README.md
AstroBarker Feb 20, 2024
7149a21
todos
AstroBarker Feb 26, 2024
9d0f1e6
remove unused rad timestepper stuff, comment out slope limiter for now
AstroBarker Feb 26, 2024
1e107d7
feat: basics of (explicit) radiation working
AstroBarker Feb 26, 2024
9ec3450
rad driver changes
AstroBarker Feb 26, 2024
efe3b03
fmt all and change braces in clang format
AstroBarker Feb 26, 2024
9b69243
fmt: allow clang-fmt to sort includes
AstroBarker Feb 26, 2024
2196042
Merge branch 'main' into rad
AstroBarker Feb 26, 2024
8cdf946
fix: hpp files were not being formated...
AstroBarker Feb 26, 2024
5782216
fmt: missed unit test
AstroBarker Feb 26, 2024
b31bd2a
some formatting
AstroBarker Feb 26, 2024
d4d2d8b
fmt...
AstroBarker Feb 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ SpacesInConditionalStatement: true
SpacesInParentheses: true
AlignConsecutiveAssignments: true

BreakBeforeBraces: Allman
BreakBeforeBraces: Attach
PointerAlignment: Right
SortIncludes: Never
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ option(ATHELAS_ENABLE_UNIT_TESTS "Enable unit tests" OFF)
option(ATHELAS_ENABLE_INTEGRATION_TESTS "Enable integration tests" OFF) # Future
option(ATHELAS_ENABLE_REGRESSION_TESTS "Enable regression tests" OFF) # Future

set( MACHINE "UBUNTU" CACHE STRING "Set OS")
set( MACHINE "LINUX" CACHE STRING "Set OS")
message( "Building On ${MACHINE} ")

# Don't allow in-source builds
Expand Down Expand Up @@ -103,6 +103,7 @@ set( ATHELAS_SOURCES
"src/EoS/EoS_Ideal.cpp"
"src/Fluid/FluidUtilities.cpp"
"src/Radiation/RadUtilities.cpp"
"src/Radiation/Rad_Discretization.cpp"
"src/Fluid/Fluid_Discretization.cpp"
"src/Geometry/Grid.cpp"
"src/IO/IOLibrary.cpp"
Expand Down Expand Up @@ -190,7 +191,7 @@ if (${MACHINE} STREQUAL UBUNTU)
target_link_libraries( libathelas ${LAPACK_LIBRARIES} )
else()
find_package( LAPACK REQUIRED )
message(STATUS "LAPACK_LIBRARIES = ${LAPACK_LIBRARIES}")
message(STATUS "LAPACKE_LIBRARIES = ${LAPACK_LIBRARIES}")
include_directories(${LAPACK_INCLUDE_DIRS})
target_link_libraries( libathelas ${LAPACK_LIBRARIES} )
endif()
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,26 @@ This will create a directory `bin` in the root directory that contains the execu
## NOTE:
The build system may not be perfect yet. Your mileage may vary.

## TODO
- function naming overhaul
- class accessor refactor
- cmake: bin into build
- kokkos parallel slope limiter
- repalce simpleini reader with different format (TOML, YAML)
- Rename values in hdf5 output...
- generalize applyBC for rad and fluid. extents for dims

### Radiation TODO:
- radiation riemann solver
- radiation timestepper
- strang split
- probably more
- ... microphysics...


# Future Work

- Grey M1 radiation
- Grey M1 radiation [WIP]
- Relativistic hydro
- Gravity
- Multigroup radiation
Expand All @@ -75,6 +91,7 @@ Simply call `tools/bash/format.sh` to format the `.hpp` and `.cpp` files.
- [ ] New TCI
- [ ] linter
- [ ] format on make
- [ ] Rad: Riemann solvers beyond LLF?
- [ ] Adjust numerical fluxes for 1D MHD
- [ ] Implement 1.5D NRMHD

Expand Down
28 changes: 28 additions & 0 deletions inputs/advection.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[Problem]
problem=MovingContact
t_end=5.0
geometry=planar;spherical or planar
restart=false
do_rad=true
xL=0.0
xR=1.0
BC=Homogenous
CFL=0.35

[Fluid]
Basis=Legendre
nNodes=1
pOrder=1
nX=128
nG=1

[Time]
tOrder=1
nStages=1

[Limiters]
alpha=1.0
Threshold=0.0
TCI_Opt=false
TCI_val=0.1
Characteristic=true
28 changes: 28 additions & 0 deletions inputs/radeq.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[Problem]
problem=RadEquilibrium
t_end=1.0e-7
geometry=planar;spherical or planar
restart=false
do_rad=true
xL=0.0
xR=1.0
BC=Homogenous
CFL=0.35

[Fluid]
Basis=Legendre
nNodes=1
pOrder=1
nX=256
nG=1

[Time]
tOrder=1
nStages=1

[Limiters]
alpha=1.0
Threshold=0.0
TCI_Opt=false
TCI_val=0.1
Characteristic=true
67 changes: 21 additions & 46 deletions src/BC/BoundaryConditionsLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@

#include "Kokkos_Core.hpp"

#include "Grid.hpp"
#include "BoundaryConditionsLibrary.hpp"
#include "Grid.hpp"

// Apply Boundary Conditions to fluid fields
void ApplyBC( Kokkos::View<Real ***> uCF, GridStructure *Grid,
const UInt order, const std::string BC )
{
void ApplyBC( Kokkos::View<Real ***> uCF, GridStructure *Grid, const UInt order,
const std::string BC ) {

const UInt ilo = Grid->Get_ilo( );
const UInt ihi = Grid->Get_ihi( );
Expand All @@ -26,60 +25,45 @@ void ApplyBC( Kokkos::View<Real ***> uCF, GridStructure *Grid,
const UInt nG = Grid->Get_Guard( );

// ! ? How to correctly implement reflecting BC ? !
if ( BC == "Reflecting" )
{
for ( UInt iCF = 0; iCF < 3; iCF++ )
{
if ( BC == "Reflecting" ) {
for ( UInt iCF = 0; iCF < 3; iCF++ ) {
// Inner Boudnary
for ( UInt iX = 0; iX < ilo; iX++ )
for ( UInt k = 0; k < order; k++ )
{
if ( iCF != 1 )
{
for ( UInt k = 0; k < order; k++ ) {
if ( iCF != 1 ) {
if ( k == 0 ) uCF( iCF, iX, k ) = +uCF( iCF, ilo, k );
if ( k != 0 ) uCF( iCF, iX, k ) = -uCF( iCF, ilo, k );
}
else
{
} else {
if ( k == 0 ) uCF( 1, iX, 0 ) = -uCF( 1, ilo, 0 );
if ( k != 0 ) uCF( 1, iX, k ) = +uCF( 1, ilo, k );
}
}

// Outer Boundary
for ( UInt iX = ihi + 1; iX < nX + 2 * nG; iX++ )
for ( UInt k = 0; k < order; k++ )
{
if ( iCF != 1 )
{
for ( UInt k = 0; k < order; k++ ) {
if ( iCF != 1 ) {
uCF( iCF, iX, k ) = uCF( iCF, ihi, k );
}
else
{
} else {
uCF( iCF, iX, k ) = -uCF( 1, ihi, k );
}
}
}
}
else if ( BC == "Periodic" )
{
} else if ( BC == "Periodic" ) {
for ( UInt iCF = 0; iCF < 3; iCF++ )
for ( UInt iX = 0; iX < ilo; iX++ )
for ( UInt k = 0; k < order; k++ )
{
for ( UInt k = 0; k < order; k++ ) {
uCF( iCF, ilo - 1 - iX, k ) = uCF( iCF, ihi - iX, k );
uCF( iCF, ihi + 1 + iX, k ) = uCF( iCF, ilo + iX, k );
}
}
else if ( BC == "ShocklessNoh" ) /* Special case for ShocklessNoh test */
} else if ( BC == "ShocklessNoh" ) /* Special case for ShocklessNoh test */
{
// for ( UInt iCF = 0; iCF < 3; iCF++ )
for ( UInt iX = 0; iX < ilo; iX++ )
for ( UInt k = 0; k < order; k++ )
// for ( UInt iCF = 0; iCF < 3; iCF++ )
{
if ( k == 0 )
{
if ( k == 0 ) {

uCF( 0, ilo - 1 - iX, k ) = uCF( 0, ilo + iX, k );
uCF( 0, ihi + 1 + iX, k ) = uCF( 0, ihi - iX, k );
Expand All @@ -98,9 +82,7 @@ void ApplyBC( Kokkos::View<Real ***> uCF, GridStructure *Grid,
uCF( 2, ihi - iX, k ) -
0.5 * uCF( 1, ihi - iX, k ) * uCF( 1, ihi - iX, k ) +
0.5 * uCF( 1, ihi + 1 + iX, k ) * uCF( 1, ihi + 1 + iX, k );
}
else if ( k == 1 )
{
} else if ( k == 1 ) {
uCF( 0, ilo - 1 - iX, k ) = 0.0;
uCF( 0, ihi + 1 + iX, k ) = 0.0;

Expand All @@ -111,9 +93,7 @@ void ApplyBC( Kokkos::View<Real ***> uCF, GridStructure *Grid,
-uCF( 1, ilo + iX, 0 ) * uCF( 1, ilo + iX, 1 );
uCF( 2, ihi + 1 + iX, k ) =
uCF( 1, ihi + 1 + iX, 0 ) * uCF( 1, ihi + 1 + iX, 1 );
}
else if ( k == 2 )
{
} else if ( k == 2 ) {

// uCF( iCF, ilo - 1 - iX, k ) = 0.0;
// uCF( iCF, ihi + 1 + iX, k ) = 0.0;
Expand All @@ -130,9 +110,7 @@ void ApplyBC( Kokkos::View<Real ***> uCF, GridStructure *Grid,
uCF( 2, ilo + iX, 2 ); // * uCF( 1, ilo + iX, 1 );
uCF( 2, ihi + 1 + iX, k ) =
uCF( 2, ihi - iX, 2 ); //* uCF( 1, ihi - iX, 1 );
}
else
{
} else {
uCF( 0, ilo - 1 - iX, k ) = 0.0; // uCF( 0, ilo + iX, k );
uCF( 0, ihi + 1 + iX, k ) = 0.0; // uCF( 0, ihi - iX, k );

Expand All @@ -143,13 +121,10 @@ void ApplyBC( Kokkos::View<Real ***> uCF, GridStructure *Grid,
uCF( 2, ihi + 1 + iX, k ) = uCF( 2, ihi - iX, k );
}
}
}
else
{
for ( UInt iCF = 0; iCF < 3; iCF++ )
} else {
for ( UInt iCF = 0; iCF < uCF.extent( 0 ); iCF++ )
for ( UInt iX = 0; iX < ilo; iX++ )
for ( UInt k = 0; k < order; k++ )
{
for ( UInt k = 0; k < order; k++ ) {
uCF( iCF, ilo - 1 - iX, k ) = uCF( iCF, ilo + iX, k );
uCF( iCF, ihi + 1 + iX, k ) = uCF( iCF, ihi - iX, k );
}
Expand Down
11 changes: 6 additions & 5 deletions src/BC/BoundaryConditionsLibrary.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef BOUNDARYCONDITIONSLIBRARY_H
#define BOUNDARYCONDITIONSLIBRARY_H
#ifndef _BOUNDARYCONDITIONSLIBRARY_HPP_
#define _BOUNDARYCONDITIONSLIBRARY_HPP_

#include "Abstractions.hpp"
#include "Grid.hpp"

void ApplyBC( Kokkos::View<Real ***> uCF, GridStructure *Grid,
const UInt order, const std::string BC );
void ApplyBC( Kokkos::View<Real ***> uCF, GridStructure *Grid, const UInt order,
const std::string BC );

#endif
#endif // _BOUNDARYCONDITIONSLIBRARY_HPP_
Loading
Loading