updated formatter settings

main
Antonio De Lucreziis 11 months ago
parent 5c2af8b497
commit 0d2667e852

@ -0,0 +1,2 @@
# .clang-format
IndentWidth: 4

@ -1,39 +1,7 @@
# cmake_minimum_required(VERSION 3.5.0)
# set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# # set root of location to find PETSc's pkg-config
# set(PETSC $ENV{PETSC_DIR}/$ENV{PETSC_ARCH})
# set(ENV{PKG_CONFIG_PATH} ${PETSC}/lib/pkgconfig)
# # Remove the lines below if you do not wish to have PETSc determine the compilers
# execute_process ( COMMAND pkg-config PETSc --variable=ccompiler COMMAND tr -d '\n' OUTPUT_VARIABLE C_COMPILER)
# SET(CMAKE_C_COMPILER ${C_COMPILER})
# execute_process ( COMMAND pkg-config PETSc --variable=cxxcompiler COMMAND tr -d '\n' OUTPUT_VARIABLE CXX_COMPILER)
# if (CXX_COMPILER)
# SET(CMAKE_CXX_COMPILER ${CXX_COMPILER})
# endif (CXX_COMPILER)
# execute_process ( COMMAND pkg-config PETSc --variable=fcompiler COMMAND tr -d '\n' OUTPUT_VARIABLE FORTRAN_COMPILER)
# if (FORTRAN_COMPILER)
# SET(CMAKE_Fortran_COMPILER ${FORTRAN_COMPILER})
# enable_language(Fortran)
# endif (FORTRAN_COMPILER)
# # tells CMake to build the application ex1 from the source file ex1.c
# # this must appear AFTER the compilers are set
# project(main)
# add_executable(main main.c)
# find_package(MPI REQUIRED)
# include_directories(${MPI_INCLUDE_PATH})
# find_package(PkgConfig REQUIRED)
# pkg_search_module(PETSC REQUIRED IMPORTED_TARGET PETSc)
# target_link_libraries(main PkgConfig::PETSC)
cmake_minimum_required(VERSION 3.5.0)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Set root of location to find PETSc's pkg-config
set(PETSC $ENV{PETSC_DIR}/$ENV{PETSC_ARCH})

@ -47,24 +47,24 @@ int main(int argc, char **argv) {
// A := diag(-1, 2, -1)
for (PetscInt i = 0; i < n; i++) {
// PetscScalar v[3] = {-1.0, 2.0, -1.0};
// PetscInt col[3] = {i - 1, i, i + 1};
// PetscInt ncol = 0;
// if (i > 0) {
// col[ncol] = i - 1;
// v[ncol] = -1.0;
// ncol++;
// }
// col[ncol] = i;
// v[ncol] = 2.0;
// ncol++;
// if (i < n - 1) {
// col[ncol] = i + 1;
// v[ncol] = -1.0;
// ncol++;
// }
// MatSetValues(A, 1, &i, ncol, col, v, INSERT_VALUES);
MatSetValue(A, i, i, (PetscScalar)(i + 1), INSERT_VALUES);
PetscScalar v[3] = {-1.0, 2.0, -1.0};
PetscInt col[3] = {i - 1, i, i + 1};
PetscInt ncol = 0;
if (i > 0) {
col[ncol] = i - 1;
v[ncol] = -1.0;
ncol++;
}
col[ncol] = i;
v[ncol] = 2.0;
ncol++;
if (i < n - 1) {
col[ncol] = i + 1;
v[ncol] = -1.0;
ncol++;
}
MatSetValues(A, 1, &i, ncol, col, v, INSERT_VALUES);
// MatSetValue(A, i, i, (PetscScalar)(i + 1), INSERT_VALUES);
}
MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);

Loading…
Cancel
Save