reorganized project for cleaner filesystem

This commit is contained in:
Vasco C. B. Ferreira
2026-03-18 01:44:29 +01:00
parent 76d1a773d5
commit 7dd374c35f
19 changed files with 285 additions and 1405 deletions
+24 -14
View File
@@ -1,16 +1,7 @@
##
# CMake script for NuFI FEM Poisson Prototype
##
cmake_minimum_required(VERSION 3.13.4)
# Name of your executable (must match your .cc filename!)
set(TARGET "nufi_poisson")
# List your source files here
set(TARGET_SRC
${TARGET}.cc
)
project(nufi_poisson)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(deal.II 9.6.0
HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
@@ -25,8 +16,27 @@ endif()
deal_ii_initialize_cached_variables()
project(${TARGET})
# -------------------------
add_executable(${TARGET} ${TARGET_SRC})
add_library(nufi_lib
src/nufi_solver.cc
src/save_results.cc
)
deal_ii_setup_target(${TARGET})
target_include_directories(nufi_lib PUBLIC
${CMAKE_SOURCE_DIR}
)
deal_ii_setup_target(nufi_lib)
# -------------------------
add_executable(nufi_poisson
src/main.cc
)
target_link_libraries(nufi_poisson
nufi_lib
)
deal_ii_setup_target(nufi_poisson)
+86 -18
View File
@@ -116,6 +116,19 @@ depend:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named nufi_lib
# Build rule for target.
nufi_lib: cmake_check_build_system
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 nufi_lib
.PHONY : nufi_lib
# fast build rule for target.
nufi_lib/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_lib.dir/build.make CMakeFiles/nufi_lib.dir/build
.PHONY : nufi_lib/fast
#=============================================================================
# Target rules for targets named nufi_poisson
@@ -129,29 +142,77 @@ nufi_poisson/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_poisson.dir/build.make CMakeFiles/nufi_poisson.dir/build
.PHONY : nufi_poisson/fast
nufi_poisson.o: nufi_poisson.cc.o
.PHONY : nufi_poisson.o
src/main.o: src/main.cc.o
.PHONY : src/main.o
# target to build an object file
nufi_poisson.cc.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_poisson.dir/build.make CMakeFiles/nufi_poisson.dir/nufi_poisson.cc.o
.PHONY : nufi_poisson.cc.o
src/main.cc.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_poisson.dir/build.make CMakeFiles/nufi_poisson.dir/src/main.cc.o
.PHONY : src/main.cc.o
nufi_poisson.i: nufi_poisson.cc.i
.PHONY : nufi_poisson.i
src/main.i: src/main.cc.i
.PHONY : src/main.i
# target to preprocess a source file
nufi_poisson.cc.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_poisson.dir/build.make CMakeFiles/nufi_poisson.dir/nufi_poisson.cc.i
.PHONY : nufi_poisson.cc.i
src/main.cc.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_poisson.dir/build.make CMakeFiles/nufi_poisson.dir/src/main.cc.i
.PHONY : src/main.cc.i
nufi_poisson.s: nufi_poisson.cc.s
.PHONY : nufi_poisson.s
src/main.s: src/main.cc.s
.PHONY : src/main.s
# target to generate assembly for a file
nufi_poisson.cc.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_poisson.dir/build.make CMakeFiles/nufi_poisson.dir/nufi_poisson.cc.s
.PHONY : nufi_poisson.cc.s
src/main.cc.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_poisson.dir/build.make CMakeFiles/nufi_poisson.dir/src/main.cc.s
.PHONY : src/main.cc.s
src/nufi_solver.o: src/nufi_solver.cc.o
.PHONY : src/nufi_solver.o
# target to build an object file
src/nufi_solver.cc.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_lib.dir/build.make CMakeFiles/nufi_lib.dir/src/nufi_solver.cc.o
.PHONY : src/nufi_solver.cc.o
src/nufi_solver.i: src/nufi_solver.cc.i
.PHONY : src/nufi_solver.i
# target to preprocess a source file
src/nufi_solver.cc.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_lib.dir/build.make CMakeFiles/nufi_lib.dir/src/nufi_solver.cc.i
.PHONY : src/nufi_solver.cc.i
src/nufi_solver.s: src/nufi_solver.cc.s
.PHONY : src/nufi_solver.s
# target to generate assembly for a file
src/nufi_solver.cc.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_lib.dir/build.make CMakeFiles/nufi_lib.dir/src/nufi_solver.cc.s
.PHONY : src/nufi_solver.cc.s
src/save_results.o: src/save_results.cc.o
.PHONY : src/save_results.o
# target to build an object file
src/save_results.cc.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_lib.dir/build.make CMakeFiles/nufi_lib.dir/src/save_results.cc.o
.PHONY : src/save_results.cc.o
src/save_results.i: src/save_results.cc.i
.PHONY : src/save_results.i
# target to preprocess a source file
src/save_results.cc.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_lib.dir/build.make CMakeFiles/nufi_lib.dir/src/save_results.cc.i
.PHONY : src/save_results.cc.i
src/save_results.s: src/save_results.cc.s
.PHONY : src/save_results.s
# target to generate assembly for a file
src/save_results.cc.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_lib.dir/build.make CMakeFiles/nufi_lib.dir/src/save_results.cc.s
.PHONY : src/save_results.cc.s
# Help Target
help:
@@ -161,10 +222,17 @@ help:
@echo "... depend"
@echo "... edit_cache"
@echo "... rebuild_cache"
@echo "... nufi_lib"
@echo "... nufi_poisson"
@echo "... nufi_poisson.o"
@echo "... nufi_poisson.i"
@echo "... nufi_poisson.s"
@echo "... src/main.o"
@echo "... src/main.i"
@echo "... src/main.s"
@echo "... src/nufi_solver.o"
@echo "... src/nufi_solver.i"
@echo "... src/nufi_solver.s"
@echo "... src/save_results.o"
@echo "... src/save_results.i"
@echo "... src/save_results.s"
.PHONY : help
-402
View File
@@ -1,402 +0,0 @@
# vtk DataFile Version 3.0
#This file was generated by the deal.II library on 2026/2/26 at 2:47:45
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 256 double
0 0 0
0.09375 0 0
0.09375 0 0
0.1875 0 0
0.1875 0 0
0.28125 0 0
0.28125 0 0
0.375 0 0
0.375 0 0
0.46875 0 0
0.46875 0 0
0.5625 0 0
0.5625 0 0
0.65625 0 0
0.65625 0 0
0.75 0 0
0.75 0 0
0.84375 0 0
0.84375 0 0
0.9375 0 0
0.9375 0 0
1.03125 0 0
1.03125 0 0
1.125 0 0
1.125 0 0
1.21875 0 0
1.21875 0 0
1.3125 0 0
1.3125 0 0
1.40625 0 0
1.40625 0 0
1.5 0 0
1.5 0 0
1.59375 0 0
1.59375 0 0
1.6875 0 0
1.6875 0 0
1.78125 0 0
1.78125 0 0
1.875 0 0
1.875 0 0
1.96875 0 0
1.96875 0 0
2.0625 0 0
2.0625 0 0
2.15625 0 0
2.15625 0 0
2.25 0 0
2.25 0 0
2.34375 0 0
2.34375 0 0
2.4375 0 0
2.4375 0 0
2.53125 0 0
2.53125 0 0
2.625 0 0
2.625 0 0
2.71875 0 0
2.71875 0 0
2.8125 0 0
2.8125 0 0
2.90625 0 0
2.90625 0 0
3 0 0
3 0 0
3.09375 0 0
3.09375 0 0
3.1875 0 0
3.1875 0 0
3.28125 0 0
3.28125 0 0
3.375 0 0
3.375 0 0
3.46875 0 0
3.46875 0 0
3.5625 0 0
3.5625 0 0
3.65625 0 0
3.65625 0 0
3.75 0 0
3.75 0 0
3.84375 0 0
3.84375 0 0
3.9375 0 0
3.9375 0 0
4.03125 0 0
4.03125 0 0
4.125 0 0
4.125 0 0
4.21875 0 0
4.21875 0 0
4.3125 0 0
4.3125 0 0
4.40625 0 0
4.40625 0 0
4.5 0 0
4.5 0 0
4.59375 0 0
4.59375 0 0
4.6875 0 0
4.6875 0 0
4.78125 0 0
4.78125 0 0
4.875 0 0
4.875 0 0
4.96875 0 0
4.96875 0 0
5.0625 0 0
5.0625 0 0
5.15625 0 0
5.15625 0 0
5.25 0 0
5.25 0 0
5.34375 0 0
5.34375 0 0
5.4375 0 0
5.4375 0 0
5.53125 0 0
5.53125 0 0
5.625 0 0
5.625 0 0
5.71875 0 0
5.71875 0 0
5.8125 0 0
5.8125 0 0
5.90625 0 0
5.90625 0 0
6 0 0
6 0 0
6.09375 0 0
6.09375 0 0
6.1875 0 0
6.1875 0 0
6.28125 0 0
6.28125 0 0
6.375 0 0
6.375 0 0
6.46875 0 0
6.46875 0 0
6.5625 0 0
6.5625 0 0
6.65625 0 0
6.65625 0 0
6.75 0 0
6.75 0 0
6.84375 0 0
6.84375 0 0
6.9375 0 0
6.9375 0 0
7.03125 0 0
7.03125 0 0
7.125 0 0
7.125 0 0
7.21875 0 0
7.21875 0 0
7.3125 0 0
7.3125 0 0
7.40625 0 0
7.40625 0 0
7.5 0 0
7.5 0 0
7.59375 0 0
7.59375 0 0
7.6875 0 0
7.6875 0 0
7.78125 0 0
7.78125 0 0
7.875 0 0
7.875 0 0
7.96875 0 0
7.96875 0 0
8.0625 0 0
8.0625 0 0
8.15625 0 0
8.15625 0 0
8.25 0 0
8.25 0 0
8.34375 0 0
8.34375 0 0
8.4375 0 0
8.4375 0 0
8.53125 0 0
8.53125 0 0
8.625 0 0
8.625 0 0
8.71875 0 0
8.71875 0 0
8.8125 0 0
8.8125 0 0
8.90625 0 0
8.90625 0 0
9 0 0
9 0 0
9.09375 0 0
9.09375 0 0
9.1875 0 0
9.1875 0 0
9.28125 0 0
9.28125 0 0
9.375 0 0
9.375 0 0
9.46875 0 0
9.46875 0 0
9.5625 0 0
9.5625 0 0
9.65625 0 0
9.65625 0 0
9.75 0 0
9.75 0 0
9.84375 0 0
9.84375 0 0
9.9375 0 0
9.9375 0 0
10.0312 0 0
10.0312 0 0
10.125 0 0
10.125 0 0
10.2188 0 0
10.2188 0 0
10.3125 0 0
10.3125 0 0
10.4062 0 0
10.4062 0 0
10.5 0 0
10.5 0 0
10.5938 0 0
10.5938 0 0
10.6875 0 0
10.6875 0 0
10.7812 0 0
10.7812 0 0
10.875 0 0
10.875 0 0
10.9688 0 0
10.9688 0 0
11.0625 0 0
11.0625 0 0
11.1562 0 0
11.1562 0 0
11.25 0 0
11.25 0 0
11.3438 0 0
11.3438 0 0
11.4375 0 0
11.4375 0 0
11.5312 0 0
11.5312 0 0
11.625 0 0
11.625 0 0
11.7188 0 0
11.7188 0 0
11.8125 0 0
11.8125 0 0
11.9062 0 0
11.9062 0 0
12 0 0
CELLS 128 384
2 0 1
2 2 3
2 4 5
2 6 7
2 8 9
2 10 11
2 12 13
2 14 15
2 16 17
2 18 19
2 20 21
2 22 23
2 24 25
2 26 27
2 28 29
2 30 31
2 32 33
2 34 35
2 36 37
2 38 39
2 40 41
2 42 43
2 44 45
2 46 47
2 48 49
2 50 51
2 52 53
2 54 55
2 56 57
2 58 59
2 60 61
2 62 63
2 64 65
2 66 67
2 68 69
2 70 71
2 72 73
2 74 75
2 76 77
2 78 79
2 80 81
2 82 83
2 84 85
2 86 87
2 88 89
2 90 91
2 92 93
2 94 95
2 96 97
2 98 99
2 100 101
2 102 103
2 104 105
2 106 107
2 108 109
2 110 111
2 112 113
2 114 115
2 116 117
2 118 119
2 120 121
2 122 123
2 124 125
2 126 127
2 128 129
2 130 131
2 132 133
2 134 135
2 136 137
2 138 139
2 140 141
2 142 143
2 144 145
2 146 147
2 148 149
2 150 151
2 152 153
2 154 155
2 156 157
2 158 159
2 160 161
2 162 163
2 164 165
2 166 167
2 168 169
2 170 171
2 172 173
2 174 175
2 176 177
2 178 179
2 180 181
2 182 183
2 184 185
2 186 187
2 188 189
2 190 191
2 192 193
2 194 195
2 196 197
2 198 199
2 200 201
2 202 203
2 204 205
2 206 207
2 208 209
2 210 211
2 212 213
2 214 215
2 216 217
2 218 219
2 220 221
2 222 223
2 224 225
2 226 227
2 228 229
2 230 231
2 232 233
2 234 235
2 236 237
2 238 239
2 240 241
2 242 243
2 244 245
2 246 247
2 248 249
2 250 251
2 252 253
2 254 255
CELL_TYPES 128
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
POINT_DATA 256
SCALARS density double 1
LOOKUP_TABLE default
-0.00999992 -0.00998894 -0.00998894 -0.00995601 -0.00995601 -0.00990121 -0.00990121 -0.00982466 -0.00982466 -0.00972652 -0.00972652 -0.00960702 -0.00960702 -0.00946641 -0.00946641 -0.009305 -0.009305 -0.00912315 -0.00912315 -0.00892126 -0.00892126 -0.00869977 -0.00869977 -0.00845917 -0.00845917 -0.00819998 -0.00819998 -0.00792278 -0.00792278 -0.00762818 -0.00762818 -0.00731681 -0.00731681 -0.00698938 -0.00698938 -0.00664658 -0.00664658 -0.00628919 -0.00628919 -0.00591798 -0.00591798 -0.00553376 -0.00553376 -0.00513739 -0.00513739 -0.00472974 -0.00472974 -0.00431169 -0.00431169 -0.00388417 -0.00388417 -0.00344812 -0.00344812 -0.00300449 -0.00300449 -0.00255426 -0.00255426 -0.00209842 -0.00209842 -0.00163797 -0.00163797 -0.00117392 -0.00117392 -0.000707297 -0.000707297 -0.000239116 -0.000239116 0.000229591 0.000229591 0.000697794 0.000697794 0.00116446 0.00116446 0.00162858 0.00162858 0.00208911 0.00208911 0.00254506 0.00254506 0.00299541 0.00299541 0.00343918 0.00343918 0.0038754 0.0038754 0.00430311 0.00430311 0.00472136 0.00472136 0.00512924 0.00512924 0.00552585 0.00552585 0.00591032 0.00591032 0.00628181 0.00628181 0.0066395 0.0066395 0.0069826 0.0069826 0.00731036 0.00731036 0.00762207 0.00762207 0.00791703 0.00791703 0.00819459 0.00819459 0.00845416 0.00845416 0.00869515 0.00869515 0.00891704 0.00891704 0.00911934 0.00911934 0.0093016 0.0093016 0.00946343 0.00946343 0.00960448 0.00960448 0.00972442 0.00972442 0.009823 0.009823 0.0099 0.0099 0.00995525 0.00995525 0.00998863 0.00998863 0.0100001 0.0100001 0.00998954 0.00998954 0.00995706 0.00995706 0.00990271 0.00990271 0.00982661 0.00982661 0.00972891 0.00972891 0.00960985 0.00960985 0.00946967 0.00946967 0.00930869 0.00930869 0.00912726 0.00912726 0.00892578 0.00892578 0.00870469 0.00870469 0.00846448 0.00846448 0.00820567 0.00820567 0.00792883 0.00792883 0.00763458 0.00763458 0.00732356 0.00732356 0.00699644 0.00699644 0.00665396 0.00665396 0.00629686 0.00629686 0.00592592 0.00592592 0.00554197 0.00554197 0.00514584 0.00514584 0.00473841 0.00473841 0.00432057 0.00432057 0.00389324 0.00389324 0.00345735 0.00345735 0.00301387 0.00301387 0.00256377 0.00256377 0.00210803 0.00210803 0.00164767 0.00164767 0.00118368 0.00118368 0.000717099 0.000717099 0.000248939 0.000248939 -0.000219768 -0.000219768 -0.000687991 -0.000687991 -0.0011547 -0.0011547 -0.00161888 -0.00161888 -0.0020795 -0.0020795 -0.00253555 -0.00253555 -0.00298603 -0.00298603 -0.00342995 -0.00342995 -0.00386633 -0.00386633 -0.00429422 -0.00429422 -0.00471268 -0.00471268 -0.00512078 -0.00512078 -0.00551763 -0.00551763 -0.00590236 -0.00590236 -0.00627413 -0.00627413 -0.00663211 -0.00663211 -0.00697552 -0.00697552 -0.00730361 -0.00730361 -0.00761565 -0.00761565 -0.00791096 -0.00791096 -0.00818889 -0.00818889 -0.00844883 -0.00844883 -0.00869021 -0.00869021 -0.0089125 -0.0089125 -0.00911521 -0.00911521 -0.00929789 -0.00929789 -0.00946015 -0.00946015 -0.00960163
SCALARS x_coordinate double 1
LOOKUP_TABLE default
0 0.09375 0.09375 0.1875 0.1875 0.28125 0.28125 0.375 0.375 0.46875 0.46875 0.5625 0.5625 0.65625 0.65625 0.75 0.75 0.84375 0.84375 0.9375 0.9375 1.03125 1.03125 1.125 1.125 1.21875 1.21875 1.3125 1.3125 1.40625 1.40625 1.5 1.5 1.59375 1.59375 1.6875 1.6875 1.78125 1.78125 1.875 1.875 1.96875 1.96875 2.0625 2.0625 2.15625 2.15625 2.25 2.25 2.34375 2.34375 2.4375 2.4375 2.53125 2.53125 2.625 2.625 2.71875 2.71875 2.8125 2.8125 2.90625 2.90625 3 3 3.09375 3.09375 3.1875 3.1875 3.28125 3.28125 3.375 3.375 3.46875 3.46875 3.5625 3.5625 3.65625 3.65625 3.75 3.75 3.84375 3.84375 3.9375 3.9375 4.03125 4.03125 4.125 4.125 4.21875 4.21875 4.3125 4.3125 4.40625 4.40625 4.5 4.5 4.59375 4.59375 4.6875 4.6875 4.78125 4.78125 4.875 4.875 4.96875 4.96875 5.0625 5.0625 5.15625 5.15625 5.25 5.25 5.34375 5.34375 5.4375 5.4375 5.53125 5.53125 5.625 5.625 5.71875 5.71875 5.8125 5.8125 5.90625 5.90625 6 6 6.09375 6.09375 6.1875 6.1875 6.28125 6.28125 6.375 6.375 6.46875 6.46875 6.5625 6.5625 6.65625 6.65625 6.75 6.75 6.84375 6.84375 6.9375 6.9375 7.03125 7.03125 7.125 7.125 7.21875 7.21875 7.3125 7.3125 7.40625 7.40625 7.5 7.5 7.59375 7.59375 7.6875 7.6875 7.78125 7.78125 7.875 7.875 7.96875 7.96875 8.0625 8.0625 8.15625 8.15625 8.25 8.25 8.34375 8.34375 8.4375 8.4375 8.53125 8.53125 8.625 8.625 8.71875 8.71875 8.8125 8.8125 8.90625 8.90625 9 9 9.09375 9.09375 9.1875 9.1875 9.28125 9.28125 9.375 9.375 9.46875 9.46875 9.5625 9.5625 9.65625 9.65625 9.75 9.75 9.84375 9.84375 9.9375 9.9375 10.0312 10.0312 10.125 10.125 10.2188 10.2188 10.3125 10.3125 10.4062 10.4062 10.5 10.5 10.5938 10.5938 10.6875 10.6875 10.7812 10.7812 10.875 10.875 10.9688 10.9688 11.0625 11.0625 11.1562 11.1562 11.25 11.25 11.3438 11.3438 11.4375 11.4375 11.5312 11.5312 11.625 11.625 11.7188 11.7188 11.8125 11.8125 11.9062 11.9062 12
-659
View File
@@ -1,659 +0,0 @@
# vtk DataFile Version 3.0
#This file was generated by the deal.II library on 2026/2/26 at 2:47:45
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 256 double
0 0 0
0.09375 0 0
0.09375 0 0
0.1875 0 0
0.1875 0 0
0.28125 0 0
0.28125 0 0
0.375 0 0
0.375 0 0
0.46875 0 0
0.46875 0 0
0.5625 0 0
0.5625 0 0
0.65625 0 0
0.65625 0 0
0.75 0 0
0.75 0 0
0.84375 0 0
0.84375 0 0
0.9375 0 0
0.9375 0 0
1.03125 0 0
1.03125 0 0
1.125 0 0
1.125 0 0
1.21875 0 0
1.21875 0 0
1.3125 0 0
1.3125 0 0
1.40625 0 0
1.40625 0 0
1.5 0 0
1.5 0 0
1.59375 0 0
1.59375 0 0
1.6875 0 0
1.6875 0 0
1.78125 0 0
1.78125 0 0
1.875 0 0
1.875 0 0
1.96875 0 0
1.96875 0 0
2.0625 0 0
2.0625 0 0
2.15625 0 0
2.15625 0 0
2.25 0 0
2.25 0 0
2.34375 0 0
2.34375 0 0
2.4375 0 0
2.4375 0 0
2.53125 0 0
2.53125 0 0
2.625 0 0
2.625 0 0
2.71875 0 0
2.71875 0 0
2.8125 0 0
2.8125 0 0
2.90625 0 0
2.90625 0 0
3 0 0
3 0 0
3.09375 0 0
3.09375 0 0
3.1875 0 0
3.1875 0 0
3.28125 0 0
3.28125 0 0
3.375 0 0
3.375 0 0
3.46875 0 0
3.46875 0 0
3.5625 0 0
3.5625 0 0
3.65625 0 0
3.65625 0 0
3.75 0 0
3.75 0 0
3.84375 0 0
3.84375 0 0
3.9375 0 0
3.9375 0 0
4.03125 0 0
4.03125 0 0
4.125 0 0
4.125 0 0
4.21875 0 0
4.21875 0 0
4.3125 0 0
4.3125 0 0
4.40625 0 0
4.40625 0 0
4.5 0 0
4.5 0 0
4.59375 0 0
4.59375 0 0
4.6875 0 0
4.6875 0 0
4.78125 0 0
4.78125 0 0
4.875 0 0
4.875 0 0
4.96875 0 0
4.96875 0 0
5.0625 0 0
5.0625 0 0
5.15625 0 0
5.15625 0 0
5.25 0 0
5.25 0 0
5.34375 0 0
5.34375 0 0
5.4375 0 0
5.4375 0 0
5.53125 0 0
5.53125 0 0
5.625 0 0
5.625 0 0
5.71875 0 0
5.71875 0 0
5.8125 0 0
5.8125 0 0
5.90625 0 0
5.90625 0 0
6 0 0
6 0 0
6.09375 0 0
6.09375 0 0
6.1875 0 0
6.1875 0 0
6.28125 0 0
6.28125 0 0
6.375 0 0
6.375 0 0
6.46875 0 0
6.46875 0 0
6.5625 0 0
6.5625 0 0
6.65625 0 0
6.65625 0 0
6.75 0 0
6.75 0 0
6.84375 0 0
6.84375 0 0
6.9375 0 0
6.9375 0 0
7.03125 0 0
7.03125 0 0
7.125 0 0
7.125 0 0
7.21875 0 0
7.21875 0 0
7.3125 0 0
7.3125 0 0
7.40625 0 0
7.40625 0 0
7.5 0 0
7.5 0 0
7.59375 0 0
7.59375 0 0
7.6875 0 0
7.6875 0 0
7.78125 0 0
7.78125 0 0
7.875 0 0
7.875 0 0
7.96875 0 0
7.96875 0 0
8.0625 0 0
8.0625 0 0
8.15625 0 0
8.15625 0 0
8.25 0 0
8.25 0 0
8.34375 0 0
8.34375 0 0
8.4375 0 0
8.4375 0 0
8.53125 0 0
8.53125 0 0
8.625 0 0
8.625 0 0
8.71875 0 0
8.71875 0 0
8.8125 0 0
8.8125 0 0
8.90625 0 0
8.90625 0 0
9 0 0
9 0 0
9.09375 0 0
9.09375 0 0
9.1875 0 0
9.1875 0 0
9.28125 0 0
9.28125 0 0
9.375 0 0
9.375 0 0
9.46875 0 0
9.46875 0 0
9.5625 0 0
9.5625 0 0
9.65625 0 0
9.65625 0 0
9.75 0 0
9.75 0 0
9.84375 0 0
9.84375 0 0
9.9375 0 0
9.9375 0 0
10.0312 0 0
10.0312 0 0
10.125 0 0
10.125 0 0
10.2188 0 0
10.2188 0 0
10.3125 0 0
10.3125 0 0
10.4062 0 0
10.4062 0 0
10.5 0 0
10.5 0 0
10.5938 0 0
10.5938 0 0
10.6875 0 0
10.6875 0 0
10.7812 0 0
10.7812 0 0
10.875 0 0
10.875 0 0
10.9688 0 0
10.9688 0 0
11.0625 0 0
11.0625 0 0
11.1562 0 0
11.1562 0 0
11.25 0 0
11.25 0 0
11.3438 0 0
11.3438 0 0
11.4375 0 0
11.4375 0 0
11.5312 0 0
11.5312 0 0
11.625 0 0
11.625 0 0
11.7188 0 0
11.7188 0 0
11.8125 0 0
11.8125 0 0
11.9062 0 0
11.9062 0 0
12 0 0
CELLS 128 384
2 0 1
2 2 3
2 4 5
2 6 7
2 8 9
2 10 11
2 12 13
2 14 15
2 16 17
2 18 19
2 20 21
2 22 23
2 24 25
2 26 27
2 28 29
2 30 31
2 32 33
2 34 35
2 36 37
2 38 39
2 40 41
2 42 43
2 44 45
2 46 47
2 48 49
2 50 51
2 52 53
2 54 55
2 56 57
2 58 59
2 60 61
2 62 63
2 64 65
2 66 67
2 68 69
2 70 71
2 72 73
2 74 75
2 76 77
2 78 79
2 80 81
2 82 83
2 84 85
2 86 87
2 88 89
2 90 91
2 92 93
2 94 95
2 96 97
2 98 99
2 100 101
2 102 103
2 104 105
2 106 107
2 108 109
2 110 111
2 112 113
2 114 115
2 116 117
2 118 119
2 120 121
2 122 123
2 124 125
2 126 127
2 128 129
2 130 131
2 132 133
2 134 135
2 136 137
2 138 139
2 140 141
2 142 143
2 144 145
2 146 147
2 148 149
2 150 151
2 152 153
2 154 155
2 156 157
2 158 159
2 160 161
2 162 163
2 164 165
2 166 167
2 168 169
2 170 171
2 172 173
2 174 175
2 176 177
2 178 179
2 180 181
2 182 183
2 184 185
2 186 187
2 188 189
2 190 191
2 192 193
2 194 195
2 196 197
2 198 199
2 200 201
2 202 203
2 204 205
2 206 207
2 208 209
2 210 211
2 212 213
2 214 215
2 216 217
2 218 219
2 220 221
2 222 223
2 224 225
2 226 227
2 228 229
2 230 231
2 232 233
2 234 235
2 236 237
2 238 239
2 240 241
2 242 243
2 244 245
2 246 247
2 248 249
2 250 251
2 252 253
2 254 255
CELL_TYPES 128
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
POINT_DATA 256
VECTORS electric_field double
-0.00558919 0 0
-0.00652637 0 0
-0.00652634 0 0
-0.00746147 0 0
-0.00746143 0 0
-0.00839244 0 0
-0.00839241 0 0
-0.00931726 0 0
-0.00931723 0 0
-0.0102339 0 0
-0.0102339 0 0
-0.0111403 0 0
-0.0111403 0 0
-0.0120345 0 0
-0.0120345 0 0
-0.0129146 0 0
-0.0129146 0 0
-0.0137786 0 0
-0.0137786 0 0
-0.0146246 0 0
-0.0146246 0 0
-0.0154507 0 0
-0.0154507 0 0
-0.0162552 0 0
-0.0162552 0 0
-0.0170362 0 0
-0.0170362 0 0
-0.0177921 0 0
-0.0177921 0 0
-0.0185212 0 0
-0.0185212 0 0
-0.0192219 0 0
-0.0192219 0 0
-0.0198926 0 0
-0.0198926 0 0
-0.0205319 0 0
-0.0205319 0 0
-0.0211384 0 0
-0.0211384 0 0
-0.0217107 0 0
-0.0217107 0 0
-0.0222476 0 0
-0.0222476 0 0
-0.0227479 0 0
-0.0227479 0 0
-0.0232105 0 0
-0.0232105 0 0
-0.0236344 0 0
-0.0236344 0 0
-0.0240186 0 0
-0.0240186 0 0
-0.0243624 0 0
-0.0243624 0 0
-0.0246649 0 0
-0.0246649 0 0
-0.0249255 0 0
-0.0249255 0 0
-0.0251437 0 0
-0.0251437 0 0
-0.0253189 0 0
-0.0253188 0 0
-0.0254507 0 0
-0.0254507 0 0
-0.0255389 0 0
-0.0255389 0 0
-0.0255833 0 0
-0.0255833 0 0
-0.0255837 0 0
-0.0255837 0 0
-0.0255402 0 0
-0.0255402 0 0
-0.0254529 0 0
-0.0254529 0 0
-0.025322 0 0
-0.025322 0 0
-0.0251477 0 0
-0.0251477 0 0
-0.0249304 0 0
-0.0249304 0 0
-0.0246706 0 0
-0.0246706 0 0
-0.024369 0 0
-0.024369 0 0
-0.024026 0 0
-0.024026 0 0
-0.0236426 0 0
-0.0236426 0 0
-0.0232195 0 0
-0.0232195 0 0
-0.0227577 0 0
-0.0227577 0 0
-0.0222581 0 0
-0.0222581 0 0
-0.0217219 0 0
-0.021722 0 0
-0.0211503 0 0
-0.0211503 0 0
-0.0205445 0 0
-0.0205445 0 0
-0.0199059 0 0
-0.0199059 0 0
-0.0192358 0 0
-0.0192358 0 0
-0.0185357 0 0
-0.0185357 0 0
-0.0178072 0 0
-0.0178072 0 0
-0.0170518 0 0
-0.0170518 0 0
-0.0162712 0 0
-0.0162713 0 0
-0.0154672 0 0
-0.0154672 0 0
-0.0146415 0 0
-0.0146415 0 0
-0.0137959 0 0
-0.0137959 0 0
-0.0129322 0 0
-0.0129323 0 0
-0.0120525 0 0
-0.0120525 0 0
-0.0111585 0 0
-0.0111585 0 0
-0.0102523 0 0
-0.0102523 0 0
-0.00933583 0 0
-0.00933586 0 0
-0.00841114 0 0
-0.00841118 0 0
-0.00748026 0 0
-0.00748029 0 0
-0.00654522 0 0
-0.00654525 0 0
-0.00560807 0 0
-0.00560811 0 0
-0.00467089 0 0
-0.00467092 0 0
-0.00373572 0 0
-0.00373576 0 0
-0.00280462 0 0
-0.00280466 0 0
-0.00187964 0 0
-0.00187968 0 0
-0.00096281 0 0
-0.000962843 0 0
-5.61397e-05 0 0
-5.61726e-05 0 0
0.000838376 0 0
0.000838344 0 0
0.00171877 0 0
0.00171874 0 0
0.00258312 0 0
0.00258308 0 0
0.00342951 0 0
0.00342948 0 0
0.00425609 0 0
0.00425606 0 0
0.00506104 0 0
0.00506101 0 0
0.00584259 0 0
0.00584257 0 0
0.00659904 0 0
0.00659901 0 0
0.0073287 0 0
0.00732868 0 0
0.00802999 0 0
0.00802997 0 0
0.00870137 0 0
0.00870134 0 0
0.00934135 0 0
0.00934132 0 0
0.00994853 0 0
0.0099485 0 0
0.0105216 0 0
0.0105216 0 0
0.0110592 0 0
0.0110592 0 0
0.0115603 0 0
0.0115603 0 0
0.0120237 0 0
0.0120237 0 0
0.0124484 0 0
0.0124484 0 0
0.0128335 0 0
0.0128335 0 0
0.0131781 0 0
0.0131781 0 0
0.0134815 0 0
0.0134815 0 0
0.013743 0 0
0.013743 0 0
0.0139621 0 0
0.0139621 0 0
0.0141382 0 0
0.0141381 0 0
0.0142709 0 0
0.0142709 0 0
0.01436 0 0
0.01436 0 0
0.0144053 0 0
0.0144053 0 0
0.0144067 0 0
0.0144067 0 0
0.0143641 0 0
0.0143641 0 0
0.0142777 0 0
0.0142777 0 0
0.0141477 0 0
0.0141477 0 0
0.0139743 0 0
0.0139743 0 0
0.0137579 0 0
0.0137579 0 0
0.013499 0 0
0.0134991 0 0
0.0131982 0 0
0.0131982 0 0
0.0128562 0 0
0.0128562 0 0
0.0124736 0 0
0.0124736 0 0
0.0120513 0 0
0.0120513 0 0
0.0115903 0 0
0.0115903 0 0
0.0110915 0 0
0.0110915 0 0
0.0105561 0 0
0.0105561 0 0
0.0099852 0 0
0.00998522 0 0
0.00938011 0 0
0.00938013 0 0
0.00874214 0 0
0.00874216 0 0
0.00807268 0 0
0.0080727 0 0
0.00737321 0 0
0.00737323 0 0
0.00664527 0 0
0.00664529 0 0
0.00589045 0 0
0.00589047 0 0
0.00511041 0 0
0.00511044 0 0
0.00430687 0 0
0.0043069 0 0
0.00348159 0 0
0.00348162 0 0
0.00263639 0 0
0.00263642 0 0
0.00177311 0 0
0.00177315 0 0
0.000893668 0 0
0.000893701 0 0
-1.6382e-08 0 0
SCALARS potential double 1
LOOKUP_TABLE default
0 0.000567925 0.000567925 0.00122363 0.00122363 0.00196682 0.00196682 0.00279702 0.00279702 0.00371355 0.00371355 0.00471555 0.00471555 0.00580197 0.00580197 0.00697158 0.00697158 0.00822296 0.00822296 0.0095545 0.0095545 0.0109644 0.0109644 0.0124508 0.0124508 0.0140116 0.0140116 0.0156443 0.0156443 0.0173467 0.0173467 0.0191162 0.0191162 0.0209499 0.0209499 0.0228451 0.0228451 0.0247986 0.0247986 0.0268074 0.0268074 0.0288683 0.0288683 0.0309777 0.0309777 0.0331323 0.0331323 0.0353285 0.0353285 0.0375625 0.0375625 0.0398307 0.0398307 0.0421292 0.0421292 0.0444541 0.0444541 0.0468014 0.0468014 0.0491672 0.0491672 0.0515473 0.0515473 0.0539378 0.0539378 0.0563345 0.0563345 0.0587333 0.0587333 0.0611301 0.0611301 0.0635207 0.0635207 0.0659011 0.0659011 0.0682672 0.0682672 0.070615 0.070615 0.0729403 0.0729403 0.0752394 0.0752394 0.0775082 0.0775082 0.079743 0.079743 0.08194 0.08194 0.0840955 0.0840955 0.0862059 0.0862059 0.0882677 0.0882677 0.0902776 0.0902776 0.0922323 0.0922323 0.0941287 0.0941287 0.0959637 0.0959637 0.0977345 0.0977345 0.0994383 0.0994383 0.101072 0.101072 0.102635 0.102635 0.104123 0.104123 0.105534 0.105534 0.106867 0.106867 0.10812 0.10812 0.109292 0.109292 0.11038 0.11038 0.111383 0.111383 0.112302 0.112302 0.113134 0.113134 0.113879 0.113879 0.114536 0.114536 0.115106 0.115106 0.115588 0.115588 0.115982 0.115982 0.116288 0.116288 0.116508 0.116508 0.116641 0.116641 0.116688 0.116688 0.116652 0.116652 0.116532 0.116532 0.11633 0.11633 0.116048 0.116048 0.115688 0.115688 0.115251 0.115251 0.114739 0.114739 0.114156 0.114156 0.113503 0.113503 0.112783 0.112783 0.111998 0.111998 0.111152 0.111152 0.110248 0.110248 0.109288 0.109288 0.108276 0.108276 0.107215 0.107215 0.10611 0.10611 0.104962 0.104962 0.103777 0.103777 0.102557 0.102557 0.101307 0.101307 0.100031 0.100031 0.0987317 0.0987317 0.0974141 0.0974141 0.0960821 0.0960821 0.0947397 0.0947397 0.093391 0.093391 0.0920401 0.0920401 0.0906911 0.0906911 0.0893482 0.0893482 0.0880154 0.0880154 0.0866968 0.0866968 0.0853966 0.0853966 0.0841186 0.0841186 0.0828668 0.0828668 0.0816452 0.0816452 0.0804575 0.0804575 0.0793076 0.0793076 0.0781991 0.0781991 0.0771356 0.0771356 0.0761206 0.0761206 0.0751575 0.0751575 0.0742495 0.0742495 0.0733997 0.0733997 0.0726113 0.0726113 0.071887 0.071887 0.0712297 0.0712297 0.0706419 0.0706419 0.070126 0.070126 0.0696844 0.0696844 0.0693192 0.0693192 0.0690322 0.0690322 0.0688254 0.0688254 0.0687003 0.0687003 0.0686583
SCALARS x_coordinate double 1
LOOKUP_TABLE default
0 0.09375 0.09375 0.1875 0.1875 0.28125 0.28125 0.375 0.375 0.46875 0.46875 0.5625 0.5625 0.65625 0.65625 0.75 0.75 0.84375 0.84375 0.9375 0.9375 1.03125 1.03125 1.125 1.125 1.21875 1.21875 1.3125 1.3125 1.40625 1.40625 1.5 1.5 1.59375 1.59375 1.6875 1.6875 1.78125 1.78125 1.875 1.875 1.96875 1.96875 2.0625 2.0625 2.15625 2.15625 2.25 2.25 2.34375 2.34375 2.4375 2.4375 2.53125 2.53125 2.625 2.625 2.71875 2.71875 2.8125 2.8125 2.90625 2.90625 3 3 3.09375 3.09375 3.1875 3.1875 3.28125 3.28125 3.375 3.375 3.46875 3.46875 3.5625 3.5625 3.65625 3.65625 3.75 3.75 3.84375 3.84375 3.9375 3.9375 4.03125 4.03125 4.125 4.125 4.21875 4.21875 4.3125 4.3125 4.40625 4.40625 4.5 4.5 4.59375 4.59375 4.6875 4.6875 4.78125 4.78125 4.875 4.875 4.96875 4.96875 5.0625 5.0625 5.15625 5.15625 5.25 5.25 5.34375 5.34375 5.4375 5.4375 5.53125 5.53125 5.625 5.625 5.71875 5.71875 5.8125 5.8125 5.90625 5.90625 6 6 6.09375 6.09375 6.1875 6.1875 6.28125 6.28125 6.375 6.375 6.46875 6.46875 6.5625 6.5625 6.65625 6.65625 6.75 6.75 6.84375 6.84375 6.9375 6.9375 7.03125 7.03125 7.125 7.125 7.21875 7.21875 7.3125 7.3125 7.40625 7.40625 7.5 7.5 7.59375 7.59375 7.6875 7.6875 7.78125 7.78125 7.875 7.875 7.96875 7.96875 8.0625 8.0625 8.15625 8.15625 8.25 8.25 8.34375 8.34375 8.4375 8.4375 8.53125 8.53125 8.625 8.625 8.71875 8.71875 8.8125 8.8125 8.90625 8.90625 9 9 9.09375 9.09375 9.1875 9.1875 9.28125 9.28125 9.375 9.375 9.46875 9.46875 9.5625 9.5625 9.65625 9.65625 9.75 9.75 9.84375 9.84375 9.9375 9.9375 10.0312 10.0312 10.125 10.125 10.2188 10.2188 10.3125 10.3125 10.4062 10.4062 10.5 10.5 10.5938 10.5938 10.6875 10.6875 10.7812 10.7812 10.875 10.875 10.9688 10.9688 11.0625 11.0625 11.1562 11.1562 11.25 11.25 11.3438 11.3438 11.4375 11.4375 11.5312 11.5312 11.625 11.625 11.7188 11.7188 11.8125 11.8125 11.9062 11.9062 12
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef NUFI_BLAS_HPP
#define NUFI_BLAS_HPP
#ifndef NUFI_BLAS_H
#define NUFI_BLAS_H
#include <cstddef>
+5 -5
View File
@@ -1,11 +1,11 @@
#ifndef FIELDS_HPP
#define FIELDS_HPP
#ifndef FIELDS_H
#define FIELDS_H
#include <cmath>
#include <deal.II/base/function.h>
#include "parameters.hpp"
#include "splines.hpp"
#include "lsmr.hpp"
#include "nufi/parameters.h"
#include "nufi/splines.h"
#include "nufi/lsmr.h"
using namespace dealii;
+3 -3
View File
@@ -1,11 +1,11 @@
#ifndef LSMR_HPP
#define LSMR_HPP
#ifndef LSMR_H
#define LSMR_H
#include <cmath>
#include <limits>
#include <iomanip>
#include <iostream>
#include "blas.hpp"
#include "nufi/blas.h"
template <typename real>
struct lsmr_options
+70
View File
@@ -0,0 +1,70 @@
#ifndef NUFI_SOLVER_H
#define NUFI_SOLVER_H
#include <vector>
#include <cmath>
#include <deal.II/base/point.h>
#include <deal.II/base/tensor.h>
#include <deal.II/numerics/fe_field_function.h>
#include "nufi/parameters.h"
#include "nufi/poisson_problem.h"
#include "nufi/fields.h"
using namespace dealii;
class NuFISolver
{
public:
NuFISolver();
void run();
double eval_rho(unsigned int n, double x, const double *E_coeffs, unsigned int Nv = Parameters::NV) const;
double eval_ftilda(unsigned int n, double x, double u, const double *E_coeffs) const;
private:
unsigned int Nt = std::floor(Parameters::TMAX/Parameters::DT);
unsigned int Nx = Parameters::SPLINE_NX;
double Lx = Parameters::LX;
std::vector<double> rho;
unsigned int order;
PoissonProblem<1> poisson;
};
template<unsigned int dim>
class ChargeDensity_NuFI : public Function<dim>
{
public:
ChargeDensity_NuFI(const double *rho_values, unsigned int Nx)
: Function<dim>(), rho(rho_values), Nx(Nx) {}
virtual double value(const Point<dim> &p,
[[maybe_unused]] const unsigned int component = 0) const override
{
const double x = p[0];
// Map x -> grid index
const double L = Parameters::LX;
const double dx = L / (Nx-1);
int i = static_cast<int>(std::floor((x - Parameters::X_DOMAIN_LEFT) / dx));
// periodic wrap
i = (i % Nx + Nx) % Nx;
return rho[i];
}
private:
const double *rho;
const unsigned int Nx;
};
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef PARAMETERS_HPP
#define PARAMETERS_HPP
#ifndef PARAMETERS_H
#define PARAMETERS_H
#include <cmath>
#include <cstdlib>
@@ -1,7 +1,7 @@
#ifndef POISSON_NON_PERIODIC_HPP
#define POISSON_NON_PERIODIC_HPP
#ifndef POISSON_NON_PERIODIC_H
#define POISSON_NON_PERIODIC_H
#include "parameters.hpp"
#include "nufi/parameters.h"
#include <deal.II/base/point.h>
#include <deal.II/grid/tria.h>
#include <deal.II/dofs/dof_handler.h>
@@ -1,8 +1,7 @@
#ifndef POISSON_PROBLEM_HPP
#define POISSON_PROBLEM_HPP
#ifndef POISSON_PROBLEM_H
#define POISSON_PROBLEM_H
#include <deal.II/base/function.h>
#include <fstream>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/logstream.h>
@@ -38,7 +37,7 @@
#include <utility>
#include <vector>
#include "parameters.hpp"
#include "nufi/parameters.h"
using namespace dealii;
+26
View File
@@ -0,0 +1,26 @@
#ifndef SAVE_RESULTS_H
#define SAVE_RESULTS_H
#include <string>
#include "nufi/nufi_solver.h"
void save_ftilda( const NuFISolver &solver,
unsigned int n,
const double *E_coeffs,
unsigned int Nx_out,
unsigned int Nv_out,
const std::string &filename);
void save_rho(const NuFISolver &solver,
unsigned int n,
const double *E_coeffs,
unsigned int Nx_out,
const std::string &filename);
void save_Efield(unsigned int n,
const double *E_coeffs,
unsigned int Nx_out,
const std::string &filename);
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef SPLINES_HPP
#define SPLINES_HPP
#ifndef SPLINES_H
#define SPLINES_H
#include <cstddef>
-53
View File
@@ -1,53 +0,0 @@
#include <iostream>
#include <filesystem>
#include "nufi_solver.hpp"
int main()
{
try
{
// Delete all files in results/ directory
std::string results_dir = "results";
if (std::filesystem::exists(results_dir) && std::filesystem::is_directory(results_dir))
{
for (const auto& entry : std::filesystem::directory_iterator(results_dir))
{
if (std::filesystem::is_regular_file(entry.path()))
{
std::filesystem::remove(entry.path());
std::cout << "Deleted: " << entry.path() << "\n";
}
}
}
//Used in the past to test the basic poisson problem
//
// PoissonProblem<Parameters::DIMENSION> poisson_problem(Parameters::FE_DEGREE,
// Parameters::NV);
//
// poisson_problem.run();
NuFISolver solver;
solver.run();
}
catch (std::exception &exc)
{
std::cerr << std::endl
<< "Exception: "
<< std::endl
<< exc.what()
<< std::endl;
return 1;
}
catch (...)
{
std::cerr << std::endl
<< "Unknown exception!"
<< std::endl;
return 1;
}
return 0;
}
-152
View File
@@ -1,152 +0,0 @@
#ifndef SPLINE_FIELD_HPP
#define SPLINE_FIELD_HPP
#include <iostream>
#include <stdexcept>
#include <cstddef>
#include <vector>
#include <cmath>
template<typename Real, size_t Order>
class UniformSpline1D
{
public:
struct Config
{
size_t Nx;
Real x_min;
Real Lx;
Real dx;
Real dx_inv;
Real Lx_inv;
};
Config config;
std::vector<Real> coeffs;
public:
UniformSpline1D(const std::vector<Real>& values,
Real x_min,
Real x_max)
{
config.Nx = values.size();
config.x_min = x_min;
config.Lx = x_max - x_min;
config.dx = config.Lx / (config.Nx-1);
config.dx_inv = 1.0 / config.dx;
config.Lx_inv = 1.0 / config.Lx;
coeffs.resize(config.Nx + Order - 1);
interpolate(values);
}
Real eval(Real x) const
{
x -= config.x_min;
x = std::fmod(x, config.Lx);
if (x<0) x+= config.Lx;
Real x_cell = x * config.dx_inv;
size_t i = std::min(static_cast<size_t>(std::floor(x_cell)), config.Nx - 1);
Real local_x = x_cell - i;
Real basis[Order];
basisFunctions(local_x, basis);
Real result = 0;
for(size_t j = 0; j < Order; ++j)
{
size_t idx = (i+j) % coeffs.size();
result += basis[j] * coeffs[idx];
}
return result;
}
private:
static void basisFunctions(Real x, Real* N)
{
Real v[Order];
v[Order-1] = 1;
for(size_t k = 1; k < Order; ++k)
{
v[Order-k-1] = (1-x)*v[Order-k];
for(int i = 1-k; i < 0; ++i)
v[Order-1+i] = (x-i)*v[Order-1+i] + (k+1+i-x)*v[Order+i];
v[Order-1] *= x;
}
Real factor = 1;
for(size_t i=2;i<Order;i++) factor*=i;
for(size_t i=0;i<Order;i++)
N[i] = v[i]/factor;
}
void interpolate(const std::vector<Real>& values)
{
size_t N = config.Nx;
std::vector<Real> rhs(values);
std::vector<std::vector<Real>> A(N, std::vector<Real>(N,0));
Real Nbasis[Order];
basisFunctions(0, Nbasis);
for(size_t i=0;i<N;i++)
{
for(size_t j=0;j<Order;j++)
{
size_t col = (i+j)%N;
A[i][col] = Nbasis[j];
}
}
// naive Gaussian elimination
std::vector<Real> x = rhs;
for(size_t k=0;k<N;k++)
{
Real pivot = A[k][k];
for(size_t j=k;j<N;j++)
A[k][j] /= pivot;
x[k] /= pivot;
for(size_t i=k+1;i<N;i++)
{
Real f = A[i][k];
for(size_t j=k;j<N;j++)
A[i][j] -= f*A[k][j];
x[i] -= f*x[k];
}
}
for(int i=N-1;i>=0;i--)
{
for(size_t j=i+1;j<N;j++)
x[i] -= A[i][j]*x[j];
}
for(size_t i=0;i<N;i++)
coeffs[i] = x[i];
for(size_t i=0;i<Order-1;i++)
coeffs[N+i] = coeffs[i];
}
};
#endif // !SPLINE_FIELD_HPP
+42
View File
@@ -0,0 +1,42 @@
#include <iostream>
#include <filesystem>
#include <nufi/nufi_solver.h>
void clear_results_directory(const std::string &dir)
{
if (!std::filesystem::exists(dir) || !std::filesystem::is_directory(dir))
return;
for (const auto &entry : std::filesystem::directory_iterator(dir))
{
if (std::filesystem::is_regular_file(entry))
{
std::filesystem::remove(entry.path());
std::cout << "Deleted: " << entry.path() << '\n';
}
}
}
int main()
{
try
{
clear_results_directory("results");
NuFISolver solver;
solver.run();
}
catch (const std::exception &exc)
{
std::cerr << "\nException:\n" << exc.what() << "\n";
return 1;
}
catch (...)
{
std::cerr << "\nUnknown exception!\n";
return 1;
}
return 0;
}
+11 -77
View File
@@ -1,5 +1,4 @@
#ifndef NUFI_SOLVER_HPP
#define NUFI_SOLVER_HPP
#include "nufi/nufi_solver.h"
#include <cmath>
#include <cstdlib>
@@ -10,50 +9,19 @@
#include <iostream>
#include <memory>
#include <ostream>
#include <vector>
#include <cstddef>
#include "parameters.hpp"
#include "save_results.hpp"
#include "poisson_problem.hpp"
#include "fields.hpp"
#include "nufi/parameters.h"
#include "nufi/save_results.h"
#include "nufi/poisson_problem.h"
#include "nufi/fields.h"
using namespace dealii;
class NuFISolver
{
public:
NuFISolver();
void run();
double eval_rho(unsigned int n, double x, const double *E_coeffs, unsigned int Nv = Parameters::NV);
double eval_ftilda(unsigned int n, double x, double u, const double *E_coeffs);
// void save_ftilda(unsigned int n, const double *E_coeffs, unsigned int Nx_out, unsigned int Nv_out, const std::string &filename);
// void save_rho(unsigned int n, const double *E_coeffs, unsigned int Nx_out, const std::string &filename);
// void save_Efield(unsigned int n, const double *E_coeffs, unsigned int Nx_out, const std::string &filename);
private:
unsigned int Nt = std::floor(Parameters::TMAX/Parameters::DT);
unsigned int Nx = Parameters::SPLINE_NX;
double Lx = Parameters::LX;
std::vector<double> rho;
unsigned int order;
PoissonProblem<1> poisson;
};
inline double NuFISolver::eval_ftilda(unsigned int n,
double NuFISolver::eval_ftilda(unsigned int n,
double x,
double u,
const double *E_coeffs)
const double *E_coeffs) const
{
if ( n == 0 ) return f0(x,u);
@@ -82,10 +50,10 @@ inline double NuFISolver::eval_ftilda(unsigned int n,
return f0(x,u);
}
inline double NuFISolver::eval_rho(const unsigned int n,
double NuFISolver::eval_rho(const unsigned int n,
const double x,
const double *E_coeffs,
const unsigned int Nv)
const unsigned int Nv) const
{
const double dv = (Parameters::V_DOMAIN_RIGHT - Parameters::V_DOMAIN_LEFT) / Nv;
const double v_min = Parameters::V_DOMAIN_LEFT;
@@ -97,39 +65,7 @@ inline double NuFISolver::eval_rho(const unsigned int n,
return 1.0 - integral;
}
template<unsigned int dim>
class ChargeDensity_NuFI : public Function<dim>
{
public:
ChargeDensity_NuFI(const double *rho_values, unsigned int Nx)
: Function<dim>(), rho(rho_values), Nx(Nx) {}
virtual double value(const Point<dim> &p,
[[maybe_unused]] const unsigned int component = 0) const override
{
const double x = p[0];
// Map x -> grid index
const double L = Parameters::LX;
const double dx = L / (Nx-1);
int i = static_cast<int>(std::floor((x - Parameters::X_DOMAIN_LEFT) / dx));
// periodic wrap
i = (i % Nx + Nx) % Nx;
return rho[i];
}
private:
const double *rho;
const unsigned int Nx;
};
inline void NuFISolver::run()
void NuFISolver::run()
{
std::cout << "Building E_sline\n\n";
@@ -192,12 +128,10 @@ inline void NuFISolver::run()
std::cout << "NuFI simulation finished.\n";
}
inline NuFISolver::NuFISolver()
NuFISolver::NuFISolver()
: order(Parameters::FE_DEGREE),
poisson(order)
{
std::cout << "Initializing dealii Poisson Solver\n";
poisson.initialize();
}
#endif
+6 -9
View File
@@ -1,13 +1,12 @@
#ifndef SAVE_RESULTS_HPP
#define SAVE_RESULTS_HPP
#include "nufi/save_results.h"
#include "parameters.hpp"
#include "nufi/parameters.h"
#include <fstream>
#include <string>
#include "nufi_solver.hpp"
#include "nufi/nufi_solver.h"
inline void save_ftilda( const NuFISolver &solver,
void save_ftilda( const NuFISolver &solver,
unsigned int n,
const double *E_coeffs,
unsigned int Nx_out,
@@ -51,7 +50,7 @@ inline void save_ftilda( const NuFISolver &solver,
file.close();
}
inline void save_rho(const NuFISolver &solver,
void save_rho(const NuFISolver &solver,
unsigned int n,
const double *E_coeffs,
unsigned int Nx_out,
@@ -75,7 +74,7 @@ inline void save_rho(const NuFISolver &solver,
file.close();
}
inline void save_Efield(unsigned int n,
void save_Efield(unsigned int n,
const double *E_coeffs,
unsigned int Nx_out,
const std::string &filename)
@@ -103,5 +102,3 @@ inline void save_Efield(unsigned int n,
}
file.close();
}
#endif