From c6cd9f9a50f6f826eb1633777f8916b7d5e4da30 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Sat, 25 Jul 2020 21:14:22 +0200 Subject: [PATCH 01/33] Begin of refactor (new class dgMesh) --- CMakeLists.txt | 46 +- geometry/dispersion/dispersion.geo | 2 +- geometry/dispersion/dispersion.msh | 3109 +++++++++++++++++ run/windows/genCBProjectMSYS2.sh | 26 + run/windows/genCBproject.bat | 45 - srcs/CMakeLists.txt | 35 +- srcs/dgMesh/CMakeLists.txt | 28 + srcs/dgMesh/dgMesh.cpp | 348 ++ srcs/dgMesh/dgMesh.hpp | 102 + srcs/dgMesh/dgMesh.inl | 0 srcs/flux/buildFlux.cpp | 118 - srcs/flux/buildFlux.hpp | 20 - srcs/main.cpp | 95 +- srcs/matrices/buildM.cpp | 81 - srcs/matrices/buildM.hpp | 20 - srcs/matrices/buildMatrix.cpp | 29 - srcs/matrices/buildMatrix.hpp | 14 - srcs/matrices/buildS.cpp | 91 - srcs/matrices/buildS.hpp | 28 - srcs/matrices/matrix.hpp | 18 - srcs/mesh/Mesh.cpp | 748 ---- srcs/mesh/Mesh.hpp | 158 - srcs/mesh/displayMesh.cpp | 170 - srcs/mesh/displayMesh.hpp | 12 - srcs/params/Params.cpp | 670 ---- srcs/params/Params.hpp | 80 - srcs/physics/boundaryConditions.hpp | 12 - srcs/physics/commonBC.cpp | 24 - srcs/physics/commonBC.hpp | 23 - srcs/physics/fluxes.hpp | 8 - srcs/physics/ibcFunction.hpp | 24 - .../linShallowWater/boundaryCondition.cpp | 132 - .../linShallowWater/boundaryCondition.hpp | 114 - srcs/physics/linShallowWater/flux.cpp | 50 - srcs/physics/linShallowWater/flux.hpp | 19 - srcs/physics/linShallowWater/phiPsi.cpp | 166 - srcs/physics/linShallowWater/phiPsi.hpp | 45 - srcs/physics/linShallowWater/source.cpp | 13 - srcs/physics/linShallowWater/source.hpp | 17 - srcs/physics/linShallowWater/writer.cpp | 132 - srcs/physics/linShallowWater/writer.hpp | 30 - srcs/physics/meanPhiPsi.cpp | 35 - srcs/physics/meanPhiPsi.hpp | 26 - srcs/physics/phiPsis.hpp | 9 - .../shallowWater/boundaryCondition.cpp | 188 - .../shallowWater/boundaryCondition.hpp | 160 - srcs/physics/shallowWater/flux.cpp | 55 - srcs/physics/shallowWater/flux.hpp | 17 - srcs/physics/shallowWater/phiPsi.cpp | 166 - srcs/physics/shallowWater/phiPsi.hpp | 45 - srcs/physics/shallowWater/source.cpp | 39 - srcs/physics/shallowWater/source.hpp | 27 - srcs/physics/shallowWater/writer.cpp | 134 - srcs/physics/shallowWater/writer.hpp | 30 - srcs/physics/sources.hpp | 7 - srcs/physics/transport/boundaryCondition.cpp | 70 - srcs/physics/transport/boundaryCondition.hpp | 78 - srcs/physics/transport/flux.cpp | 26 - srcs/physics/transport/flux.hpp | 18 - srcs/physics/transport/phiPsi.cpp | 45 - srcs/physics/transport/phiPsi.hpp | 27 - srcs/physics/transport/writer.cpp | 35 - srcs/physics/transport/writer.hpp | 29 - srcs/physics/writers.hpp | 8 - srcs/solver/RungeKutta.cpp | 99 - srcs/solver/RungeKutta.hpp | 76 - srcs/solver/field.hpp | 102 - srcs/solver/timeInteg.cpp | 240 -- srcs/solver/timeInteg.hpp | 22 - srcs/utils/utils.cpp | 36 - srcs/utils/utils.hpp | 12 - srcs/write/write.cpp | 12 - srcs/write/write.hpp | 83 - 73 files changed, 3633 insertions(+), 5225 deletions(-) create mode 100644 geometry/dispersion/dispersion.msh create mode 100644 run/windows/genCBProjectMSYS2.sh delete mode 100644 run/windows/genCBproject.bat create mode 100644 srcs/dgMesh/CMakeLists.txt create mode 100644 srcs/dgMesh/dgMesh.cpp create mode 100644 srcs/dgMesh/dgMesh.hpp create mode 100644 srcs/dgMesh/dgMesh.inl delete mode 100644 srcs/flux/buildFlux.cpp delete mode 100644 srcs/flux/buildFlux.hpp delete mode 100644 srcs/matrices/buildM.cpp delete mode 100644 srcs/matrices/buildM.hpp delete mode 100644 srcs/matrices/buildMatrix.cpp delete mode 100644 srcs/matrices/buildMatrix.hpp delete mode 100644 srcs/matrices/buildS.cpp delete mode 100644 srcs/matrices/buildS.hpp delete mode 100644 srcs/matrices/matrix.hpp delete mode 100644 srcs/mesh/Mesh.cpp delete mode 100644 srcs/mesh/Mesh.hpp delete mode 100644 srcs/mesh/displayMesh.cpp delete mode 100644 srcs/mesh/displayMesh.hpp delete mode 100644 srcs/params/Params.cpp delete mode 100644 srcs/params/Params.hpp delete mode 100644 srcs/physics/boundaryConditions.hpp delete mode 100644 srcs/physics/commonBC.cpp delete mode 100644 srcs/physics/commonBC.hpp delete mode 100644 srcs/physics/fluxes.hpp delete mode 100644 srcs/physics/ibcFunction.hpp delete mode 100644 srcs/physics/linShallowWater/boundaryCondition.cpp delete mode 100644 srcs/physics/linShallowWater/boundaryCondition.hpp delete mode 100644 srcs/physics/linShallowWater/flux.cpp delete mode 100644 srcs/physics/linShallowWater/flux.hpp delete mode 100644 srcs/physics/linShallowWater/phiPsi.cpp delete mode 100644 srcs/physics/linShallowWater/phiPsi.hpp delete mode 100644 srcs/physics/linShallowWater/source.cpp delete mode 100644 srcs/physics/linShallowWater/source.hpp delete mode 100644 srcs/physics/linShallowWater/writer.cpp delete mode 100644 srcs/physics/linShallowWater/writer.hpp delete mode 100644 srcs/physics/meanPhiPsi.cpp delete mode 100644 srcs/physics/meanPhiPsi.hpp delete mode 100644 srcs/physics/phiPsis.hpp delete mode 100644 srcs/physics/shallowWater/boundaryCondition.cpp delete mode 100644 srcs/physics/shallowWater/boundaryCondition.hpp delete mode 100644 srcs/physics/shallowWater/flux.cpp delete mode 100644 srcs/physics/shallowWater/flux.hpp delete mode 100644 srcs/physics/shallowWater/phiPsi.cpp delete mode 100644 srcs/physics/shallowWater/phiPsi.hpp delete mode 100644 srcs/physics/shallowWater/source.cpp delete mode 100644 srcs/physics/shallowWater/source.hpp delete mode 100644 srcs/physics/shallowWater/writer.cpp delete mode 100644 srcs/physics/shallowWater/writer.hpp delete mode 100644 srcs/physics/sources.hpp delete mode 100644 srcs/physics/transport/boundaryCondition.cpp delete mode 100644 srcs/physics/transport/boundaryCondition.hpp delete mode 100644 srcs/physics/transport/flux.cpp delete mode 100644 srcs/physics/transport/flux.hpp delete mode 100644 srcs/physics/transport/phiPsi.cpp delete mode 100644 srcs/physics/transport/phiPsi.hpp delete mode 100644 srcs/physics/transport/writer.cpp delete mode 100644 srcs/physics/transport/writer.hpp delete mode 100644 srcs/physics/writers.hpp delete mode 100644 srcs/solver/RungeKutta.cpp delete mode 100644 srcs/solver/RungeKutta.hpp delete mode 100644 srcs/solver/field.hpp delete mode 100644 srcs/solver/timeInteg.cpp delete mode 100644 srcs/solver/timeInteg.hpp delete mode 100644 srcs/utils/utils.cpp delete mode 100644 srcs/utils/utils.hpp delete mode 100644 srcs/write/write.cpp delete mode 100644 srcs/write/write.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6243a25..59a3f59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,12 +13,9 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/ CACHE PATH "") SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/ CACHE PATH "") MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH) -# enable C++11 -SET(CMAKE_CXX_STANDARD 11) # newer way to set C++11 (requires cmake>3.1) +SET(CMAKE_CXX_STANDARD 17) SET(CMAKE_CXX_STANDARD_REQUIRED ON) -#SET(CMAKE_CXX_FLAGS "-fopenmp") #enable openmp -# compiler options IF(CMAKE_CXX_COMPILER_ID MATCHES MSVC) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS) ADD_DEFINITIONS(-D_USE_MATH_DEFINES) # for M_PI @@ -30,45 +27,16 @@ IF(APPLE) SET(CMAKE_FIND_FRAMEWORK LAST) ENDIF() -# find gmsh-sdk -# gmsh.h -FIND_PATH(GMSH_INCLUDE_DIRS NAMES "gmsh.h") -MESSAGE(STATUS "GMSH_INCLUDE_DIRS=" ${GMSH_INCLUDE_DIRS}) -if(NOT GMSH_INCLUDE_DIRS) - MESSAGE(FATAL_ERROR "gmsh.h not found!") -ENDIF() -INCLUDE_DIRECTORIES(${GMSH_INCLUDE_DIRS}) - -# libgmsh.so -FIND_LIBRARY(GMSH_LIBRARIES gmsh) -MESSAGE(STATUS "GMSH_LIBRARIES=" ${GMSH_LIBRARIES}) -IF(NOT GMSH_LIBRARIES) - MESSAGE(FATAL_ERROR "gmsh library not found!") -ENDIF() - -# gmsh.exe -FIND_PROGRAM(GMSH_EXECUTABLE gmsh) -MESSAGE(STATUS "GMSH_EXECUTABLE=" ${GMSH_EXECUTABLE}) -IF(NOT GMSH_EXECUTABLE) - MESSAGE(FATAL_ERROR "gmsh executable not found!") -ENDIF() - -FIND_PATH(EIGEN_INCLUDE_DIRS NAMES "Eigen") -MESSAGE(STATUS "EIGEN_INCLUDE_DIRS=" ${EIGEN_INCLUDE_DIRS}) -if(NOT EIGEN_INCLUDE_DIRS) - MESSAGE(FATAL_ERROR "eigen not found!") -ENDIF() -INCLUDE_DIRECTORIES(${EIGEN_INCLUDE_DIRS}) - -FIND_PACKAGE(OpenMP) -IF(OPENMP_FOUND) - MESSAGE(STATUS "OpenMP found") +FIND_PACKAGE(OpenMP REQUIRED) +IF(OPENMP_CXX_FOUND) + MESSAGE(STATUS "OpenMP found: " ${OpenMP_CXX_LIBRARIES}) SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") ELSE() - MESSAGE(STATUS "OpenMP not found") + MESSAGE(FATAL_ERROR "OpenMP not found !") ENDIF() -ADD_SUBDIRECTORY( srcs ) +INCLUDE(GenerateExportHeader) +ADD_SUBDIRECTORY(srcs) ENABLE_TESTING() diff --git a/geometry/dispersion/dispersion.geo b/geometry/dispersion/dispersion.geo index 7565f95..fe0a2b9 100644 --- a/geometry/dispersion/dispersion.geo +++ b/geometry/dispersion/dispersion.geo @@ -18,7 +18,7 @@ Line(4) = {1, 2}; Curve Loop(1) = {1, 4, 3, 2}; Plane Surface(1) = {1}; -Physical Surface(1) = {1}; +Physical Surface("Domain") = {1}; // Boundary conditions Physical Curve("BC_Left") = {1}; Physical Curve("BC_Up") = {2}; diff --git a/geometry/dispersion/dispersion.msh b/geometry/dispersion/dispersion.msh new file mode 100644 index 0000000..6b87c87 --- /dev/null +++ b/geometry/dispersion/dispersion.msh @@ -0,0 +1,3109 @@ +$MeshFormat +4.1 0 8 +$EndMeshFormat +$PhysicalNames +5 +1 2 "BC_Left" +1 3 "BC_Up" +1 4 "BC_Down" +1 5 "BC_Right" +2 1 "Domain" +$EndPhysicalNames +$Entities +4 4 1 0 +1 0 0 0 0 +2 2 0 0 0 +3 0 3 0 0 +4 2 3 0 0 +1 0 0 0 0 3 0 1 2 2 3 -1 +2 0 3 0 2 3 0 1 3 2 4 -3 +3 2 0 0 2 3 0 1 5 2 2 -4 +4 0 0 0 2 0 0 1 4 2 1 -2 +1 0 0 0 2 3 0 1 1 4 1 4 3 2 +$EndEntities +$Nodes +9 767 1 767 +0 1 0 1 +1 +0 0 0 +0 2 0 1 +2 +2 0 0 +0 3 0 1 +3 +0 3 0 +0 4 0 1 +4 +2 3 0 +1 1 0 29 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +0 2.900000000001199 0 +0 2.800000000002174 0 +0 2.700000000001933 0 +0 2.600000000002023 0 +0 2.500000000003165 0 +0 2.400000000003 0 +0 2.300000000002719 0 +0 2.200000000002438 0 +0 2.100000000002157 0 +0 2.000000000001934 0 +0 1.900000000002364 0 +0 1.800000000002824 0 +0 1.700000000003284 0 +0 1.600000000003743 0 +0 1.500000000004159 0 +0 1.400000000003922 0 +0 1.300000000003642 0 +0 1.200000000003361 0 +0 1.100000000003082 0 +0 1.000000000002801 0 +0 0.900000000002521 0 +0 0.8000000000022411 0 +0 0.7000000000019608 0 +0 0.600000000001681 0 +0 0.5000000000014007 0 +0 0.4000000000011208 0 +0 0.30000000000084 0 +0 0.2000000000005602 0 +0 0.1000000000002803 0 +1 2 0 19 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +1.899999999999584 3 0 +1.799999999999167 3 0 +1.699999999999306 3 0 +1.6 3 0 +1.500000000000693 3 0 +1.400000000001387 3 0 +1.30000000000208 3 0 +1.200000000002774 3 0 +1.100000000003467 3 0 +1.000000000004117 3 0 +0.9000000000037447 3 0 +0.8000000000033287 3 0 +0.7000000000029127 3 0 +0.6000000000024965 3 0 +0.5000000000020806 3 0 +0.4000000000016644 3 0 +0.3000000000012482 3 0 +0.200000000000832 3 0 +0.100000000000416 3 0 +1 3 0 29 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +2 0.09999999999955492 0 +2 0.1999999999991203 0 +2 0.2999999999987617 0 +2 0.3999999999983593 0 +2 0.4999999999978253 0 +2 0.5999999999974546 0 +2 0.6999999999970983 0 +2 0.799999999996742 0 +2 0.8999999999963859 0 +2 0.9999999999960294 0 +2 1.099999999995673 0 +2 1.199999999995317 0 +2 1.299999999994961 0 +2 1.399999999994604 0 +2 1.499999999994291 0 +2 1.599999999994632 0 +2 1.699999999995016 0 +2 1.799999999995399 0 +2 1.899999999995782 0 +2 1.999999999996166 0 +2 2.099999999996549 0 +2 2.199999999996932 0 +2 2.299999999997316 0 +2 2.3999999999977 0 +2 2.499999999998083 0 +2 2.599999999998466 0 +2 2.69999999999885 0 +2 2.799999999999233 0 +2 2.899999999999617 0 +1 4 0 19 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +0.0999999999997993 0 0 +0.1999999999996293 0 0 +0.2999999999994072 0 0 +0.3999999999991157 0 0 +0.4999999999988242 0 0 +0.5999999999985328 0 0 +0.6999999999982413 0 0 +0.7999999999979498 0 0 +0.8999999999976585 0 0 +0.9999999999973885 0 0 +1.09999999999763 0 0 +1.199999999997894 0 0 +1.299999999998157 0 0 +1.39999999999842 0 0 +1.499999999998683 0 0 +1.599999999998947 0 0 +1.69999999999921 0 0 +1.799999999999474 0 0 +1.899999999999737 0 0 +2 1 0 667 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +0.08567574094381239 1.851605263711261 0 +1.925520303651494 1.051682511745986 0 +1.910205144953765 1.555521709885902 0 +0.08660254037866988 1.250000000003472 0 +1.904665352495766 1.956040719269109 0 +0.9391149484015294 0.08877518819975173 0 +0.950000000003931 2.913397459621677 0 +0.08660254037868623 0.8500000000023811 0 +0.08998443554295418 2.249319200160628 0 +1.917988073714183 2.351862884835471 0 +1.360543519829252 0.08889534756631978 0 +1.350000000002015 2.913397459622785 0 +1.918115767012055 0.6465701583273789 0 +0.5499999999986785 0.08660254037819137 0 +0.6500000000037706 2.913397459621408 0 +0.08850103052617866 1.550889898975647 0 +0.09511981159751383 0.5617683908805766 0 +0.08923577788656019 2.544028731728886 0 +1.649999999999659 2.913397459622368 0 +1.639456480172268 0.08889534756601696 0 +0.3500000000032161 2.913397459621257 0 +1.911120362674342 2.65102663099716 0 +1.91114569792829 0.3490798000974065 0 +0.08490589429531283 0.3513001905164764 0 +1.915489299129562 1.749999999995236 0 +1.908089895041246 2.144154919930564 0 +1.149999999997766 0.08254586071370697 0 +0.08660254037843602 2.050000000002109 0 +1.920564926376219 1.344766374832779 0 +0.08660254037867471 1.050000000002932 0 +1.910012962686141 0.8578039790608067 0 +0.3499999999992615 0.08660254037819143 0 +0.7499999999980955 0.0866025403781914 0 +1.150000000003146 2.913397459622061 0 +0.08962961249596202 2.758672565472106 0 +1.846132486538898 2.915630369559582 0 +0.07910205176954838 0.1434015684221479 0 +1.846132486540039 0.08436963044167972 0 +0.150423736928686 2.915322795494212 0 +0.8500000000037874 2.91339745962163 0 +0.9000000000041277 2.82679491924358 0 +0.8000000000044271 2.826794919243265 0 +0.8500000000046384 2.740192378865423 0 +0.9500000000041268 2.740192378865737 0 +0.9000000000046813 2.653589838487567 0 +1.000000000004241 2.653589838487919 0 +0.9500000000047262 2.5669872981097 0 +1.050000000004329 2.56698729811006 0 +1.000000000004798 2.480384757731783 0 +1.10000000000446 2.480384757732153 0 +1.050000000004927 2.393782217353835 0 +0.9500000000052617 2.393782217353496 0 +1.000000000005399 2.307179676975507 0 +0.9000000000057247 2.307179676975174 0 +0.9500000000058597 2.220577136597147 0 +1.050000000005544 2.220577136597514 0 +1.000000000005967 2.13397459621913 0 +0.9000000000062831 2.133974596218787 0 +0.9500000000064266 2.047372055840711 0 +1.050000000006073 2.04737205584102 0 +1.000000000006553 1.960769515462604 0 +0.900000000006745 1.960769515462218 0 +0.9500000000068809 1.874166975084111 0 +1.050000000006702 1.874166975084467 0 +1.000000000007056 1.787564434706005 0 +0.900000000007259 1.787564434705756 0 +0.9500000000073991 1.700961894327586 0 +1.050000000007221 1.700961894327846 0 +1.000000000007554 1.614359353949418 0 +0.9000000000077168 1.614359353949152 0 +0.9500000000078762 1.527756813570984 0 +1.050000000007709 1.527756813571255 0 +1.000000000008031 1.441154273192821 0 +1.100000000007854 1.441154273193099 0 +1.050000000008168 1.354551732814666 0 +0.9500000000083395 1.354551732814385 0 +1.000000000008492 1.267949192436212 0 +0.9000000000086855 1.267949192435905 0 +0.9500000000088656 1.181346652057716 0 +1.05000000000867 1.181346652058023 0 +1.000000000008992 1.094744111679559 0 +0.9000000000092752 1.094744111679157 0 +0.9500000000093216 1.00814157130109 0 +1.050000000009156 1.008141571301384 0 +1.000000000009488 0.9215390309229352 0 +0.9000000000097726 0.9215390309225935 0 +1.100000000009326 0.9215390309232256 0 +0.8000000000050671 2.653589838487388 0 +1.050000000009758 0.8349364905446022 0 +1.150000000009544 0.8349364905450676 0 +1.20000000000916 0.9215390309235172 0 +1.250000000009331 0.834936490545376 0 +1.200000000009696 0.7483339501669484 0 +1.300000000009502 0.7483339501672357 0 +1.300000000008972 0.9215390309238094 0 +1.250000000009827 0.6617314097887773 0 +1.350000000009687 0.6617314097890732 0 +1.300000000010022 0.5751288694105987 0 +1.200000000010133 0.5751288694102979 0 +1.400000000009898 0.5751288694109096 0 +1.450000000009541 0.6617314097893784 0 +1.500000000009758 0.5751288694112254 0 +1.150000000007541 1.527756813571526 0 +1.200000000007685 1.441154273193358 0 +1.250000000007386 1.527756813571806 0 +1.300000000007532 1.441154273193617 0 +1.350000000007244 1.527756813572088 0 +1.400000000007412 1.441154273193903 0 +1.450000000007119 1.52775681357237 0 +1.400000000006937 1.61435935395058 0 +1.500000000006857 1.614359353950848 0 +1.450000000006644 1.700961894329091 0 +1.350000000007677 1.354551732815434 0 +1.450000000007555 1.354551732815719 0 +0.8500000000080483 1.527756813570718 0 +0.8000000000078797 1.614359353948889 0 +0.7500000000082094 1.527756813570434 0 +0.7000000000080184 1.61435935394861 0 +0.6500000000083443 1.527756813570138 0 +0.6000000000081527 1.614359353948326 0 +0.5500000000084562 1.527756813569857 0 +0.6000000000086503 1.441154273191636 0 +0.5000000000083029 1.614359353948052 0 +0.5500000000079611 1.700961894326472 0 +0.50000000000872 1.441154273191367 0 +0.5500000000089751 1.354551732813075 0 +1.150000000004589 2.393782217354174 0 +1.200000000004127 2.480384757732542 0 +1.250000000004297 2.393782217354516 0 +1.300000000003881 2.48038475773295 0 +1.35000000000407 2.39378221735485 0 +1.400000000003688 2.480384757733344 0 +1.450000000003913 2.39378221735518 0 +1.400000000004276 2.307179676976673 0 +1.500000000003527 2.480384757733698 0 +1.500000000004182 2.307179676976989 0 +1.450000000004506 2.220577136598429 0 +1.450000000010119 0.4885263290327599 0 +1.250000000010339 0.4885263290321034 0 +1.15000000001045 0.4885263290317992 0 +1.550000000007006 1.527756813572602 0 +1.5500000000094 0.6617314097896771 0 +0.4500000000081695 1.700961894326219 0 +0.5000000000078195 1.7875644347046 0 +1.550000000009977 0.4885263290330689 0 +0.4507972087318531 1.355012001483593 0 +0.5001328681297205 1.268025903879623 0 +1.550000000006599 1.700961894329351 0 +1.500000000006372 1.787564434707611 0 +1.550000000004478 2.220577136598742 0 +1.500000000010316 0.4019237886545773 0 +1.400000000007875 1.267949192437286 0 +1.500000000007696 1.267949192437551 0 +1.400000000006433 1.787564434707334 0 +1.250000000003738 2.566987298111013 0 +1.450000000003292 2.566987298111851 0 +1.550000000003129 2.566987298112223 0 +1.600000000006333 1.787564434707897 0 +1.450000000006036 1.874166975085797 0 +1.600023831360189 2.480298410255842 0 +0.4009300768522498 1.441726634585647 0 +0.4056955790370439 1.271844757857141 0 +0.4513245695655558 1.182212596202042 0 +0.5502429062889627 1.181503761321362 0 +0.5002612459822945 1.094914620579476 0 +0.4041758097501699 1.095971324217905 0 +0.450783519014564 1.008349115849537 0 +0.5501741275061715 1.008204580207985 0 +0.5001596077603528 0.9215841231638475 0 +0.4048178251008032 0.9183401964521554 0 +0.4507735009501791 0.8344660983388253 0 +0.550155518125466 0.8348656072156572 0 +0.5001548365198885 0.7482437375754067 0 +0.6000134646532834 0.7483269610659617 0 +0.550028050203003 0.6617152095043906 0 +0.6500069191500915 0.6617275448892503 0 +0.6000058282331826 0.5751255252109673 0 +0.7000005530517008 0.5751285566432129 0 +0.5000056464137669 0.5751256119940225 0 +0.6500010635553451 0.4885257195355904 0 +0.7500002694421923 0.4885261753197278 0 +0.4008412126206802 0.7478441710174804 0 +0.8000001370896791 0.5751287916621967 0 +1.597083004240126 0.4002396603617989 0 +0.400000000008058 1.787564434704338 0 +0.4500000000077124 1.874166975082714 0 +0.5500000000075491 1.874166975082884 0 +0.5000000000074036 1.960769515461071 0 +0.4055252132430041 1.962875950699043 0 +0.4517287003074698 2.047256726686749 0 +0.5502881167238636 2.047352834313992 0 +0.5000000000068244 2.133974596217775 0 +0.4055627475685061 2.130300159539891 0 +0.450927124600243 2.219964730482948 0 +0.5501545207722376 2.220475068910594 0 +0.5001802742328938 2.307060598007814 0 +0.4001845664766084 2.307057762794072 0 +0.4500000000062348 2.393782217352296 0 +0.5500300457105161 2.393762370858114 0 +0.500005007623333 2.480381449981558 0 +0.4000008346090804 2.480384206438884 0 +0.4500009737092126 2.56698665493528 0 +1.500000000009175 0.748333950167822 0 +1.600000000009017 0.7483339501681187 0 +1.550000000008823 0.834936490546242 0 +1.450000000008016 1.181346652059136 0 +1.550000000007827 1.181346652059402 0 +1.600000000007495 1.267949192437803 0 +1.350000000008157 1.181346652058828 0 +0.8500000000055958 2.393782217353173 0 +1.100000000010264 0.5751288694099949 0 +1.350000000006198 1.874166975085555 0 +0.8500000677628607 0.4885262904537669 0 +1.350000000004595 2.220577136598134 0 +1.50000000000284 2.653589838490313 0 +1.600000000002638 2.653589838490754 0 +1.200000000010658 0.4019237886535985 0 +1.100000000010746 0.4019237886531597 0 +0.8000000562087527 0.4019237566035952 0 +1.659101226056925 0.4819593805450709 0 +0.3500000000084067 1.700961894325969 0 +1.650000000006573 1.700961894329605 0 +1.650000000007618 1.181346652059672 0 +0.350000301390505 2.566987099030959 0 +1.650000000008634 0.8349364905465482 0 +0.8000000000060468 2.307179676974862 0 +0.5500009968923923 2.566986639621903 0 +0.500000000005469 2.653589838487063 0 +0.7000033973076448 0.7483321411652202 0 +1.600000000008469 0.9215390309246743 0 +1.300000000006506 1.78756443470705 0 +0.6500000000089018 1.354551732813427 0 +1.400000000004795 2.133974596219881 0 +1.300000000004871 2.133974596219571 0 +0.3000001893377385 2.48038463266872 0 +1.549513834048856 0.3150405602274906 0 +1.641885844094983 0.3176611521098557 0 +1.449918972350339 0.3152744669345504 0 +1.700000000008243 0.9215390309249958 0 +1.704465819879052 1.789637028922678 0 +1.650744303318055 1.87451240745539 0 +1.700000000008802 0.7483339501684427 0 +1.700000000007286 1.267949192438055 0 +1.499905467740523 0.2286641296660034 0 +1.154365893543559 0.31784189808137 0 +1.050623699084391 0.3085947828966927 0 +0.2960060495235249 1.787623114330151 0 +0.2448685217190861 1.703044268479847 0 +1.750000000007385 1.181346652059929 0 +0.6000001661530604 2.653589728739526 0 +0.7500000000058726 2.393782217352908 0 +1.400000000003091 2.653589838489933 0 +1.500000000008148 1.094744111680968 0 +1.500000000008622 0.9215390309243765 0 +1.250000000008809 1.00814157130194 0 +0.7500000000077028 1.700961894326983 0 +0.6500001938445242 2.566987170070044 0 +1.650000000007175 1.354551732816191 0 +1.100000000003973 2.653589838488381 0 +1.200000000007202 1.61435935394999 0 +0.8500000000084875 1.354551732814125 0 +1.250000000006319 1.874166975085254 0 +0.29914475362714 1.614706416306614 0 +1.59997912147023 2.307167622750172 0 +1.64957578692181 2.220332217061588 0 +1.599929297824328 2.13393377629751 0 +1.699496780800617 2.133684062477727 0 +1.698723917435686 2.307222466197974 0 +1.250727648932952 0.3197980362412501 0 +1.200000000004696 2.307179676976127 0 +0.8000000000089723 1.267949192435514 0 +0.9000000341493488 0.5751288500213534 0 +0.8500000285469681 0.6617313935976076 0 +1.450000000002729 2.740192378868254 0 +0.9500000104564916 0.6617314038576791 0 +0.5500000276964081 2.740192360574047 0 +0.4500000046205076 2.740192375816627 0 +1.350000000003026 2.740192378867682 0 +1.750000000006559 1.700961894329853 0 +1.7000000000067 1.614359353951318 0 +1.752137468722482 1.877122937036129 0 +0.252738739818742 2.568568409033757 0 +0.3004565068721862 2.65385332379444 0 +0.9000000065074036 0.7483339464789551 0 +0.7000000000062624 2.307179676974597 0 +0.7500000000064613 2.220577136596535 0 +1.700000000007732 1.094744111681565 0 +1.350000000008627 1.008141571302241 0 +0.8000000000054568 2.480384757731203 0 +1.200000000006665 1.78756443470668 0 +0.650000032311721 2.740192357525301 0 +1.300000000005803 1.960769515463682 0 +1.200000000005962 1.960769515463263 0 +0.5000000053891783 2.826794915686657 0 +0.900000005388996 0.4019237855875276 0 +0.8500000102742893 0.3153212424210755 0 +0.7500000110886584 0.3153212419561134 0 +1.649904346440976 2.047316830231369 0 +1.549985854108372 2.047363888704773 0 +1.749900187877139 2.047314429283722 0 +1.747008467934791 1.356278894663609 0 +1.699501411328198 1.44144213350247 0 +1.389089868417762 0.2265315801368712 0 +1.796065682822972 1.443193908503122 0 +1.200000000011186 0.2287187078968399 0 +0.8000000035687684 0.2327753855314725 0 +0.700000002451302 0.2334514994459487 0 +0.6500000022648357 0.3161100458115444 0 +0.6000000007945412 0.2336956524074373 0 +0.550000000518192 0.3162822052808091 0 +0.5000000002274162 0.2337650378123012 0 +0.4500000001326336 0.3163224627595965 0 +0.5000000000122529 0.4019237886501987 0 +0.4000000000323246 0.4020906577311864 0 +0.3500000000359879 0.3155159288661613 0 +0.2955341801437303 0.401663415487565 0 +0.3492556967039018 0.4885107450146693 0 +0.2500000000126684 0.3153212482709108 0 +0.2500000000120372 0.4885263290278253 0 +0.2998759494603382 0.575126272070835 0 +0.9000000000121124 0.22871870789489 0 +0.3000000000168592 0.2328078343236403 0 +0.2039389243016333 2.653205447274179 0 +0.2536332069593911 2.738497545427942 0 +0.1843981191416838 2.487761977253071 0 +0.2473997180845566 2.395011733095549 0 +0.1588554016236095 2.397200451227663 0 +0.1858807814108985 2.303324057091354 0 +0.2024902647437297 0.2342826251651116 0 +0.1824168498085249 1.605477047364508 0 +0.2532902539909532 1.524171521154471 0 +0.1506730039650063 1.701186981079215 0 +1.813912073051446 1.609624382445061 0 +1.79327773404983 1.095945676266274 0 +1.846030838728037 1.193912390936405 0 +1.450000000011108 0.1421161675190768 0 +0.8500000000124857 0.1421161675164534 0 +0.6500000000128622 0.1421161675157921 0 +0.2500000000133283 0.1421161675139965 0 +0.2000000000116868 0.5751288694061585 0 +0.2499793249194512 0.6617309768955136 0 +0.1520374260791947 0.657549356251713 0 +0.2039346956339166 0.747621744864154 0 +1.799923812979007 2.136563821433263 0 +1.849314926905576 2.049140567562979 0 +1.843628115203236 2.22726796395993 0 +1.557804441566622 0.1487877141669806 0 +0.09592626909476006 0.7464219052618689 0 +0.4000000016714963 2.826794918141974 0 +1.000000002834034 0.7483339485633748 0 +0.6500050076233197 2.393778909603702 0 +0.6500257534675243 2.220560125315381 0 +0.7000042922502244 2.133971761004583 0 +0.750000000003988 2.913397459621477 0 +1.913335320395408 1.650657108679735 0 +1.050000000003533 2.913397459621799 0 +1.100000000003512 2.826794919244118 0 +1.200000000003094 2.826794919244433 0 +1.300000000003465 2.653589838489424 0 +0.08716618957258485 2.149886533361949 0 +0.1732990222892382 2.099981088895316 0 +0.1732207376787668 1.999996848150932 0 +0.2680124397393981 2.04794283360519 0 +0.2571565301747958 2.153194098125951 0 +0.2575956275648125 1.943399446903982 0 +0.2500706228234277 2.913718348933286 0 +0.1849903305443435 2.818320949736173 0 +1.049999999997643 0.08660254037858883 0 +1.110885051600825 0.1713210489134778 0 +1.007934879602966 0.1638748322887283 0 +1.913816544278576 1.848364030473873 0 +1.819003118060341 1.794921362686967 0 +1.550000000002037 2.740192378868572 0 +1.650000000001338 2.740192378868842 0 +1.700000000002377 2.653589838491176 0 +1.750000000001084 2.740192378869203 0 +1.500000000001534 2.826794919245993 0 +1.80251314617894 2.652870711171456 0 +1.750617368350648 2.56666587533195 0 +1.850000000001938 2.740192378870543 0 +1.849999372442296 2.562948169182494 0 +1.798441763203205 2.479784482369233 0 +1.904282505757147 2.46725727217871 0 +1.699832101501031 2.480154635017811 0 +0.102377153345599 2.651789330918509 0 +0.1732050807572075 2.20000000000244 0 +1.251757253303166 0.08225188196754663 0 +1.299999999998051 0.1732050807572216 0 +0.7000000653875238 2.653589795299423 0 +0.6000068752832552 2.48038021631108 0 +0.7000020127946489 2.48038342819634 0 +1.749999999999307 0.08660254037865353 0 +1.799355414422828 0.17283292910097 0 +1.907899360299498 0.1628878944905867 0 +1.849999999999413 0.2598076211355445 0 +1.749999999999517 0.2598076211355467 0 +1.80745411542178 0.3450441166322817 0 +1.854024803522876 0.4419485408733843 0 +1.752146452980727 0.4315490772110969 0 +1.805954899896231 0.5214889174188279 0 +0.3417505152975953 2.209765708224825 0 +0.172591648974137 1.900430335661664 0 +0.09926246554992058 0.2420621264266467 0 +0.6000659336354588 2.307136124945033 0 +1.400000000008785 0.9215390309240995 0 +1.550000000008287 1.00814157130284 0 +1.749355414422574 2.91376961127913 0 +1.747000875066516 1.007257136818633 0 +1.450000000008468 1.008141571302539 0 +1.450000000008976 0.8349364905459589 0 +1.300000000008481 1.094744111680382 0 +1.200000000008654 1.094744111680087 0 +1.250000000008311 1.181346652058519 0 +1.300000000007977 1.267949192436968 0 +1.200000000008123 1.267949192436677 0 +0.6000287101131325 2.133966023835371 0 +0.6500535198514199 2.04736695098602 0 +0.7500096353548131 2.047370732495415 0 +0.7000105258725402 1.960768444095052 0 +0.8000008746950972 1.960769411567866 0 +0.7500019000994897 1.874166779206624 0 +0.6500020710003575 1.874166763875909 0 +0.08589025125109029 0.4514311730613133 0 +0.1844951786897861 0.4016517080607105 0 +0.08634844466252536 1.950338741255044 0 +0.1833839893213601 1.795086433293929 0 +0.6500000000078233 1.700961894326704 0 +1.699999999999209 0.1732050807571612 0 +1.899046073171376 1.44673822892796 0 +1.050000000010711 0.4885263290310483 0 +1.601516871017459 0.5740343779968107 0 +1.697693085887201 0.5768346078533302 0 +1.350000000003526 2.566987298111419 0 +1.200000000003777 2.653589838488862 0 +1.907880451350487 0.5371439452300524 0 +1.000000000003795 2.826794919243818 0 +0.7500003786737449 2.5669870479823 0 +0.0866025403786705 0.950000000002662 0 +0.1732050807573192 1.000000000002799 0 +0.1732050807573248 1.100000000003021 0 +0.2562292460886686 1.051331519529038 0 +0.2598076211359608 1.150000000003094 0 +0.2560486523896847 0.9523240913728666 0 +0.1732050807573195 1.200000000003283 0 +0.2574142581319442 1.244895107483344 0 +0.1706750394478949 0.9036843878486761 0 +0.2528774220891872 0.8441326774222678 0 +0.08660254037867261 1.350000000003735 0 +0.1728061869233333 1.299149184583527 0 +0.2585315849537935 1.355035298773115 0 +0.165453795521089 1.401651128697961 0 +1.650000000009251 0.6617314097899636 0 +1.742935291171311 0.667817709039882 0 +1.798230555952401 0.7496766578363291 0 +1.746918902141865 0.8335516673091501 0 +1.812762938958133 0.9138671510533798 0 +1.789641890304358 1.277499636441829 0 +0.08660254037876142 1.450000000003867 0 +1.350000000006732 1.700961894328814 0 +0.9000000000051812 2.480384757731459 0 +1.600000000007951 1.094744111681276 0 +1.150000000010108 0.6617314097884248 0 +0.6500287300195501 0.8349232103052998 0 +0.7500053545614016 0.8349339756704279 0 +0.700005680770235 0.9215363984029784 0 +0.6000872773652981 0.9215425817658691 0 +0.6500445142785268 1.008152225838735 0 +0.7500083658480046 1.008142908303507 0 +0.7000088133608605 1.094746110268588 0 +1.400000000008322 1.09474411168069 0 +1.500000000007256 1.441154273194147 0 +1.250000000004788 2.220577136597924 0 +1.20000000000509 2.133974596219467 0 +1.40000000000566 1.960769515463951 0 +0.3495975514201882 2.39396670488721 0 +1.250000000006867 1.700961894328482 0 +1.350000000009146 0.8349364905456682 0 +1.250000000007825 1.35455173281517 0 +1.499985858658584 2.133966431710274 0 +0.8500000000075552 1.700961894327275 0 +0.6001219345710809 1.094811325045417 0 +0.6500622757081809 1.181384372260327 0 +0.7500118481843268 1.181353271855964 0 +0.6000730083589738 1.267994449253882 0 +0.08660254037866415 1.150000000003184 0 +1.100000000008831 1.094744111679818 0 +1.6495001458512 1.007994165555664 0 +0.7500018391927847 0.6617303963536705 0 +0.7000002337619764 0.4020551213128343 0 +0.4501716242967172 0.6616315015471324 0 +1.350000000010236 0.4885263290324291 0 +0.341466056793334 1.884845706614773 0 +1.914503953602161 0.954164506943851 0 +1.150000000008989 1.008141571301659 0 +0.9500000015634315 0.8349364896627884 0 +1.400000000009338 0.7483339501675227 0 +0.9000000000082037 1.441154273192547 0 +1.550124050557884 1.874224547147497 0 +1.100000000007374 1.614359353949687 0 +1.550000000007375 1.354551732815956 0 +1.899888267541574 0.751250941235637 0 +0.4000000000732363 0.2344972794636854 0 +0.4500000000132666 0.1421161675150014 0 +0.8000004610191707 0.7483337177450116 0 +0.7000000000085365 1.441154273191956 0 +1.600000000006762 1.614359353951091 0 +0.8500017516793257 2.047371817967252 0 +0.4501550128158456 1.527852207135379 0 +1.300000000007061 1.614359353950293 0 +0.8500000000061692 2.220577136596834 0 +0.8500000631164762 2.566987256421602 0 +1.100000000008313 1.267949192436497 0 +0.3998832944127818 1.61443309660196 0 +0.8000026132172128 2.133973863479901 0 +1.150000000004068 2.566987298110502 0 +0.4000762977672455 2.653633611821488 0 +1.300121274830901 0.4026699199815705 0 +1.100000000005046 2.307179676975851 0 +1.150000000008484 1.18134665205827 0 +1.650078883536668 2.566880982616626 0 +0.6000000564144379 0.4020053726135882 0 +1.150000000007984 1.354551732814926 0 +1.599916901893974 1.441202249912365 0 +1.100000000006236 1.960769515462893 0 +1.600000000010819 0.2287187078980621 0 +1.549979613607044 2.393753762844137 0 +0.800000000008379 1.441154273192274 0 +1.649903052208209 1.527812786410476 0 +1.150000000007026 1.700961894328137 0 +1.300000000004454 2.307179676976371 0 +0.5500020991068219 0.4885387245054492 0 +0.2960724957393757 2.307491296715402 0 +1.40000670787044 0.4020403469852724 0 +1.100000000006862 1.787564434706335 0 +1.050000000003891 2.740192378866139 0 +1.150000000006457 1.874166975084815 0 +0.6000003451731837 1.787564399503595 0 +1.750000000006617 1.527756813573008 0 +0.7500000000087299 1.354551732813796 0 +1.348310745402237 0.3198955226942587 0 +0.350567231951371 1.527376072774453 0 +0.4498772403801124 0.4885530662170242 0 +0.8500004624704741 1.874166925121977 0 +1.250000000002515 2.913397459622407 0 +0.6000590389105223 1.960765247302488 0 +0.8000003937666788 1.78756439373227 0 +0.7000007850092059 1.787564354162014 0 +1.10000000048064 0.7483339498993686 0 +0.8500009706119016 0.8349360319003105 0 +0.3998643595443658 0.5751131011047597 0 +0.8500013943160371 1.008141794134501 0 +0.7500000162865131 2.740192368110559 0 +1.150000000005111 2.220577136597749 0 +0.3506943363160967 2.739961115707358 0 +0.9457380589301115 0.316720819031471 0 +0.301958598915871 0.7492699000735913 0 +0.7000000000091028 1.267949192435481 0 +0.9500000178889603 0.4885263188592 0 +0.3500000000113583 0.6617314097848751 0 +0.8500019747049572 1.181347755357137 0 +1.100000000005549 2.133974596219415 0 +1.15000000000367 2.740192378866567 0 +0.8000053994039101 1.094745991933142 0 +1.150000000005665 2.047372055841247 0 +1.250000000003168 2.740192378867022 0 +0.8000009443240567 0.9215388553789885 0 +1.250000000005271 2.047372055841642 0 +1.350000000005138 2.047372055841961 0 +1.450000000005027 2.047372055842309 0 +1.05000000230043 0.6617314084880257 0 +0.9995668787309328 0.4012896329552809 0 +1.000000010802701 0.5751288632778835 0 +1.400000000002376 2.826794919245633 0 +1.500018317448049 1.960777749618098 0 +1.600129478646459 1.960827489770284 0 +1.700469297501771 1.961310601540292 0 +1.798739488051035 1.962512119714086 0 +1.300000000002699 2.826794919244993 0 +0.7000000081025344 2.826794913894142 0 +0.6000000087522401 2.82679491346502 0 +0.4500000011785588 2.913397458845279 0 +0.5500000009333833 2.913397459007578 0 +1.450000000001392 2.913397459623027 0 +0.2982314163863285 2.825115056261332 0 +1.550000000000525 2.913397459622915 0 +1.600000000000455 2.826794919245923 0 +1.699892569070748 2.82685694452198 0 +1.799230078338026 2.827239433724528 0 +1.907881455145069 2.837122443056483 0 +1.649874728800224 2.393709891992943 0 +0.3072122569659845 1.443557526823987 0 +1.746879491369121 2.394917585160068 0 +0.3452459848627192 1.004420022709314 0 +0.3465492895498234 1.190246341512674 0 +1.74763700847575 2.220809812143999 0 +1.926569158449572 1.248212458401383 0 +0.3541189382206327 0.8325584204572573 0 +1.790295133200368 2.307593974894326 0 +0.3582513135580188 1.358996137390946 0 +0.3643223647037129 2.046570653838644 0 +0.08324999266557842 2.850874057689268 0 +0.1595874031458186 0.08258935465233344 0 +0.0845596095017131 2.448247465690702 0 +0.1630087787907281 1.500000000004441 0 +0.08201367923789848 1.644073597710844 0 +0.0817140309628798 1.75677525426138 0 +1.842347962128663 1.701232949627371 0 +1.837784613811911 2.387561537529188 0 +0.08338864138261259 2.344320390501803 0 +1.844000782213305 1.021896442251685 0 +0.2502086744354337 1.862277007360899 0 +0.1626159899666257 0.4956117412121357 0 +0.1630252042572436 0.3078011430937277 0 +1.927140941417694 2.250846925540137 0 +1.84837395587456 0.5953750714470114 0 +0.2508130806759746 2.234755032031995 0 +1.930057958018202 1.149999999995494 0 +1.833845794801235 1.51656700866701 0 +1.837180194459306 1.886749728052105 0 +0.1665377428988436 2.581070779241681 0 +1.833562725456023 0.8212300792990606 0 +0.06766888983331984 0.6511472049864198 0 +1.933219987854036 0.2511336586695458 0 +1.933012701893802 2.749999999999041 0 +1.933310313034786 2.049999999996357 0 +0.1669138455293858 2.724097167765782 0 +1.677394777662296 0.3923040457429132 0 +1.832050807573677 1.364914703899633 0 +1.934610190560331 0.4456344572394055 0 +1.933080448174757 2.556246414470983 0 +0.1618409111018992 0.8194151770278081 0 +1.53287682029103 0.0736769486069902 0 +1.448684068025699 0.06093769273847735 0 +1.051417174218732 0.232124843571676 0 +1.297625652552437 0.2536297855452883 0 +1.202528460982199 0.1476085160497586 0 +0.8499999999978043 0.06226246238849065 0 +0.7500000012087028 0.1674123520775716 0 +0.6499999999983869 0.06226246238811901 0 +0.5500000002093529 0.1676591131257447 0 +0.4499999999989699 0.06226246238767476 0 +0.3500000000231904 0.167627997838903 0 +0.2519174806314889 0.06226161250890427 0 +1.829647794731769 0.6671569873612132 0 +0.3210860144209016 1.100000000002998 0 +0.1601528389699378 0.1656786511079376 0 +0.3233311753735667 0.9061157821524415 0 +0.07320508075746701 2.926794919242966 0 +1.926794919242799 0.0732050807570114 0 +1.926794919242822 2.926794919242833 0 +0.07140530914160918 0.07074420273602094 0 +0.2294993340445096 1.444883095090795 0 +0.3263411748071883 1.286800604822196 0 +0.3268007965096965 2.114841715457772 0 +1.374908347064043 0.1576870439948723 0 +1.117097505838907 0.2494694992612767 0 +1.676195361199277 0.2446837222954793 0 +1.628406912477408 0.1629689715409296 0 +0.9265030599259929 0.1614636800005941 0 +0.9771540468809841 0.2394584252113942 0 +1.724198172094746 0.331279005291982 0 +1.731057938016656 0.5071485297683629 0 +0.3283042908542037 1.976206537043223 0 +1.775943827596288 0.5893036371481045 0 +1.870938887951701 1.10846167068199 0 +1.865901179534406 2.296235526258708 0 +1.862971524286372 1.285861112902406 0 +$EndNodes +$Elements +5 1532 1 1532 +1 1 1 30 +1 3 5 +2 5 6 +3 6 7 +4 7 8 +5 8 9 +6 9 10 +7 10 11 +8 11 12 +9 12 13 +10 13 14 +11 14 15 +12 15 16 +13 16 17 +14 17 18 +15 18 19 +16 19 20 +17 20 21 +18 21 22 +19 22 23 +20 23 24 +21 24 25 +22 25 26 +23 26 27 +24 27 28 +25 28 29 +26 29 30 +27 30 31 +28 31 32 +29 32 33 +30 33 1 +1 2 1 20 +31 4 34 +32 34 35 +33 35 36 +34 36 37 +35 37 38 +36 38 39 +37 39 40 +38 40 41 +39 41 42 +40 42 43 +41 43 44 +42 44 45 +43 45 46 +44 46 47 +45 47 48 +46 48 49 +47 49 50 +48 50 51 +49 51 52 +50 52 3 +1 3 1 30 +51 2 53 +52 53 54 +53 54 55 +54 55 56 +55 56 57 +56 57 58 +57 58 59 +58 59 60 +59 60 61 +60 61 62 +61 62 63 +62 63 64 +63 64 65 +64 65 66 +65 66 67 +66 67 68 +67 68 69 +68 69 70 +69 70 71 +70 71 72 +71 72 73 +72 73 74 +73 74 75 +74 75 76 +75 76 77 +76 77 78 +77 78 79 +78 79 80 +79 80 81 +80 81 4 +1 4 1 20 +81 1 82 +82 82 83 +83 83 84 +84 84 85 +85 85 86 +86 86 87 +87 87 88 +88 88 89 +89 89 90 +90 90 91 +91 91 92 +92 92 93 +93 93 94 +94 94 95 +95 95 96 +96 96 97 +97 97 98 +98 98 99 +99 99 100 +100 100 2 +2 1 2 1432 +101 135 467 701 +102 556 131 593 +103 348 347 526 +104 340 379 472 +105 110 76 483 +106 467 135 726 +107 425 118 703 +108 433 103 455 +109 116 430 705 +110 430 116 704 +111 117 440 442 +112 500 498 535 +113 109 428 709 +114 416 419 524 +115 131 556 721 +116 418 416 524 +117 118 425 720 +118 428 109 486 +119 381 340 472 +120 103 433 718 +121 126 444 445 +122 535 498 729 +123 76 77 483 +124 432 348 526 +125 117 442 722 +126 80 81 689 +127 53 54 494 +128 526 347 711 +129 447 436 732 +130 732 436 733 +131 105 445 677 +132 110 483 708 +133 547 443 656 +134 472 379 707 +135 429 503 746 +136 428 427 709 +137 478 122 480 +138 495 123 497 +139 26 27 448 +140 17 705 706 +141 703 10 709 +142 444 126 446 +143 689 81 750 +144 53 494 749 +145 529 404 728 +146 430 432 705 +147 497 123 498 +148 122 478 481 +149 427 425 703 +150 431 430 704 +151 467 139 701 +152 126 445 725 +153 485 423 726 +154 503 137 746 +155 108 26 448 +156 545 542 694 +157 554 601 721 +158 433 455 707 +159 592 465 711 +160 443 547 731 +161 423 485 720 +162 557 435 767 +163 705 432 706 +164 427 703 709 +165 435 696 767 +166 129 529 728 +167 439 702 743 +168 524 419 712 +169 465 592 763 +170 445 105 725 +171 404 529 718 +172 499 320 727 +173 501 464 754 +174 541 543 693 +175 478 479 481 +176 545 694 753 +177 556 593 710 +178 464 501 716 +179 547 656 697 +180 440 117 712 +181 105 677 719 +182 503 429 713 +183 481 479 482 +184 405 469 736 +185 133 437 738 +186 437 133 737 +187 114 438 740 +188 438 114 739 +189 436 111 733 +190 488 403 735 +191 132 603 742 +192 603 132 741 +193 120 447 732 +194 488 405 736 +195 405 488 735 +196 106 437 737 +197 438 133 738 +198 133 438 739 +199 603 114 740 +200 114 603 741 +201 439 132 742 +202 132 439 743 +203 702 439 746 +204 497 498 499 +205 135 485 726 +206 448 27 722 +207 601 554 744 +208 418 524 713 +209 320 499 762 +210 444 446 695 +211 482 479 484 +212 481 482 483 +213 499 498 500 +214 480 122 724 +215 123 495 723 +216 260 484 620 +217 484 479 620 +218 469 405 756 +219 403 488 755 +220 437 106 759 +221 484 260 690 +222 466 467 684 +223 467 424 684 +224 49 121 681 +225 121 449 681 +226 121 466 684 +227 604 384 649 +228 384 450 595 +229 450 189 595 +230 140 45 454 +231 384 595 649 +232 142 140 454 +233 378 673 678 +234 299 451 490 +235 489 357 537 +236 188 489 537 +237 679 115 680 +238 43 44 107 +239 295 452 504 +240 452 295 516 +241 582 583 657 +242 372 658 672 +243 295 292 516 +244 452 385 504 +245 19 20 558 +246 351 389 491 +247 35 36 507 +248 43 107 456 +249 451 299 504 +250 564 604 649 +251 583 371 657 +252 291 288 645 +253 490 451 491 +254 318 530 671 +255 453 517 518 +256 454 115 679 +257 91 92 468 +258 134 42 456 +259 106 91 468 +260 36 119 507 +261 292 291 516 +262 103 68 455 +263 565 564 666 +264 460 461 486 +265 255 459 534 +266 385 451 504 +267 42 43 456 +268 461 464 486 +269 107 140 141 +270 6 7 135 +271 459 255 533 +272 357 491 537 +273 468 469 470 +274 534 359 615 +275 451 351 491 +276 518 607 614 +277 67 68 103 +278 163 162 643 +279 189 450 648 +280 518 520 607 +281 226 247 584 +282 549 550 551 +283 34 35 136 +284 453 516 517 +285 460 128 461 +286 121 50 466 +287 457 456 536 +288 116 19 558 +289 544 545 549 +290 13 14 128 +291 520 162 607 +292 453 518 614 +293 125 70 471 +294 491 389 537 +295 46 115 454 +296 69 125 455 +297 492 138 493 +298 125 471 472 +299 104 544 549 +300 537 389 611 +301 106 468 470 +302 13 128 460 +303 107 44 140 +304 549 545 550 +305 255 230 533 +306 493 138 494 +307 101 502 525 +308 7 8 485 +309 144 146 635 +310 391 489 652 +311 662 534 665 +312 99 138 492 +313 92 127 468 +314 48 49 681 +315 255 534 615 +316 487 111 488 +317 572 314 630 +318 506 353 509 +319 517 291 645 +320 162 520 643 +321 350 357 489 +322 107 141 536 +323 466 139 467 +324 492 493 528 +325 14 15 525 +326 635 359 662 +327 134 456 457 +328 66 67 529 +329 493 496 528 +330 508 339 556 +331 332 226 584 +332 188 537 611 +333 300 299 490 +334 67 103 529 +335 230 232 533 +336 68 69 455 +337 15 101 525 +338 330 339 587 +339 94 111 487 +340 457 536 635 +341 353 506 561 +342 493 494 495 +343 468 127 469 +344 32 137 503 +345 136 35 507 +346 44 45 140 +347 213 206 578 +348 301 335 575 +349 46 47 115 +350 461 128 462 +351 489 188 652 +352 299 296 504 +353 339 508 587 +354 92 93 127 +355 109 12 460 +356 69 70 125 +357 12 13 460 +358 357 490 491 +359 247 264 584 +360 45 46 454 +361 567 569 581 +362 505 354 509 +363 264 581 582 +364 391 350 489 +365 109 460 486 +366 49 50 121 +367 128 14 525 +368 51 139 466 +369 301 324 335 +370 268 567 581 +371 335 324 382 +372 264 582 584 +373 354 506 509 +374 673 112 678 +375 514 213 578 +376 502 101 526 +377 523 124 524 +378 536 144 635 +379 370 572 630 +380 296 295 504 +381 544 104 585 +382 256 315 352 +383 127 93 487 +384 8 118 485 +385 342 553 554 +386 99 100 138 +387 178 371 660 +388 350 327 357 +389 352 315 374 +390 354 505 510 +391 78 79 122 +392 252 213 514 +393 71 105 471 +394 371 583 660 +395 612 180 619 +396 294 292 295 +397 516 291 517 +398 303 305 510 +399 148 150 615 +400 30 124 523 +401 141 144 536 +402 352 374 378 +403 569 568 663 +404 342 552 553 +405 327 300 490 +406 511 309 513 +407 129 66 529 +408 304 242 552 +409 518 517 519 +410 502 462 525 +411 309 511 570 +412 548 549 551 +413 465 462 502 +414 120 98 492 +415 374 473 477 +416 559 576 609 +417 206 204 578 +418 303 510 596 +419 543 539 546 +420 51 52 139 +421 293 292 294 +422 509 353 570 +423 357 327 490 +424 32 33 137 +425 218 356 527 +426 50 51 466 +427 294 295 296 +428 70 71 471 +429 305 354 510 +430 581 569 582 +431 511 388 570 +432 543 546 547 +433 456 107 536 +434 342 304 552 +435 548 104 549 +436 575 426 632 +437 248 211 606 +438 496 495 497 +439 359 534 662 +440 506 330 587 +441 256 257 315 +442 124 31 503 +443 242 202 531 +444 539 538 546 +445 242 531 552 +446 637 527 647 +447 576 360 609 +448 201 303 596 +449 538 108 546 +450 339 555 556 +451 339 325 555 +452 152 149 560 +453 20 548 558 +454 461 462 463 +455 288 287 645 +456 561 506 587 +457 98 99 492 +458 149 147 560 +459 309 252 514 +460 335 382 425 +461 120 492 528 +462 359 148 615 +463 268 566 567 +464 315 316 473 +465 433 380 638 +466 232 256 533 +467 294 297 501 +468 430 348 432 +469 411 602 603 +470 351 310 389 +471 463 462 465 +472 564 329 604 +473 513 309 514 +474 388 509 570 +475 335 426 575 +476 11 12 109 +477 658 530 672 +478 211 241 606 +479 21 104 548 +480 104 22 585 +481 20 21 548 +482 25 108 538 +483 268 269 566 +484 117 29 523 +485 141 143 144 +486 228 230 255 +487 202 245 531 +488 389 560 611 +489 141 142 143 +490 612 515 622 +491 399 366 579 +492 352 459 533 +493 97 98 120 +494 220 218 527 +495 422 429 439 +496 31 32 503 +497 540 539 541 +498 243 244 285 +499 473 316 474 +500 130 538 539 +501 398 366 399 +502 75 76 110 +503 30 31 124 +504 73 74 126 +505 245 284 320 +506 199 196 562 +507 310 152 560 +508 71 72 105 +509 301 302 324 +510 28 29 117 +511 582 569 583 +512 563 329 564 +513 352 378 459 +514 515 612 619 +515 379 322 380 +516 515 578 622 +517 223 220 224 +518 541 539 543 +519 584 582 657 +520 411 412 602 +521 342 554 555 +522 272 273 274 +523 540 541 542 +524 274 329 563 +525 274 273 275 +526 210 212 559 +527 130 540 585 +528 223 224 243 +529 166 163 643 +530 232 235 256 +531 196 193 562 +532 389 310 560 +533 329 276 588 +534 243 224 244 +535 321 285 347 +536 197 200 201 +537 349 435 557 +538 130 539 540 +539 245 320 531 +540 325 342 555 +541 274 275 276 +542 276 275 277 +543 201 202 242 +544 552 532 553 +545 531 320 532 +546 374 315 473 +547 93 94 487 +548 303 242 304 +549 278 277 280 +550 540 544 585 +551 201 200 202 +552 293 294 501 +553 298 301 575 +554 379 380 433 +555 349 434 435 +556 240 199 311 +557 221 223 608 +558 269 271 272 +559 307 353 561 +560 276 277 278 +561 272 271 273 +562 240 311 530 +563 256 352 533 +564 130 24 538 +565 29 30 523 +566 94 95 111 +567 349 387 434 +568 396 397 406 +569 567 565 568 +570 278 280 281 +571 298 296 299 +572 253 306 307 +573 421 406 437 +574 218 216 356 +575 237 234 314 +576 265 268 581 +577 25 26 108 +578 208 214 571 +579 326 310 351 +580 315 257 316 +581 531 532 552 +582 239 199 240 +583 333 314 334 +584 407 409 438 +585 212 254 559 +586 272 274 563 +587 395 319 396 +588 576 390 629 +589 396 319 397 +590 544 542 545 +591 331 362 390 +592 362 392 393 +593 57 58 535 +594 265 267 268 +595 322 248 606 +596 208 206 213 +597 221 220 223 +598 353 306 570 +599 274 276 329 +600 345 318 346 +601 201 242 303 +602 334 572 573 +603 415 418 422 +604 330 325 339 +605 518 519 520 +606 349 323 387 +607 150 228 615 +608 254 312 331 +609 210 559 609 +610 253 252 306 +611 385 351 451 +612 23 24 130 +613 313 281 319 +614 290 291 292 +615 331 312 362 +616 325 304 342 +617 334 314 572 +618 191 192 195 +619 406 397 407 +620 214 252 253 +621 195 192 577 +622 308 307 323 +623 559 331 576 +624 343 323 349 +625 566 565 567 +626 264 265 581 +627 305 304 325 +628 170 167 580 +629 283 281 313 +630 396 406 421 +631 493 495 496 +632 219 218 220 +633 306 309 570 +634 397 319 589 +635 298 300 301 +636 586 184 594 +637 434 387 508 +638 510 505 577 +639 254 331 559 +640 573 572 653 +641 314 234 630 +642 548 551 558 +643 247 263 264 +644 164 634 636 +645 187 190 191 +646 192 194 577 +647 362 393 636 +648 177 179 180 +649 303 304 305 +650 278 281 283 +651 181 183 184 +652 24 25 538 +653 21 22 104 +654 268 267 269 +655 512 586 594 +656 184 185 187 +657 621 280 631 +658 154 152 310 +659 313 319 395 +660 167 166 580 +661 505 195 577 +662 197 201 596 +663 191 190 192 +664 214 213 252 +665 408 397 589 +666 254 259 312 +667 331 390 576 +668 216 170 580 +669 269 272 566 +670 161 159 162 +671 563 565 566 +672 208 213 214 +673 384 375 450 +674 307 306 353 +675 145 143 188 +676 388 195 505 +677 510 577 596 +678 567 568 569 +679 281 280 589 +680 224 220 527 +681 323 307 561 +682 180 179 181 +683 180 181 586 +684 513 514 515 +685 184 183 185 +686 217 216 218 +687 343 349 557 +688 577 194 596 +689 305 325 330 +690 212 249 254 +691 362 312 392 +692 253 307 308 +693 157 155 158 +694 283 313 372 +695 237 314 333 +696 311 199 562 +697 563 564 565 +698 388 505 509 +699 347 285 592 +700 328 327 350 +701 146 359 635 +702 412 415 602 +703 376 350 391 +704 318 240 530 +705 191 195 355 +706 243 285 321 +707 202 238 245 +708 172 171 173 +709 207 206 208 +710 209 208 571 +711 172 173 174 +712 407 408 409 +713 169 171 172 +714 237 333 579 +715 355 195 388 +716 294 296 297 +717 181 184 586 +718 306 252 309 +719 154 310 326 +720 187 189 190 +721 215 170 216 +722 22 23 585 +723 308 323 343 +724 23 130 585 +725 168 167 169 +726 241 209 571 +727 192 193 194 +728 356 216 580 +729 134 457 458 +730 317 240 318 +731 415 422 602 +732 169 170 171 +733 254 249 259 +734 354 330 506 +735 269 270 271 +736 629 390 634 +737 272 563 566 +738 373 375 384 +739 241 623 628 +740 515 514 578 +741 373 372 375 +742 165 167 168 +743 264 263 265 +744 177 180 612 +745 305 330 354 +746 169 167 170 +747 571 214 600 +748 290 288 291 +749 329 588 604 +750 187 185 189 +751 337 336 625 +752 326 351 385 +753 165 166 167 +754 174 173 175 +755 184 187 594 +756 205 204 206 +757 222 226 332 +758 319 281 589 +759 191 355 594 +760 181 182 183 +761 387 323 561 +762 187 191 594 +763 211 209 241 +764 253 308 600 +765 141 140 142 +766 219 222 605 +767 165 163 166 +768 177 178 179 +769 407 397 408 +770 197 198 200 +771 520 519 521 +772 283 372 373 +773 321 347 348 +774 355 512 594 +775 355 388 511 +776 540 542 544 +777 277 275 279 +778 367 366 398 +779 192 190 193 +780 462 128 525 +781 55 56 123 +782 256 235 257 +783 508 387 587 +784 512 511 513 +785 168 169 599 +786 203 174 204 +787 312 259 574 +788 409 410 411 +789 198 196 199 +790 245 251 284 +791 401 343 557 +792 180 586 619 +793 239 240 317 +794 172 174 203 +795 171 170 215 +796 340 322 379 +797 355 511 512 +798 169 172 599 +799 273 271 282 +800 276 278 588 +801 521 519 522 +802 214 253 600 +803 175 176 177 +804 161 162 163 +805 90 91 106 +806 62 63 102 +807 246 225 261 +808 217 219 605 +809 283 373 588 +810 207 208 209 +811 278 283 588 +812 380 322 606 +813 426 428 632 +814 387 561 587 +815 422 418 429 +816 265 266 267 +817 284 336 337 +818 461 463 464 +819 150 149 151 +820 181 179 182 +821 173 171 597 +822 392 312 574 +823 207 209 210 +824 185 183 186 +825 522 287 637 +826 522 637 647 +827 203 205 360 +828 194 197 596 +829 308 358 600 +830 15 16 101 +831 222 332 605 +832 358 343 401 +833 286 288 289 +834 151 149 152 +835 386 385 452 +836 373 384 604 +837 61 62 593 +838 194 196 197 +839 269 267 270 +840 202 200 238 +841 212 248 249 +842 285 244 286 +843 409 408 410 +844 228 229 230 +845 205 206 207 +846 365 250 366 +847 146 148 359 +848 210 209 211 +849 144 143 145 +850 189 185 595 +851 258 248 322 +852 171 215 597 +853 289 288 290 +854 210 211 212 +855 215 216 217 +856 607 158 614 +857 178 176 361 +858 175 173 176 +859 160 159 161 +860 203 204 205 +861 608 223 613 +862 164 163 165 +863 162 159 607 +864 172 203 599 +865 275 273 590 +866 198 199 239 +867 290 292 293 +868 534 459 665 +869 200 198 591 +870 177 176 178 +871 243 321 613 +872 247 262 263 +873 157 158 159 +874 273 282 590 +875 225 221 608 +876 158 155 610 +877 360 205 609 +878 308 343 358 +879 236 234 237 +880 60 61 131 +881 217 218 219 +882 178 361 371 +883 366 250 579 +884 442 441 443 +885 219 220 221 +886 413 621 631 +887 86 87 114 +888 402 401 404 +889 88 89 133 +890 578 204 622 +891 301 300 302 +892 241 571 623 +893 250 237 579 +894 154 326 610 +895 326 386 610 +896 223 243 613 +897 302 300 327 +898 203 360 599 +899 286 287 288 +900 440 420 441 +901 185 186 595 +902 317 318 345 +903 159 158 607 +904 145 188 611 +905 369 345 405 +906 326 385 386 +907 194 193 196 +908 380 606 628 +909 259 249 598 +910 59 60 601 +911 261 225 608 +912 228 255 615 +913 204 174 622 +914 207 210 609 +915 419 417 420 +916 265 263 266 +917 588 373 604 +918 62 102 593 +919 156 155 157 +920 212 211 248 +921 317 345 369 +922 358 401 402 +923 58 59 113 +924 226 246 247 +925 176 173 597 +926 198 239 591 +927 175 177 612 +928 148 147 149 +929 586 512 619 +930 222 225 226 +931 205 207 609 +932 217 605 627 +933 161 163 164 +934 286 244 287 +935 386 452 453 +936 258 340 341 +937 219 221 222 +938 153 154 155 +939 297 296 298 +940 222 221 225 +941 361 176 597 +942 453 452 516 +943 157 159 160 +944 589 280 621 +945 382 324 383 +946 416 414 417 +947 512 513 619 +948 286 289 592 +949 258 322 340 +950 279 275 590 +951 153 152 154 +952 131 61 593 +953 298 299 300 +954 442 443 448 +955 285 286 592 +956 365 366 367 +957 367 398 400 +958 197 196 198 +959 344 436 447 +960 236 237 250 +961 513 515 619 +962 153 155 156 +963 591 239 617 +964 238 200 591 +965 161 164 624 +966 249 248 258 +967 440 441 442 +968 230 231 232 +969 419 420 440 +970 150 227 228 +971 146 145 147 +972 144 145 146 +973 247 246 262 +974 363 348 430 +975 41 42 134 +976 164 165 634 +977 634 390 636 +978 580 166 646 +979 393 624 636 +980 84 85 132 +981 151 152 153 +982 479 475 620 +983 564 649 666 +984 336 344 625 +985 148 149 150 +986 258 341 598 +987 623 402 628 +988 412 414 415 +989 321 363 613 +990 411 410 412 +991 317 369 617 +992 412 410 413 +993 245 238 251 +994 236 250 364 +995 155 154 610 +996 226 225 246 +997 239 317 617 +998 175 612 622 +999 277 279 631 +1000 297 298 575 +1001 233 231 234 +1002 302 327 328 +1003 416 417 419 +1004 60 131 601 +1005 475 316 620 +1006 232 233 235 +1007 321 348 363 +1008 415 416 418 +1009 501 297 632 +1010 229 227 370 +1011 341 340 381 +1012 344 338 403 +1013 228 227 229 +1014 249 258 598 +1015 364 250 365 +1016 174 175 622 +1017 412 413 414 +1018 160 161 624 +1019 364 365 368 +1020 233 234 236 +1021 39 40 112 +1022 158 610 614 +1023 415 414 416 +1024 560 147 611 +1025 146 147 148 +1026 58 113 535 +1027 610 386 614 +1028 150 151 227 +1029 284 251 336 +1030 367 400 444 +1031 147 145 611 +1032 363 430 431 +1033 113 59 601 +1034 230 229 231 +1035 287 522 645 +1036 344 403 436 +1037 573 653 661 +1038 257 235 260 +1039 360 576 629 +1040 408 589 621 +1041 287 244 637 +1042 444 400 445 +1043 386 453 614 +1044 571 600 623 +1045 224 527 637 +1046 151 153 618 +1047 336 338 344 +1048 382 383 423 +1049 633 617 640 +1050 215 217 627 +1051 600 358 623 +1052 316 257 620 +1053 377 394 449 +1054 280 277 631 +1055 336 251 338 +1056 168 599 629 +1057 627 605 639 +1058 591 617 633 +1059 661 160 664 +1060 377 449 654 +1061 457 635 662 +1062 65 66 129 +1063 478 475 479 +1064 232 231 233 +1065 413 410 621 +1066 390 362 636 +1067 402 404 638 +1068 297 575 632 +1069 358 402 623 +1070 474 316 475 +1071 410 408 621 +1072 599 360 629 +1073 606 241 628 +1074 458 662 665 +1075 474 475 476 +1076 328 350 376 +1077 324 302 616 +1078 335 425 426 +1079 165 168 634 +1080 344 447 625 +1081 8 9 118 +1082 168 629 634 +1083 597 215 627 +1084 188 143 652 +1085 236 364 626 +1086 530 658 671 +1087 328 377 616 +1088 227 151 618 +1089 153 156 618 +1090 380 628 638 +1091 527 356 647 +1092 235 233 626 +1093 190 189 648 +1094 624 164 636 +1095 260 235 626 +1096 361 627 639 +1097 36 37 119 +1098 328 376 377 +1099 562 193 648 +1100 476 478 480 +1101 361 597 627 +1102 233 236 626 +1103 628 402 638 +1104 257 260 620 +1105 234 231 630 +1106 476 475 478 +1107 656 441 659 +1108 370 227 618 +1109 183 182 651 +1110 229 370 630 +1111 244 224 637 +1112 135 7 485 +1113 238 591 633 +1114 377 376 394 +1115 261 608 641 +1116 414 413 642 +1117 522 519 645 +1118 395 396 655 +1119 302 328 616 +1120 371 361 639 +1121 605 332 639 +1122 166 643 646 +1123 40 41 644 +1124 520 521 643 +1125 41 134 644 +1126 372 313 658 +1127 338 251 633 +1128 413 631 642 +1129 417 414 642 +1130 519 517 645 +1131 231 229 630 +1132 251 238 633 +1133 631 279 642 +1134 403 338 640 +1135 338 633 640 +1136 383 324 616 +1137 617 369 640 +1138 112 40 644 +1139 18 19 116 +1140 179 178 660 +1141 134 458 644 +1142 642 279 650 +1143 157 160 661 +1144 356 580 646 +1145 417 642 650 +1146 423 383 424 +1147 282 656 659 +1148 363 431 641 +1149 521 522 647 +1150 608 613 641 +1151 395 655 671 +1152 613 363 641 +1153 646 521 647 +1154 568 651 663 +1155 356 646 647 +1156 426 425 427 +1157 193 190 648 +1158 595 186 649 +1159 568 565 666 +1160 426 427 428 +1161 186 183 651 +1162 420 417 650 +1163 393 392 667 +1164 562 648 670 +1165 583 569 663 +1166 643 521 646 +1167 279 590 650 +1168 667 392 668 +1169 572 370 653 +1170 573 661 664 +1171 441 420 659 +1172 450 375 670 +1173 375 372 672 +1174 346 318 671 +1175 399 579 669 +1176 396 421 655 +1177 618 156 653 +1178 182 660 663 +1179 332 584 657 +1180 378 374 673 +1181 143 142 652 +1182 392 574 668 +1183 670 375 672 +1184 394 680 682 +1185 313 395 658 +1186 370 618 653 +1187 443 441 656 +1188 668 574 669 +1189 660 583 663 +1190 674 598 675 +1191 650 590 659 +1192 590 282 659 +1193 648 450 670 +1194 182 179 660 +1195 156 157 661 +1196 639 332 657 +1197 420 650 659 +1198 371 639 657 +1199 653 156 661 +1200 655 346 671 +1201 259 598 674 +1202 458 457 662 +1203 383 616 654 +1204 616 377 654 +1205 399 669 674 +1206 424 383 654 +1207 186 651 666 +1208 47 48 682 +1209 651 182 663 +1210 624 393 664 +1211 651 568 666 +1212 459 378 665 +1213 160 624 664 +1214 675 341 676 +1215 598 341 675 +1216 391 679 680 +1217 334 573 667 +1218 334 667 668 +1219 341 381 676 +1220 333 334 668 +1221 664 393 667 +1222 676 381 677 +1223 333 668 669 +1224 649 186 666 +1225 579 333 669 +1226 391 652 679 +1227 449 121 684 +1228 573 664 667 +1229 311 562 670 +1230 374 477 673 +1231 530 311 672 +1232 669 574 674 +1233 399 674 675 +1234 311 670 672 +1235 39 112 683 +1236 574 259 674 +1237 398 399 675 +1238 142 454 679 +1239 398 675 676 +1240 665 378 678 +1241 394 376 680 +1242 680 115 682 +1243 400 398 676 +1244 658 395 671 +1245 400 676 677 +1246 644 458 678 +1247 445 400 677 +1248 119 37 685 +1249 112 644 678 +1250 473 474 686 +1251 654 449 684 +1252 458 665 678 +1253 112 673 683 +1254 652 142 679 +1255 115 47 682 +1256 48 681 682 +1257 683 477 685 +1258 376 391 680 +1259 449 394 681 +1260 38 39 683 +1261 119 685 686 +1262 673 477 683 +1263 687 476 688 +1264 474 476 687 +1265 424 654 684 +1266 38 683 685 +1267 37 38 685 +1268 686 474 687 +1269 681 394 682 +1270 477 473 686 +1271 685 477 686 +1272 476 480 688 +1273 507 119 687 +1274 119 686 687 +1275 507 687 688 +1276 136 507 688 +1277 688 480 689 +1278 136 688 689 +1279 690 368 692 +1280 364 368 690 +1281 260 626 690 +1282 261 641 691 +1283 484 690 692 +1284 482 484 692 +1285 626 364 690 +1286 267 266 693 +1287 641 431 691 +1288 270 267 693 +1289 111 436 755 +1290 447 120 758 +1291 693 543 747 +1292 601 131 721 +1293 368 695 698 +1294 266 263 694 +1295 367 444 695 +1296 368 365 695 +1297 64 65 696 +1298 485 118 720 +1299 551 550 752 +1300 550 691 752 +1301 500 535 715 +1302 271 270 697 +1303 656 282 697 +1304 434 710 765 +1305 263 262 694 +1306 261 691 699 +1307 695 446 698 +1308 262 246 699 +1309 691 550 699 +1310 290 293 700 +1311 5 6 701 +1312 365 367 695 +1313 446 126 714 +1314 65 129 696 +1315 432 526 706 +1316 9 10 703 +1317 428 486 716 +1318 64 696 717 +1319 558 551 704 +1320 529 103 718 +1321 17 18 705 +1322 16 17 706 +1323 526 101 706 +1324 282 271 697 +1325 497 499 761 +1326 293 501 754 +1327 498 123 729 +1328 125 472 707 +1329 10 11 709 +1330 434 508 710 +1331 692 368 698 +1332 246 261 699 +1333 270 693 747 +1334 289 290 700 +1335 502 526 711 +1336 6 135 701 +1337 442 448 722 +1338 744 553 764 +1339 710 102 765 +1340 122 481 730 +1341 715 744 764 +1342 126 74 714 +1343 75 110 714 +1344 696 435 717 +1345 483 482 708 +1346 102 63 717 +1347 82 83 702 +1348 433 638 718 +1349 694 262 753 +1350 471 105 719 +1351 425 382 720 +1352 556 555 721 +1353 28 117 722 +1354 122 79 724 +1355 55 123 723 +1356 73 126 725 +1357 105 72 725 +1358 424 467 726 +1359 320 284 727 +1360 401 557 728 +1361 57 535 729 +1362 123 56 729 +1363 501 632 716 +1364 347 592 711 +1365 547 546 731 +1366 469 127 736 +1367 487 488 736 +1368 97 120 732 +1369 111 95 733 +1370 369 405 735 +1371 437 406 738 +1372 407 438 738 +1373 422 439 742 +1374 90 106 737 +1375 438 409 740 +1376 133 89 737 +1377 411 603 740 +1378 88 133 739 +1379 114 87 739 +1380 603 602 742 +1381 86 114 741 +1382 132 85 741 +1383 403 640 735 +1384 84 132 743 +1385 52 3 748 +1386 3 5 748 +1387 100 2 749 +1388 2 53 749 +1389 494 138 749 +1390 4 34 750 +1391 81 4 750 +1392 136 689 750 +1393 708 698 766 +1394 118 9 703 +1395 345 346 756 +1396 346 655 760 +1397 78 122 730 +1398 113 601 744 +1399 523 524 712 +1400 33 1 751 +1401 1 82 751 +1402 692 698 708 +1403 592 289 763 +1404 379 433 707 +1405 381 472 719 +1406 124 503 713 +1407 116 558 704 +1408 18 116 705 +1409 117 523 712 +1410 101 16 706 +1411 108 448 731 +1412 524 124 713 +1413 499 727 761 +1414 593 102 710 +1415 455 125 707 +1416 463 465 763 +1417 702 83 743 +1418 11 109 709 +1419 508 556 710 +1420 482 692 708 +1421 693 266 745 +1422 110 708 766 +1423 541 693 745 +1424 448 443 731 +1425 465 502 711 +1426 419 440 712 +1427 429 418 713 +1428 80 689 724 +1429 494 54 723 +1430 632 428 716 +1431 74 75 714 +1432 535 113 715 +1433 700 463 763 +1434 486 464 716 +1435 63 64 717 +1436 554 553 744 +1437 677 381 719 +1438 464 463 754 +1439 346 734 756 +1440 734 346 760 +1441 638 404 718 +1442 483 77 730 +1443 472 471 719 +1444 550 545 753 +1445 382 423 720 +1446 266 694 745 +1447 555 554 721 +1448 27 28 722 +1449 54 55 723 +1450 495 494 723 +1451 79 80 724 +1452 689 480 724 +1453 72 73 725 +1454 423 424 726 +1455 284 337 727 +1456 439 429 746 +1457 404 401 728 +1458 77 78 730 +1459 56 57 729 +1460 481 483 730 +1461 694 542 745 +1462 543 547 747 +1463 546 108 731 +1464 463 700 754 +1465 5 701 748 +1466 699 550 753 +1467 470 469 734 +1468 96 97 732 +1469 96 732 733 +1470 95 96 733 +1471 127 487 736 +1472 640 369 735 +1473 89 90 737 +1474 406 407 738 +1475 87 88 739 +1476 409 411 740 +1477 85 86 741 +1478 602 422 742 +1479 83 84 743 +1480 728 557 767 +1481 532 320 762 +1482 542 541 745 +1483 697 270 747 +1484 137 33 751 +1485 139 52 748 +1486 138 100 749 +1487 34 136 750 +1488 714 110 766 +1489 704 551 752 +1490 102 717 765 +1491 337 757 761 +1492 436 403 755 +1493 757 625 758 +1494 337 625 757 +1495 625 447 758 +1496 106 470 759 +1497 759 470 760 +1498 262 699 753 +1499 700 293 754 +1500 691 431 752 +1501 499 500 762 +1502 488 111 755 +1503 405 345 756 +1504 528 757 758 +1505 528 496 757 +1506 120 528 758 +1507 421 437 759 +1508 421 759 760 +1509 655 421 760 +1510 757 496 761 +1511 496 497 761 +1512 547 697 747 +1513 435 434 765 +1514 553 532 764 +1515 701 139 748 +1516 137 702 746 +1517 702 137 751 +1518 82 702 751 +1519 696 129 767 +1520 762 500 764 +1521 289 700 763 +1522 698 446 766 +1523 532 762 764 +1524 431 704 752 +1525 715 113 744 +1526 500 715 764 +1527 446 714 766 +1528 727 337 761 +1529 717 435 765 +1530 734 469 756 +1531 470 734 760 +1532 129 728 767 +$EndElements diff --git a/run/windows/genCBProjectMSYS2.sh b/run/windows/genCBProjectMSYS2.sh new file mode 100644 index 0000000..ec0bfc8 --- /dev/null +++ b/run/windows/genCBProjectMSYS2.sh @@ -0,0 +1,26 @@ +#!/bin/sh +#Launch this in MinGW64 shell from MSYS2 +#You should have installed the following package from MSYS2: +#mingw-w64-x86_64-cmake +#mingw-w64-x86_64-toolchain + +export GMSHSDK=/c/tools/gmsh-4.6.0-Windows64-sdk #put gmsh sdk here + +export PATH=${GMSHSDK}/bin:${GMSHSDK}/lin:${PATH} +export INCLUDE=${GMSHSDK}/include +export LIB=${GMSHSDK}/lib + +cd ../../ + +rm -rf build +mkdir build +cd build + +cmake -G "CodeBlocks - MinGW Makefiles" -DCMAKE_SH=SH-NOTFOUND .. +cp -r ${GMSHSDK}/lib/gmsh-4.6.dll bin +cp -r /c/tools/msys64/mingw64/bin/libgcc_s_seh-1.dll bin +cp -r /c/tools/msys64/mingw64/bin/libgomp-1.dll bin +cp -r /c/tools/msys64/mingw64/bin/libstdc++-6.dll bin +cp -r /c/tools/msys64/mingw64/bin/libwinpthread-1.dll bin + +cd ../ \ No newline at end of file diff --git a/run/windows/genCBproject.bat b/run/windows/genCBproject.bat deleted file mode 100644 index 87493f1..0000000 --- a/run/windows/genCBproject.bat +++ /dev/null @@ -1,45 +0,0 @@ -:: This file is intended to generate debug and release Code::Blocks project under windows. -:: Please replace the windows compiler by the latest 64 bits compiler from here -:: -> https://sourceforge.net/projects/mingw-w64/files/latest/download -:: How to create a new compile profile in Code::Blocks -:: -> https://medium.com/@yzhong.cs/code-blocks-compile-64-bit-under-windows-with-mingw-w64-79101f5bbc02 -:: Do not forget to change the CB project compiler when you launch the .cbp ! - -@ECHO OFF - -set GMSHSDK=C:\Program Files (x86)\CodeBlocks\gmsh-4.4.0-Windows64-sdk -set EIGENSDK=C:\Program Files (x86)\CodeBlocks\eigen-eigen-323c052e1731 - -:: where is gmsh.exe and gmsh-**.dll ? (HINT: copy gmsh-**.dll to the bin folder) -set PATH=%GMSHSDK%\bin;%GMSHSDK%\lib;%PATH% -:: where is gmsh.h ? (rename gmsh.h_cwrap => gmsh.h) -set INCLUDE=%EIGENSDK%;%GMSHSDK%\include;%INCLUDE% -:: where is gmsh.lib ? -set LIB=%GMSHSDK%\lib;%LIB% -:: where is gmsh.py ? (required only if you want to use the python API) -set PYTHONPATH=%GMSHSDK%\lib;%PYTHONPATH% - -cd ../../ - -rd /s /q build -mkdir build -cd build - -mkdir Release -cd Release -cmake ../../ -DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - MinGW Makefiles" -copy "%GMSHSDK%\bin\gmsh-4.4.dll" "%cd%\bin" -xcopy /E /I "../../Geometry" "%cd%\bin\Geometry" -xcopy /E /I "../../Params" "%cd%\bin\Params" - -cd ../ - -mkdir Debug -cd Debug -cmake ../../ -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" -copy "%GMSHSDK%\bin\gmsh-4.4.dll" "%cd%\bin" -xcopy /E /I "../../Geometry" "%cd%\bin\Geometry" -xcopy /E /I "../../Params" "%cd%\bin\Params" - -cd ../../ -PAUSE diff --git a/srcs/CMakeLists.txt b/srcs/CMakeLists.txt index a471f3d..b409674 100644 --- a/srcs/CMakeLists.txt +++ b/srcs/CMakeLists.txt @@ -1,29 +1,8 @@ +ADD_SUBDIRECTORY(dgMesh) + SET(SRCS -main.cpp -./mesh/Mesh.cpp ./mesh/Mesh.hpp ./mesh/displayMesh.cpp ./mesh/displayMesh.hpp -./matrices/buildM.cpp ./matrices/buildM.hpp ./matrices/buildS.cpp ./matrices/buildS.hpp ./matrices/buildMatrix.cpp ./matrices/buildMatrix.hpp ./matrices/matrix.hpp -./flux/buildFlux.cpp ./flux/buildFlux.hpp -./solver/timeInteg.cpp ./solver/timeInteg.hpp ./solver/field.hpp ./solver/RungeKutta.cpp ./solver/RungeKutta.hpp -./params/Params.hpp ./params/Params.cpp -./utils/utils.hpp ./utils/utils.cpp -./write/write.hpp ./write/write.cpp -./physics/shallowWater/flux.hpp ./physics/shallowWater/flux.cpp -./physics/shallowWater/phiPsi.hpp ./physics/shallowWater/phiPsi.cpp -./physics/shallowWater/boundaryCondition.hpp ./physics/shallowWater/boundaryCondition.cpp -./physics/shallowWater/writer.hpp ./physics/shallowWater/writer.cpp -./physics/shallowWater/source.hpp ./physics/shallowWater/source.cpp -./physics/linShallowWater/flux.hpp ./physics/linShallowWater/flux.cpp -./physics/linShallowWater/phiPsi.hpp ./physics/linShallowWater/phiPsi.cpp -./physics/linShallowWater/source.hpp ./physics/linShallowWater/source.cpp -./physics/linShallowWater/boundaryCondition.hpp ./physics/linShallowWater/boundaryCondition.cpp -./physics/linShallowWater/writer.hpp ./physics/linShallowWater/writer.cpp -./physics/transport/flux.hpp ./physics/transport/flux.cpp -./physics/transport/phiPsi.hpp ./physics/transport/phiPsi.cpp -./physics/transport/boundaryCondition.hpp ./physics/transport/boundaryCondition.cpp -./physics/transport/writer.hpp ./physics/transport/writer.cpp -./physics/fluxes.hpp ./physics/phiPsis.hpp ./physics/boundaryConditions.hpp ./physics/sources.hpp -./physics/ibcFunction.hpp ./physics/writers.hpp -./physics/meanPhiPsi.cpp ./physics/meanPhiPsi.hpp -./physics/commonBC.cpp ./physics/commonBC.hpp) -ADD_EXECUTABLE(main ${SRCS}) -TARGET_LINK_LIBRARIES(main ${GMSH_LIBRARIES}) +main.cpp) + +ADD_EXECUTABLE(dgExe ${SRCS}) +TARGET_LINK_LIBRARIES(dgExe PUBLIC dgMesh) +SET_TARGET_PROPERTIES(dgExe PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic-errors -Wold-style-cast -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast -Wshadow") \ No newline at end of file diff --git a/srcs/dgMesh/CMakeLists.txt b/srcs/dgMesh/CMakeLists.txt new file mode 100644 index 0000000..4c75d4c --- /dev/null +++ b/srcs/dgMesh/CMakeLists.txt @@ -0,0 +1,28 @@ +# find gmsh-sdk +# gmsh.h +FIND_PATH(GMSH_INCLUDE_DIRS NAMES "gmsh.h") +MESSAGE(STATUS "Found GMSH: " ${GMSH_INCLUDE_DIRS}) +if(NOT GMSH_INCLUDE_DIRS) + MESSAGE(FATAL_ERROR "gmsh.h not found!") +ENDIF() +INCLUDE_DIRECTORIES(SYSTEM ${GMSH_INCLUDE_DIRS}) + +# libgmsh.so +FIND_LIBRARY(GMSH_LIBRARIES gmsh) +MESSAGE(STATUS "Found GMSH: " ${GMSH_LIBRARIES}) +IF(NOT GMSH_LIBRARIES) + MESSAGE(FATAL_ERROR "gmsh library not found!") +ENDIF() + +SET(LIBMESHSRCS +dgMesh.hpp dgMesh.inl dgMesh.cpp) + +ADD_LIBRARY(dgMesh SHARED ${LIBMESHSRCS}) +GENERATE_EXPORT_HEADER(dgMesh + EXPORT_MACRO_NAME DG_MESH_API + EXPORT_FILE_NAME dgMesh_export.h) +TARGET_INCLUDE_DIRECTORIES(dgMesh SYSTEM + PUBLIC ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${GMSH_INCLUDE_DIRS}) +TARGET_LINK_LIBRARIES(dgMesh PRIVATE ${GMSH_LIBRARIES}) +SET_TARGET_PROPERTIES(dgMesh PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic-errors -Wold-style-cast -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast -Wshadow") diff --git a/srcs/dgMesh/dgMesh.cpp b/srcs/dgMesh/dgMesh.cpp new file mode 100644 index 0000000..5fd12b5 --- /dev/null +++ b/srcs/dgMesh/dgMesh.cpp @@ -0,0 +1,348 @@ +#include "dgMesh.hpp" + +#include +#include +#include +#include +#include + +#include + +dgMesh::dgMesh(std::string integrationType, std::string basisFuncType): +m_dimension(-1), +m_integrationType(integrationType), +m_basisFuncType(basisFuncType) +{ + +} + +void dgMesh::loadFromFile(std::string fileName) +{ + /** + NB: In this work, we will only support mesh with a single element type. + + A geometry is represented by a set of geometrical entities. There is normally entities + for every geometrical object of any dimension in the mesh (points, curves, surfaces and volumes). + Any entity should belong to **at least** one physical group. Every entity is then discretized into + a set of elements (which are called elements regardless of the dimension). + + NB: two entities can have the same tag if they are of different dimension, but not physical groups. + + Multiple meshed of different element types can composed an entity, but we will not support them. + + Despite every entity of any dimension being meshed using elements, one can retrieve the "edges" + and "faces" of an element. + **/ + + //Dummy stream to check if the file exist, because gmsh does not do it. + std::ifstream dummyStream(fileName); + if(!dummyStream.is_open()) + throw std::runtime_error("could not open file " + fileName + "."); + + gmsh::initialize(); + gmsh::open(fileName); + + m_dimension = gmsh::model::getDimension(); + + loadPhysicalGroupsAndEntities(); + + loadElementsProperty(); + + gmsh::finalize(); +} + +void dgMesh::displayToConsole() const noexcept +{ + std::cout << m_dimension << "D physical groups: " << std::endl; + for(PhysicalGroup pg : m_physicalGroupHD) + { + std::cout << "\t * " << pg.name << ": \n"; + std::cout << "\t\t - tag: " << pg.tag << "\n"; + std::cout << "\t\t - entities tag: "; + for(Entity* pEntity : pg.pEntities) + std::cout << pEntity->tag << ", "; + std::cout << std::endl; + } + std::cout << std::endl; + + std::cout << m_dimension - 1 << "D physical groups: " << std::endl; + for(PhysicalGroup pg : m_physicalGroupLD) + { + std::cout << "\t * " << pg.name << ": \n"; + std::cout << "\t\t - tag: " << pg.tag << "\n"; + std::cout << "\t\t - entities tag: "; + for(Entity* pEntity : pg.pEntities) + std::cout << pEntity->tag << ", "; + std::cout << std::endl; + } + std::cout << std::endl; + + std::cout << m_dimension << "D entities: " << std::endl; + for(Entity entity : m_entitiesHD) + { + std::cout << "\t * " << entity.tag << ": \n"; + std::cout << "\t\t - element type: " << entity.pElementProperty->type << "\n"; + std::cout << "\t\t - element name: " << entity.pElementProperty->name << "\n"; + } + std::cout << std::endl; + + std::cout << m_dimension - 1 << "D entities: " << std::endl; + for(Entity entity : m_entitiesLD) + { + std::cout << "\t * " << entity.tag << ": \n"; + std::cout << "\t\t - element type: " << entity.pElementProperty->type << "\n"; + std::cout << "\t\t - element name: " << entity.pElementProperty->name << "\n"; + } + std::cout << std::endl; +} + +void dgMesh::loadPhysicalGroupsAndEntities() +{ + /** We firstly retrieve the physical groups of dimension HD and LD **/ + + gmsh::vectorpair physicalGroupsHD; + gmsh::model::getPhysicalGroups(physicalGroupsHD, m_dimension); + if(physicalGroupsHD.size() == 0) + { + throw std::runtime_error("it seems your mesh does not have any physical groups set for dimension " + + std::to_string(m_dimension) + "."); + } + + for(std::pair pgHD : physicalGroupsHD) + { + std::string pgName; + gmsh::model::getPhysicalName(pgHD.first, pgHD.second, pgName); + + if(pgName.empty()) + { + throw std::runtime_error("one of your " + std::to_string(m_dimension) + + "D physical group does not have a name."); + } + + m_physicalGroupHD.push_back({pgHD.second, pgName, {}}); + } + + gmsh::vectorpair physicalGroupsLD; + gmsh::model::getPhysicalGroups(physicalGroupsLD, m_dimension - 1); + if(physicalGroupsLD.size() == 0) + { + throw std::runtime_error("it seems your mesh does not have any physical groups set for dimension " + + std::to_string(m_dimension - 1) + "."); + } + + for(std::pair pgLD : physicalGroupsLD) + { + std::string pgName; + gmsh::model::getPhysicalName(pgLD.first, pgLD.second, pgName); + + if(pgName.empty()) + { + throw std::runtime_error("one of your " + std::to_string(m_dimension - 1) + + "D physical group does not have a name."); + } + + m_physicalGroupLD.push_back({pgLD.second, pgName, {}}); + } + + /** + We then retrieves the entities of dimension HD and LD. Their names are not + retrieve since we will not use them + **/ + + gmsh::vectorpair entitiesHD; + gmsh::model::getEntities(entitiesHD, m_dimension); + if(entitiesHD.size() == 0) + { + throw std::runtime_error("it seems your mesh does not have any geometry set for dimension " + + std::to_string(m_dimension) + "."); + } + + for(std::pair entityHD : entitiesHD) + { + m_entitiesHD.push_back({ + entityHD.second, + {}, + nullptr, + {}, + }); + } + + gmsh::vectorpair entitiesLD; + gmsh::model::getEntities(entitiesLD, m_dimension -1); + if(entitiesLD.size() == 0) + { + throw std::runtime_error("it seems your mesh does not have any geometry set for dimension " + + std::to_string(m_dimension - 1) + "."); + } + + for(std::pair entityLD : entitiesLD) + { + m_entitiesLD.push_back({ + entityLD.second, + {}, + nullptr, + {}, + }); + } + + /** We now create the vector of pointers to entities in each physical group **/ + + for(PhysicalGroup& pgHD : m_physicalGroupHD) + { + std::vector entitiesTagInPG; + gmsh::model::getEntitiesForPhysicalGroup(m_dimension, pgHD.tag, entitiesTagInPG); + + for(int entityTagInPG : entitiesTagInPG) + { + auto it = std::find_if(m_entitiesHD.begin(), m_entitiesHD.end(), + [entityTagInPG](const Entity& knownEntity) + { + return (entityTagInPG == knownEntity.tag); + }); + + assert(it != m_entitiesHD.cend()); + + pgHD.pEntities.push_back(&*it); + } + } + + for(PhysicalGroup& pgLD : m_physicalGroupLD) + { + std::vector entitiesTagInPG; + gmsh::model::getEntitiesForPhysicalGroup(m_dimension - 1, pgLD.tag, entitiesTagInPG); + + for(int entityTagInPG : entitiesTagInPG) + { + auto it = std::find_if(m_entitiesLD.begin(), m_entitiesLD.end(), + [entityTagInPG](const Entity& knownEntity) + { + return (entityTagInPG == knownEntity.tag); + }); + + assert(it != m_entitiesLD.cend()); + + pgLD.pEntities.push_back(&*it); + } + } + + /** We now create the vector of pointers to physical group in each entity **/ + + for(Entity& entityHD : m_entitiesHD) + { + std::vector physicalGroupsTagInEntity; + gmsh::model::getPhysicalGroupsForEntity(m_dimension, entityHD.tag, physicalGroupsTagInEntity); + + for(int pgTagInEntity : physicalGroupsTagInEntity) + { + auto it = std::find_if(m_physicalGroupHD.begin(), m_physicalGroupHD.end(), + [pgTagInEntity](const PhysicalGroup& knownPG) + { + return (pgTagInEntity == knownPG.tag); + }); + + assert(it != m_physicalGroupHD.cend()); + + entityHD.pPhysicalGroups.push_back(&*it); + } + } + + for(Entity& entityLD : m_entitiesLD) + { + std::vector physicalGroupsTagInEntity; + gmsh::model::getPhysicalGroupsForEntity(m_dimension - 1, entityLD.tag, physicalGroupsTagInEntity); + + for(int pgTagInEntity : physicalGroupsTagInEntity) + { + auto it = std::find_if(m_physicalGroupLD.begin(), m_physicalGroupLD.end(), + [pgTagInEntity](const PhysicalGroup& knownPG) + { + return (pgTagInEntity == knownPG.tag); + }); + + assert(it != m_physicalGroupLD.cend()); + + entityLD.pPhysicalGroups.push_back(&*it); + } + } +} + +void dgMesh::loadElementsProperty() +{ + /** We retrieve all the element property inside the whole mesh **/ + + std::vector elementsType; + gmsh::model::mesh::getElementTypes(elementsType); + + for(int elementType : elementsType) + { + ElementProperty elmProperty; + elmProperty.type = elementType; + int dimension; + gmsh::model::mesh::getElementProperties(elementType, + elmProperty.name, dimension, + elmProperty.order, elmProperty.numNodes, + elmProperty.localNodeCoord, elmProperty.numPrimaryNodes); + + gmsh::model::mesh::getIntegrationPoints(elementType, m_integrationType, + elmProperty.intPointsCoord, + elmProperty.intPointsWeigth); + + int dummyNumOrientation; + gmsh::model::mesh::getBasisFunctions(elementType, elmProperty.intPointsCoord, + m_basisFuncType, elmProperty.basisFuncNumComp, + elmProperty.basisFunctions, dummyNumOrientation); + + assert(dummyNumOrientation == 1); + + gmsh::model::mesh::getBasisFunctions(elementType, elmProperty.intPointsCoord, + "Grad" + m_basisFuncType, elmProperty.basisFuncNumCompGrad, + elmProperty.basisFunctionsGrad, dummyNumOrientation); + + assert(dummyNumOrientation == 1); + + if(dimension == m_dimension) + m_elementsPropertyHD.push_back(std::move(elmProperty)); + else if(dimension == m_dimension - 1) + m_elementsPropertyLD.push_back(std::move(elmProperty)); + } + + /** We now determine which element type is in which entity (no hybrid meshes) **/ + + for(Entity& entity : m_entitiesHD) + { + std::vector elementType; + gmsh::model::mesh::getElementTypes(elementType, m_dimension, entity.tag); + + if(elementType.size() != 1) + throw std::runtime_error("Hybrid Meshes are currently not handled"); + + auto it = std::find_if(m_elementsPropertyHD.begin(), m_elementsPropertyHD.end(), + [elementType](const ElementProperty& knownElmProp) + { + return (elementType[0] == knownElmProp.type); + }); + + assert(it != m_elementsPropertyHD.cend()); + + entity.pElementProperty = &*it; + } + + for(Entity& entity : m_entitiesLD) + { + std::vector elementType; + gmsh::model::mesh::getElementTypes(elementType, m_dimension - 1, entity.tag); + + if(elementType.size() != 1) + throw std::runtime_error("Hybrid Meshes are currently not handled"); + + auto it = std::find_if(m_elementsPropertyLD.begin(), m_elementsPropertyLD.end(), + [elementType](const ElementProperty& knownElmProp) + { + return (elementType[0] == knownElmProp.type); + }); + + assert(it != m_elementsPropertyLD.cend()); + + entity.pElementProperty = &*it; + } +} diff --git a/srcs/dgMesh/dgMesh.hpp b/srcs/dgMesh/dgMesh.hpp new file mode 100644 index 0000000..1ea3ea9 --- /dev/null +++ b/srcs/dgMesh/dgMesh.hpp @@ -0,0 +1,102 @@ +#pragma once +#ifndef DGMESH_HPP_INCLUDED +#define DGMESH_HPP_INCLUDED + +#include +#include +#include + +#include "dgMesh_export.h" + +class DG_MESH_API dgMesh +{ + public: + dgMesh() = delete; + dgMesh(std::string integrationType, std::string basisFuncType); + dgMesh(const dgMesh& mesh) = delete; + dgMesh& operator=(const dgMesh& mesh) = delete; + dgMesh(dgMesh&& mesh) = delete; + dgMesh& operator=(dgMesh&& mesh) = delete; + ~dgMesh() = default; + + void displayToConsole() const noexcept; + void loadFromFile(std::string fileName); + + private: + void loadPhysicalGroupsAndEntities(); + void loadElementsProperty(); + void loadElements(); + void loadFaces(); + + int m_dimension; + + std::string m_integrationType; + std::string m_basisFuncType; + + struct PhysicalGroup; + struct Entity; + + struct ElementProperty + { + int type = -1; + std::string name = {}; + int order = -1; + int numNodes = -1; + std::vector localNodeCoord = {}; + int numPrimaryNodes = -1; + + std::vector intPointsCoord = {}; + std::vector intPointsWeigth = {}; + + int basisFuncNumComp = -1; + std::vector basisFunctions = {}; + + int basisFuncNumCompGrad = -1; + std::vector basisFunctionsGrad = {}; + }; + + struct Element + { + int tag = -1; + std::vector nodesTag = {}; + std::vector> nodesCoord = {}; + + std::vector determinant = {}; + std::vector>> jacobian = {}; + + std::vector pElements = {}; + std::vector pEntity = {}; + }; + + struct Entity + { + int tag = -1; + std::vector pPhysicalGroups = {}; + + ElementProperty* pElementProperty = nullptr; + std::vector pElements; + }; + + struct PhysicalGroup + { + int tag = -1; + std::string name = {}; + std::vector pEntities = {}; + }; + + std::vector m_physicalGroupHD; + std::vector m_physicalGroupLD; + + std::vector m_entitiesHD; + std::vector m_entitiesLD; + + std::vector m_elementsPropertyHD; + std::vector m_elementsPropertyLD; + + std::vector m_elementsHD; + std::vector m_elementsLD; +}; + +#include "dgMesh.inl" + +#endif // DGMESH_HPP_INCLUDED diff --git a/srcs/dgMesh/dgMesh.inl b/srcs/dgMesh/dgMesh.inl new file mode 100644 index 0000000..e69de29 diff --git a/srcs/flux/buildFlux.cpp b/srcs/flux/buildFlux.cpp deleted file mode 100644 index 9098a3e..0000000 --- a/srcs/flux/buildFlux.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include -#include -#include "buildFlux.hpp" -#include - - -// see .hpp file for description -void buildFlux(const Mesh& mesh, Field& field, double factor, double t, - const SolverParams& solverParams) -{ - // loop over the elements - #pragma omp parallel for default(none) shared(field, mesh, solverParams, factor, t) - for(size_t elm = 0 ; elm < mesh.elements.size() ; elm++) - { - PartialField partialField(solverParams.nUnknowns, mesh.dim); - - // local I vector for the current element - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - { - partialField.partialIu[unk] - .resize(mesh.elementProperties - .at(mesh.elements[elm].elementTypeHD).nSF); - partialField.partialIu[unk].setZero(); - } - - // loop over the edges for the current element - unsigned int nSigma = mesh.elements[elm].edges.size(); - for(unsigned int s = 0 ; s < nSigma ; ++s) - { - // current edge - - // we first compute the matrix-vector product of dM with gx and gy - for(unsigned short dim = 0 ; dim < mesh.dim ; ++dim) - { - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - { - partialField.g[dim][unk] - .resize(mesh.elementProperties - .at(mesh.elements[elm].elementTypeHD).nSF); - partialField.g[dim][unk].setZero(); - } - } - - for(unsigned int j = 0 ; - j < mesh.elements[elm].edges[s].offsetInElm.size() ; ++j) - { - // global index of the current node - unsigned int indexJ = mesh.elements[elm].offsetInU - + mesh.elements[elm].edges[s].offsetInElm[j]; - - // case of a boundary condition - if (mesh.elements[elm].edges[s].edgeInFront.first == -1) - { - // compute the boundary condition - ibc boundary = solverParams.boundaryConditions - .at(mesh.elements[elm].edges[s].bcName); - - boundary.ibcFunc(partialField.uAtBC, - mesh.elements[elm].edges[s].nodeCoordinate[j], t, - field, indexJ, mesh.elements[elm].edges[s].normal, - boundary.coefficients, solverParams.fluxCoeffs); - - solverParams.flux(field, partialField, solverParams, true); - - // compute the numerical flux - // (the weak/strong form is stored in "factor") - solverParams.phiPsi(mesh.elements[elm].edges[s], field, - partialField, j, factor, true, indexJ, 0, solverParams); - } - else // general case - { - // global index of the node "in front" - unsigned int indexFrontJ = - mesh - .elements[mesh.elements[elm].edges[s] - .edgeInFront.first].offsetInU - + mesh - .elements[mesh.elements[elm].edges[s] - .edgeInFront.first] - .edges[mesh.elements[elm].edges[s] - .edgeInFront.second] - .offsetInElm[mesh.elements[elm] - .edges[s] - .nodeIndexEdgeInFront[j]]; - - // compute the numerical flux - // (the weak/strong form is stored in "factor") - solverParams.phiPsi(mesh.elements[elm].edges[s], field, - partialField, j, factor, false, indexJ, - indexFrontJ, solverParams); - } - } - - // dot product between dM and the normal - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - { - partialField.partialIu[unk] += - mesh.elements[elm].edges[s].determinantLD[0]*( - mesh.elements[elm].edges[s].normal[0]*mesh - .elements[elm].dM[s]*partialField.g[0][unk] - + mesh.elements[elm].edges[s].normal[1]*mesh - .elements[elm].dM[s]*partialField.g[1][unk]); - } - } - - // add the local rhs vector to the global one - for(unsigned short unk = 0 ; unk < field.Iu.size() ; ++unk) - { - for(unsigned int j = 0 ; - j < mesh.elementProperties - .at(mesh.elements[elm].elementTypeHD).nSF ; ++j) - { - field.Iu[unk][mesh.elements[elm].offsetInU + j] - = partialField.partialIu[unk][j]; - } - } - } -} diff --git a/srcs/flux/buildFlux.hpp b/srcs/flux/buildFlux.hpp deleted file mode 100644 index 4883db4..0000000 --- a/srcs/flux/buildFlux.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef buildFlux_hpp -#define buildFlux_hpp - -#include "../mesh/Mesh.hpp" -#include "../params/Params.hpp" -#include "../solver/field.hpp" - - -/** - * \brief Function that allows to build the rhs of the DG method. - * \param mesh The mesh of the problem. - * \param field Structure containing all the information about the computed unknowns. - * \param factor Parameter for a strong or weak form of DG method (+1 or -1). - * \param t Current time of the simulation. - * \param solverParams Structure containing the solver's parameters. - */ -void buildFlux(const Mesh& mesh, Field& field, double factor, double t, - const SolverParams& solverParams); - -#endif /* buildFlux_hpp */ diff --git a/srcs/main.cpp b/srcs/main.cpp index 470fa5b..11d807f 100644 --- a/srcs/main.cpp +++ b/srcs/main.cpp @@ -1,98 +1,13 @@ -#include #include #include -#if defined(_OPENMP) - #include - #include -#endif -#include -#include "mesh/Mesh.hpp" -#include "mesh/displayMesh.hpp" -#include "solver/timeInteg.hpp" -#include "params/Params.hpp" -/** - * @param argv[1] .msh file that contains the mesh. - * @param argv[2] .dat file that contains the parameters. - * @param argv[3] name of the .msh file that will contain the results. - */ +#include "dgMesh/dgMesh.hpp" + int main(int argc, char **argv) { - - // check that the file format is valid - if (argc < 3) - { - std::cerr << "Usage: " << argv[0] << " file.msh " << " param.dat " - << std::endl; - return 1; - } - - // load the solver parameters - std::cout << "================================================================" - << std::endl - << " LOADING THE SOLVER PARAMETERS " - << std::endl - << "================================================================" - << std::endl; - - SolverParams solverParams; - if(!loadSolverParams(std::string(argv[2]), solverParams)) - return -1; - - // set the desired number of OpenMP threads - #if defined(_OPENMP) - unsigned int n = std::atoi(std::getenv("OMP_NUM_THREADS")); - omp_set_num_threads(n); - Eigen::setNbThreads(1); - std::cout << "Number of threads: " << n << std::endl;; - #endif - - // load the mesh - std::cout << "================================================================" - << std::endl - << " LOADING THE MESH " - << std::endl - << "================================================================" - << std::endl; - - Mesh mesh; - auto startTime = std::chrono::high_resolution_clock::now(); - if(!readMesh(mesh, std::string(argv[1]), solverParams.spaceIntType, - solverParams.basisFuncType)) - { - std::cerr << "Something went wrong when reading mesh file: " - << argv[1] << std::endl; - return -1; - } - auto endTime = std::chrono::high_resolution_clock::now(); - auto ellapsedTime = - std::chrono::duration_cast(endTime - startTime); - - std::cout << "Ellapsed time for mesh reading: " - << static_cast(ellapsedTime.count())/1000.0 - << " s" << std::endl; - - // displayMesh(mesh); - std::cout << "================================================================" - << std::endl - << " EXECUTING THE SOLVER " - << std::endl - << "================================================================" - << std::endl; - - startTime = std::chrono::high_resolution_clock::now(); - if(!timeInteg(mesh, solverParams, std::string(argv[1]),std::string(argv[3]))) - { - std::cerr << "Something went wrong when time integrating" << std::endl; - return -1; - } - endTime = std::chrono::high_resolution_clock::now(); - ellapsedTime = - std::chrono::duration_cast(endTime - startTime); - - std::cout << "Ellapsed time for time integration: " - << static_cast(ellapsedTime.count())/1000.0 - << " s" << std::endl; + dgMesh mesh("Gauss1", "Lagrange"); + mesh.loadFromFile(std::string(argv[1])); + mesh.displayToConsole(); return 0; } diff --git a/srcs/matrices/buildM.cpp b/srcs/matrices/buildM.cpp deleted file mode 100644 index 809a1d3..0000000 --- a/srcs/matrices/buildM.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include "buildM.hpp" - - -// see .hpp file for description -void buildM(const Mesh& mesh, Eigen::SparseMatrix& invM) -{ - - // * index: vector of triplets that contains the coordinates in the [M] matrix - // for each of its component - // * offsetMatrix: upper-left coordinate at which the current element matrix - // should be added - std::vector> index; - unsigned int offsetMatrix = 0; - - // loop over the elements - for(size_t elm = 0 ; elm < mesh.elements.size() ; ++elm) - { - // get the 2D properties of the current element type - // * prodFunc[k][i,j]: w_k*l_i*l_j evaluated at each GP - // * IJ[l]: components (i, j) for the index l that runs through the - // upper-half part of [M] - ElementProperty elmProp - = mesh.elementProperties.at(mesh.elements[elm].elementTypeHD); - std::vector> prodFunc = elmProp.prodFunc; - std::vector> IJ = elmProp.IJ; - - // local [M] matrix for the current element - Eigen::MatrixXd MLocal(elmProp.nSF, elmProp.nSF); - MLocal.setZero(); - - // construct the local [M] matrix - // since [M] is symmetric, we only loop over the upper-half matrix - for(unsigned int l = 0 ; l < elmProp.nSF*(elmProp.nSF+1)/2 ; ++l) - { - - // sum over the GP - double sum = 0.0; - for(unsigned int k = 0 ; k < elmProp.nGP ; ++k) - { - // M_ij = sum_k{w_k*l_i(x_k)*l_j(x_k)*det[J](x_k)} - sum += prodFunc[k][l]*mesh.elements[elm].determinantHD[k]; - } - - MLocal(IJ[l].first, IJ[l].second) = sum; - - // if we are not on the diagonal, we also add the lower-half matrix - if(IJ[l].first != IJ[l].second) - { - MLocal(IJ[l].second, IJ[l].first) = sum; - } - } - - // inverse local M matrix (which is also symmetric) - MLocal = MLocal.inverse(); - - // set the indices for the global [M] matrix - for(unsigned int l = 0 ; l < elmProp.nSF*(elmProp.nSF+1)/2 ; ++l) - { - index.push_back(Eigen::Triplet - (IJ[l].first + offsetMatrix, - IJ[l].second + offsetMatrix, - MLocal(IJ[l].first, IJ[l].second))); - - // if we are not on the diagonal, we also add the lower-half matrix - if(IJ[l].first != IJ[l].second) - { - index.push_back(Eigen::Triplet - (IJ[l].second + offsetMatrix, - IJ[l].first + offsetMatrix, - MLocal(IJ[l].first, IJ[l].second))); - } - } - - // increase the offset of the local matrix - offsetMatrix += elmProp.nSF; - } - - // add the triplets in the sparse matrix - invM.setFromTriplets(index.begin(), index.end()); -} diff --git a/srcs/matrices/buildM.hpp b/srcs/matrices/buildM.hpp deleted file mode 100644 index ba7e6d4..0000000 --- a/srcs/matrices/buildM.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef buildM_hpp -#define buildM_hpp - -#include -#include -#include "../mesh/Mesh.hpp" - - -/** - * \brief Function that builds the [M] matrix of the DG method. This matrix is - * defined as M_ij = sum_k{w_k*l_i(x_k)*l_j(x_k)*det[J](x_k)}, where the sum is done - * over the Gauss points (GP). Since the components w_k*l_i(x_k)*l_j(x_k) are already - * computed in the mesh, it suffices to get the determinant of the elements, - * calculate this sum, and store the result in a sparse matrix. - * \param mesh The structure that contains the mesh. - * \param invM The Eigen::SparseMatrix in which the matrix components will be stored. - */ -void buildM(const Mesh& mesh, Eigen::SparseMatrix& invM); - -#endif /* buildM_hpp */ diff --git a/srcs/matrices/buildMatrix.cpp b/srcs/matrices/buildMatrix.cpp deleted file mode 100644 index 4c9c054..0000000 --- a/srcs/matrices/buildMatrix.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include "buildM.hpp" -#include "buildS.hpp" -#include "buildMatrix.hpp" - -// see .hpp file for description -void buildMatrix(const Mesh& mesh, Matrix& matrix) -{ - // redimension the matrix sizes - matrix.invM.resize(mesh.nodeData.numNodes, mesh.nodeData.numNodes); - matrix.Sx.resize(mesh.nodeData.numNodes, mesh.nodeData.numNodes); - matrix.Sy.resize(mesh.nodeData.numNodes, mesh.nodeData.numNodes); - - // build the invM matrix - std::cout << "Building the invM matrix..."; - buildM(mesh, matrix.invM); - // std::cout << "invM:\n" << matrix.invM; - std::cout << "\rBuilding the invM matrix... Done" << std::flush - << std::endl; - - // build the Sx and Sy matrices - std::cout << "Building the Sx and Sy matrices..."; - buildS(mesh, matrix.Sx, matrix.Sy); - // std::cout << "Sx:\n" << matrix.Sx; - // std::cout << "Sy:\n" << matrix.Sy; - std::cout << "\rBuilding the Sx and Sy matrices... Done" << std::flush - << std::endl; - -} diff --git a/srcs/matrices/buildMatrix.hpp b/srcs/matrices/buildMatrix.hpp deleted file mode 100644 index 8158096..0000000 --- a/srcs/matrices/buildMatrix.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef buildMatrix_hpp -#define buildMatrix_hpp - -#include "../mesh/Mesh.hpp" -#include "matrix.hpp" - -/** - * \brief Builds the matrices required for the DG-FEM - * \param mesh The structure that contains the mesh. - * \param matrix The structure that will contain the matrices. - */ -void buildMatrix(const Mesh& mesh, Matrix& matrix); - -#endif /* buildMatrix_hpp */ diff --git a/srcs/matrices/buildS.cpp b/srcs/matrices/buildS.cpp deleted file mode 100644 index c6e09e7..0000000 --- a/srcs/matrices/buildS.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include -#include "buildS.hpp" - - -// see .hpp for description -void buildS(const Mesh& mesh, Eigen::SparseMatrix& Sx, - Eigen::SparseMatrix& Sy) -{ - - // * indexx/indexy: vectors of triplets that contains the coordinates in the - // [Sx]/[Sy] matrices of each ot their components - // * offsetMatrix: upper-left coordinate at which the current element matrix - // should be added - std::vector> indexx, indexy; - unsigned int offsetMatrix = 0; - - // loop over the elements - for(size_t elm = 0 ; elm < mesh.elements.size() ; ++elm) - { - // get the 2D properties of the current element type - // * pondFunc[k][i]: w_k*l_i evaluated at each GP - ElementProperty elmProp - = mesh.elementProperties.at(mesh.elements[elm].elementTypeHD); - std::vector> pondFunc = elmProp.pondFunc; - - // matrices [Sx], [Sy] for the current element, the matrices are stored - // as vectors, such that S_{i,j} = [S](i*elmProp.nSF + j) - std::vector sxElm(elmProp.nSF*elmProp.nSF, 0.0); - std::vector syElm(elmProp.nSF*elmProp.nSF, 0.0); - - // sum over the GP - for(unsigned int k = 0 ; k < elmProp.nGP ; ++k) - { - - // only the 2D case here - double dxdxi = mesh.elements[elm].jacobianHD[9*k]; - double dxdeta = mesh.elements[elm].jacobianHD[9*k + 3]; - double dydxi = mesh.elements[elm].jacobianHD[9*k + 1]; - double dydeta = mesh.elements[elm].jacobianHD[9*k + 4]; - - // dzdzeta component of the jacobian: +/-1 - double sign = mesh.elements[elm].jacobianHD[9*k + 8]; - - // the dets simplify in the inverse of a 2x2 matrix ! - double dxidx = dydeta/sign; - double detadx = - dydxi/sign; - double dxidy = - dxdeta/sign; - double detady = dxdxi/sign; - - // loop over the components of the matrix - for(unsigned int i = 0 ; i < elmProp.nSF ; ++i) - { - for(unsigned int j = 0 ; j < elmProp.nSF ; ++j) - { - - // gradient of the shape functions - double dljdxi = elmProp.basisFuncGrad - [k*elmProp.nSF*3 + j*3]; - double dljdeta = elmProp.basisFuncGrad - [k*elmProp.nSF*3 + j*3 + 1]; - - // components of the elements - sxElm[i*elmProp.nSF + j] - += pondFunc[k][i]*(dljdxi*dxidx + dljdeta*detadx); - syElm[i*elmProp.nSF + j] - += pondFunc[k][i]*(dljdxi*dxidy + dljdeta*detady); - - // if we have calculated the sum for all the GP, - // we can save the computed components - if(k == elmProp.nGP - 1) - { - indexx.push_back(Eigen::Triplet - (i + offsetMatrix, j + offsetMatrix, - sxElm[i*elmProp.nSF + j])); - - indexy.push_back(Eigen::Triplet - (i + offsetMatrix, j + offsetMatrix, - syElm[i*elmProp.nSF + j])); - } - } - } - } - - // increase the offset of the local matrix - offsetMatrix += elmProp.nSF; - } - - // add the triplets in the sparse matrix - Sx.setFromTriplets(indexx.begin(), indexx.end()); - Sy.setFromTriplets(indexy.begin(), indexy.end()); -} diff --git a/srcs/matrices/buildS.hpp b/srcs/matrices/buildS.hpp deleted file mode 100644 index 5ac3ca4..0000000 --- a/srcs/matrices/buildS.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef buildS_hpp -#define buildS_hpp - -#include -#include "../mesh/Mesh.hpp" - - -/** - * \brief Function that builds the [Sx], [Sy] matrix of the DG method. This matrix is - * defined as - * sum_k{w_k*l_i(x_k)*[dl_j/dxi(x_k)*dxi/dx(x_k) - * + dl_j/deta(x_k)*deta/dx(x_k)]*det[J](x_k)}, and - $ sum_k{w_k*l_i(x_k)*[dl_j/dxi(x_k)*dxi/dy(x_k) - * + dl_j/deta(x_k)*deta/dy(x_k)]*det[J](x_k)}, where the - * sum is done over the Gauss points (GP). Since the components w_k*l_i(x_k) are - * already computed in the mesh, it suffices to compute the components of the inverse - * change of variable between the reference and physical frame (the dX/dx), to - * calculate the sum, and store the result in a sparse matrix. - * \param mesh The structure that contains the mesh. - * \param Sx The Eigen::SparseMatrix in which the matrix [Sx] components will be - * stored. - * \param Sy The Eigen::SparseMatrix in which the matrix [Sx] components will be - * stored. - */ -void buildS(const Mesh& mesh, Eigen::SparseMatrix& Sx, - Eigen::SparseMatrix& Sy); - -#endif /* buildS_hpp */ diff --git a/srcs/matrices/matrix.hpp b/srcs/matrices/matrix.hpp deleted file mode 100644 index 1691d18..0000000 --- a/srcs/matrices/matrix.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef matrix_hpp_included -#define matrix_hpp_included - -#include - -/** - * \struct Matrix - * \brief A simple structure containing the matrices needed for DG-FEm. - */ -struct Matrix -{ - - Eigen::SparseMatrix invM; /**< Inverse of the mass matrix */ - Eigen::SparseMatrix Sx; /**< X-stiffness matrix */ - Eigen::SparseMatrix Sy; /**< Y-stiffness matrix */ -}; - -#endif diff --git a/srcs/mesh/Mesh.cpp b/srcs/mesh/Mesh.cpp deleted file mode 100644 index e5e746d..0000000 --- a/srcs/mesh/Mesh.cpp +++ /dev/null @@ -1,748 +0,0 @@ -/** - * \file Mesh.cpp - * \brief Implementation of the required function to load a Mesh structure from file. - */ - -#include -#include -#include -#include -#include "Mesh.hpp" -#include "../utils/utils.hpp" - - -static void loadNodeData(Mesh& mesh) -{ - - unsigned int numNodes = 0; - std::vector elementTags; - std::vector elementNumNodes; - std::vector nodeTags; - std::vector> coord; - - // loop over the elements - for(size_t elm = 0 ; elm < mesh.elements.size() ; ++elm) - { - elementTags.push_back(mesh.elements[elm].elementTag); - elementNumNodes.push_back(mesh.elements[elm].nodeTags.size()); - - for(size_t n = 0 ; n < mesh.elements[elm].nodeTags.size() ; ++n) - { - std::vector temp; - temp.push_back(mesh.elements[elm].nodesCoord[n][0]); - temp.push_back(mesh.elements[elm].nodesCoord[n][1]); - coord.push_back(temp); - - nodeTags.push_back(mesh.elements[elm].nodeTags[n]); - numNodes++; - - } - } - - mesh.nodeData.numNodes = numNodes; - mesh.nodeData.elementTags = elementTags; - mesh.nodeData.elementNumNodes = elementNumNodes; - mesh.nodeData.nodeTags = nodeTags; - mesh.nodeData.coord = coord; -} - - -/** - * \brief Loads the name order, dimension, number of nodes, - * basis functions, integration points for a certain element type into a map. - * \param meshElementProp The map in which the element properties are stored. - * \param eleTypes A vector of element types for which properties will be loaded. - * The function does not try to load them twice if it already exists. - * \param intScheme Integration scheme for the basis functions evaluation. - * \param basisFuncType The type of basis function you will use. - */ -static void loadElementProperties(std::map& meshElementProp, - const std::vector& eleTypes, - const std::string& intScheme, - const std::string& basisFuncType) -{ - for(unsigned int i = 0 ; i < eleTypes.size() ; ++i) - { - // if the element type has already been considered, there is no need to - // add its properties in the map meshElementProp - if(meshElementProp.count(eleTypes[i]) == 0) - { - ElementProperty elementProperty; - gmsh::model::mesh::getElementProperties(eleTypes[i], - elementProperty.name, - elementProperty.dim, - elementProperty.order, - elementProperty.numNodes, - elementProperty.paramCoord); - - gmsh::model::mesh::getIntegrationPoints(eleTypes[i], intScheme, - elementProperty.intPoints, - elementProperty.intWeigths); - - gmsh::model::mesh::getBasisFunctions(eleTypes[i], - elementProperty.intPoints, - basisFuncType, - elementProperty.numComp, - elementProperty.basisFunc); - - int dummyNumComp; - gmsh::model::mesh::getBasisFunctions(eleTypes[i], - elementProperty.intPoints, - std::string("Grad" + basisFuncType), - dummyNumComp, - elementProperty.basisFuncGrad); - - - // add the products prodFunc[k][i,j] = w_k*l_i(x_k)*l_j(x_k) - // add the products pondFunc[k][i] = w_k*l_i(x_k) - elementProperty.nGP = elementProperty.intPoints.size()/3; - elementProperty.nSF = elementProperty.basisFunc.size() - /elementProperty.nGP; - for(unsigned int k = 0 ; k < elementProperty.nGP ; ++k) - { - std::vector wll; - std::vector wl; - - for(unsigned int i = 0 ; i < elementProperty.nSF ; ++i) - { - - wl.push_back(elementProperty.intWeigths[k] - *elementProperty.basisFunc[elementProperty.nSF*k + i]); - - for(unsigned int j = i ; j < elementProperty.nSF ; ++j) - { - if(k == 0) - { - elementProperty.IJ.push_back( - std::pair(i, j)); - } - - wll.push_back(elementProperty.intWeigths[k] - *elementProperty.basisFunc[elementProperty.nSF*k + i] - *elementProperty.basisFunc[elementProperty.nSF*k + j]); - } - } - - elementProperty.pondFunc.push_back(wl); - elementProperty.prodFunc.push_back(wll); - } - - std::vector> lalb(elementProperty.nSF); - for(size_t l = 0 ; l < lalb.size() ; ++l) - { - lalb[l].resize(elementProperty.nSF); - } - - for(unsigned int l = 0 ; - l < elementProperty.nSF*(elementProperty.nSF+1)/2 ; ++l) - { - double sum = 0.0; - for (unsigned int k = 0 ; k < elementProperty.nGP ; ++k) - { - sum += elementProperty.prodFunc[k][l]; - } - - lalb[elementProperty.IJ[l].first][elementProperty.IJ[l].second] = sum; - if(elementProperty.IJ[l].first != elementProperty.IJ[l].second) - { - lalb[elementProperty.IJ[l].second][elementProperty.IJ[l].first] - = sum; - } - } - - elementProperty.lalb = std::move(lalb); - - meshElementProp[eleTypes[i]] = std::move(elementProperty); - } - } -} - - -/** - * \brief Add an edge to a certain element (filling the required fields). - * \param element The parent element. - * \param nodesTagsEdge Nodes tag per edge of the element. - * \param determinantLD Determinant associated with the edge of the element. - * \param nodesTagsElement Nodes tag of the element. - */ -static void addEdge(Element& element, std::vector nodesTagsEdge, - std::vector determinantLD, - const std::vector& nodesTagsElement) -{ - - Edge edge; - // should be before movement ! - for(unsigned int i = 0 ; i < nodesTagsEdge.size() ; ++i) - { - for(unsigned int j = 0 ; j < nodesTagsElement.size() ; ++j) - { - if(nodesTagsEdge[i] == nodesTagsElement[j]) // we should always find it! - edge.offsetInElm.push_back(j); - - } - } - edge.nodeTags = std::move(nodesTagsEdge); - edge.determinantLD = std::move(determinantLD); - - element.edges.push_back(edge); - // we still need to add its tag -} - - -/** - * \brief Compute the outward normal of an edge. - * \param edge The edge of which the normal is computed. - * \param meshDim Dimension of the mesh (1 or 2) - * \param baryCenter Barycenter of the parent element. - */ -static void computeEdgeNormalCoord(Edge& edge, unsigned int meshDim, - const std::vector& baryCenter) -{ - std::vector normal; - - std::vector coord1, coord2; - for(unsigned int i = 0 ; i < edge.nodeTags.size() ; ++i) - { - std::vector coord, dummyParametricCoord; - gmsh::model::mesh::getNode(edge.nodeTags[i], coord, - dummyParametricCoord); - - edge.nodeCoordinate.push_back(coord); - - // normally first and second node tags are vertex - if(i == 0) - coord1 = std::move(coord); - else if(i == 1) - coord2 = std::move(coord); - } - - edge.length=sqrt((coord1[0]-coord2[0])*(coord1[0]-coord2[0]) - +(coord1[1]-coord2[1])*(coord1[1]-coord2[1]) - +(coord1[2]-coord2[2])*(coord1[2]-coord2[2])); - - switch(meshDim) - { - case 1: - // normals are either 1 or -1 - if(coord1[0]-baryCenter[0] < 0) - normal.push_back(-1); - else - normal.push_back(1); - edge.normal = std::move(normal); - break; - - case 2: - // compute the normal - // if A:(x1, y1) and B:(x2, y2), then AB = (x2 - x1, y2 - y1) and a - // normal is given by n = (y2 - y1, x1 - x2) - double nx = coord2[1] - coord1[1]; - double ny = coord1[0] - coord2[0]; - double norm = sqrt(ny*ny + nx*nx); - - // unfortunately, nodes per edge in nodes vector are not always in - // the same order (clockwise vs anticlockwise) => we need to check - // the orientation - double vx = baryCenter[0] - (coord2[0] + coord1[0])/2; - double vy = baryCenter[1] - (coord2[1] + coord1[1])/2; - - if(nx*vx + ny*vy > 0) - { - nx = -nx; - ny = -ny; - } - - // normalize the normal components - normal.push_back(nx/norm); - normal.push_back(ny/norm); - - edge.normal = std::move(normal); - break; - } -} - -/** - * \brief Find the second position of the edge in the entity. - * \param entity The parent entity. - * \param currentEdge The edge of which you want to find the neighbor. - * \param edgePos Index of the edge in its element. - */ -static void findInFrontEdge(Mesh& mesh, Edge& currentEdge, unsigned int edgePos) -{ - // try to find the edge in another element. If an edge is not a boundary, then - // it has necessarily an "edge in front", which will be found - // (the check is done an all previously computed elements). - unsigned int elVecSize = mesh.elements.size(); - unsigned int nEdgePerEl = mesh.elements[0].edges.size(); - - #pragma omp parallel default(none) shared(mesh, elVecSize, nEdgePerEl, currentEdge, edgePos) - { - #pragma omp for - for(unsigned int elm = 0 ; elm < elVecSize ; ++elm) - { - for(unsigned int k = 0 ; k < nEdgePerEl ; ++k) - { - std::vector nodesTagsInfront - = mesh.elements[elm].edges[k].nodeTags; - std::vector permutation1, permutation2; - - // if the nodes tags of an edge is the permutation of the nodes tags - // of another, we have found the "edge in front" - if(isPermutation(currentEdge.nodeTags, nodesTagsInfront, - permutation1, permutation2)) - { - #pragma omp critical - { - currentEdge.edgeInFront - = std::pair(elm, k); - mesh.elements[elm].edges[k].edgeInFront - = std::pair - (elVecSize, edgePos); - currentEdge.nodeIndexEdgeInFront = std::move(permutation1); - mesh.elements[elm].edges[k].nodeIndexEdgeInFront - = std::move(permutation2); - } - #pragma omp cancel for - } - } - #pragma omp cancellation point for - } - } -} - -/** - * \brief Check if an edge lies on a boundary (and which one) - * \param nodesTagBoundaries Map which stores the tags of the nodes belonging to a - * certain boundary. - * \param edge The edge which we check if it is a boundary. - */ -static bool IsBoundary(const std::map>& nodesTagBoundaries, Edge& edge) -{ - // check if an edge is on the boundary of the domain. - for(std::pair> nodeTagBoundary : nodesTagBoundaries) - { - for(unsigned int j = 0 ; j < edge.nodeTags.size() ; ++j) - { - // if one of the nodes tags of the edge is not found inside the boundary - // then the edge does not belong to that boundary - if(!std::count(nodeTagBoundary.second.begin(), - nodeTagBoundary.second.end(), edge.nodeTags[j])) - break; - - // ok the edge belongs to that boundary. - if(j == edge.nodeTags.size() - 1) - { - edge.bcName = nodeTagBoundary.first; - return true; - } - } - } - return false; -} - - -/** - * \brief Add an element to a certain entity (filling the required fields). - * \param entity The parent entity. - * \param elementTag Element tag. - * \param eleTypeHD Type of the element. - * \param eleTypeLD Type of the element's edges. - * \param jacobiansHD Jacobian matrix of the variable change of the element - * evaluated at each Gauss points. - * \param determinantsHD Determinant of the variable change of the element - * evaluated at each Gauss points. - * \param determinantsLD Determinant of the variable change of the element's edges - * evaluated at each Gauss points. - * \param nGPLD Number of Gauss point for integration. - * \param offsetInU Offset of the element in the u unknown vector. - * \param nodesTagsPerEdge Node tags of the element, per edge. - * \param nodesTags Node tags of the element. - * \param elementBarycenter Element barycenter coordinate. - */ -static void addElement(Mesh& mesh, int elementTag, int eleTypeHD, - int eleTypeLD, std::vector jacobiansHD, - std::vector determinantsHD, - std::vector determinantsLD, - unsigned int nGPLD, unsigned int offsetInU, - std::vector nodesTagsPerEdge, - std::vector nodesTags, - const std::vector& elementBarycenter) -{ - // fill an element structure - Element element; - element.elementTag = elementTag; - element.elementTypeHD = eleTypeHD; - element.elementTypeLD = eleTypeLD; - - element.offsetInU = offsetInU; - - element.determinantHD = std::move(determinantsHD); - element.jacobianHD = std::move(jacobiansHD); - element.nodeTags = std::move(nodesTags); - - for(unsigned int i = 0 ; i < element.nodeTags.size() ; ++i) - { - std::vector coord, dummyParametricCoord; - gmsh::model::mesh::getNode(element.nodeTags[i], coord, dummyParametricCoord); - - element.nodesCoord.push_back(coord); - } - - // compute the number of edge and of nodes per edge of that element - unsigned int nEdge = determinantsLD.size()/nGPLD; - unsigned int nNodePerEdge = mesh.elementProperties.at(eleTypeLD).numNodes; - - // for each edge, we add an edge to the element.edges field - for(unsigned int i = 0 ; i < nEdge ; ++i) - { - // get the nodes tags associated with that particular edge - std::vector nodesTagsEdge(nodesTagsPerEdge.begin() + nNodePerEdge*i, - nodesTagsPerEdge.begin() - + nNodePerEdge*(i + 1)); - - // get the determinants associated with that particular edge - std::vector determinantsEdgeLD(determinantsLD.begin() - + nGPLD*i, determinantsLD.begin() - + nGPLD*(i + 1)); - - // add the edge to the element.edges field - addEdge(element, std::move(nodesTagsEdge), std::move(determinantsEdgeLD), - element.nodeTags); - if(mesh.elements.size() != 0) - { - // check if the edge is on the boundary of the domain - // if not, try to find the edge neighbour in a previously computed element - if(!IsBoundary(mesh.nodesTagBoundary, element.edges[i])) - findInFrontEdge(mesh, element.edges[i], i); - - } - else - { - IsBoundary(mesh.nodesTagBoundary, element.edges[i]); - } - - // compute the normal of the edge and get the nodes coordinates of the edge - computeEdgeNormalCoord(element.edges[i], mesh.dim, elementBarycenter); - - // compute some essential matrix for the DG-FEM method - Eigen::SparseMatrix dMs(mesh.elementProperties.at(eleTypeHD).nSF, - mesh.elementProperties.at(eleTypeHD).nSF); - std::vector> indices; - - for(size_t nA = 0 ; nA < element.edges[i].nodeTags.size() ; ++nA) - { - for(size_t nB = 0 ; nB < element.edges[i].nodeTags.size() ; ++nB) - { - indices.push_back(Eigen::Triplet - (element.edges[i].offsetInElm[nA], - element.edges[i].offsetInElm[nB], - mesh.elementProperties.at(eleTypeLD).lalb[nA][nB])); - } - } - dMs.setFromTriplets(indices.begin(), indices.end()); - element.dM.push_back(dMs); - } - - // add the element to the mesh - mesh.elements.push_back(element); -} - - -/** - * \brief Add an entity to a certain 2D mesh (filling the required fields). - * \param mesh The parent mesh. - * \param entityTag Entity tag to add. - * \param currentOffset Offset in u unknown vector. - * \param intScheme Integration scheme for the basis functions evaluation. - * \param basisFuncType The type of basis function you will use. - * \return true if then entity was added flawlessly, false otherwise. - */ -static bool buildMesh(Mesh& mesh, int entityTag, unsigned int& currentOffset, - const std::string& intScheme, const std::string& basisFuncType) -{ - // fill an entity structure - mesh.entityTagHD = entityTag; - - // add an entity for the mesh.dim-1 D elements created (edges of the elements) - int c = gmsh::model::addDiscreteEntity(1); - mesh.entityTagLD = c; - - // get the element types in the current mesh.dim D entity - std::vector eleTypesHD; - gmsh::model::mesh::getElementTypes(eleTypesHD, mesh.dim,entityTag); - - loadElementProperties(mesh.elementProperties, eleTypesHD, - intScheme, basisFuncType); - - // loop over the element types in the current mesh.dim D entity - for(auto eleTypeHD : eleTypesHD) - { - // get the elements of type eleTypeHD and their nodes tags. - std::vector nodeTags, elementTags; - gmsh::model::mesh::getElementsByType(eleTypeHD, elementTags, nodeTags, - entityTag); - - // get the elements nodes tags "per edge". - std::vector nodesTagPerEdge; - gmsh::model::mesh::getElementEdgeNodes(eleTypeHD, nodesTagPerEdge, - entityTag); - - unsigned int numNodes = mesh.elementProperties[eleTypeHD].numNodes; - unsigned int order = mesh.elementProperties[eleTypeHD].order; - - if(intScheme == "Lagrange" && order > 7) - { - std::cerr << "Lagrange polynomials are not stable with an order" - << " superior to 7" - << std::endl; - - return false; - } - - // get the elements barycenters (for normal computation) - std::vector baryCenters; - gmsh::model::mesh::getBarycenters(eleTypeHD, entityTag, false, true, - baryCenters); - - // add mesh.dim-1 D entity to store all the lines associated to elements - // of the same order - int eleTypeLD; - switch(mesh.dim) - { - case 1: - eleTypeLD = gmsh::model::mesh::getElementType("point", order); - break; - - case 2: - eleTypeLD = gmsh::model::mesh::getElementType("line", order); - break; - } - - // creation of the mesh.dim-1 D elements - gmsh::model::mesh::addElementsByType(c, eleTypeLD, {}, nodesTagPerEdge); - - loadElementProperties(mesh.elementProperties, std::vector(1, eleTypeLD), - intScheme, basisFuncType); - - // we then load jacobian matrices and their determinants of the mesh.dim D - // and mesh.dim -1 D elements (useful for M, Sx, Sy, Sz) - std::vector jacobiansHD, determinantsHD, dummyPointsHD; - gmsh::model::mesh::getJacobians(eleTypeHD, - mesh.elementProperties[eleTypeHD].intPoints, - jacobiansHD, determinantsHD, dummyPointsHD, - entityTag); - - std::vector dummyJacobiansLD, determinantsLD, dummyPointsLD; - gmsh::model::mesh::getJacobians(eleTypeLD, - mesh.elementProperties[eleTypeLD].intPoints, - dummyJacobiansLD, determinantsLD, - dummyPointsLD, c); - - // computation of the number of mesh.dim D elements, number of gauss points - // for mesh.dim and mesh.dim-1 D elements, the number of edges per mesh.dim D - // elements and the number of nodes per edge. - unsigned int nElements = nodeTags.size() - /mesh.elementProperties[eleTypeHD].numNodes; - unsigned int nGPHD = mesh.elementProperties[eleTypeHD].nGP; - unsigned int nGPLD = mesh.elementProperties[eleTypeLD].nGP; - unsigned int nEdgePerElement = determinantsLD.size()/(nGPLD*nElements); - unsigned int nNodesPerEdge = mesh.elementProperties[eleTypeLD].numNodes; - - // loop over each mesh.dim D elements - unsigned ratio, currentDecade = 0; - for(unsigned int i = 0 ; i < elementTags.size() ; ++i) - { - - // display progress - ratio = int(100*double(i)/double(elementTags.size())); - if(ratio >= currentDecade) - { - std::cout << "\r" << "Entity [" << mesh.entityTagHD << "]: " - << ratio << "% of the elements computed" - << std::flush; - currentDecade = ratio + 1; - } - - // get jacobians and determinant associated with that particular element - std::vector jacobiansElementHD( - jacobiansHD.begin() + 9*nGPHD*i, - jacobiansHD.begin() + 9*nGPHD*(1 + i)); - std::vector determinantsElementHD( - determinantsHD.begin() + nGPHD*i, - determinantsHD.begin() + nGPHD*(1 + i)); - std::vector determinantElementLD( - determinantsLD.begin() + nEdgePerElement - *nGPLD*i, - determinantsLD.begin() + nEdgePerElement - *nGPLD*(1 + i)); - - // get nodes tags and nodes tags "per edge" associated with that - // particular element - std::vector nodeTagsElement(nodeTags.begin() + numNodes*i, - nodeTags.begin() + numNodes*(1 + i)); - - std::vector nodesTagPerEdgeElement( - nodesTagPerEdge.begin() - + nNodesPerEdge*nEdgePerElement*i, - nodesTagPerEdge.begin() - + nNodesPerEdge*nEdgePerElement*(i + 1)); - - // get the barycenter of that particular element - std::vector elementBarycenter(baryCenters.begin() + 3*i, - baryCenters.begin() + 3*(i + 1)); - - // offset of the element in the unknown vector - unsigned int elementOffset = numNodes; - - double dx; - - // add the element to the entity - addElement(mesh, elementTags[i], eleTypeHD, eleTypeLD, - std::move(jacobiansElementHD), - std::move(determinantsElementHD), - std::move(determinantElementLD), - nGPLD, currentOffset, - std::move(nodesTagPerEdgeElement), - std::move(nodeTagsElement), - elementBarycenter); - - currentOffset += elementOffset; - } - - std::cout << "\r" << "Entity [" << mesh.entityTagHD << "]: " - << "100% of the elements computed" << std::flush << std::endl; - } - - return true; -} - - -/** - * \brief Compute the mesh dimension. - * \return The mesh dimension (1, 2 or 3). - */ -static unsigned short getMeshDim() -{ - int elementDim = -1; - - // loop over the dimension i to get the maximum element dimension in the mesh - for(unsigned short i = 0 ; i <= 3 ; ++i) - { - std::vector eleTypes; - gmsh::model::mesh::getElementTypes(eleTypes, i); - - switch(eleTypes.size()) - { - case 0: - break; - case 1: - elementDim = i; - break; - default: - elementDim = i; - std::cerr << "Hybrid meshes not handled in this example!" - << std::endl; - } - } - - return elementDim; -} - -// documentation in .hpp file -std::vector getTags(const Mesh& mesh) -{ - std::vector listTags; - - // loop over the nodes - for(unsigned int elm = 0 ; elm < mesh.elements.size() ; ++elm) - { - for(unsigned int n = 0 ; n < mesh.elements[elm].nodeTags.size() ; ++n) - { - listTags.push_back(mesh.elements[elm].nodeTags[n]); - } - } - - return listTags; -} - -// documentation in .hpp file -bool readMesh(Mesh& mesh, const std::string& fileName, - const std::string& intScheme, const std::string& basisFuncType) -{ - gmsh::initialize(); - gmsh::option::setNumber("General.Terminal", 1); - std::ifstream file(fileName); - if(file.is_open()) - file.close(); - else - { - std::cerr << "File: " << fileName << " does not exist!" << std::endl; - return false; - } - gmsh::open(fileName); - - // check that the mesh is not 3D - mesh.dim = getMeshDim(); - if(mesh.dim == 3) - { - std::cerr << "3D meshes unsupported!" << std::endl; - return false; - } - - // we retrieve the tags of the physical groups of dimension mesh.dim and - // mesh.dim-1 - std::vector> physGroupHandles; - gmsh::model::getPhysicalGroups(physGroupHandles, mesh.dim); - - std::vector> BCHandles; - gmsh::model::getPhysicalGroups(BCHandles, mesh.dim - 1); - - // physical groups of dimension mesh.dim-1 are boundary conditions. - // we then retrieve and store the tag of each node in those boundaries. - for(auto BCHandle : BCHandles) - { - std::string name; - gmsh::model::getPhysicalName(mesh.dim - 1, BCHandle.second, name); - std::vector nodesTags; - std::vector dummyCoord; - gmsh::model::mesh::getNodesForPhysicalGroup(mesh.dim - 1, BCHandle.second, - nodesTags, dummyCoord); - mesh.nodesTagBoundary[name] = nodesTags; - } - - // we assume that a physical group contains only one entity and we retrieve them. - std::vector entitiesTag; - for(auto physGroupHandle : physGroupHandles) - { - std::vector entityTag; - gmsh::model::getEntitiesForPhysicalGroup(physGroupHandle.first, - physGroupHandle.second, - entityTag); - - entitiesTag.push_back(entityTag[0]); - } - - - unsigned int currentOffset = 0; - - // we add each identified entity to the mesh. - if(entitiesTag.size() > 1) - { - std::cerr << "Multiple " << mesh.dim << "D entities in " << mesh.dim - << "D meshes " << "currently not supported" < -#include -#include -#include -#include - -/** - * \struct Edge - * \brief Represents an edge. - */ -struct Edge -{ - int edgeTag; /**< Element tag of the edge*/ - - std::vector determinantLD; /**< Determinant of the variable change for - Gauss integration, - evaluated at each Gauss point*/ - - std::vector nodeTags; /**< Node tags for each point of the edge*/ - std::vector> nodeCoordinate; /**< Coordinate of the node*/ - std::vector normal; /**< Edge normal point outwards the element*/ - - double length; - - std::pair edgeInFront - = std::pair(-1, -1); /**< Element index and edge - index to find the - second location of this edge - in the mesh*/ - std::vector nodeIndexEdgeInFront; /**< Track if the node are - inverted in the edge in front*/ - std::string bcName; /**< Name of the physical group of the boundary condition - in which the edge is in (if any)*/ - - std::vector offsetInElm; /**< Offset of the edge nodes in the element*/ -}; - -/** - * \struct Element - * \brief Represents an element. - */ -struct Element -{ - int elementTag; /**< element tag of the element*/ - int elementTypeHD; /**< Type of the element*/ - int elementTypeLD; /**< Type of the edges*/ //Store it only once - - unsigned int offsetInU; /**< Offset of the element in the unknowns - vector*/ - - std::vector determinantHD; /**< Determinant of the variable change for - Gauss integration, evaluated at each - Gauss point*/ - - std::vector jacobianHD; /**< Jacobian of the variable change for - Gauss integration, evaluated at each - Gauss point*/ - - std::vector edges; /**< List of edge which compose the element */ - std::vector nodeTags; /**< List of node tags of the element */ - std::vector> nodesCoord; /**< Node coordinates - of the elemnts */ - - std::vector> dM; /**< Partial M matrix */ -}; - - -/** - * \struct ElementProperty - * \brief Store the different properties of a certain element type. - */ -struct ElementProperty -{ - std::string name; /**< Name of the element type */ - int dim; /**< Dimension of the element type */ - int order; /**< Order of the element type */ - int numNodes; /**< Number of nodes of the element type */ - - std::vector paramCoord; - std::vector basisFunc; /**< Basis functions evaluated at each Gauss point in the reference axis */ - std::vector basisFuncGrad; /**< Basis functions gradient evaluated at each Gauss point in the reference axis */ - std::vector intPoints; /**< Integration points for Gauss integration */ - std::vector intWeigths; - int numComp; - - unsigned int nGP; /**< Number of GP */ - unsigned int nSF; /**< Number of SF */ - std::vector> prodFunc; /**< Cross-product w_k*l_i*l_j - evaluated at each GP */ - - std::vector> pondFunc; /**< Cross-product w_k*l_i - evaluated at each GP */ - - std::vector> IJ; /**< Index list of - the elements of - prodFunc */ - std::vector> lalb; - -}; - - -struct NodeData -{ - unsigned int numNodes; - std::vector elementTags; - std::vector elementNumNodes; - std::vector nodeTags; - std::vector> coord; -}; - - -/** - * \struct Mesh - * \brief Represents a mesh. - */ -struct Mesh -{ - std::map elementProperties; /**< Store element - properties for each - element type */ - - std::map> nodesTagBoundary;/**< Tags of the nodes - per BC */ - - int entityTagHD; /**< Tag of the HD entity*/ - int entityTagLD; /**< Tag of the LD entity linked to this - HD entity*/ - - std::vector elements; /**< List of the elements inside the entity*/ - - unsigned short dim; /**< Mesh dimension (1, 2, (3)) */ - - NodeData nodeData; -}; - -/** - * \brief Get the tags of nodes (i.e. of unknowns) given a mesh. - * \param mesh The structure that contains the mesh. - * \return Vector containing all the tags of the nodes inside a mesh. - */ -std::vector getTags(const Mesh& mesh); - - -/** - * \brief Read a mesh from a file.msh - * \param mesh The structure which will contain loaded informations. - * \param fileName The name of the file to load. - * \param intScheme Integration scheme for the basis functions evaluation. - * \param basisFuncType The type of basis function you will use. - */ -bool readMesh(Mesh& mesh, const std::string& fileName, - const std::string& intScheme, const std::string& basisFuncType); - -#endif // Mesh2D_hpp_included - diff --git a/srcs/mesh/displayMesh.cpp b/srcs/mesh/displayMesh.cpp deleted file mode 100644 index 1964bd4..0000000 --- a/srcs/mesh/displayMesh.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/** - * \file displayMesh.cpp - * \brief Implementation of the required function to display a Mesh2D struct. - */ - -#include -#include -#include "Mesh.hpp" - - -// see .hpp for description -void displayMesh(const Mesh& mesh) -{ - - std::cout << "================================================================" - << std::endl - << " DISPLAYING THE MESH INFORMATION " - << std::endl - << "================================================================" - << std::endl; - - /******************************************************************************* - * DISPLAY INFORMATION ABOUT THE ENTITIES * - *******************************************************************************/ - // general information about the current entity - std::cout << "[Entity (" << 1 << ")]:\n" - << "\t- Tag of the " << mesh.dim << "D entity: " - << mesh.entityTagHD << "\n" - << "\t- Tag of the " << mesh.dim-1 << "D entity: " - << mesh.entityTagLD << "\n" - << "\t- Number of " << mesh.dim << "D elements: " - << mesh.elements.size() << "\n"; - - // display the information about each element - for(size_t j = 0 ; j < mesh.elements.size() ; ++j) - { - - // display the information about the current element - Element element = mesh.elements[j]; - std::cout << "\t[Element (" << j << ")]:\n" - << "\t\t- Tag: " << element.elementTag << "\n" - << "\t\t- " << mesh.dim << "D type: " - << element.elementTypeHD << "\n" - << "\t\t- " << mesh.dim-1 << "D type: " - << element.elementTypeLD << "\n" - << "\t\t- Offset in u: " << element.offsetInU << "\n" - << "\t\t- Nodes tags: " << std::endl; - - // node tags - for(size_t p = 0 ; p < element.nodeTags.size() ; ++p) - { - std::cout << "\t\t\t Node (" << p << "): " - << element.nodeTags[p] << std::endl; - } - std::cout << std::endl; - - // determinant of the change of variable - for(size_t k = 0 ; k < element.determinantHD.size() ; ++k) - { - - std::cout << "\t\t- [at GP (" << k << ")]:\n" - << "\t\t\t- det = " << element.determinantHD[k] - << std::endl; - for(unsigned int l = 0 ; l < 9 ; ++l) - { - std::cout << "\t\t\t- jac[" << l << "] = " - << element.jacobianHD[9*k + l] << std::endl; - } - } - - // edges - std::vector edges = element.edges; - for(size_t k = 0 ; k < edges.size() ; ++k) - { - - std::cout << "\t\t- [Edge (" << k << ")]:\n"; - - // node tags - for(size_t b = 0 ; b < edges[k].nodeTags.size() ; ++b) - { - std::cout << "\t\t\t- Tag (" << b << "): " - << edges[k].nodeTags[b] << std::endl; - } - - // normal and determinant - std::cout << "\t\t\t- Normal: (" ; - for(size_t y = 0 ; y < edges[k].normal.size() ; ++y) - { - std::cout << element.edges[k].normal[y] << ", "; - } - std::cout << ")\n" - << "\t\t\t- Det: "; - for(size_t r = 0 ; r < edges[k].determinantLD.size() ; ++r) - { - std::cout << edges[k].determinantLD[r]; - if(r != edges[k].determinantLD.size() - 1) - { - std::cout << ", "; - } - else - { - std::cout << std::endl; - } - } - - // offset in the element - for(size_t i = 0 ; i < edges[k].offsetInElm.size() ; ++i) - { - std::cout << "\t\t\t- OffsetInElm of node (" << i << "): " - << edges[k].offsetInElm[i] - << std::endl; - } - - // neighbour or BC - if(edges[k].edgeInFront.first != -1) - { - std::cout << "\t\t\t- Edge in front: element " - << edges[k].edgeInFront.first << ", " - << "edge " << edges[k].edgeInFront.second - << std::endl; - - //Check that the normals are computed correctly - for(unsigned int v = 0 ; v < edges[k].normal.size() ; ++v) - { - if(edges[k].normal[v] != -mesh - .elements[edges[k].edgeInFront.first] - .edges[edges[k].edgeInFront.second].normal[v]) - { - std::cerr << "Bug in the normal of that edge !" - << std::endl; - return; - } - } - } - else - { - if(edges[k].bcName.size() == 0) - { - std::cerr << "BC node does not have a BC name !" - << std::endl; - return; - } - else - std::cout << "\t\t\t- BC: " << edges[k].bcName - << std::endl; - } - } - } - std::cout << std::endl; - - - /******************************************************************************* - * DISPLAY INFORMATION ABOUT THE ELEMENT TYPES * - *******************************************************************************/ - // display the number of 2D element types - std::cout << "Number of element types: " << mesh.elementProperties.size() - << std::endl; - - // loop over the element types - for(std::pair elmProperty : mesh.elementProperties) - { - std::cout << "[Type (" << elmProperty.first << ")]:" << std::endl; - - ElementProperty property = elmProperty.second; - std::cout << "\t- name: " << property.name << std::endl - << "\t- dim: " << property.dim << std::endl - << "\t- order: " << property.order << std::endl - << "\t- numNodes: " << property.numNodes << std::endl; - } -} diff --git a/srcs/mesh/displayMesh.hpp b/srcs/mesh/displayMesh.hpp deleted file mode 100644 index 2e815de..0000000 --- a/srcs/mesh/displayMesh.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef displayMesh_hpp -#define displayMesh_hpp - -#include "Mesh.hpp" - -/** - * \brief Display what is contained in a 2D mesh. - * \param mesh The mesh that will be displayed. - */ -void displayMesh(const Mesh& mesh); - -#endif /* displayMeshhpp */ diff --git a/srcs/params/Params.cpp b/srcs/params/Params.cpp deleted file mode 100644 index 5172871..0000000 --- a/srcs/params/Params.cpp +++ /dev/null @@ -1,670 +0,0 @@ -/** - * \file Params.cpp - * \brief Implementation of the required function to load a SolverParams struct from file. - */ - -#include -#include -#include //Change with something more c++ ;-) -#include -#include -#include "Params.hpp" -#include "../physics/boundaryConditions.hpp" -#include "../physics/fluxes.hpp" -#include "../physics/phiPsis.hpp" -#include "../physics/sources.hpp" - -/** - * \brief Wrapper of std::getline to have comments in file with // - * \param file The file which has been previously opened. - * \param line The computed line (without comments) - */ -static void getLine(std::ifstream& file, std::string& line) -{ - std::string tempLine; - while(true) //be careful with this - { - std::getline(file, tempLine); - if(tempLine.compare(0, 2, "//") != 0) - { - std::size_t pos; - pos = tempLine.find("//"); - if(pos != std::string::npos) - { - while(true) - { - if(tempLine.at(pos-1) == ' ' || tempLine.at(pos-1) == '\t') - tempLine.erase(pos-1, 1); - else - { - tempLine.erase(pos); - break; - } - pos = tempLine.find("//"); - } - } - - line = tempLine; - return; - } - } -} - - -/** - * \brief Load boundary conditions from a file - * \param paramFile The file which has been previously opened. - * \param solverParams The structure in which the parameters are loaded. - * \param fileName The name of the parameters file which has been opened (for debug output). - * \return true if the loading succeeds, false otherwise. - */ -static bool handleBoundaryCondition(std::ifstream& paramFile, SolverParams& solverParams, - const std::string& fileName) -{ - unsigned int nBC = 0; - bool foundInitCond = false; - - while(true) - { - ibc tempCondition; - std::string bcName; - std::string bcType; - std::string tempBcCoeff; - std::vector bcCoeff; - - if(paramFile.eof()) - { - std::cout << "End of file reached." << std::endl; - break; - } - getLine(paramFile, bcName); - - getLine(paramFile, bcType); - if(bcType[0] != '\t') //Let's make them tabulated for easier reading - { - std::cerr << "Bad type format for BC " << bcName - << " in parameter file " << fileName << std::endl; - - return false; - } - bcType.erase(0,1); - - bool error = false; - if(solverParams.problemType == "transport") - { - if(bcType == "constant") - tempCondition.ibcFunc = constant; - - else if(bcType == "sinusTransport") - tempCondition.ibcFunc = sinusTransport; - - else if(bcType == "gaussianTransport") - tempCondition.ibcFunc = gaussianTransport; - - else if(bcType == "freeTransport") - tempCondition.ibcFunc = freeTransport; - - else if(bcType == "gaussian2DTransport") - tempCondition.ibcFunc = gaussian2DTransport; - - else - error = true; - } - else if(solverParams.problemType == "shallow") - { - if(bcType == "constant") - tempCondition.ibcFunc = constant; - - else if(bcType == "affineShallow") - tempCondition.ibcFunc = affineShallow; - - else if(bcType == "sinusShallow") - tempCondition.ibcFunc = sinusShallow; - - else if(bcType == "sinusAffShallow") - tempCondition.ibcFunc = sinusAffShallow; - - else if(bcType == "reflectShallow") - tempCondition.ibcFunc = reflectShallow; - - else if(bcType == "gaussian2DShallow") - tempCondition.ibcFunc = gaussian2DShallow; - - else if(bcType == "gaussian1DShallowX") - tempCondition.ibcFunc = gaussian1DShallowX; - - else if(bcType == "gaussian1DShallowY") - tempCondition.ibcFunc = gaussian1DShallowY; - - else if(bcType == "openShallow") - tempCondition.ibcFunc = openShallow; - - else if(bcType == "openAffShallow") - tempCondition.ibcFunc = openAffShallow; - - else - error = true; - - } - else if(solverParams.problemType == "shallowLin") - { - if(bcType == "constant") - tempCondition.ibcFunc = constant; - - else if(bcType == "sinusShallowLin") - tempCondition.ibcFunc = sinusShallowLin; - - else if(bcType == "reflectShallowLin") - tempCondition.ibcFunc = reflectShallowLin; - - else if(bcType == "gaussian2DShallowLin") - tempCondition.ibcFunc = gaussian2DShallowLin; - - else if(bcType == "gaussian1DShallowXLin") - tempCondition.ibcFunc = gaussian1DShallowXLin; - - else if(bcType == "gaussian1DShallowYLin") - tempCondition.ibcFunc = gaussian1DShallowYLin; - - else if(bcType == "openShallowLin") - tempCondition.ibcFunc = openShallowLin; - - else - error = true; - } - - if(error) - { - std::cerr << "Unhandled boundary condition type " << bcType - << " for boundary " << std::endl << bcName - << " for problem type " - << solverParams.problemType << " in parameter file " - << fileName < -#include -#include -#include "../solver/field.hpp" -#include "../mesh/Mesh.hpp" -#include "../physics/writers.hpp" -#include "../physics/ibcFunction.hpp" -/** - * \struct SolverParams - * \brief Parameters of the method. - */ -struct SolverParams -{ - std::string spaceIntType; /**< Number of points for Gauss integration - (format Gaussx, x the number of points) */ - std::string basisFuncType; /**< Type of basis functions (Lagrange or Isoparametric */ - std::string timeIntType; /**< Runge-Kutta time integration type (RK1 or RK4) */ - std::string solverType; /**< Solver form (strong or weak) */ - - double simTime; /**< Simulation time duration */ - double timeStep; /**< Time steps for the simulation */ - double simTimeDtWrite; /**< Time between two data writings */ - - std::map boundaryConditions; /**< Map of the problem's boundary condition*/ - ibc initCondition; /**< Initial condition*/ - - std::string problemType; /**< Equations to solve (transport, shallow, ...)*/ - - std::function flux; /**< Pointer to the flux function - (represents the physics of the problem)*/ - - std::vector fluxCoeffs; /**< Coefficient of the physical flux*/ - - unsigned short nUnknowns; /**< Number of scalar unknowns - (determined by the type of problem)*/ - - std::string fluxType; /**< Type of numerical flux - (mean, Lax-Friedirichs, Roe, ...)*/ - - std::function phiPsi; /**< Pointer to the - rhs function (phi or psi depending of the type of scheme)*/ - - bool IsSourceTerms; /**< (De)activate source terms computation*/ - std::string sourceType; /**< Denotes the type of source terms*/ - std::vector sourceCoeffs; /**< Coefficient of the source terms*/ - std::function sourceTerm;/**< Pointer to the source terms function*/ - - - std::vector whatToWrite; /**< Vector of boolean denoting - what will be written (problem dependent)*/ - std::vector viewTags; /**< Store the view tag of what will be written*/ - - std::function>& uDisplay, - const std::vector& elementNumNodes, - const std::vector& elementTags, - const std::string& modelName,unsigned int nbreStep, double t, - const Field& field, const std::vector& fluxCoeffs, - const std::vector& whatToWrite, - std::vector& viewTags)> write; /**< Pointer to the function - which will write*/ -}; - -/** - * \brief Load solver parameters from file in a structure - * \param fileName The name of the parameters file to load. - * \param solverParams The structure in which the parameters are loaded. - * \return true if the loading succeeds, false otherwise. - */ -bool loadSolverParams(const std::string& fileName, SolverParams& solverParams); - -#endif // Params_hpp_included diff --git a/srcs/physics/boundaryConditions.hpp b/srcs/physics/boundaryConditions.hpp deleted file mode 100644 index 55cf9c7..0000000 --- a/srcs/physics/boundaryConditions.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef boundaryConditions_hpp_included -#define boundaryConditions_hpp_included - -#include -#include "../solver/field.hpp" - -#include "commonBC.hpp" -#include "linShallowWater/boundaryCondition.hpp" -#include "shallowWater/boundaryCondition.hpp" -#include "transport/boundaryCondition.hpp" - -#endif // boundaryConditions_hpp_included diff --git a/srcs/physics/commonBC.cpp b/srcs/physics/commonBC.cpp deleted file mode 100644 index bf6be47..0000000 --- a/srcs/physics/commonBC.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include "commonBC.hpp" - -#include - - -// see .hpp file for description -void constant(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - - // check that there is enough values - assert(coeffs.size() == uAtIBC.size()); - - // compute constant values - for(unsigned short unk = 0 ; unk < field.u.size() ; ++unk) - { - uAtIBC[unk] = coeffs[unk]; - } -} diff --git a/srcs/physics/commonBC.hpp b/srcs/physics/commonBC.hpp deleted file mode 100644 index 7c45401..0000000 --- a/srcs/physics/commonBC.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef commonBC_hpp_included -#define commonBC_hpp_included - -#include -#include "../solver/field.hpp" - -/** - * \brief Compute a constant -- for shallow waters & the pure transport case. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficient for the constant: coeffs[unk] = constant. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void constant(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -#endif // commonBC_hpp_included diff --git a/srcs/physics/fluxes.hpp b/srcs/physics/fluxes.hpp deleted file mode 100644 index 709fd5b..0000000 --- a/srcs/physics/fluxes.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef fluxes_hpp_included -#define fluxes_hpp_included - -#include "linShallowWater/flux.hpp" -#include "shallowWater/flux.hpp" -#include "transport/flux.hpp" - -#endif // fluxes_hpp_included diff --git a/srcs/physics/ibcFunction.hpp b/srcs/physics/ibcFunction.hpp deleted file mode 100644 index 6ee97da..0000000 --- a/srcs/physics/ibcFunction.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef ibcFunction_hpp_included -#define ibcFunction_hpp_included - -#include -#include -#include "../solver/field.hpp" - -/** - * \struct bc - * \brief Mathematical function for a boundary condition. - */ -struct ibc -{ - std::vector coefficients; /**< Coefficient for the mathematical function */ - std::function& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs)> ibcFunc; - /**< Pointer to the mathematical function */ -}; - -#endif // ibcFunction_hpp_included - diff --git a/srcs/physics/linShallowWater/boundaryCondition.cpp b/srcs/physics/linShallowWater/boundaryCondition.cpp deleted file mode 100644 index c7c39e1..0000000 --- a/srcs/physics/linShallowWater/boundaryCondition.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include -#include -#include "boundaryCondition.hpp" - -#include - -// see .hpp file for description -void sinusShallowLin(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough values - assert(field.u.size() == uAtIBC.size()); - assert(coeffs.size() == 4); - - // compute a physical reflection - double g = fluxCoeffs[0]; - double h0 = fluxCoeffs[1]; - double H = coeffs[0]*sin(2*M_PI*coeffs[1]*t + coeffs[2])+coeffs[3]; - double alpha = (edgeNormal[0]*field.u[1][indexJ] - + edgeNormal[1]*field.u[2][indexJ])/h0 - - sqrt(g/H)*(field.u[0][indexJ] - H); - - uAtIBC[0] = H; - uAtIBC[1] = alpha*edgeNormal[0]; - uAtIBC[2] = alpha*edgeNormal[1]; -} - - -// see .hpp file for description -void reflectShallowLin(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - - // check that there is enough values - assert(field.u.size() == uAtIBC.size()); - - // compute a physical reflection - uAtIBC[0] = field.u[0][indexJ]; - uAtIBC[1] = (-2*edgeNormal[0]*edgeNormal[0]+1)*field.u[1][indexJ] - -2*edgeNormal[0]*edgeNormal[1]*field.u[2][indexJ]; - uAtIBC[2] = (-2*edgeNormal[1]*edgeNormal[1]+1)*field.u[2][indexJ] - -2*edgeNormal[0]*edgeNormal[1]*field.u[1][indexJ]; -} - -// see .hpp file for description -void openShallowLin(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough values - assert(field.u.size() == uAtIBC.size()); - - // compute a physical reflection - double g = fluxCoeffs[0]; - double h0 = fluxCoeffs[1]; - double H = coeffs[0]; - double alpha = (edgeNormal[0]*field.u[1][indexJ] - + edgeNormal[1]*field.u[2][indexJ])/h0 - - sqrt(g/H)*(field.u[0][indexJ] - H); - - uAtIBC[0] = H; - uAtIBC[1] = alpha*edgeNormal[0]; - uAtIBC[2] = alpha*edgeNormal[1]; -} - -// see .hpp file for description -void gaussian2DShallowLin(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough coefficients - assert(coeffs.size() == 6); - assert(pos.size() == 3); - - // compute a 2D gaussian - double X = (pos[0]-coeffs[1])*(pos[0]-coeffs[1])/(2*coeffs[2]); - double Y = (pos[1]-coeffs[3])*(pos[1]-coeffs[3])/(2*coeffs[4]); - - uAtIBC[0] = coeffs[0]*exp(-(X+Y))+coeffs[5]; - uAtIBC[1] = 0; - uAtIBC[2] = 0; -} - -// see .hpp file for description -void gaussian1DShallowXLin(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough coefficients - assert(coeffs.size() == 4); - assert(pos.size() == 3); - - // compute a 1D gaussian along x - double X = (pos[0]-coeffs[1])*(pos[0]-coeffs[1])/(2*coeffs[2]); - - uAtIBC[0] = coeffs[0]*exp(-(X))+coeffs[3]; - uAtIBC[1] = 0; - uAtIBC[2] = 0; -} - - -// see .hpp file for description -void gaussian1DShallowYLin(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough coefficients - assert(coeffs.size() == 4); - assert(pos.size() == 3); - - // compute a 1D gaussian along y - double Y = (pos[1]-coeffs[1])*(pos[1]-coeffs[1])/(2*coeffs[2]); - - uAtIBC[0] = coeffs[0]*exp(-(Y))+coeffs[3]; - uAtIBC[1] = 0; - uAtIBC[2] = 0; -} - diff --git a/srcs/physics/linShallowWater/boundaryCondition.hpp b/srcs/physics/linShallowWater/boundaryCondition.hpp deleted file mode 100644 index 82ecc0a..0000000 --- a/srcs/physics/linShallowWater/boundaryCondition.hpp +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef linShallow_boundaryCondition_hpp_included -#define linShallow_boundaryCondition_hpp_included - -#include -#include "../../solver/field.hpp" - - - -/** - * \brief Compute a wave of the shape A*sin(2*pi*nu*t + phi) + B -- for the - * linear shallow water. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficients for the sinus: coeffs[0] = A, coeffs[1] = nu, - * coeffs[2] = phi, coeffs[3] = B. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void sinusShallowLin(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a physical reflection -- for linear shallow waters. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficient (not used here). - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void reflectShallowLin(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a physical opening -- for linear shallow waters. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param u The current solution. - * \param t Current time. - * \param coeffs Coefficient (not used here). - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void openShallowLin(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a 2D gaussian: A*exp(-(x-x0)^2/(2*var_y)-(y-y0)^2/(2*var_y)) -- for - * linear shallow waters - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficients for the gaussian: coeffs[0] = A, coeffs[1] = x_0, - * coeffs[2] = var_x, coeffs[3] = y_0, coeffs[4] = var_y. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void gaussian2DShallowLin(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a 1D gaussian along x: A*exp(-(x-x0)^2/(2*var_x) + B -- for linear - * shallow waters. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficients for the gaussian: coeffs[0] = A, coeffs[1] = x_0, - * coeffs[2] = var_x, coeffs[3] = B. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void gaussian1DShallowXLin(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - - -/** - * \brief Compute a 1D gaussian along y: A*exp(-(y-y0)^2/(2*var_y) + B -- for linear - * shallow waters. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficients for the gaussian: coeffs[0] = A, coeffs[1] = y_0, - * coeffs[2] = var_y, coeffs[3] = B. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void gaussian1DShallowYLin(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - - -#endif // linShallow_boundaryCondition_hpp_included diff --git a/srcs/physics/linShallowWater/flux.cpp b/srcs/physics/linShallowWater/flux.cpp deleted file mode 100644 index 57143f5..0000000 --- a/srcs/physics/linShallowWater/flux.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "flux.hpp" - -// see .hpp file for description -void fluxShallowLin(Field& field, PartialField& partialField, - const SolverParams& solverParams, bool boundary) -{ - - // the physical flux is given by - // Fx = [h0*u, g*h0*H, 0 ] - // Fy = [h0*v, 0, g*h_0*h ] - - if(boundary) - { - // flux for the (x, y) coordinates for H - partialField.FluxAtBC[0][0] = partialField.uAtBC[1]; - partialField.FluxAtBC[1][0] = partialField.uAtBC[2]; - - // flux for the (x, y) coordinates for H*u - partialField.FluxAtBC[0][1] = solverParams.fluxCoeffs[0] - *partialField.uAtBC[0]*solverParams.fluxCoeffs[1]; - partialField.FluxAtBC[0][2] = 0.0; - - // flux for the (x, y) coordinates for H*v - partialField.FluxAtBC[1][1] = 0.0; - partialField.FluxAtBC[1][2] = solverParams.fluxCoeffs[0] - *partialField.uAtBC[0]*solverParams.fluxCoeffs[1]; - } - else - { - if (field.u[0].minCoeff() <= 0) - { - std::cerr << "WARNING: Negative height or division by 0 !" << std::endl; - } - - // flux for the (x, y) coordinates for H - field.flux[0][0] = field.u[1]; - field.flux[1][0] = field.u[2]; - - // flux for the (x, y) coordinates for u - field.flux[0][1] = solverParams.fluxCoeffs[0]*solverParams.fluxCoeffs[1] - *field.u[0]; - // field.flux[0][2] = Eigen::VectorXd::Zero(field.u[0].size()); - - // flux for the (x, y) coordinates for v - // field.flux[1][1] = Eigen::VectorXd::Zero(field.u[0].size()); - field.flux[1][2] = solverParams.fluxCoeffs[0]*solverParams.fluxCoeffs[1] - *field.u[0]; - } -} diff --git a/srcs/physics/linShallowWater/flux.hpp b/srcs/physics/linShallowWater/flux.hpp deleted file mode 100644 index 77cf057..0000000 --- a/srcs/physics/linShallowWater/flux.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef linShallow_flux_hpp_included -#define linShallow_flux_hpp_included - -#include "../../params/Params.hpp" -#include "../../solver/field.hpp" - - -/** - * \brief Function that computes the physical flux for the linearized shallow water - * equations. - * \param field Structure containing all the information about the computed unknowns. - * \param partialField Structure containing temporary unknowns. - * \param solverParams Structure containing the solver's parameters. - * \param boundary Boolean that specifies if we consider a boundary (1) or not (0). - */ -void fluxShallowLin(Field& field, PartialField& partialField, - const SolverParams& solverParams, bool boundary); - -#endif // linShallow_flux_hpp_included diff --git a/srcs/physics/linShallowWater/phiPsi.cpp b/srcs/physics/linShallowWater/phiPsi.cpp deleted file mode 100644 index 339bf0f..0000000 --- a/srcs/physics/linShallowWater/phiPsi.cpp +++ /dev/null @@ -1,166 +0,0 @@ -#include "phiPsi.hpp" - -// see .hpp file for description -void LFShallowLin(const Edge& edge, Field& field, PartialField& partialField, - unsigned int j, double factor, bool boundary, unsigned int indexJ, - unsigned int indexFrontJ, const SolverParams& solverParams) -{ - // gravity parameter - double g = solverParams.fluxCoeffs[0]; - - // computation of the absolute value of the eigenvalue lambda inside the element - double lambdaIn = (field.u[1][indexJ]*edge.normal[0] - + field.u[2][indexJ]*edge.normal[1])/field.u[0][indexJ]; - - lambdaIn = (lambdaIn >= 0) ? lambdaIn + sqrt(g*field.u[0][indexJ]) : - -lambdaIn + sqrt(g*field.u[0][indexJ]); - - double lambdaOut; - - // compute the numerical flux - if(boundary) - { - // computation of the absolute value of the eigenvalue outside the element - lambdaOut = (partialField.uAtBC[1]*edge.normal[0] - + partialField.uAtBC[2]*edge.normal[1])/partialField.uAtBC[0]; - - lambdaOut = (lambdaOut >= 0) ? lambdaOut + sqrt(g*partialField.uAtBC[0]) : - -lambdaOut + sqrt(g*partialField.uAtBC[0]); - - // computation of the value of C in the LF scheme - double C = (lambdaIn > lambdaOut ? lambdaIn : lambdaOut); - - //computation of g - for(unsigned short dim = 0 ; dim < partialField.g.size() ; ++dim) - { - for(unsigned short unk = 0 ; unk < partialField.g[dim].size() ; ++unk) - { - partialField.g[dim][unk][edge.offsetInElm[j]] += - -(factor*field.flux[dim][unk][indexJ] - + partialField.FluxAtBC[dim][unk] - + C*edge.normal[dim]*(field.u[unk][indexJ] - - partialField.uAtBC[unk]))/2; - } - } - } - else - { - // computation of the absolute value of the eigenvalue outside the element - lambdaOut = (field.u[1][indexFrontJ]*edge.normal[0] - + field.u[2][indexFrontJ]*edge.normal[1]) - /field.u[0][indexFrontJ]; - - lambdaOut = (lambdaOut >= 0) ? lambdaOut + sqrt(g*field.u[0][indexFrontJ]) : - -lambdaOut + sqrt(g*field.u[0][indexFrontJ]); - - // computation of the value of C in the LF scheme - double C = (lambdaIn > lambdaOut ? lambdaIn : lambdaOut); - - //computation of g - for(unsigned short dim = 0 ; dim < partialField.g.size() ; ++dim) - { - for(unsigned short unk = 0 ; unk < partialField.g[dim].size() ; ++unk) - { - partialField.g[dim][unk][edge.offsetInElm[j]] += - -(factor*field.flux[dim][unk][indexJ] - + field.flux[dim][unk][indexFrontJ] - + C*edge.normal[dim]*(field.u[unk][indexJ] - - field.u[unk][indexFrontJ]))/2; - } - } - } -} - - -// see .hpp file for description -void RoeLin(const Edge& edge, Field& field, PartialField& partialField, unsigned int j, - double factor, bool boundary, unsigned int indexJ, - unsigned int indexFrontJ, const SolverParams& solverParams) -{ - // gravity parameter - double g = solverParams.fluxCoeffs[0]; - - double hJSqrt, hFrontJSqrt, uRoe, vRoe, cRoe; - - // compute the numerical flux - if(boundary) - { - // compute the Roe averages - hJSqrt = sqrt(field.u[0][indexJ]); - hFrontJSqrt = sqrt(partialField.uAtBC[0]); - - uRoe = ((field.u[1][indexJ]/field.u[0][indexJ])*hJSqrt - + (partialField.uAtBC[1]/partialField.uAtBC[0])*hFrontJSqrt) - /(hJSqrt + hFrontJSqrt); - - vRoe = ((field.u[2][indexJ]/field.u[0][indexJ])*hJSqrt - + (partialField.uAtBC[2]/partialField.uAtBC[0])*hFrontJSqrt) - /(hJSqrt + hFrontJSqrt); - - cRoe = sqrt(g*(field.u[0][indexJ] + partialField.uAtBC[0])/2); - - // compute the (limited) Froude number - double Fr = (uRoe*edge.normal[0] + vRoe*edge.normal[1])/cRoe; - if(Fr < -1.0) - { - Fr = -1.0; - } - else if(Fr > 1.0) - { - Fr = 1.0; - } - - //computation of g - for(unsigned short dim = 0 ; dim < partialField.g.size() ; ++dim) - { - for(unsigned short unk = 0 ; unk < partialField.g[dim].size() ; ++unk) - { - partialField.g[dim][unk][edge.offsetInElm[j]] += - -((Fr + factor)*field.flux[dim][unk][indexJ]+ - (1 - Fr)*partialField.FluxAtBC[dim][unk] - + cRoe*(1-Fr*Fr)*edge.normal[dim]*(field.u[unk][indexJ] - - partialField.uAtBC[unk]))/2; - } - } - } - else - { - // compute the Roe averages - hJSqrt = sqrt(field.u[0][indexJ]); - hFrontJSqrt = sqrt(field.u[0][indexFrontJ]); - - uRoe = ((field.u[1][indexJ]/field.u[0][indexJ])*hJSqrt - + (field.u[1][indexFrontJ]/field.u[0][indexFrontJ]) - *hFrontJSqrt)/(hJSqrt + hFrontJSqrt); - - vRoe = ((field.u[2][indexJ]/field.u[0][indexJ])*hJSqrt - + (field.u[2][indexFrontJ]/field.u[0][indexFrontJ]) - *hFrontJSqrt)/(hJSqrt + hFrontJSqrt); - - cRoe = sqrt(g*(field.u[0][indexJ] + field.u[0][indexFrontJ])/2); - - // compute the (limited) Froude number - double Fr = (uRoe*edge.normal[0] + vRoe*edge.normal[1])/cRoe; - if(Fr < -1.0) - { - Fr = -1.0; - } - else if(Fr > 1.0) - { - Fr = 1.0; - } - - //computation of g - for(unsigned short dim = 0 ; dim < partialField.g.size() ; ++dim) - { - for(unsigned short unk = 0 ; unk < partialField.g[dim].size() ; ++unk) - { - partialField.g[dim][unk][edge.offsetInElm[j]] += - -((Fr + factor)*field.flux[dim][unk][indexJ]+ - (1 - Fr)*field.flux[dim][unk][indexFrontJ] - + cRoe*(1 - Fr*Fr)*edge.normal[dim]*(field.u[unk][indexJ] - - field.u[unk][indexFrontJ]))/2; - } - } - } -} diff --git a/srcs/physics/linShallowWater/phiPsi.hpp b/srcs/physics/linShallowWater/phiPsi.hpp deleted file mode 100644 index 6768585..0000000 --- a/srcs/physics/linShallowWater/phiPsi.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef linShallow_phiPsi_hpp_included -#define linShallow_phiPsi_hpp_included - -#include "../../mesh/Mesh.hpp" -#include "../../params/Params.hpp" -#include "../../solver/field.hpp" - - -/** - * \brief Function that computes the numerical LF flux for shallow waters. - * \param edge Edge of the current node (useful for the normal & the offset index). - * \param field Structure containing the current unknowns of the DG-FEM. - * \param partialField Structure containing temporary unknowns - * (like here, the fluxes at the boundary). - * \param j Index of the current node, with respect to the current element. - * \param factor Parameter that determines the weak (+1) or strong form (-1). - * \param boundary Boolean that specifies if we consider a boundary (1) or not (0). - * \param indexJ Index of the current node, with respect to the whole mesh. - * \param indexFrontJ Index of the oppsoite node, with respect to the whole mesh. - * \param solverParams Structure containing the solver's parameters. - */ -void LFShallowLin(const Edge& edge, Field& field, PartialField& partialField, unsigned int j, double factor, - bool boundary, unsigned int indexJ, unsigned int indexFrontJ, - const SolverParams& solverParams); - - -/** - * \brief Function that computes the numerical Roe flux for shallow waters. - * \param edge Edge of the current node (useful for the normal & the offset index). - * \param field Structure containing the current unknowns of the DG-FEM. - * \param partialField Structure containing temporary unknowns - * (like here, the fluxes at the boundary). - * \param j Index of the current node, with respect to the current element. - * \param factor Parameter that determines the weak (+1) or strong form (-1). - * \param boundary Boolean that specifies if we consider a boundary (1) or not (0). - * \param indexJ Index of the current node, with respect to the whole mesh. - * \param indexFrontJ Index of the oppsoite node, with respect to the whole mesh. - * \param solverParams Structure containing the solver's parameters. - */ -void RoeLin(const Edge& edge, Field& field, PartialField& partialField, unsigned int j, - double factor, bool boundary, unsigned int indexJ, - unsigned int indexFrontJ, const SolverParams& solverParams); - - -#endif // linShallow_phiPsi_hpp_included diff --git a/srcs/physics/linShallowWater/source.cpp b/srcs/physics/linShallowWater/source.cpp deleted file mode 100644 index c89634e..0000000 --- a/srcs/physics/linShallowWater/source.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "source.hpp" - - -// see .hpp file for description -void sourceShallowLinCst(Field& field, const SolverParams& solverParams) -{ - field.s[0].setZero(); - - field.s[1] = solverParams.sourceCoeffs[0]*solverParams.fluxCoeffs[1]*field.u[2]; - - field.s[2] = -solverParams.sourceCoeffs[0]*solverParams.fluxCoeffs[1]*field.u[1]; -} - diff --git a/srcs/physics/linShallowWater/source.hpp b/srcs/physics/linShallowWater/source.hpp deleted file mode 100644 index 3b3033c..0000000 --- a/srcs/physics/linShallowWater/source.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef linShallow_source_hpp_included -#define linShallow_source_hpp_included - -#include -#include "../../params/Params.hpp" -#include "../../solver/field.hpp" - - -/** - * \brief Function that computes the source term of the shallow water equation - * (coriolis). - * \param field Structure containing all the information about the computed unknowns. - * \param solverParams Structure containing the solver's parameters. - */ -void sourceShallowLinCst(Field& field, const SolverParams& solverParams); - -#endif // linShallow_source_hpp_included diff --git a/srcs/physics/linShallowWater/writer.cpp b/srcs/physics/linShallowWater/writer.cpp deleted file mode 100644 index df7ad45..0000000 --- a/srcs/physics/linShallowWater/writer.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include -#include "writer.hpp" - -void writeShallowLin(std::vector>& uDisplay, - const std::vector& elementNumNodes, - const std::vector& elementTags, - const std::string& modelName, unsigned int nbreStep, double t, - const Field& field, const std::vector& fluxCoeffs, - const std::vector& whatToWrite, std::vector& viewTags) -{ - if(nbreStep == 0) - { - if(whatToWrite[0] == true) - viewTags[0] = gmsh::view::add("H"); - - if(whatToWrite[1] == true) - viewTags[1] = gmsh::view::add("u"); - - if(whatToWrite[2] == true) - viewTags[2] = gmsh::view::add("v"); - - if(whatToWrite[3] == true) - viewTags[3] = gmsh::view::add("Specific KE"); - - if(whatToWrite[4] == true) - viewTags[4] = gmsh::view::add("Velocity Field"); - } - - if(whatToWrite[0] == true) - { - unsigned int offset = 0; - for(size_t count = 0 ; count < elementNumNodes.size() ; ++count) - { - std::vector temp(elementNumNodes[count]); - for (unsigned int countLocal = 0; countLocal < elementNumNodes[count]; - ++countLocal) - { - temp[countLocal] = field.u[0][countLocal+offset]; - } - offset += elementNumNodes[count]; - uDisplay[count] = std::move(temp); - } - - gmsh::view::addModelData(viewTags[0], nbreStep, modelName, - "ElementNodeData", elementTags, uDisplay, t, 1); - } - - if(whatToWrite[1] == true) - { - unsigned int offset = 0; - for(size_t count = 0 ; count < elementNumNodes.size() ; ++count) - { - std::vector temp(elementNumNodes[count]); - for (unsigned int countLocal = 0; countLocal < elementNumNodes[count]; - ++countLocal) - { - temp[countLocal] = field.u[1][countLocal+offset]/fluxCoeffs[0]; - } - offset += elementNumNodes[count]; - uDisplay[count] = std::move(temp); - } - - gmsh::view::addModelData(viewTags[1], nbreStep, modelName, - "ElementNodeData", elementTags, uDisplay, t, 1); - } - - if(whatToWrite[2] == true) - { - unsigned int offset = 0; - for(size_t count = 0 ; count < elementNumNodes.size() ; ++count) - { - std::vector temp(elementNumNodes[count]); - for (unsigned int countLocal = 0; countLocal < elementNumNodes[count]; - ++countLocal) - { - temp[countLocal] = field.u[2][countLocal+offset]/fluxCoeffs[0]; - } - offset += elementNumNodes[count]; - uDisplay[count] = std::move(temp); - } - - gmsh::view::addModelData(viewTags[2], nbreStep, modelName, - "ElementNodeData", elementTags, uDisplay, t, 1); - } - - if(whatToWrite[3] == true) - { - unsigned int offset = 0; - for(size_t count = 0 ; count < elementNumNodes.size() ; ++count) - { - std::vector temp(elementNumNodes[count]); - for (unsigned int countLocal = 0; countLocal < elementNumNodes[count]; - ++countLocal) - { - temp[countLocal] = - 0.5*(field.u[1][countLocal+offset]*field.u[1][countLocal+offset] - +field.u[2][countLocal+offset]*field.u[2][countLocal+offset]) - /(fluxCoeffs[0]*fluxCoeffs[0]); - } - offset += elementNumNodes[count]; - uDisplay[count] = std::move(temp); - } - - gmsh::view::addModelData(viewTags[3], nbreStep, modelName, - "ElementNodeData", elementTags, uDisplay, t, 1); - } - - if(whatToWrite[4] == true) - { - unsigned int offset = 0; - for(size_t count = 0 ; count < elementNumNodes.size() ; ++count) - { - std::vector temp(3*elementNumNodes[count]); - for (unsigned int countLocal = 0; countLocal < elementNumNodes[count]; - ++countLocal) - { - temp[3*countLocal] = field.u[1][countLocal+offset] - /fluxCoeffs[0]; - - temp[3*countLocal+1] = field.u[2][countLocal+offset] - /fluxCoeffs[0]; - - temp[3*countLocal+2] = 0; - } - offset += elementNumNodes[count]; - uDisplay[count] = std::move(temp); - } - - gmsh::view::addModelData(viewTags[4], nbreStep, modelName, - "ElementNodeData", elementTags, uDisplay, t, 3); - } -} diff --git a/srcs/physics/linShallowWater/writer.hpp b/srcs/physics/linShallowWater/writer.hpp deleted file mode 100644 index 1ab938d..0000000 --- a/srcs/physics/linShallowWater/writer.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef linShallow_writer_hpp_included -#define linShallow_writer_hpp_included - -#include -#include "../../solver/field.hpp" -#include "../../params/Params.hpp" - - -/** - * \brief Write data for linear shallow waters. You can write H, u, v, 0.*(u²+v²) - * or the velocity field (boolean in whatToWrite). - * \param uDisplay Vector (per element) of vector (per nodes) to write the data. - * \param elementNumNodes Vector containg the number of nodes per element. - * \param elementTags Vector containing the tag of all elements. - * \param modelName Name of the model. - * \param nbreStep Current time step. - * \param t Current simulation physical time. - * \param field Structure that contains all the main variables. - * \param fluxCoeffs Coefficient of the physical flux. - * \param whatToWrite Vector containing boolean describing which unknown to write. - * \param viewTags Vector containing the rag of the different writing data's. - */ -void writeShallowLin(std::vector>& uDisplay, - const std::vector& elementNumNodes, - const std::vector& elementTags, - const std::string& modelName, unsigned int nbreStep, double t, - const Field& field, const std::vector& fluxCoeffs, - const std::vector& whatToWrite, std::vector& viewTags); - -#endif /* linShallow_writer_hpp_included */ diff --git a/srcs/physics/meanPhiPsi.cpp b/srcs/physics/meanPhiPsi.cpp deleted file mode 100644 index 0d0a75a..0000000 --- a/srcs/physics/meanPhiPsi.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "meanPhiPsi.hpp" - -void mean(const Edge& edge, Field& field, PartialField& partialField, unsigned int j, double factor, - bool boundary, unsigned int indexJ, unsigned int indexFrontJ, - const SolverParams& solverParams) -{ - - // compute the numerical flux - if(boundary) - { - //computation of g - for(unsigned short dim = 0 ; dim < partialField.g.size() ; ++dim) - { - for(unsigned short unk = 0 ; unk < partialField.g[dim].size() ; ++unk) - { - partialField.g[dim][unk][edge.offsetInElm[j]] += - -(factor*field.flux[dim][unk][indexJ] - + partialField.FluxAtBC[dim][unk])/2; - } - } - } - else - { - //computation of g - for(unsigned short dim = 0 ; dim < partialField.g.size() ; ++dim) - { - for(unsigned short unk = 0 ; unk < partialField.g[dim].size() ; ++unk) - { - partialField.g[dim][unk][edge.offsetInElm[j]] += - -(factor*field.flux[dim][unk][indexJ] - + field.flux[dim][unk][indexFrontJ])/2; - } - } - } -} diff --git a/srcs/physics/meanPhiPsi.hpp b/srcs/physics/meanPhiPsi.hpp deleted file mode 100644 index e811dcf..0000000 --- a/srcs/physics/meanPhiPsi.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef meanPhiPsi_hpp_included -#define meanPhiPsi_hpp_included - -#include "../mesh/Mesh.hpp" -#include "../params/Params.hpp" -#include "../solver/field.hpp" - -/** - * \brief Function that computes the numerical mean flux. - * \param edge Edge of the current node (useful for the normal & the offset index). - * \param field Structure containing the current unknowns of the DG-FEM. - * \param partialField Structure containing temporary unknowns - * (like here, the fluxes at the boundary). - * \param j Index of the current node, with respect to the current element. - * \param factor Parameter that determines the weak (+1) or strong form (-1). - * \param boundary Boolean that specifies if we consider a boundary (1) or not (0). - * \param indexJ Index of the current node, with respect to the whole mesh. - * \param indexFrontJ Index of the oppsoite node, with respect to the whole mesh. - * \param solverParams Structure containing the solver's parameters. - */ -void mean(const Edge& edge, Field& field, PartialField& partialField, unsigned int j, - double factor, bool boundary, unsigned int indexJ, - unsigned int indexFrontJ, const SolverParams& solverParams); - - -#endif // meanPhiPsi_hpp_included diff --git a/srcs/physics/phiPsis.hpp b/srcs/physics/phiPsis.hpp deleted file mode 100644 index 101512d..0000000 --- a/srcs/physics/phiPsis.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef phiPsis_hpp_included -#define phiPsis_hpp_included - -#include "meanPhiPsi.hpp" -#include "linShallowWater/phiPsi.hpp" -#include "shallowWater/phiPsi.hpp" -#include "transport/phiPsi.hpp" - -#endif // phiPsis_hpp_included diff --git a/srcs/physics/shallowWater/boundaryCondition.cpp b/srcs/physics/shallowWater/boundaryCondition.cpp deleted file mode 100644 index 5ae642e..0000000 --- a/srcs/physics/shallowWater/boundaryCondition.cpp +++ /dev/null @@ -1,188 +0,0 @@ -#include -#include -#include "boundaryCondition.hpp" - -#include - -// see .hpp file for description -void reflectShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - - // check that there is enough values - assert(field.u.size() == uAtIBC.size()); - - // compute a physical reflection - uAtIBC[0] = field.u[0][indexJ]; - uAtIBC[1] = (-2*edgeNormal[0]*edgeNormal[0]+1)*field.u[1][indexJ] - -2*edgeNormal[0]*edgeNormal[1]*field.u[2][indexJ]; - uAtIBC[2] = (-2*edgeNormal[1]*edgeNormal[1]+1)*field.u[2][indexJ] - -2*edgeNormal[0]*edgeNormal[1]*field.u[1][indexJ]; -} - - -// see .hpp file for description -void openShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough values - assert(field.u.size() == uAtIBC.size()); - - // compute a physical reflection - double g = fluxCoeffs[0]; - double H = coeffs[0]; - double alpha = (edgeNormal[0]*field.u[1][indexJ] - + edgeNormal[1]*field.u[2][indexJ])/field.u[0][indexJ] - - sqrt(g/H)*(field.u[0][indexJ] - H); - - uAtIBC[0] = H; - uAtIBC[1] = alpha*edgeNormal[0]; - uAtIBC[2] = alpha*edgeNormal[1]; -} - -// see .hpp file for description -void openAffShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough values - assert(field.u.size() == uAtIBC.size()); - - // compute a physical reflection - double g = fluxCoeffs[0]; - double H = coeffs[0]*pos[0] + coeffs[1]*pos[1] + coeffs[2];; - double alpha = (edgeNormal[0]*field.u[1][indexJ] - + edgeNormal[1]*field.u[2][indexJ])/field.u[0][indexJ] - - sqrt(g/H)*(field.u[0][indexJ] - H); - - uAtIBC[0] = H; - uAtIBC[1] = alpha*edgeNormal[0]; - uAtIBC[2] = alpha*edgeNormal[1]; -} - -// see .hpp file for description -void affineShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - uAtIBC[0] = coeffs[0]*pos[0] + coeffs[1]*pos[1] + coeffs[2]; - uAtIBC[1] = 0; - uAtIBC[2] = 0; -} - -// see .hpp file for description -void sinusShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough values - assert(field.u.size() == uAtIBC.size()); - assert(coeffs.size() == 4); - - // compute a physical reflection - double g = fluxCoeffs[0]; - double H = coeffs[0]*sin(2*M_PI*coeffs[1]*t + coeffs[2]) + coeffs[3]; - double alpha = (edgeNormal[0]*field.u[1][indexJ] - + edgeNormal[1]*field.u[2][indexJ])/field.u[0][indexJ] - - sqrt(g/H)*(field.u[0][indexJ] - H); - - uAtIBC[0] = H; - uAtIBC[1] = alpha*edgeNormal[0]; - uAtIBC[2] = alpha*edgeNormal[1]; -} - -// see .hpp file for description -void sinusAffShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough values - assert(field.u.size() == uAtIBC.size()); - assert(coeffs.size() == 6); - - // compute a physical reflection - double g = fluxCoeffs[0]; - double H = coeffs[0]*sin(2*M_PI*coeffs[1]*t + coeffs[2]) + coeffs[3] - + coeffs[4]*pos[0] + coeffs[5]*pos[1]; - double alpha = (edgeNormal[0]*field.u[1][indexJ] - + edgeNormal[1]*field.u[2][indexJ])/field.u[0][indexJ] - - sqrt(g/H)*(field.u[0][indexJ] - H); - - uAtIBC[0] = H; - uAtIBC[1] = alpha*edgeNormal[0]; - uAtIBC[2] = alpha*edgeNormal[1]; -} - -// see .hpp file for description -void gaussian2DShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough coefficients - assert(coeffs.size() == 6); - assert(pos.size() == 3); - - // compute a 2D gaussian - double X = (pos[0]-coeffs[1])*(pos[0]-coeffs[1])/(2*coeffs[2]); - double Y = (pos[1]-coeffs[3])*(pos[1]-coeffs[3])/(2*coeffs[4]); - - uAtIBC[0] = coeffs[0]*exp(-(X+Y))+coeffs[5]; - uAtIBC[1] = 0; - uAtIBC[2] = 0; -} - - -// see .hpp file for description -void gaussian1DShallowX(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough coefficients - assert(coeffs.size() == 4); - assert(pos.size() == 3); - - // compute a 1D gaussian along x - double X = (pos[0]-coeffs[1])*(pos[0]-coeffs[1])/(2*coeffs[2]); - - uAtIBC[0] = coeffs[0]*exp(-(X))+coeffs[3]; - uAtIBC[1] = 0; - uAtIBC[2] = 0; -} - - -// see .hpp file for description -void gaussian1DShallowY(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough coefficients - assert(coeffs.size() == 4); - assert(pos.size() == 3); - - // compute a 1D gaussian along y - double Y = (pos[1]-coeffs[1])*(pos[1]-coeffs[1])/(2*coeffs[2]); - - uAtIBC[0] = coeffs[0]*exp(-(Y))+coeffs[3]; - uAtIBC[1] = 0; - uAtIBC[2] = 0; -} diff --git a/srcs/physics/shallowWater/boundaryCondition.hpp b/srcs/physics/shallowWater/boundaryCondition.hpp deleted file mode 100644 index de2ece7..0000000 --- a/srcs/physics/shallowWater/boundaryCondition.hpp +++ /dev/null @@ -1,160 +0,0 @@ -#ifndef shallow_boundaryCondition_hpp_included -#define shallow_boundaryCondition_hpp_included - -#include -#include "../../solver/field.hpp" - - - -/** - * \brief Compute a wave of the shape A*sin(2*pi*nu*t + phi) + B -- for the - * shallow water. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficients for the sinus: coeffs[0] = A, coeffs[1] = nu, - * coeffs[2] = phi, coeffs[3] = B. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void sinusShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a physical opening -- for shallow waters. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param u The current solution. - * \param t Current time. - * \param coeffs Coefficient, coeffs[0] = H away from the BC. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void openAffShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a linear initial condtion -- for shallow waters. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param u The current solution. - * \param t Current time. - * \param coeffs Coefficient, coeffs[0] = dh/dx, coeffs[0] = dh/dy, coeffs[0] = offset. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void affineShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a sinus BC when there is a seabed gradient -- for shallow waters. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param u The current solution. - * \param t Current time. - * \param coeffs Coefficient, coeffs[0] = A , coeffs[1] = f , coeffs[2] = phi, - coeffs[3] = offset, coeffs[] = dh/dx, coeffs[0] = dh/dy - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void sinusAffShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a physical reflection -- for shallow waters. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficient (not used here). - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void reflectShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a physical opening -- for shallow waters. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param u The current solution. - * \param t Current time. - * \param coeffs Coefficient (not used here). - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void openShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a 2D gaussian: A*exp(-(x-x0)^2/(2*var_y)-(y-y0)^2/(2*var_y)) -- for - * shallow waters - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficients for the gaussian: coeffs[0] = A, coeffs[1] = x_0, - * coeffs[2] = var_x, coeffs[3] = y_0, coeffs[4] = var_y. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void gaussian2DShallow(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a 1D gaussian along x: A*exp(-(x-x0)^2/(2*var_x) + B -- for shallow - * waters. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficients for the gaussian: coeffs[0] = A, coeffs[1] = x_0, - * coeffs[2] = var_x, coeffs[3] = B. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void gaussian1DShallowX(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - - -/** - * \brief Compute a 1D gaussian along y: A*exp(-(y-y0)^2/(2*var_y) + B -- for shallow - * waters. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficients for the gaussian: coeffs[0] = A, coeffs[1] = y_0, - * coeffs[2] = var_y, coeffs[3] = B. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void gaussian1DShallowY(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - - -#endif // shallow_boundaryCondition_hpp_included diff --git a/srcs/physics/shallowWater/flux.cpp b/srcs/physics/shallowWater/flux.cpp deleted file mode 100644 index 09459ec..0000000 --- a/srcs/physics/shallowWater/flux.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include "flux.hpp" - -void fluxShallow(Field& field, PartialField& partialField, - const SolverParams& solverParams, bool boundary) -{ - // gravity parameter - double g = solverParams.fluxCoeffs[0]; - - // the physical flux is given by - // Fx = [H*u, H*u^2 + g*H^2/2, H*u*v ] - // Fy = [H*v, H*u*v, H*v^2 + g*H ] - - if(boundary) - { - // flux for the (x, y) coordinates for H - partialField.FluxAtBC[0][0] = partialField.uAtBC[1]; - partialField.FluxAtBC[1][0] = partialField.uAtBC[2]; - - // flux for the (x, y) coordinates for H*u - partialField.FluxAtBC[0][1] = partialField.uAtBC[1]*partialField.uAtBC[1] - /partialField.uAtBC[0] - + g/2*partialField.uAtBC[0]*partialField.uAtBC[0]; - partialField.FluxAtBC[0][2] = partialField.uAtBC[1]*partialField.uAtBC[2] - /partialField.uAtBC[0]; - - // flux for the (x, y) coordinates for H*v - partialField.FluxAtBC[1][1] = partialField.uAtBC[1]*partialField.uAtBC[2] - /partialField.uAtBC[0]; - partialField.FluxAtBC[1][2] = partialField.uAtBC[2]*partialField.uAtBC[2] - /partialField.uAtBC[0] - + g/2*partialField.uAtBC[0]*partialField.uAtBC[0]; - } - else - { - if (field.u[0].minCoeff() <= 0) - { - std::cerr << "WARNING: Negative height or division by 0 !" << std::endl; - } - - // flux for the (x, y) coordinates for H - field.flux[0][0] = field.u[1]; - field.flux[1][0] = field.u[2]; - - // flux for the (x, y) coordinates for H*u - field.flux[0][1] = field.u[1].array().square()/field.u[0].array() - + g/2*field.u[0].array().square(); - field.flux[0][2] = field.u[1].array()*field.u[2].array()/field.u[0].array(); - - // flux for the (x, y) coordinates for H*v - field.flux[1][1] = field.u[1].array()*field.u[2].array()/field.u[0].array(); - field.flux[1][2] = field.u[2].array().square()/field.u[0].array() - + g/2*field.u[0].array().square(); - } -} diff --git a/srcs/physics/shallowWater/flux.hpp b/srcs/physics/shallowWater/flux.hpp deleted file mode 100644 index ee096d5..0000000 --- a/srcs/physics/shallowWater/flux.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef shallow_flux_hpp_included -#define shallow_flux_hpp_included - -#include "../../params/Params.hpp" -#include "../../solver/field.hpp" - -/** - * \brief Function that computes the physical flux for the shallow water equations. - * \param field Structure containing all the information about the computed unknowns. - * \param partialField Structure containing temporary unknowns. - * \param solverParams Structure containing the solver's parameters. - * \param boundary Boolean that specifies if we consider a boundary (1) or not (0). - */ -void fluxShallow(Field& field, PartialField& partialField, - const SolverParams& solverParams, bool boundary); - -#endif // shallow_flux_hpp_included diff --git a/srcs/physics/shallowWater/phiPsi.cpp b/srcs/physics/shallowWater/phiPsi.cpp deleted file mode 100644 index 817740b..0000000 --- a/srcs/physics/shallowWater/phiPsi.cpp +++ /dev/null @@ -1,166 +0,0 @@ -#include "phiPsi.hpp" - -// see .hpp file for description -void LFShallow(const Edge& edge, Field& field, PartialField& partialField, - unsigned int j, double factor, bool boundary, unsigned int indexJ, - unsigned int indexFrontJ, const SolverParams& solverParams) -{ - // gravity parameter - double g = solverParams.fluxCoeffs[0]; - - // computation of the absolute value of the eigenvalue lambda inside the element - double lambdaIn = (field.u[1][indexJ]*edge.normal[0] - + field.u[2][indexJ]*edge.normal[1])/field.u[0][indexJ]; - - lambdaIn = (lambdaIn >= 0) ? lambdaIn + sqrt(g*field.u[0][indexJ]) : - -lambdaIn + sqrt(g*field.u[0][indexJ]); - - double lambdaOut; - - // compute the numerical flux - if(boundary) - { - // computation of the absolute value of the eigenvalue outside the element - lambdaOut = (partialField.uAtBC[1]*edge.normal[0] - + partialField.uAtBC[2]*edge.normal[1])/partialField.uAtBC[0]; - - lambdaOut = (lambdaOut >= 0) ? lambdaOut + sqrt(g*partialField.uAtBC[0]) : - -lambdaOut + sqrt(g*partialField.uAtBC[0]); - - // computation of the value of C in the LF scheme - double C = (lambdaIn > lambdaOut ? lambdaIn : lambdaOut); - - //computation of g - for(unsigned short dim = 0 ; dim < partialField.g.size() ; ++dim) - { - for(unsigned short unk = 0 ; unk < partialField.g[dim].size() ; ++unk) - { - partialField.g[dim][unk][edge.offsetInElm[j]] += - -(factor*field.flux[dim][unk][indexJ] - + partialField.FluxAtBC[dim][unk] - + C*edge.normal[dim]*(field.u[unk][indexJ] - - partialField.uAtBC[unk]))/2; - } - } - } - else - { - // computation of the absolute value of the eigenvalue outside the element - lambdaOut = (field.u[1][indexFrontJ]*edge.normal[0] - + field.u[2][indexFrontJ]*edge.normal[1]) - /field.u[0][indexFrontJ]; - - lambdaOut = (lambdaOut >= 0) ? lambdaOut + sqrt(g*field.u[0][indexFrontJ]) : - -lambdaOut + sqrt(g*field.u[0][indexFrontJ]); - - // computation of the value of C in the LF scheme - double C = (lambdaIn > lambdaOut ? lambdaIn : lambdaOut); - - //computation of g - for(unsigned short dim = 0 ; dim < partialField.g.size() ; ++dim) - { - for(unsigned short unk = 0 ; unk < partialField.g[dim].size() ; ++unk) - { - partialField.g[dim][unk][edge.offsetInElm[j]] += - -(factor*field.flux[dim][unk][indexJ] - + field.flux[dim][unk][indexFrontJ] - + C*edge.normal[dim]*(field.u[unk][indexJ] - - field.u[unk][indexFrontJ]))/2; - } - } - } -} - - -// see .hpp file for description -void Roe(const Edge& edge, Field& field, PartialField& partialField, unsigned int j, - double factor, bool boundary, unsigned int indexJ, - unsigned int indexFrontJ, const SolverParams& solverParams) -{ - // gravity parameter - double g = solverParams.fluxCoeffs[0]; - - double hJSqrt, hFrontJSqrt, uRoe, vRoe, cRoe; - - // compute the numerical flux - if(boundary) - { - // compute the Roe averages - hJSqrt = sqrt(field.u[0][indexJ]); - hFrontJSqrt = sqrt(partialField.uAtBC[0]); - - uRoe = ((field.u[1][indexJ]/field.u[0][indexJ])*hJSqrt - + (partialField.uAtBC[1]/partialField.uAtBC[0])*hFrontJSqrt) - /(hJSqrt + hFrontJSqrt); - - vRoe = ((field.u[2][indexJ]/field.u[0][indexJ])*hJSqrt - + (partialField.uAtBC[2]/partialField.uAtBC[0])*hFrontJSqrt) - /(hJSqrt + hFrontJSqrt); - - cRoe = sqrt(g*(field.u[0][indexJ] + partialField.uAtBC[0])/2); - - // compute the (limited) Froude number - double Fr = (uRoe*edge.normal[0] + vRoe*edge.normal[1])/cRoe; - if(Fr < -1.0) - { - Fr = -1.0; - } - else if(Fr > 1.0) - { - Fr = 1.0; - } - - //computation of g - for(unsigned short dim = 0 ; dim < partialField.g.size() ; ++dim) - { - for(unsigned short unk = 0 ; unk < partialField.g[dim].size() ; ++unk) - { - partialField.g[dim][unk][edge.offsetInElm[j]] += - -((Fr + factor)*field.flux[dim][unk][indexJ]+ - (1 - Fr)*partialField.FluxAtBC[dim][unk] - + cRoe*(1-Fr*Fr)*edge.normal[dim]*(field.u[unk][indexJ] - - partialField.uAtBC[unk]))/2; - } - } - } - else - { - // compute the Roe averages - hJSqrt = sqrt(field.u[0][indexJ]); - hFrontJSqrt = sqrt(field.u[0][indexFrontJ]); - - uRoe = ((field.u[1][indexJ]/field.u[0][indexJ])*hJSqrt - + (field.u[1][indexFrontJ]/field.u[0][indexFrontJ]) - *hFrontJSqrt)/(hJSqrt + hFrontJSqrt); - - vRoe = ((field.u[2][indexJ]/field.u[0][indexJ])*hJSqrt - + (field.u[2][indexFrontJ]/field.u[0][indexFrontJ]) - *hFrontJSqrt)/(hJSqrt + hFrontJSqrt); - - cRoe = sqrt(g*(field.u[0][indexJ] + field.u[0][indexFrontJ])/2); - - // compute the (limited) Froude number - double Fr = (uRoe*edge.normal[0] + vRoe*edge.normal[1])/cRoe; - if(Fr < -1.0) - { - Fr = -1.0; - } - else if(Fr > 1.0) - { - Fr = 1.0; - } - - //computation of g - for(unsigned short dim = 0 ; dim < partialField.g.size() ; ++dim) - { - for(unsigned short unk = 0 ; unk < partialField.g[dim].size() ; ++unk) - { - partialField.g[dim][unk][edge.offsetInElm[j]] += - -((Fr + factor)*field.flux[dim][unk][indexJ]+ - (1 - Fr)*field.flux[dim][unk][indexFrontJ] - + cRoe*(1 - Fr*Fr)*edge.normal[dim]*(field.u[unk][indexJ] - - field.u[unk][indexFrontJ]))/2; - } - } - } -} diff --git a/srcs/physics/shallowWater/phiPsi.hpp b/srcs/physics/shallowWater/phiPsi.hpp deleted file mode 100644 index 162ad36..0000000 --- a/srcs/physics/shallowWater/phiPsi.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef shallow_phiPsi_hpp_included -#define shallow_phiPsi_hpp_included - -#include "../../mesh/Mesh.hpp" -#include "../../params/Params.hpp" -#include "../../solver/field.hpp" - - -/** - * \brief Function that computes the numerical LF flux for shallow waters. - * \param edge Edge of the current node (useful for the normal & the offset index). - * \param field Structure containing the current unknowns of the DG-FEM. - * \param partialField Structure containing temporary unknowns - * (like here, the fluxes at the boundary). - * \param j Index of the current node, with respect to the current element. - * \param factor Parameter that determines the weak (+1) or strong form (-1). - * \param boundary Boolean that specifies if we consider a boundary (1) or not (0). - * \param indexJ Index of the current node, with respect to the whole mesh. - * \param indexFrontJ Index of the oppsoite node, with respect to the whole mesh. - * \param solverParams Structure containing the solver's parameters. - */ -void LFShallow(const Edge& edge, Field& field, PartialField& partialField, unsigned int j, double factor, - bool boundary, unsigned int indexJ, unsigned int indexFrontJ, - const SolverParams& solverParams); - - -/** - * \brief Function that computes the numerical Roe flux for shallow waters. - * \param edge Edge of the current node (useful for the normal & the offset index). - * \param field Structure containing the current unknowns of the DG-FEM. - * \param partialField Structure containing temporary unknowns - * (like here, the fluxes at the boundary). - * \param j Index of the current node, with respect to the current element. - * \param factor Parameter that determines the weak (+1) or strong form (-1). - * \param boundary Boolean that specifies if we consider a boundary (1) or not (0). - * \param indexJ Index of the current node, with respect to the whole mesh. - * \param indexFrontJ Index of the oppsoite node, with respect to the whole mesh. - * \param solverParams Structure containing the solver's parameters. - */ -void Roe(const Edge& edge, Field& field, PartialField& partialField, unsigned int j, - double factor, bool boundary, unsigned int indexJ, - unsigned int indexFrontJ, const SolverParams& solverParams); - - -#endif // shallow_phiPsi_hpp_included diff --git a/srcs/physics/shallowWater/source.cpp b/srcs/physics/shallowWater/source.cpp deleted file mode 100644 index a7b3016..0000000 --- a/srcs/physics/shallowWater/source.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "source.hpp" - - -// see .hpp file for description -void sourceShallowCstGradCstFrict(Field& field, const SolverParams& solverParams) -{ - field.s[0].setZero(); - - field.s[1] = solverParams.sourceCoeffs[1]*field.u[2] - + solverParams.fluxCoeffs[0]*solverParams.sourceCoeffs[2]*field.u[0] - - solverParams.sourceCoeffs[4]*field.u[1]/solverParams.sourceCoeffs[0]; - - field.s[2] = -solverParams.sourceCoeffs[1]*field.u[1] - + solverParams.fluxCoeffs[0]*solverParams.sourceCoeffs[3]*field.u[0] - - solverParams.sourceCoeffs[4]*field.u[2]/solverParams.sourceCoeffs[0]; -} - - -// see .hpp file for description -void sourceShallowCstGradQuadFrict(Field& field, const SolverParams& solverParams) -{ - Eigen::VectorXd speedNorm(field.u[0].size()); - speedNorm = field.u[1].array()*field.u[1].array() - + field.u[2].array()*field.u[2].array(); - speedNorm = speedNorm.array().sqrt(); - speedNorm = speedNorm.array()/field.u[0].array(); - - field.s[0].setZero(); - - field.s[1] = solverParams.sourceCoeffs[1]*field.u[2].array() - + solverParams.fluxCoeffs[0]*solverParams.sourceCoeffs[2]*field.u[0].array() - - solverParams.sourceCoeffs[4]*speedNorm.array()*field.u[1].array() - /(solverParams.sourceCoeffs[0]*field.u[0].array()); - - field.s[2] = -solverParams.sourceCoeffs[1]*field.u[1].array() - + solverParams.fluxCoeffs[0]*solverParams.sourceCoeffs[3]*field.u[0].array() - - solverParams.sourceCoeffs[4]*speedNorm.array()*field.u[2].array() - /(solverParams.sourceCoeffs[0]*field.u[0].array()); -} diff --git a/srcs/physics/shallowWater/source.hpp b/srcs/physics/shallowWater/source.hpp deleted file mode 100644 index 8347c2a..0000000 --- a/srcs/physics/shallowWater/source.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef shallow_source_hpp_included -#define shallow_source_hpp_included - -#include -#include "../../params/Params.hpp" -#include "../../solver/field.hpp" - - -/** - * \brief Function that computes the source term of the shallow water equation - * (linear gradient of bed and linear bottom friction term, plus coriolis). - * \param field Structure containing all the information about the computed unknowns. - * \param solverParams Structure containing the solver's parameters. - */ - void sourceShallowCstGradCstFrict(Field& field, const SolverParams& solverParams); - - -/** - * \brief Function that computes the source term of the shallow water equation - * (linear gradient of bed and quadratic bottom friction term, plus coriolis). - * \param field Structure containing all the information about the computed unknowns. - * \param solverParams Structure containing the solver's parameters. - */ -void sourceShallowCstGradQuadFrict(Field& field, const SolverParams& solverParams); - - -#endif // shallow_source_hpp_included diff --git a/srcs/physics/shallowWater/writer.cpp b/srcs/physics/shallowWater/writer.cpp deleted file mode 100644 index dfa7e0c..0000000 --- a/srcs/physics/shallowWater/writer.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#include -#include "writer.hpp" - -void writeShallow(std::vector>& uDisplay, - const std::vector& elementNumNodes, - const std::vector& elementTags, - const std::string& modelName, unsigned int nbreStep, double t, - const Field& field, const std::vector& fluxCoeffs, - const std::vector& whatToWrite, std::vector& viewTags) -{ - if(nbreStep == 0) - { - if(whatToWrite[0] == true) - viewTags[0] = gmsh::view::add("H"); - - if(whatToWrite[1] == true) - viewTags[1] = gmsh::view::add("u"); - - if(whatToWrite[2] == true) - viewTags[2] = gmsh::view::add("v"); - - if(whatToWrite[3] == true) - viewTags[3] = gmsh::view::add("Specific KE"); - - if(whatToWrite[4] == true) - viewTags[4] = gmsh::view::add("Velocity Field"); - } - - if(whatToWrite[0] == true) - { - unsigned int offset = 0; - for(size_t count = 0 ; count < elementNumNodes.size() ; ++count) - { - std::vector temp(elementNumNodes[count]); - for (unsigned int countLocal = 0; countLocal < elementNumNodes[count]; - ++countLocal) - { - temp[countLocal] = field.u[0][countLocal+offset]; - } - offset += elementNumNodes[count]; - uDisplay[count] = std::move(temp); - } - - gmsh::view::addModelData(viewTags[0], nbreStep, modelName, - "ElementNodeData", elementTags, uDisplay, t, 1); - } - - if(whatToWrite[1] == true) - { - unsigned int offset = 0; - for(size_t count = 0 ; count < elementNumNodes.size() ; ++count) - { - std::vector temp(elementNumNodes[count]); - for (unsigned int countLocal = 0; countLocal < elementNumNodes[count]; - ++countLocal) - { - temp[countLocal] = field.u[1][countLocal+offset] - /field.u[0][countLocal+offset]; - } - offset += elementNumNodes[count]; - uDisplay[count] = std::move(temp); - } - - gmsh::view::addModelData(viewTags[1], nbreStep, modelName, - "ElementNodeData", elementTags, uDisplay, t, 1); - } - - if(whatToWrite[2] == true) - { - unsigned int offset = 0; - for(size_t count = 0 ; count < elementNumNodes.size() ; ++count) - { - std::vector temp(elementNumNodes[count]); - for (unsigned int countLocal = 0; countLocal < elementNumNodes[count]; - ++countLocal) - { - temp[countLocal] = field.u[2][countLocal+offset] - /field.u[0][countLocal+offset]; - } - offset += elementNumNodes[count]; - uDisplay[count] = std::move(temp); - } - - gmsh::view::addModelData(viewTags[2], nbreStep, modelName, - "ElementNodeData", elementTags, uDisplay, t, 1); - } - - if(whatToWrite[3] == true) - { - unsigned int offset = 0; - for(size_t count = 0 ; count < elementNumNodes.size() ; ++count) - { - std::vector temp(elementNumNodes[count]); - for (unsigned int countLocal = 0; countLocal < elementNumNodes[count]; - ++countLocal) - { - temp[countLocal] = - 0.5*(field.u[1][countLocal+offset]*field.u[1][countLocal+offset] - +field.u[2][countLocal+offset]*field.u[2][countLocal+offset]) - /(field.u[0][countLocal+offset]*field.u[0][countLocal+offset]); - } - offset += elementNumNodes[count]; - uDisplay[count] = std::move(temp); - } - - gmsh::view::addModelData(viewTags[3], nbreStep, modelName, - "ElementNodeData", elementTags, uDisplay, t, 1); - } - - if(whatToWrite[4] == true) - { - unsigned int offset = 0; - for(size_t count = 0 ; count < elementNumNodes.size() ; ++count) - { - std::vector temp(3*elementNumNodes[count]); - for (unsigned int countLocal = 0; countLocal < elementNumNodes[count]; - ++countLocal) - { - temp[3*countLocal] = field.u[1][countLocal+offset] - /field.u[0][countLocal+offset]; - - temp[3*countLocal+1] = field.u[2][countLocal+offset] - /field.u[0][countLocal+offset]; - - temp[3*countLocal+2] = 0; - } - offset += elementNumNodes[count]; - uDisplay[count] = std::move(temp); - } - - gmsh::view::addModelData(viewTags[4], nbreStep, modelName, - "ElementNodeData", elementTags, uDisplay, t, 3); - } -} diff --git a/srcs/physics/shallowWater/writer.hpp b/srcs/physics/shallowWater/writer.hpp deleted file mode 100644 index d32c818..0000000 --- a/srcs/physics/shallowWater/writer.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef shallow_writer_hpp_included -#define shallow_writer_hpp_included - -#include -#include "../../solver/field.hpp" -#include "../../params/Params.hpp" - - -/** - * \brief Write data for shallow waters. You can write H, u, v, 0.*(u²+v²) - * or the velocity field (boolean in whatToWrite). - * \param uDisplay Vector (per element) of vector (per nodes) to write the data. - * \param elementNumNodes Vector containg the number of nodes per element. - * \param elementTags Vector containing the tag of all elements. - * \param modelName Name of the model. - * \param nbreStep Current time step. - * \param t Current simulation physical time. - * \param field Structure that contains all the main variables. - * \param fluxCoeffs Coefficient of the physical flux. - * \param whatToWrite Vector containing boolean describing which unknown to write. - * \param viewTags Vector containing the rag of the different writing data's. - */ -void writeShallow(std::vector>& uDisplay, - const std::vector& elementNumNodes, - const std::vector& elementTags, - const std::string& modelName, unsigned int nbreStep, double t, - const Field& field, const std::vector& fluxCoeffs, - const std::vector& whatToWrite, std::vector& viewTags); - -#endif /* shallow_writer_hpp_included */ diff --git a/srcs/physics/sources.hpp b/srcs/physics/sources.hpp deleted file mode 100644 index 13cac74..0000000 --- a/srcs/physics/sources.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef sources_hpp_included -#define sources_hpp_included - -#include "linShallowWater/source.hpp" -#include "shallowWater/source.hpp" - -#endif // sources_hpp_included diff --git a/srcs/physics/transport/boundaryCondition.cpp b/srcs/physics/transport/boundaryCondition.cpp deleted file mode 100644 index 0229c48..0000000 --- a/srcs/physics/transport/boundaryCondition.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include -#include "boundaryCondition.hpp" - -#include - -// see .hpp file for description -void sinusTransport(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough coefficients - assert(coeffs.size() == 4); - - // compute a sine wave - uAtIBC[0] = coeffs[0]*sin(2*M_PI*coeffs[1]*t + coeffs[2])+coeffs[3]; -} - - -// see .hpp file for description -void gaussianTransport(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough coefficients - assert(coeffs.size() == 4); - - // compute a sine wave - uAtIBC[0] = coeffs[0]*sin(2*M_PI*coeffs[1]*t + coeffs[2])+coeffs[3]; -} - - -// see .hpp file for description -void freeTransport(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - - // check that there is enough values - assert(field.u.size() == uAtIBC.size()); - - // compute same values - for(unsigned short unk = 0 ; unk < field.u.size() ; ++unk) - uAtIBC[unk] = field.u[unk][indexJ]; -} - - -// see .hpp file for description -void gaussian2DTransport(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs) -{ - // check that there is enough coefficients - assert(coeffs.size() == 6); - assert(pos.size() == 3); - - // compute a 2D gaussian - double X = (pos[0]-coeffs[1])*(pos[0]-coeffs[1])/(2*coeffs[2]); - double Y = (pos[1]-coeffs[3])*(pos[1]-coeffs[3])/(2*coeffs[4]); - - uAtIBC[0] = coeffs[0]*exp(-(X+Y))+coeffs[5]; -} diff --git a/srcs/physics/transport/boundaryCondition.hpp b/srcs/physics/transport/boundaryCondition.hpp deleted file mode 100644 index 071f549..0000000 --- a/srcs/physics/transport/boundaryCondition.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef transport_boundaryCondition_hpp_included -#define transport_boundaryCondition_hpp_included - -#include -#include "../../solver/field.hpp" - -/** - * \brief Compute a wave of the shape A*sin(2*pi*nu*t + phi) -- for the pure - * transport case. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficients for the sinus: coeffs[0] = A, coeffs[1] = nu, - * coeffs[2] = phi. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void sinusTransport(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a gaussian: A*exp(-(t-t_peak)^2/(2*var)) -- for the pure transport - * case. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficients for the gaussian: coeffs[0] = A, coeffs[1] = t_peak, - * coeffs[2] = var. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void gaussianTransport(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -/** - * \brief Compute a 2D gaussian: A*exp(-(x-x0)^2/(2*var_y)-(y-y0)^2/(2*var_y)) -- - * for the pure transport case. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficients for the gaussian: coeffs[0] = A, coeffs[1] = x_0, - * coeffs[2] = var_x, coeffs[3] = y_0, coeffs[4] = var_y. - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void gaussian2DTransport(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - - -/** - * \brief Compute a physical opening -- for the pure transport case. - * \param uAtIBC Value of the BC unknowns at (x, y, z, t). - * \param pos Node position. - * \param t Current time. - * \param field Structure containing the current solution. - * \param indexJ Index of the node corresponding to the boundary in the field structure. - * \param coeffs Coefficient (not used here). - * \param fluxCoeffs Coefficients of the physical fluxes. - */ -void freeTransport(std::vector& uAtIBC, const std::vector& pos, - double t, const Field& field, unsigned int indexJ, - const std::vector& edgeNormal, - const std::vector& coeffs, - const std::vector& fluxCoeffs); - -#endif // transport_boundaryCondition_hpp_included diff --git a/srcs/physics/transport/flux.cpp b/srcs/physics/transport/flux.cpp deleted file mode 100644 index a0498b1..0000000 --- a/srcs/physics/transport/flux.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include "flux.hpp" - - -// see .hpp file for description -void fluxTransport(Field& field, PartialField& partialField, - const SolverParams& solverParams, bool boundary) -{ - // the physical flux is F = a*Q", where "a" is a 2D vector - if(boundary) - { - // flux for the x coordinate - partialField.FluxAtBC[0][0] = solverParams.fluxCoeffs[0] - *partialField.uAtBC[0]; - // flux for the y coordinate - partialField.FluxAtBC[1][0] = solverParams.fluxCoeffs[1] - *partialField.uAtBC[0]; - } - else - { - // flux for the x coordinate - field.flux[0][0] = solverParams.fluxCoeffs[0]*field.u[0]; - // flux for the y coordinate - field.flux[1][0] = solverParams.fluxCoeffs[1]*field.u[0]; - } -} diff --git a/srcs/physics/transport/flux.hpp b/srcs/physics/transport/flux.hpp deleted file mode 100644 index 3bbf2ed..0000000 --- a/srcs/physics/transport/flux.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef transport_flux_hpp_included -#define transport_flux_hpp_included - -#include "../../params/Params.hpp" -#include "../../solver/field.hpp" - - -/** - * \brief Function that computes the physical flux for a pure transport. - * \param field Structure containing all the information about the computed unknowns. - * \param partialField Structure containing temporary unknowns. - * \param solverParams Structure containing the solver's parameters. - * \param boundary Boolean that specifies if we consider a boundary (1) or not (0). - */ -void fluxTransport(Field& field, PartialField& partialField, - const SolverParams& solverParams, bool boundary); - -#endif // transport_flux_hpp_included diff --git a/srcs/physics/transport/phiPsi.cpp b/srcs/physics/transport/phiPsi.cpp deleted file mode 100644 index 56385c0..0000000 --- a/srcs/physics/transport/phiPsi.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "phiPsi.hpp" - - -// see .hpp file for description -void LFTransport(const Edge& edge, Field& field, PartialField& partialField, unsigned int j, double factor, - bool boundary, unsigned int indexJ, unsigned int indexFrontJ, - const SolverParams& solverParams) -{ - - // compute the value of the C of a pure transport LF scheme - double C = fabs(solverParams.fluxCoeffs[0]*edge.normal[0] - + solverParams.fluxCoeffs[1]*edge.normal[1]); - - // compute the numerical flux - if(boundary) - { - //computation of g - for(unsigned short dim = 0 ; dim < partialField.g.size() ; ++dim) - { - for(unsigned short unk = 0 ; unk < partialField.g[dim].size() ; ++unk) - { - partialField.g[dim][unk][edge.offsetInElm[j]] += - -(factor*field.flux[dim][unk][indexJ] - + partialField.FluxAtBC[dim][unk] - + C*edge.normal[dim]*(field.u[unk][indexJ] - - partialField.uAtBC[unk]))/2; - } - } - } - else - { - //computation of g - for(unsigned short dim = 0 ; dim < partialField.g.size() ; ++dim) - { - for(unsigned short unk = 0 ; unk < partialField.g[dim].size() ; ++unk) - { - partialField.g[dim][unk][edge.offsetInElm[j]] += - -(factor*field.flux[dim][unk][indexJ] - + field.flux[dim][unk][indexFrontJ] - + C*edge.normal[dim]*(field.u[unk][indexJ] - - field.u[unk][indexFrontJ]))/2; - } - } - } -} diff --git a/srcs/physics/transport/phiPsi.hpp b/srcs/physics/transport/phiPsi.hpp deleted file mode 100644 index 4f9d5ba..0000000 --- a/srcs/physics/transport/phiPsi.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef transport_phiPsi_hpp_included -#define transport_phiPsi_hpp_included - -#include "../../mesh/Mesh.hpp" -#include "../../params/Params.hpp" -#include "../../solver/field.hpp" - - -/** - * \brief Function that computes the numerical LF flux for a pure transport case. - * \param edge Edge of the current node (useful for the normal & the offset index). - * \param field Structure containing the current unknowns of the DG-FEM. - * \param partialField Structure containing temporary unknowns - * (like here, the fluxes at the boundary). - * \param j Index of the current node, with respect to the current element. - * \param factor Parameter that determines the weak (+1) or strong form (-1). - * \param boundary Boolean that specifies if we consider a boundary (1) or not (0). - * \param indexJ Index of the current node, with respect to the whole mesh. - * \param indexFrontJ Index of the oppsoite node, with respect to the whole mesh. - * \param solverParams Structure containing the solver's parameters. - */ -void LFTransport(const Edge& edge, Field& field, PartialField& partialField, - unsigned int j, double factor, bool boundary, - unsigned int indexJ, unsigned int indexFrontJ, - const SolverParams& solverParams); - -#endif // transport_phiPsi_hpp_included diff --git a/srcs/physics/transport/writer.cpp b/srcs/physics/transport/writer.cpp deleted file mode 100644 index 81a545d..0000000 --- a/srcs/physics/transport/writer.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include "writer.hpp" - -void writeTransport(std::vector>& uDisplay, - const std::vector& elementNumNodes, - const std::vector& elementTags, - const std::string& modelName, unsigned int nbreStep, double t, - const Field& field, const std::vector& fluxCoeffs, - const std::vector& whatToWrite, std::vector& viewTags) -{ - if(nbreStep == 0) - { - if(whatToWrite[0] == true) - viewTags[0] = gmsh::view::add("C"); - } - - if(whatToWrite[0] == true) - { - unsigned int offset = 0; - for(size_t count = 0 ; count < elementNumNodes.size() ; ++count) - { - std::vector temp(elementNumNodes[count]); - for (unsigned int countLocal = 0; countLocal < elementNumNodes[count]; - ++countLocal) - { - temp[countLocal] = field.u[0][countLocal+offset]; - } - offset += elementNumNodes[count]; - uDisplay[count] = std::move(temp); - } - - gmsh::view::addModelData(viewTags[0], nbreStep, modelName, - "ElementNodeData", elementTags, uDisplay, t, 1); - } -} diff --git a/srcs/physics/transport/writer.hpp b/srcs/physics/transport/writer.hpp deleted file mode 100644 index c080ee5..0000000 --- a/srcs/physics/transport/writer.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef transport_writer_hpp_included -#define transport_writer_hpp_included - -#include -#include "../../solver/field.hpp" -#include "../../params/Params.hpp" - - -/** - * \brief Write data for simple transport (boolean in whatToWrite). - * \param uDisplay Vector (per element) of vector (per nodes) to write the data. - * \param elementNumNodes Vector containg the number of nodes per element. - * \param elementTags Vector containing the tag of all elements. - * \param modelName Name of the model. - * \param nbreStep Current time step. - * \param t Current simulation physical time. - * \param field Structure that contains all the main variables. - * \param fluxCoeffs Coefficient of the physical flux. - * \param whatToWrite Vector containing boolean describing which unknown to write. - * \param viewTags Vector containing the rag of the different writing data's. - */ -void writeTransport(std::vector>& uDisplay, - const std::vector& elementNumNodes, - const std::vector& elementTags, - const std::string& modelName, unsigned int nbreStep, double t, - const Field& field, const std::vector& fluxCoeffs, - const std::vector& whatToWrite, std::vector& viewTags); - -#endif /* transport_writer_hpp_included */ diff --git a/srcs/physics/writers.hpp b/srcs/physics/writers.hpp deleted file mode 100644 index 207607a..0000000 --- a/srcs/physics/writers.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef writer_hpp_included -#define writer_hpp_included - -#include "linShallowWater/writer.hpp" -#include "shallowWater/writer.hpp" -#include "transport/writer.hpp" - -#endif // writer_hpp_included diff --git a/srcs/solver/RungeKutta.cpp b/srcs/solver/RungeKutta.cpp deleted file mode 100644 index f62fdf4..0000000 --- a/srcs/solver/RungeKutta.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "RungeKutta.hpp" - -// see .hpp file for prototype -void RK1(double t, Field& field, const Matrix& matrix, - const Mesh& mesh, const SolverParams& solverParams, Field& temp, UsedF usedF) -{ - usedF(t, field, matrix, mesh, solverParams); - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - field.u[unk] += field.DeltaU[unk]*solverParams.timeStep; -} - - -// see .hpp file for prototype -void RK2(double t, Field& field, const Matrix& matrix, - const Mesh& mesh, const SolverParams& solverParams, Field& temp, UsedF usedF) -{ - - double h = solverParams.timeStep; - - usedF(t, temp, matrix, mesh, solverParams); - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - { - field.k1[unk] = temp.DeltaU[unk]*h; - temp.u[unk] = field.u[unk] + field.k1[unk]/2; - } - - usedF(t + h/2, temp, matrix, mesh, solverParams); - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - { - field.k2[unk] = temp.DeltaU[unk]*h; - field.u[unk] += field.k2[unk]; - } -} - - -// see .hpp file for prototype -void RK3(double t, Field& field, const Matrix& matrix, - const Mesh& mesh, const SolverParams& solverParams, Field& temp, UsedF usedF) -{ - double h = solverParams.timeStep; - - usedF(t, temp, matrix, mesh, solverParams); - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - { - field.k1[unk] = temp.DeltaU[unk]*h; - temp.u[unk] = field.u[unk] + field.k1[unk]/2; - } - - usedF(t + h/2, temp, matrix, mesh, solverParams); - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - { - field.k2[unk] = temp.DeltaU[unk]*h; - temp.u[unk] = field.u[unk] - field.k1[unk] + 2*field.k2[unk]; - } - - usedF(t + h, temp, matrix, mesh, solverParams); - for(unsigned short unk = 0 ; unk < 3 ; ++unk) - { - field.k3[unk] = temp.DeltaU[unk]*h; - field.u[unk] += (field.k1[unk] + 4*field.k2[unk] + field.k3[unk])/6; - } -} - - -// see .hpp file for prototype -void RK4(double t, Field& field, const Matrix& matrix, - const Mesh& mesh, const SolverParams& solverParams, Field& temp, UsedF usedF) -{ - double h = solverParams.timeStep; - - usedF(t, temp, matrix, mesh, solverParams); - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - { - field.k1[unk] = temp.DeltaU[unk]*h; - temp.u[unk] = field.u[unk] + field.k1[unk]/2; - } - - usedF(t + h/2, temp, matrix, mesh, solverParams); - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - { - field.k2[unk] = temp.DeltaU[unk]*h; - temp.u[unk] = field.u[unk] + field.k2[unk]/2; - } - - usedF(t + h/2, temp, matrix, mesh, solverParams); - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - { - field.k3[unk] = temp.DeltaU[unk]*h; - temp.u[unk] = field.u[unk] + field.k3[unk]; - } - - usedF(t + h, temp, matrix, mesh, solverParams); - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - { - field.k4[unk] = temp.DeltaU[unk]*h; - field.u[unk] += (field.k1[unk] + 2*field.k2[unk] + 2*field.k3[unk] - + field.k4[unk])/6; - } -} diff --git a/srcs/solver/RungeKutta.hpp b/srcs/solver/RungeKutta.hpp deleted file mode 100644 index d96bfa6..0000000 --- a/srcs/solver/RungeKutta.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#include -#include "field.hpp" -#include "../matrices/matrix.hpp" -#include "../params/Params.hpp" -#include "../mesh/Mesh.hpp" - -//typedef to lighten the notations -typedef std::function UsedF; - -typedef std::function IntegScheme; - - -/** - * \brief Compute the numerical time integration using the method of Runge-Kutta order 1 - i.e. explicit Euler - * \param t Current time. - * \param field Field that contains all the main variables. - * \param partialField Field that contains all the main variables (private) - * \param matrix Structure that contains the matrices of the DG method. - * \param mesh Mesh representing the domain. - * \param solverParams Parameters of the solver. - * \param temp temporary Field needed to compute the different k's - * \param usedF pointer to the function Fweak or Fstrong - */ -void RK1(double t, Field& field, const Matrix& matrix, - const Mesh& mesh, const SolverParams& solverParams, Field& temp, UsedF usedF); - - -/** - * \brief Compute the numerical time integration using the method of Runge-Kutta order 2 - i.e. explicit Euler - * \param t Current time. - * \param field Field that contains all the main variables. - * \param partialField Field that contains all the main variables (private) - * \param matrix Structure that contains the matrices of the DG method. - * \param mesh Mesh representing the domain. - * \param solverParams Parameters of the solver. - * \param temp temporary Field needed to compute the different k's - * \param usedF pointer to the function Fweak or Fstrong - */ -void RK2(double t, Field& field, const Matrix& matrix, - const Mesh& mesh, const SolverParams& solverParams, Field& temp, UsedF usedF); - - -/** - * \brief Compute the numerical time integration using the method of Runge-Kutta order 3 - i.e. explicit Euler - * \param t Current time. - * \param field Field that contains all the main variables. - * \param partialField Field that contains all the main variables (private) - * \param matrix Structure that contains the matrices of the DG method. - * \param mesh Mesh representing the domain. - * \param solverParams Parameters of the solver. - * \param temp temporary Field needed to compute the different k's - * \param usedF pointer to the function Fweak or Fstrong - */ -void RK3(double t, Field& field, const Matrix& matrix, - const Mesh& mesh, const SolverParams& solverParams, Field& temp, UsedF usedF); - - -/** - * \brief Compute the numerical time integration using the method of Runge-Kutta order 4 - i.e. explicit Euler - * \param t Current time. - * \param field Field that contains all the main variables. - * \param partialField Field that contains all the main variables (private) - * \param matrix Structure that contains the matrices of the DG method. - * \param mesh Mesh representing the domain. - * \param solverParams Parameters of the solver. - * \param temp temporary Field needed to compute the different k's - * \param usedF pointer to the function Fweak or Fstrong - */ -void RK4(double t, Field& field, const Matrix& matrix, - const Mesh& mesh, const SolverParams& solverParams, Field& temp, UsedF usedF); diff --git a/srcs/solver/field.hpp b/srcs/solver/field.hpp deleted file mode 100644 index 2e21832..0000000 --- a/srcs/solver/field.hpp +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef field_hpp_included -#define field_hpp_included - -#include -#include - - -/** - * \struct Field - * \brief Structure that contains the main unknowns & variables for the DG method. - */ -struct Field -{ - std::vector u; /**< Solution fields (of size equal - to the number of scalar unknowns) */ - - std::vector> flux; /**< Physical flux fields (of size equal to the number of dimension, with each - dimension as a size equal to the number of scalar unknowns) */ - - std::vector s; /**< Source terms (of size equal - to the number of scalar unknowns) */ - - std::vector DeltaU; /**< Time-integration increment */ - - std::vector Iu; /**< RHS fields */ - - std::vector k1; /**< Temporary integration variables (useful for RK schemes) */ - std::vector k2; /**< Temporary integration variables (useful for RK schemes) */ - std::vector k3; /**< Temporary integration variables (useful for RK schemes) */ - std::vector k4; /**< Temporary integration variables (useful for RK schemes) */ - - /** - * \brief Constructor - * \param numNodes The number of nodes in the mesh. - * \param numUnknown The number of unknowns of the problem. - * \param dim The dimension of the mesh. - */ - Field(unsigned int numNodes, unsigned short numUnknown, unsigned short dim) - { - // resize each field - flux.resize(dim); - for(unsigned short i = 0 ; i < dim ; ++i) - { - flux[i].resize(numUnknown); - } - - u.resize(numUnknown); - s.resize(numUnknown); - DeltaU.resize(numUnknown); - Iu.resize(numUnknown); - for(unsigned short i = 0 ; i < numUnknown ; ++i) - { - u[i].resize(numNodes); - DeltaU[i].resize(numNodes); - Iu[i].resize(numNodes); - s[i].resize(numNodes); - for(unsigned short j = 0 ; j < dim ; ++j) - { - flux[j][i].resize(numNodes); - flux[j][i] = Eigen::VectorXd::Zero(numNodes); - } - } - - k1.resize(numNodes); - k2.resize(numNodes); - k3.resize(numNodes); - k4.resize(numNodes); - } -}; - -/** - * \struct PartialField - * \brief Structure that contains temporary unknowns while computing th fluxes. - */ -struct PartialField -{ - std::vector partialIu; /**< Partial RHS */ - std::vector> g; /**< Partial fields (useful for the computation of the flux at the nodes) */ - - std::vector> FluxAtBC; /**< Boundary fluxes */ - std::vector uAtBC; /**< Boundary fields (useful for the computation of the flux at BC) */ - - /** - * \brief Constructor - * \param numUnknown The number of unknowns of the problem. - * \param dim The dimension of the mesh. - */ - PartialField(unsigned short numUnknown, unsigned short dim) - { - partialIu.resize(numUnknown); - uAtBC.resize(numUnknown); - g.resize(dim); - FluxAtBC.resize(dim); - for(unsigned short i = 0 ; i < dim ; ++i) - { - FluxAtBC[i].resize(numUnknown); - g[i].resize(numUnknown); - } - } -}; - -#endif /* field_hpp */ diff --git a/srcs/solver/timeInteg.cpp b/srcs/solver/timeInteg.cpp deleted file mode 100644 index 63a5a9e..0000000 --- a/srcs/solver/timeInteg.cpp +++ /dev/null @@ -1,240 +0,0 @@ -#include -#include -#include -#include "../matrices/buildMatrix.hpp" -#include "../matrices/matrix.hpp" -#include "../flux/buildFlux.hpp" -#include "../write/write.hpp" -#include "timeInteg.hpp" -#include "field.hpp" -#include "RungeKutta.hpp" - - -/** - * \brief Compute the increment vector of the unknown fields, for the weak form. - * \param t Current time. - * \param u Current solution. - * \param field Structure that contains all the main variables. - * \param matrix Structure that contains the matrices of the DG method. - * \param mesh Mesh representing the domain. - * \param solverParams Parameters of the solver. - */ -static void Fweak(double t, Field& field, - const Matrix& matrix, const Mesh& mesh, - const SolverParams& solverParams) -{ - // compute the nodal physical fluxes - PartialField partialField(solverParams.nUnknowns, mesh.dim); - - solverParams.flux(field, partialField, solverParams, false); - - if(solverParams.IsSourceTerms) - solverParams.sourceTerm(field, solverParams); - - // compute the right-hand side of the master equation (phi or psi) - buildFlux(mesh, field, 1, t, solverParams); - - // compute the increment - for(unsigned short unk = 0 ; unk < field.DeltaU.size() ; ++unk) - { - field.DeltaU[unk] - = matrix.invM*(field.Iu[unk] + matrix.Sx*field.flux[0][unk] - + matrix.Sy*field.flux[1][unk]); - - if(solverParams.IsSourceTerms) - field.DeltaU[unk]+=field.s[unk]; - - } -} - - -/** - * \brief Compute the increment vector of the unknown fields, for the strong form. - * \param t Current time. - * \param u Current solution. - * \param field Structure that contains all the main variables. - * \param matrix Structure that contains the matrices of the DG method. - * \param mesh Mesh representing the domain. - * \param solverParams Parameters of the solver. - */ -static void Fstrong(double t, Field& field, const Matrix& matrix, const Mesh& mesh, - const SolverParams& solverParams) -{ - PartialField partialField(solverParams.nUnknowns, mesh.dim); - - // compute the nodal physical fluxes - solverParams.flux(field, partialField, solverParams, false); - - if(solverParams.IsSourceTerms) - solverParams.sourceTerm(field, solverParams); - - // compute the right-hand side of the master equation (phi or psi) - buildFlux(mesh, field, -1, t, solverParams); - - // compute the increment - for(unsigned short unk = 0 ; unk < field.DeltaU.size() ; ++unk) - { - field.DeltaU[unk] - = matrix.invM*(field.Iu[unk] - matrix.Sx*field.flux[0][unk] - - matrix.Sy*field.flux[1][unk]); - - if(solverParams.IsSourceTerms) - field.DeltaU[unk]+=field.s[unk]; - } -} - - -// see .hpp file for description -bool timeInteg(const Mesh& mesh, SolverParams& solverParams, - const std::string& fileName, const std::string& resultsName) -{ - std::cout << "Number of nodes: " << mesh.nodeData.numNodes << std::endl; - - /******************************************************************************* - * TIME STEPS * - *******************************************************************************/ - unsigned int nTimeSteps - = static_cast(solverParams.simTime/solverParams.timeStep); - unsigned int nTimeStepsDtWrite - = static_cast(solverParams.simTimeDtWrite/solverParams.timeStep); - - - /******************************************************************************* - * MATRICES * - *******************************************************************************/ - Matrix matrix; - buildMatrix(mesh, matrix); - - - /******************************************************************************* - * WEAK AND STRONG FORM * - *******************************************************************************/ - //Function pointer to the used function (weak vs strong form) - UsedF usedF; - - if(solverParams.solverType == "weak") - { - usedF = Fweak; - matrix.Sx = matrix.Sx.transpose(); - matrix.Sy = matrix.Sy.transpose(); - } - else - { - usedF = Fstrong; - } - - //Initialization of the field of unknowns - Field field(mesh.nodeData.numNodes, solverParams.nUnknowns, mesh.dim); - - /******************************************************************************* - * INITIAL CONDITION * - *******************************************************************************/ - std::vector uIC(solverParams.nUnknowns); - - for(auto element : mesh.elements) - { - for(unsigned int n = 0 ; n < element.nodeTags.size() ; ++n) - { - solverParams.initCondition.ibcFunc(uIC, element.nodesCoord[n], 0, field, 0, {}, - solverParams.initCondition.coefficients, solverParams.fluxCoeffs); - - for(unsigned short unk = 0 ; unk < solverParams.nUnknowns ; ++unk) - field.u[unk](element.offsetInU + n) = uIC[unk]; - } - } - - - /******************************************************************************* - * LAUNCH GMSH * - *******************************************************************************/ - gmsh::initialize(); - gmsh::option::setNumber("General.Terminal", 1); - gmsh::open(fileName); - std::vector names; - gmsh::model::list(names); - std::string modelName = names[0]; - std::string dataType = "ElementNodeData"; - std::vector elementTags = mesh.nodeData.elementTags; - std::vector elementNumNodes = mesh.nodeData.elementNumNodes; - std::vector> uDisplay(elementNumNodes.size()); - - double t = 0.0; - - /******************************************************************************* - * INITIAL CONDITION * - *******************************************************************************/ - solverParams.write(uDisplay, elementNumNodes, elementTags, modelName,0, 0, field, - solverParams.fluxCoeffs, solverParams.whatToWrite, - solverParams.viewTags); - - - /******************************************************************************* - * TIME INTEGRATION * - *******************************************************************************/ - // temporary vectors (only for RK4, but I don't want to define them at each time - // iteration) - Field temp = field; - - //Function pointer to the used integration scheme - IntegScheme integScheme; - - if (solverParams.timeIntType == "RK1") - { - integScheme = RK1; - } - else if (solverParams.timeIntType == "RK2") - { - integScheme = RK2; - } - else if (solverParams.timeIntType == "RK3") - { - integScheme = RK3; - } - else if (solverParams.timeIntType == "RK4") - { - integScheme = RK4; - } - - - // numerical integration - unsigned int ratio, currentDecade = 0; - for(unsigned int nbrStep = 1 ; nbrStep < nTimeSteps + 1 ; - nbrStep++) - { - // display progress - ratio = int(100*double(nbrStep - 1)/double(nTimeSteps)); - if(ratio >= currentDecade) - { - std::cout << "\r" << "Integrating: " << ratio << "%" - << " of the time steps done" << std::flush; - currentDecade = ratio + 1; - } - - integScheme(t, field, matrix, mesh, solverParams, temp, usedF); - - temp = field; - - // check that it does not diverge - // assert(field.u[0].maxCoeff() <= 1E5); - - // add time step - t += solverParams.timeStep; - - // store the results every Dt only. - if((nbrStep % nTimeStepsDtWrite) == 0) - { - solverParams.write(uDisplay, elementNumNodes, elementTags, modelName, - nbrStep, t, field, solverParams.fluxCoeffs, - solverParams.whatToWrite, solverParams.viewTags); - } - } - - std::cout << "\r" << "Integrating: 100% of the time steps done" << std::flush - << std::endl; - - // write the results & finalize - writeEnd(solverParams.viewTags, solverParams.whatToWrite, resultsName); - gmsh::finalize(); - - return true; -} diff --git a/srcs/solver/timeInteg.hpp b/srcs/solver/timeInteg.hpp deleted file mode 100644 index 24daf91..0000000 --- a/srcs/solver/timeInteg.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef timeInteg_hpp_included -#define timeInteg_hpp_included - -#include -#include -#include -#include "../mesh/Mesh.hpp" -#include "../params/Params.hpp" - - -/** - * \brief Time integrate the equations (DG-FEM) - * \param mesh The mesh representing the domain of interest - * \param solverParams The structure in which the parameters of the solver are. - * \param fileName The name of the .msh file containing the mesh. - * \param resultsName name of the .msh file that will contain the results - * \return true if time integration happened without problems, false otherwise. - */ -bool timeInteg(const Mesh& mesh, SolverParams& solverParams, - const std::string& fileName, const std::string& resultsName); - -#endif /* timeInteg_hpp */ diff --git a/srcs/utils/utils.cpp b/srcs/utils/utils.cpp deleted file mode 100644 index 3c6e68e..0000000 --- a/srcs/utils/utils.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include "utils.hpp" - - -// see .hpp file for description -bool isPermutation(const std::vector& vec1, - const std::vector& vec2, - std::vector& permutation1, - std::vector& permutation2) -{ - assert(vec1.size() != 0 && vec2.size() == vec1.size()); - assert(permutation1.size() == 0 && permutation2.size() == 0); - - permutation1.resize(vec1.size()); - permutation2.resize(vec2.size()); - - for(unsigned int i = 0 ; i < vec1.size() ; ++i) - { - bool found = false; - for(unsigned int j = 0 ; j < vec2.size() ; ++j) - { - if(vec2[j] == vec1[i]) - { - permutation1[i] = j; - permutation2[j] = i; - - found = true; - break; - } - } - if(!found) - return false; - } - - return true; -} diff --git a/srcs/utils/utils.hpp b/srcs/utils/utils.hpp deleted file mode 100644 index 2fc26b9..0000000 --- a/srcs/utils/utils.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef utils_hpp_included -#define utils_hpp_included - -#include - - -bool isPermutation(const std::vector& vec1, - const std::vector& vec2, - std::vector& permutation1, - std::vector& permutation2); - -#endif /* utils_hpp_included */ diff --git a/srcs/write/write.cpp b/srcs/write/write.cpp deleted file mode 100644 index 9058998..0000000 --- a/srcs/write/write.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include "write.hpp" - -void writeEnd(const std::vector& viewTags, const std::vector& whatToWrite, - const std::string& resultsName) -{ - for(unsigned int i = 0 ; i < whatToWrite.size() ; ++i) - { - if(whatToWrite[i] == true) - gmsh::view::write(viewTags[i], resultsName, true); - } -} diff --git a/srcs/write/write.hpp b/srcs/write/write.hpp deleted file mode 100644 index 7699966..0000000 --- a/srcs/write/write.hpp +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef write_hpp_included -#define write_hpp_included - -#include -#include "../solver/field.hpp" -#include "../params/Params.hpp" - - -/** - * \brief Write data for shallow waters. You can write H, u, v, 0.*(u²+v²) - * or the velocity field (boolean in whatToWrite). - * \param uDisplay Vector (per element) of vector (per nodes) to write the data. - * \param elementNumNodes Vector containg the number of nodes per element. - * \param elementTags Vector containing the tag of all elements. - * \param modelName Name of the model. - * \param nbreStep Current time step. - * \param t Current simulation physical time. - * \param field Structure that contains all the main variables. - * \param fluxCoeffs Coefficient of the physical flux. - * \param whatToWrite Vector containing boolean describing which unknown to write. - * \param viewTags Vector containing the rag of the different writing data's. - */ -void writeShallow(std::vector>& uDisplay, - const std::vector& elementNumNodes, - const std::vector& elementTags, const std::string& modelName, - unsigned int nbreStep, double t, const Field& field, - const std::vector& fluxCoeffs, - const std::vector& whatToWrite, std::vector& viewTags); - - -/** - * \brief Write data for linear shallow waters. You can write H, u, v, 0.*(u²+v²) - * or the velocity field (boolean in whatToWrite). - * \param uDisplay Vector (per element) of vector (per nodes) to write the data. - * \param elementNumNodes Vector containg the number of nodes per element. - * \param elementTags Vector containing the tag of all elements. - * \param modelName Name of the model. - * \param nbreStep Current time step. - * \param t Current simulation physical time. - * \param field Structure that contains all the main variables. - * \param fluxCoeffs Coefficient of the physical flux. - * \param whatToWrite Vector containing boolean describing which unknown to write. - * \param viewTags Vector containing the rag of the different writing data's. - */ -void writeShallowLin(std::vector>& uDisplay, - const std::vector& elementNumNodes, - const std::vector& elementTags, const std::string& modelName, - unsigned int nbreStep, double t, const Field& field, - const std::vector& fluxCoeffs, - const std::vector& whatToWrite, std::vector& viewTags); - - -/** - * \brief Write data for simple transport (boolean in whatToWrite). - * \param uDisplay Vector (per element) of vector (per nodes) to write the data. - * \param elementNumNodes Vector containg the number of nodes per element. - * \param elementTags Vector containing the tag of all elements. - * \param modelName Name of the model. - * \param nbreStep Current time step. - * \param t Current simulation physical time. - * \param field Structure that contains all the main variables. - * \param fluxCoeffs Coefficient of the physical flux. - * \param whatToWrite Vector containing boolean describing which unknown to write. - * \param viewTags Vector containing the rag of the different writing data's. - */ -void writeTransport(std::vector>& uDisplay, - const std::vector& elementNumNodes, - const std::vector& elementTags, const std::string& modelName, - unsigned int nbreStep, double t, const Field& field, - const std::vector& fluxCoeffs, - const std::vector& whatToWrite, std::vector& viewTags); - - -/** - * \brief Actually write the results file. - * \param viewTags Vector containing the rag of the different writing data's. - * \param whatToWrite Vector containing boolean describing which unknown to write. - * \param resultsName the name of the .msh file that will contain the results - */ -void writeEnd(const std::vector& viewTags, const std::vector& whatToWrite, - const std::string& resultsName); - -#endif /* write_hpp_included */ From 4b119fa57e1ae9ce6821e2ab911cce415eccc8a8 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Tue, 28 Jul 2020 23:31:23 +0200 Subject: [PATCH 02/33] Fix travis in PR (if I did not screwed up) --- .travis.yml | 6 +++--- build_travis.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index e92b480..4ab1251 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,8 @@ matrix: services: - docker before_install: - - docker run -d --name ubuntu-19-04 -v $(pwd):/travis ubuntu:19.04 tail -f /dev/null + - docker run -d --name ubuntu-20-04 -v $(pwd):/travis ubuntu:20.04 tail -f /dev/null install: - - docker exec -t ubuntu-19-04 bash -c "apt-get -qq update; apt-get install -y git; apt-get install -y cmake; apt-get install -y build-essential; apt-get install -y wget; apt-get install -y tar; apt-get install -y libgfortran3; apt-get install -y libgmsh-dev; apt-get install -y libeigen3-dev" + - docker exec -t ubuntu-20-04 bash -c "apt-get -qq update; apt-get install -y git; apt-get install -y cmake; apt-get install -y build-essential; apt-get install -y wget; apt-get install -y tar; apt-get install -y libgfortran3; apt-get install -y libgmsh-dev; apt-get install -y libeigen3-dev" script: - - docker exec -t ubuntu-19-04 bash -c "cd /travis; ./build_travis.sh;" + - docker exec -t ubuntu-20-04 bash -c "cd /travis; ./build_travis.sh;" diff --git a/build_travis.sh b/build_travis.sh index 8ee5c99..8ce6205 100755 --- a/build_travis.sh +++ b/build_travis.sh @@ -1,7 +1,7 @@ #!/bin/sh -wget http://gmsh.info/bin/Linux/gmsh-4.4.0-Linux64-sdk.tgz -tar -xf gmsh-4.4.0-Linux64-sdk.tgz -cd gmsh-4.4.0-Linux64-sdk/ +wget http://gmsh.info/bin/Linux/gmsh-4.6.0-Linux64-sdk.tgz +tar -xf gmsh-4.6.0-Linux64-sdk.tgz +cd gmsh-4.6.0-Linux64-sdk/ export PATH=${PWD}/bin:${PWD}/lib:${PATH} export INCLUDE=${PWD}/include:${INCLUDE} export LIB=${PWD}/lib:${LIB} From e082fca750906fc9633fac09dae71b8235a77a36 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Tue, 28 Jul 2020 23:31:40 +0200 Subject: [PATCH 03/33] Continue refactor of Mesh --- srcs/dgMesh/dgMesh.cpp | 104 +++++++++++++++++++++++++++++++++++++---- srcs/dgMesh/dgMesh.hpp | 37 +++++++++++---- srcs/main.cpp | 26 ++++++++++- 3 files changed, 145 insertions(+), 22 deletions(-) diff --git a/srcs/dgMesh/dgMesh.cpp b/srcs/dgMesh/dgMesh.cpp index 5fd12b5..654d7c6 100644 --- a/srcs/dgMesh/dgMesh.cpp +++ b/srcs/dgMesh/dgMesh.cpp @@ -48,6 +48,8 @@ void dgMesh::loadFromFile(std::string fileName) loadElementsProperty(); + loadElements(); + gmsh::finalize(); } @@ -60,7 +62,7 @@ void dgMesh::displayToConsole() const noexcept std::cout << "\t\t - tag: " << pg.tag << "\n"; std::cout << "\t\t - entities tag: "; for(Entity* pEntity : pg.pEntities) - std::cout << pEntity->tag << ", "; + std::cout << pEntity->mainTag << ", "; std::cout << std::endl; } std::cout << std::endl; @@ -72,7 +74,7 @@ void dgMesh::displayToConsole() const noexcept std::cout << "\t\t - tag: " << pg.tag << "\n"; std::cout << "\t\t - entities tag: "; for(Entity* pEntity : pg.pEntities) - std::cout << pEntity->tag << ", "; + std::cout << pEntity->mainTag << ", "; std::cout << std::endl; } std::cout << std::endl; @@ -80,7 +82,7 @@ void dgMesh::displayToConsole() const noexcept std::cout << m_dimension << "D entities: " << std::endl; for(Entity entity : m_entitiesHD) { - std::cout << "\t * " << entity.tag << ": \n"; + std::cout << "\t * " << entity.mainTag << ": \n"; std::cout << "\t\t - element type: " << entity.pElementProperty->type << "\n"; std::cout << "\t\t - element name: " << entity.pElementProperty->name << "\n"; } @@ -89,7 +91,7 @@ void dgMesh::displayToConsole() const noexcept std::cout << m_dimension - 1 << "D entities: " << std::endl; for(Entity entity : m_entitiesLD) { - std::cout << "\t * " << entity.tag << ": \n"; + std::cout << "\t * " << entity.mainTag << ": \n"; std::cout << "\t\t - element type: " << entity.pElementProperty->type << "\n"; std::cout << "\t\t - element name: " << entity.pElementProperty->name << "\n"; } @@ -161,6 +163,7 @@ void dgMesh::loadPhysicalGroupsAndEntities() { m_entitiesHD.push_back({ entityHD.second, + -1, {}, nullptr, {}, @@ -179,6 +182,7 @@ void dgMesh::loadPhysicalGroupsAndEntities() { m_entitiesLD.push_back({ entityLD.second, + -1, {}, nullptr, {}, @@ -197,7 +201,7 @@ void dgMesh::loadPhysicalGroupsAndEntities() auto it = std::find_if(m_entitiesHD.begin(), m_entitiesHD.end(), [entityTagInPG](const Entity& knownEntity) { - return (entityTagInPG == knownEntity.tag); + return (entityTagInPG == knownEntity.mainTag); }); assert(it != m_entitiesHD.cend()); @@ -216,7 +220,7 @@ void dgMesh::loadPhysicalGroupsAndEntities() auto it = std::find_if(m_entitiesLD.begin(), m_entitiesLD.end(), [entityTagInPG](const Entity& knownEntity) { - return (entityTagInPG == knownEntity.tag); + return (entityTagInPG == knownEntity.mainTag); }); assert(it != m_entitiesLD.cend()); @@ -230,7 +234,7 @@ void dgMesh::loadPhysicalGroupsAndEntities() for(Entity& entityHD : m_entitiesHD) { std::vector physicalGroupsTagInEntity; - gmsh::model::getPhysicalGroupsForEntity(m_dimension, entityHD.tag, physicalGroupsTagInEntity); + gmsh::model::getPhysicalGroupsForEntity(m_dimension, entityHD.mainTag, physicalGroupsTagInEntity); for(int pgTagInEntity : physicalGroupsTagInEntity) { @@ -249,7 +253,7 @@ void dgMesh::loadPhysicalGroupsAndEntities() for(Entity& entityLD : m_entitiesLD) { std::vector physicalGroupsTagInEntity; - gmsh::model::getPhysicalGroupsForEntity(m_dimension - 1, entityLD.tag, physicalGroupsTagInEntity); + gmsh::model::getPhysicalGroupsForEntity(m_dimension - 1, entityLD.mainTag, physicalGroupsTagInEntity); for(int pgTagInEntity : physicalGroupsTagInEntity) { @@ -311,7 +315,7 @@ void dgMesh::loadElementsProperty() for(Entity& entity : m_entitiesHD) { std::vector elementType; - gmsh::model::mesh::getElementTypes(elementType, m_dimension, entity.tag); + gmsh::model::mesh::getElementTypes(elementType, m_dimension, entity.mainTag); if(elementType.size() != 1) throw std::runtime_error("Hybrid Meshes are currently not handled"); @@ -330,7 +334,7 @@ void dgMesh::loadElementsProperty() for(Entity& entity : m_entitiesLD) { std::vector elementType; - gmsh::model::mesh::getElementTypes(elementType, m_dimension - 1, entity.tag); + gmsh::model::mesh::getElementTypes(elementType, m_dimension - 1, entity.mainTag); if(elementType.size() != 1) throw std::runtime_error("Hybrid Meshes are currently not handled"); @@ -346,3 +350,83 @@ void dgMesh::loadElementsProperty() entity.pElementProperty = &*it; } } + +void dgMesh::loadElements() +{ + /** Element in HD entities should appear inly once **/ + + for(Entity& entity : m_entitiesHD) + { + entity.subTag = gmsh::model::addDiscreteEntity(1); + std::vector nodesTagPerEdge; + gmsh::model::mesh::getElementEdgeNodes(entity.pElementProperty->type, nodesTagPerEdge, entity.mainTag); + int eleTypeSubEntity; + switch(m_dimension) + { + case 1: + eleTypeSubEntity = gmsh::model::mesh::getElementType("point", entity.pElementProperty->order); + break; + + case 2: + eleTypeSubEntity = gmsh::model::mesh::getElementType("line", entity.pElementProperty->order); + break; + + case 3: + eleTypeSubEntity = gmsh::model::mesh::getElementType("line", entity.pElementProperty->order); + break; + } + gmsh::model::mesh::addElementsByType(entity.subTag, eleTypeSubEntity, {}, nodesTagPerEdge); + + std::vector elementTags; + std::vector nodeTags; + gmsh::model::mesh::getElementsByType(entity.pElementProperty->type, + elementTags, nodeTags, entity.mainTag); + + std::vector jacobians; + std::vector determinants; + std::vector dummyCoord; + gmsh::model::mesh::getJacobians(entity.pElementProperty->type, entity.pElementProperty->localNodeCoord, + jacobians, determinants, dummyCoord, entity.mainTag); + + std::vector baryCenters; + gmsh::model::mesh::getBarycenters(entity.pElementProperty->type, entity.mainTag, false, true, baryCenters); + + unsigned int nNodes = entity.pElementProperty->numNodes; + unsigned int nGP = entity.pElementProperty->intPointsWeigth.size(); + + for(std::size_t i = 0 ; i < elementTags.size() ; ++i) + { + std::vector nodesTagsOfElm(nodeTags.begin() + nNodes*i, + nodeTags.begin() + nNodes*(i + 1)); + + std::vector determinantsOfElm(determinants.begin() + nGP*i, + determinants.begin() + nGP*(i + 1)); + + std::vector jacobiansOfElm(jacobians.begin() + 9*nGP*i, + jacobians.begin() + 9*nGP*(1 + i)); + + + assert(nodesTagsOfElm.size() == nNodes); + assert(determinantsOfElm.size() == nGP); + assert(jacobiansOfElm.size() == 9*nGP); + + Element elm = {}; + elm.tag = elementTags[i]; + elm.nodesTag = nodesTagsOfElm; + elm.determinant = determinantsOfElm; + elm.jacobian = jacobiansOfElm; + elm.pEntity = &entity; + elm.faceEdges = {}; + + for(std::size_t nodeTag : elm.nodesTag) + { + std::vector coord, dummyParametricCoord; + gmsh::model::mesh::getNode(nodeTag, coord, dummyParametricCoord); + elm.nodesCoord.push_back(coord); + } + + m_elementsHD.push_back(std::move(elm)); + entity.pElements.push_back(&m_elementsHD.back()); + } + } +} diff --git a/srcs/dgMesh/dgMesh.hpp b/srcs/dgMesh/dgMesh.hpp index 1ea3ea9..4bdffea 100644 --- a/srcs/dgMesh/dgMesh.hpp +++ b/srcs/dgMesh/dgMesh.hpp @@ -26,7 +26,6 @@ class DG_MESH_API dgMesh void loadPhysicalGroupsAndEntities(); void loadElementsProperty(); void loadElements(); - void loadFaces(); int m_dimension; @@ -55,26 +54,43 @@ class DG_MESH_API dgMesh std::vector basisFunctionsGrad = {}; }; + struct FaceEdge; + struct Element { - int tag = -1; - std::vector nodesTag = {}; + std::size_t tag = -1; + std::vector nodesTag = {}; + std::vector> nodesCoord = {}; + + std::vector determinant = {}; + std::vector jacobian = {}; + + Entity* pEntity = nullptr; + std::vector faceEdges = {}; + }; + + struct FaceEdge + { + std::size_t tag = -1; + std::vector nodesTag = {}; std::vector> nodesCoord = {}; std::vector determinant = {}; - std::vector>> jacobian = {}; + std::vector jacobian = {}; - std::vector pElements = {}; - std::vector pEntity = {}; + std::vector normal = {}; + Element* parentElementHD = nullptr; + Element* elementLD = nullptr; }; struct Entity { - int tag = -1; + int mainTag = -1; + int subTag = -1; std::vector pPhysicalGroups = {}; ElementProperty* pElementProperty = nullptr; - std::vector pElements; + std::vector pElements = {}; }; struct PhysicalGroup @@ -93,8 +109,9 @@ class DG_MESH_API dgMesh std::vector m_elementsPropertyHD; std::vector m_elementsPropertyLD; - std::vector m_elementsHD; - std::vector m_elementsLD; + std::vector m_elementsHD; + std::vector m_elementsLD; + std::vector m_faceEdges; }; #include "dgMesh.inl" diff --git a/srcs/main.cpp b/srcs/main.cpp index 11d807f..9c196af 100644 --- a/srcs/main.cpp +++ b/srcs/main.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "dgMesh/dgMesh.hpp" @@ -6,8 +7,29 @@ int main(int argc, char **argv) { dgMesh mesh("Gauss1", "Lagrange"); - mesh.loadFromFile(std::string(argv[1])); - mesh.displayToConsole(); + + try + { + mesh.loadFromFile(std::string(argv[1])); + mesh.displayToConsole(); + } + catch(const std::exception& exception) + { + std::cerr << "Something went wrong: " << exception.what() << std::endl; + return -1; + } + catch(int e) + { + std::cerr << "GMSH certainly throwed something (only one to use int exceptions): " + << e << std::endl; + return -2; + } + catch(...) + { + std::cerr << "Unexpected exception: bip bip boup ?" << std::endl; + return -3; + } + return 0; } From bc97a45461d7bc2ecc0ea8649eadc0f0866862eb Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Tue, 28 Jul 2020 23:34:36 +0200 Subject: [PATCH 04/33] Travis annoys me --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4ab1251..bc9092e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,6 @@ matrix: before_install: - docker run -d --name ubuntu-20-04 -v $(pwd):/travis ubuntu:20.04 tail -f /dev/null install: - - docker exec -t ubuntu-20-04 bash -c "apt-get -qq update; apt-get install -y git; apt-get install -y cmake; apt-get install -y build-essential; apt-get install -y wget; apt-get install -y tar; apt-get install -y libgfortran3; apt-get install -y libgmsh-dev; apt-get install -y libeigen3-dev" + - docker exec -e DEBIAN_FRONTEND=noninteractive -t ubuntu-20-04 bash -c "apt-get -qq update; apt-get install -y git; apt-get install -y cmake; apt-get install -y build-essential; apt-get install -y wget; apt-get install -y tar; apt-get install -y libgfortran3; apt-get install -y libgmsh-dev; apt-get install -y libeigen3-dev" script: - docker exec -t ubuntu-20-04 bash -c "cd /travis; ./build_travis.sh;" From 9449ef14bf78f12f83d7b826d782dea0f61b8d82 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 31 Jul 2020 00:17:11 +0200 Subject: [PATCH 05/33] Load edges (still need to find the "edge in front') --- srcs/dgMesh/dgMesh.cpp | 142 +++++++++++++++++++++++++++++++++-------- srcs/dgMesh/dgMesh.hpp | 8 ++- 2 files changed, 120 insertions(+), 30 deletions(-) diff --git a/srcs/dgMesh/dgMesh.cpp b/srcs/dgMesh/dgMesh.cpp index 654d7c6..047fa07 100644 --- a/srcs/dgMesh/dgMesh.cpp +++ b/srcs/dgMesh/dgMesh.cpp @@ -40,6 +40,7 @@ void dgMesh::loadFromFile(std::string fileName) throw std::runtime_error("could not open file " + fileName + "."); gmsh::initialize(); + gmsh::option::setNumber("General.Terminal", 1); gmsh::open(fileName); m_dimension = gmsh::model::getDimension(); @@ -357,7 +358,7 @@ void dgMesh::loadElements() for(Entity& entity : m_entitiesHD) { - entity.subTag = gmsh::model::addDiscreteEntity(1); + entity.subTag = gmsh::model::addDiscreteEntity(m_dimension - 1); std::vector nodesTagPerEdge; gmsh::model::mesh::getElementEdgeNodes(entity.pElementProperty->type, nodesTagPerEdge, entity.mainTag); int eleTypeSubEntity; @@ -375,6 +376,18 @@ void dgMesh::loadElements() eleTypeSubEntity = gmsh::model::mesh::getElementType("line", entity.pElementProperty->order); break; } + + for(auto& elmProp : m_elementsPropertyLD) + { + if(elmProp.type == eleTypeSubEntity) + { + entity.pFaceEdgePropety = &elmProp; + break; + } + } + + assert(entity.pFaceEdgePropety != nullptr); + gmsh::model::mesh::addElementsByType(entity.subTag, eleTypeSubEntity, {}, nodesTagPerEdge); std::vector elementTags; @@ -382,41 +395,40 @@ void dgMesh::loadElements() gmsh::model::mesh::getElementsByType(entity.pElementProperty->type, elementTags, nodeTags, entity.mainTag); - std::vector jacobians; - std::vector determinants; - std::vector dummyCoord; - gmsh::model::mesh::getJacobians(entity.pElementProperty->type, entity.pElementProperty->localNodeCoord, - jacobians, determinants, dummyCoord, entity.mainTag); + std::vector jacobiansHD; + std::vector determinantsHD; + std::vector dummyCoordHD; + gmsh::model::mesh::getJacobians(entity.pElementProperty->type, entity.pElementProperty->intPointsCoord, + jacobiansHD, determinantsHD, dummyCoordHD, entity.mainTag); + + std::vector jacobiansLD; + std::vector determinantsLD; + std::vector dummyCoordLD; + gmsh::model::mesh::getJacobians(entity.pFaceEdgePropety->type, entity.pFaceEdgePropety->intPointsCoord, + jacobiansLD, determinantsLD, dummyCoordLD, entity.subTag); std::vector baryCenters; gmsh::model::mesh::getBarycenters(entity.pElementProperty->type, entity.mainTag, false, true, baryCenters); - unsigned int nNodes = entity.pElementProperty->numNodes; - unsigned int nGP = entity.pElementProperty->intPointsWeigth.size(); + unsigned int nNodesElm = entity.pElementProperty->numNodes; + unsigned int nElements = elementTags.size(); + unsigned int nNodesFaceEdge = entity.pFaceEdgePropety->numNodes; + unsigned int nFaceEdges = nodesTagPerEdge.size()/nNodesFaceEdge; + unsigned int nFaceEdgesPerElm = nNodesElm; + unsigned int nGPHD = entity.pElementProperty->intPointsWeigth.size(); + unsigned int nGPLD = entity.pFaceEdgePropety->intPointsWeigth.size(); - for(std::size_t i = 0 ; i < elementTags.size() ; ++i) + for(std::size_t e = 0 ; e < nElements ; ++e) { - std::vector nodesTagsOfElm(nodeTags.begin() + nNodes*i, - nodeTags.begin() + nNodes*(i + 1)); - - std::vector determinantsOfElm(determinants.begin() + nGP*i, - determinants.begin() + nGP*(i + 1)); - - std::vector jacobiansOfElm(jacobians.begin() + 9*nGP*i, - jacobians.begin() + 9*nGP*(1 + i)); - - - assert(nodesTagsOfElm.size() == nNodes); - assert(determinantsOfElm.size() == nGP); - assert(jacobiansOfElm.size() == 9*nGP); - Element elm = {}; - elm.tag = elementTags[i]; - elm.nodesTag = nodesTagsOfElm; - elm.determinant = determinantsOfElm; - elm.jacobian = jacobiansOfElm; + elm.tag = elementTags[e]; + elm.nodesTag = std::vector(nodeTags.begin() + nNodesElm*e, + nodeTags.begin() + nNodesElm*(e + 1)); + elm.determinant = std::vector(determinantsHD.begin() + nGPHD*e, + determinantsHD.begin() + nGPHD*(e + 1)); + elm.jacobian = std::vector(jacobiansHD.begin() + 9*nGPHD*e, + jacobiansHD.begin() + 9*nGPHD*(e + 1)); elm.pEntity = &entity; - elm.faceEdges = {}; for(std::size_t nodeTag : elm.nodesTag) { @@ -425,8 +437,82 @@ void dgMesh::loadElements() elm.nodesCoord.push_back(coord); } + std::vector elementBarycenters(baryCenters.begin() + 3*e, + baryCenters.begin() + 3*(e + 1)); + + for(unsigned int i = 0 ; i < nFaceEdgesPerElm ; ++i) + { + FaceEdge faceEdge = {}; + + faceEdge.nodesTag = std::vector(nodesTagPerEdge.begin() + nNodesFaceEdge*nFaceEdgesPerElm*e + nNodesFaceEdge*i, + nodesTagPerEdge.begin() + nNodesFaceEdge*nFaceEdgesPerElm*e + nNodesFaceEdge*(i + 1)); + + for(std::size_t nodeTag : faceEdge.nodesTag) + { + std::vector coord, dummyParametricCoord; + gmsh::model::mesh::getNode(nodeTag, coord, dummyParametricCoord); + faceEdge.nodesCoord.push_back(coord); + } + + faceEdge.determinant = std::vector(determinantsLD.begin() + nFaceEdgesPerElm*nGPLD*e + nGPLD*i, + determinantsLD.begin() + nFaceEdgesPerElm*nGPLD*e + nGPLD*(i + 1)); + + faceEdge.jacobian = std::vector(jacobiansLD.begin() + nFaceEdgesPerElm*9*nGPLD*e + 9*nGPLD*i, + jacobiansLD.begin() + nFaceEdgesPerElm*9*nGPLD*e + 9*nGPLD*(i + 1)); + + computeFaceEdgeNormal(faceEdge, elementBarycenters); + + m_faceEdges.push_back(std::move(faceEdge)); + elm.pFaceEdges.push_back(&m_faceEdges.back()); + } + m_elementsHD.push_back(std::move(elm)); entity.pElements.push_back(&m_elementsHD.back()); + + Element& finalElm = m_elementsHD.back(); + for(FaceEdge* pFaceEdge : finalElm.pFaceEdges) + { + pFaceEdge->parentElementHD = &finalElm; + } } } } + +void dgMesh::computeFaceEdgeNormal(FaceEdge& faceEdge, const std::vector& elementBarycenter) +{ + std::vector normal; + + //TO DO: 3D version and 1D version +// double edgeLength = std::sqrt((faceEdge.nodesCoord[0][0] - faceEdge.nodesCoord[1][0]) +// *(faceEdge.nodesCoord[0][0] - faceEdge.nodesCoord[1][0]) +// + (faceEdge.nodesCoord[0][1] - faceEdge.nodesCoord[1][1]) +// *(faceEdge.nodesCoord[0][1] - faceEdge.nodesCoord[1][1]) +// + (faceEdge.nodesCoord[0][2] - faceEdge.nodesCoord[1][2]) +// *(faceEdge.nodesCoord[0][2] - faceEdge.nodesCoord[1][2])); + + // compute the normal + // if A:(x1, y1) and B:(x2, y2), then AB = (x2 - x1, y2 - y1) and a + // normal is given by n = (y2 - y1, x1 - x2) + double nx = faceEdge.nodesCoord[1][1] - faceEdge.nodesCoord[0][1]; + double ny = faceEdge.nodesCoord[0][0] - faceEdge.nodesCoord[1][0]; + double norm = sqrt(ny*ny + nx*nx); + + // unfortunately, nodes per edge in nodes vector are not always in + // the same order (clockwise vs anticlockwise) => we need to check + // the orientation + double vx = elementBarycenter[0] - (faceEdge.nodesCoord[1][0] + faceEdge.nodesCoord[0][0])/2; + double vy = elementBarycenter[1] - (faceEdge.nodesCoord[1][1] + faceEdge.nodesCoord[0][1])/2; + + if(nx*vx + ny*vy > 0) + { + nx = -nx; + ny = -ny; + } + + // normalize the normal components + normal.push_back(nx/norm); + normal.push_back(ny/norm); + + faceEdge.normal = std::move(normal); +} + diff --git a/srcs/dgMesh/dgMesh.hpp b/srcs/dgMesh/dgMesh.hpp index 4bdffea..9183504 100644 --- a/srcs/dgMesh/dgMesh.hpp +++ b/srcs/dgMesh/dgMesh.hpp @@ -66,12 +66,11 @@ class DG_MESH_API dgMesh std::vector jacobian = {}; Entity* pEntity = nullptr; - std::vector faceEdges = {}; + std::vector pFaceEdges = {}; }; struct FaceEdge { - std::size_t tag = -1; std::vector nodesTag = {}; std::vector> nodesCoord = {}; @@ -79,10 +78,14 @@ class DG_MESH_API dgMesh std::vector jacobian = {}; std::vector normal = {}; + Element* parentElementHD = nullptr; Element* elementLD = nullptr; + FaceEdge* edgeInFront = nullptr; }; + void computeFaceEdgeNormal(FaceEdge& faceEdge, const std::vector& elementBarycenter); + struct Entity { int mainTag = -1; @@ -90,6 +93,7 @@ class DG_MESH_API dgMesh std::vector pPhysicalGroups = {}; ElementProperty* pElementProperty = nullptr; + ElementProperty* pFaceEdgePropety = nullptr; std::vector pElements = {}; }; From c0c83bf97fe6b2a976ebe34cd792ca67eb0bf2a6 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 31 Jul 2020 23:48:43 +0200 Subject: [PATCH 06/33] Fix potential invalid pointers due to vector reallocation --- srcs/dgMesh/dgMesh.cpp | 89 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 16 deletions(-) diff --git a/srcs/dgMesh/dgMesh.cpp b/srcs/dgMesh/dgMesh.cpp index 047fa07..5b6782f 100644 --- a/srcs/dgMesh/dgMesh.cpp +++ b/srcs/dgMesh/dgMesh.cpp @@ -111,8 +111,11 @@ void dgMesh::loadPhysicalGroupsAndEntities() + std::to_string(m_dimension) + "."); } - for(std::pair pgHD : physicalGroupsHD) + m_physicalGroupHD.resize(physicalGroupsHD.size()); + for(std::size_t i = 0 ; i < m_physicalGroupHD.size() ; ++i) { + std::pair pgHD = physicalGroupsHD[i]; + std::string pgName; gmsh::model::getPhysicalName(pgHD.first, pgHD.second, pgName); @@ -122,7 +125,11 @@ void dgMesh::loadPhysicalGroupsAndEntities() "D physical group does not have a name."); } - m_physicalGroupHD.push_back({pgHD.second, pgName, {}}); + PhysicalGroup physGroup = { + pgHD.second, pgName, {} + }; + + m_physicalGroupHD[i] = std::move(physGroup); } gmsh::vectorpair physicalGroupsLD; @@ -133,8 +140,11 @@ void dgMesh::loadPhysicalGroupsAndEntities() + std::to_string(m_dimension - 1) + "."); } - for(std::pair pgLD : physicalGroupsLD) + m_physicalGroupLD.resize(physicalGroupsLD.size()); + for(std::size_t i = 0 ; i < m_physicalGroupLD.size() ; ++i) { + std::pair pgLD = physicalGroupsLD[i]; + std::string pgName; gmsh::model::getPhysicalName(pgLD.first, pgLD.second, pgName); @@ -144,7 +154,11 @@ void dgMesh::loadPhysicalGroupsAndEntities() "D physical group does not have a name."); } - m_physicalGroupLD.push_back({pgLD.second, pgName, {}}); + PhysicalGroup physGroup = { + pgLD.second, pgName, {} + }; + + m_physicalGroupLD[i] = std::move(physGroup); } /** @@ -160,15 +174,20 @@ void dgMesh::loadPhysicalGroupsAndEntities() + std::to_string(m_dimension) + "."); } - for(std::pair entityHD : entitiesHD) + m_entitiesHD.resize(entitiesHD.size()); + for(std::size_t i = 0 ; i < m_entitiesHD.size() ; ++i) { - m_entitiesHD.push_back({ + std::pair entityHD = entitiesHD[i]; + + Entity entity = { entityHD.second, -1, {}, nullptr, - {}, - }); + {} + }; + + m_entitiesHD[i] = std::move(entity); } gmsh::vectorpair entitiesLD; @@ -179,15 +198,20 @@ void dgMesh::loadPhysicalGroupsAndEntities() + std::to_string(m_dimension - 1) + "."); } - for(std::pair entityLD : entitiesLD) + m_entitiesLD.resize(entitiesLD.size()); + for(std::size_t i = 0 ; i < m_entitiesLD.size() ; ++i) { - m_entitiesLD.push_back({ + std::pair entityLD = entitiesLD[i]; + + Entity entity = { entityLD.second, -1, {}, nullptr, - {}, - }); + {} + }; + + m_entitiesLD[i] = std::move(entity); } /** We now create the vector of pointers to entities in each physical group **/ @@ -354,8 +378,23 @@ void dgMesh::loadElementsProperty() void dgMesh::loadElements() { - /** Element in HD entities should appear inly once **/ + /** + Get all the elementTags across all entities (assume one elementType per entities!) + and resize the vectors of elements. + **/ + + std::vector dummyElementType; + std::vector> dummyElementTags; + std::vector> dummyNodesTags; + gmsh::model::mesh::getElements(dummyElementType, dummyElementTags, dummyNodesTags, m_dimension); + std::size_t totalElementHDNumber = 0; + for(auto elmTags : dummyElementTags) + totalElementHDNumber += elmTags.size(); + + m_elementsHD.resize(totalElementHDNumber); + + std::size_t totalFaceEdgeNumber = 0; for(Entity& entity : m_entitiesHD) { entity.subTag = gmsh::model::addDiscreteEntity(m_dimension - 1); @@ -390,6 +429,21 @@ void dgMesh::loadElements() gmsh::model::mesh::addElementsByType(entity.subTag, eleTypeSubEntity, {}, nodesTagPerEdge); + totalFaceEdgeNumber += nodesTagPerEdge.size()/entity.pFaceEdgePropety->numNodes; + } + + m_faceEdges.resize(totalFaceEdgeNumber); + + /** Fill the elements vector with th required infos. **/ + + std::size_t elmCounter = 0; + std::size_t faceEdgeCounter = 0; + + for(Entity& entity : m_entitiesHD) + { + std::vector nodesTagPerEdge; + gmsh::model::mesh::getElementEdgeNodes(entity.pElementProperty->type, nodesTagPerEdge, entity.mainTag); + std::vector elementTags; std::vector nodeTags; gmsh::model::mesh::getElementsByType(entity.pElementProperty->type, @@ -413,7 +467,6 @@ void dgMesh::loadElements() unsigned int nNodesElm = entity.pElementProperty->numNodes; unsigned int nElements = elementTags.size(); unsigned int nNodesFaceEdge = entity.pFaceEdgePropety->numNodes; - unsigned int nFaceEdges = nodesTagPerEdge.size()/nNodesFaceEdge; unsigned int nFaceEdgesPerElm = nNodesElm; unsigned int nGPHD = entity.pElementProperty->intPointsWeigth.size(); unsigned int nGPLD = entity.pFaceEdgePropety->intPointsWeigth.size(); @@ -462,11 +515,13 @@ void dgMesh::loadElements() computeFaceEdgeNormal(faceEdge, elementBarycenters); - m_faceEdges.push_back(std::move(faceEdge)); + m_faceEdges[faceEdgeCounter] = std::move(faceEdge); elm.pFaceEdges.push_back(&m_faceEdges.back()); + + faceEdgeCounter++; } - m_elementsHD.push_back(std::move(elm)); + m_elementsHD[elmCounter] = std::move(elm); entity.pElements.push_back(&m_elementsHD.back()); Element& finalElm = m_elementsHD.back(); @@ -474,6 +529,8 @@ void dgMesh::loadElements() { pFaceEdge->parentElementHD = &finalElm; } + + elmCounter++; } } } From 5a8349e0895721505dc2c795f2261e48fe49c37f Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Sun, 2 Aug 2020 16:15:40 +0200 Subject: [PATCH 07/33] First implementation of an "edgeInFront" algorithm --- srcs/dgMesh/dgMesh.cpp | 178 ++++++++++++++++++++++++++++++++++++++++- srcs/dgMesh/dgMesh.hpp | 9 ++- 2 files changed, 181 insertions(+), 6 deletions(-) diff --git a/srcs/dgMesh/dgMesh.cpp b/srcs/dgMesh/dgMesh.cpp index 5b6782f..3d301ba 100644 --- a/srcs/dgMesh/dgMesh.cpp +++ b/srcs/dgMesh/dgMesh.cpp @@ -51,6 +51,10 @@ void dgMesh::loadFromFile(std::string fileName) loadElements(); + checkIfFaceEdgeIsBoundary(); + + associateFaceEdges(); + gmsh::finalize(); } @@ -380,7 +384,64 @@ void dgMesh::loadElements() { /** Get all the elementTags across all entities (assume one elementType per entities!) - and resize the vectors of elements. + and resize the vectors of elements LD. + **/ + + std::vector dummyElementTypeLD; + std::vector> dummyElementTagsLD; + std::vector> dummyNodesTagsLD; + gmsh::model::mesh::getElements(dummyElementTypeLD, dummyElementTagsLD, dummyNodesTagsLD, m_dimension - 1); + + std::size_t totalElementLDNumber = 0; + for(auto elmTags : dummyElementTagsLD) + totalElementLDNumber += elmTags.size(); + + m_elementsLD.resize(totalElementLDNumber); + + /** + Fill the elements LD vector with th required infos (we do not load determinant + and jacobian as it will be loaded in the required faceEdge. + **/ + + std::size_t elmLDCounter = 0; + + for(Entity& entity : m_entitiesLD) + { + std::vector elementTags; + std::vector nodeTags; + gmsh::model::mesh::getElementsByType(entity.pElementProperty->type, + elementTags, nodeTags, entity.mainTag); + + + unsigned int nNodesElm = entity.pElementProperty->numNodes; + unsigned int nElements = elementTags.size(); + + + for(std::size_t e = 0 ; e < nElements ; ++e) + { + Element elm = {}; + elm.tag = elementTags[e]; + elm.nodesTag = std::vector(nodeTags.begin() + nNodesElm*e, + nodeTags.begin() + nNodesElm*(e + 1)); + elm.pEntity = &entity; + + for(std::size_t nodeTag : elm.nodesTag) + { + std::vector coord, dummyParametricCoord; + gmsh::model::mesh::getNode(nodeTag, coord, dummyParametricCoord); + elm.nodesCoord.push_back(coord); + } + + m_elementsLD[elmLDCounter] = std::move(elm); + entity.pElements.push_back(&m_elementsLD.back()); + + elmLDCounter++; + } + } + + /** + Get all the elementTags across all entities (assume one elementType per entities!) + and resize the vectors of elements HD. **/ std::vector dummyElementType; @@ -434,7 +495,7 @@ void dgMesh::loadElements() m_faceEdges.resize(totalFaceEdgeNumber); - /** Fill the elements vector with th required infos. **/ + /** Fill the elements HD vector with th required infos. **/ std::size_t elmCounter = 0; std::size_t faceEdgeCounter = 0; @@ -527,7 +588,7 @@ void dgMesh::loadElements() Element& finalElm = m_elementsHD.back(); for(FaceEdge* pFaceEdge : finalElm.pFaceEdges) { - pFaceEdge->parentElementHD = &finalElm; + pFaceEdge->pParentElementHD = &finalElm; } elmCounter++; @@ -572,4 +633,115 @@ void dgMesh::computeFaceEdgeNormal(FaceEdge& faceEdge, const std::vector faceEdge.normal = std::move(normal); } + +void dgMesh::checkIfFaceEdgeIsBoundary() +{ + assert(m_elementsLD.size() != 0); + + //TO DO: OpenMP This ! As well as use pointers to elementLD to remove elements found + for(FaceEdge& faceEdge : m_faceEdges) + { + for(Element& elementLD : m_elementsLD) + { + if(std::is_permutation(faceEdge.nodesTag.begin(), faceEdge.nodesTag.end(), elementLD.nodesTag.begin())) + { + faceEdge.pElementLD = &elementLD; + break; + } + } + } +} + +void dgMesh::associateFaceEdges() +{ + std::vector pFaceEdges; + + for(FaceEdge& faceEdge : m_faceEdges) + { + if(faceEdge.pElementLD == nullptr) + pFaceEdges.push_back(&faceEdge); + } + + assert(pFaceEdges.size() % 2 == 0); + + while(pFaceEdges.size() != 0) + { + std::vector currentFaceEdgeNodeTag = pFaceEdges[0]->nodesTag; + std::size_t indexInFront = 0; + bool nodesInFrontInverted = false; + + #pragma omp parallel default(shared) + { + #pragma omp for schedule(static) + for(std::size_t i = 1 ; i < pFaceEdges.size() ; ++i) + { + if((currentFaceEdgeNodeTag.front() == pFaceEdges[i]->nodesTag.front()) && + (currentFaceEdgeNodeTag.back() == pFaceEdges[i]->nodesTag.back())) + { + #pragma omp critical + { + indexInFront = i; + nodesInFrontInverted = false; + } + #pragma omp cancel for + } + else if((currentFaceEdgeNodeTag.front() == pFaceEdges[i]->nodesTag.back()) && + (currentFaceEdgeNodeTag.back() == pFaceEdges[i]->nodesTag.front())) + { + #pragma omp critical + { + indexInFront = i; + nodesInFrontInverted = true; + } + #pragma omp cancel for + } + + #pragma omp cancellation point for + } + } + + assert(indexInFront != 0); + + pFaceEdges[0]->pEdgeInFront = pFaceEdges[indexInFront]; + pFaceEdges[0]->nodesInFrontInverted = nodesInFrontInverted; + pFaceEdges[indexInFront]->pEdgeInFront = pFaceEdges[0]; + pFaceEdges[indexInFront]->nodesInFrontInverted = nodesInFrontInverted; + + pFaceEdges.erase(pFaceEdges.begin() + indexInFront); + pFaceEdges.erase(pFaceEdges.begin()); + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/srcs/dgMesh/dgMesh.hpp b/srcs/dgMesh/dgMesh.hpp index 9183504..d8cb061 100644 --- a/srcs/dgMesh/dgMesh.hpp +++ b/srcs/dgMesh/dgMesh.hpp @@ -26,6 +26,8 @@ class DG_MESH_API dgMesh void loadPhysicalGroupsAndEntities(); void loadElementsProperty(); void loadElements(); + void checkIfFaceEdgeIsBoundary(); + void associateFaceEdges(); int m_dimension; @@ -79,9 +81,10 @@ class DG_MESH_API dgMesh std::vector normal = {}; - Element* parentElementHD = nullptr; - Element* elementLD = nullptr; - FaceEdge* edgeInFront = nullptr; + Element* pParentElementHD = nullptr; + Element* pElementLD = nullptr; + FaceEdge* pEdgeInFront = nullptr; + bool nodesInFrontInverted = false; }; void computeFaceEdgeNormal(FaceEdge& faceEdge, const std::vector& elementBarycenter); From 98ac0363b53705f03ddab666a0f446c71f4b8cbd Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Sun, 2 Aug 2020 22:38:20 +0200 Subject: [PATCH 08/33] Fix crash --- srcs/dgMesh/dgMesh.cpp | 54 +++--------------------------------------- srcs/dgMesh/dgMesh.hpp | 1 - 2 files changed, 3 insertions(+), 52 deletions(-) diff --git a/srcs/dgMesh/dgMesh.cpp b/srcs/dgMesh/dgMesh.cpp index 3d301ba..c6e5b33 100644 --- a/srcs/dgMesh/dgMesh.cpp +++ b/srcs/dgMesh/dgMesh.cpp @@ -528,9 +528,9 @@ void dgMesh::loadElements() unsigned int nNodesElm = entity.pElementProperty->numNodes; unsigned int nElements = elementTags.size(); unsigned int nNodesFaceEdge = entity.pFaceEdgePropety->numNodes; - unsigned int nFaceEdgesPerElm = nNodesElm; unsigned int nGPHD = entity.pElementProperty->intPointsWeigth.size(); unsigned int nGPLD = entity.pFaceEdgePropety->intPointsWeigth.size(); + unsigned int nFaceEdgesPerElm = determinantsLD.size()/(nGPLD*nElements); for(std::size_t e = 0 ; e < nElements ; ++e) { @@ -668,30 +668,18 @@ void dgMesh::associateFaceEdges() { std::vector currentFaceEdgeNodeTag = pFaceEdges[0]->nodesTag; std::size_t indexInFront = 0; - bool nodesInFrontInverted = false; #pragma omp parallel default(shared) { #pragma omp for schedule(static) for(std::size_t i = 1 ; i < pFaceEdges.size() ; ++i) { - if((currentFaceEdgeNodeTag.front() == pFaceEdges[i]->nodesTag.front()) && - (currentFaceEdgeNodeTag.back() == pFaceEdges[i]->nodesTag.back())) + if(std::is_permutation(pFaceEdges[i]->nodesTag.begin(), pFaceEdges[i]->nodesTag.end(), + currentFaceEdgeNodeTag.begin())) { #pragma omp critical { indexInFront = i; - nodesInFrontInverted = false; - } - #pragma omp cancel for - } - else if((currentFaceEdgeNodeTag.front() == pFaceEdges[i]->nodesTag.back()) && - (currentFaceEdgeNodeTag.back() == pFaceEdges[i]->nodesTag.front())) - { - #pragma omp critical - { - indexInFront = i; - nodesInFrontInverted = true; } #pragma omp cancel for } @@ -703,45 +691,9 @@ void dgMesh::associateFaceEdges() assert(indexInFront != 0); pFaceEdges[0]->pEdgeInFront = pFaceEdges[indexInFront]; - pFaceEdges[0]->nodesInFrontInverted = nodesInFrontInverted; pFaceEdges[indexInFront]->pEdgeInFront = pFaceEdges[0]; - pFaceEdges[indexInFront]->nodesInFrontInverted = nodesInFrontInverted; pFaceEdges.erase(pFaceEdges.begin() + indexInFront); pFaceEdges.erase(pFaceEdges.begin()); } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/srcs/dgMesh/dgMesh.hpp b/srcs/dgMesh/dgMesh.hpp index d8cb061..41baa19 100644 --- a/srcs/dgMesh/dgMesh.hpp +++ b/srcs/dgMesh/dgMesh.hpp @@ -84,7 +84,6 @@ class DG_MESH_API dgMesh Element* pParentElementHD = nullptr; Element* pElementLD = nullptr; FaceEdge* pEdgeInFront = nullptr; - bool nodesInFrontInverted = false; }; void computeFaceEdgeNormal(FaceEdge& faceEdge, const std::vector& elementBarycenter); From 488a0ae1245b82c8f0f943adb85b7e1428794ed0 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 14:55:01 +0200 Subject: [PATCH 09/33] Update Mesh class --- run/windows/genCBProjectMSYS2.sh | 2 +- run/windows/start.bat | 8 + srcs/CMakeLists.txt | 8 +- srcs/{dgMesh => dG/Mesh}/CMakeLists.txt | 4 +- srcs/dG/Mesh/Element.hpp | 52 ++ srcs/dG/Mesh/Element.inl | 39 ++ srcs/dG/Mesh/ElementProperty.hpp | 27 + srcs/dG/Mesh/Entity.hpp | 54 ++ srcs/dG/Mesh/Entity.inl | 44 ++ srcs/dG/Mesh/Face.hpp | 56 ++ srcs/dG/Mesh/Face.inl | 49 ++ srcs/dG/Mesh/Mesh.cpp | 692 +++++++++++++++++++++++ srcs/dG/Mesh/Mesh.hpp | 67 +++ srcs/dG/Mesh/Mesh.inl | 14 + srcs/dG/Mesh/PhysicalGroup.hpp | 42 ++ srcs/dG/Mesh/PhysicalGroup.inl | 24 + srcs/dgMesh/dgMesh.cpp | 699 ------------------------ srcs/dgMesh/dgMesh.hpp | 125 ----- srcs/dgMesh/dgMesh.inl | 0 srcs/main.cpp | 7 +- 20 files changed, 1179 insertions(+), 834 deletions(-) create mode 100644 run/windows/start.bat rename srcs/{dgMesh => dG/Mesh}/CMakeLists.txt (87%) create mode 100644 srcs/dG/Mesh/Element.hpp create mode 100644 srcs/dG/Mesh/Element.inl create mode 100644 srcs/dG/Mesh/ElementProperty.hpp create mode 100644 srcs/dG/Mesh/Entity.hpp create mode 100644 srcs/dG/Mesh/Entity.inl create mode 100644 srcs/dG/Mesh/Face.hpp create mode 100644 srcs/dG/Mesh/Face.inl create mode 100644 srcs/dG/Mesh/Mesh.cpp create mode 100644 srcs/dG/Mesh/Mesh.hpp create mode 100644 srcs/dG/Mesh/Mesh.inl create mode 100644 srcs/dG/Mesh/PhysicalGroup.hpp create mode 100644 srcs/dG/Mesh/PhysicalGroup.inl delete mode 100644 srcs/dgMesh/dgMesh.cpp delete mode 100644 srcs/dgMesh/dgMesh.hpp delete mode 100644 srcs/dgMesh/dgMesh.inl diff --git a/run/windows/genCBProjectMSYS2.sh b/run/windows/genCBProjectMSYS2.sh index ec0bfc8..cff4731 100644 --- a/run/windows/genCBProjectMSYS2.sh +++ b/run/windows/genCBProjectMSYS2.sh @@ -6,7 +6,7 @@ export GMSHSDK=/c/tools/gmsh-4.6.0-Windows64-sdk #put gmsh sdk here -export PATH=${GMSHSDK}/bin:${GMSHSDK}/lin:${PATH} +export PATH=${GMSHSDK}/bin:${GMSHSDK}/lib:${PATH} export INCLUDE=${GMSHSDK}/include export LIB=${GMSHSDK}/lib diff --git a/run/windows/start.bat b/run/windows/start.bat new file mode 100644 index 0000000..283a3ac --- /dev/null +++ b/run/windows/start.bat @@ -0,0 +1,8 @@ +@ECHO OFF + +set OMP_NUM_THREADS=4 +set OMP_CANCELLATION=TRUE + +dgExe ../../geometry/dispersion.msh + +PAUSE \ No newline at end of file diff --git a/srcs/CMakeLists.txt b/srcs/CMakeLists.txt index b409674..a3fe599 100644 --- a/srcs/CMakeLists.txt +++ b/srcs/CMakeLists.txt @@ -1,8 +1,8 @@ -ADD_SUBDIRECTORY(dgMesh) +ADD_SUBDIRECTORY(dG/Mesh) SET(SRCS main.cpp) -ADD_EXECUTABLE(dgExe ${SRCS}) -TARGET_LINK_LIBRARIES(dgExe PUBLIC dgMesh) -SET_TARGET_PROPERTIES(dgExe PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic-errors -Wold-style-cast -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast -Wshadow") \ No newline at end of file +ADD_EXECUTABLE(DGangoFEtt ${SRCS}) +TARGET_LINK_LIBRARIES(DGangoFEtt PUBLIC dgMesh) +SET_TARGET_PROPERTIES(DGangoFEtt PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic-errors -Wold-style-cast -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast -Wshadow") diff --git a/srcs/dgMesh/CMakeLists.txt b/srcs/dG/Mesh/CMakeLists.txt similarity index 87% rename from srcs/dgMesh/CMakeLists.txt rename to srcs/dG/Mesh/CMakeLists.txt index 4c75d4c..b404c97 100644 --- a/srcs/dgMesh/CMakeLists.txt +++ b/srcs/dG/Mesh/CMakeLists.txt @@ -15,7 +15,9 @@ IF(NOT GMSH_LIBRARIES) ENDIF() SET(LIBMESHSRCS -dgMesh.hpp dgMesh.inl dgMesh.cpp) +Mesh.hpp Mesh.inl Mesh.cpp +Entity.hpp PhysicalGroup.hpp ElementProperty.hpp Element.hpp Face.hpp +Entity.inl PhysicalGroup.inl Element.inl Face.inl) ADD_LIBRARY(dgMesh SHARED ${LIBMESHSRCS}) GENERATE_EXPORT_HEADER(dgMesh diff --git a/srcs/dG/Mesh/Element.hpp b/srcs/dG/Mesh/Element.hpp new file mode 100644 index 0000000..bcb1829 --- /dev/null +++ b/srcs/dG/Mesh/Element.hpp @@ -0,0 +1,52 @@ +#pragma once +#ifndef ELEMENT_HPP_INCLUDED +#define ELEMENT_HPP_INCLUDED + +#include + +#include "dgMesh_export.h" + +namespace dG +{ + class Entity; + class Face; + class Mesh; + + class DG_MESH_API Element + { + public: + Element() = default; + Element(const Element& element) = default; + Element& operator=(const Element& element) = default; + Element(Element&& entity) = default; + Element& operator=(Element&& element) = default; + ~Element() = default; + + inline std::size_t getTag() const noexcept; + inline std::size_t getNodeTag(unsigned short nodeIndex) const noexcept; + inline std::vector getNodeCoord(unsigned short nodeIndex) const noexcept; + inline double getDeterminant(unsigned short gaussPoint) const noexcept; + inline double getJacobian(unsigned short gaussPoint, unsigned short i, unsigned short j) const noexcept; + + inline const Entity& getEntity() const noexcept; + inline const Face& getFace(unsigned short faceIndex) const noexcept; + + private: + std::size_t tag = -1; + std::vector nodesTag = {}; + std::vector> nodesCoord = {}; + + std::vector determinant = {}; + std::vector jacobian = {}; + + Entity* pEntity = nullptr; + std::vector pFaces = {}; + + friend class Mesh; + }; +} + +#include "Element.inl" + +#endif // ELEMENT_HPP_INCLUDED + diff --git a/srcs/dG/Mesh/Element.inl b/srcs/dG/Mesh/Element.inl new file mode 100644 index 0000000..d153241 --- /dev/null +++ b/srcs/dG/Mesh/Element.inl @@ -0,0 +1,39 @@ +#include "Element.hpp" + +namespace dG +{ + inline std::size_t Element::getTag() const noexcept + { + return tag; + } + + inline std::size_t Element::getNodeTag(unsigned short nodeIndex) const noexcept + { + return nodesTag[nodeIndex]; + } + + inline std::vector Element::getNodeCoord(unsigned short nodeIndex) const noexcept + { + return nodesCoord[nodeIndex]; + } + + inline double Element::getDeterminant(unsigned short gaussPoint) const noexcept + { + return determinant[gaussPoint]; + } + + inline double Element::getJacobian(unsigned short gaussPoint, unsigned short i, unsigned short j) const noexcept + { + return jacobian[9*gaussPoint + 3*i + j]; + } + + inline const Entity& Element::getEntity() const noexcept + { + return *pEntity; + } + + inline const Face& Element::getFace(unsigned short faceIndex) const noexcept + { + return *pFaces[faceIndex]; + } +} diff --git a/srcs/dG/Mesh/ElementProperty.hpp b/srcs/dG/Mesh/ElementProperty.hpp new file mode 100644 index 0000000..2c054e3 --- /dev/null +++ b/srcs/dG/Mesh/ElementProperty.hpp @@ -0,0 +1,27 @@ +#pragma once +#ifndef ELEMENTPROPERTY_HPP_INCLUDED +#define ELEMENTPROPERTY_HPP_INCLUDED + +namespace dG +{ + struct ElementProperty + { + int type = -1; + std::string name = {}; + int order = -1; + int numNodes = -1; + std::vector localNodeCoord = {}; + int numPrimaryNodes = -1; + + std::vector intPointsCoord = {}; + std::vector intPointsWeigth = {}; + + int basisFuncNumComp = -1; + std::vector basisFunctions = {}; + + int basisFuncNumCompGrad = -1; + std::vector basisFunctionsGrad = {}; + }; +} + +#endif // ELEMENTPROPERTY_HPP_INCLUDED diff --git a/srcs/dG/Mesh/Entity.hpp b/srcs/dG/Mesh/Entity.hpp new file mode 100644 index 0000000..0f192a8 --- /dev/null +++ b/srcs/dG/Mesh/Entity.hpp @@ -0,0 +1,54 @@ +#pragma once +#ifndef ENTITY_HPP_INCLUDED +#define ENTITY_HPP_INCLUDED + +#include + +#include "dgMesh_export.h" + +namespace dG +{ + class PhysicalGroup; + struct ElementProperty; + class Element; + class Mesh; + + class DG_MESH_API Entity + { + public: + Entity() = default; + Entity(const Entity& entity) = default; + Entity& operator=(const Entity& entity) = default; + Entity(Entity&& entity) = default; + Entity& operator=(Entity&& entity) = default; + ~Entity() = default; + + inline int getMainTag() const noexcept; + inline int getSubTag() const noexcept; + + inline std::size_t getPhysicalGroupCount() const noexcept; + inline const PhysicalGroup& getPhysicalGroup(std::size_t pg) const noexcept; + + inline const ElementProperty& getElementProperty() const noexcept; + inline const ElementProperty& getFaceProperty() const noexcept; + + inline std::size_t getElementCount() const noexcept; + inline const Element& getElement(std::size_t elmIndex) const noexcept; + + private: + int mainTag = -1; + int subTag = -1; + std::vector pPhysicalGroups = {}; + + ElementProperty* pElementProperty = nullptr; + ElementProperty* pFaceProperty = nullptr; + std::vector pElements = {}; + + friend class Mesh; + }; +} + +#include "Entity.inl" + +#endif // ENTITY_HPP_INCLUDED + diff --git a/srcs/dG/Mesh/Entity.inl b/srcs/dG/Mesh/Entity.inl new file mode 100644 index 0000000..3eda054 --- /dev/null +++ b/srcs/dG/Mesh/Entity.inl @@ -0,0 +1,44 @@ +#include "Entity.hpp" + +namespace dG +{ + inline int Entity::getMainTag() const noexcept + { + return mainTag; + } + + inline int Entity::getSubTag() const noexcept + { + return subTag; + } + + inline std::size_t Entity::getPhysicalGroupCount() const noexcept + { + return pPhysicalGroups.size(); + } + + inline const PhysicalGroup& Entity::getPhysicalGroup(std::size_t pg) const noexcept + { + return *pPhysicalGroups[pg]; + } + + inline const ElementProperty& Entity::getElementProperty() const noexcept + { + return *pElementProperty; + } + + inline const ElementProperty& Entity::getFaceProperty() const noexcept + { + return *pFaceProperty; + } + + inline std::size_t Entity::getElementCount() const noexcept + { + return pElements.size(); + } + + inline const Element& Entity::getElement(std::size_t elmIndex) const noexcept + { + return *pElements[elmIndex]; + } +} diff --git a/srcs/dG/Mesh/Face.hpp b/srcs/dG/Mesh/Face.hpp new file mode 100644 index 0000000..37b60f2 --- /dev/null +++ b/srcs/dG/Mesh/Face.hpp @@ -0,0 +1,56 @@ +#pragma once +#ifndef FACE_HPP_INCLUDED +#define FACE_HPP_INCLUDED + +#include + +#include "dgMesh_export.h" + +namespace dG +{ + class Element; + class Mesh; + + class DG_MESH_API Face + { + public: + Face() = default; + Face(const Face& face) = default; + Face& operator=(const Face& face) = default; + Face(Face&& face) = default; + Face& operator=(Face&& face) = default; + ~Face() = default; + + inline std::size_t getNodeTag(unsigned short nodeIndex) const noexcept; + inline std::vector getNodeCoord(unsigned short nodeIndex) const noexcept; + + inline double getDeterminant(unsigned short gaussPoint) const noexcept; + inline double getJacobian(unsigned short gaussPoint, unsigned short i, unsigned short j) const noexcept; + + inline std::vector getNormal() const noexcept; + + inline const Element& getParentElement() const noexcept; + inline bool isOnBOundary() const noexcept; + inline const Element& getBoundaryElement() const noexcept; + inline const Face& getFaceInFront() const noexcept; + + private: + std::vector nodesTag = {}; + std::vector> nodesCoord = {}; + + std::vector determinant = {}; + std::vector jacobian = {}; + + std::vector normal = {}; + + Element* pParentElementHD = nullptr; + Element* pElementLD = nullptr; + Face* pFaceInFront = nullptr; + + friend class Mesh; + }; +} + +#include "Face.inl" + +#endif // FACE_HPP_INCLUDED diff --git a/srcs/dG/Mesh/Face.inl b/srcs/dG/Mesh/Face.inl new file mode 100644 index 0000000..03c8ecc --- /dev/null +++ b/srcs/dG/Mesh/Face.inl @@ -0,0 +1,49 @@ +#include "Face.hpp" + +namespace dG +{ + inline std::size_t Face::getNodeTag(unsigned short nodeIndex) const noexcept + { + return nodesTag[nodeIndex]; + } + + inline std::vector Face::getNodeCoord(unsigned short nodeIndex) const noexcept + { + return nodesCoord[nodeIndex]; + } + + inline double Face::getDeterminant(unsigned short gaussPoint) const noexcept + { + return determinant[gaussPoint]; + } + + inline double Face::getJacobian(unsigned short gaussPoint, unsigned short i, unsigned short j) const noexcept + { + return jacobian[9*gaussPoint + 3*i + j]; + } + + inline std::vector Face::getNormal() const noexcept + { + return normal; + } + + inline const Element& Face::getParentElement() const noexcept + { + return *pParentElementHD; + } + + inline bool Face::isOnBOundary() const noexcept + { + return (pElementLD != nullptr); + } + + inline const Element& Face::getBoundaryElement() const noexcept + { + return *pElementLD; + } + + inline const Face& Face::getFaceInFront() const noexcept + { + return *pFaceInFront; + } +} diff --git a/srcs/dG/Mesh/Mesh.cpp b/srcs/dG/Mesh/Mesh.cpp new file mode 100644 index 0000000..0cee835 --- /dev/null +++ b/srcs/dG/Mesh/Mesh.cpp @@ -0,0 +1,692 @@ +#include "Mesh.hpp" + +#include +#include +#include +#include +#include + +#include + +namespace dG +{ + Mesh::Mesh(std::string integrationType, std::string basisFuncType): + m_dimension(-1), + m_integrationType(integrationType), + m_basisFuncType(basisFuncType) + { + + } + + void Mesh::loadFromFile(std::string fileName) + { + /** + NB: In this work, we will only support mesh with a single element type. + + A geometry is represented by a set of geometrical entities. There is normally entities + for every geometrical object of any dimension in the mesh (points, curves, surfaces and volumes). + Any entity should belong to **at least** one physical group. Every entity is then discretized into + a set of elements (which are called elements regardless of the dimension). + + NB: two entities can have the same tag if they are of different dimension, but not physical groups. + + Multiple meshed of different element types can composed an entity, but we will not support them. + + Despite every entity of any dimension being meshed using elements, one can retrieve the "edges" + and "faces" of an element. + **/ + + //Dummy stream to check if the file exist, because gmsh does not do it. + std::ifstream dummyStream(fileName); + if(!dummyStream.is_open()) + throw std::runtime_error("could not open file " + fileName + "."); + + gmsh::initialize(); + gmsh::option::setNumber("General.Terminal", 1); + gmsh::open(fileName); + + m_dimension = gmsh::model::getDimension(); + + loadPhysicalGroupsAndEntities(); + + loadElementsProperty(); + + loadElements(); + + checkIfFaceIsBoundary(); + + associateFaces(); + + gmsh::finalize(); + } + + void Mesh::displayToConsole() const noexcept + { + std::cout << m_dimension << "D physical groups: " << std::endl; + for(const PhysicalGroup& pg : m_physicalGroupHD) + { + std::cout << "\t * " << pg.name << ": \n"; + std::cout << "\t\t - tag: " << pg.tag << "\n"; + std::cout << "\t\t - entities tag: "; + for(Entity* pEntity : pg.pEntities) + std::cout << pEntity->mainTag << ", "; + std::cout << std::endl; + } + std::cout << std::endl; + + std::cout << m_dimension - 1 << "D physical groups: " << std::endl; + for(const PhysicalGroup& pg : m_physicalGroupLD) + { + std::cout << "\t * " << pg.name << ": \n"; + std::cout << "\t\t - tag: " << pg.tag << "\n"; + std::cout << "\t\t - entities tag: "; + for(Entity* pEntity : pg.pEntities) + std::cout << pEntity->mainTag << ", "; + std::cout << std::endl; + } + std::cout << std::endl; + + std::cout << m_dimension << "D entities: " << std::endl; + for(const Entity& entity : m_entitiesHD) + { + std::cout << "\t * " << entity.mainTag << ": \n"; + std::cout << "\t\t - element type: " << entity.pElementProperty->type << "\n"; + std::cout << "\t\t - element name: " << entity.pElementProperty->name << "\n"; + } + std::cout << std::endl; + + std::cout << m_dimension - 1 << "D entities: " << std::endl; + for(const Entity& entity : m_entitiesLD) + { + std::cout << "\t * " << entity.mainTag << ": \n"; + std::cout << "\t\t - element type: " << entity.pElementProperty->type << "\n"; + std::cout << "\t\t - element name: " << entity.pElementProperty->name << "\n"; + } + std::cout << std::endl; + } + + void Mesh::loadPhysicalGroupsAndEntities() + { + /** We firstly retrieve the physical groups of dimension HD and LD **/ + + gmsh::vectorpair physicalGroupsHD; + gmsh::model::getPhysicalGroups(physicalGroupsHD, m_dimension); + if(physicalGroupsHD.size() == 0) + { + throw std::runtime_error("it seems your mesh does not have any physical groups set for dimension " + + std::to_string(m_dimension) + "."); + } + + m_physicalGroupHD.resize(physicalGroupsHD.size()); + for(std::size_t i = 0 ; i < m_physicalGroupHD.size() ; ++i) + { + std::pair pgHD = physicalGroupsHD[i]; + + std::string pgName; + gmsh::model::getPhysicalName(pgHD.first, pgHD.second, pgName); + + if(pgName.empty()) + { + throw std::runtime_error("one of your " + std::to_string(m_dimension) + + "D physical group does not have a name."); + } + + PhysicalGroup physGroup; + physGroup.tag = pgHD.second; + physGroup.name = pgName; + + m_physicalGroupHD[i] = std::move(physGroup); + } + + gmsh::vectorpair physicalGroupsLD; + gmsh::model::getPhysicalGroups(physicalGroupsLD, m_dimension - 1); + if(physicalGroupsLD.size() == 0) + { + throw std::runtime_error("it seems your mesh does not have any physical groups set for dimension " + + std::to_string(m_dimension - 1) + "."); + } + + m_physicalGroupLD.resize(physicalGroupsLD.size()); + for(std::size_t i = 0 ; i < m_physicalGroupLD.size() ; ++i) + { + std::pair pgLD = physicalGroupsLD[i]; + + std::string pgName; + gmsh::model::getPhysicalName(pgLD.first, pgLD.second, pgName); + + if(pgName.empty()) + { + throw std::runtime_error("one of your " + std::to_string(m_dimension - 1) + + "D physical group does not have a name."); + } + + PhysicalGroup physGroup; + physGroup.tag = pgLD.second; + physGroup.name = pgName; + + m_physicalGroupLD[i] = std::move(physGroup); + } + + /** + We then retrieves the entities of dimension HD and LD. Their names are not + retrieve since we will not use them + **/ + + gmsh::vectorpair entitiesHD; + gmsh::model::getEntities(entitiesHD, m_dimension); + if(entitiesHD.size() == 0) + { + throw std::runtime_error("it seems your mesh does not have any geometry set for dimension " + + std::to_string(m_dimension) + "."); + } + + m_entitiesHD.resize(entitiesHD.size()); + for(std::size_t i = 0 ; i < m_entitiesHD.size() ; ++i) + { + std::pair entityHD = entitiesHD[i]; + + Entity entity; + entity.mainTag = entityHD.second; + + m_entitiesHD[i] = std::move(entity); + } + + gmsh::vectorpair entitiesLD; + gmsh::model::getEntities(entitiesLD, m_dimension -1); + if(entitiesLD.size() == 0) + { + throw std::runtime_error("it seems your mesh does not have any geometry set for dimension " + + std::to_string(m_dimension - 1) + "."); + } + + m_entitiesLD.resize(entitiesLD.size()); + for(std::size_t i = 0 ; i < m_entitiesLD.size() ; ++i) + { + std::pair entityLD = entitiesLD[i]; + + Entity entity; + entity.mainTag = entityLD.second; + + m_entitiesLD[i] = std::move(entity); + } + + /** We now create the vector of pointers to entities in each physical group **/ + + for(PhysicalGroup& pgHD : m_physicalGroupHD) + { + std::vector entitiesTagInPG; + gmsh::model::getEntitiesForPhysicalGroup(m_dimension, pgHD.tag, entitiesTagInPG); + + for(int entityTagInPG : entitiesTagInPG) + { + auto it = std::find_if(m_entitiesHD.begin(), m_entitiesHD.end(), + [entityTagInPG](const Entity& knownEntity) + { + return (entityTagInPG == knownEntity.mainTag); + }); + + assert(it != m_entitiesHD.cend()); + + pgHD.pEntities.push_back(&*it); + } + } + + for(PhysicalGroup& pgLD : m_physicalGroupLD) + { + std::vector entitiesTagInPG; + gmsh::model::getEntitiesForPhysicalGroup(m_dimension - 1, pgLD.tag, entitiesTagInPG); + + for(int entityTagInPG : entitiesTagInPG) + { + auto it = std::find_if(m_entitiesLD.begin(), m_entitiesLD.end(), + [entityTagInPG](const Entity& knownEntity) + { + return (entityTagInPG == knownEntity.mainTag); + }); + + assert(it != m_entitiesLD.cend()); + + pgLD.pEntities.push_back(&*it); + } + } + + /** We now create the vector of pointers to physical group in each entity **/ + + for(Entity& entityHD : m_entitiesHD) + { + std::vector physicalGroupsTagInEntity; + gmsh::model::getPhysicalGroupsForEntity(m_dimension, entityHD.mainTag, physicalGroupsTagInEntity); + + for(int pgTagInEntity : physicalGroupsTagInEntity) + { + auto it = std::find_if(m_physicalGroupHD.begin(), m_physicalGroupHD.end(), + [pgTagInEntity](const PhysicalGroup& knownPG) + { + return (pgTagInEntity == knownPG.tag); + }); + + assert(it != m_physicalGroupHD.cend()); + + entityHD.pPhysicalGroups.push_back(&*it); + } + } + + for(Entity& entityLD : m_entitiesLD) + { + std::vector physicalGroupsTagInEntity; + gmsh::model::getPhysicalGroupsForEntity(m_dimension - 1, entityLD.mainTag, physicalGroupsTagInEntity); + + for(int pgTagInEntity : physicalGroupsTagInEntity) + { + auto it = std::find_if(m_physicalGroupLD.begin(), m_physicalGroupLD.end(), + [pgTagInEntity](const PhysicalGroup& knownPG) + { + return (pgTagInEntity == knownPG.tag); + }); + + assert(it != m_physicalGroupLD.cend()); + + entityLD.pPhysicalGroups.push_back(&*it); + } + } + } + + void Mesh::loadElementsProperty() + { + /** We retrieve all the element property inside the whole mesh **/ + + std::vector elementsType; + gmsh::model::mesh::getElementTypes(elementsType); + + for(int elementType : elementsType) + { + ElementProperty elmProperty; + elmProperty.type = elementType; + int dimension; + gmsh::model::mesh::getElementProperties(elementType, + elmProperty.name, dimension, + elmProperty.order, elmProperty.numNodes, + elmProperty.localNodeCoord, elmProperty.numPrimaryNodes); + + gmsh::model::mesh::getIntegrationPoints(elementType, m_integrationType, + elmProperty.intPointsCoord, + elmProperty.intPointsWeigth); + + int dummyNumOrientation; + gmsh::model::mesh::getBasisFunctions(elementType, elmProperty.intPointsCoord, + m_basisFuncType, elmProperty.basisFuncNumComp, + elmProperty.basisFunctions, dummyNumOrientation); + + assert(dummyNumOrientation == 1); + + gmsh::model::mesh::getBasisFunctions(elementType, elmProperty.intPointsCoord, + "Grad" + m_basisFuncType, elmProperty.basisFuncNumCompGrad, + elmProperty.basisFunctionsGrad, dummyNumOrientation); + + assert(dummyNumOrientation == 1); + + if(dimension == m_dimension) + m_elementsPropertyHD.push_back(std::move(elmProperty)); + else if(dimension == m_dimension - 1) + m_elementsPropertyLD.push_back(std::move(elmProperty)); + } + + /** We now determine which element type is in which entity (no hybrid meshes) **/ + + for(Entity& entity : m_entitiesHD) + { + std::vector elementType; + gmsh::model::mesh::getElementTypes(elementType, m_dimension, entity.mainTag); + + if(elementType.size() != 1) + throw std::runtime_error("Hybrid Meshes are currently not handled"); + + auto it = std::find_if(m_elementsPropertyHD.begin(), m_elementsPropertyHD.end(), + [elementType](const ElementProperty& knownElmProp) + { + return (elementType[0] == knownElmProp.type); + }); + + assert(it != m_elementsPropertyHD.cend()); + + entity.pElementProperty = &*it; + } + + for(Entity& entity : m_entitiesLD) + { + std::vector elementType; + gmsh::model::mesh::getElementTypes(elementType, m_dimension - 1, entity.mainTag); + + if(elementType.size() != 1) + throw std::runtime_error("Hybrid Meshes are currently not handled"); + + auto it = std::find_if(m_elementsPropertyLD.begin(), m_elementsPropertyLD.end(), + [elementType](const ElementProperty& knownElmProp) + { + return (elementType[0] == knownElmProp.type); + }); + + assert(it != m_elementsPropertyLD.cend()); + + entity.pElementProperty = &*it; + } + } + + void Mesh::loadElements() + { + /** + Get all the elementTags across all entities (assume one elementType per entities!) + and resize the vectors of elements LD. + **/ + + std::vector dummyElementTypeLD; + std::vector> dummyElementTagsLD; + std::vector> dummyNodesTagsLD; + gmsh::model::mesh::getElements(dummyElementTypeLD, dummyElementTagsLD, dummyNodesTagsLD, m_dimension - 1); + + std::size_t totalElementLDNumber = 0; + for(auto elmTags : dummyElementTagsLD) + totalElementLDNumber += elmTags.size(); + + m_elementsLD.resize(totalElementLDNumber); + + /** + Fill the elements LD vector with th required infos (we do not load determinant + and jacobian as it will be loaded in the required faceEdge. + **/ + + std::size_t elmLDCounter = 0; + + for(Entity& entity : m_entitiesLD) + { + std::vector elementTags; + std::vector nodeTags; + gmsh::model::mesh::getElementsByType(entity.pElementProperty->type, + elementTags, nodeTags, entity.mainTag); + + + unsigned int nNodesElm = entity.pElementProperty->numNodes; + unsigned int nElements = elementTags.size(); + + + for(std::size_t e = 0 ; e < nElements ; ++e) + { + Element elm = {}; + elm.tag = elementTags[e]; + elm.nodesTag = std::vector(nodeTags.begin() + nNodesElm*e, + nodeTags.begin() + nNodesElm*(e + 1)); + elm.pEntity = &entity; + + for(std::size_t nodeTag : elm.nodesTag) + { + std::vector coord, dummyParametricCoord; + gmsh::model::mesh::getNode(nodeTag, coord, dummyParametricCoord); + elm.nodesCoord.push_back(coord); + } + + m_elementsLD[elmLDCounter] = std::move(elm); + entity.pElements.push_back(&m_elementsLD.back()); + + elmLDCounter++; + } + } + + /** + Get all the elementTags across all entities (assume one elementType per entities!) + and resize the vectors of elements HD. + **/ + + std::vector dummyElementType; + std::vector> dummyElementTags; + std::vector> dummyNodesTags; + gmsh::model::mesh::getElements(dummyElementType, dummyElementTags, dummyNodesTags, m_dimension); + + std::size_t totalElementHDNumber = 0; + for(auto elmTags : dummyElementTags) + totalElementHDNumber += elmTags.size(); + + m_elementsHD.resize(totalElementHDNumber); + + std::size_t totalFaceNumber = 0; + for(Entity& entity : m_entitiesHD) + { + entity.subTag = gmsh::model::addDiscreteEntity(m_dimension - 1); + std::vector nodesTagPerFace; + gmsh::model::mesh::getElementEdgeNodes(entity.pElementProperty->type, nodesTagPerFace, entity.mainTag); + int eleTypeSubEntity; + switch(m_dimension) + { + case 1: + eleTypeSubEntity = gmsh::model::mesh::getElementType("point", entity.pElementProperty->order); + break; + + case 2: + eleTypeSubEntity = gmsh::model::mesh::getElementType("line", entity.pElementProperty->order); + break; + + case 3: + eleTypeSubEntity = gmsh::model::mesh::getElementType("line", entity.pElementProperty->order); + break; + } + + for(auto& elmProp : m_elementsPropertyLD) + { + if(elmProp.type == eleTypeSubEntity) + { + entity.pFaceProperty = &elmProp; + break; + } + } + + assert(entity.pFaceProperty != nullptr); + + gmsh::model::mesh::addElementsByType(entity.subTag, eleTypeSubEntity, {}, nodesTagPerFace); + + totalFaceNumber += nodesTagPerFace.size()/entity.pFaceProperty->numNodes; + } + + m_faces.resize(totalFaceNumber); + + /** Fill the elements HD vector with th required infos. **/ + + std::size_t elmCounter = 0; + std::size_t faceCounter = 0; + + for(Entity& entity : m_entitiesHD) + { + std::vector nodesTagPerFace; + gmsh::model::mesh::getElementEdgeNodes(entity.pElementProperty->type, nodesTagPerFace, entity.mainTag); + + std::vector elementTags; + std::vector nodeTags; + gmsh::model::mesh::getElementsByType(entity.pElementProperty->type, + elementTags, nodeTags, entity.mainTag); + + std::vector jacobiansHD; + std::vector determinantsHD; + std::vector dummyCoordHD; + gmsh::model::mesh::getJacobians(entity.pElementProperty->type, entity.pElementProperty->intPointsCoord, + jacobiansHD, determinantsHD, dummyCoordHD, entity.mainTag); + + std::vector jacobiansLD; + std::vector determinantsLD; + std::vector dummyCoordLD; + gmsh::model::mesh::getJacobians(entity.pFaceProperty->type, entity.pFaceProperty->intPointsCoord, + jacobiansLD, determinantsLD, dummyCoordLD, entity.subTag); + + std::vector baryCenters; + gmsh::model::mesh::getBarycenters(entity.pElementProperty->type, entity.mainTag, false, true, baryCenters); + + unsigned int nNodesElm = entity.pElementProperty->numNodes; + unsigned int nElements = elementTags.size(); + unsigned int nNodesFace = entity.pFaceProperty->numNodes; + unsigned int nGPHD = entity.pElementProperty->intPointsWeigth.size(); + unsigned int nGPLD = entity.pFaceProperty->intPointsWeigth.size(); + unsigned int nFacesPerElm = determinantsLD.size()/(nGPLD*nElements); + + for(std::size_t e = 0 ; e < nElements ; ++e) + { + Element elm = {}; + elm.tag = elementTags[e]; + elm.nodesTag = std::vector(nodeTags.begin() + nNodesElm*e, + nodeTags.begin() + nNodesElm*(e + 1)); + elm.determinant = std::vector(determinantsHD.begin() + nGPHD*e, + determinantsHD.begin() + nGPHD*(e + 1)); + elm.jacobian = std::vector(jacobiansHD.begin() + 9*nGPHD*e, + jacobiansHD.begin() + 9*nGPHD*(e + 1)); + elm.pEntity = &entity; + + for(std::size_t nodeTag : elm.nodesTag) + { + std::vector coord, dummyParametricCoord; + gmsh::model::mesh::getNode(nodeTag, coord, dummyParametricCoord); + elm.nodesCoord.push_back(coord); + } + + std::vector elementBarycenters(baryCenters.begin() + 3*e, + baryCenters.begin() + 3*(e + 1)); + + for(unsigned int i = 0 ; i < nFacesPerElm ; ++i) + { + Face face = {}; + + face.nodesTag = std::vector(nodesTagPerFace.begin() + nNodesFace*nFacesPerElm*e + nNodesFace*i, + nodesTagPerFace.begin() + nNodesFace*nFacesPerElm*e + nNodesFace*(i + 1)); + + for(std::size_t nodeTag : face.nodesTag) + { + std::vector coord, dummyParametricCoord; + gmsh::model::mesh::getNode(nodeTag, coord, dummyParametricCoord); + face.nodesCoord.push_back(coord); + } + + face.determinant = std::vector(determinantsLD.begin() + nFacesPerElm*nGPLD*e + nGPLD*i, + determinantsLD.begin() + nFacesPerElm*nGPLD*e + nGPLD*(i + 1)); + + face.jacobian = std::vector(jacobiansLD.begin() + nFacesPerElm*9*nGPLD*e + 9*nGPLD*i, + jacobiansLD.begin() + nFacesPerElm*9*nGPLD*e + 9*nGPLD*(i + 1)); + + computeFaceNormal(face, elementBarycenters); + + m_faces[faceCounter] = std::move(face); + elm.pFaces.push_back(&m_faces.back()); + + faceCounter++; + } + + m_elementsHD[elmCounter] = std::move(elm); + entity.pElements.push_back(&m_elementsHD.back()); + + Element& finalElm = m_elementsHD.back(); + for(Face* pFace : finalElm.pFaces) + { + pFace->pParentElementHD = &finalElm; + } + + elmCounter++; + } + } + } + + void Mesh::computeFaceNormal(Face& face, const std::vector& elementBarycenter) + { + std::vector normal; + + //TO DO: 3D version and 1D version + // double edgeLength = std::sqrt((faceEdge.nodesCoord[0][0] - faceEdge.nodesCoord[1][0]) + // *(faceEdge.nodesCoord[0][0] - faceEdge.nodesCoord[1][0]) + // + (faceEdge.nodesCoord[0][1] - faceEdge.nodesCoord[1][1]) + // *(faceEdge.nodesCoord[0][1] - faceEdge.nodesCoord[1][1]) + // + (faceEdge.nodesCoord[0][2] - faceEdge.nodesCoord[1][2]) + // *(faceEdge.nodesCoord[0][2] - faceEdge.nodesCoord[1][2])); + + // compute the normal + // if A:(x1, y1) and B:(x2, y2), then AB = (x2 - x1, y2 - y1) and a + // normal is given by n = (y2 - y1, x1 - x2) + double nx = face.nodesCoord[1][1] - face.nodesCoord[0][1]; + double ny = face.nodesCoord[0][0] - face.nodesCoord[1][0]; + double norm = sqrt(ny*ny + nx*nx); + + // unfortunately, nodes per edge in nodes vector are not always in + // the same order (clockwise vs anticlockwise) => we need to check + // the orientation + double vx = elementBarycenter[0] - (face.nodesCoord[1][0] + face.nodesCoord[0][0])/2; + double vy = elementBarycenter[1] - (face.nodesCoord[1][1] + face.nodesCoord[0][1])/2; + + if(nx*vx + ny*vy > 0) + { + nx = -nx; + ny = -ny; + } + + // normalize the normal components + normal.push_back(nx/norm); + normal.push_back(ny/norm); + + face.normal = std::move(normal); + } + + void Mesh::checkIfFaceIsBoundary() + { + assert(m_elementsLD.size() != 0); + + //TO DO: OpenMP This ! As well as use pointers to elementLD to remove elements found + for(Face& face : m_faces) + { + for(Element& elementLD : m_elementsLD) + { + if(std::is_permutation(face.nodesTag.begin(), face.nodesTag.end(), elementLD.nodesTag.begin())) + { + face.pElementLD = &elementLD; + break; + } + } + } + } + + void Mesh::associateFaces() + { + std::vector pFaces; + + for(Face& face : m_faces) + { + if(face.pElementLD == nullptr) + pFaces.push_back(&face); + } + + assert(pFaces.size() % 2 == 0); + + while(pFaces.size() != 0) + { + std::vector currentFaceNodeTag = pFaces[0]->nodesTag; + std::size_t indexInFront = 0; + + #pragma omp parallel default(shared) + { + #pragma omp for schedule(static) + for(std::size_t i = 1 ; i < pFaces.size() ; ++i) + { + if(std::is_permutation(pFaces[i]->nodesTag.begin(), pFaces[i]->nodesTag.end(), + currentFaceNodeTag.begin())) + { + #pragma omp critical + { + indexInFront = i; + } + #pragma omp cancel for + } + + #pragma omp cancellation point for + } + } + + assert(indexInFront != 0); + + pFaces[0]->pFaceInFront = pFaces[indexInFront]; + pFaces[indexInFront]->pFaceInFront = pFaces[0]; + + pFaces.erase(pFaces.begin() + indexInFront); + pFaces.erase(pFaces.begin()); + } + } +} diff --git a/srcs/dG/Mesh/Mesh.hpp b/srcs/dG/Mesh/Mesh.hpp new file mode 100644 index 0000000..65fabed --- /dev/null +++ b/srcs/dG/Mesh/Mesh.hpp @@ -0,0 +1,67 @@ +#pragma once +#ifndef MESH_HPP_INCLUDED +#define MESH_HPP_INCLUDED + +#include +#include +#include + +#include "PhysicalGroup.hpp" +#include "Entity.hpp" +#include "Element.hpp" +#include "Face.hpp" +#include "ElementProperty.hpp" + +#include "dgMesh_export.h" + +namespace dG +{ + class DG_MESH_API Mesh + { + public: + Mesh() = delete; + Mesh(std::string integrationType, std::string basisFuncType); + Mesh(const Mesh& mesh) = delete; + Mesh& operator=(const Mesh& mesh) = delete; + Mesh(Mesh&& mesh) = delete; + Mesh& operator=(Mesh&& mesh) = delete; + ~Mesh() = default; + + void displayToConsole() const noexcept; + void loadFromFile(std::string fileName); + + inline unsigned int getEntityHDCount() const noexcept; + inline const Entity& getEntityHD(unsigned int entityIndex) const noexcept; + + private: + void loadPhysicalGroupsAndEntities(); + void loadElementsProperty(); + void loadElements(); + void checkIfFaceIsBoundary(); + void associateFaces(); + + void computeFaceNormal(Face& face, const std::vector& elementBarycenter); + + int m_dimension; + + std::string m_integrationType; + std::string m_basisFuncType; + + std::vector m_physicalGroupHD; + std::vector m_physicalGroupLD; + + std::vector m_entitiesHD; + std::vector m_entitiesLD; + + std::vector m_elementsPropertyHD; + std::vector m_elementsPropertyLD; + + std::vector m_elementsHD; + std::vector m_elementsLD; + std::vector m_faces; + }; +} + +#include "Mesh.inl" + +#endif // MESH_HPP_INCLUDED diff --git a/srcs/dG/Mesh/Mesh.inl b/srcs/dG/Mesh/Mesh.inl new file mode 100644 index 0000000..9b197cd --- /dev/null +++ b/srcs/dG/Mesh/Mesh.inl @@ -0,0 +1,14 @@ +#include "Mesh.hpp" + +namespace dG +{ + inline unsigned int Mesh::getEntityHDCount() const noexcept + { + return m_entitiesHD.size(); + } + + inline const Entity& Mesh::getEntityHD(unsigned int entityIndex) const noexcept + { + return m_entitiesHD[entityIndex]; + } +} diff --git a/srcs/dG/Mesh/PhysicalGroup.hpp b/srcs/dG/Mesh/PhysicalGroup.hpp new file mode 100644 index 0000000..ef254b7 --- /dev/null +++ b/srcs/dG/Mesh/PhysicalGroup.hpp @@ -0,0 +1,42 @@ +#pragma once +#ifndef PHYSICALGROUP_HPP_INCLUDED +#define PHYSICALGROUP_HPP_INCLUDED + +#include +#include + +#include "dgMesh_export.h" + +namespace dG +{ + class Entity; + class Mesh; + + class DG_MESH_API PhysicalGroup + { + public: + PhysicalGroup() = default; + PhysicalGroup(const PhysicalGroup& entity) = default; + PhysicalGroup& operator=(const PhysicalGroup& entity) = default; + PhysicalGroup(PhysicalGroup&& entity) = default; + PhysicalGroup& operator=(PhysicalGroup&& entity) = default; + ~PhysicalGroup() = default; + + inline int getTag() const noexcept; + inline std::string getName() const noexcept; + + inline std::size_t getEntityCount() const noexcept; + inline const Entity& getEntity(std::size_t entity) const noexcept; + + private: + int tag = -1; + std::string name = {}; + std::vector pEntities = {}; + + friend class Mesh; + }; +} + +#include "PhysicalGroup.inl" + +#endif // PHYSICALGROUP_HPP_INCLUDED diff --git a/srcs/dG/Mesh/PhysicalGroup.inl b/srcs/dG/Mesh/PhysicalGroup.inl new file mode 100644 index 0000000..20d9bbe --- /dev/null +++ b/srcs/dG/Mesh/PhysicalGroup.inl @@ -0,0 +1,24 @@ +#include "PhysicalGroup.hpp" + +namespace dG +{ + inline int PhysicalGroup::getTag() const noexcept + { + return tag; + } + + inline std::string PhysicalGroup::getName() const noexcept + { + return name; + } + + inline std::size_t PhysicalGroup::getEntityCount() const noexcept + { + return pEntities.size(); + } + + inline const Entity& PhysicalGroup::getEntity(std::size_t entity) const noexcept + { + return *pEntities[entity]; + } +} diff --git a/srcs/dgMesh/dgMesh.cpp b/srcs/dgMesh/dgMesh.cpp deleted file mode 100644 index c6e5b33..0000000 --- a/srcs/dgMesh/dgMesh.cpp +++ /dev/null @@ -1,699 +0,0 @@ -#include "dgMesh.hpp" - -#include -#include -#include -#include -#include - -#include - -dgMesh::dgMesh(std::string integrationType, std::string basisFuncType): -m_dimension(-1), -m_integrationType(integrationType), -m_basisFuncType(basisFuncType) -{ - -} - -void dgMesh::loadFromFile(std::string fileName) -{ - /** - NB: In this work, we will only support mesh with a single element type. - - A geometry is represented by a set of geometrical entities. There is normally entities - for every geometrical object of any dimension in the mesh (points, curves, surfaces and volumes). - Any entity should belong to **at least** one physical group. Every entity is then discretized into - a set of elements (which are called elements regardless of the dimension). - - NB: two entities can have the same tag if they are of different dimension, but not physical groups. - - Multiple meshed of different element types can composed an entity, but we will not support them. - - Despite every entity of any dimension being meshed using elements, one can retrieve the "edges" - and "faces" of an element. - **/ - - //Dummy stream to check if the file exist, because gmsh does not do it. - std::ifstream dummyStream(fileName); - if(!dummyStream.is_open()) - throw std::runtime_error("could not open file " + fileName + "."); - - gmsh::initialize(); - gmsh::option::setNumber("General.Terminal", 1); - gmsh::open(fileName); - - m_dimension = gmsh::model::getDimension(); - - loadPhysicalGroupsAndEntities(); - - loadElementsProperty(); - - loadElements(); - - checkIfFaceEdgeIsBoundary(); - - associateFaceEdges(); - - gmsh::finalize(); -} - -void dgMesh::displayToConsole() const noexcept -{ - std::cout << m_dimension << "D physical groups: " << std::endl; - for(PhysicalGroup pg : m_physicalGroupHD) - { - std::cout << "\t * " << pg.name << ": \n"; - std::cout << "\t\t - tag: " << pg.tag << "\n"; - std::cout << "\t\t - entities tag: "; - for(Entity* pEntity : pg.pEntities) - std::cout << pEntity->mainTag << ", "; - std::cout << std::endl; - } - std::cout << std::endl; - - std::cout << m_dimension - 1 << "D physical groups: " << std::endl; - for(PhysicalGroup pg : m_physicalGroupLD) - { - std::cout << "\t * " << pg.name << ": \n"; - std::cout << "\t\t - tag: " << pg.tag << "\n"; - std::cout << "\t\t - entities tag: "; - for(Entity* pEntity : pg.pEntities) - std::cout << pEntity->mainTag << ", "; - std::cout << std::endl; - } - std::cout << std::endl; - - std::cout << m_dimension << "D entities: " << std::endl; - for(Entity entity : m_entitiesHD) - { - std::cout << "\t * " << entity.mainTag << ": \n"; - std::cout << "\t\t - element type: " << entity.pElementProperty->type << "\n"; - std::cout << "\t\t - element name: " << entity.pElementProperty->name << "\n"; - } - std::cout << std::endl; - - std::cout << m_dimension - 1 << "D entities: " << std::endl; - for(Entity entity : m_entitiesLD) - { - std::cout << "\t * " << entity.mainTag << ": \n"; - std::cout << "\t\t - element type: " << entity.pElementProperty->type << "\n"; - std::cout << "\t\t - element name: " << entity.pElementProperty->name << "\n"; - } - std::cout << std::endl; -} - -void dgMesh::loadPhysicalGroupsAndEntities() -{ - /** We firstly retrieve the physical groups of dimension HD and LD **/ - - gmsh::vectorpair physicalGroupsHD; - gmsh::model::getPhysicalGroups(physicalGroupsHD, m_dimension); - if(physicalGroupsHD.size() == 0) - { - throw std::runtime_error("it seems your mesh does not have any physical groups set for dimension " - + std::to_string(m_dimension) + "."); - } - - m_physicalGroupHD.resize(physicalGroupsHD.size()); - for(std::size_t i = 0 ; i < m_physicalGroupHD.size() ; ++i) - { - std::pair pgHD = physicalGroupsHD[i]; - - std::string pgName; - gmsh::model::getPhysicalName(pgHD.first, pgHD.second, pgName); - - if(pgName.empty()) - { - throw std::runtime_error("one of your " + std::to_string(m_dimension) + - "D physical group does not have a name."); - } - - PhysicalGroup physGroup = { - pgHD.second, pgName, {} - }; - - m_physicalGroupHD[i] = std::move(physGroup); - } - - gmsh::vectorpair physicalGroupsLD; - gmsh::model::getPhysicalGroups(physicalGroupsLD, m_dimension - 1); - if(physicalGroupsLD.size() == 0) - { - throw std::runtime_error("it seems your mesh does not have any physical groups set for dimension " - + std::to_string(m_dimension - 1) + "."); - } - - m_physicalGroupLD.resize(physicalGroupsLD.size()); - for(std::size_t i = 0 ; i < m_physicalGroupLD.size() ; ++i) - { - std::pair pgLD = physicalGroupsLD[i]; - - std::string pgName; - gmsh::model::getPhysicalName(pgLD.first, pgLD.second, pgName); - - if(pgName.empty()) - { - throw std::runtime_error("one of your " + std::to_string(m_dimension - 1) + - "D physical group does not have a name."); - } - - PhysicalGroup physGroup = { - pgLD.second, pgName, {} - }; - - m_physicalGroupLD[i] = std::move(physGroup); - } - - /** - We then retrieves the entities of dimension HD and LD. Their names are not - retrieve since we will not use them - **/ - - gmsh::vectorpair entitiesHD; - gmsh::model::getEntities(entitiesHD, m_dimension); - if(entitiesHD.size() == 0) - { - throw std::runtime_error("it seems your mesh does not have any geometry set for dimension " - + std::to_string(m_dimension) + "."); - } - - m_entitiesHD.resize(entitiesHD.size()); - for(std::size_t i = 0 ; i < m_entitiesHD.size() ; ++i) - { - std::pair entityHD = entitiesHD[i]; - - Entity entity = { - entityHD.second, - -1, - {}, - nullptr, - {} - }; - - m_entitiesHD[i] = std::move(entity); - } - - gmsh::vectorpair entitiesLD; - gmsh::model::getEntities(entitiesLD, m_dimension -1); - if(entitiesLD.size() == 0) - { - throw std::runtime_error("it seems your mesh does not have any geometry set for dimension " - + std::to_string(m_dimension - 1) + "."); - } - - m_entitiesLD.resize(entitiesLD.size()); - for(std::size_t i = 0 ; i < m_entitiesLD.size() ; ++i) - { - std::pair entityLD = entitiesLD[i]; - - Entity entity = { - entityLD.second, - -1, - {}, - nullptr, - {} - }; - - m_entitiesLD[i] = std::move(entity); - } - - /** We now create the vector of pointers to entities in each physical group **/ - - for(PhysicalGroup& pgHD : m_physicalGroupHD) - { - std::vector entitiesTagInPG; - gmsh::model::getEntitiesForPhysicalGroup(m_dimension, pgHD.tag, entitiesTagInPG); - - for(int entityTagInPG : entitiesTagInPG) - { - auto it = std::find_if(m_entitiesHD.begin(), m_entitiesHD.end(), - [entityTagInPG](const Entity& knownEntity) - { - return (entityTagInPG == knownEntity.mainTag); - }); - - assert(it != m_entitiesHD.cend()); - - pgHD.pEntities.push_back(&*it); - } - } - - for(PhysicalGroup& pgLD : m_physicalGroupLD) - { - std::vector entitiesTagInPG; - gmsh::model::getEntitiesForPhysicalGroup(m_dimension - 1, pgLD.tag, entitiesTagInPG); - - for(int entityTagInPG : entitiesTagInPG) - { - auto it = std::find_if(m_entitiesLD.begin(), m_entitiesLD.end(), - [entityTagInPG](const Entity& knownEntity) - { - return (entityTagInPG == knownEntity.mainTag); - }); - - assert(it != m_entitiesLD.cend()); - - pgLD.pEntities.push_back(&*it); - } - } - - /** We now create the vector of pointers to physical group in each entity **/ - - for(Entity& entityHD : m_entitiesHD) - { - std::vector physicalGroupsTagInEntity; - gmsh::model::getPhysicalGroupsForEntity(m_dimension, entityHD.mainTag, physicalGroupsTagInEntity); - - for(int pgTagInEntity : physicalGroupsTagInEntity) - { - auto it = std::find_if(m_physicalGroupHD.begin(), m_physicalGroupHD.end(), - [pgTagInEntity](const PhysicalGroup& knownPG) - { - return (pgTagInEntity == knownPG.tag); - }); - - assert(it != m_physicalGroupHD.cend()); - - entityHD.pPhysicalGroups.push_back(&*it); - } - } - - for(Entity& entityLD : m_entitiesLD) - { - std::vector physicalGroupsTagInEntity; - gmsh::model::getPhysicalGroupsForEntity(m_dimension - 1, entityLD.mainTag, physicalGroupsTagInEntity); - - for(int pgTagInEntity : physicalGroupsTagInEntity) - { - auto it = std::find_if(m_physicalGroupLD.begin(), m_physicalGroupLD.end(), - [pgTagInEntity](const PhysicalGroup& knownPG) - { - return (pgTagInEntity == knownPG.tag); - }); - - assert(it != m_physicalGroupLD.cend()); - - entityLD.pPhysicalGroups.push_back(&*it); - } - } -} - -void dgMesh::loadElementsProperty() -{ - /** We retrieve all the element property inside the whole mesh **/ - - std::vector elementsType; - gmsh::model::mesh::getElementTypes(elementsType); - - for(int elementType : elementsType) - { - ElementProperty elmProperty; - elmProperty.type = elementType; - int dimension; - gmsh::model::mesh::getElementProperties(elementType, - elmProperty.name, dimension, - elmProperty.order, elmProperty.numNodes, - elmProperty.localNodeCoord, elmProperty.numPrimaryNodes); - - gmsh::model::mesh::getIntegrationPoints(elementType, m_integrationType, - elmProperty.intPointsCoord, - elmProperty.intPointsWeigth); - - int dummyNumOrientation; - gmsh::model::mesh::getBasisFunctions(elementType, elmProperty.intPointsCoord, - m_basisFuncType, elmProperty.basisFuncNumComp, - elmProperty.basisFunctions, dummyNumOrientation); - - assert(dummyNumOrientation == 1); - - gmsh::model::mesh::getBasisFunctions(elementType, elmProperty.intPointsCoord, - "Grad" + m_basisFuncType, elmProperty.basisFuncNumCompGrad, - elmProperty.basisFunctionsGrad, dummyNumOrientation); - - assert(dummyNumOrientation == 1); - - if(dimension == m_dimension) - m_elementsPropertyHD.push_back(std::move(elmProperty)); - else if(dimension == m_dimension - 1) - m_elementsPropertyLD.push_back(std::move(elmProperty)); - } - - /** We now determine which element type is in which entity (no hybrid meshes) **/ - - for(Entity& entity : m_entitiesHD) - { - std::vector elementType; - gmsh::model::mesh::getElementTypes(elementType, m_dimension, entity.mainTag); - - if(elementType.size() != 1) - throw std::runtime_error("Hybrid Meshes are currently not handled"); - - auto it = std::find_if(m_elementsPropertyHD.begin(), m_elementsPropertyHD.end(), - [elementType](const ElementProperty& knownElmProp) - { - return (elementType[0] == knownElmProp.type); - }); - - assert(it != m_elementsPropertyHD.cend()); - - entity.pElementProperty = &*it; - } - - for(Entity& entity : m_entitiesLD) - { - std::vector elementType; - gmsh::model::mesh::getElementTypes(elementType, m_dimension - 1, entity.mainTag); - - if(elementType.size() != 1) - throw std::runtime_error("Hybrid Meshes are currently not handled"); - - auto it = std::find_if(m_elementsPropertyLD.begin(), m_elementsPropertyLD.end(), - [elementType](const ElementProperty& knownElmProp) - { - return (elementType[0] == knownElmProp.type); - }); - - assert(it != m_elementsPropertyLD.cend()); - - entity.pElementProperty = &*it; - } -} - -void dgMesh::loadElements() -{ - /** - Get all the elementTags across all entities (assume one elementType per entities!) - and resize the vectors of elements LD. - **/ - - std::vector dummyElementTypeLD; - std::vector> dummyElementTagsLD; - std::vector> dummyNodesTagsLD; - gmsh::model::mesh::getElements(dummyElementTypeLD, dummyElementTagsLD, dummyNodesTagsLD, m_dimension - 1); - - std::size_t totalElementLDNumber = 0; - for(auto elmTags : dummyElementTagsLD) - totalElementLDNumber += elmTags.size(); - - m_elementsLD.resize(totalElementLDNumber); - - /** - Fill the elements LD vector with th required infos (we do not load determinant - and jacobian as it will be loaded in the required faceEdge. - **/ - - std::size_t elmLDCounter = 0; - - for(Entity& entity : m_entitiesLD) - { - std::vector elementTags; - std::vector nodeTags; - gmsh::model::mesh::getElementsByType(entity.pElementProperty->type, - elementTags, nodeTags, entity.mainTag); - - - unsigned int nNodesElm = entity.pElementProperty->numNodes; - unsigned int nElements = elementTags.size(); - - - for(std::size_t e = 0 ; e < nElements ; ++e) - { - Element elm = {}; - elm.tag = elementTags[e]; - elm.nodesTag = std::vector(nodeTags.begin() + nNodesElm*e, - nodeTags.begin() + nNodesElm*(e + 1)); - elm.pEntity = &entity; - - for(std::size_t nodeTag : elm.nodesTag) - { - std::vector coord, dummyParametricCoord; - gmsh::model::mesh::getNode(nodeTag, coord, dummyParametricCoord); - elm.nodesCoord.push_back(coord); - } - - m_elementsLD[elmLDCounter] = std::move(elm); - entity.pElements.push_back(&m_elementsLD.back()); - - elmLDCounter++; - } - } - - /** - Get all the elementTags across all entities (assume one elementType per entities!) - and resize the vectors of elements HD. - **/ - - std::vector dummyElementType; - std::vector> dummyElementTags; - std::vector> dummyNodesTags; - gmsh::model::mesh::getElements(dummyElementType, dummyElementTags, dummyNodesTags, m_dimension); - - std::size_t totalElementHDNumber = 0; - for(auto elmTags : dummyElementTags) - totalElementHDNumber += elmTags.size(); - - m_elementsHD.resize(totalElementHDNumber); - - std::size_t totalFaceEdgeNumber = 0; - for(Entity& entity : m_entitiesHD) - { - entity.subTag = gmsh::model::addDiscreteEntity(m_dimension - 1); - std::vector nodesTagPerEdge; - gmsh::model::mesh::getElementEdgeNodes(entity.pElementProperty->type, nodesTagPerEdge, entity.mainTag); - int eleTypeSubEntity; - switch(m_dimension) - { - case 1: - eleTypeSubEntity = gmsh::model::mesh::getElementType("point", entity.pElementProperty->order); - break; - - case 2: - eleTypeSubEntity = gmsh::model::mesh::getElementType("line", entity.pElementProperty->order); - break; - - case 3: - eleTypeSubEntity = gmsh::model::mesh::getElementType("line", entity.pElementProperty->order); - break; - } - - for(auto& elmProp : m_elementsPropertyLD) - { - if(elmProp.type == eleTypeSubEntity) - { - entity.pFaceEdgePropety = &elmProp; - break; - } - } - - assert(entity.pFaceEdgePropety != nullptr); - - gmsh::model::mesh::addElementsByType(entity.subTag, eleTypeSubEntity, {}, nodesTagPerEdge); - - totalFaceEdgeNumber += nodesTagPerEdge.size()/entity.pFaceEdgePropety->numNodes; - } - - m_faceEdges.resize(totalFaceEdgeNumber); - - /** Fill the elements HD vector with th required infos. **/ - - std::size_t elmCounter = 0; - std::size_t faceEdgeCounter = 0; - - for(Entity& entity : m_entitiesHD) - { - std::vector nodesTagPerEdge; - gmsh::model::mesh::getElementEdgeNodes(entity.pElementProperty->type, nodesTagPerEdge, entity.mainTag); - - std::vector elementTags; - std::vector nodeTags; - gmsh::model::mesh::getElementsByType(entity.pElementProperty->type, - elementTags, nodeTags, entity.mainTag); - - std::vector jacobiansHD; - std::vector determinantsHD; - std::vector dummyCoordHD; - gmsh::model::mesh::getJacobians(entity.pElementProperty->type, entity.pElementProperty->intPointsCoord, - jacobiansHD, determinantsHD, dummyCoordHD, entity.mainTag); - - std::vector jacobiansLD; - std::vector determinantsLD; - std::vector dummyCoordLD; - gmsh::model::mesh::getJacobians(entity.pFaceEdgePropety->type, entity.pFaceEdgePropety->intPointsCoord, - jacobiansLD, determinantsLD, dummyCoordLD, entity.subTag); - - std::vector baryCenters; - gmsh::model::mesh::getBarycenters(entity.pElementProperty->type, entity.mainTag, false, true, baryCenters); - - unsigned int nNodesElm = entity.pElementProperty->numNodes; - unsigned int nElements = elementTags.size(); - unsigned int nNodesFaceEdge = entity.pFaceEdgePropety->numNodes; - unsigned int nGPHD = entity.pElementProperty->intPointsWeigth.size(); - unsigned int nGPLD = entity.pFaceEdgePropety->intPointsWeigth.size(); - unsigned int nFaceEdgesPerElm = determinantsLD.size()/(nGPLD*nElements); - - for(std::size_t e = 0 ; e < nElements ; ++e) - { - Element elm = {}; - elm.tag = elementTags[e]; - elm.nodesTag = std::vector(nodeTags.begin() + nNodesElm*e, - nodeTags.begin() + nNodesElm*(e + 1)); - elm.determinant = std::vector(determinantsHD.begin() + nGPHD*e, - determinantsHD.begin() + nGPHD*(e + 1)); - elm.jacobian = std::vector(jacobiansHD.begin() + 9*nGPHD*e, - jacobiansHD.begin() + 9*nGPHD*(e + 1)); - elm.pEntity = &entity; - - for(std::size_t nodeTag : elm.nodesTag) - { - std::vector coord, dummyParametricCoord; - gmsh::model::mesh::getNode(nodeTag, coord, dummyParametricCoord); - elm.nodesCoord.push_back(coord); - } - - std::vector elementBarycenters(baryCenters.begin() + 3*e, - baryCenters.begin() + 3*(e + 1)); - - for(unsigned int i = 0 ; i < nFaceEdgesPerElm ; ++i) - { - FaceEdge faceEdge = {}; - - faceEdge.nodesTag = std::vector(nodesTagPerEdge.begin() + nNodesFaceEdge*nFaceEdgesPerElm*e + nNodesFaceEdge*i, - nodesTagPerEdge.begin() + nNodesFaceEdge*nFaceEdgesPerElm*e + nNodesFaceEdge*(i + 1)); - - for(std::size_t nodeTag : faceEdge.nodesTag) - { - std::vector coord, dummyParametricCoord; - gmsh::model::mesh::getNode(nodeTag, coord, dummyParametricCoord); - faceEdge.nodesCoord.push_back(coord); - } - - faceEdge.determinant = std::vector(determinantsLD.begin() + nFaceEdgesPerElm*nGPLD*e + nGPLD*i, - determinantsLD.begin() + nFaceEdgesPerElm*nGPLD*e + nGPLD*(i + 1)); - - faceEdge.jacobian = std::vector(jacobiansLD.begin() + nFaceEdgesPerElm*9*nGPLD*e + 9*nGPLD*i, - jacobiansLD.begin() + nFaceEdgesPerElm*9*nGPLD*e + 9*nGPLD*(i + 1)); - - computeFaceEdgeNormal(faceEdge, elementBarycenters); - - m_faceEdges[faceEdgeCounter] = std::move(faceEdge); - elm.pFaceEdges.push_back(&m_faceEdges.back()); - - faceEdgeCounter++; - } - - m_elementsHD[elmCounter] = std::move(elm); - entity.pElements.push_back(&m_elementsHD.back()); - - Element& finalElm = m_elementsHD.back(); - for(FaceEdge* pFaceEdge : finalElm.pFaceEdges) - { - pFaceEdge->pParentElementHD = &finalElm; - } - - elmCounter++; - } - } -} - -void dgMesh::computeFaceEdgeNormal(FaceEdge& faceEdge, const std::vector& elementBarycenter) -{ - std::vector normal; - - //TO DO: 3D version and 1D version -// double edgeLength = std::sqrt((faceEdge.nodesCoord[0][0] - faceEdge.nodesCoord[1][0]) -// *(faceEdge.nodesCoord[0][0] - faceEdge.nodesCoord[1][0]) -// + (faceEdge.nodesCoord[0][1] - faceEdge.nodesCoord[1][1]) -// *(faceEdge.nodesCoord[0][1] - faceEdge.nodesCoord[1][1]) -// + (faceEdge.nodesCoord[0][2] - faceEdge.nodesCoord[1][2]) -// *(faceEdge.nodesCoord[0][2] - faceEdge.nodesCoord[1][2])); - - // compute the normal - // if A:(x1, y1) and B:(x2, y2), then AB = (x2 - x1, y2 - y1) and a - // normal is given by n = (y2 - y1, x1 - x2) - double nx = faceEdge.nodesCoord[1][1] - faceEdge.nodesCoord[0][1]; - double ny = faceEdge.nodesCoord[0][0] - faceEdge.nodesCoord[1][0]; - double norm = sqrt(ny*ny + nx*nx); - - // unfortunately, nodes per edge in nodes vector are not always in - // the same order (clockwise vs anticlockwise) => we need to check - // the orientation - double vx = elementBarycenter[0] - (faceEdge.nodesCoord[1][0] + faceEdge.nodesCoord[0][0])/2; - double vy = elementBarycenter[1] - (faceEdge.nodesCoord[1][1] + faceEdge.nodesCoord[0][1])/2; - - if(nx*vx + ny*vy > 0) - { - nx = -nx; - ny = -ny; - } - - // normalize the normal components - normal.push_back(nx/norm); - normal.push_back(ny/norm); - - faceEdge.normal = std::move(normal); -} - -void dgMesh::checkIfFaceEdgeIsBoundary() -{ - assert(m_elementsLD.size() != 0); - - //TO DO: OpenMP This ! As well as use pointers to elementLD to remove elements found - for(FaceEdge& faceEdge : m_faceEdges) - { - for(Element& elementLD : m_elementsLD) - { - if(std::is_permutation(faceEdge.nodesTag.begin(), faceEdge.nodesTag.end(), elementLD.nodesTag.begin())) - { - faceEdge.pElementLD = &elementLD; - break; - } - } - } -} - -void dgMesh::associateFaceEdges() -{ - std::vector pFaceEdges; - - for(FaceEdge& faceEdge : m_faceEdges) - { - if(faceEdge.pElementLD == nullptr) - pFaceEdges.push_back(&faceEdge); - } - - assert(pFaceEdges.size() % 2 == 0); - - while(pFaceEdges.size() != 0) - { - std::vector currentFaceEdgeNodeTag = pFaceEdges[0]->nodesTag; - std::size_t indexInFront = 0; - - #pragma omp parallel default(shared) - { - #pragma omp for schedule(static) - for(std::size_t i = 1 ; i < pFaceEdges.size() ; ++i) - { - if(std::is_permutation(pFaceEdges[i]->nodesTag.begin(), pFaceEdges[i]->nodesTag.end(), - currentFaceEdgeNodeTag.begin())) - { - #pragma omp critical - { - indexInFront = i; - } - #pragma omp cancel for - } - - #pragma omp cancellation point for - } - } - - assert(indexInFront != 0); - - pFaceEdges[0]->pEdgeInFront = pFaceEdges[indexInFront]; - pFaceEdges[indexInFront]->pEdgeInFront = pFaceEdges[0]; - - pFaceEdges.erase(pFaceEdges.begin() + indexInFront); - pFaceEdges.erase(pFaceEdges.begin()); - } -} diff --git a/srcs/dgMesh/dgMesh.hpp b/srcs/dgMesh/dgMesh.hpp deleted file mode 100644 index 41baa19..0000000 --- a/srcs/dgMesh/dgMesh.hpp +++ /dev/null @@ -1,125 +0,0 @@ -#pragma once -#ifndef DGMESH_HPP_INCLUDED -#define DGMESH_HPP_INCLUDED - -#include -#include -#include - -#include "dgMesh_export.h" - -class DG_MESH_API dgMesh -{ - public: - dgMesh() = delete; - dgMesh(std::string integrationType, std::string basisFuncType); - dgMesh(const dgMesh& mesh) = delete; - dgMesh& operator=(const dgMesh& mesh) = delete; - dgMesh(dgMesh&& mesh) = delete; - dgMesh& operator=(dgMesh&& mesh) = delete; - ~dgMesh() = default; - - void displayToConsole() const noexcept; - void loadFromFile(std::string fileName); - - private: - void loadPhysicalGroupsAndEntities(); - void loadElementsProperty(); - void loadElements(); - void checkIfFaceEdgeIsBoundary(); - void associateFaceEdges(); - - int m_dimension; - - std::string m_integrationType; - std::string m_basisFuncType; - - struct PhysicalGroup; - struct Entity; - - struct ElementProperty - { - int type = -1; - std::string name = {}; - int order = -1; - int numNodes = -1; - std::vector localNodeCoord = {}; - int numPrimaryNodes = -1; - - std::vector intPointsCoord = {}; - std::vector intPointsWeigth = {}; - - int basisFuncNumComp = -1; - std::vector basisFunctions = {}; - - int basisFuncNumCompGrad = -1; - std::vector basisFunctionsGrad = {}; - }; - - struct FaceEdge; - - struct Element - { - std::size_t tag = -1; - std::vector nodesTag = {}; - std::vector> nodesCoord = {}; - - std::vector determinant = {}; - std::vector jacobian = {}; - - Entity* pEntity = nullptr; - std::vector pFaceEdges = {}; - }; - - struct FaceEdge - { - std::vector nodesTag = {}; - std::vector> nodesCoord = {}; - - std::vector determinant = {}; - std::vector jacobian = {}; - - std::vector normal = {}; - - Element* pParentElementHD = nullptr; - Element* pElementLD = nullptr; - FaceEdge* pEdgeInFront = nullptr; - }; - - void computeFaceEdgeNormal(FaceEdge& faceEdge, const std::vector& elementBarycenter); - - struct Entity - { - int mainTag = -1; - int subTag = -1; - std::vector pPhysicalGroups = {}; - - ElementProperty* pElementProperty = nullptr; - ElementProperty* pFaceEdgePropety = nullptr; - std::vector pElements = {}; - }; - - struct PhysicalGroup - { - int tag = -1; - std::string name = {}; - std::vector pEntities = {}; - }; - - std::vector m_physicalGroupHD; - std::vector m_physicalGroupLD; - - std::vector m_entitiesHD; - std::vector m_entitiesLD; - - std::vector m_elementsPropertyHD; - std::vector m_elementsPropertyLD; - - std::vector m_elementsHD; - std::vector m_elementsLD; - std::vector m_faceEdges; -}; - -#include "dgMesh.inl" - -#endif // DGMESH_HPP_INCLUDED diff --git a/srcs/dgMesh/dgMesh.inl b/srcs/dgMesh/dgMesh.inl deleted file mode 100644 index e69de29..0000000 diff --git a/srcs/main.cpp b/srcs/main.cpp index 9c196af..fb3d9f6 100644 --- a/srcs/main.cpp +++ b/srcs/main.cpp @@ -2,11 +2,11 @@ #include #include -#include "dgMesh/dgMesh.hpp" +#include "dG/Mesh/Mesh.hpp" int main(int argc, char **argv) { - dgMesh mesh("Gauss1", "Lagrange"); + dG::Mesh mesh("Gauss1", "Lagrange"); try { @@ -20,7 +20,7 @@ int main(int argc, char **argv) } catch(int e) { - std::cerr << "GMSH certainly throwed something (only one to use int exceptions): " + std::cerr << "GMSH certainly thrown something (only one to use int exceptions): " << e << std::endl; return -2; } @@ -30,6 +30,5 @@ int main(int argc, char **argv) return -3; } - return 0; } From e3ceb1a6051fe6a22f8aea261986e57ba27c3d0f Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 15:06:25 +0200 Subject: [PATCH 10/33] Fix travis ? --- build_travis.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build_travis.sh b/build_travis.sh index 8ce6205..8c2f73d 100755 --- a/build_travis.sh +++ b/build_travis.sh @@ -7,9 +7,9 @@ export INCLUDE=${PWD}/include:${INCLUDE} export LIB=${PWD}/lib:${LIB} export PYTHONPATH=${PWD}/lib:${PYTHONPATH} cd ../ -wget http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz -tar -xf 3.3.7.tar.gz -cd ./eigen-eigen-323c052e1731 +wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz +tar -xf eigen-3.3.7.tar.gz +cd ./eigen-3.3.7 export INCLUDE=${PWD}:${INCLUDE} cd ../ git clone https://github.com/tgregov/Multiphysics.git From 1e0c2757fc8e5d3f6c2ecc0cac5471b15a7e9414 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 15:12:03 +0200 Subject: [PATCH 11/33] Will not fix travis but anyway --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bc9092e..643f49b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,6 @@ matrix: before_install: - docker run -d --name ubuntu-20-04 -v $(pwd):/travis ubuntu:20.04 tail -f /dev/null install: - - docker exec -e DEBIAN_FRONTEND=noninteractive -t ubuntu-20-04 bash -c "apt-get -qq update; apt-get install -y git; apt-get install -y cmake; apt-get install -y build-essential; apt-get install -y wget; apt-get install -y tar; apt-get install -y libgfortran3; apt-get install -y libgmsh-dev; apt-get install -y libeigen3-dev" + - docker exec -e DEBIAN_FRONTEND=noninteractive -t ubuntu-20-04 bash -c "apt-get -qq update; apt-get install -y git; apt-get install -y cmake; apt-get install -y build-essential; apt-get install -y wget; apt-get install -y tar; apt-get install -y libgfortran5; apt-get install -y libgmsh-dev; apt-get install -y libeigen3-dev" script: - docker exec -t ubuntu-20-04 bash -c "cd /travis; ./build_travis.sh;" From 707a6661c5ad01d9264bfee9207ca4334a75f146 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 15:55:15 +0200 Subject: [PATCH 12/33] Who knows if travis will be fixed with that commit ? --- .travis.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 643f49b..3cd92e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,5 +10,23 @@ matrix: - docker run -d --name ubuntu-20-04 -v $(pwd):/travis ubuntu:20.04 tail -f /dev/null install: - docker exec -e DEBIAN_FRONTEND=noninteractive -t ubuntu-20-04 bash -c "apt-get -qq update; apt-get install -y git; apt-get install -y cmake; apt-get install -y build-essential; apt-get install -y wget; apt-get install -y tar; apt-get install -y libgfortran5; apt-get install -y libgmsh-dev; apt-get install -y libeigen3-dev" + - docker exec -t ubuntu-20-04 bash -c " + cd /travis; wget http://gmsh.info/bin/Linux/gmsh-4.6.0-Linux64-sdk.tgz; + tar -xf gmsh-4.6.0-Linux64-sdk.tgz; + wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; + tar -xf eigen-3.3.7.tar.gz + " script: - - docker exec -t ubuntu-20-04 bash -c "cd /travis; ./build_travis.sh;" + - docker exec -t ubuntu-20-04 bash -c " + cd /travis/tgregov/Multiphysics; + cd gmsh-4.6.0-Linux64-sdk/; + export PATH=/travis/gmsh-4.6.0-Linux64-sdk/bin:/travis/gmsh-4.6.0-Linux64-sdk/lib:${PATH}; + export INCLUDE=/travis/gmsh-4.6.0-Linux64-sdk/include:${INCLUDE}; + export LIB=/travis/gmsh-4.6.0-Linux64-sdk/lib:${LIB}; + export PYTHONPATH=/travis/gmsh-4.6.0-Linux64-sdk/lib:${PYTHONPATH}; + export INCLUDE=/travis/eigen-3.3.7/:${INCLUDE}; + mkdir build; + cd build; + cmake ../ -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"; + make; + " \ No newline at end of file From 2f3e4da61c6ba8fa71578d3d6cf5f4f235e3b4a3 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 16:21:47 +0200 Subject: [PATCH 13/33] Try not to use docker --- .travis.yml | 60 ++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3cd92e9..49417ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,32 @@ language: cpp -matrix: - include: - - env: NAME="Ubuntu 64 bits" - sudo: required - services: - - docker - before_install: - - docker run -d --name ubuntu-20-04 -v $(pwd):/travis ubuntu:20.04 tail -f /dev/null - install: - - docker exec -e DEBIAN_FRONTEND=noninteractive -t ubuntu-20-04 bash -c "apt-get -qq update; apt-get install -y git; apt-get install -y cmake; apt-get install -y build-essential; apt-get install -y wget; apt-get install -y tar; apt-get install -y libgfortran5; apt-get install -y libgmsh-dev; apt-get install -y libeigen3-dev" - - docker exec -t ubuntu-20-04 bash -c " - cd /travis; wget http://gmsh.info/bin/Linux/gmsh-4.6.0-Linux64-sdk.tgz; - tar -xf gmsh-4.6.0-Linux64-sdk.tgz; - wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; - tar -xf eigen-3.3.7.tar.gz - " - script: - - docker exec -t ubuntu-20-04 bash -c " - cd /travis/tgregov/Multiphysics; - cd gmsh-4.6.0-Linux64-sdk/; - export PATH=/travis/gmsh-4.6.0-Linux64-sdk/bin:/travis/gmsh-4.6.0-Linux64-sdk/lib:${PATH}; - export INCLUDE=/travis/gmsh-4.6.0-Linux64-sdk/include:${INCLUDE}; - export LIB=/travis/gmsh-4.6.0-Linux64-sdk/lib:${LIB}; - export PYTHONPATH=/travis/gmsh-4.6.0-Linux64-sdk/lib:${PYTHONPATH}; - export INCLUDE=/travis/eigen-3.3.7/:${INCLUDE}; - mkdir build; - cd build; - cmake ../ -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"; - make; - " \ No newline at end of file +os: linux + +dist: focal + +install: + - sudo apt-get update + - sudo apt-get install -y cmake + - sudo apt-get install -y build-essential + - sudo apt-get install -y wget + - sudo apt-get install -y tar + - sudo apt-get install -y libgfortran5 + - sudo apt-get install -y libgmsh-dev + - sudo apt-get install -y libeigen3-dev + - wget http://gmsh.info/bin/Linux/gmsh-4.6.0-Linux64-sdk.tgz + - tar -xf gmsh-4.6.0-Linux64-sdk.tgz + - wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz + - tar -xf eigen-3.3.7.tar.gz + +before_script: + - mkdir build + - cd build + - cmake ../ -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" + +script: + - export PATH=${TRAVIS_BUILD_DIR}/gmsh-4.6.0-Linux64-sdk/bin:${TRAVIS_BUILD_DIR}/gmsh-4.6.0-Linux64-sdk/lib:${PATH} + - export INCLUDE=${TRAVIS_BUILD_DIR}/gmsh-4.6.0-Linux64-sdk/include:${INCLUDE} + - export LIB=${TRAVIS_BUILD_DIR}/gmsh-4.6.0-Linux64-sdk/lib:${LIB} + - export PYTHONPATH=${TRAVIS_BUILD_DIR}/gmsh-4.6.0-Linux64-sdk/lib:${PYTHONPATH} + - export INCLUDE=${TRAVIS_BUILD_DIR}/eigen-3.3.7/:${INCLUDE} + - make \ No newline at end of file From 042633652ce1052fc5020ab7c1131e955532fef6 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 16:35:46 +0200 Subject: [PATCH 14/33] One more commit ^^ --- .travis.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 49417ec..afc45de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,13 @@ os: linux dist: focal +compiler: + - gcc + - clang + install: - sudo apt-get update - sudo apt-get install -y cmake - - sudo apt-get install -y build-essential - sudo apt-get install -y wget - sudo apt-get install -y tar - sudo apt-get install -y libgfortran5 @@ -19,14 +22,14 @@ install: - tar -xf eigen-3.3.7.tar.gz before_script: + - export PATH=${PWD}/gmsh-4.6.0-Linux64-sdk/bin:${PWD}/gmsh-4.6.0-Linux64-sdk/lib:${PATH} + - export INCLUDE=${PWD}/gmsh-4.6.0-Linux64-sdk/include:${INCLUDE} + - export LIB=${PWD}/gmsh-4.6.0-Linux64-sdk/lib:${LIB} + - export PYTHONPATH=${PWD}/gmsh-4.6.0-Linux64-sdk/lib:${PYTHONPATH} + - export INCLUDE=${PWD}/eigen-3.3.7/:${INCLUDE} - mkdir build - cd build - cmake ../ -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" script: - - export PATH=${TRAVIS_BUILD_DIR}/gmsh-4.6.0-Linux64-sdk/bin:${TRAVIS_BUILD_DIR}/gmsh-4.6.0-Linux64-sdk/lib:${PATH} - - export INCLUDE=${TRAVIS_BUILD_DIR}/gmsh-4.6.0-Linux64-sdk/include:${INCLUDE} - - export LIB=${TRAVIS_BUILD_DIR}/gmsh-4.6.0-Linux64-sdk/lib:${LIB} - - export PYTHONPATH=${TRAVIS_BUILD_DIR}/gmsh-4.6.0-Linux64-sdk/lib:${PYTHONPATH} - - export INCLUDE=${TRAVIS_BUILD_DIR}/eigen-3.3.7/:${INCLUDE} - make \ No newline at end of file From cedb1c634f8d09e92035de777667910d46f1e46d Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 16:56:09 +0200 Subject: [PATCH 15/33] Better warnings --- CMakeLists.txt | 8 ++++++++ srcs/CMakeLists.txt | 1 - srcs/dG/Mesh/CMakeLists.txt | 3 +-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59a3f59..760b8b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,14 @@ ELSE() MESSAGE(FATAL_ERROR "OpenMP not found !") ENDIF() +IF(CMAKE_CXX_COMPILER_ID MATCHES GNU) + ADD_COMPILE_OPTIONS(-Wall -Wextra -pedantic-errors -Wold-style-cast -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast -Wshadow) +ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES CLANG) + ADD_COMPILE_OPTIONS(-Wall -Wextra -pedantic-errors -Wold-style-cast -Wnull-dereference -Wshadow) +ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES MSVC) + ADD_COMPILE_OPTIONS(/W4 /WX) +ENDIF() + INCLUDE(GenerateExportHeader) ADD_SUBDIRECTORY(srcs) ENABLE_TESTING() diff --git a/srcs/CMakeLists.txt b/srcs/CMakeLists.txt index a3fe599..419d0a6 100644 --- a/srcs/CMakeLists.txt +++ b/srcs/CMakeLists.txt @@ -5,4 +5,3 @@ main.cpp) ADD_EXECUTABLE(DGangoFEtt ${SRCS}) TARGET_LINK_LIBRARIES(DGangoFEtt PUBLIC dgMesh) -SET_TARGET_PROPERTIES(DGangoFEtt PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic-errors -Wold-style-cast -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast -Wshadow") diff --git a/srcs/dG/Mesh/CMakeLists.txt b/srcs/dG/Mesh/CMakeLists.txt index b404c97..d6358cc 100644 --- a/srcs/dG/Mesh/CMakeLists.txt +++ b/srcs/dG/Mesh/CMakeLists.txt @@ -2,7 +2,7 @@ # gmsh.h FIND_PATH(GMSH_INCLUDE_DIRS NAMES "gmsh.h") MESSAGE(STATUS "Found GMSH: " ${GMSH_INCLUDE_DIRS}) -if(NOT GMSH_INCLUDE_DIRS) +IF(NOT GMSH_INCLUDE_DIRS) MESSAGE(FATAL_ERROR "gmsh.h not found!") ENDIF() INCLUDE_DIRECTORIES(SYSTEM ${GMSH_INCLUDE_DIRS}) @@ -27,4 +27,3 @@ TARGET_INCLUDE_DIRECTORIES(dgMesh SYSTEM PUBLIC ${CMAKE_CURRENT_BINARY_DIR} PRIVATE ${GMSH_INCLUDE_DIRS}) TARGET_LINK_LIBRARIES(dgMesh PRIVATE ${GMSH_LIBRARIES}) -SET_TARGET_PROPERTIES(dgMesh PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic-errors -Wold-style-cast -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast -Wshadow") From ce134e5f82e9a9781c1b36797ad4888da5e31259 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 17:30:03 +0200 Subject: [PATCH 16/33] Test multiple os travis --- .travis.yml | 63 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index afc45de..fa00a2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,45 @@ language: cpp -os: linux - -dist: focal - -compiler: - - gcc - - clang - +jobs: + include: + - os: linux + dist: focal + compiler: gcc + - os: osx + osx_image: xcode12u + install: - - sudo apt-get update - - sudo apt-get install -y cmake - - sudo apt-get install -y wget - - sudo apt-get install -y tar - - sudo apt-get install -y libgfortran5 - - sudo apt-get install -y libgmsh-dev - - sudo apt-get install -y libeigen3-dev - - wget http://gmsh.info/bin/Linux/gmsh-4.6.0-Linux64-sdk.tgz - - tar -xf gmsh-4.6.0-Linux64-sdk.tgz - - wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz - - tar -xf eigen-3.3.7.tar.gz + - if [ $TRAVIS_OS_NAME == linux ]; then + sudo apt-get update && sudo apt-get install -y cmake wget tar libgmsh-dev; + wget http://gmsh.info/bin/Linux/gmsh-4.6.0-Linux64-sdk.tgz; + tar -xf gmsh-4.6.0-Linux64-sdk.tgz; + wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz ; + tar -xf eigen-3.3.7.tar.gz; + fi + - if [ $TRAVIS_OS_NAME == osx ]; then + brew update && brew intall cmake wget tar; + wget http://gmsh.info/bin/MacOSX/gmsh-4.6.0-MacOSX-sdk.tgz; + tar -xf gmsh-4.6.0-MacOSX-sdk.tgz; + wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz ; + tar -xf eigen-3.3.7.tar.gz; + fi -before_script: - - export PATH=${PWD}/gmsh-4.6.0-Linux64-sdk/bin:${PWD}/gmsh-4.6.0-Linux64-sdk/lib:${PATH} - - export INCLUDE=${PWD}/gmsh-4.6.0-Linux64-sdk/include:${INCLUDE} - - export LIB=${PWD}/gmsh-4.6.0-Linux64-sdk/lib:${LIB} - - export PYTHONPATH=${PWD}/gmsh-4.6.0-Linux64-sdk/lib:${PYTHONPATH} - - export INCLUDE=${PWD}/eigen-3.3.7/:${INCLUDE} +before_script: + - if [ $TRAVIS_OS_NAME == linux ]; then + export PATH=${PWD}/gmsh-4.6.0-Linux64-sdk/bin:${PWD}/gmsh-4.6.0-Linux64-sdk/lib:${PATH}; + export INCLUDE=${PWD}/gmsh-4.6.0-Linux64-sdk/include:${INCLUDE}; + export LIB=${PWD}/gmsh-4.6.0-Linux64-sdk/lib:${LIB}; + export PYTHONPATH=${PWD}/gmsh-4.6.0-Linux64-sdk/lib:${PYTHONPATH}; + export INCLUDE=${PWD}/eigen-3.3.7/:${INCLUDE}; + fi + + - if [ $TRAVIS_OS_NAME == osx ]; then + export PATH=${PWD}/gmsh-4.6.0-MacOSX-sdk/bin:${PWD}/gmsh-4.6.0-MacOSX-sdk/lib:${PATH}; + export INCLUDE=${PWD}/gmsh-4.6.0-MacOSX-sdk/include:${INCLUDE}; + export LIB=${PWD}/gmsh-4.6.0-MacOSX-sdk/lib:${LIB}; + export PYTHONPATH=${PWD}/gmsh-4.6.0-MacOSX-sdk/lib:${PYTHONPATH}; + export INCLUDE=${PWD}/eigen-3.3.7/:${INCLUDE}; + fi - mkdir build - cd build - cmake ../ -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" From bf4e87b6353d7ee1e49784662ddcff4de040a753 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 17:36:22 +0200 Subject: [PATCH 17/33] Fix a warning using gcc on linux --- .travis.yml | 2 +- srcs/dG/Mesh/Mesh.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fa00a2d..87011b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ install: tar -xf eigen-3.3.7.tar.gz; fi - if [ $TRAVIS_OS_NAME == osx ]; then - brew update && brew intall cmake wget tar; + brew update && brew install cmake wget tar; wget http://gmsh.info/bin/MacOSX/gmsh-4.6.0-MacOSX-sdk.tgz; tar -xf gmsh-4.6.0-MacOSX-sdk.tgz; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz ; diff --git a/srcs/dG/Mesh/Mesh.cpp b/srcs/dG/Mesh/Mesh.cpp index 0cee835..5b61063 100644 --- a/srcs/dG/Mesh/Mesh.cpp +++ b/srcs/dG/Mesh/Mesh.cpp @@ -453,7 +453,7 @@ namespace dG entity.subTag = gmsh::model::addDiscreteEntity(m_dimension - 1); std::vector nodesTagPerFace; gmsh::model::mesh::getElementEdgeNodes(entity.pElementProperty->type, nodesTagPerFace, entity.mainTag); - int eleTypeSubEntity; + int eleTypeSubEntity = -1; switch(m_dimension) { case 1: From 6237e93dbdb566cb73ec9e2f4e8aaa66ddfd2804 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 17:52:36 +0200 Subject: [PATCH 18/33] Let's try to add windows and fix macOS --- .travis.yml | 61 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 87011b5..5325031 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,22 +7,63 @@ jobs: compiler: gcc - os: osx osx_image: xcode12u - + - os: windows + +before_install: +- |- + case $TRAVIS_OS_NAME in + windows) + [[ ! -f C:/tools/msys64/msys2_shell.cmd ]] && rm -rf C:/tools/msys64 + choco uninstall -y mingw + choco upgrade --no-progress -y msys2 + export msys2='cmd //C RefreshEnv.cmd ' + export msys2+='& set MSYS=winsymlinks:nativestrict ' + export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start' + export mingw64="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --" + export msys2+=" -msys2 -c "\"\$@"\" --" + $msys2 pacman --sync --noconfirm --needed mingw-w64-x86_64-toolchain + ## Install more MSYS2 packages from https://packages.msys2.org/base here + taskkill //IM gpg-agent.exe //F # https://travis-ci.community/t/4967 + export PATH=/C/tools/msys64/mingw64/bin:$PATH + export MAKE=mingw32-make # so that Autotools can find it + ;; + esac + +before_cache: +- |- + case $TRAVIS_OS_NAME in + windows) + # https://unix.stackexchange.com/a/137322/107554 + $msys2 pacman --sync --clean --noconfirm + ;; + esac + +cache: + directories: + - $HOME/AppData/Local/Temp/chocolatey + - /C/tools/msys64 + install: - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get update && sudo apt-get install -y cmake wget tar libgmsh-dev; wget http://gmsh.info/bin/Linux/gmsh-4.6.0-Linux64-sdk.tgz; tar -xf gmsh-4.6.0-Linux64-sdk.tgz; - wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz ; + wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; tar -xf eigen-3.3.7.tar.gz; fi - if [ $TRAVIS_OS_NAME == osx ]; then - brew update && brew install cmake wget tar; + brew update && brew intall cmake wget tar llvm libomp; wget http://gmsh.info/bin/MacOSX/gmsh-4.6.0-MacOSX-sdk.tgz; tar -xf gmsh-4.6.0-MacOSX-sdk.tgz; - wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz ; + wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; tar -xf eigen-3.3.7.tar.gz; - fi + fi + - if [ $TRAVIS_OS_NAME == windows ]; then + wget http://gmsh.info/bin/Windows/gmsh-4.6.0-Windows64-sdk.zip; + 7z x gmsh-4.6.0-Windows64-sdk.zip; + wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; + 7z x eigen-3.3.7.tar.gz; + fi before_script: - if [ $TRAVIS_OS_NAME == linux ]; then @@ -32,14 +73,20 @@ before_script: export PYTHONPATH=${PWD}/gmsh-4.6.0-Linux64-sdk/lib:${PYTHONPATH}; export INCLUDE=${PWD}/eigen-3.3.7/:${INCLUDE}; fi - - if [ $TRAVIS_OS_NAME == osx ]; then export PATH=${PWD}/gmsh-4.6.0-MacOSX-sdk/bin:${PWD}/gmsh-4.6.0-MacOSX-sdk/lib:${PATH}; export INCLUDE=${PWD}/gmsh-4.6.0-MacOSX-sdk/include:${INCLUDE}; export LIB=${PWD}/gmsh-4.6.0-MacOSX-sdk/lib:${LIB}; export PYTHONPATH=${PWD}/gmsh-4.6.0-MacOSX-sdk/lib:${PYTHONPATH}; export INCLUDE=${PWD}/eigen-3.3.7/:${INCLUDE}; - fi + fi + - if [ $TRAVIS_OS_NAME == windows ]; then + export PATH=${PWD}/gmsh-4.6.0-Windows64-sdk/bin:${PWD}/gmsh-4.6.0-Windows64-sdk/lib:${PATH}; + export INCLUDE=${PWD}/gmsh-4.6.0-Windows64-sdk/include:${INCLUDE}; + export LIB=${PWD}/gmsh-4.6.0-Windows64-sdk/lib:${LIB}; + export PYTHONPATH=${PWD}/gmsh-4.6.0-Windows64-sdk/lib:${PYTHONPATH}; + export INCLUDE=${PWD}/eigen-3.3.7/:${INCLUDE}; + fi - mkdir build - cd build - cmake ../ -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" From 5f4f9fcdd159d5cb7c88803b51dc720017e667c0 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 18:03:23 +0200 Subject: [PATCH 19/33] Let's hope it works this time --- .travis.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5325031..b380bab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,7 @@ install: tar -xf eigen-3.3.7.tar.gz; fi - if [ $TRAVIS_OS_NAME == osx ]; then - brew update && brew intall cmake wget tar llvm libomp; + brew update && brew install cmake wget tar llvm libomp; wget http://gmsh.info/bin/MacOSX/gmsh-4.6.0-MacOSX-sdk.tgz; tar -xf gmsh-4.6.0-MacOSX-sdk.tgz; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; @@ -63,6 +63,7 @@ install: 7z x gmsh-4.6.0-Windows64-sdk.zip; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; 7z x eigen-3.3.7.tar.gz; + $mingw64 pacman -S mingw-w64-x86_64-toolchain fi before_script: @@ -89,7 +90,15 @@ before_script: fi - mkdir build - cd build - - cmake ../ -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" + - if [ $TRAVIS_OS_NAME == linux ]; then + cmake .. -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"; + fi + - if [ $TRAVIS_OS_NAME == osx ]; then + cmake .. -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"; + fi + - if [ $TRAVIS_OS_NAME == windows ]; then + cmake .. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles"; + fi script: - make \ No newline at end of file From 4f3ca834f5507bef23eeecf727282df200c4e0ce Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 18:11:07 +0200 Subject: [PATCH 20/33] Well well well --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b380bab..0e3fa2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,7 +63,6 @@ install: 7z x gmsh-4.6.0-Windows64-sdk.zip; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; 7z x eigen-3.3.7.tar.gz; - $mingw64 pacman -S mingw-w64-x86_64-toolchain fi before_script: From 64320946ff6327a854925744ea8eff560b8eb93a Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 18:20:43 +0200 Subject: [PATCH 21/33] Hop hop hop --- .travis.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0e3fa2e..4f79b5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,11 +45,11 @@ cache: install: - if [ $TRAVIS_OS_NAME == linux ]; then - sudo apt-get update && sudo apt-get install -y cmake wget tar libgmsh-dev; + sudo apt-get update && sudo apt-get install -y cmake wget gnu-tar libgmsh-dev; wget http://gmsh.info/bin/Linux/gmsh-4.6.0-Linux64-sdk.tgz; - tar -xf gmsh-4.6.0-Linux64-sdk.tgz; + gtar -xf gmsh-4.6.0-Linux64-sdk.tgz; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; - tar -xf eigen-3.3.7.tar.gz; + gtar -xf eigen-3.3.7.tar.gz; fi - if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install cmake wget tar llvm libomp; @@ -100,4 +100,12 @@ before_script: fi script: - - make \ No newline at end of file + - if [ $TRAVIS_OS_NAME == linux ]; then + make; + fi + - if [ $TRAVIS_OS_NAME == osx ]; then + make; + fi + - if [ $TRAVIS_OS_NAME == windows ]; then + mingw32_make; + fi \ No newline at end of file From 37ce5f8d8cb52eec85ca6d2fe9ac09d5263a61a9 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 18:24:24 +0200 Subject: [PATCH 22/33] You are without any doubt the worse pirate I have ever heard of --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4f79b5e..4fe87f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,18 +45,18 @@ cache: install: - if [ $TRAVIS_OS_NAME == linux ]; then - sudo apt-get update && sudo apt-get install -y cmake wget gnu-tar libgmsh-dev; + sudo apt-get update && sudo apt-get install -y cmake wget tar libgmsh-dev; wget http://gmsh.info/bin/Linux/gmsh-4.6.0-Linux64-sdk.tgz; - gtar -xf gmsh-4.6.0-Linux64-sdk.tgz; + tar -xf gmsh-4.6.0-Linux64-sdk.tgz; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; - gtar -xf eigen-3.3.7.tar.gz; + tar -xf eigen-3.3.7.tar.gz; fi - if [ $TRAVIS_OS_NAME == osx ]; then - brew update && brew install cmake wget tar llvm libomp; + brew update && brew install cmake wget gnu-tar llvm libomp; wget http://gmsh.info/bin/MacOSX/gmsh-4.6.0-MacOSX-sdk.tgz; - tar -xf gmsh-4.6.0-MacOSX-sdk.tgz; + gtar -xf gmsh-4.6.0-MacOSX-sdk.tgz; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; - tar -xf eigen-3.3.7.tar.gz; + gtar -xf eigen-3.3.7.tar.gz; fi - if [ $TRAVIS_OS_NAME == windows ]; then wget http://gmsh.info/bin/Windows/gmsh-4.6.0-Windows64-sdk.zip; From 6eca881a879b2ae870a7c09b88bfc0971db765e8 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 18:41:41 +0200 Subject: [PATCH 23/33] I am not a clever man --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4fe87f3..39ee8e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,7 @@ install: tar -xf eigen-3.3.7.tar.gz; fi - if [ $TRAVIS_OS_NAME == osx ]; then - brew update && brew install cmake wget gnu-tar llvm libomp; + brew update && brew install cmake wget gnu-tar libomp; wget http://gmsh.info/bin/MacOSX/gmsh-4.6.0-MacOSX-sdk.tgz; gtar -xf gmsh-4.6.0-MacOSX-sdk.tgz; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; @@ -107,5 +107,5 @@ script: make; fi - if [ $TRAVIS_OS_NAME == windows ]; then - mingw32_make; + mingw32-make; fi \ No newline at end of file From 51fc07fc0aa7225fbec85d3b9dfcf51e444834f7 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 18:56:42 +0200 Subject: [PATCH 24/33] Will macOS succeed now ? --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39ee8e3..f4e3af9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,8 @@ install: tar -xf eigen-3.3.7.tar.gz; fi - if [ $TRAVIS_OS_NAME == osx ]; then - brew update && brew install cmake wget gnu-tar libomp; + brew update && brew install cmake wget gnu-tar llvm libomp; + export PATH=/usr/local/opt/llvm/bin:${PATH}; wget http://gmsh.info/bin/MacOSX/gmsh-4.6.0-MacOSX-sdk.tgz; gtar -xf gmsh-4.6.0-MacOSX-sdk.tgz; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; From ee8275905cf2136cd3b48f091b4836c48be00d01 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 19:29:25 +0200 Subject: [PATCH 25/33] macOS I am trying my best --- .travis.yml | 3 +-- CMakeLists.txt | 2 +- srcs/CMakeLists.txt | 2 +- srcs/dG/Mesh/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f4e3af9..9441c42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,6 @@ install: fi - if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install cmake wget gnu-tar llvm libomp; - export PATH=/usr/local/opt/llvm/bin:${PATH}; wget http://gmsh.info/bin/MacOSX/gmsh-4.6.0-MacOSX-sdk.tgz; gtar -xf gmsh-4.6.0-MacOSX-sdk.tgz; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; @@ -94,7 +93,7 @@ before_script: cmake .. -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"; fi - if [ $TRAVIS_OS_NAME == osx ]; then - cmake .. -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"; + LDFLAGS="-L/usr/local/opt/llvm/lib" CPPFLAGS="-I/usr/local/opt/llvm/include" cmake .. -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"; fi - if [ $TRAVIS_OS_NAME == windows ]; then cmake .. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles"; diff --git a/CMakeLists.txt b/CMakeLists.txt index 760b8b1..af8d50d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ PROJECT(MULTIPHYSICS CXX) -CMAKE_MINIMUM_REQUIRED(VERSION 3.1) +CMAKE_MINIMUM_REQUIRED(VERSION 3.12) # build type is "" by default in Linux IF(NOT CMAKE_BUILD_TYPE) diff --git a/srcs/CMakeLists.txt b/srcs/CMakeLists.txt index 419d0a6..ef4ee11 100644 --- a/srcs/CMakeLists.txt +++ b/srcs/CMakeLists.txt @@ -4,4 +4,4 @@ SET(SRCS main.cpp) ADD_EXECUTABLE(DGangoFEtt ${SRCS}) -TARGET_LINK_LIBRARIES(DGangoFEtt PUBLIC dgMesh) +TARGET_LINK_LIBRARIES(DGangoFEtt PRIVATE dgMesh OpenMP::OpenMP_CXX) diff --git a/srcs/dG/Mesh/CMakeLists.txt b/srcs/dG/Mesh/CMakeLists.txt index d6358cc..7f62fe6 100644 --- a/srcs/dG/Mesh/CMakeLists.txt +++ b/srcs/dG/Mesh/CMakeLists.txt @@ -26,4 +26,4 @@ GENERATE_EXPORT_HEADER(dgMesh TARGET_INCLUDE_DIRECTORIES(dgMesh SYSTEM PUBLIC ${CMAKE_CURRENT_BINARY_DIR} PRIVATE ${GMSH_INCLUDE_DIRS}) -TARGET_LINK_LIBRARIES(dgMesh PRIVATE ${GMSH_LIBRARIES}) +TARGET_LINK_LIBRARIES(dgMesh PRIVATE ${GMSH_LIBRARIES} OpenMP::OpenMP_CXX) From b2305795e71804f035bca70d7c0af6226f4cff68 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 19:44:58 +0200 Subject: [PATCH 26/33] Last try before I kill apple --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9441c42..6743fcc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -93,7 +93,7 @@ before_script: cmake .. -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"; fi - if [ $TRAVIS_OS_NAME == osx ]; then - LDFLAGS="-L/usr/local/opt/llvm/lib" CPPFLAGS="-I/usr/local/opt/llvm/include" cmake .. -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"; + LDFLAGS="-L/usr/local/opt/llvm/lib" CPPFLAGS="-I/usr/local/opt/llvm/include" cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang -G "Unix Makefiles"; fi - if [ $TRAVIS_OS_NAME == windows ]; then cmake .. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles"; From 99d1176a5107aa09b342ad335ef44eb5cf433b4a Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 19:59:59 +0200 Subject: [PATCH 27/33] Fix build on macOS and use MSVC on windows That way I check for gcc, clang and msvc ! --- .travis.yml | 41 +++++------------------------------------ srcs/dG/Mesh/Mesh.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 40 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6743fcc..c0720c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,40 +8,7 @@ jobs: - os: osx osx_image: xcode12u - os: windows - -before_install: -- |- - case $TRAVIS_OS_NAME in - windows) - [[ ! -f C:/tools/msys64/msys2_shell.cmd ]] && rm -rf C:/tools/msys64 - choco uninstall -y mingw - choco upgrade --no-progress -y msys2 - export msys2='cmd //C RefreshEnv.cmd ' - export msys2+='& set MSYS=winsymlinks:nativestrict ' - export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start' - export mingw64="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --" - export msys2+=" -msys2 -c "\"\$@"\" --" - $msys2 pacman --sync --noconfirm --needed mingw-w64-x86_64-toolchain - ## Install more MSYS2 packages from https://packages.msys2.org/base here - taskkill //IM gpg-agent.exe //F # https://travis-ci.community/t/4967 - export PATH=/C/tools/msys64/mingw64/bin:$PATH - export MAKE=mingw32-make # so that Autotools can find it - ;; - esac - -before_cache: -- |- - case $TRAVIS_OS_NAME in - windows) - # https://unix.stackexchange.com/a/137322/107554 - $msys2 pacman --sync --clean --noconfirm - ;; - esac - -cache: - directories: - - $HOME/AppData/Local/Temp/chocolatey - - /C/tools/msys64 + env: MSBUILD_PATH="C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin" install: - if [ $TRAVIS_OS_NAME == linux ]; then @@ -59,6 +26,7 @@ install: gtar -xf eigen-3.3.7.tar.gz; fi - if [ $TRAVIS_OS_NAME == windows ]; then + choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64" wget http://gmsh.info/bin/Windows/gmsh-4.6.0-Windows64-sdk.zip; 7z x gmsh-4.6.0-Windows64-sdk.zip; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; @@ -96,7 +64,8 @@ before_script: LDFLAGS="-L/usr/local/opt/llvm/lib" CPPFLAGS="-I/usr/local/opt/llvm/include" cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang -G "Unix Makefiles"; fi - if [ $TRAVIS_OS_NAME == windows ]; then - cmake .. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles"; + export PATH=MSBUILD_PATH:${PATH}; + cmake .. -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -A x64; fi script: @@ -107,5 +76,5 @@ script: make; fi - if [ $TRAVIS_OS_NAME == windows ]; then - mingw32-make; + cmake --build; fi \ No newline at end of file diff --git a/srcs/dG/Mesh/Mesh.cpp b/srcs/dG/Mesh/Mesh.cpp index 5b61063..918554f 100644 --- a/srcs/dG/Mesh/Mesh.cpp +++ b/srcs/dG/Mesh/Mesh.cpp @@ -120,7 +120,7 @@ namespace dG m_physicalGroupHD.resize(physicalGroupsHD.size()); for(std::size_t i = 0 ; i < m_physicalGroupHD.size() ; ++i) { - std::pair pgHD = physicalGroupsHD[i]; + std::pair pgHD = physicalGroupsHD[i]; std::string pgName; gmsh::model::getPhysicalName(pgHD.first, pgHD.second, pgName); @@ -149,7 +149,7 @@ namespace dG m_physicalGroupLD.resize(physicalGroupsLD.size()); for(std::size_t i = 0 ; i < m_physicalGroupLD.size() ; ++i) { - std::pair pgLD = physicalGroupsLD[i]; + std::pair pgLD = physicalGroupsLD[i]; std::string pgName; gmsh::model::getPhysicalName(pgLD.first, pgLD.second, pgName); @@ -183,7 +183,7 @@ namespace dG m_entitiesHD.resize(entitiesHD.size()); for(std::size_t i = 0 ; i < m_entitiesHD.size() ; ++i) { - std::pair entityHD = entitiesHD[i]; + std::pair entityHD = entitiesHD[i]; Entity entity; entity.mainTag = entityHD.second; @@ -202,7 +202,7 @@ namespace dG m_entitiesLD.resize(entitiesLD.size()); for(std::size_t i = 0 ; i < m_entitiesLD.size() ; ++i) { - std::pair entityLD = entitiesLD[i]; + std::pair entityLD = entitiesLD[i]; Entity entity; entity.mainTag = entityLD.second; From e20d695c6988cab746cf053643aff0204e62fa84 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 20:10:09 +0200 Subject: [PATCH 28/33] Fix windows and apple build --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c0720c3..7f63665 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ install: gtar -xf eigen-3.3.7.tar.gz; fi - if [ $TRAVIS_OS_NAME == windows ]; then - choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64" + choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64"; wget http://gmsh.info/bin/Windows/gmsh-4.6.0-Windows64-sdk.zip; 7z x gmsh-4.6.0-Windows64-sdk.zip; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; @@ -61,7 +61,7 @@ before_script: cmake .. -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"; fi - if [ $TRAVIS_OS_NAME == osx ]; then - LDFLAGS="-L/usr/local/opt/llvm/lib" CPPFLAGS="-I/usr/local/opt/llvm/include" cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang -G "Unix Makefiles"; + LDFLAGS="-L/usr/local/opt/llvm/lib" CPPFLAGS="-I/usr/local/opt/llvm/include" cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -G "Unix Makefiles"; fi - if [ $TRAVIS_OS_NAME == windows ]; then export PATH=MSBUILD_PATH:${PATH}; From 00a8064e0635467e40d5be1682358e7d2cd5ee79 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 20:15:54 +0200 Subject: [PATCH 29/33] Final fix I hope --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7f63665..f01ea77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,5 +76,5 @@ script: make; fi - if [ $TRAVIS_OS_NAME == windows ]; then - cmake --build; + cmake --build .; fi \ No newline at end of file From 734a99dfc68631641ddf18899bc7c2e62f738e6f Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 20:45:34 +0200 Subject: [PATCH 30/33] Fix msvc being stupid --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af8d50d..368d38b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES GNU) ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES CLANG) ADD_COMPILE_OPTIONS(-Wall -Wextra -pedantic-errors -Wold-style-cast -Wnull-dereference -Wshadow) ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES MSVC) - ADD_COMPILE_OPTIONS(/W4 /WX) + ADD_COMPILE_OPTIONS(/W4 /WX /ignore:4251) ENDIF() INCLUDE(GenerateExportHeader) From 60b0d24dbeab810e906fc6fb29cfd165774cfa8a Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 20:52:47 +0200 Subject: [PATCH 31/33] Fix msvc stupid warning round 2 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 368d38b..6efba37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES GNU) ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES CLANG) ADD_COMPILE_OPTIONS(-Wall -Wextra -pedantic-errors -Wold-style-cast -Wnull-dereference -Wshadow) ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES MSVC) - ADD_COMPILE_OPTIONS(/W4 /WX /ignore:4251) + ADD_COMPILE_OPTIONS(/W4 /WX /wd4251) ENDIF() INCLUDE(GenerateExportHeader) From d8183ba4e53ad043f56d9b73571edf7549f9366b Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 21:38:24 +0200 Subject: [PATCH 32/33] Reswitch to mingw on windows MSVC only use openmp 2.0 oO --- .travis.yml | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f01ea77..a6b6127 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,40 @@ jobs: - os: osx osx_image: xcode12u - os: windows - env: MSBUILD_PATH="C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin" + +before_install: +- |- + case $TRAVIS_OS_NAME in + windows) + [[ ! -f C:/tools/msys64/msys2_shell.cmd ]] && rm -rf C:/tools/msys64 + choco uninstall -y mingw + choco upgrade --no-progress -y msys2 + export msys2='cmd //C RefreshEnv.cmd ' + export msys2+='& set MSYS=winsymlinks:nativestrict ' + export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start' + export mingw64="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --" + export msys2+=" -msys2 -c "\"\$@"\" --" + $msys2 pacman --sync --noconfirm --needed mingw-w64-x86_64-toolchain + ## Install more MSYS2 packages from https://packages.msys2.org/base here + taskkill //IM gpg-agent.exe //F # https://travis-ci.community/t/4967 + export PATH=/C/tools/msys64/mingw64/bin:$PATH + export MAKE=mingw32-make # so that Autotools can find it + ;; + esac + +before_cache: +- |- + case $TRAVIS_OS_NAME in + windows) + # https://unix.stackexchange.com/a/137322/107554 + $msys2 pacman --sync --clean --noconfirm + ;; + esac + +cache: + directories: + - $HOME/AppData/Local/Temp/chocolatey + - /C/tools/msys64 install: - if [ $TRAVIS_OS_NAME == linux ]; then @@ -26,7 +59,6 @@ install: gtar -xf eigen-3.3.7.tar.gz; fi - if [ $TRAVIS_OS_NAME == windows ]; then - choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64"; wget http://gmsh.info/bin/Windows/gmsh-4.6.0-Windows64-sdk.zip; 7z x gmsh-4.6.0-Windows64-sdk.zip; wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz; @@ -64,8 +96,7 @@ before_script: LDFLAGS="-L/usr/local/opt/llvm/lib" CPPFLAGS="-I/usr/local/opt/llvm/include" cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -G "Unix Makefiles"; fi - if [ $TRAVIS_OS_NAME == windows ]; then - export PATH=MSBUILD_PATH:${PATH}; - cmake .. -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -A x64; + cmake .. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles"; fi script: @@ -76,5 +107,5 @@ script: make; fi - if [ $TRAVIS_OS_NAME == windows ]; then - cmake --build .; + mingw32-make; fi \ No newline at end of file From f1663c5fa72e092f6e33a2ff929a2b8f49b8ad76 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 28 Aug 2020 21:52:24 +0200 Subject: [PATCH 33/33] Quick fix --- build_travis.sh | 20 ------------------- build_cluster.sh => run/NIC4/build_cluster.sh | 0 srcs/dG/Mesh/Mesh.hpp | 2 +- srcs/dG/Mesh/Mesh.inl | 2 +- 4 files changed, 2 insertions(+), 22 deletions(-) delete mode 100755 build_travis.sh rename build_cluster.sh => run/NIC4/build_cluster.sh (100%) mode change 100755 => 100644 diff --git a/build_travis.sh b/build_travis.sh deleted file mode 100755 index 8c2f73d..0000000 --- a/build_travis.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -wget http://gmsh.info/bin/Linux/gmsh-4.6.0-Linux64-sdk.tgz -tar -xf gmsh-4.6.0-Linux64-sdk.tgz -cd gmsh-4.6.0-Linux64-sdk/ -export PATH=${PWD}/bin:${PWD}/lib:${PATH} -export INCLUDE=${PWD}/include:${INCLUDE} -export LIB=${PWD}/lib:${LIB} -export PYTHONPATH=${PWD}/lib:${PYTHONPATH} -cd ../ -wget https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz -tar -xf eigen-3.3.7.tar.gz -cd ./eigen-3.3.7 -export INCLUDE=${PWD}:${INCLUDE} -cd ../ -git clone https://github.com/tgregov/Multiphysics.git -cd Multiphysics/ -mkdir build -cd build -cmake ../ -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" -make diff --git a/build_cluster.sh b/run/NIC4/build_cluster.sh old mode 100755 new mode 100644 similarity index 100% rename from build_cluster.sh rename to run/NIC4/build_cluster.sh diff --git a/srcs/dG/Mesh/Mesh.hpp b/srcs/dG/Mesh/Mesh.hpp index 65fabed..3304834 100644 --- a/srcs/dG/Mesh/Mesh.hpp +++ b/srcs/dG/Mesh/Mesh.hpp @@ -30,7 +30,7 @@ namespace dG void displayToConsole() const noexcept; void loadFromFile(std::string fileName); - inline unsigned int getEntityHDCount() const noexcept; + inline std::size_t getEntityHDCount() const noexcept; inline const Entity& getEntityHD(unsigned int entityIndex) const noexcept; private: diff --git a/srcs/dG/Mesh/Mesh.inl b/srcs/dG/Mesh/Mesh.inl index 9b197cd..2cbd6cd 100644 --- a/srcs/dG/Mesh/Mesh.inl +++ b/srcs/dG/Mesh/Mesh.inl @@ -2,7 +2,7 @@ namespace dG { - inline unsigned int Mesh::getEntityHDCount() const noexcept + inline std::size_t Mesh::getEntityHDCount() const noexcept { return m_entitiesHD.size(); }