Skip to content

Commit

Permalink
Merge branch 'master' into nc-jump
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewreisner authored Nov 15, 2018
2 parents 82c00cc + 26d7c66 commit 6f7e702
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 29 deletions.
21 changes: 13 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,30 @@ include(testing)

option(ENABLE_UNIT_TESTS "Enable unit testing" OFF)
option(AutodetectMPI "Automatically detect MPI" ON)
option(ENABLE_CEDAR "Enable Cedar solver" OFF)

enable_language(C CXX Fortran)

find_package(PETSc REQUIRED)
#if(PETSC_VERSION VERSION_LESS 3.7.0)
#message(FATAL_ERROR "ERROR: stella requires PETSc 3.7.0 or newer.")
#endif()

set(req-lib ${PETSC_LIBRARIES} m)
set(req-inc ${PETSC_INCLUDES})
set(req-def PETSC_OPTIONS_TAKES_DATABASE)
set(req-def "")

find_package(PETSc REQUIRED)
list(APPEND req-def PETSC_OPTIONS_TAKES_DATABASE)
# if(PETSC_VERSION)
# if(NOT (${PETSC_VERSION} VERSION_LESS 3.7.0))
# list(APPEND req-def PETSC_OPTIONS_TAKES_DATABASE)
# endif()
# endif()

if(AutodetectMPI)
find_package(MPI REQUIRED)
list(APPEND req-lib ${MPI_C_LIBRARIES})
list(APPEND req-inc ${MPI_C_INCLUDE_PATH})
endif()
find_package(cedar QUIET)
if (cedar_FOUND)

if(ENABLE_CEDAR)
find_package(cedar REQUIRED)
list(APPEND req-inc ${CEDAR_INCLUDE_DIR})
list(APPEND req-lib cedar)
list(APPEND req-def WITH_CEDAR)
Expand Down
12 changes: 8 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(stella_sources
set(sources
${CMAKE_CURRENT_SOURCE_DIR}/stella_bc.c
${CMAKE_CURRENT_SOURCE_DIR}/stella_boundary.c
${CMAKE_CURRENT_SOURCE_DIR}/stella_dirichlet.c
Expand All @@ -15,6 +15,10 @@ set(stella_sources
${CMAKE_CURRENT_SOURCE_DIR}/stella_stencil.c
${CMAKE_CURRENT_SOURCE_DIR}/stella_signals.c
${CMAKE_CURRENT_SOURCE_DIR}/stella_classify.c
${CMAKE_CURRENT_SOURCE_DIR}/stella_util.c
${CMAKE_CURRENT_SOURCE_DIR}/stella_cedar.c
PARENT_SCOPE)
${CMAKE_CURRENT_SOURCE_DIR}/stella_util.c)

if (ENABLE_CEDAR)
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/stella_cedar.c)
endif()

set(stella_sources ${sources} PARENT_SCOPE)
2 changes: 1 addition & 1 deletion src/stella_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ PetscErrorCode stella_io_print(MPI_Comm comm, char *msg)
{
PetscErrorCode ierr;

ierr = PetscPrintf(comm, "PlasComCM: %s\n", msg);CHKERRQ(ierr);
ierr = PetscPrintf(comm, "stella: %s\n", msg);CHKERRQ(ierr);

return 0;
}
7 changes: 0 additions & 7 deletions src/stella_solver.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,6 @@ PetscErrorCode stella_solve(stella *slv)
// Update external array with solution
ierr = update_solution(slv);CHKERRQ(ierr);

if (stella_log(slv, STELLA_LOG_PROBLEM)) {
PetscViewer vout;
ierr = PetscViewerBinaryOpen(slv->comm, "sol.dat", FILE_MODE_WRITE, &vout);CHKERRQ(ierr);
ierr = VecView(slv->x, vout);CHKERRQ(ierr);
ierr = PetscViewerDestroy(&vout);CHKERRQ(ierr);
}

return 0;
}

Expand Down
16 changes: 16 additions & 0 deletions tools/single-block/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"log": ["status","error"],
"solver":
{
"cycle":
{
"nrelax-pre": 2,
"nrelax-post": 1
},
"relaxation": "point",
"tol": 1e-10,
"max-iter": 10,
"min-coarse": 3,
"cg-solver": "LU"
}
}
14 changes: 5 additions & 9 deletions tools/single-block/grid.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,27 +156,23 @@ grid *grid_create(double startx, double endx, int nx,
grd->hy = (endy - starty) / (grd->num_global[1] - 1);
grd->hz = (endz - startz) / (grd->num_global[2] - 1);

startx = startx + (grd->is[0]-1)*grd->hx - grd->ibeg[0]*grd->hx;
starty = starty + (grd->is[1]-1)*grd->hy - grd->ibeg[1]*grd->hy;
startz = startz + (grd->is[2]-1)*grd->hz - grd->ibeg[2]*grd->hz;

if (grd->nd == 3) {
for (k = 0; k < grd->len[2]; k++) {
for (j = 0; j < grd->len[1]; j++) {
for (i = 0; i < grd->len[0]; i++) {
ind = k*grd->len[0]*grd->len[1] + j*grd->len[0] + i;
grd->x[ind] = startx + i*grd->hx;
grd->y[ind] = starty + j*grd->hy;
grd->z[ind] = startz + k*grd->hz;
grd->x[ind] = startx + (grd->is[0]-1-grd->ibeg[0]+i)*grd->hx;
grd->y[ind] = starty + (grd->is[1]-1-grd->ibeg[1]+j)*grd->hy;
grd->z[ind] = startz + (grd->is[2]-1-grd->ibeg[2]+k)*grd->hz;
}
}
}
} else {
for (j = 0; j < grd->len[1]; j++) {
for (i = 0; i < grd->len[0]; i++) {
ind = j*grd->len[0] + i;
grd->x[ind] = startx + i*grd->hx;
grd->y[ind] = starty + j*grd->hy;
grd->x[ind] = startx + (grd->is[0]-1-grd->ibeg[0]+i)*grd->hx;
grd->y[ind] = starty + (grd->is[1]-1-grd->ibeg[1]+j)*grd->hy;
}
}
}
Expand Down

0 comments on commit 6f7e702

Please sign in to comment.