diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 33f72ecb941c410f7541f32541a34878ff987b3f..1bf144d5cc9c96169ee13d99c638936542201e9d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,5 +13,5 @@ "runArgs": ["--gpus","all", // remove this line in case you have no gpus available "--hostname=${localEnv:HOSTNAME}"], // HOSTNAME needs to be known by the vscode environment. It is probably necessary to add "export HOSTNAME=<hostname>" to the config file of your host machine's bash. - "image": "git.rz.tu-bs.de:4567/irmb/virtualfluids/ubuntu20_04:1.4" + "image": "git.rz.tu-bs.de:4567/irmb/virtualfluids/ubuntu20_04:1.5" } diff --git a/.gitignore b/.gitignore index f6951f7b7b4a6c1960be0a92f831fd7bf05c0367..d3e29c184e8e90ec5899b7b7241bd9fb34385cc9 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,8 @@ pythonbindings/pymuparser/bindings* # simulation results output/ logs/ +reference_data/ +generated/ # grid .grid/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1cff49512e8325e7dad10f60d5b88c3a90f30420..c7fcb81d30f212feb33263ee7af58483ae631fd9 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ ############################################################################### ## VirtualFluids CI Pipeline ## ############################################################################### -image: git.rz.tu-bs.de:4567/irmb/virtualfluids/ubuntu20_04:1.4 +image: git.rz.tu-bs.de:4567/irmb/virtualfluids/ubuntu20_04:1.5 stages: - build @@ -52,6 +52,7 @@ stages: --preset=make_all -DBUILD_WARNINGS_AS_ERRORS=ON -DCMAKE_CUDA_ARCHITECTURES=60 + -DBUILD_VF_ALL_SAMPLES=ON - make -j4 - ccache --show-stats @@ -92,14 +93,14 @@ msvc_17: - git --version - $env:Path += ";C:\Program Files\CMake\bin\" - cmake --version - - $env:Path += ";C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin" + - $env:Path += ";C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin" - MSBuild.exe -version script: - cd $CI_PROJECT_DIR - md -force $env:BUILD_FOLDER - cd $env:BUILD_FOLDER - - cmake .. --preset=msvc_all -DCMAKE_CUDA_ARCHITECTURES=61 -DBUILD_WARNINGS_AS_ERRORS=ON + - cmake .. --preset=msvc_all -DCMAKE_CUDA_ARCHITECTURES=61 -DBUILD_WARNINGS_AS_ERRORS=ON -DBUILD_VF_ALL_SAMPLES=ON - MSBuild.exe VirtualFluids.sln /property:Configuration=$env:BUILD_CONFIGURATION /verbosity:minimal /maxcpucount:4 artifacts: @@ -178,6 +179,7 @@ gcc_9_unit_tests: script: - ctest + - ctest --rerun-failed --output-on-failure ############################################################################### msvc_17_unit_tests: @@ -212,7 +214,6 @@ gcc_9_python_bindings_test: script: - python3 -m unittest discover -s Python -v - ############################################################################### gcc_9_python_hpc_test: image: python:latest @@ -234,6 +235,44 @@ gcc_9_python_hpc_test: script: - hpc-rocket launch --watch Python/SlurmTests/poiseuille/rocket.yml +############################################################################### +build-regression-tests-ci: + image: python:3.10 + stage: test + + before_script: + - pip install -r utilities/ci-regression-tests/requirements.txt + + script: + - python3 utilities/ci-regression-tests/generate-ci.py + + artifacts: + expire_in: 1 week + paths: + - generated/ + + rules: + - if: $CI_PIPELINE_SOURCE == "schedule" + when: always + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + when: never + - when: manual + allow_failure: true + + needs: [] + +trigger-regression-tests: + stage: test + needs: + - build-regression-tests-ci + trigger: + include: + - artifact: generated/regression-tests-ci.yml + job: build-regression-tests-ci + strategy: depend + variables: + PARENT_PIPELINE_ID: $CI_PIPELINE_ID + ############################################################################### regression_test_4gpu: image: python:latest @@ -324,24 +363,23 @@ gpu_numerical_tests: before_script: - cd /tmp - - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.rz.tu-bs.de/irmb/test_data.git + - git clone --depth 1 --filter=blob:none --sparse https://github.com/irmb/test_data + - cd test_data + - git sparse-checkout set numerical_tests_gpu/grids numerical_tests_gpu/grids - export CCACHE_BASEDIR=$CI_PROJECT_DIR - export CCACHE_DIR=$CI_PROJECT_DIR/cache - ccache -s - mkdir -p $CI_PROJECT_DIR/build - cd $CI_PROJECT_DIR/build - - rm -r -f ./* + - rm -rf ./* - cmake .. --preset=make_numerical_tests_gpu -DCMAKE_CUDA_ARCHITECTURES=60 - -DPATH_NUMERICAL_TESTS=/tmp/test_data/numerical_tests_gpu - make -j4 - ccache -s script: - - cd $CI_PROJECT_DIR - # - ./build/bin/NumericalTests $CI_PROJECT_DIR/apps/gpu/tests/NumericalTests/configK15_nu10tm2.txt 2>&1 | tee -a numerical_tests_gpu_results.txt - - ./build/bin/NumericalTests $CI_PROJECT_DIR/apps/gpu/tests/NumericalTests/configK17chim_nu10tm3.txt 2>&1 | tee -a numerical_tests_gpu_results.txt + - $CI_PROJECT_DIR/build/bin/NumericalTests $CI_PROJECT_DIR/apps/gpu/tests/NumericalTests/configK17chim_nu10tm3.txt /tmp/test_data/numerical_tests_gpu/ 2>&1 | tee -a numerical_tests_gpu_results.txt cache: key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" @@ -353,31 +391,6 @@ gpu_numerical_tests: paths: - $CI_PROJECT_DIR/numerical_tests_gpu_results.txt -############################################################################### -run-regression-tests: - stage: test - - rules: - - if: $CI_PIPELINE_SOURCE == "schedule" - when: always - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - when: never - - when: manual - allow_failure: true - - needs: [] - - tags: - - gpu - - linux - - before_script: - - apt-get update && apt-get -y install python3.8-venv - - chmod +x ./regression-tests/* - - script: - - ./regression-tests/regression-tests.sh - ############################################################################### ## Code analysis ## ############################################################################### @@ -597,8 +610,6 @@ pages: .deploy_template: stage: deploy - - before_script: - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' - apt-get install -y rsync diff --git a/3rdParty/WebDemo/LBMDemoCopy.htm b/3rdParty/WebDemo/LBMDemoCopy.htm deleted file mode 100644 index c0a2834eaf2ad463f301bd3593972337219fb813..0000000000000000000000000000000000000000 --- a/3rdParty/WebDemo/LBMDemoCopy.htm +++ /dev/null @@ -1,1364 +0,0 @@ - -<!DOCTYPE HTML> -<!-- - A lattice-Boltzmann fluid simulation in JavaScript, using HTML5 canvas for graphics - - Copyright 2013, Daniel V. Schroeder - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated data and documentation (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name of the author shall not be used in - advertising or otherwise to promote the sale, use or other dealings in this - Software without prior written authorization. - - Credits: - The "wind tunnel" entry/exit conditions are inspired by Graham Pullan's code - (http://www.many-core.group.cam.ac.uk/projects/LBdemo.shtml). Additional inspiration from - Thomas Pohl's applet (http://thomas-pohl.info/work/lba.html). Other portions of code are based - on Wagner (http://www.ndsu.edu/physics/people/faculty/wagner/lattice_boltzmann_codes/) and - Gonsalves (http://www.physics.buffalo.edu/phy411-506-2004/index.html; code adapted from Succi, - http://global.oup.com/academic/product/the-lattice-boltzmann-equation-9780199679249). - - Revision history: - First version, with only start/stop, speed, and viscosity controls, February 2013 - Added resolution control, mouse interaction, plot options, etc., March 2013 - Added sensor, contrast slider, improved tracer placement, Fy period readout, May 2013 - Added option to animate using setTimeout instead of requestAnimationFrame, July 2013 - Added "Flowline" plotting (actually just line segments), August 2013 - - Still to do: - * Fix the apparent bug in the force calculation that gives inconsistent results depending - on initial conditions. Perhaps bounce-backs between adjacent barrier sites don't cancel? - * Grabbing the sensor while "drag fluid" selected causes a momentary drag at previous mouse location. - * Try to pass two-fingered touch events on to the browser, so it's still possible to zoom in and out. - * Work on GUI control layout, especially for smaller screens. - * Treat ends symmetrically when flow speed is zero. - * Try some other visualization techniques. ---> -<html> - -<head> -<title>Fluid Dynamics Simulation</title> -<meta charset="utf-8"> -<meta name="viewport" content="width=620"> -<style> - body {background-color:#ffffff; font-family:Arial, sans-serif; font-size:14px; - text-align:center;} /* gray background, center everything */ - p {margin-left:auto; margin-right:auto; width:600px;} /* keep paragraphs narrow and centered */ - input {font-size:115%;} /* make buttons bigger */ - input[type="range"] {width:90px;} /* make sliders shorter */ - select {font-size:115%;} /* make selectors bigger too */ - li {text-align:left;} -</style> -</head> - -<body> - -<h2>Fluid Dynamics Simulation</h2> - -<p>By <a href="http://physics.weber.edu/schroeder/">Dan Schroeder</a>, -<a href="http://physics.weber.edu">Physics Department</a>, -<a href="http://weber.edu">Weber State University</a></p> - -<canvas id="theCanvas" width="600" height="240">This application runs only in modern -browsers. For best results, use Google Chrome.</canvas> - -<div> - <select id="sizeSelect" onchange="resize()"> - <option value="10">60 x 24</option> - <option value="8">75 x 30</option> - <option value="6">100 x 40</option> - <option value="5">120 x 48</option> - <option value="4">150 x 60</option> - <option value="3">200 x 80</option> - <option value="2">300 x 120</option> - <option value="1">600 x 240</option> - </select> - <input id="resetFluidButton" type="button" onclick="initFluid()" value="Reset fluid"> - <input id="stepButton" type="button" onclick="simulate()" value="Step"> - <input id="startButton" type="button" onclick="startStop()" value="Start"> -</div> -<div> - Flow speed = <span id="speedValue">0.100</span> - <input id="speedSlider" type="range" min="0" max="0.12" step="0.005" value="0.1" onchange="adjustSpeed()"> - Viscosity = <span id="viscValue">0.020</span> - <input id="viscSlider" type="range" min="0.000000001" max="0.02" step="0.000005" value="0.02" onchange="adjustViscosity()"> -</div> -<div style="margin-top:3px"> - <select id="mouseSelect"> - <option value="draw">Draw barriers</option> - <option value="erase">Erase barriers</option> - <option value="push">Drag fluid</option> - </select> - <select id="barrierSelect" onchange="placePresetBarrier()"> - <option>Barrier shapes</option> - </select> - <input id="clearButton" type="button" onclick="clearBarriers()" value="Clear barriers"> -</div> -<div> - <select id="plotSelect" onchange="paintCanvas()"> - <option>Plot density</option> - <option>Plot x velocity</option> - <option>Plot y velocity</option> - <option>Plot speed</option> - <option selected>Plot curl</option> - </select> - Contrast: - <input id="contrastSlider" type="range" min="-10" max="10" step="1" value="0" onchange="paintCanvas()"> -</div> -<div> - Animation speed: - <input id="stepsSlider" type="range" min="1" max="40" step="1" value="20" onchange="resetTimer()"> - Steps per second: <span id="speedReadout">0</span> - <input id="rafCheck" type="checkbox" checked onchange="resetTimer()">Faster? -</div> -<div style="margin-top:4px"> - <!--<input id="pixelCheck" type="checkbox" checked onchange="resetTimer()">Use pixel graphics--> - Show: - <input id="tracerCheck" type="checkbox" onchange="initTracers()">Tracers - <input id="flowlineCheck" type="checkbox" onchange="paintCanvas()">Flowlines - <input id="forceCheck" type="checkbox" onchange="paintCanvas()">Force on barriers - <input id="sensorCheck" type="checkbox" onchange="paintCanvas()">Sensor - <input id="dataCheck" type="checkbox" onchange="showData()">Data -</div> -<div id="dataSection" style="display:none"> - <textarea id="dataArea" rows="8" cols="50" disabled readonly></textarea> - <div> - <input id="dataButton" type="button" value="Start data collection" onclick="startOrStopData()"> - <input id="periodButton" type="button" value="Show F_y period" onclick="showPeriod()"> - <input id="barrierDataButton" type="button" value="Show barrier locations" onclick="showBarrierLocations()"> - <input id="debugButton" type="button" value="Debug" onclick="debug()" style="display:none"> - </div> -</div> -<p style="text-align:left">This is a simulation of a two-dimensional fluid. Initially the fluid -is flowing from left to right, and a linear barrier (shown in black) diverts the fluid and creates -vortices. The colors indicate the curl, or local rotational motion, of the fluid. -Use the controls to adjust the flow speed and viscosity, draw different barriers, drag the -fluid around, plot other quantities besides the curl, show the force exerted by the fluid -on the barriers, and measure the fluid's density and velocity at any point. Enjoy!</p> - -<p style="text-align:left">The simulation uses a fairly simple -<a href="http://en.wikipedia.org/wiki/Lattice_Boltzmann_methods">lattice-Boltzmann algorithm</a>, -which you can see by viewing the JavaScript source code. As of mid-2013, the simulation -runs fastest under Chrome on either MacOS or Windows. Firefox is somewhat slower and Safari slower still, -while Opera and Internet Explorer are much slower. You can adjust the resolution to increase or -decrease the simulation speed.</p> - -<p style="text-align:left">If you don't see the slider controls above, try updating your browser. -As of August 2013, the most recent versions of all major browsers should show the sliders.</p> - -<p style="text-align:left">This HTML5-canvas-JavaScript web app is a work in progress. It still -has a few bugs and awkward features, which I hope to address some day.</p> - -<p style="text-align:left"> - Related materials: -</p> -<div style="margin-left:auto; margin-right:auto; width:600px;"> - <ul> - <li><a href="LatticeBoltzmannDemo.java.txt">A similar simulation in Java</a></li> - <li><a href="LatticeBoltzmannDemo.py.txt">A similar simulation in Python</a></li> - <li><a href="FluidSimulationsForUndergrads.pdf">Poster presentation</a> - given at the AAPT summer meeting, 2013 (pdf, 2.6 MB)</li> - <li><a href="http://physics.weber.edu/schroeder/javacourse/LatticeBoltzmann.pdf">Instructions</a> - for a lattice-Boltzmann project in a computational physics course</li> - <li>A more detailed explanation of the lattice-Boltzmann algorithm (coming soon)</li> - </ul> -</div> - -<script src="barrierdata.js"></script> -<script> - // Global variables: - var mobile = navigator.userAgent.match(/iPhone|iPad|iPod|Android|BlackBerry|Opera Mini|IEMobile/i) - var canvas = document.getElementById('theCanvas'); - var context = canvas.getContext('2d'); - var image = context.createImageData(canvas.width, canvas.height); // for direct pixel manipulation (faster than fillRect) - for (var i=3; i<image.data.length; i+=4) image.data[i] = 255; // set all alpha values to opaque - var sizeSelect = document.getElementById('sizeSelect'); - sizeSelect.selectedIndex = 5; - if (mobile) sizeSelect.selectedIndex = 1; // smaller works better on mobile platforms - var pxPerSquare = Number(sizeSelect.options[sizeSelect.selectedIndex].value); - // width of plotted grid site in pixels - var xdim = canvas.width / pxPerSquare; // grid dimensions for simulation - var ydim = canvas.height / pxPerSquare; - var stepsSlider = document.getElementById('stepsSlider'); - var startButton = document.getElementById('startButton'); - var speedSlider = document.getElementById('speedSlider'); - var speedValue = document.getElementById('speedValue'); - var viscSlider = document.getElementById('viscSlider'); - var viscValue = document.getElementById('viscValue'); - var mouseSelect = document.getElementById('mouseSelect'); - var barrierSelect = document.getElementById('barrierSelect'); - for (var barrierIndex=0; barrierIndex<barrierList.length; barrierIndex++) { - var shape = document.createElement("option"); - shape.text = barrierList[barrierIndex].name; - barrierSelect.add(shape, null); - } - var plotSelect = document.getElementById('plotSelect'); - var contrastSlider = document.getElementById('contrastSlider'); - //var pixelCheck = document.getElementById('pixelCheck'); - var tracerCheck = document.getElementById('tracerCheck'); - var flowlineCheck = document.getElementById('flowlineCheck'); - var forceCheck = document.getElementById('forceCheck'); - var sensorCheck = document.getElementById('sensorCheck'); - var dataCheck = document.getElementById('dataCheck'); - var rafCheck = document.getElementById('rafCheck'); - var speedReadout = document.getElementById('speedReadout'); - var dataSection = document.getElementById('dataSection'); - var dataArea = document.getElementById('dataArea'); - var dataButton = document.getElementById('dataButton'); - var running = false; // will be true when running - var stepCount = 0; - var startTime = 0; - var four9ths = 4.0 / 9.0; // abbreviations - var one9th = 1.0 / 9.0; - var one36th = 1.0 / 36.0; - var barrierCount = 0; - var barrierxSum = 0; - var barrierySum = 0; - var barrierFx = 0.0; // total force on all barrier sites - var barrierFy = 0.0; - var sensorX = xdim / 2; // coordinates of "sensor" to measure local fluid properties - var sensorY = ydim / 2; - var draggingSensor = false; - var mouseIsDown = false; - var mouseX, mouseY; // mouse location in canvas coordinates - var oldMouseX = -1, oldMouseY = -1; // mouse coordinates from previous simulation frame - var collectingData = false; - var time = 0; // time (in simulation step units) since data collection started - var showingPeriod = false; - var lastBarrierFy = 1; // for determining when F_y oscillation begins - var lastFyOscTime = 0; // for calculating F_y oscillation period - - canvas.addEventListener('mousedown', mouseDown, false); - canvas.addEventListener('mousemove', mouseMove, false); - document.body.addEventListener('mouseup', mouseUp, false); // button release could occur outside canvas - canvas.addEventListener('touchstart', mouseDown, false); - canvas.addEventListener('touchmove', mouseMove, false); - document.body.addEventListener('touchend', mouseUp, false); - - // Create the arrays of fluid particle densities, etc. (using 1D arrays for speed): - // To index into these arrays, use x + y*xdim, traversing rows first and then columns. - var n0 = new Array(xdim*ydim); // microscopic densities along each lattice direction - var nN = new Array(xdim*ydim); - var nS = new Array(xdim*ydim); - var nE = new Array(xdim*ydim); - var nW = new Array(xdim*ydim); - var nNE = new Array(xdim*ydim); - var nSE = new Array(xdim*ydim); - var nNW = new Array(xdim*ydim); - var nSW = new Array(xdim*ydim); - var rho = new Array(xdim*ydim); // macroscopic density - var ux = new Array(xdim*ydim); // macroscopic velocity - var uy = new Array(xdim*ydim); - var curl = new Array(xdim*ydim); - var barrier = new Array(xdim * ydim); // boolean array of barrier locations - var odd = 1; - - // Initialize to a steady rightward flow with no barriers: - for (var y=0; y<ydim; y++) { - for (var x=0; x<xdim; x++) { - barrier[x+y*xdim] = false; - } - } - - // Create a simple linear "wall" barrier (intentionally a little offset from center): - var barrierSize = 8; - if (mobile) barrierSize = 4; - for (var y=(ydim/2)-barrierSize; y<=(ydim/2)+barrierSize; y++) { - var x = Math.round(ydim/3); - barrier[x+y*xdim] = true; - } - - // Set up the array of colors for plotting (mimicks matplotlib "jet" colormap): - // (Kludge: Index nColors+1 labels the color used for drawing barriers.) - var nColors = 400; // there are actually nColors+2 colors - var hexColorList = new Array(nColors+2); - var redList = new Array(nColors+2); - var greenList = new Array(nColors+2); - var blueList = new Array(nColors+2); - for (var c=0; c<=nColors; c++) { - var r, g, b; - if (c < nColors/8) { - r = 0; g = 0; b = Math.round(255 * (c + nColors/8) / (nColors/4)); - } else if (c < 3*nColors/8) { - r = 0; g = Math.round(255 * (c - nColors/8) / (nColors/4)); b = 255; - } else if (c < 5*nColors/8) { - r = Math.round(255 * (c - 3*nColors/8) / (nColors/4)); g = 255; b = 255 - r; - } else if (c < 7*nColors/8) { - r = 255; g = Math.round(255 * (7*nColors/8 - c) / (nColors/4)); b = 0; - } else { - r = Math.round(255 * (9*nColors/8 - c) / (nColors/4)); g = 0; b = 0; - } - redList[c] = r; greenList[c] = g; blueList[c] = b; - hexColorList[c] = rgbToHex(r, g, b); - } - redList[nColors+1] = 0; greenList[nColors+1] = 0; blueList[nColors+1] = 0; // barriers are black - hexColorList[nColors+1] = rgbToHex(0, 0, 0); - - // Functions to convert rgb to hex color string (from stackoverflow): - function componentToHex(c) { - var hex = c.toString(16); - return hex.length == 1 ? "0" + hex : hex; - } - function rgbToHex(r, g, b) { - return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b); - } - - // Initialize array of partially transparant blacks, for drawing flow lines: - var transBlackArraySize = 50; - var transBlackArray = new Array(transBlackArraySize); - for (var i=0; i<transBlackArraySize; i++) { - transBlackArray[i] = "rgba(0,0,0," + Number(i/transBlackArraySize).toFixed(2) + ")"; - } - - // Initialize tracers (but don't place them yet): - var nTracers = 144; - var tracerX = new Array(nTracers); - var tracerY = new Array(nTracers); - for (var t=0; t<nTracers; t++) { - tracerX[t] = 0.0; tracerY[t] = 0.0; - } - - initFluid(); // initialize to steady rightward flow - - // Mysterious gymnastics that are apparently useful for better cross-browser animation timing: - window.requestAnimFrame = (function(callback) { - return window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function(callback) { - window.setTimeout(callback, 1); // second parameter is time in ms - }; - })(); - - // Simulate function executes a bunch of steps and then schedules another call to itself: - function simulate() { - var stepsPerFrame = Number(stepsSlider.value); // number of simulation steps per animation frame - setBoundaries(); - // Test to see if we're dragging the fluid: - var pushing = false; - var pushX, pushY, pushUX, pushUY; - if (mouseIsDown && mouseSelect.selectedIndex==2) { - if (oldMouseX >= 0) { - var gridLoc = canvasToGrid(mouseX, mouseY); - pushX = gridLoc.x; - pushY = gridLoc.y; - pushUX = (mouseX - oldMouseX) / pxPerSquare / stepsPerFrame; - pushUY = -(mouseY - oldMouseY) / pxPerSquare / stepsPerFrame; // y axis is flipped - if (Math.abs(pushUX) > 0.1) pushUX = 0.1 * Math.abs(pushUX) / pushUX; - if (Math.abs(pushUY) > 0.1) pushUY = 0.1 * Math.abs(pushUY) / pushUY; - pushing = true; - } - oldMouseX = mouseX; oldMouseY = mouseY; - } else { - oldMouseX = -1; oldMouseY = -1; - } - // Execute a bunch of time steps: - for (var step = 0; step < stepsPerFrame; step++) { - setBoundaries(); - collide(); - //stream(); - if (odd == 1) { odd = 0; } - else { odd = 1; } - if (tracerCheck.checked) moveTracers(); - if (pushing) push(pushX, pushY, pushUX, pushUY); - time++; - if (showingPeriod && (barrierFy > 0) && (lastBarrierFy <=0)) { - var thisFyOscTime = time - barrierFy/(barrierFy-lastBarrierFy); // interpolate when Fy changed sign - if (lastFyOscTime > 0) { - var period = thisFyOscTime - lastFyOscTime; - dataArea.innerHTML += Number(period).toFixed(2) + "\n"; - dataArea.scrollTop = dataArea.scrollHeight; - } - lastFyOscTime = thisFyOscTime; - } - lastBarrierFy = barrierFy; - } - paintCanvas(); - if (collectingData) { - writeData(); - if (time >= 10000) startOrStopData(); - } - if (running) { - stepCount += stepsPerFrame; - var elapsedTime = ((new Date()).getTime() - startTime) / 1000; // time in seconds - speedReadout.innerHTML = Number(stepCount/elapsedTime).toFixed(0); - } - var stable = true; - for (var x=0; x<xdim; x++) { - var index = x + (ydim/2)*xdim; // look at middle row only - if (rho[index] <= 0) stable = false; - } - if (!stable) { - window.alert("The simulation has become unstable due to excessive fluid speeds."); - startStop(); - initFluid(); - } - if (running) { - if (rafCheck.checked) { - requestAnimFrame(function() { simulate(); }); // let browser schedule next frame - } else { - window.setTimeout(simulate, 1); // schedule next frame asap (nominally 1 ms but always more) - } - } - } - - // Set the fluid variables at the boundaries, according to the current slider value: - function setBoundaries() { - var u0 = Number(speedSlider.value); - for (var x=0; x<xdim; x++) { - setEquil(x, 0, u0, 0, 1); - setEquil(x, ydim-1, u0, 0, 1); - } - for (var y=1; y<ydim-1; y++) { - setEquil(0, y, u0, 0, 1); - setEquil(xdim-1, y, u0, 0, 1); - } - } - - // Collide particles within each cell (here's the physics!): - function collideOLD() { - var viscosity = Number(viscSlider.value); // kinematic viscosity coefficient in natural units - var omega = 1 / (3*viscosity + 0.5); // reciprocal of relaxation time - for (var y=1; y<ydim-1; y++) { - for (var x=1; x<xdim-1; x++) { - var i = x + y*xdim; // array index for this lattice site - var thisrho = n0[i] + nN[i] + nS[i] + nE[i] + nW[i] + nNW[i] + nNE[i] + nSW[i] + nSE[i]; - rho[i] = thisrho; - var thisux = (nE[i] + nNE[i] + nSE[i] - nW[i] - nNW[i] - nSW[i]) / thisrho; - ux[i] = thisux; - var thisuy = (nN[i] + nNE[i] + nNW[i] - nS[i] - nSE[i] - nSW[i]) / thisrho; - uy[i] = thisuy - var one9thrho = one9th * thisrho; // pre-compute a bunch of stuff for optimization - var one36thrho = one36th * thisrho; - var ux3 = 3 * thisux; - var uy3 = 3 * thisuy; - var ux2 = thisux * thisux; - var uy2 = thisuy * thisuy; - var uxuy2 = 2 * thisux * thisuy; - var u2 = ux2 + uy2; - var u215 = 1.5 * u2; - n0[i] += omega * (four9ths*thisrho * (1 - u215) - n0[i]); - nE[i] += omega * ( one9thrho * (1 + ux3 + 4.5*ux2 - u215) - nE[i]); - nW[i] += omega * ( one9thrho * (1 - ux3 + 4.5*ux2 - u215) - nW[i]); - nN[i] += omega * ( one9thrho * (1 + uy3 + 4.5*uy2 - u215) - nN[i]); - nS[i] += omega * ( one9thrho * (1 - uy3 + 4.5*uy2 - u215) - nS[i]); - nNE[i] += omega * ( one36thrho * (1 + ux3 + uy3 + 4.5*(u2+uxuy2) - u215) - nNE[i]); - nSE[i] += omega * ( one36thrho * (1 + ux3 - uy3 + 4.5*(u2-uxuy2) - u215) - nSE[i]); - nNW[i] += omega * ( one36thrho * (1 - ux3 + uy3 + 4.5*(u2-uxuy2) - u215) - nNW[i]); - nSW[i] += omega * ( one36thrho * (1 - ux3 - uy3 + 4.5*(u2+uxuy2) - u215) - nSW[i]); - } - } - for (var y=1; y<ydim-2; y++) { - nW[xdim-1+y*xdim] = nW[xdim-2+y*xdim]; // at right end, copy left-flowing densities from next row to the left - nNW[xdim-1+y*xdim] = nNW[xdim-2+y*xdim]; - nSW[xdim-1+y*xdim] = nSW[xdim-2+y*xdim]; - } - } - - ///----------------------------Cumulants - function collide() { - var viscosity = Number(viscSlider.value); // kinematic viscosity coefficient in natural units - var omega = 1 / (3 * viscosity + 0.5); // reciprocal of relaxation time - //var om3 = 9.0 * (8.0 - 6.0 * omega + omega * omega) / (36.0 - 18 * omega + 2 * omega * omega); // - var om3 = 3.0 * (omega - 2.0) / (omega - 3.0); - for (var y = 1; y < ydim - 1; y++) { - for (var x = 1; x < xdim - 1; x++) { - if (x > xdim - 5) { omega = 1; } - //if (true) - // {//(!barrier[x+y*xdim]){ - else { omega = 1 / (3 * viscosity + 0.5); } - if (!barrier[x+y*xdim]){ - var i = x + y * xdim; // array index for this lattice site - var ix=(x+1)+ y*xdim; - var iy=x+(y+1)*xdim; - var ixy=(x+1)+(y+1)*xdim; -var maa; -var mab; -var mac; -var mba; -var mbb; -var mbc; -var mca; -var mcb; -var mcc; - - if(odd==1){ - maa = nSW[ixy]; - mab = nW[ix]; - mac = nNW[ix]; - mba = nS[iy]; - mbb = n0[i]; - mbc = nN[i]; - mca = nSE[iy]; - mcb = nE[i]; - mcc = nNE[i]; - } - else - { - maa = nNE[ixy]; - mab = nE[ix]; - mac = nSE[ix]; - mba = nN[iy]; - mbb = n0[i]; - mbc = nS[i]; - mca = nNW[iy]; - mcb = nW[i]; - mcc = nSW[i]; - } - - var thisrho = maa + mab + mac + mba + mbb + mbc + mca + mcb + mcc; - rho[i] = thisrho; - var thisux = (mca+mcb+mcc-maa-mab-mac) / thisrho; - ux[i] = thisux; - var thisuy = (mac+mbc+mcc-maa-mba-mca) / thisrho; - uy[i] = thisuy; - - - - var n1=maa+mab+mac; - var n2=(-1-thisuy)*maa-thisuy*mab+(1-thisuy)*mac; - mac=(-1-thisuy)*(-1-thisuy)*maa+thisuy*thisuy*mab+(1-thisuy)*(1-thisuy)*mac; - maa=n1; - mab=n2; - - - n1=mba+mbb+mbc; - n2=(-1-thisuy)*mba-thisuy*mbb+(1-thisuy)*mbc; - mbc=(-1-thisuy)*(-1-thisuy)*mba+thisuy*thisuy*mbb+(1-thisuy)*(1-thisuy)*mbc; - mba=n1; - mbb=n2; - - - n1=mca+mcb+mcc; - n2=(-1-thisuy)*mca-thisuy*mcb+(1-thisuy)*mcc; - mcc=(-1-thisuy)*(-1-thisuy)*mca+thisuy*thisuy*mcb+(1-thisuy)*(1-thisuy)*mcc; - mca=n1; - mcb=n2; -///// y - n1=maa+mba+mca; - n2=(-1-thisux)*maa-thisux*mba+(1-thisux)*mca; - mca=(-1-thisux)*(-1-thisux)*maa+thisux*thisux*mba+(1-thisux)*(1-thisux)*mca; - maa=n1; - mba=n2; - - n1=mab+mbb+mcb; - n2=(-1-thisux)*mab-thisux*mbb+(1-thisux)*mcb; - mcb=(-1-thisux)*(-1-thisux)*mab+thisux*thisux*mbb+(1-thisux)*(1-thisux)*mcb; - mab=n1; - mbb=n2; - - n1=mac+mbc+mcc; - n2=(-1-thisux)*mac-thisux*mbc+(1-thisux)*mcc; - mcc=(-1-thisux)*(-1-thisux)*mac+thisux*thisux*mbc+(1-thisux)*(1-thisux)*mcc; - mac=n1; - mbc=n2; - // - - //----fast transform - -// var n1 = mcc + maa - mac - mca - thisux * thisuy / thisrho; -// var n2; -// //var pp = 2 * (mca + mac + maa + mcc) + mba + mbc + mab + mcb - (thisux * thisux + thisuy * thisuy) / thisrho; -// var pxx = -mba - mbc + mab + mcb - (thisux * thisux - thisuy * thisuy) / thisrho; -// maa = thisrho; -// mba = 0; -// mab = 0; -// mbb = n1; - - //-----!FastTransform - - //now the collision: - - var pp=mac+mca; - var pxx = mca - mac; - var CUMcc = mcc - (mca * mac + 2 * mbb * mbb) / thisrho; - - //---- - var dxUx = (-0.5 * omega * (2 * mca - mac) - 0.5 * (mca + mac - maa)) / thisrho; - var dyUy = (-0.5 * omega * (2 * mac - mca) - 0.5 * (mca + mac - maa)) / thisrho; - //---- - - // pp = thisrho/3.0*(dxUx*dxUx+dyUy*dyUy)+ 2.0 / 3.0 * thisrho; - // CUMcc = 0.0; - // pxx =thisrho/3.0*(dxUx*dxUx-dyUy*dyUy)*omega-3*thisrho*(1.0-omega*0.5)*(thisux*thisux*dxUx-thisuy*thisuy*dyUy)+ pxx * (1.0 - omega); - var om2=omega;//1.99; -var quadLim = 0.01; //0.001/(0.01+uu+1.0e-9); -var limit1 = om2 + (1.0 - om2) * Math.abs(pp) / (Math.abs(pp) + 0.5); //4 Konstantin - pp=2.0/3.0*thisrho*limit1+(1.0-limit1)*pp; - //pp = 2.0 / 3.0 * thisrho; - pxx = -3*thisrho*(1.0-omega*0.5)*(thisux*thisux*dxUx-thisuy*thisuy*dyUy)+ pxx * (1.0 - omega); - mbb = mbb * (1.0 - omega); - mca = 0.5 * (pp + pxx); - mac = 0.5 * (pp - pxx); - //-----without limiter - // mcb = 0.0; //mcb * (1.0 - om3); - - // mbc = 0.0; //mbc * (1.0 - om3); - //---with limiter - var uu = Math.sqrt(thisux * thisux + thisuy * thisuy); - - var limIT = om3 + (1.0 - om3) * Math.abs(mcb) / (Math.abs(mcb) + quadLim); - mcb = mcb * (1.0 - limIT); - limIT = om3 + (1.0 - om3) * Math.abs(mbc) / (Math.abs(mbc) + quadLim); - mbc = mbc * (1.0 - limIT); - //---!limiter - - mcc = /*CUMcc+ */ (mca * mac + 2 * mbb * mbb) / thisrho; - - - ////x-Richtung - - n1 = (mcc + mac * (-1 + thisux) * thisux + mbc * (-1 + 2 * thisux)) * 0.5; - n2 = mac - mcc - 2 * mbc * thisux - mac * thisux * thisux; - mcc = (mbc + mcc + 2 * mbc * thisux + mac * thisux * (1 + thisux)) * 0.5; - mac = n1; - mbc = n2; - - n1 = (mcb + mab * (-1 + thisux) * thisux + mbb * (-1 + 2 * thisux)) * 0.5; - n2 = mab - mcb - 2 * mbb * thisux - mab * thisux * thisux; - mcb = (mbb + mcb + 2 * mbb * thisux + mab * thisux * (1 + thisux)) * 0.5; - mab = n1; - mbb = n2; - - n1 = (mca + maa * (-1 + thisux) * thisux + mba * (-1 + 2 * thisux)) * 0.5; - n2 = maa - mca - 2 * mba * thisux - maa * thisux * thisux; - mca = (mba + mca + 2 * mba * thisux + maa * thisux * (1 + thisux)) * 0.5; - maa = n1; - mba = n2; - - ////y-Richtung - n1 = (mcc + mca * (-1 + thisuy) * thisuy + mcb * (-1 + 2 * thisuy)) * 0.5; - n2 = mca - mcc - 2 * mcb * thisuy - mca * thisuy * thisuy; - mcc = (mcb + mcc + 2 * mcb * thisuy + mca * thisuy * (1 + thisuy)) * 0.5; - mca = n1; - mcb = n2; - - n1 = (mbc + mba * (-1 + thisuy) * thisuy + mbb * (-1 + 2 * thisuy)) * 0.5; - n2 = mba - mbc - 2 * mbb * thisuy - mba * thisuy * thisuy; - mbc = (mbb + mbc + 2 * mbb * thisuy + mba * thisuy * (1 + thisuy)) * 0.5; - mba = n1; - mbb = n2; - - n1 = (mac + maa * (-1 + thisuy) * thisuy + mab * (-1 + 2 * thisuy)) * 0.5; - n2 = maa - mac - 2 * mab * thisuy - maa * thisuy * thisuy; - mac = (mab + mac + 2 * mab * thisuy + maa * thisuy * (1 + thisuy)) * 0.5; - maa = n1; - mab = n2; - - - if (odd==1){ - n0[i] =mbb; - nW[ix] =mcb; - nE[i] =mab; - nS[iy] =mbc; - nN[i] =mba; - nSW[ixy]=mcc; - nNW[ix]=mca; - nSE[iy]=mac; - nNE[i] = maa; - - } - else{ - n0[i] =mbb; - nE[ix] =mcb; - nW[i] =mab; - nN[iy] =mbc; - nS[i] =mba; - nNE[ixy]=mcc; - nSE[ix]=mca; - nNW[iy]=mac; - nSW[i] = maa; - - } - } - } - } - // if (odd == 0) { - // for (var y = 1; y < ydim - 2; y++) { - // nE[xdim - 1 + y * xdim] = nE[xdim - 2 + y * xdim]; // at right end, copy left-flowing densities from next row to the left - // nNE[xdim - 1 + y * xdim] = nNE[xdim - 2 + y * xdim]; - // nSE[xdim - 1 + y * xdim] = nSE[xdim - 2 + y * xdim]; - - // nW[1+y * xdim] += 0.0001 * 3; - // nWE[1+y * xdim] += 0.0001; - // nWS[1+y * xdim] += 0.0001; - // } - //} - //else { - // for (var y = 1; y < ydim - 2; y++) { - // nW[xdim - 1 + y * xdim] = nW[xdim - 2 + y * xdim]; // at right end, copy left-flowing densities from next row to the left - // nNW[xdim - 1 + y * xdim] = nNW[xdim - 2 + y * xdim]; - // nSW[xdim - 1 + y * xdim] = nSW[xdim - 2 + y * xdim]; - //} - //} - - } - -////------------------------------!Cumulants - - - - // Move particles along their directions of motion: - function stream() { - barrierCount = 0; barrierxSum = 0; barrierySum = 0; - barrierFx = 0.0; barrierFy = 0.0; - for (var y=ydim-2; y>0; y--) { // first start in NW corner... - for (var x=1; x<xdim-1; x++) { - nN[x+y*xdim] = nN[x+(y-1)*xdim]; // move the north-moving particles - nNW[x+y*xdim] = nNW[x+1+(y-1)*xdim]; // and the northwest-moving particles - } - } - for (var y=ydim-2; y>0; y--) { // now start in NE corner... - for (var x=xdim-2; x>0; x--) { - nE[x+y*xdim] = nE[x-1+y*xdim]; // move the east-moving particles - nNE[x+y*xdim] = nNE[x-1+(y-1)*xdim]; // and the northeast-moving particles - } - } - for (var y=1; y<ydim-1; y++) { // now start in SE corner... - for (var x=xdim-2; x>0; x--) { - nS[x+y*xdim] = nS[x+(y+1)*xdim]; // move the south-moving particles - nSE[x+y*xdim] = nSE[x-1+(y+1)*xdim]; // and the southeast-moving particles - } - } - for (var y=1; y<ydim-1; y++) { // now start in the SW corner... - for (var x=1; x<xdim-1; x++) { - nW[x+y*xdim] = nW[x+1+y*xdim]; // move the west-moving particles - nSW[x+y*xdim] = nSW[x+1+(y+1)*xdim]; // and the southwest-moving particles - } - } - for (var y=1; y<ydim-1; y++) { // Now handle bounce-back from barriers - for (var x=1; x<xdim-1; x++) { - if (barrier[x+y*xdim]) { - var index = x + y*xdim; - nE[x+1+y*xdim] = nW[index]; - nW[x-1+y*xdim] = nE[index]; - nN[x+(y+1)*xdim] = nS[index]; - nS[x+(y-1)*xdim] = nN[index]; - nNE[x+1+(y+1)*xdim] = nSW[index]; - nNW[x-1+(y+1)*xdim] = nSE[index]; - nSE[x+1+(y-1)*xdim] = nNW[index]; - nSW[x-1+(y-1)*xdim] = nNE[index]; - // Keep track of stuff needed to plot force vector: - barrierCount++; - barrierxSum += x; - barrierySum += y; - barrierFx += nE[index] + nNE[index] + nSE[index] - nW[index] - nNW[index] - nSW[index]; - barrierFy += nN[index] + nNE[index] + nNW[index] - nS[index] - nSE[index] - nSW[index]; - } - } - } - } - - // Move the tracer particles: - function moveTracers() { - for (var t=0; t<nTracers; t++) { - var roundedX = Math.round(tracerX[t]); - var roundedY = Math.round(tracerY[t]); - var index = roundedX + roundedY*xdim; - tracerX[t] += ux[index]; - tracerY[t] += uy[index]; - if (tracerX[t] > xdim-1) { - tracerX[t] = 0; - tracerY[t] = Math.random() * ydim; - } - } - } - - // "Drag" the fluid in a direction determined by the mouse (or touch) motion: - // (The drag affects a "circle", 5 px in diameter, centered on the given coordinates.) - function push(pushX, pushY, pushUX, pushUY) { - // First make sure we're not too close to edge: - var margin = 3; - if ((pushX > margin) && (pushX < xdim-1-margin) && (pushY > margin) && (pushY < ydim-1-margin)) { - for (var dx=-1; dx<=1; dx++) { - setEquil(pushX+dx, pushY+2, pushUX, pushUY); - setEquil(pushX+dx, pushY-2, pushUX, pushUY); - } - for (var dx=-2; dx<=2; dx++) { - for (var dy=-1; dy<=1; dy++) { - setEquil(pushX+dx, pushY+dy, pushUX, pushUY); - } - } - } - } - - // Set all densities in a cell to their equilibrium values for a given velocity and density: - // (If density is omitted, it's left unchanged.) - function setEquil(x, y, newux, newuy, newrho) { - var i = x + y * xdim; - var ix = (x + 1) + y * xdim; - var iy = x + (y + 1) * xdim; - var ixy = (x + 1) + (y + 1) * xdim; - - if (typeof newrho == 'undefined') { - newrho = rho[i]; - } - var ux3 = 3 * newux; - var uy3 = 3 * newuy; - var ux2 = newux * newux; - var uy2 = newuy * newuy; - var uxuy2 = 2 * newux * newuy; - var u2 = ux2 + uy2; - var u215 = 1.5 * u2; - if (odd == 0) { - n0[i] = four9ths * newrho * (1 - u215); - nW[ix] = one9th * newrho * (1 + ux3 + 4.5 * ux2 - u215); - nE[i] = one9th * newrho * (1 - ux3 + 4.5 * ux2 - u215); - nS[iy] = one9th * newrho * (1 + uy3 + 4.5 * uy2 - u215); - nN[i] = one9th * newrho * (1 - uy3 + 4.5 * uy2 - u215); - nSW[ixy] = one36th * newrho * (1 + ux3 + uy3 + 4.5 * (u2 + uxuy2) - u215); - nNW[ix] = one36th * newrho * (1 + ux3 - uy3 + 4.5 * (u2 - uxuy2) - u215); - nSE[iy] = one36th * newrho * (1 - ux3 + uy3 + 4.5 * (u2 - uxuy2) - u215); - nNE[i] = one36th * newrho * (1 - ux3 - uy3 + 4.5 * (u2 + uxuy2) - u215); - rho[i] = newrho; - ux[i] = newux; - uy[i] = newuy; - } - else { - n0[i] = four9ths * newrho * (1 - u215); - nE[ix] = one9th * newrho * (1 + ux3 + 4.5 * ux2 - u215); - nW[i] = one9th * newrho * (1 - ux3 + 4.5 * ux2 - u215); - nN[iy] = one9th * newrho * (1 + uy3 + 4.5 * uy2 - u215); - nS[i] = one9th * newrho * (1 - uy3 + 4.5 * uy2 - u215); - nNE[ixy] = one36th * newrho * (1 + ux3 + uy3 + 4.5 * (u2 + uxuy2) - u215); - nSE[ix] = one36th * newrho * (1 + ux3 - uy3 + 4.5 * (u2 - uxuy2) - u215); - nNW[iy] = one36th * newrho * (1 - ux3 + uy3 + 4.5 * (u2 - uxuy2) - u215); - nSW[i] = one36th * newrho * (1 - ux3 - uy3 + 4.5 * (u2 + uxuy2) - u215); - rho[i] = newrho; - ux[i] = newux; - uy[i] = newuy; - - } - } - - // Initialize the tracer particles: - function initTracers() { - if (tracerCheck.checked) { - var nRows = Math.ceil(Math.sqrt(nTracers)); - var dx = xdim / nRows; - var dy = ydim / nRows; - var nextX = dx / 2; - var nextY = dy / 2; - for (var t=0; t<nTracers; t++) { - tracerX[t] = nextX; - tracerY[t] = nextY; - nextX += dx; - if (nextX > xdim) { - nextX = dx / 2; - nextY += dy; - } - } - } - paintCanvas(); - } - - // Paint the canvas: - function paintCanvas() { - var cIndex=0; - var contrast = Math.pow(1.2,Number(contrastSlider.value)); - var plotType = plotSelect.selectedIndex; - //var pixelGraphics = pixelCheck.checked; - if (plotType == 4) computeCurl(); - for (var y=0; y<ydim; y++) { - for (var x=0; x<xdim; x++) { - if (barrier[x+y*xdim]) { - cIndex = nColors + 1; // kludge for barrier color which isn't really part of color map - } else { - if (plotType == 0) { - cIndex = Math.round(nColors * ((rho[x+y*xdim]-1)*6*contrast + 0.5)); - } else if (plotType == 1) { - cIndex = Math.round(nColors * (ux[x+y*xdim]*2*contrast + 0.5)); - } else if (plotType == 2) { - cIndex = Math.round(nColors * (uy[x+y*xdim]*2*contrast + 0.5)); - } else if (plotType == 3) { - var speed = Math.sqrt(ux[x+y*xdim]*ux[x+y*xdim] + uy[x+y*xdim]*uy[x+y*xdim]); - cIndex = Math.round(nColors * (speed*4*contrast)); - } else { - cIndex = Math.round(nColors * (curl[x+y*xdim]*5*contrast + 0.5)); - } - if (cIndex < 0) cIndex = 0; - if (cIndex > nColors) cIndex = nColors; - } - //if (pixelGraphics) { - //colorSquare(x, y, cIndex); - colorSquare(x, y, redList[cIndex], greenList[cIndex], blueList[cIndex]); - //} else { - // context.fillStyle = hexColorList[cIndex]; - // context.fillRect(x*pxPerSquare, (ydim-y-1)*pxPerSquare, pxPerSquare, pxPerSquare); - //} - } - } - //if (pixelGraphics) - context.putImageData(image, 0, 0); // blast image to the screen - // Draw tracers, force vector, and/or sensor if appropriate: - if (tracerCheck.checked) drawTracers(); - if (flowlineCheck.checked) drawFlowlines(); - if (forceCheck.checked) drawForceArrow(barrierxSum/barrierCount, barrierySum/barrierCount, barrierFx, barrierFy); - if (sensorCheck.checked) drawSensor(); - } - - // Color a grid square in the image data array, one pixel at a time (rgb each in range 0 to 255): - function colorSquare(x, y, r, g, b) { - //function colorSquare(x, y, cIndex) { // for some strange reason, this version is quite a bit slower on Chrome - //var r = redList[cIndex]; - //var g = greenList[cIndex]; - //var b = blueList[cIndex]; - var flippedy = ydim - y - 1; // put y=0 at the bottom - for (var py=flippedy*pxPerSquare; py<(flippedy+1)*pxPerSquare; py++) { - for (var px=x*pxPerSquare; px<(x+1)*pxPerSquare; px++) { - var index = (px + py*image.width) * 4; - image.data[index+0] = r; - image.data[index+1] = g; - image.data[index+2] = b; - } - } - } - - // Compute the curl (actually times 2) of the macroscopic velocity field, for plotting: - function computeCurl() { - for (var y=1; y<ydim-1; y++) { // interior sites only; leave edges set to zero - for (var x=1; x<xdim-1; x++) { - curl[x+y*xdim] = uy[x+1+y*xdim] - uy[x-1+y*xdim] - ux[x+(y+1)*xdim] + ux[x+(y-1)*xdim]; - } - } - } - - // Draw the tracer particles: - function drawTracers() { - context.fillStyle = "rgb(150,150,150)"; - for (var t=0; t<nTracers; t++) { - var canvasX = (tracerX[t]+0.5) * pxPerSquare; - var canvasY = canvas.height - (tracerY[t]+0.5) * pxPerSquare; - context.fillRect(canvasX-1, canvasY-1, 2, 2); - } - } - - // Draw a grid of short line segments along flow directions: - function drawFlowlines() { - var pxPerFlowline = 10; - if (pxPerSquare == 1) pxPerFlowline = 6; - if (pxPerSquare == 2) pxPerFlowline = 8; - if (pxPerSquare == 5) pxPerFlowline = 12; - if ((pxPerSquare == 6) || (pxPerSquare == 8)) pxPerFlowline = 15; - if (pxPerSquare == 10) pxPerFlowline = 20; - var sitesPerFlowline = pxPerFlowline / pxPerSquare; - var xLines = canvas.width / pxPerFlowline; - var yLines = canvas.height / pxPerFlowline; - for (var yCount=0; yCount<yLines; yCount++) { - for (var xCount=0; xCount<xLines; xCount++) { - var x = Math.round((xCount+0.5) * sitesPerFlowline); - var y = Math.round((yCount+0.5) * sitesPerFlowline); - var thisUx = ux[x+y*xdim]; - var thisUy = uy[x+y*xdim]; - var speed = Math.sqrt(thisUx*thisUx + thisUy*thisUy); - if (speed > 0.0001) { - var px = (xCount+0.5) * pxPerFlowline; - var py = canvas.height - ((yCount+0.5) * pxPerFlowline); - var scale = 0.5 * pxPerFlowline / speed; - context.beginPath(); - context.moveTo(px-thisUx*scale, py+thisUy*scale); - context.lineTo(px+thisUx*scale, py-thisUy*scale); - //context.lineWidth = speed * 5; - var cIndex = Math.round(speed * transBlackArraySize / 0.3); - if (cIndex >= transBlackArraySize) cIndex = transBlackArraySize - 1; - context.strokeStyle = transBlackArray[cIndex]; - //context.strokeStyle = "rgba(0,0,0,0.1)"; - context.stroke(); - } - } - } - } - - // Draw an arrow to represent the total force on the barrier(s): - function drawForceArrow(x, y, Fx, Fy) { - context.fillStyle = "rgba(100,100,100,0.7)"; - context.translate((x + 0.5) * pxPerSquare, canvas.height - (y + 0.5) * pxPerSquare); - var magF = Math.sqrt(Fx*Fx + Fy*Fy); - context.scale(4*magF, 4*magF); - context.rotate(Math.atan2(-Fy, Fx)); - context.beginPath(); - context.moveTo(0, 3); - context.lineTo(100, 3); - context.lineTo(100, 12); - context.lineTo(130, 0); - context.lineTo(100, -12); - context.lineTo(100, -3); - context.lineTo(0, -3); - context.lineTo(0, 3); - context.fill(); - context.setTransform(1, 0, 0, 1, 0, 0); - } - - // Draw the sensor and its associated data display: - function drawSensor() { - var canvasX = (sensorX+0.5) * pxPerSquare; - var canvasY = canvas.height - (sensorY+0.5) * pxPerSquare; - context.fillStyle = "rgba(180,180,180,0.7)"; // first draw gray filled circle - context.beginPath(); - context.arc(canvasX, canvasY, 7, 0, 2*Math.PI); - context.fill(); - context.strokeStyle = "#404040"; // next draw cross-hairs - context.linewidth = 1; - context.beginPath(); - context.moveTo(canvasX, canvasY-10); - context.lineTo(canvasX, canvasY+10); - context.moveTo(canvasX-10, canvasY); - context.lineTo(canvasX+10, canvasY); - context.stroke(); - context.fillStyle = "rgba(255,255,255,0.5)"; // draw rectangle behind text - canvasX += 10; - context.font = "12px Monospace"; - var rectWidth = context.measureText("00000000000").width+6; - var rectHeight = 58; - if (canvasX+rectWidth > canvas.width) canvasX -= (rectWidth+20); - if (canvasY+rectHeight > canvas.height) canvasY = canvas.height - rectHeight; - context.fillRect(canvasX, canvasY, rectWidth, rectHeight); - context.fillStyle = "#000000"; // finally draw the text - canvasX += 3; - canvasY += 12; - var coordinates = " (" + sensorX + "," + sensorY + ")"; - context.fillText(coordinates, canvasX, canvasY); - canvasY += 14; - var rhoSymbol = String.fromCharCode(parseInt('03C1',16)); - var index = sensorX + sensorY * xdim; - context.fillText(" " + rhoSymbol + " = " + Number(rho[index]).toFixed(3), canvasX, canvasY); - canvasY += 14; - var digitString = Number(ux[index]).toFixed(3); - if (ux[index] >= 0) digitString = " " + digitString; - context.fillText("ux = " + digitString, canvasX, canvasY); - canvasY += 14; - digitString = Number(uy[index]).toFixed(3); - if (uy[index] >= 0) digitString = " " + digitString; - context.fillText("uy = " + digitString, canvasX, canvasY); - } - - // Functions to handle mouse/touch interaction: - function mouseDown(e) { - if (sensorCheck.checked) { - var canvasLoc = pageToCanvas(e.pageX, e.pageY); - var gridLoc = canvasToGrid(canvasLoc.x, canvasLoc.y); - var dx = (gridLoc.x - sensorX) * pxPerSquare; - var dy = (gridLoc.y - sensorY) * pxPerSquare; - if (Math.sqrt(dx*dx + dy*dy) <= 8) { - draggingSensor = true; - } - } - mousePressDrag(e); - }; - function mouseMove(e) { - if (mouseIsDown) { - mousePressDrag(e); - } - }; - function mouseUp(e) { - mouseIsDown = false; - draggingSensor = false; - }; - - // Handle mouse press or drag: - function mousePressDrag(e) { - e.preventDefault(); - mouseIsDown = true; - var canvasLoc = pageToCanvas(e.pageX, e.pageY); - if (draggingSensor) { - var gridLoc = canvasToGrid(canvasLoc.x, canvasLoc.y); - sensorX = gridLoc.x; - sensorY = gridLoc.y; - paintCanvas(); - return; - } - if (mouseSelect.selectedIndex == 2) { - mouseX = canvasLoc.x; - mouseY = canvasLoc.y; - return; - } - var gridLoc = canvasToGrid(canvasLoc.x, canvasLoc.y); - if (mouseSelect.selectedIndex == 0) { - addBarrier(gridLoc.x, gridLoc.y); - paintCanvas(); - } else { - removeBarrier(gridLoc.x, gridLoc.y); - } - } - - // Convert page coordinates to canvas coordinates: - function pageToCanvas(pageX, pageY) { - var canvasX = pageX - canvas.offsetLeft; - var canvasY = pageY - canvas.offsetTop; - // this simple subtraction may not work when the canvas is nested in other elements - return { x:canvasX, y:canvasY }; - } - - // Convert canvas coordinates to grid coordinates: - function canvasToGrid(canvasX, canvasY) { - var gridX = Math.floor(canvasX / pxPerSquare); - var gridY = Math.floor((canvas.height - 1 - canvasY) / pxPerSquare); // off by 1? - return { x:gridX, y:gridY }; - } - - // Add a barrier at a given grid coordinate location: - function addBarrier(x, y) { - if ((x > 1) && (x < xdim-2) && (y > 1) && (y < ydim-2)) { - barrier[x+y*xdim] = true; - } - } - - // Remove a barrier at a given grid coordinate location: - function removeBarrier(x, y) { - if (barrier[x+y*xdim]) { - barrier[x+y*xdim] = false; - paintCanvas(); - } - } - - // Clear all barriers: - function clearBarriers() { - for (var x=0; x<xdim; x++) { - for (var y=0; y<ydim; y++) { - barrier[x+y*xdim] = false; - } - } - paintCanvas(); - } - - // Resize the grid: - function resize() { - // First up-sample the macroscopic variables into temporary arrays at max resolution: - var tempRho = new Array(canvas.width*canvas.height); - var tempUx = new Array(canvas.width*canvas.height); - var tempUy = new Array(canvas.width*canvas.height); - var tempBarrier = new Array(canvas.width*canvas.height); - for (var y=0; y<canvas.height; y++) { - for (var x=0; x<canvas.width; x++) { - var tempIndex = x + y*canvas.width; - var xOld = Math.floor(x / pxPerSquare); - var yOld = Math.floor(y / pxPerSquare); - var oldIndex = xOld + yOld*xdim; - tempRho[tempIndex] = rho[oldIndex]; - tempUx[tempIndex] = ux[oldIndex]; - tempUy[tempIndex] = uy[oldIndex]; - tempBarrier[tempIndex] = barrier[oldIndex]; - } - } - // Get new size from GUI selector: - var oldPxPerSquare = pxPerSquare; - pxPerSquare = Number(sizeSelect.options[sizeSelect.selectedIndex].value); - var growRatio = oldPxPerSquare / pxPerSquare; - xdim = canvas.width / pxPerSquare; - ydim = canvas.height / pxPerSquare; - // Create new arrays at the desired resolution: - n0 = new Array(xdim*ydim); - nN = new Array(xdim*ydim); - nS = new Array(xdim*ydim); - nE = new Array(xdim*ydim); - nW = new Array(xdim*ydim); - nNE = new Array(xdim*ydim); - nSE = new Array(xdim*ydim); - nNW = new Array(xdim*ydim); - nSW = new Array(xdim*ydim); - rho = new Array(xdim*ydim); - ux = new Array(xdim*ydim); - uy = new Array(xdim*ydim); - curl = new Array(xdim*ydim); - barrier = new Array(xdim*ydim); - // Down-sample the temporary arrays into the new arrays: - for (var yNew=0; yNew<ydim; yNew++) { - for (var xNew=0; xNew<xdim; xNew++) { - var rhoTotal = 0; - var uxTotal = 0; - var uyTotal = 0; - var barrierTotal = 0; - for (var y=yNew*pxPerSquare; y<(yNew+1)*pxPerSquare; y++) { - for (var x=xNew*pxPerSquare; x<(xNew+1)*pxPerSquare; x++) { - var index = x + y*canvas.width; - rhoTotal += tempRho[index]; - uxTotal += tempUx[index]; - uyTotal += tempUy[index]; - if (tempBarrier[index]) barrierTotal++; - } - } - setEquil(xNew, yNew, uxTotal/(pxPerSquare*pxPerSquare), uyTotal/(pxPerSquare*pxPerSquare), rhoTotal/(pxPerSquare*pxPerSquare)) - curl[xNew+yNew*xdim] = 0.0; - barrier[xNew+yNew*xdim] = (barrierTotal >= pxPerSquare*pxPerSquare/2); - } - } - setBoundaries(); - if (tracerCheck.checked) { - for (var t=0; t<nTracers; t++) { - tracerX[t] *= growRatio; - tracerY[t] *= growRatio; - } - } - sensorX = Math.round(sensorX * growRatio); - sensorY = Math.round(sensorY * growRatio); - //computeCurl(); - paintCanvas(); - resetTimer(); - } - - // Function to initialize or re-initialize the fluid, based on speed slider setting: - function initFluid() { - // Amazingly, if I nest the y loop inside the x loop, Firefox slows down by a factor of 20 - var u0 = Number(speedSlider.value); - for (var y=0; y<ydim; y++) { - for (var x=0; x<xdim; x++) { - setEquil(x, y, u0, 0, 1); - curl[x+y*xdim] = 0.0; - } - } - paintCanvas(); - } - - // Function to start or pause the simulation: - function startStop() { - running = !running; - if (running) { - startButton.value = "Pause"; - resetTimer(); - simulate(); - } else { - startButton.value = " Run "; - } - } - - // Reset the timer that handles performance evaluation: - function resetTimer() { - stepCount = 0; - startTime = (new Date()).getTime(); - } - - // Show value of flow speed setting: - function adjustSpeed() { - speedValue.innerHTML = Number(speedSlider.value).toFixed(3); - } - - // Show value of viscosity: - function adjustViscosity() { - viscValue.innerHTML = Number(viscSlider.value);//.toFixed(6); - } - - // Show or hide the data area: - function showData() { - if (dataCheck.checked) { - dataSection.style.display="block"; - } else { - dataSection.style.display="none"; - } - } - - // Start or stop collecting data: - function startOrStopData() { - collectingData = !collectingData; - if (collectingData) { - time = 0; - dataArea.innerHTML = "Time \tDensity\tVel_x \tVel_y \tForce_x\tForce_y\n"; - writeData(); - dataButton.value = "Stop data collection"; - showingPeriod = false; - periodButton.value = "Show F_y period"; - } else { - dataButton.value = "Start data collection"; - } - } - - // Write one line of data to the data area: - function writeData() { - var timeString = String(time); - while (timeString.length < 5) timeString = "0" + timeString; - sIndex = sensorX + sensorY*xdim; - dataArea.innerHTML += timeString + "\t" + Number(rho[sIndex]).toFixed(4) + "\t" - + Number(ux[sIndex]).toFixed(4) + "\t" + Number(uy[sIndex]).toFixed(4) + "\t" - + Number(barrierFx).toFixed(4) + "\t" + Number(barrierFy).toFixed(4) + "\n"; - dataArea.scrollTop = dataArea.scrollHeight; - } - - // Handle click to "show period" button - function showPeriod() { - showingPeriod = !showingPeriod; - if (showingPeriod) { - time = 0; - lastBarrierFy = 1.0; // arbitrary positive value - lastFyOscTime = -1.0; // arbitrary negative value - dataArea.innerHTML = "Period of F_y oscillation\n"; - periodButton.value = "Stop data"; - collectingData = false; - dataButton.value = "Start data collection"; - } else { - periodButton.value = "Show F_y period"; - } - } - - // Write all the barrier locations to the data area: - function showBarrierLocations() { - dataArea.innerHTML = '{name:"Barrier locations",\n'; - dataArea.innerHTML += 'locations:[\n'; - for (var y=1; y<ydim-1; y++) { - for (var x=1; x<xdim-1; x++) { - if (barrier[x+y*xdim]) dataArea.innerHTML += x + ',' + y + ',\n'; - } - } - dataArea.innerHTML = dataArea.innerHTML.substr(0, dataArea.innerHTML.length-2); // remove final comma - dataArea.innerHTML += '\n]},\n'; - } - - // Place a preset barrier: - function placePresetBarrier() { - var index = barrierSelect.selectedIndex; - if (index == 0) return; - clearBarriers(); - var bCount = barrierList[index-1].locations.length/2; // number of barrier sites - // To decide where to place it, find minimum x and min/max y: - var xMin = barrierList[index-1].locations[0]; - var yMin = barrierList[index-1].locations[1]; - var yMax = yMin; - for (var siteIndex=2; siteIndex<2*bCount; siteIndex+=2) { - if (barrierList[index-1].locations[siteIndex] < xMin) { - xMin = barrierList[index-1].locations[siteIndex]; - } - if (barrierList[index-1].locations[siteIndex+1] < yMin) { - yMin = barrierList[index-1].locations[siteIndex+1]; - } - if (barrierList[index-1].locations[siteIndex+1] > yMax) { - yMax = barrierList[index-1].locations[siteIndex+1]; - } - } - var yAverage = Math.round((yMin+yMax)/2); - // Now place the barriers: - for (var siteIndex=0; siteIndex<2*bCount; siteIndex+=2) { - var x = barrierList[index-1].locations[siteIndex] - xMin + Math.round(ydim/3); - var y = barrierList[index-1].locations[siteIndex+1] - yAverage + Math.round(ydim/2); - addBarrier(x, y); - } - paintCanvas(); - barrierSelect.selectedIndex = 0; // A choice on this menu is a one-time action, not an ongoing setting - } - - // Print debugging data: - function debug() { - dataArea.innerHTML = "Tracer locations:\n"; - for (var t=0; t<nTracers; t++) { - dataArea.innerHTML += tracerX[t] + ", " + tracerY[t] + "\n"; - } - } -</script> - -</body> -</html> \ No newline at end of file diff --git a/3rdParty/WebDemo/barrierdata.js b/3rdParty/WebDemo/barrierdata.js deleted file mode 100644 index c165530d7dbc4b7b07d3e7a3f6703b180c38cbce..0000000000000000000000000000000000000000 --- a/3rdParty/WebDemo/barrierdata.js +++ /dev/null @@ -1,655 +0,0 @@ -var barrierList = [ -{ name: "Short line", - locations: [ -12, 15, -12, 16, -12, 17, -12, 18, -12, 19, -12, 20, -12, 21, -12, 22, -12, 23] -}, -{ name: "Long line", - locations: [ -13, 11, -13, 12, -13, 13, -13, 14, -13, 15, -13, 16, -13, 17, -13, 18, -13, 19, -13, 20, -13, 21, -13, 22, -13, 23, -13, 24, -13, 25, -13, 26, -13, 27, -13, 28 -] -}, -{ name: "Diagonal", - locations: [ -30, 14, -29, 15, -30, 15, -28, 16, -29, 16, -27, 17, -28, 17, -26, 18, -27, 18, -25, 19, -26, 19, -24, 20, -25, 20, -23, 21, -24, 21, -22, 22, -23, 22, -21, 23, -22, 23, -20, 24, -21, 24, -19, 25, -20, 25, -18, 26, -19, 26, -17, 27, -18, 27, -16, 28, -17, 28, -15, 29, -16, 29, -14, 30, -15, 30, -13, 31, -14, 31 -] -}, -{ name: "Shallow diagonal", - locations: [ -47, 18, -48, 18, -49, 18, -50, 18, -44, 19, -45, 19, -46, 19, -47, 19, -41, 20, -42, 20, -43, 20, -44, 20, -38, 21, -39, 21, -40, 21, -41, 21, -35, 22, -36, 22, -37, 22, -38, 22, -32, 23, -33, 23, -34, 23, -35, 23, -29, 24, -30, 24, -31, 24, -32, 24, -26, 25, -27, 25, -28, 25, -29, 25, -23, 26, -24, 26, -25, 26, -26, 26, -20, 27, -21, 27, -22, 27, -23, 27, -17, 28, -18, 28, -19, 28, -20, 28 -] -}, -{ name: "Small circle", - locations: [ -14, 11, -15, 11, -16, 11, -17, 11, -18, 11, -13, 12, -14, 12, -18, 12, -19, 12, -12, 13, -13, 13, -19, 13, -20, 13, -12, 14, -20, 14, -12, 15, -20, 15, -12, 16, -20, 16, -12, 17, -13, 17, -19, 17, -20, 17, -13, 18, -14, 18, -18, 18, -19, 18, -14, 19, -15, 19, -16, 19, -17, 19, -18, 19 -] -}, -{ name: "Large circle", - locations: [ -19, 11, -20, 11, -21, 11, -22, 11, -23, 11, -24, 11, -17, 12, -18, 12, -19, 12, -24, 12, -25, 12, -26, 12, -16, 13, -17, 13, -26, 13, -27, 13, -15, 14, -16, 14, -27, 14, -28, 14, -14, 15, -15, 15, -28, 15, -29, 15, -14, 16, -29, 16, -13, 17, -14, 17, -29, 17, -30, 17, -13, 18, -30, 18, -13, 19, -30, 19, -13, 20, -30, 20, -13, 21, -30, 21, -13, 22, -14, 22, -29, 22, -30, 22, -14, 23, -29, 23, -14, 24, -15, 24, -28, 24, -29, 24, -15, 25, -16, 25, -27, 25, -28, 25, -16, 26, -17, 26, -26, 26, -27, 26, -17, 27, -18, 27, -19, 27, -24, 27, -25, 27, -26, 27, -19, 28, -20, 28, -21, 28, -22, 28, -23, 28, -24, 28 -] -}, -{ name: "Line with spoiler", - locations: [ -16, 20, -16, 21, -16, 22, -16, 23, -16, 24, -17, 24, -18, 24, -19, 24, -20, 24, -21, 24, -22, 24, -23, 24, -24, 24, -25, 24, -26, 24, -27, 24, -28, 24, -29, 24, -30, 24, -31, 24, -32, 24, -33, 24, -34, 24, -35, 24, -36, 24, -37, 24, -38, 24, -39, 24, -40, 24, -41, 24, -42, 24, -43, 24, -44, 24, -45, 24, -46, 24, -47, 24, -48, 24, -49, 24, -50, 24, -16, 25, -16, 26, -16, 27, -16, 28 -] -}, -{ name: "Circle with spoiler", - locations: [ -29, 36, -30, 36, -31, 36, -32, 36, -33, 36, -28, 37, -29, 37, -33, 37, -34, 37, -27, 38, -28, 38, -34, 38, -35, 38, -27, 39, -35, 39, -27, 40, -35, 40, -36, 40, -37, 40, -38, 40, -39, 40, -40, 40, -41, 40, -42, 40, -43, 40, -44, 40, -45, 40, -46, 40, -47, 40, -48, 40, -49, 40, -50, 40, -51, 40, -52, 40, -53, 40, -54, 40, -55, 40, -56, 40, -57, 40, -58, 40, -59, 40, -60, 40, -61, 40, -62, 40, -63, 40, -64, 40, -65, 40, -66, 40, -67, 40, -68, 40, -69, 40, -27, 41, -35, 41, -27, 42, -28, 42, -34, 42, -35, 42, -28, 43, -29, 43, -33, 43, -34, 43, -29, 44, -30, 44, -31, 44, -32, 44, -33, 44 -] -}, -{ name: "Right angle", - locations: [ -27, 36, -28, 36, -29, 36, -30, 36, -31, 36, -32, 36, -33, 36, -34, 36, -35, 36, -36, 36, -37, 36, -38, 36, -39, 36, -40, 36, -41, 36, -42, 36, -43, 36, -44, 36, -45, 36, -46, 36, -47, 36, -48, 36, -49, 36, -50, 36, -51, 36, -52, 36, -53, 36, -54, 36, -55, 36, -56, 36, -57, 36, -58, 36, -59, 36, -60, 36, -61, 36, -62, 36, -63, 36, -64, 36, -65, 36, -66, 36, -67, 36, -68, 36, -69, 36, -70, 36, -71, 36, -72, 36, -73, 36, -74, 36, -75, 36, -76, 36, -77, 36, -78, 36, -79, 36, -27, 37, -27, 38, -27, 39, -27, 40, -27, 41, -27, 42, -27, 43, -27, 44 -] -}, -{ name: "Wedge", - locations: [ -27, 36, -28, 36, -29, 36, -30, 36, -31, 36, -32, 36, -33, 36, -34, 36, -35, 36, -36, 36, -37, 36, -38, 36, -39, 36, -40, 36, -41, 36, -42, 36, -43, 36, -44, 36, -45, 36, -46, 36, -47, 36, -48, 36, -49, 36, -50, 36, -51, 36, -52, 36, -53, 36, -54, 36, -55, 36, -56, 36, -57, 36, -58, 36, -59, 36, -60, 36, -61, 36, -62, 36, -63, 36, -64, 36, -65, 36, -66, 36, -67, 36, -68, 36, -69, 36, -70, 36, -71, 36, -72, 36, -73, 36, -74, 36, -75, 36, -76, 36, -77, 36, -78, 36, -79, 36, -27, 37, -67, 37, -68, 37, -69, 37, -70, 37, -71, 37, -72, 37, -73, 37, -27, 38, -61, 38, -62, 38, -63, 38, -64, 38, -65, 38, -66, 38, -67, 38, -27, 39, -55, 39, -56, 39, -57, 39, -58, 39, -59, 39, -60, 39, -61, 39, -27, 40, -49, 40, -50, 40, -51, 40, -52, 40, -53, 40, -54, 40, -55, 40, -27, 41, -43, 41, -44, 41, -45, 41, -46, 41, -47, 41, -48, 41, -49, 41, -27, 42, -37, 42, -38, 42, -39, 42, -40, 42, -41, 42, -42, 42, -43, 42, -27, 43, -31, 43, -32, 43, -33, 43, -34, 43, -35, 43, -36, 43, -37, 43, -27, 44, -28, 44, -29, 44, -30, 44, -31, 44 -] -}, -{ name: "Airfoil", - locations: [ -17, 16, -18, 16, -19, 16, -20, 16, -21, 16, -22, 16, -23, 16, -24, 16, -25, 16, -26, 16, -27, 16, -28, 16, -29, 16, -30, 16, -31, 16, -32, 16, -33, 16, -34, 16, -35, 16, -36, 16, -37, 16, -38, 16, -39, 16, -40, 16, -41, 16, -42, 16, -43, 16, -44, 16, -45, 16, -46, 16, -47, 16, -48, 16, -49, 16, -50, 16, -51, 16, -52, 16, -53, 16, -54, 16, -55, 16, -56, 16, -57, 16, -58, 16, -59, 16, -60, 16, -61, 16, -62, 16, -63, 16, -64, 16, -65, 16, -66, 16, -67, 16, -68, 16, -14, 17, -15, 17, -16, 17, -17, 17, -56, 17, -57, 17, -58, 17, -59, 17, -60, 17, -61, 17, -62, 17, -13, 18, -14, 18, -50, 18, -51, 18, -52, 18, -53, 18, -54, 18, -55, 18, -56, 18, -13, 19, -44, 19, -45, 19, -46, 19, -47, 19, -48, 19, -49, 19, -50, 19, -13, 20, -38, 20, -39, 20, -40, 20, -41, 20, -42, 20, -43, 20, -44, 20, -13, 21, -14, 21, -32, 21, -33, 21, -34, 21, -35, 21, -36, 21, -37, 21, -38, 21, -14, 22, -15, 22, -26, 22, -27, 22, -28, 22, -29, 22, -30, 22, -31, 22, -32, 22, -15, 23, -16, 23, -17, 23, -18, 23, -21, 23, -22, 23, -23, 23, -24, 23, -25, 23, -26, 23, -18, 24, -19, 24, -20, 24, -21, 24 -] -} -]; \ No newline at end of file diff --git a/CMake/cmake_config_files/ARAGORN.config.cmake b/CMake/cmake_config_files/ARAGORN.config.cmake index d713f02d971024f29d3fb0fd30cfce7585d9dc55..9f33c9977924ab60a1300763f53d04bb842b2f00 100644 --- a/CMake/cmake_config_files/ARAGORN.config.cmake +++ b/CMake/cmake_config_files/ARAGORN.config.cmake @@ -6,10 +6,6 @@ set(CMAKE_CUDA_ARCHITECTURES 86) # Nvidia GeForce RTX 3060 -# numerical tests location of the grids -# SET(PATH_NUMERICAL_TESTS "E:/temp/numericalTests/") -# list(APPEND VF_COMPILER_DEFINITION "PATH_NUMERICAL_TESTS=${PATH_NUMERICAL_TESTS}") - # add invidual apps here set(GPU_APP "apps/gpu/LBM/") list(APPEND USER_APPS diff --git a/CMake/cmake_config_files/ARAGORNUBUNTU.config.cmake b/CMake/cmake_config_files/ARAGORNUBUNTU.config.cmake index 90debb1a4c270109d4dfbb455f21253b3a6754b8..3259e13acaade9b896e5e4a82dec90d3f4eb5e89 100644 --- a/CMake/cmake_config_files/ARAGORNUBUNTU.config.cmake +++ b/CMake/cmake_config_files/ARAGORNUBUNTU.config.cmake @@ -14,4 +14,9 @@ list(APPEND USER_APPS "${GPU_APP}DrivenCavityMultiGPU" "${GPU_APP}SphereScaling" # "${GPU_APP}MusselOyster" - ) \ No newline at end of file + ) + +# add_compile_options(-fsanitize=address) +# add_link_options(-fsanitize=address) +# add_compile_options(-fsanitize=undefined) +# add_link_options(-fsanitize=undefined) diff --git a/CMake/cmake_config_files/BOMBADIL.config.cmake b/CMake/cmake_config_files/BOMBADIL.config.cmake index 9c4bd4ecffab1e63161343ecc493eb9d9bc951a4..0534bf1c87cb54bf6d8839b881fe6b772e2b7365 100644 --- a/CMake/cmake_config_files/BOMBADIL.config.cmake +++ b/CMake/cmake_config_files/BOMBADIL.config.cmake @@ -48,25 +48,6 @@ set(LIGGGHTS_RELEASE_LIBRARY "d:/Tools/LIGGGHTS/build/Release/liggghts.lib") # SET(METIS_RELEASE_LIBRARY "/mnt/d/Tools/metis-5.1.0/build/Linux-x86_64/libmetis/libmetis.a") #ENDIF() -################################################################################# -# PE -################################################################################# -IF(${USE_DEM_COUPLING}) - SET(PE_BINARY_DIR "d:/Tools/waLBerla/walberlaGit/build" CACHE PATH "pe binary dir") - SET(PE_ROOT "d:/Tools/waLBerla/walberlaGit" CACHE PATH "pe root") - - SET(PE_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/pe/Debug/pe.lib) - SET(PE_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/pe/Release/pe.lib) - SET(BLOCKFOREST_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/blockforest/Debug/blockforest.lib) - SET(BLOCKFOREST_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/blockforest/Release/blockforest.lib) - SET(DOMAIN_DECOMPOSITION_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/domain_decomposition/Debug/domain_decomposition.lib) - SET(DOMAIN_DECOMPOSITION_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/domain_decomposition/Release/domain_decomposition.lib) - SET(GEOMETRY_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/geometry/Debug/geometry.lib) - SET(GEOMETRY_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/geometry/Release/geometry.lib) - SET(CORE_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/core/Debug/core.lib) - SET(CORE_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/core/Release/core.lib) - - ENDIF() ################################################################################## # FETOL diff --git a/CMake/cmake_config_files/GITLAB-RUNNER03.config.cmake b/CMake/cmake_config_files/GITLAB-RUNNER03.config.cmake index edaf7669b171518c8aa6b2ec9786147a6ffc48f5..86780712df9b315883e3a49c7ea20443e66ddfd5 100644 --- a/CMake/cmake_config_files/GITLAB-RUNNER03.config.cmake +++ b/CMake/cmake_config_files/GITLAB-RUNNER03.config.cmake @@ -4,7 +4,4 @@ # OS: Windows 10 ################################################################################# - -#SET(PATH_NUMERICAL_TESTS "E:/temp/numericalTests/") -#LIST(APPEND VF_COMPILER_DEFINITION "PATH_NUMERICAL_TESTS=${PATH_NUMERICAL_TESTS}") SET(CMAKE_CUDA_ARCHITECTURES 61) \ No newline at end of file diff --git a/CMake/cmake_config_files/PHOENIX.config.cmake b/CMake/cmake_config_files/PHOENIX.config.cmake index d31d8684a53a769e48408ad5febe7d2c6b22c623..2112bd6aa50e9335bc6b23bda0f0e9fda3ef7533 100644 --- a/CMake/cmake_config_files/PHOENIX.config.cmake +++ b/CMake/cmake_config_files/PHOENIX.config.cmake @@ -4,24 +4,6 @@ # OS: CentOS 7.3 ################################################################################# -################################################################################# -# PE (legacy) -################################################################################# -IF(${USE_DEM_COUPLING}) - SET(PE_BINARY_DIR "/home/irmb/walberla-git/build" CACHE PATH "pe binary dir") - SET(PE_ROOT "/home/irmb/walberla-git" CACHE PATH "pe root") - - SET(PE_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/pe/libpe.a) - SET(PE_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/pe/libpe.a) - SET(BLOCKFOREST_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/blockforest/libblockforest.a) - SET(BLOCKFOREST_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/blockforest/libblockforest.a) - SET(DOMAIN_DECOMPOSITION_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/domain_decomposition/libdomain_decomposition.a) - SET(DOMAIN_DECOMPOSITION_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/domain_decomposition/libdomain_decomposition.a) - SET(GEOMETRY_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/geometry/libgeometry.a) - SET(GEOMETRY_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/geometry/libgeometry.a) - SET(CORE_DEBUG_LIBRARY ${PE_BINARY_DIR}/src/core/libcore.a) - SET(CORE_RELEASE_LIBRARY ${PE_BINARY_DIR}/src/core/libcore.a) -ENDIF() ## nvidia set(CMAKE_CUDA_ARCHITECTURES 60) # NVIDIA Tesla P100 diff --git a/CMakeLists.txt b/CMakeLists.txt index c6498bf19bb021f3ae19d69c4131aa56476149be..7d0dbf22fd98c2f6ac0cb417b2fe900f775bfa55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,9 +52,6 @@ option(BUILD_USE_BOOST "Build VirtualFluids with boost" OFF) option(BUILD_USE_MPI "include MPI library support" ON) # vf gpu -option(BUILD_VF_GKS "Build VirtualFluids GKS" OFF ) -option(BUILD_VF_TRAFFIC "Build VirtualFluids Traffic" OFF) -option(BUILD_JSONCPP "Builds json cpp " OFF) option(BUILD_NUMERIC_TESTS "Build numeric tests" OFF) option(BUILD_VF_UNIT_TESTS "Build VirtualFluids unit tests" OFF) @@ -78,7 +75,7 @@ endif() option(BUILD_VF_PYTHON_BINDINGS "" OFF) option(BUILD_VF_DOUBLE_ACCURACY "Use double accuracy" OFF) - +option(BUILD_VF_ALL_SAMPLES "Build All Samples" OFF) ################################################################################# # MACROS @@ -100,7 +97,7 @@ IF( BUILD_VF_DOUBLE_ACCURACY ) ENDIF() # set gpu features -if(BUILD_VF_GPU OR BUILD_VF_GKS) +if(BUILD_VF_GPU) include(CheckLanguage) check_language(CUDA) @@ -137,6 +134,8 @@ if(BUILD_VF_GPU OR BUILD_VF_GKS) message(STATUS "CMAKE_CUDA_FLAGS: ${CMAKE_CUDA_FLAGS}") message(STATUS "CUDA Architecture: ${CMAKE_CUDA_ARCHITECTURES}") set(CMAKE_CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}" CACHE STRING "Cuda Architecture (compute capabilitiy)") + + set(CMAKE_CUDA_FLAGS_DEBUG " -G" CACHE STRING "" FORCE) endif() @@ -212,11 +211,11 @@ add_subdirectory(src/lbm) # VIRTUAL FLUIDS CPU / GPU ################################################################################# if (BUILD_VF_CPU) - include (cpu.cmake) + include(cpu.cmake) endif() -if(BUILD_VF_GPU OR BUILD_VF_GKS) +if(BUILD_VF_GPU) add_subdirectory(src/cuda) - include (gpu.cmake) + include(gpu.cmake) endif() if (BUILD_VF_PYTHON_BINDINGS) diff --git a/Containers/dockerfiles/Ubuntu20_04.Dockerfile b/Containers/Ubuntu20_04.Dockerfile similarity index 73% rename from Containers/dockerfiles/Ubuntu20_04.Dockerfile rename to Containers/Ubuntu20_04.Dockerfile index 21511a97adab3694540c1d13a699f4d10b3d0356..97bce073bfd825e0afec97dace698ce28aca6139 100644 --- a/Containers/dockerfiles/Ubuntu20_04.Dockerfile +++ b/Containers/Ubuntu20_04.Dockerfile @@ -14,12 +14,14 @@ # clangd language server https://clangd.llvm.org/ # python pip3 with modules: setuptools, wheels, scikit-build, pyvista, numpy, ansible, gcovr +# software-properties-common for add-apt-repository + FROM nvidia/cuda:11.3.1-devel-ubuntu20.04 ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ apt-get install -y \ - wget unzip git \ + wget unzip software-properties-common \ build-essential gdb \ ccache \ ninja-build \ @@ -36,16 +38,13 @@ RUN apt-get update && \ cppcheck \ clangd-12 \ && update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-12 100 \ - && mkdir -p /usr/local/cmake/ && cd /usr/local/cmake/ \ - && version=3.24 && build=0 \ - && wget https://cmake.org/files/v$version/cmake-$version.$build-linux-x86_64.tar.gz \ - && tar -xzvf cmake-$version.$build-linux-x86_64.tar.gz \ - && ln -s /usr/local/cmake/cmake-$version.$build-linux-x86_64/bin/* /usr/local/bin/ \ && pip3 install \ + cmake==3.26.3 \ setuptools \ wheel \ scikit-build \ pyvista \ numpy \ ansible \ - 'jinja2<3.1' gcovr==5.0 + 'jinja2<3.1' gcovr==5.0 \ + && apt update && add-apt-repository -y ppa:git-core/ppa && apt update && apt install git -y diff --git a/Containers/VirtualFluidsBasicsTest.def b/Containers/VirtualFluidsBasicsTest.def deleted file mode 100644 index 930b93e5e9f71ff9b4b8afcae4c8ea47aeb82522..0000000000000000000000000000000000000000 --- a/Containers/VirtualFluidsBasicsTest.def +++ /dev/null @@ -1,29 +0,0 @@ -BootStrap: docker -From: ubuntu:20.04 - -%files - 3rdParty 3rdParty - apps apps - CMake CMake - Python Python - src src - CMakeLists.txt CMakeLists.txt - cpu.cmake cpu.cmake - gpu.cmake gpu.cmake - setup.py setup.py - pyproject.toml pyproject.toml - -%post - apt-get update && \ - apt-get install -y \ - build-essential \ - cmake=3.16.3-1ubuntu1 \ - openmpi-bin=4.0.3-0ubuntu1 \ - libomp-dev - - mkdir -p build && \ - cmake -DBUILD_VF_CPU=ON -DBUILD_VF_UNIT_TESTS=ON &&\ - make -j4 2>&1 - -%runscript - bin/basicsTest \ No newline at end of file diff --git a/Containers/VirtualFluidsMPICH.def b/Containers/VirtualFluidsMPICH.def deleted file mode 100644 index 72f9ac549bd9d2bd006dafededf7b7b2f74f2600..0000000000000000000000000000000000000000 --- a/Containers/VirtualFluidsMPICH.def +++ /dev/null @@ -1,44 +0,0 @@ -BootStrap: docker -From: ubuntu:20.04 - -%files - 3rdParty 3rdParty - apps apps - CMake CMake - Python Python - src src - CMakeLists.txt CMakeLists.txt - cpu.cmake cpu.cmake - gpu.cmake gpu.cmake - setup.py setup.py - pyproject.toml pyproject.toml - - -%post - export DEBIAN_FRONTEND=noninteractive - apt-get update && \ - apt-get install -y \ - build-essential \ - cmake=3.16.3-1ubuntu1 \ - python3 \ - python3-dev \ - python3-pip \ - mpich \ - libomp-dev - - pip3 install setuptools wheel - - export PYTHONPATH=Python - python3 /setup.py install - -%environment - export PYTHONPATH=/Python - -%runscript - python3 /Python/liddrivencavity/simulation.py - -%appenv poiseuille - export PYTHONPATH=Python - -%apprun poisueille - python3 /Python/poiseuille/poiseuille_hpc.py diff --git a/Containers/VirtualFluidsOpenMPI.def b/Containers/VirtualFluidsOpenMPI.def deleted file mode 100644 index 3903b8769d7e652bbb12add7b815eb35de279d94..0000000000000000000000000000000000000000 --- a/Containers/VirtualFluidsOpenMPI.def +++ /dev/null @@ -1,25 +0,0 @@ -BootStrap: docker -From: irmb/virtualfluids-python-deps - -%files - 3rdParty 3rdParty - apps apps - CMake CMake - Python Python - src src - CMakeLists.txt CMakeLists.txt - cpu.cmake cpu.cmake - gpu.cmake gpu.cmake - setup.py setup.py - pyproject.toml pyproject.toml - - -%post - export PYTHONPATH=Python - python3 /setup.py install - -%environment - export PYTHONPATH=/Python - -%runscript - python3 /Python/liddrivencavity/simulation.py diff --git a/Containers/VirtualFluidsPython.def b/Containers/VirtualFluidsPython.def deleted file mode 100644 index d54066bc634cf25f4340b1e659eae72515467fa8..0000000000000000000000000000000000000000 --- a/Containers/VirtualFluidsPython.def +++ /dev/null @@ -1,33 +0,0 @@ -BootStrap: docker -From: ubuntu:20.04 - -%files - Python Python - dist dist - - -%post - export DEBIAN_FRONTEND=noninteractive - apt-get update && \ - apt-get install -y \ - build-essential \ - cmake=3.16.3-1ubuntu1 \ - python3 \ - python3-dev \ - python3-pip \ - mpich \ - libomp-dev - - pip3 install setuptools wheel $(find dist/*.whl) - -%environment - export PYTHONPATH=/Python - -%runscript - python3 /Python/liddrivencavity/simulation.py - -%appenv poiseuille - export PYTHONPATH=Python - -%apprun poisueille - python3 /Python/poiseuille/poiseuille_hpc.py diff --git a/Python/actuator_line/actuator_line.py b/Python/actuator_line/actuator_line.py index 721af737ff6ef3340c3c2f6204aa6a7824cd1d2f..d0589f402456e8ffe8320ce7f780738aef22fbe4 100644 --- a/Python/actuator_line/actuator_line.py +++ b/Python/actuator_line/actuator_line.py @@ -46,10 +46,7 @@ output_path.mkdir(exist_ok=True) #%% logger.Logger.initialize_logger() -basics.logger.Logger.add_stdout() -basics.logger.Logger.set_debug_level(basics.logger.Level.INFO_LOW) -basics.logger.Logger.time_stamp(basics.logger.TimeStamp.ENABLE) -basics.logger.Logger.enable_printed_rank_numbers(True) + #%% grid_factory = gpu.grid_generator.GridFactory.make() grid_builder = gpu.grid_generator.MultipleGridBuilder.make_shared(grid_factory) @@ -147,7 +144,7 @@ grid_scaling_factory.set_scaling_factory(gpu.GridScaling.ScaleCompressible) grid_builder.add_coarse_grid(0.0, 0.0, 0.0, *length, dx) grid_builder.set_periodic_boundary_condition(not read_precursor, True, False) -grid_builder.build_grids(basics.LbmOrGks.LBM, False) +grid_builder.build_grids(False) sampling_offset = 2 if read_precursor: diff --git a/Python/boundary_layer/boundary_layer.py b/Python/boundary_layer/boundary_layer.py index 6f6c64bc072d3afbb8aa5febbec209c26af2deee..25b3cd895f8a3a80f9fd6438e00d3e924fc13779 100644 --- a/Python/boundary_layer/boundary_layer.py +++ b/Python/boundary_layer/boundary_layer.py @@ -46,10 +46,7 @@ output_path.mkdir(exist_ok=True) #%% logger.Logger.initialize_logger() -basics.logger.Logger.add_stdout() -basics.logger.Logger.set_debug_level(basics.logger.Level.INFO_LOW) -basics.logger.Logger.time_stamp(basics.logger.TimeStamp.ENABLE) -basics.logger.Logger.enable_printed_rank_numbers(True) + #%% grid_factory = gpu.grid_generator.GridFactory.make() grid_builder = gpu.grid_generator.MultipleGridBuilder.make_shared(grid_factory) @@ -145,7 +142,7 @@ tm_factory.read_config_file(config) #%% grid_builder.add_coarse_grid(0.0, 0.0, 0.0, *length, dx) grid_builder.set_periodic_boundary_condition(not read_precursor, True, False) -grid_builder.build_grids(basics.LbmOrGks.LBM, False) +grid_builder.build_grids(False) sampling_offset = 2 if read_precursor: diff --git a/README.md b/README.md index 9e02f019a98078c19f7c6a61a029e9f4d8f97434..fe1bb5dd262d193ba3ac201fe8a7875c1bf812f7 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ with usage of the GPU: - CUDA [developer.nvidia.com/cuda-zone](https://developer.nvidia.com/cuda-zone): * Minimum CUDA Version 9.0 * Minimum Compute Capability 3.0, because of maximal number of Blocks in x direction - * Recommended Compute Capability 6.0, because of atomics for double precision floating point data (GKS only) ### Build VirtualFluids diff --git a/apps/cpu/TPMSRow/TPMSRow.cpp b/apps/cpu/TPMSRow/TPMSRow.cpp index 6369340273cc21c666c1d049ad063a7ae0b8015e..15df6e24316a0f00407218a04df4a7b48293d637 100644 --- a/apps/cpu/TPMSRow/TPMSRow.cpp +++ b/apps/cpu/TPMSRow/TPMSRow.cpp @@ -7,7 +7,7 @@ using namespace std; using namespace vf::lbm::dir; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; void run(string configname) { diff --git a/apps/cpu/Thermoplast/CMakeLists.txt b/apps/cpu/Thermoplast/CMakeLists.txt deleted file mode 100644 index 5624b03136a7c901d1fe69fa224464104d3a08a6..0000000000000000000000000000000000000000 --- a/apps/cpu/Thermoplast/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) - -######################################################## -## C++ PROJECT ### -######################################################## -PROJECT(thermoplast) -IF(${USE_DEM_COUPLING}) - INCLUDE(${APPS_ROOT}/IncludsList.cmake) - INCLUDE(${SOURCE_ROOT}/DemCoupling/IncludsList.cmake) - - ################################################################# - ### LOCAL FILES ### - ################################################################# - FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp ) - - SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) - SOURCE_GROUP(src FILES ${SPECIFIC_FILES}) - - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} VirtualFluids) - - #message("CAB_ADDITIONAL_LINK_LIBRARIES: " ${CAB_ADDITIONAL_LINK_LIBRARIES}) - - ################################################################# - ### CREATE PROJECT ### - ################################################################# - CREATE_CAB_PROJECT(thermoplast BINARY) -ENDIF() \ No newline at end of file diff --git a/apps/cpu/Thermoplast/config.txt b/apps/cpu/Thermoplast/config.txt deleted file mode 100644 index 18e7e7ea896acdc20527de1d6af9154fbac16e6b..0000000000000000000000000000000000000000 --- a/apps/cpu/Thermoplast/config.txt +++ /dev/null @@ -1,57 +0,0 @@ -#simulation parameters - -#x1min x2min x3min x1max x2max x3max -#boundingBox = 0 0 0 300 1520 2320 - -#boundingBox = 60 1370 130 190 1530 320 #test bb - -boundingBox = 60 20 130 190 170 320 #test bb - -#boundingBox = 60 0 10 190 1530 750 #test bb 2 - -#boundingBox = 60 0 10 190 1530 2320 #production bb - -blocknx = 10 10 10 -#blocknx = 300 420 320 -availMem = 25e9 -#uLB = 0.1 -uLB = 0.03 -Re = 300 - -#PE parameters -#test pe offset -peMinOffset = 46 2 2 -peMaxOffset = -8 -25 -2 - -#production pe offset -#peMinOffset = 46 18 14 -#peMaxOffset = -8 -25 -23 - -sphereTime = 10 - -#geometry files -pathGeo = d:/Projects/ThermoPlast/SimPerfMS -michel = /Werkzeug_Michel_MS.stl -plexiglas = /plexiglas.stl - -#obstacle -obstacle = true -obstacleGeo1 = /QuaderMS.stl #/DreieckMS_2.stl # DreieckSchoen.iges.stl #/QuaderMS.stl -obstacleGeo2 = /KugelMS_2.stl -obstacleGeo3 = /DreieckMS.stl - -pathOut = g:/temp/thermoplastObst - -logToFile = false - -#restart -restart = false -restartStep = 1000 - -#timing -nupsTime = 100 100 1000000 -cpStart = 1000 -cpStep = 1000 -outTime = 1000 -endTime = 100000 - diff --git a/apps/cpu/Thermoplast/thermoplast.cpp b/apps/cpu/Thermoplast/thermoplast.cpp deleted file mode 100644 index b004543254e4788ffa6a7314536b1811c217700b..0000000000000000000000000000000000000000 --- a/apps/cpu/Thermoplast/thermoplast.cpp +++ /dev/null @@ -1,763 +0,0 @@ -#include <iostream> -#include <string> - -#include "PointerDefinitions.h" - -#include <iostream> -#include <string> -#include <memory> -#include <array> - -#include "VirtualFluids.h" -#include <muParser.h> -#include "ForceCalculator.h" - - -#include <MovableObjectInteractor.h> -#include <DemCoProcessor.h> -#include <PePartitioningGridVisitor.h> - -#include <PePhysicsEngineMaterialAdapter.h> -#include <PePhysicsEngineGeometryAdapter.h> -#include <PePhysicsEngineSolverAdapter.h> -#include "PeLoadBalancerAdapter.h" - -#include <VelocityBcReconstructor.h> -#include <EquilibriumReconstructor.h> -#include <ExtrapolationReconstructor.h> - -#include <DummyPhysicsEngineSolverAdapter.h> -#include <DummyPhysicsEngineMaterialAdapter.h> -#include <DummyPhysicsEngineGeometryAdapter.h> -#include <WriteDemObjectsCoProcessor.h> -#include <WritePeBlocksCoProcessor.h> - -#include "CreateDemObjectsCoProcessor.h" -#include "RestartDemObjectsCoProcessor.h" - -using namespace std; - -//simulation bounding box -double g_minX1 = 0; -double g_minX2 = 0; -double g_minX3 = 0; - -double g_maxX1 = 0; -double g_maxX2 = 0; -double g_maxX3 = 0; - -vector<double> peMinOffset; -vector<double> peMaxOffset; - -string pathOut;// = "d:/temp/thermoplastCluster"; -string pathGeo;// = "d:/Projects/ThermoPlast/Geometrie"; - -void addNozzle(SPtr<Grid3D> grid, SPtr<vf::mpi::Communicator> comm, SPtr<BCAdapter> noSlipBCAdapter/*, InteractorsHelper& intHelper*/) -{ - int myid = comm->getProcessID(); - if (myid==0) UBLOG(logINFO, "Add nozzles:start"); - - SPtr<UbScheduler> sch(new UbScheduler(1)); - WriteGbObjectsCoProcessor gbObjectsCoProcessor(grid, sch, pathOut, WbWriterVtkXmlBinary::getInstance(), comm); - - std::vector< SPtr<Interactor3D> > interactors; - - for (int i = 0; i <= 55; i++) - { - SPtr<GbTriFaceMesh3D> bbGeo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+"/n_bb_new/bb_new"+UbSystem::toString(i)+".stl", "bb", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); - SPtr<Interactor3D> bbInt = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(bbGeo, grid, noSlipBCAdapter, Interactor3D::SOLID, Interactor3D::EDGES)); - //GbSystem3D::writeGeoObject(bbGeo.get(), pathOut+"/ns/bbGeo"+UbSystem::toString(i), WbWriterVtkXmlBinary::getInstance()); - //intHelper.addInteractor(bbInt); - if (myid==0) gbObjectsCoProcessor.addGbObject(bbGeo); - interactors.push_back(bbInt); - } - - for (int i = 0; i <= 334; i++) - { - SPtr<GbTriFaceMesh3D> bbGeo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+"/n_bb/bb"+UbSystem::toString(i)+".stl", "bb", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); - SPtr<Interactor3D> bbInt = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(bbGeo, grid, noSlipBCAdapter, Interactor3D::SOLID, Interactor3D::EDGES)); - //GbSystem3D::writeGeoObject(bbGeo.get(), pathOut+"/ns/bbGeo"+UbSystem::toString(i), WbWriterVtkXmlBinary::getInstance()); - //intHelper.addInteractor(bbInt); - if (myid==0) gbObjectsCoProcessor.addGbObject(bbGeo); - interactors.push_back(bbInt); - } - - for (int i = 0; i <= 51; i++) - { - SPtr<GbTriFaceMesh3D> bsGeo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+"/n_bs/bs"+UbSystem::toString(i)+".stl", "bs", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); - SPtr<Interactor3D> bsInt = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(bsGeo, grid, noSlipBCAdapter, Interactor3D::SOLID, Interactor3D::EDGES)); - //intHelper.addInteractor(bsInt); - if (myid==0) gbObjectsCoProcessor.addGbObject(bsGeo); - interactors.push_back(bsInt); - } - - std::array<int, 6> n ={ 0,1,3,4,6,7 }; - - for (int i = 0; i < n.size(); i++) - { - SPtr<GbTriFaceMesh3D> biGeo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+"/n_bi/bi"+UbSystem::toString(n[i])+".stl", "bi", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); - SPtr<Interactor3D> biInt = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(biGeo, grid, noSlipBCAdapter, Interactor3D::SOLID, Interactor3D::EDGES)); - //intHelper.addInteractor(biInt); - if (myid==0) gbObjectsCoProcessor.addGbObject(biGeo); - interactors.push_back(biInt); - } - - if (myid==0) gbObjectsCoProcessor.process(0); - - - for (SPtr<Interactor3D> interactor : interactors) - { - std::vector< std::shared_ptr<Block3D> > blockVector; - UbTupleInt3 blockNX=grid->getBlockNX(); - SPtr<GbObject3D> geoObject(interactor->getGbObject3D()); - double ext = 0.0; - std::array<double, 6> AABB ={ geoObject->getX1Minimum(),geoObject->getX2Minimum(),geoObject->getX3Minimum(),geoObject->getX1Maximum(),geoObject->getX2Maximum(),geoObject->getX3Maximum() }; - grid->getBlocksByCuboid(AABB[0]-(double)val<1>(blockNX)*ext, AABB[1]-(double)val<2>(blockNX)*ext, AABB[2]-(double)val<3>(blockNX)*ext, AABB[3]+(double)val<1>(blockNX)*ext, AABB[4]+(double)val<2>(blockNX)*ext, AABB[5]+(double)val<3>(blockNX)*ext, blockVector); - for (std::shared_ptr<Block3D> block : blockVector) - { - if (block->getKernel()) - { - interactor->setBCBlock(block); - } - } - interactor->initInteractor(); - } - - if (myid==0) UBLOG(logINFO, "Add nozzles:end"); -} - -std::shared_ptr<DemCoProcessor> makePeCoProcessor(SPtr<Grid3D> grid, SPtr<vf::mpi::Communicator> comm, const SPtr<UbScheduler> peScheduler, const std::shared_ptr<LBMUnitConverter> lbmUnitConverter, int maxpeIterations) -{ - double peRelaxtion = 0.7; - //int maxpeIterations = 10000; - //Beschleunigung g - double g = 9.81 * lbmUnitConverter->getFactorAccWToLb(); - //Vector3D globalLinearAcc(0.0, -g, 0.0); - //Vector3D globalLinearAcc(0.0, 0.0, -g); - Vector3D globalLinearAcc(0.0, 0.0, 0.0); - - std::shared_ptr<PePhysicsEngineMaterialAdapter> planeMaterial = std::make_shared<PePhysicsEngineMaterialAdapter>("granular", 1.0, 0, 0.1 / 2, 0.1 / 2, 0.5, 1, 1, 0, 0); - - const int gridNX1 = val<1>(grid->getBlockNX()) * grid->getNX1(); - const int gridNX2 = val<2>(grid->getBlockNX()) * grid->getNX2(); - const int gridNX3 = val<3>(grid->getBlockNX()) * grid->getNX3(); - - //UbTupleInt3 simulationDomain(gridNx, gridNy, gridNz); - //std::array<double, 6> simulationDomain = {1, 1, 1, 30, 30, 30}; - std::array<double, 6> simulationDomain ={ g_minX1, g_minX2, g_minX3, g_minX1+gridNX1, g_minX2+gridNX2, g_minX3+gridNX3 }; - UbTupleInt3 numberOfBlocks(grid->getNX1(), grid->getNX2(), grid->getNX3()); - //UbTupleInt3 numberOfBlocks((simulationDomain[3]-simulationDomain[0])/val<1>(grid->getBlockNX()), (simulationDomain[4]-simulationDomain[1])/val<2>(grid->getBlockNX()), (simulationDomain[5]-simulationDomain[2])/val<3>(grid->getBlockNX())); - UbTupleBool3 isPeriodic(grid->isPeriodicX1(), grid->isPeriodicX2(), grid->isPeriodicX3()); - Vector3D minOffset(peMinOffset[0], peMinOffset[1], peMinOffset[2]); - Vector3D maxOffset(peMaxOffset[0], peMaxOffset[1], peMaxOffset[2]); - - SPtr<GbObject3D> boxPE(new GbCuboid3D(simulationDomain[0]+minOffset[0], simulationDomain[1]+minOffset[1], simulationDomain[2]+minOffset[2], simulationDomain[3]+maxOffset[0], simulationDomain[4]+maxOffset[1], simulationDomain[5]+maxOffset[2])); - GbSystem3D::writeGeoObject(boxPE.get(), pathOut + "/geo/boxPE", WbWriterVtkXmlBinary::getInstance()); - - std::shared_ptr<PeParameter> peParamter = std::make_shared<PeParameter>(peRelaxtion, maxpeIterations, globalLinearAcc, - planeMaterial, simulationDomain, numberOfBlocks, isPeriodic, minOffset, maxOffset); - std::shared_ptr<PeLoadBalancerAdapter> loadBalancer(new PeLoadBalancerAdapter(grid, comm->getNumberOfProcesses(), comm->getProcessID())); - std::shared_ptr<PhysicsEngineSolverAdapter> peSolver = std::make_shared<PePhysicsEngineSolverAdapter>(peParamter, loadBalancer); - //create obstacle - //test - std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(peSolver)->createObstacle(Vector3D( 90, 260, 472), Vector3D( 115, 320, 460)); - //production - //std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(peSolver)->createObstacle(Vector3D( 90, 430, 472), Vector3D( 115, 320, 460)); - //std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(peSolver)->createObstacle(Vector3D( 100, 430, 1840), Vector3D( 130, 320, 470)); - //std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(peSolver)->createObstacle(Vector3D( 100, 821, 1159), Vector3D( 125, 625, 625)); - //walberla::pe::createSphere(*globalBodyStorage, *forest, *storageId, 0, walberla::pe::Vec3( -720, 820, 1150), 900, global, communicating, infiniteMass); - //walberla::pe::createSphere(*globalBodyStorage, *forest, *storageId, 0, walberla::pe::Vec3( -720, 220, 472), 900, material, global, communicating, infiniteMass); - - SPtr<CoProcessor> peblocks(new WritePeBlocksCoProcessor(grid, SPtr<UbScheduler>(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm, std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(peSolver)->getBlockForest())); - peblocks->process(0); - peblocks.reset(); - - const std::shared_ptr<ForceCalculator> forceCalculator = std::make_shared<ForceCalculator>(comm); - - return std::make_shared<DemCoProcessor>(grid, peScheduler, comm, forceCalculator, peSolver); -} - -void createSpheres(double radius, Vector3D origin, int maxX2, int maxX3, double uLB, SPtr<CreateDemObjectsCoProcessor> createSphereCoProcessor) -{ - double d = 2.0*radius; - double dividerX2 = (double)maxX2/2.0; - double dividerX3 = (double)maxX3/2.0; - for (int x3 = 0; x3 < maxX3; x3++) - for (int x2 = 0; x2 < maxX2; x2++) - //for (int x1 = 0; x1 < 1; x1++) - { - //SPtr<GbObject3D> sphere(new GbSphere3D(origin[0]+2.0*d*(double)x1, origin[1]+(double)x2*1.0*d, origin[2]+(double)x3*1.0*d, radius)); - SPtr<GbObject3D> sphere(new GbSphere3D(origin[0]+2.0*d, origin[1]+(double)x2*1.0*d, origin[2]+(double)x3*1.0*d, radius)); - createSphereCoProcessor->addGeoObject(sphere, Vector3D(uLB, -uLB+uLB/dividerX2*(double)x2, -uLB+uLB/dividerX3*(double)x3)); - } -} - -void thermoplast(string configname) -{ - SPtr<vf::mpi::Communicator> comm = vf::mpi::MPICommunicator::getInstance(); - int myid = comm->getProcessID(); - - vf::basics::ConfigurationFile config; - config.load(configname); - - vector<int> blocknx = config.getVector<int>("blocknx"); - vector<double> boundingBox = config.getVector<double>("boundingBox"); - - int endTime = config.getValue<int>("endTime"); - double outTime = config.getValue<double>("outTime"); - double availMem = config.getValue<double>("availMem"); - double uLB = config.getValue<double>("uLB"); - double Re = config.getValue<double>("Re"); - - string michel = config.getValue<string>("michel"); - string plexiglas = config.getValue<string>("plexiglas"); - double sphereTime = config.getValue<double>("sphereTime"); - - double cpStart = config.getValue<double>("cpStart"); - double cpStep = config.getValue<double>("cpStep"); - bool restart = config.getValue<bool>("restart"); - int restartStep = config.getValue<int>("restartStep"); - - peMinOffset = config.getVector<double>("peMinOffset"); - peMaxOffset = config.getVector<double>("peMaxOffset"); - - pathOut = config.getValue<string>("pathOut"); - pathGeo = config.getValue<string>("pathGeo"); - - vector<int> nupsTime = config.getVector<int>("nupsTime"); - - bool logToFile = config.getValue<bool>("logToFile"); - if (logToFile) - { -#if defined(__unix__) - if (myid==0) - { - const char* str = pathOut.c_str(); - mkdir(str, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH); - } -#endif - - if (myid==0) - { - stringstream logFilename; - logFilename<<pathOut+"/logfile"+UbSystem::getTimeStamp()+".txt"; - UbLog::output_policy::setStream(logFilename.str()); - } - } - - bool obstacle = config.getValue<bool>("obstacle"); - string obstacleGeo1 = config.getValue<string>("obstacleGeo1"); - string obstacleGeo2 = config.getValue<string>("obstacleGeo2"); - string obstacleGeo3 = config.getValue<string>("obstacleGeo3"); - - if (myid==0) UBLOG(logINFO, "BEGIN LOGGING - " << UbSystem::getTimeStamp()); - - //parameters - //string pathOut = "d:/temp/thermoplast3"; - //string pathGeo = "d:/Projects/ThermoPlast/Geometrie"; - int numOfThreads = 1; - //int blocknx[3] ={ 10,10,10 }; - //double endTime = 1000000; - //double outTime = 300; - //double availMem = 8e9; - double deltax = 1; - double rhoLB = 0.0; - //double uLB = 0.1; - double radiusLB = 7.5; - double radiusWorld = 1.5e-3; - //double nuLB = 0.000333333; - //double Re = (uLB*2.0*radiusLB)/nuLB; - //double Re = 900; - double nuLB = (uLB*2.0*radiusLB)/Re; - - //geometry definition - - //simulation bounding box - g_minX1 = boundingBox[0]; - g_minX2 = boundingBox[1]; - g_minX3 = boundingBox[2]; - - g_maxX1 = boundingBox[3]; - g_maxX2 = boundingBox[4]; - g_maxX3 = boundingBox[5]; - - double blockLength = blocknx[0]*deltax; - - //Grid definition - SPtr<Grid3D> grid(new Grid3D(comm)); - grid->setDeltaX(deltax); - grid->setBlockNX(blocknx[0], blocknx[1], blocknx[2]); - grid->setPeriodicX1(false); - grid->setPeriodicX2(false); - grid->setPeriodicX3(false); - - //boundary conditions definition - ////////////////////////////////////////////////////////////////////////////// - SPtr<BCAdapter> noSlipBCAdapter(new NoSlipBCAdapter()); - //noSlipBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new NoSlipBCAlgorithm())); - noSlipBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new ThinWallNoSlipBCAlgorithm())); - - mu::Parser fct; - fct.SetExpr("U"); - fct.DefineConst("U", uLB); - SPtr<BCAdapter> inflowAdapter(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST)); - inflowAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityBCAlgorithm())); - //inflowAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityWithDensityBCAlgorithm())); - - SPtr<BCAdapter> outflowAdapter(new DensityBCAdapter(rhoLB)); - outflowAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new EqDensityBCAlgorithm())); - //outflowAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new NonEqDensityBCAlgorithm())); - //outflowAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new NonReflectingOutflowBCAlgorithm())); - - //sphere BC - mu::Parser fct2; - fct2.SetExpr("U"); - fct2.DefineConst("U", 0.0); - SPtr<BCAdapter> velocityBcParticleAdapter(new VelocityBCAdapter(true, false, false, fct2, 0, BCFunction::INFCONST)); - velocityBcParticleAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityWithDensityBCAlgorithm())); - - //boundary conditions visitor - SPtr<BoundaryConditionsBlockVisitor> bcVisitor(new BoundaryConditionsBlockVisitor()); - bcVisitor->addBC(noSlipBCAdapter); - bcVisitor->addBC(inflowAdapter); - bcVisitor->addBC(outflowAdapter); - bcVisitor->addBC(velocityBcParticleAdapter); - ////////////////////////////////////////////////////////////////////////////////// - - //LBM kernel definition - SPtr<LBMKernel> kernel; - kernel = SPtr<LBMKernel>(new IncompressibleCumulantLBMKernel()); - //SPtr<BCProcessor> bcProc(new BCProcessor()); - SPtr<BCProcessor> bcProc(new ThinWallBCProcessor()); - kernel->setBCProcessor(bcProc); - - //if (myid==0) UBLOG(logINFO, "Read obstacleGeo1:start"); - //SPtr<GbTriFaceMesh3D> obstacleGeo1geo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+obstacleGeo1, "michelGeo", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); - //if (myid==0) UBLOG(logINFO, "Read obstacleGeo1:end"); - //if (myid==0) GbSystem3D::writeGeoObject(obstacleGeo1geo.get(), pathOut+"/geo/obstacleGeo1", WbWriterVtkXmlBinary::getInstance()); - //g_minX1 = obstacleGeo1geo->getX1Minimum(); - //g_minX2 = obstacleGeo1geo->getX2Minimum(); - //g_minX3 = obstacleGeo1geo->getX3Minimum(); - //g_maxX1 = obstacleGeo1geo->getX1Maximum(); - //g_maxX2 = obstacleGeo1geo->getX2Maximum(); - //g_maxX3 = obstacleGeo1geo->getX3Maximum(); - - - - //blocks generating - SPtr<GbObject3D> gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); - if (myid == 0) GbSystem3D::writeGeoObject(gridCube.get(), pathOut + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); - GenBlocksGridVisitor genBlocks(gridCube); - grid->accept(genBlocks); - - - //{ - //SPtr<Interactor3D> obstacleGeo1int = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(obstacleGeo1geo, grid, noSlipBCAdapter, Interactor3D::SOLID)); - //SPtr<Grid3DVisitor> peVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); - //InteractorsHelper intHelper(grid, peVisitor, true); - //intHelper.addInteractor(obstacleGeo1int); - //intHelper.selectBlocks(); - - ////create LBM kernel - ////SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, 1); - ////grid->accept(kernelVisitor); - - ////SPtr<Interactor3D> obstacleGeo1int = SPtr<D3Q27Interactor>(new D3Q27Interactor(obstacleGeo1geo, grid, noSlipBCAdapter, Interactor3D::SOLID)); - ////UBLOG(logINFO, "Obst: start"); - ////std::vector< std::shared_ptr<Block3D> > blockVector; - ////UbTupleInt3 blockNX=grid->getBlockNX(); - ////SPtr<GbObject3D> geoObject(obstacleGeo1int->getGbObject3D()); - ////double ext = 0.0; - ////std::array<double, 6> AABB ={ geoObject->getX1Minimum(),geoObject->getX2Minimum(),geoObject->getX3Minimum(),geoObject->getX1Maximum(),geoObject->getX2Maximum(),geoObject->getX3Maximum() }; - ////grid->getBlocksByCuboid(AABB[0]-(double)val<1>(blockNX)*ext, AABB[1]-(double)val<2>(blockNX)*ext, AABB[2]-(double)val<3>(blockNX)*ext, AABB[3]+(double)val<1>(blockNX)*ext, AABB[4]+(double)val<2>(blockNX)*ext, AABB[5]+(double)val<3>(blockNX)*ext, blockVector); - ////for (std::shared_ptr<Block3D> block : blockVector) - ////{ - ////if (block->getKernel()) - ////{ - ////obstacleGeo1int->setBCBlock(block); - ////} - ////} - ////UBLOG(logINFO, "Obst: select blocks"); - ////obstacleGeo1int->initInteractor(); - ////UBLOG(logINFO, "Obst: end"); - - //SPtr<CoProcessor> ppblocks(new WriteBlocksCoProcessor(grid, SPtr<UbScheduler>(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm)); - //ppblocks->process(0); - //ppblocks.reset(); - //} - - //return; - - - ///////////////////////////////////////////////////// - ////PE domain test - //std::array<double, 6> simulationDomain ={ g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3 }; - //Vector3D minOffset(peMinOffset[0], peMinOffset[1], peMinOffset[2]); - //Vector3D maxOffset(peMaxOffset[0], peMaxOffset[1], peMaxOffset[2]); - //SPtr<GbObject3D> boxPE(new GbCuboid3D(simulationDomain[0]+minOffset[0], simulationDomain[1]+minOffset[1], simulationDomain[2]+minOffset[2], simulationDomain[3]+maxOffset[0], simulationDomain[4]+maxOffset[1], simulationDomain[5]+maxOffset[2])); - //GbSystem3D::writeGeoObject(boxPE.get(), pathOut + "/geo/boxPE", WbWriterVtkXmlBinary::getInstance()); - //return; - ////////////////////////////////////////////////////// - - - if (myid == 0) - { - UBLOG(logINFO, "Parameters:"); - UBLOG(logINFO, "* uLB = " << uLB); - UBLOG(logINFO, "* rhoLB = " << rhoLB); - UBLOG(logINFO, "* nuLB = " << nuLB); - UBLOG(logINFO, "* deltaX = " << deltax); - UBLOG(logINFO, "* radius = " << radiusLB); - UBLOG(logINFO, "* Re = " << Re); - UBLOG(logINFO, "* number of threads = "<<numOfThreads); - UBLOG(logINFO, "* number of processes = "<<comm->getNumberOfProcesses()); - UBLOG(logINFO, "* path = "<<pathOut); - UBLOG(logINFO, "Preprocess - start"); - } - - //GbCuboid3DPtr geoInjector2(new GbCuboid3D(-12, -5, 1210, 64, 105, 1320)); - //if (myid == 0) GbSystem3D::writeGeoObject(geoInjector2.get(), pathOut + "/geo/geoInjector2", WbWriterVtkXmlASCII::getInstance()); - - //GbCuboid3DPtr geoInjector5(new GbCuboid3D(-12, 1415, 205, 64, 1525, 315)); - //if (myid == 0) GbSystem3D::writeGeoObject(geoInjector5.get(), pathOut + "/geo/geoInjector5", WbWriterVtkXmlASCII::getInstance()); - - GbCuboid3DPtr geoInjector4(new GbCuboid3D(-12, -5, 205, 64, 105, 315)); - if (myid == 0) GbSystem3D::writeGeoObject(geoInjector4.get(), pathOut + "/geo/geoInjector4", WbWriterVtkXmlASCII::getInstance()); - - //GbCuboid3DPtr geoInjector7(new GbCuboid3D(28, 705, 542, 103, 815, 652)); - //if (myid == 0) GbSystem3D::writeGeoObject(geoInjector7.get(), pathOut + "/geo/geoInjector7", WbWriterVtkXmlASCII::getInstance()); - - GbCuboid3DPtr testWallGeo(new GbCuboid3D(g_minX1-blockLength, g_minX2 - blockLength, g_maxX3, g_maxX1 + blockLength, g_maxX2 + blockLength, g_maxX3 + blockLength)); - if (myid == 0) GbSystem3D::writeGeoObject(testWallGeo.get(), pathOut + "/geo/testWallGeo", WbWriterVtkXmlASCII::getInstance()); - - if (!restart) - { - //box - SPtr<GbObject3D> box(new GbCuboid3D(g_minX1-blockLength, g_minX2, g_minX3, g_maxX1+blockLength, g_maxX2, g_maxX3)); - GbSystem3D::writeGeoObject(box.get(), pathOut + "/geo/box", WbWriterVtkXmlBinary::getInstance()); - - //michel - if (myid==0) UBLOG(logINFO, "Read michelGeo:start"); - SPtr<GbTriFaceMesh3D> michelGeo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+michel, "michelGeo", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); - if (myid==0) UBLOG(logINFO, "Read michelGeo:end"); - if (myid==0) GbSystem3D::writeGeoObject(michelGeo.get(), pathOut+"/geo/michelGeo", WbWriterVtkXmlBinary::getInstance()); - - //plexiglas - if (myid==0) UBLOG(logINFO, "Read plexiglasGeo:start"); - SPtr<GbTriFaceMesh3D> plexiglasGeo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+plexiglas, "plexiglasGeo", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); - if (myid==0) UBLOG(logINFO, "Read plexiglasGeo:end"); - if (myid==0) GbSystem3D::writeGeoObject(plexiglasGeo.get(), pathOut+"/geo/plexiglasGeo", WbWriterVtkXmlBinary::getInstance()); - - //inflow - GbCuboid3DPtr geoOutflowMichel(new GbCuboid3D(g_minX1-blockLength, g_minX2 - blockLength, g_minX3 - blockLength, g_minX1, g_maxX2 + blockLength, g_maxX3 + blockLength)); - if (myid == 0) GbSystem3D::writeGeoObject(geoOutflowMichel.get(), pathOut + "/geo/geoOutflowMichel", WbWriterVtkXmlASCII::getInstance()); - - //outflow - GbCuboid3DPtr geoOutflowPlexiglas(new GbCuboid3D(g_maxX1, g_minX2 - blockLength, g_minX3 - blockLength, g_maxX1 + blockLength, g_maxX2 + blockLength, g_maxX3 + blockLength)); - if (myid == 0) GbSystem3D::writeGeoObject(geoOutflowPlexiglas.get(), pathOut + "/geo/geoOutflowPlexiglas", WbWriterVtkXmlASCII::getInstance()); - - //set boundary conditions for blocks and create process decomposition for MPI - SPtr<D3Q27Interactor> boxInt(new D3Q27Interactor(box, grid, noSlipBCAdapter, Interactor3D::INVERSESOLID)); - - //inflow - //SPtr<D3Q27Interactor> inflowInjector2Int = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoInjector2, grid, inflowAdapter, Interactor3D::SOLID)); - //SPtr<D3Q27Interactor> inflowInjector5Int = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoInjector5, grid, inflowAdapter, Interactor3D::SOLID)); - SPtr<D3Q27Interactor> inflowInjector4Int = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoInjector4, grid, inflowAdapter, Interactor3D::SOLID)); - //SPtr<D3Q27Interactor> inflowInjector7Int = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoInjector7, grid, inflowAdapter, Interactor3D::SOLID)); - - SPtr<D3Q27Interactor> outflowMichelInt = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoOutflowMichel, grid, outflowAdapter, Interactor3D::SOLID)); - - //outflow - SPtr<D3Q27Interactor> outflowPlexiglasInt = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoOutflowPlexiglas, grid, outflowAdapter, Interactor3D::SOLID)); - - //michel - SPtr<Interactor3D> michelInt = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(michelGeo, grid, noSlipBCAdapter, Interactor3D::SOLID)); - - //plexiglas - SPtr<Interactor3D> plexiglasInt = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(plexiglasGeo, grid, noSlipBCAdapter, Interactor3D::SOLID)); - - SPtr<D3Q27Interactor> testWallInt = SPtr<D3Q27Interactor>(new D3Q27Interactor(testWallGeo, grid, inflowAdapter, Interactor3D::SOLID)); - - SPtr<Interactor3D> obstacleGeo1int, obstacleGeo2int, obstacleGeo3int; - if (obstacle) - { - //obstacleGeo1 - if (myid==0) UBLOG(logINFO, "Read obstacleGeo1:start"); - SPtr<GbTriFaceMesh3D> obstacleGeo1geo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+obstacleGeo1, "michelGeo", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); - if (myid==0) UBLOG(logINFO, "Read obstacleGeo1:end"); - if (myid==0) GbSystem3D::writeGeoObject(obstacleGeo1geo.get(), pathOut+"/geo/obstacleGeo1", WbWriterVtkXmlBinary::getInstance()); - obstacleGeo1int = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(obstacleGeo1geo, grid, noSlipBCAdapter, Interactor3D::SOLID)); - //obstacleGeo2 - if (myid==0) UBLOG(logINFO, "Read obstacleGeo2:start"); - SPtr<GbTriFaceMesh3D> obstacleGeo2geo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+obstacleGeo2, "michelGeo", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); - if (myid==0) UBLOG(logINFO, "Read obstacleGeo2:end"); - if (myid==0) GbSystem3D::writeGeoObject(obstacleGeo2geo.get(), pathOut+"/geo/obstacleGeo2", WbWriterVtkXmlBinary::getInstance()); - obstacleGeo2int = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(obstacleGeo2geo, grid, noSlipBCAdapter, Interactor3D::SOLID)); - //obstacleGeo3 - if (myid==0) UBLOG(logINFO, "Read obstacleGeo3:start"); - SPtr<GbTriFaceMesh3D> obstacleGeo3geo = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+obstacleGeo3, "michelGeo", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); - if (myid==0) UBLOG(logINFO, "Read obstacleGeo3:end"); - if (myid==0) GbSystem3D::writeGeoObject(obstacleGeo3geo.get(), pathOut+"/geo/obstacleGeo3", WbWriterVtkXmlBinary::getInstance()); - obstacleGeo3int = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(obstacleGeo3geo, grid, noSlipBCAdapter, Interactor3D::SOLID)); - } - - ////////////////////////////////////////////////////////////////////////// - //SPtr<Grid3DVisitor> peVisitor(new PePartitioningGridVisitor(comm, demCoProcessor)); - SPtr<Grid3DVisitor> peVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); - InteractorsHelper intHelper(grid, peVisitor, true); - - //intHelper.addInteractor(obstacleGeo1int); - - intHelper.addInteractor(boxInt); - intHelper.addInteractor(michelInt); - intHelper.addInteractor(plexiglasInt); - //intHelper.addInteractor(inflowInjector2Int); - //intHelper.addInteractor(inflowInjector5Int); - intHelper.addInteractor(inflowInjector4Int); - //intHelper.addInteractor(inflowInjector7Int); - intHelper.addInteractor(outflowPlexiglasInt); - intHelper.addInteractor(outflowMichelInt); - intHelper.addInteractor(obstacleGeo1int); - intHelper.addInteractor(obstacleGeo2int); - intHelper.addInteractor(obstacleGeo3int); - //intHelper.addInteractor(testWallInt); - intHelper.selectBlocks(); - - //write data for visualization of block grid - SPtr<CoProcessor> ppblocks(new WriteBlocksCoProcessor(grid, SPtr<UbScheduler>(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm)); - ppblocks->process(0); - ppblocks.reset(); - - unsigned long long numberOfBlocks = (unsigned long long)grid->getNumberOfBlocks(); - int ghostLayer = 3; - unsigned long long numberOfNodesPerBlock = (unsigned long long)(blocknx[0])* (unsigned long long)(blocknx[1])* (unsigned long long)(blocknx[2]); - unsigned long long numberOfNodes = numberOfBlocks * numberOfNodesPerBlock; - unsigned long long numberOfNodesPerBlockWithGhostLayer = numberOfBlocks * (blocknx[0] + ghostLayer) * (blocknx[1] + ghostLayer) * (blocknx[2] + ghostLayer); - double needMemAll = double(numberOfNodesPerBlockWithGhostLayer*(27 * sizeof(double) + sizeof(int) + sizeof(float) * 4)); - double needMem = needMemAll / double(comm->getNumberOfProcesses()); - - if (myid == 0) - { - UBLOG(logINFO, "Number of blocks = " << numberOfBlocks); - UBLOG(logINFO, "Number of nodes = " << numberOfNodes); - int minInitLevel = grid->getCoarsestInitializedLevel(); - int maxInitLevel = grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - int nobl = grid->getNumberOfBlocks(level); - UBLOG(logINFO, "Number of blocks for level " << level << " = " << nobl); - UBLOG(logINFO, "Number of nodes for level " << level << " = " << nobl*numberOfNodesPerBlock); - } - UBLOG(logINFO, "Necessary memory = " << needMemAll << " bytes"); - UBLOG(logINFO, "Necessary memory per process = " << needMem << " bytes"); - UBLOG(logINFO, "Available memory per process = " << availMem << " bytes"); - } - - //create LBM kernel - SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, needMem); - grid->accept(kernelVisitor); - - addNozzle(grid, comm, noSlipBCAdapter/*,intHelper*/); - - intHelper.setBC(); - - - //////////////////////////////////////////////////////////////////////////////////////////////////// - //{ - ////UBLOG(logINFO, "Obst: start, rank="<<myid); - //std::vector< std::shared_ptr<Block3D> > blockVector; - //UbTupleInt3 blockNX=grid->getBlockNX(); - //SPtr<GbObject3D> geoObject(obstacleGeo3int->getGbObject3D()); - //double ext = 0.0; - //std::array<double, 6> AABB ={ geoObject->getX1Minimum(),geoObject->getX2Minimum(),geoObject->getX3Minimum(),geoObject->getX1Maximum(),geoObject->getX2Maximum(),geoObject->getX3Maximum() }; - //grid->getBlocksByCuboid(AABB[0]-(double)val<1>(blockNX)*ext, AABB[1]-(double)val<2>(blockNX)*ext, AABB[2]-(double)val<3>(blockNX)*ext, AABB[3]+(double)val<1>(blockNX)*ext, AABB[4]+(double)val<2>(blockNX)*ext, AABB[5]+(double)val<3>(blockNX)*ext, blockVector); - //for (std::shared_ptr<Block3D> block : blockVector) - //{ - //if (block->getKernel()) - //{ - //obstacleGeo3int->setBCBlock(block); - //} - //} - //UBLOG(logINFO, "Obst: select blocks, number of blocks="<<blockVector.size()<<", rank="<<myid); - //obstacleGeo3int->initInteractor(); - //UBLOG(logINFO, "Obst: end, rank="<<myid); - //} - ////////////////////////////////////////////////////////////////////////////////////////////////////// - //initialization of distributions - InitDistributionsBlockVisitor initVisitor; - //initVisitor.setVx1(uLB); - grid->accept(initVisitor); - - //write data for visualization of boundary conditions - { - //SPtr<UbScheduler> geoSch(new UbScheduler(1)); - //WriteBoundaryConditionsCoProcessor ppgeo(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), comm); - //ppgeo.process(0); - - //WriteMacroscopicQuantitiesCoProcessor ppInit(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), SPtr<LBMUnitConverter>(new LBMUnitConverter()), comm); - //ppInit.process(0); - } - - if (myid == 0) UBLOG(logINFO, "Preprocess - end"); - } - //restart - //UBLOG(logINFO, "restart definition - start, rank="<<myid); - SPtr<UbScheduler> restartSch(new UbScheduler(cpStep, cpStart)); - //SPtr<MPIIORestartCoProcessor> restartCoProcessor(new MPIIORestartCoProcessor(grid, restartSch, pathOut, comm)); - SPtr<MPIIOMigrationCoProcessor> restartCoProcessor(new MPIIOMigrationCoProcessor(grid, restartSch, pathOut, comm)); - restartCoProcessor->setLBMKernel(kernel); - restartCoProcessor->setBCProcessor(bcProc); - - if (restart) - { - //restartStep = restartCoProcessor->readCpTimeStep(); - restartCoProcessor->restart(restartStep); - } - - //PE initialization - double refLengthLb = radiusLB*2.0; - double refLengthWorld = radiusWorld*2.0; - const std::shared_ptr<LBMUnitConverter> lbmUnitConverter = std::make_shared<LBMUnitConverter>(refLengthWorld, LBMUnitConverter::WORLD_MATERIAL::AIR_20C, refLengthLb); - if (myid == 0) std::cout << lbmUnitConverter->toString() << std::endl; - double rhoSphere = 915 * lbmUnitConverter->getFactorDensityWToLb(); // kg/m^3 - if (myid == 0) UBLOG(logINFO, "rhoSphere = "<<rhoSphere); - SPtr<PhysicsEngineMaterialAdapter> sphereMaterial(new PePhysicsEngineMaterialAdapter("Polypropylen", rhoSphere, 0, 0.15, 0.1, 0.45, 0.5, 1, 0, 0)); - const int timestep = 2; - const SPtr<UbScheduler> peScheduler(new UbScheduler(timestep)); - int maxpeIterations = 10;//endTime/2; - SPtr<DemCoProcessor> demCoProcessor = makePeCoProcessor(grid, comm, peScheduler, lbmUnitConverter, maxpeIterations); - demCoProcessor->setBlockVisitor(bcVisitor); - - //////////////////////////////////////////////////////////////////////////// - ////generating spheres - //UBLOG(logINFO, "generating spheres - start, rank="<<myid); - SPtr<UbScheduler> sphereScheduler(new UbScheduler(sphereTime/*10,10,10*/)); - double toleranz = 0.0;//0.05; - SPtr<CreateDemObjectsCoProcessor> createSphereCoProcessor(new CreateDemObjectsCoProcessor(grid, sphereScheduler, comm, demCoProcessor, sphereMaterial, toleranz)); - //UBLOG(logINFO, "generating spheres - stop, rank="<<myid); - - ////restart - ////UBLOG(logINFO, "restart definition - start, rank="<<myid); - //SPtr<UbScheduler> restartSch(new UbScheduler(cpStep, cpStart)); - ////SPtr<MPIIORestartCoProcessor> restartCoProcessor(new MPIIORestartCoProcessor(grid, restartSch, pathOut, comm)); - //SPtr<MPIIOMigrationCoProcessor> restartCoProcessor(new MPIIOMigrationCoProcessor(grid, restartSch, pathOut, comm)); - //restartCoProcessor->setLBMKernel(kernel); - //restartCoProcessor->setBCProcessor(bcProc); - SPtr<RestartDemObjectsCoProcessor> restartDemObjectsCoProcessor(new RestartDemObjectsCoProcessor(grid, restartSch, pathOut, demCoProcessor, createSphereCoProcessor, radiusLB, comm)); - //UBLOG(logINFO, "restart definition - stop, rank="<<myid); - - if (restart) - { - createSphereCoProcessor->setToleranz(0.05); - restartDemObjectsCoProcessor->restart(restartStep); - createSphereCoProcessor->setToleranz(toleranz); - } - - //set connectors - //UBLOG(logINFO, "set connectors - start, rank="<<myid); - InterpolationProcessorPtr iProcessor(new IncompressibleOffsetInterpolationProcessor()); - SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); - grid->accept(setConnsVisitor); - //UBLOG(logINFO, "set connectors - stop, rank="<<myid); - - //BC visitor - //UBLOG(logINFO, "BC visitor - start, rank="<<myid); - grid->accept(*bcVisitor.get()); - //UBLOG(logINFO, "BC visitor - stop, rank="<<myid); - - //sphere prototypes - //UBLOG(logINFO, "sphere prototypes - start, rank="<<myid); - double d = 2.0*radiusLB; - int maxX2 = 5; - int maxX3 = 5; - //Vector3D origin1(g_minX1+peMinOffset[0]-1.5*d, geoInjector5->getX2Minimum()+1.4*d-6.0, geoInjector5->getX3Minimum()+1.5*d); - //createSpheres(radiusLB, origin1, maxX2, maxX3, uLB, createSphereCoProcessor); - //Vector3D origin2(g_minX1+peMinOffset[0]-1.5*d, geoInjector2->getX2Minimum()+2.2*d, geoInjector2->getX3Minimum()+1.5*d); - //createSpheres(radiusLB, origin2, maxX2, maxX3, uLB, createSphereCoProcessor); - - Vector3D origin2(g_minX1+peMinOffset[0]-1.5*d, geoInjector4->getX2Minimum()+2.4*d, geoInjector4->getX3Minimum()+1.5*d); - createSpheres(radiusLB,origin2,maxX2,maxX3,uLB,createSphereCoProcessor); - - //maxX2 = 7; - //maxX3 = 7; - //Vector3D origin3(g_minX1+peMinOffset[0]-1.5*d, geoInjector7->getX2Minimum()+0.5*d, geoInjector7->getX3Minimum()+0.5*d); - //createSpheres(radiusLB,origin3,maxX2,maxX3,uLB,createSphereCoProcessor); - - - createSphereCoProcessor->process(0); - - //write data for visualization of macroscopic quantities - SPtr<UbScheduler> visSch(new UbScheduler(outTime)); - SPtr<WriteMacroscopicQuantitiesCoProcessor> writeMQCoProcessor(new WriteMacroscopicQuantitiesCoProcessor(grid, visSch, pathOut, - WbWriterVtkXmlBinary::getInstance(), SPtr<LBMUnitConverter>(new LBMUnitConverter()), comm)); - - SPtr<WriteBoundaryConditionsCoProcessor> writeBCCoProcessor(new WriteBoundaryConditionsCoProcessor(grid, visSch, pathOut, - WbWriterVtkXmlBinary::getInstance(), comm)); - - SPtr<WriteDemObjectsCoProcessor> writeDemObjectsCoProcessor(new WriteDemObjectsCoProcessor(grid, visSch, pathOut, WbWriterVtkXmlBinary::getInstance(), demCoProcessor, comm)); - - if (!restart) - { - writeMQCoProcessor->process(0); - writeBCCoProcessor->process(0); - writeDemObjectsCoProcessor->process(0); - } - ////performance control - SPtr<UbScheduler> nupsSch(new UbScheduler(nupsTime[0], nupsTime[1], nupsTime[2])); - SPtr<NUPSCounterCoProcessor> npr(new NUPSCounterCoProcessor(grid, nupsSch, numOfThreads, comm)); - - //start simulation - //omp_set_num_threads(numOfThreads); - SPtr<UbScheduler> stepGhostLayer(peScheduler); - SPtr<Calculator> calculator(new BasicCalculator(grid, stepGhostLayer, endTime)); - - calculator->addCoProcessor(npr); - calculator->addCoProcessor(createSphereCoProcessor); - calculator->addCoProcessor(demCoProcessor); - ////calculator->addCoProcessor(writeBCCoProcessor); - calculator->addCoProcessor(writeDemObjectsCoProcessor); - calculator->addCoProcessor(writeMQCoProcessor); - calculator->addCoProcessor(restartDemObjectsCoProcessor); - calculator->addCoProcessor(restartCoProcessor); - - if (myid == 0) UBLOG(logINFO, "Simulation-start"); - calculator->calculate(); - if (myid == 0) UBLOG(logINFO, "Simulation-end"); - if (myid==0) UBLOG(logINFO, "END LOGGING - " << UbSystem::getTimeStamp()); -} - -////////////////////////////////////////////////////////////////////////// -int main(int argc, char* argv[]) -{ - try - { - //Sleep(30000); - walberla::Environment env(argc, argv); - - if (argv!=NULL) - { - //if (argv[1]!=NULL) - //{ - //thermoplast(string("thermoplast.cfg")); - thermoplast(string("d:/Projects/VirtualFluidsGit/source/Applications/Thermoplast/config.txt")); - //} - //else - //{ - //cout<<"Configuration file must be set!: "<<argv[0]<<" <config file>"<<endl<<std::flush; - //} - } - return 0; - } - catch (std::exception& e) - { - UBLOG(logERROR, e.what()); - } - catch (std::string& s) - { - UBLOG(logERROR, s); - } - catch (...) - { - UBLOG(logERROR, "unknown exception"); - } -} diff --git a/apps/gpu/GKS/BoundaryJet/3rdPartyLinking.cmake b/apps/gpu/GKS/BoundaryJet/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/BoundaryJet/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/BoundaryJet/BoundaryJet.cpp b/apps/gpu/GKS/BoundaryJet/BoundaryJet.cpp deleted file mode 100644 index 76cda7ba2a91d72a4e008938d18ae00d41eff159..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/BoundaryJet/BoundaryJet.cpp +++ /dev/null @@ -1,369 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" -#include "GksGpu/BoundaryConditions/Inflow.h" -#include "GksGpu/BoundaryConditions/Extrapolation.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/Periodic.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void thermalCavity( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 128; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - //real H = 0.25; - real H = L / real(nx); - - real dx = L / real(nx); - - - real Ra = 2.0e9; - - real Ba = 0.1; - real eps = 1.2; - real Pr = 0.71; - real K = 2.0; - - real g = 1.0; - real rho = 1.0; - - real lambda = Ba / ( 2.0 * g * L ); - real lambdaHot = lambda / ( 1.0 + eps * 0.5 ); - real lambdaCold = lambda / ( 1.0 - eps * 0.5 ); - - real mu = sqrt( Pr * eps * g * L * L * L / Ra ) * rho ; - - real cs = sqrt( ( ( K + 4.0 ) / ( K + 2.0 ) ) / ( 2.0 * lambda ) ); - real U = sqrt( Ra ) * mu / ( rho * L ); - - real CFL = 0.25; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " s\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = 0.125 * g; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - //parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - parameters.viscosityModel = ViscosityModel::constant; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //gridBuilder->addCoarseGrid(-0.5*L, -0.5*L, -0.5*H, - // 0.5*L, 0.5*L, 0.5*H, dx); - - gridBuilder->addCoarseGrid(- L, 0.0 , -0.5*H, - 4.0*L, 1.0*L, 0.5*H, dx); - - real L_1 = ( 0.5 - 0.35 ) / 2.0; - real L_2 = ( 0.5 - 0.45 ) / 2.0; - real L_3 = ( 0.5 - 0.475) / 2.0; - real L_4 = ( 0.5 - 0.485) / 2.0; - - Cuboid* cubeMY_1 = new Cuboid (-2.0, -2.0, -2.0, - 1.9, L_1, 2.0 ); - - Cuboid* cubeMY_2 = new Cuboid (-2.0, -2.0, -2.0, - 1.8, L_2, 2.0 ); - - Cuboid* cubeMY_3 = new Cuboid (-2.0, -2.0, -2.0, - 5.0, L_3, 2.0 ); - - Cuboid* cubeMY_4 = new Cuboid (-2.0, -2.0, -2.0, - 2.0, L_4, 2.0 ); - - Conglomerate refRegion_1; - refRegion_1.add(cubeMY_1); - - Conglomerate refRegion_2; - refRegion_2.add(cubeMY_2); - - Conglomerate refRegion_3; - refRegion_3.add(cubeMY_3); - - Conglomerate refRegion_4; - refRegion_4.add(cubeMY_4); - - gridBuilder->setNumberOfLayers(6,6); - - gridBuilder->addGrid( &refRegion_1, 1); - gridBuilder->addGrid( &refRegion_2, 2); - //gridBuilder->addGrid( &refRegion_3, 3); - //gridBuilder->addGrid( &refRegion_4, 4); - - gridBuilder->setPeriodicBoundaryCondition(false, false, true); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); // heated - //CudaUtility::setCudaDevice(1); // cooled - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real inletHeight = 0.02; - - SPtr<BoundaryCondition> bcMX_1 = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, false ); - SPtr<BoundaryCondition> bcMX_2 = std::make_shared<Inflow>( dataBase, Vec3(0.2, 0.0, 0.0), lambda, rho, 0.0, 0.0, inletHeight, -1.0 ); - //SPtr<BoundaryCondition> bcMX_3 = std::make_shared<Pressure>( dataBase, 0.5 * rho / lambda ); - - SPtr<BoundaryCondition> bcPX = std::make_shared<Pressure>( dataBase, 0.5 * rho / lambda ); - - bcMX_1->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -L && center.y > inletHeight; } ); - bcMX_2->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -L && center.y < inletHeight; } ); - //bcMX_2->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 4.0*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaHot , false ); - //SPtr<BoundaryCondition> bcMY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - //SPtr<BoundaryCondition> bcMY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, 0.0, false ); - - SPtr<BoundaryCondition> bcPY = std::make_shared<Extrapolation>( dataBase ); - //SPtr<BoundaryCondition> bcPY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, 0.0, false ); - - bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < 0.0 ; } ); - bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > L ; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Periodic>( dataBase ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*H; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*H; } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMX_1 ); - dataBase->boundaryConditions.push_back( bcMX_2 ); - //dataBase->boundaryConditions.push_back( bcMX_3 ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables{ - - real y = cellCenter.y; - - real factor = ( 0.0 - + inletHeight*y - - 1.0 *y*y ) * ( four / inletHeight / inletHeight ); - - real U_local; - if( y < inletHeight ) - U_local = 0.2 * factor; - else - U_local = 0.0; - - return toConservedVariables( PrimitiveVariables( rho, U_local, 0.0, 0.0, lambda ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - { - for (SPtr<BoundaryCondition> bc : dataBase->boundaryConditions) { - bc->runBoundaryConditionKernel(dataBase, parameters, level); - } - } - - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase ); - - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 50000 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= 1000000; iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, parameters, nullptr, 0); - - if( - //( iter < 10 && iter % 1 == 0 ) || - //( iter < 100 && iter % 10 == 0 ) || - //( iter < 1000 && iter % 100 == 0 ) || - ( iter < 100000 && iter % 1000 == 0 ) || - ( iter < 10000000 && iter % 10000 == 0 ) - ) - { - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - { - for (SPtr<BoundaryCondition> bc : dataBase->boundaryConditions) { - bc->runBoundaryConditionKernel(dataBase, parameters, level); - } - } - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - cupsAnalyzer.run( iter ); - - convergenceAnalyzer.run( iter ); - - //turbulenceAnalyzer->run( iter, parameters ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - //turbulenceAnalyzer->download(); - - //writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); -} - -int main( int argc, char* argv[]) -{ - std::string path( "F:/Work/Computations/out/BoundaryJet/Heated/" ); - //std::string path( "F:/Work/Computations/out/BoundaryJet/Cooled/" ); - //std::string path( "out/" ); - std::string simulationName ( "BoundaryJet" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - thermalCavity( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/GKS/BoundaryJet/CMakeLists.txt b/apps/gpu/GKS/BoundaryJet/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/BoundaryJet/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/BoundaryJet/CMakePackage.cmake b/apps/gpu/GKS/BoundaryJet/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/BoundaryJet/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/Candle/3rdPartyLinking.cmake b/apps/gpu/GKS/Candle/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/Candle/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/Candle/CMakeLists.txt b/apps/gpu/GKS/Candle/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/Candle/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/Candle/CMakePackage.cmake b/apps/gpu/GKS/Candle/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/Candle/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/Candle/Candle.cpp b/apps/gpu/GKS/Candle/Candle.cpp deleted file mode 100644 index 2f6ed9f30a23783a6d8bcc87722b8ffde46de802..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/Candle/Candle.cpp +++ /dev/null @@ -1,451 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" -#include "GridGenerator/geometries/TriangularMesh/TriangularMesh.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure2.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" -#include "GksGpu/BoundaryConditions/PassiveScalarDiriclet.h" -#include "GksGpu/BoundaryConditions/InflowComplete.h" -#include "GksGpu/BoundaryConditions/Open.h" -#include "GksGpu/BoundaryConditions/Extrapolation.h" -#include "GksGpu/BoundaryConditions/Symmetry.h" -#include "GksGpu/BoundaryConditions/CreepingMassFlux.h" -#include "GksGpu/BoundaryConditions/MassCompensation.h" - -#include "GksGpu/Interface/Interface.h" -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/Restart/Restart.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void thermalCavity( std::string path, std::string simulationName, uint restartIter ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 256; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 4.0; - real H = 8.0; - real W = 0.125; - - real dx = H / real(nx); - - real U = 0.05;0.025; - - real eps = 2.0; - real Pr = 0.71; - real K = 5.0; - - real g = 9.81; - real rho = 1.2; - - real mu = 5.0e-4; - - PrimitiveVariables prim( rho, 0.0, 0.0, 0.0, -1.0 ); - - setLambdaFromT( prim, 3.0 / T_FAKTOR ); - - real cs = sqrt( ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( 2.0 * prim.lambda ) ); - - real CFL = 0.5;0.125; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "cs = " << cs << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " kg/sm\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.D = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = -g; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = prim.lambda; - - parameters.rhoRef = rho; - - //parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - parameters.viscosityModel = ViscosityModel::constant; - - *logging::out << logging::Logger::INFO_HIGH << "Pr = " << parameters.Pr << "\n"; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - bool threeDimensional = true; - - if( threeDimensional ) - { - gridBuilder->addCoarseGrid(-0.5*L, -0.5*L, 0.0, - 0.5*L, 0.5*L, H, dx); - } - else - { - gridBuilder->addCoarseGrid(-0.5*L, -0.5*dx, 0.0, - 0.5*L, 0.5*dx, H, dx); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - //TriangularMesh* stl = TriangularMesh::make("F:/Work/Computations/inp/Unterzug.stl"); - TriangularMesh* stl = TriangularMesh::make("F:/Work/Computations/inp/Candle.stl"); -#else - //TriangularMesh* stl = TriangularMesh::make("inp/Unterzug.stl"); - TriangularMesh* stl = TriangularMesh::make("inp/Candle.stl"); -#endif - - gridBuilder->addGeometry(stl); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - VerticalCylinder cylinder( 0.0, 0.0, 0.0, 0.6, 8.0 ); - - gridBuilder->setNumberOfLayers(20,20); - - gridBuilder->addGrid(&cylinder, 1); - gridBuilder->addGrid(stl, 2); - - if( threeDimensional ) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - else gridBuilder->setPeriodicBoundaryCondition(false, true, false); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - if( !threeDimensional ) - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real openBoundaryVelocityLimiter = 0.5; - - SPtr<BoundaryCondition> bcMX = std::make_shared<Open>( dataBase, prim, openBoundaryVelocityLimiter ); - SPtr<BoundaryCondition> bcPX = std::make_shared<Open>( dataBase, prim, openBoundaryVelocityLimiter ); - //SPtr<BoundaryCondition> bcMX = std::make_shared<MassCompensation>( dataBase, rho, U, prim.lambda ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<MassCompensation>( dataBase, rho, U, prim.lambda ); - //SPtr<BoundaryCondition> bcMX = std::make_shared<IsothermalWall>( dataBase, Vec3(0, 0, 0), prim.lambda, false ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<IsothermalWall>( dataBase, Vec3(0, 0, 0), prim.lambda, false ); - //SPtr<BoundaryCondition> bcMX = std::make_shared<Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - - bcMX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L; } ); - - //SPtr<BoundaryCondition> bcMX_2 = std::make_shared<IsothermalWall>( dataBase, Vec3(0, 0, 0), prim.lambda, false ); - //SPtr<BoundaryCondition> bcPX_2 = std::make_shared<IsothermalWall>( dataBase, Vec3(0, 0, 0), prim.lambda, false ); - //SPtr<BoundaryCondition> bcMX_2 = std::make_shared<Symmetry>( dataBase, 'x' ); - //SPtr<BoundaryCondition> bcPX_2 = std::make_shared<Symmetry>( dataBase, 'x' ); - //SPtr<BoundaryCondition> bcMX_2 = std::make_shared<Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - //SPtr<BoundaryCondition> bcPX_2 = std::make_shared<Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - - //bcMX_2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L && center.z > 1.0; } ); - //bcPX_2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L && center.z > 1.0; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY; - SPtr<BoundaryCondition> bcPY; - - if( threeDimensional ) - { - //bcMY = std::make_shared<Open>( dataBase, prim, openBoundaryVelocityLimiter ); - //bcPY = std::make_shared<Open>( dataBase, prim, openBoundaryVelocityLimiter ); - bcMY = std::make_shared<Symmetry>( dataBase, 'y' ); - bcPY = std::make_shared<Symmetry>( dataBase, 'y' ); - - bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.5*L; } ); - bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*L; } ); - } - else - { - bcMY = std::make_shared<Periodic>(dataBase); - bcPY = std::make_shared<Periodic>(dataBase); - - bcMY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y < -0.5*dx; }); - bcPY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y > 0.5*dx; }); - } - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0, 0, 0), true ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0, 0, 0), prim.lambda, true ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<InflowComplete>( dataBase, PrimitiveVariables(rho, 0.0, 0.0, 0.0, prim.lambda, 0.0, 0.0) ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<Open>( dataBase ); - - //SPtr<BoundaryCondition> bcPZ = std::make_shared<Open>( dataBase, prim ); - //SPtr<BoundaryCondition> bcPZ = std::make_shared<Extrapolation>( dataBase ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < 0.0 || ( std::sqrt(center.x*center.x + center.y*center.y) < 0.5 && center.z < 1.0 ); } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > H ; } ); - - ////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> burner = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), 0.5*prim.lambda, 0.0, true ); - - //SPtr<BoundaryCondition> burner = std::make_shared<InflowComplete>( dataBase, PrimitiveVariables(rho, 0.0, 0.0, U, prim.lambda, 1.0, 1.0) ); - SPtr<BoundaryCondition> burner = std::make_shared<CreepingMassFlux>( dataBase, rho, U, prim.lambda ); - - burner->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - - return center.z > 0.8 && center.z < 1.5 && std::sqrt(center.x*center.x + center.y*center.y) < 0.1; - } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - //dataBase->boundaryConditions.push_back( bcMX_2 ); - //dataBase->boundaryConditions.push_back( bcPX_2 ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( burner ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint startIter = 0; - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - if( restartIter == INVALID_INDEX ) - { - Initializer::interpret(dataBase, [&](Vec3 cellCenter) -> ConservedVariables { - - PrimitiveVariables primLocal = prim; - - //primLocal.rho = rho * std::exp( - ( 2.0 * g * H * prim.lambda ) * cellCenter.z / H ); - - real r = sqrt(cellCenter.x * cellCenter.x + cellCenter.y * cellCenter.y /*+ cellCenter.z * cellCenter.z*/); - - //if( r < 0.6 ) primLocal.S_1 = 1.0; - - //if( r < 0.5 ) prim.lambda /= (two - four*r*r); - - return toConservedVariables(primLocal, parameters.K); - }); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - } - else - { - Restart::readRestart( dataBase, path + simulationName + "_" + std::to_string( restartIter ), startIter ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( restartIter ) + "_restart" ); - } - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, level ); - - Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase, 1000 ); - - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 50000 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = startIter + 1; iter <= 100000000; iter++ ) - { - uint runUpTime = 10000; - - if( iter < runUpTime ) - { - //std::dynamic_pointer_cast<InflowComplete>(burner)->prim.S_1 = 1.0 * ( real(iter) / 20000.0 ); - //std::dynamic_pointer_cast<InflowComplete>(burner)->prim.S_2 = 1.0 - 1.0 * ( real(iter) / 20000.0 ); - - //std::dynamic_pointer_cast<InflowComplete>(burner)->prim.W = U * ( real(iter) / 20000.0 ); - - //std::dynamic_pointer_cast<CreepingMassFlux>(burner)->velocity = U * ( real(iter) / runUpTime ); - - //parameters.mu = mu + 10.0 * mu * ( 1.0 - ( real(iter) / 20000.0 ) ); - - //parameters.dt = 0.2 * dt + ( dt - 0.2 * dt ) * ( real(iter) / 40000.0 ); - } - - cupsAnalyzer.run( iter ); - - convergenceAnalyzer.run( iter ); - - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( - //( iter >= 7000 && iter % 10 == 0 ) || - ( iter % 10000 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - if( iter % 10000 == 0 ) - { - Restart::writeRestart( dataBase, path + simulationName + "_" + std::to_string( iter ), iter ); - } - - //turbulenceAnalyzer->run( iter, parameters ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - //turbulenceAnalyzer->download(); - - //writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); -} - -int main( int argc, char* argv[]) -{ - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/Candle/" ); -#else - std::string path( "out/" ); -#endif - - std::string simulationName ( "Candle" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - uint restartIter = INVALID_INDEX; - //uint restartIter = 200000; - - if( argc > 1 ) restartIter = atoi( argv[1] ); - - thermalCavity( path, simulationName, restartIter ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/GKS/ChannelFlow/3rdPartyLinking.cmake b/apps/gpu/GKS/ChannelFlow/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ChannelFlow/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/ChannelFlow/CMakeLists.txt b/apps/gpu/GKS/ChannelFlow/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ChannelFlow/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/ChannelFlow/CMakePackage.cmake b/apps/gpu/GKS/ChannelFlow/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ChannelFlow/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/ChannelFlow/ChannelFlow.cpp b/apps/gpu/GKS/ChannelFlow/ChannelFlow.cpp deleted file mode 100644 index a1142e0dd5b66228e9d38bc566ebbbc279477345..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ChannelFlow/ChannelFlow.cpp +++ /dev/null @@ -1,282 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void channelFlow( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 8+1; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - real H = 1.0; - - real dx = H / real(nx); - - real Re = 1.0e1; - real U = 0.1; - real Ma = 0.1; - - real Pr = 0.1; - real K = 2.0; - - real rho = 1.0; - - real mu = U * rho * H / Re; - - real cs = U / Ma; - real lambda = c1o2 * ( ( K + 4.0 ) / ( K + 2.0 ) ) / ( cs * cs ); - - real g = eight * mu * U / ( H * H ); - - real p0 = c1o2 * rho / lambda; - - real CFL = 0.25; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = g; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - parameters.viscosityModel = ViscosityModel::constant; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->addCoarseGrid(-0.5*L, -0.5*H, -0.5*dx, - 0.5*L, 0.5*H, 0.5*dx, dx); - - //Cuboid cube(-1.0, -1.0, 0.45, 1.0, 1.0, 0.55); - - //gridBuilder->setNumberOfLayers(6,6); - //gridBuilder->addGrid( &cube, 1); - - gridBuilder->setPeriodicBoundaryCondition(true, false, true); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcMX = std::make_shared<Pressure>( dataBase, p0 + g * 0.5 * L ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<Pressure>( dataBase, p0 - g * 0.5 * L ); - SPtr<BoundaryCondition> bcMX = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPX = std::make_shared<Periodic>( dataBase ); - - bcMX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, 0.0, true ); - SPtr<BoundaryCondition> bcPY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, 0.0, true ); - //SPtr<BoundaryCondition> bcMY = std::make_shared<Periodic>( dataBase ); - //SPtr<BoundaryCondition> bcPY = std::make_shared<Periodic>( dataBase ); - - bcMY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y < -0.5*H; } ); - bcPY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y > 0.5*H; } ); - - ////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcMZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, 0.0 ); - //SPtr<BoundaryCondition> bcPZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, 0.0 ); - SPtr<BoundaryCondition> bcMZ = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Periodic>( dataBase ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*dx; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*dx; } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables{ - - real rhoLocal = rho;// - cellCenter.x * two * lambda * g; - - //real ULocal =0.0;//8.0 * ( ( 0.25 - cellCenter.y * cellCenter.y ) * ( 0.25 - cellCenter.z * cellCenter.z ) ) * U; - - real ULocal = four * ( 0.25 - cellCenter.y * cellCenter.y ) * U; - - return toConservedVariables( PrimitiveVariables( rhoLocal, ULocal, 0.0, 0.0, lambda, 0.0 ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= 2000000; iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, parameters, nullptr, 0); - - if( iter % 100000 == 0 ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - cupsAnalyzer.run( iter ); - - convergenceAnalyzer.run( iter ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - -} - -int main( int argc, char* argv[]) -{ - std::string path( "F:/Work/Computations/out/" ); - //std::string path( "out/" ); - std::string simulationName ( "ChannelFlow" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - channelFlow( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/GKS/ChannelFlowObstacle/3rdPartyLinking.cmake b/apps/gpu/GKS/ChannelFlowObstacle/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ChannelFlowObstacle/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/ChannelFlowObstacle/CMakeLists.txt b/apps/gpu/GKS/ChannelFlowObstacle/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ChannelFlowObstacle/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/ChannelFlowObstacle/CMakePackage.cmake b/apps/gpu/GKS/ChannelFlowObstacle/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ChannelFlowObstacle/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/ChannelFlowObstacle/ChannelFlowObstacle.cpp b/apps/gpu/GKS/ChannelFlowObstacle/ChannelFlowObstacle.cpp deleted file mode 100644 index 98af8e1245d5bd492d387ba580f4a0af628a8620..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ChannelFlowObstacle/ChannelFlowObstacle.cpp +++ /dev/null @@ -1,324 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/TriangularMesh/TriangularMesh.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" - -#include "GksGpu/Restart/Restart.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void channelFlow( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 32+1; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint startIter = 0; - - real L = 1.0; - real H = 1.0; - - real dx = H / real(nx); - - real Re = 1.0e4; - real U = 0.1; - real Ma = 0.1; - - real Pr = 0.1; - real K = 2.0; - - real rho = 1.0; - - real mu = U * rho * H / Re; - - real cs = U / Ma; - real lambda = c1o2 * ( ( K + 4.0 ) / ( K + 2.0 ) ) / ( cs * cs ); - - real g = eight * mu * U / ( H * H ); - - real p0 = c1o2 * rho / lambda; - - real CFL = 0.25; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = g; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - parameters.viscosityModel = ViscosityModel::constant; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //gridBuilder->addCoarseGrid(-0.5*L, -0.5*H, -0.5*dx, - //0.5*L, 0.5*H, 0.5*dx, dx); - - gridBuilder->addCoarseGrid(-0.5*L, -0.5*H, -0.5*H, - 2.5*L, 0.5*H, 0.5*H, dx); - - Cuboid cube1(-0.1, -0.1, -0.1, 0.2, 0.1, 0.1); - Cuboid cube2(-0.1, -0.1, -0.1, 0.2, 0.1, 0.1); - - gridBuilder->setNumberOfLayers(10,6); - gridBuilder->addGrid( &cube1, 2); - //gridBuilder->addGrid( &cube2, 3); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - TriangularMesh* CubeSTL = TriangularMesh::make("F:/Work/Computations/inp/Cube.stl"); - - gridBuilder->addGeometry(CubeSTL); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->setPeriodicBoundaryCondition(true, false, true); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcMX = std::make_shared<Pressure>( dataBase, p0 + g * 0.5 * L ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<Pressure>( dataBase, p0 - g * 0.5 * L ); - SPtr<BoundaryCondition> bcMX = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPX = std::make_shared<Periodic>( dataBase ); - - bcMX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, 0.0, true ); - SPtr<BoundaryCondition> bcPY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, 0.0, true ); - //SPtr<BoundaryCondition> bcMY = std::make_shared<Periodic>( dataBase ); - //SPtr<BoundaryCondition> bcPY = std::make_shared<Periodic>( dataBase ); - - bcMY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y < -0.5*H; } ); - bcPY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y > 0.5*H; } ); - - ////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcMZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, 0.0 ); - //SPtr<BoundaryCondition> bcPZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, 0.0 ); - SPtr<BoundaryCondition> bcMZ = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Periodic>( dataBase ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*dx; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*dx; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcCube = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), 0.8*lambda, 0.0, true ); - - bcCube->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return std::fabs(center.x) < 0.1 && - std::fabs(center.y) < 0.1 && - std::fabs(center.z) < 0.1; } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcCube ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - if( false ) - { - Initializer::interpret(dataBase, [&](Vec3 cellCenter) -> ConservedVariables { - - real rhoLocal = rho;// - cellCenter.x * two * lambda * g; - - //real ULocal =0.0;//8.0 * ( ( 0.25 - cellCenter.y * cellCenter.y ) * ( 0.25 - cellCenter.z * cellCenter.z ) ) * U; - - real ULocal = four * (0.25 - cellCenter.y * cellCenter.y) * U; - - return toConservedVariables(PrimitiveVariables(rhoLocal, ULocal, 0.0, 0.0, lambda), parameters.K); - }); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - } - else - { - Restart::readRestart(dataBase, path + simulationName + "_10000.rst", startIter ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string(startIter) + "_restart" ); - } - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = startIter + 1; iter <= 2000000; iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( iter % 10000 == 0 ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - - Restart::writeRestart( dataBase, path + simulationName + "_" + std::to_string( iter ), iter ); - } - - cupsAnalyzer.run( iter ); - - convergenceAnalyzer.run( iter ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - -} - -int main( int argc, char* argv[]) -{ - std::string path( "F:/Work/Computations/out/ChannelFlowObstacle/" ); - //std::string path( "out/" ); - std::string simulationName ( "ChannelFlowObstacle" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - channelFlow( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/GKS/ConcreteHeatFluxBCTest/3rdPartyLinking.cmake b/apps/gpu/GKS/ConcreteHeatFluxBCTest/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ConcreteHeatFluxBCTest/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/ConcreteHeatFluxBCTest/CMakeLists.txt b/apps/gpu/GKS/ConcreteHeatFluxBCTest/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ConcreteHeatFluxBCTest/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/ConcreteHeatFluxBCTest/CMakePackage.cmake b/apps/gpu/GKS/ConcreteHeatFluxBCTest/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ConcreteHeatFluxBCTest/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/ConcreteHeatFluxBCTest/ConcreteHeatFluxBCTest.cpp b/apps/gpu/GKS/ConcreteHeatFluxBCTest/ConcreteHeatFluxBCTest.cpp deleted file mode 100644 index f23e9d74bb1027e5c3d66b9df289ca84cee21f15..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ConcreteHeatFluxBCTest/ConcreteHeatFluxBCTest.cpp +++ /dev/null @@ -1,361 +0,0 @@ - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// || || || |||||| |||||||| || || |||||||| || -// || || || || || || || || || || || -// || || || |||||| || || || |||||||| || -// || || || || || || |||||| || || |||||| |||||| || |||||| |||||| |||||| -// || || || || || || || ||| || -// |||| ||||||||||||||||||||||||||||||||||||||||||||||||||||||| || |||||| |||||| ||| -// || || || || || || ||| -// i R M B @ T U B r a u n s c h w e i g || || || || |||||| ||||||| -// -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <sstream> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" -#include "GridGenerator/geometries/TriangularMesh/TriangularMesh.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GridGenerator/utilities/communication.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" -#include "GksGpu/FlowStateData/ThermalDependencies.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure2.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" -#include "GksGpu/BoundaryConditions/HeatFlux.h" -#include "GksGpu/BoundaryConditions/CreepingMassFlux.h" -#include "GksGpu/BoundaryConditions/ConcreteHeatFlux.h" -#include "GksGpu/BoundaryConditions/Open.h" - -#include "GksGpu/Communication/Communicator.h" -#include "GksGpu/Communication/MpiUtility.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" -#include "GksGpu/Analyzer/PointTimeseriesCollector.h" - -#include "GksGpu/Restart/Restart.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void thermalCavity( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real dx = 0.1; - - real L = 1.0; - - real Pr = 1.0; - real K = 2.0; - - real g = 9.81; - real rho = 1.0; - - PrimitiveVariables prim( rho, 0.0, 0.0, 0.0, -1.0 ); - setLambdaFromT( prim, 12.0 ); - - real cs = sqrt( ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( 2.0 * prim.lambda ) ); - - real mu = 1.0e-2; - - real cp = 0.5 * ( K + 5 ) * R_U / M_A; - - real k = mu / Pr * cp; - - real dt = 0.000025; - - //real dt = 0.01 * dx*dx / ( 2.0 * mu ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "cs = " << cs << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " kg/sm\n"; - - //*logging::out << logging::Logger::INFO_HIGH << "HRR = " << U * rhoFuel * LBurner * LBurner * (heatOfReaction * 100.0) / 0.016 / 1000.0 << " kW\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.D = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = prim.lambda; - - //parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - parameters.viscosityModel = ViscosityModel::constant; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->addCoarseGrid(-0.5 * L, -0.5 * L, -0.5 * L, - 0.5 * L, 0.5 * L, 0.5 * L, dx); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->setPeriodicBoundaryCondition(false, false, false); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "Grid_rank_" + std::to_string( rank ) + "_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "MeshFaces_rank_" + std::to_string( rank ) + ".vtk" ); - - //meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcWall1 = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), prim.lambda, false); - - bcWall1->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L; } ); - - SPtr<BoundaryCondition> bcWall2 = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false); - - bcWall2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > -0.5*L; } ); - - //SPtr<BoundaryCondition> bcWallHeatFlux = std::make_shared<ConcreteHeatFlux>( dataBase, 9, 0.1 * k / 1.0 / 50.0, 1.0, 50.0, 0.1, 3.0 ); - //SPtr<BoundaryCondition> bcWallHeatFlux = std::make_shared<ConcreteHeatFlux>( dataBase, 9, 1.0 * k / 1.0 / 50.0, 1.0, 50.0, 0.1, 3.0 ); - SPtr<BoundaryCondition> bcWallHeatFlux = std::make_shared<ConcreteHeatFlux>( dataBase, 9, 10.0 * k / 1.0 / 50.0, 1.0, 50.0, 0.1, 3.0 ); - - bcWallHeatFlux->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L && std::abs(center.y) < 0.5*L && std::abs(center.z) < 0.5*L; } ); - - std::dynamic_pointer_cast<ConcreteHeatFlux>(bcWallHeatFlux)->init(); - - ////////////////////////////////////////////////////////////////////////// - - - dataBase->boundaryConditions.push_back( bcWallHeatFlux ); - - dataBase->boundaryConditions.push_back( bcWall1 ); - dataBase->boundaryConditions.push_back( bcWall2 ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint startIter = 0; - - dataBase->setMesh( meshAdapter ); - - dataBase->setCommunicators( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&](Vec3 cellCenter) -> ConservedVariables { - - PrimitiveVariables primLocal = prim; - - return toConservedVariables(primLocal, parameters.K); - }); - - writeVtkXML(dataBase, parameters, 0, path + simulationName + "_0"); - - //std::dynamic_pointer_cast<ConcreteHeatFlux>(bcWallHeatFlux)->writeVTKFile(dataBase, parameters, path + simulationName + "_Solid_0"); - writeConcreteHeatFluxVtkXML( dataBase, std::dynamic_pointer_cast<ConcreteHeatFlux>(bcWallHeatFlux), parameters, 0, path + simulationName + "_Solid_0" ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, level ); - - Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0, true, 10000 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase, 10000 ); - - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 50000 ); - - ////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_HIGH << "================================================================================\n"; - *logging::out << logging::Logger::INFO_HIGH << "================================================================================\n"; - *logging::out << logging::Logger::INFO_HIGH << "================== S t a r t T i m e S t e p p i n g =================\n"; - *logging::out << logging::Logger::INFO_HIGH << "================================================================================\n"; - *logging::out << logging::Logger::INFO_HIGH << "================================================================================\n"; - - cupsAnalyzer.start(); - - for( uint iter = startIter + 1; iter <= 10000000; iter++ ) - { - ////////////////////////////////////////////////////////////////////////// - - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.run( iter, parameters.dt ); - - convergenceAnalyzer.run( iter ); - - ////////////////////////////////////////////////////////////////////////// - - int crashCellIndex = dataBase->getCrashCellIndex(); - if( crashCellIndex >= 0 ) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Simulation Crashed at CellIndex = " << crashCellIndex << "\n"; - dataBase->copyDataDeviceToHost(); - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - - //std::dynamic_pointer_cast<ConcreteHeatFlux>(bcWallHeatFlux)->writeVTKFile(dataBase, parameters, path + simulationName + "_Solid_" + std::to_string( iter )); - writeConcreteHeatFluxVtkXML( dataBase, std::dynamic_pointer_cast<ConcreteHeatFlux>(bcWallHeatFlux), parameters, 0, path + simulationName + "_Solid_" + std::to_string( iter ) ); - - break; - } - - if( iter % 100000 == 0 ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - - //std::dynamic_pointer_cast<ConcreteHeatFlux>(bcWallHeatFlux)->writeVTKFile(dataBase, parameters, path + simulationName + "_Solid_" + std::to_string( iter )); - writeConcreteHeatFluxVtkXML( dataBase, std::dynamic_pointer_cast<ConcreteHeatFlux>(bcWallHeatFlux), parameters, 0, path + simulationName + "_Solid_" + std::to_string( iter ) ); - } - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - //turbulenceAnalyzer->download(); - - //writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); -} - -int main( int argc, char* argv[]) -{ - ////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/ConcreteHeatFluxBCTest/" ); -#else - std::string path( "out/" ); -#endif - - std::string simulationName ( "ConcreteHeatFluxBCTest" ); - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - ////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice( 0 ); - - ////////////////////////////////////////////////////////////////////////// - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precision\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - ////////////////////////////////////////////////////////////////////////// - - try - { - thermalCavity( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - logFile.close(); - - return 0; -} diff --git a/apps/gpu/GKS/ConfinedCombustion/3rdPartyLinking.cmake b/apps/gpu/GKS/ConfinedCombustion/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ConfinedCombustion/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/ConfinedCombustion/CMakeLists.txt b/apps/gpu/GKS/ConfinedCombustion/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ConfinedCombustion/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/ConfinedCombustion/CMakePackage.cmake b/apps/gpu/GKS/ConfinedCombustion/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ConfinedCombustion/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/ConfinedCombustion/ConfinedCombustion.cpp b/apps/gpu/GKS/ConfinedCombustion/ConfinedCombustion.cpp deleted file mode 100644 index e903cb3a06e0250a8d13fbfcb40d619f87245d9c..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ConfinedCombustion/ConfinedCombustion.cpp +++ /dev/null @@ -1,430 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" -#include "GksGpu/FlowStateData/ThermalDependencies.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void thermalCavity( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 64; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - - real dx = L / real(nx); - - real U = 0.1; - - real Pr = 0.71; - real K = 2.0; - - real g = 9.81; - real rho = 1.2; - - real mu = 5.0e-3; - - PrimitiveVariables prim( rho, 0.0, 0.0, 0.0, -1.0 ); - - setLambdaFromT( prim, 3.0 ); - - real cs = sqrt( ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( 2.0 * prim.lambda ) ); - - real CFL = 0.5; - - double dt = CFL * ( dx / ( ( U + cs ) * ( c1o1 + ( c2o1 * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "cs = " << cs << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " kg/sm\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.D = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - //parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - parameters.viscosityModel = ViscosityModel::constant; - - parameters.enableReaction = true; - - parameters.useHeatReleaseRateLimiter = true; - parameters.useTemperatureLimiter = true; - parameters.usePassiveScalarLimiter = true; - parameters.useSmagorinsky = true; - - parameters.reactionLimiter = 1.0005; - parameters.temperatureLimiter = 1.0e-6; - - parameters.useSpongeLayer = true; - parameters.spongeLayerIdx = 2; - - parameters.forcingSchemeIdx = 2; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->addCoarseGrid(-0.5*L, -0.5*dx, -0.5*dx, - 0.5*L, 0.5*dx, 0.5*dx, dx); - - //gridBuilder->addCoarseGrid(-0.5*L, -0.5*L, -0.5*L, - // 0.5*L, 0.5*L, 0.5*L, dx); - - gridBuilder->setPeriodicBoundaryCondition(true, true, true); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(1); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcMX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - - //SPtr<BoundaryCondition> bcMX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, false ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - - SPtr<BoundaryCondition> bcMX = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPX = std::make_shared<Periodic>( dataBase ); - - bcMX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcMY = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - //SPtr<BoundaryCondition> bcPY = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - - //SPtr<BoundaryCondition> bcMY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - //SPtr<BoundaryCondition> bcPY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - - SPtr<BoundaryCondition> bcMY = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPY = std::make_shared<Periodic>( dataBase ); - - //bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.125*L; } ); - //bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.125*L; } ); - - bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.5*dx; } ); - bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*dx; } ); - - ////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcMZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), true ); - //SPtr<BoundaryCondition> bcPZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), true ); - - //SPtr<BoundaryCondition> bcMZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaHot, false ); - //SPtr<BoundaryCondition> bcPZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, true ); - - SPtr<BoundaryCondition> bcMZ = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Periodic>( dataBase ); - - //bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.125*L; } ); - //bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.125*L; } ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*dx; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*dx; } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables{ - - //PrimitiveVariables primFuel = prim; - - //primFuel.S_1 = 1.0; - - ////////////////////////////////////////////////////////////////////////// - - //PrimitiveVariables primAir = prim; - - ////////////////////////////////////////////////////////////////////////// - - //real massFuel = 1.0; - //real massAir = 2.0 * 32.0/16.0 + 2.0 * 0.767 / 0.233 * 32.0/16.0; - - //real volumeFuel = massFuel / primFuel.rho; - //real volumeAir = massAir / primAir.rho; - // - //real volumeRatioFuel = volumeFuel / ( volumeFuel + volumeAir ); - - //if(fabs(cellCenter.x) < 0.5 * volumeRatioFuel ) return toConservedVariables( primFuel, parameters.K ); - //else return toConservedVariables( primAir , parameters.K ); - - ////////////////////////////////////////////////////////////////////////// - - //PrimitiveVariables primMix = prim; - - //primMix.S_1 = volumeRatioFuel; - - //return toConservedVariables( primMix, parameters.K ); - - ////////////////////////////////////////////////////////////////////////// - - if( nx == 1 ) - { - // for stoichiometric mixture - double Y_F = ( rX * M_F ) / ( rX * M_F + 2.0 * M_A ); - - prim.S_1 = Y_F; - - return toConservedVariables(prim, parameters.K); - } - - ////////////////////////////////////////////////////////////////////////// - - if( nx > 1 ) - { - // for stoichiometric mixture - double Y_F = ( rX * M_F ) / ( rX * M_F + 2.0 * M_A ); - - prim.S_1 = Y_F; - - //if (cellCenter.x < 0) prim.S_1 = 0.0; - //else prim.S_1 = 2.0 * Y_F; - - return toConservedVariables(prim, parameters.K); - } - - ////////////////////////////////////////////////////////////////////////// - - //if( nx > 1 ) - //{ - // double X_F = 1.0; - // double X_A = 1.0 - X_F; - - // double M = X_F * M_F + X_A * M_A; - - // double Y_F = X_F * M_F / M; - // double Y_A = X_A * M_A / M; - - // if (cellCenter.x < 0) prim.S_1 = 0.0; - // else prim.S_1 = Y_F; - - // if (cellCenter.x < 0) prim.rho = 1.2; - // else prim.rho = 0.1; - - // return toConservedVariables(prim, parameters.K); - //} - }); - - //std::cout << toConservedVariables( PrimitiveVariables( rho, 0.0, 0.0, 0.0, lambdaHot, S_1, S_2 ), parameters.K ).rhoE << std::endl; - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, 0 ); - - Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase ); - - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 50000 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= 100000; iter++ ) - { - //if( iter < 100000 ) - //{ - // std::dynamic_pointer_cast<IsothermalWall>(bcMX)->lambda = lambdaCold + ( lambdaHot - lambdaCold ) * ( real(iter) / 100000.0 ); - //} - //if( iter == 100000 ) - //{ - // //std::dynamic_pointer_cast<IsothermalWall>(bcMX)->lambda = lambdaHot; - // dataBase->boundaryConditions[4] = bcMX_2; - //} - - cupsAnalyzer.run( iter, parameters.dt ); - - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( - //( iter < 10 && iter % 1 == 0 ) || - //( iter < 100 && iter % 10 == 0 ) || - //( iter < 1000 && iter % 100 == 0 ) || - //( iter < 10000 && iter % 1000 == 0 ) || - //( iter < 1000000 && iter % 10000 == 0 ) - //( iter < 10000000 && iter % 100000 == 0 ) - //( iter <= 400000 && iter % 100 == 0 ) - ( iter % 10000 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - convergenceAnalyzer.run( iter ); - - //turbulenceAnalyzer->run( iter, parameters ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - //turbulenceAnalyzer->download(); - - //writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); -} - -int main( int argc, char* argv[]) -{ - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/ConfinedCombustion/" ); -#else - std::string path( "out/" ); -#endif - - std::string simulationName ( "ConfinedCombustion" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - thermalCavity( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/GKS/DrivenCavity3D/3rdPartyLinking.cmake b/apps/gpu/GKS/DrivenCavity3D/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/DrivenCavity3D/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/DrivenCavity3D/CMakeLists.txt b/apps/gpu/GKS/DrivenCavity3D/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/DrivenCavity3D/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/DrivenCavity3D/CMakePackage.cmake b/apps/gpu/GKS/DrivenCavity3D/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/DrivenCavity3D/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/DrivenCavity3D/DrivenCavity3D.cpp b/apps/gpu/GKS/DrivenCavity3D/DrivenCavity3D.cpp deleted file mode 100644 index 5bb85fa912165aa19087f5991d8d3db5d215c411..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/DrivenCavity3D/DrivenCavity3D.cpp +++ /dev/null @@ -1,272 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void drivenCavity( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - - real dx = L / 128.0; - - real Re = 1.0e3; - real U = 0.1; - real Ma = 0.1; - - real Pr = 1.0; - real K = 2.0; - - real rho = 1.0; - - real mu = U * rho * L / Re; - - real cs = U / Ma; - real lambda = c1o2 * ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( cs * cs ); - - real CFL = 0.5; - - real dt = CFL * ( dx / ( ( U + cs ) * ( c1o1 + ( c2o1 * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - parameters.viscosityModel = ViscosityModel::constant; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //gridBuilder->addCoarseGrid(-0.5, -0.5, -0.5, - //0.5, 0.5, 0.5, dx); - gridBuilder->addCoarseGrid(-0.5, -0.5, -0.5*dx, - 0.5, 0.5, 0.5*dx, dx); - - //Cuboid refBox(-1.0, -1.0, 0.475, 1.0, 1.0, 0.55); - ////Cuboid refBox(-1.0, -1.0, -1.0, 1.0, 1.0, -0.475); - - //gridBuilder->setNumberOfLayers(6,6); - //gridBuilder->addGrid( &refBox, 1); - - //gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->setPeriodicBoundaryCondition(false, false, true); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + simulationName + "_Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + simulationName + "_MeshFaces.vtk" ); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcPY = std::make_shared<IsothermalWall>( dataBase, Vec3( U , 0.0, 0.0 ), lambda, false ); - SPtr<BoundaryCondition> bcWall = std::make_shared<IsothermalWall>( dataBase, Vec3( 0.0, 0.0, 0.0 ), lambda, false ); - - bcPY->findBoundaryCells ( meshAdapter, true, [&](Vec3 center){ return center.y > 0.5; } ); - bcWall->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < 0.5; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Periodic>( dataBase ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*dx; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*dx; } ); - - //dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPY ); - dataBase->boundaryConditions.push_back( bcWall ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - //CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables { - - //real uLocal = U * ( cellCenter.z + 0.5 ); - - //if( cellCenter.y ) - - real uLocal = 0.0; - - return toConservedVariables( PrimitiveVariables( 1.0, uLocal, 0.0, 0.0, lambda ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - - ////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, false, 60.0, true, 10000 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase, 10000 ); - - auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 80000 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - for( uint iter = 1; iter <= 1000000; iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( iter % 10000 == 0 ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - cupsAnalyzer.run( iter, parameters.dt ); - - turbulenceAnalyzer->run( iter, parameters ); - - convergenceAnalyzer.run( iter ); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - turbulenceAnalyzer->download(); - - writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); - - -} - -int main( int argc, char* argv[]) -{ - //std::string path( "E:/DrivenCavity/resultsGKS/" ); - std::string path( "F:/Work/Computations/out/DrivenCavity/" ); - //std::string path( "out/" ); - std::string simulationName ( "DrivenCavity" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - try - { - drivenCavity( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/GKS/DrivenCavityMultiGPU/3rdPartyLinking.cmake b/apps/gpu/GKS/DrivenCavityMultiGPU/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/DrivenCavityMultiGPU/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/DrivenCavityMultiGPU/CMakeLists.txt b/apps/gpu/GKS/DrivenCavityMultiGPU/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/DrivenCavityMultiGPU/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/DrivenCavityMultiGPU/CMakePackage.cmake b/apps/gpu/GKS/DrivenCavityMultiGPU/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/DrivenCavityMultiGPU/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/DrivenCavityMultiGPU/DrivenCavityMultiGPU.cpp b/apps/gpu/GKS/DrivenCavityMultiGPU/DrivenCavityMultiGPU.cpp deleted file mode 100644 index 12320e5ee1f4133223177ef7231a7862640cbda2..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/DrivenCavityMultiGPU/DrivenCavityMultiGPU.cpp +++ /dev/null @@ -1,472 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> -#include <thread> - -#include <mpi.h> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" -#include "GridGenerator/geometries/BoundingBox/BoundingBox.h" -#include "GridGenerator/utilities/communication.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" - -#include "GksGpu/Communication/Communicator.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void init( uint rank, SPtr<DataBase> dataBase, SPtr<Parameters> parameters, std::string path, std::string simulationName ) -{ - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(rank % 4); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 512; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - - real dx = L / real(nx); - - real Re = 10000.0; - - real U = 1.0; - real Ma = 0.1; - - real Pr = 0.71; - real K = 2.0; - - real rho = 1.0; - - ////////////////////////////////////////////////////////////////////////// - - real gamma = ( K + 5 ) / ( K + 3 ); - - real mu = U * rho * L / Re; - - real cs = U / Ma; - real lambda = c1o2 * ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( cs * cs ); - - real CFL = 0.5; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - - ////////////////////////////////////////////////////////////////////////// - - parameters->K = K; - parameters->Pr = Pr; - parameters->mu = mu; - - parameters->force.x = 0; - parameters->force.y = 0; - parameters->force.z = 0; - - parameters->dt = dt; - parameters->dx = dx; - - parameters->lambdaRef = lambda; - - parameters->viscosityModel = ViscosityModel::sutherlandsLaw; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if( rank == 0 ) gridBuilder->addCoarseGrid(-0.5*L , -0.5*L , -0.5*L , - 3.0*dx, 3.0*dx, 3.0*dx, dx); - - if( rank == 1 ) gridBuilder->addCoarseGrid(-3.0*dx, -0.5*L , -0.5*L , - 0.5*L , 3.0*dx, 3.0*dx, dx); - - if( rank == 2 ) gridBuilder->addCoarseGrid(-0.5*L , -3.0*dx, -0.5*L , - 3.0*dx, 0.5*L , 3.0*dx, dx); - - if( rank == 3 ) gridBuilder->addCoarseGrid(-3.0*dx, -3.0*dx, -0.5*L , - 0.5*L , 0.5*L , 3.0*dx, dx); - - if( rank == 4 ) gridBuilder->addCoarseGrid(-0.5*L , -0.5*L , -3.0*dx, - 3.0*dx, 3.0*dx, 0.5*L , dx); - - if( rank == 5 ) gridBuilder->addCoarseGrid(-3.0*dx, -0.5*L , -3.0*dx, - 0.5*L , 3.0*dx, 0.5*L , dx); - - if( rank == 6 ) gridBuilder->addCoarseGrid(-0.5*L , -3.0*dx, -3.0*dx, - 3.0*dx, 0.5*L , 0.5*L , dx); - - if( rank == 7 ) gridBuilder->addCoarseGrid(-3.0*dx, -3.0*dx, -3.0*dx, - 0.5*L , 0.5*L , 0.5*L , dx); - - ////////////////////////////////////////////////////////////////////////// - - Cuboid cube( -0.1, -0.1, -0.1, - 0.1, 0.1, 0.1 ); - - gridBuilder->setNumberOfLayers(6,6); - - //gridBuilder->addGrid(&cube, 1); - - ////////////////////////////////////////////////////////////////////////// - - if( rank == 0 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( -1.0, 0.0, - -1.0, 0.0, - -1.0, 0.0 ) ); - - if( rank == 1 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( 0.0, 1.0, - -1.0, 0.0, - -1.0, 0.0 ) ); - - if( rank == 2 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( -1.0, 0.0, - 0.0, 1.0, - -1.0, 0.0 ) ); - - if( rank == 3 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( 0.0, 1.0, - 0.0, 1.0, - -1.0, 0.0 ) ); - - if( rank == 4 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( -1.0, 0.0, - -1.0, 0.0, - 0.0, 1.0 ) ); - - if( rank == 5 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( 0.0, 1.0, - -1.0, 0.0, - 0.0, 1.0 ) ); - - if( rank == 6 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( -1.0, 0.0, - 0.0, 1.0, - 0.0, 1.0 ) ); - - if( rank == 7 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( 0.0, 1.0, - 0.0, 1.0, - 0.0, 1.0 ) ); - - ////////////////////////////////////////////////////////////////////////// - - gridBuilder->setPeriodicBoundaryCondition(false, false, false); - - gridBuilder->buildGrids(GKS, false); - - if( rank == 0 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PX, 1); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PY, 2); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PZ, 4); - } - - if( rank == 1 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MX, 0); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PY, 3); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PZ, 5); - } - - if( rank == 2 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PX, 3); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MY, 0); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PZ, 6); - } - - if( rank == 3 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MX, 2); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MY, 1); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PZ, 7); - } - - if( rank == 4 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PX, 5); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PY, 6); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MZ, 0); - } - - if( rank == 5 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MX, 4); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PY, 7); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MZ, 1); - } - - if( rank == 6 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PX, 7); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MY, 4); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MZ, 2); - } - - if( rank == 7 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MX, 6); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MY, 5); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MZ, 3); - } - - gridBuilder->writeGridsToVtk(path + "Grid_" + std::to_string( rank ) + "_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - meshAdapter.getCommunicationIndices(); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces_" + std::to_string( threadIndex ) + ".vtk" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, false ); - SPtr<BoundaryCondition> bcPX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, false ); - - bcMX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, false ); - SPtr<BoundaryCondition> bcPY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, false ); - - bcMY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y < -0.5*L; } ); - bcPY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambda, false ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<IsothermalWall>( dataBase, Vec3( U, U, 0.0), lambda, false ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*L; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - dataBase->setCommunicators( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables{ - return toConservedVariables( PrimitiveVariables( rho, 0.0, 0.0, 0.0, lambda ), parameters->K ); - }); - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - //writeVtkXML( dataBase, *parameters, 0, path + simulationName + "_" + std::to_string( threadIndex ) + "_" + std::to_string( 0 ) ); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void run( uint rank, SPtr<DataBase> dataBase, SPtr<Parameters> parameters, std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice( rank % 4 ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - writeVtkXML( dataBase, *parameters, 0, path + simulationName + "_" + std::to_string( rank ) + "_" + std::to_string( 0 ) ); - - CupsAnalyzer cupsAnalyzer( dataBase, true, 300.0, true, 1000 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase, 1000 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= 100000; iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, *parameters, 0); - - if( - //( iter < 10 && iter % 1 == 0 ) || - //( iter < 100 && iter % 10 == 0 ) || - //( iter < 1000 && iter % 100 == 0 ) || - //( iter < 10000 && iter % 1000 == 0 ) - ( iter < 10000000 && iter % 20000 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, *parameters, 0, path + simulationName + "_" + std::to_string( rank ) + "_" + std::to_string( iter ) ); - } - - cupsAnalyzer.run( iter ); - - convergenceAnalyzer.run( iter ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); -} - - - -int main( int argc, char* argv[]) -{ - MPI_Init(&argc, &argv); - - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - ////////////////////////////////////////////////////////////////////////// - - //std::string path( "F:/Work/Computations/out/" ); - std::string path( "out/" ); - std::string simulationName ( "DrivenCavity" ); - - std::ofstream logFile; - - logFile.open( path + simulationName + "_" + std::to_string(rank) + ".log" ); - - logging::Logger::addStream(&logFile); - - logging::Logger::addStream(&std::cout); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - auto parameters = std::make_shared<Parameters>(); - - init( rank, dataBase, parameters, path, simulationName); - - run ( rank, dataBase, parameters, path, simulationName); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - logFile.close(); - - MPI_Finalize(); - - return 0; -} diff --git a/apps/gpu/GKS/Flame7cm/CMakeLists.txt b/apps/gpu/GKS/Flame7cm/CMakeLists.txt deleted file mode 100644 index 75ca5fa4b4e9c51724d32a3733559b9489ce7943..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/Flame7cm/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -PROJECT(Flame7cm LANGUAGES CUDA CXX) - -vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator GksMeshAdapter GksVtkAdapter GksGpu MPI::MPI_CXX FILES Flame7cm.cpp ) - -set_source_files_properties(Flame7cm.cpp PROPERTIES LANGUAGE CUDA) diff --git a/apps/gpu/GKS/Flame7cm/Flame7cm.cpp b/apps/gpu/GKS/Flame7cm/Flame7cm.cpp deleted file mode 100644 index 4323ce5ae3bf8486a2203adec470e0d1fdc05a70..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/Flame7cm/Flame7cm.cpp +++ /dev/null @@ -1,494 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <iomanip> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" -#include "GksGpu/BoundaryConditions/PassiveScalarDiriclet.h" -#include "GksGpu/BoundaryConditions/InflowComplete.h" -#include "GksGpu/BoundaryConditions/Open.h" -#include "GksGpu/BoundaryConditions/Inflow.h" -#include "GksGpu/BoundaryConditions/Symmetry.h" -#include "GksGpu/BoundaryConditions/Pressure2.h" -#include "GksGpu/BoundaryConditions/CreepingMassFlux.h" - -#include "GksGpu/Interface/Interface.h" -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/Restart/Restart.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void thermalCavity( std::string path, std::string simulationName, uint _gpuIndex, uint _nx, bool _useTempLimiter, uint restartIter ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = _nx; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 0.15; - real H = 0.4; - - real R = 0.5 * 0.071; - - real dx = H / real(nx); - - real Pr = 0.71; - real K = 2.0; - - real g = 9.81; - real rho = 1.2; - - real mu = 1.8e-5; - - real U = 0.0314; - real rhoFuel = 0.68; - - GksGpu::PrimitiveVariables prim( rho, 0.0, 0.0, 0.0, -1.0 ); - - GksGpu::setLambdaFromT( prim, 3.0 ); - - real cs = sqrt( ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( 2.0 * prim.lambda ) ); - - //real CFL = 0.06125; - real CFL = 0.125; - - real dt = CFL * ( dx / ( ( U + cs ) * ( c1o1 + ( c2o1 * mu ) / ( U * dx * rho ) ) ) ); - - //real dh = 4192.0; // kJ / kmol / T_FAKTOR - real dh = 8000.0; // kJ / kmol / T_FAKTOR - - ////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "cs = " << cs << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " kg/sm\n"; - *logging::out << logging::Logger::INFO_HIGH << "Pr = " << Pr << "\n"; - - *logging::out << logging::Logger::INFO_HIGH << "HRR = " << U * rhoFuel * M_PI * R * R * ( dh * 100 ) / 0.016 / 1000.0 << " kW\n"; - - ////////////////////////////////////////////////////////////////////////// - - GksGpu::Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.D = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = -g; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = prim.lambda; - - parameters.rhoRef = rho; - - parameters.heatOfReaction = dh; - - parameters.viscosityModel = GksGpu::ViscosityModel::sutherlandsLaw; - //parameters.viscosityModel = GksGpu::ViscosityModel::constant; - - parameters.enableReaction = true; - - parameters.useHeatReleaseRateLimiter = true; - parameters.useTemperatureLimiter = _useTempLimiter; - parameters.usePassiveScalarLimiter = true; - parameters.useSmagorinsky = true; - - parameters.heatReleaseRateLimiter = 5000000.0; - parameters.temperatureLimiter = 1.0e-8; - - parameters.useSpongeLayer = true; - parameters.spongeLayerIdx = 0; - - parameters.forcingSchemeIdx = 2; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // auto gridFactory = GridFactory::make(); - // gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - bool threeDimensional = true; - - if( threeDimensional ) - { - gridBuilder->addCoarseGrid(-0.5*L, -0.5*L, 0.0, - 0.5*L, 0.5*L, H, dx); - } - else - { - gridBuilder->addCoarseGrid(-0.5*L, -0.5*dx, 0.0, - 0.5*L, 0.5*dx, H, dx); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - VerticalCylinder cylinder1( 0.0, 0.0, 0.0, 2.1*R, 0.75*H ); - VerticalCylinder cylinder2( 0.0, 0.0, 0.0, 1.5*R, 0.15*H ); - - Conglomerate refRing; - refRing.add ( new VerticalCylinder( 0.0, 0.0, 0.0, 1.2*R, 0.02 ) ); - refRing.subtract( new VerticalCylinder( 0.0, 0.0, 0.0, 0.8*R, 1.0 ) ); - - gridBuilder->setNumberOfLayers(0,10); - - //gridBuilder->addGrid( &cylinder1 ); - //gridBuilder->addGrid( &cylinder2 ); - //gridBuilder->addGrid( &refRing ); - - if( threeDimensional ) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - else gridBuilder->setPeriodicBoundaryCondition(false, true, false); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - if( !threeDimensional ) - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksGpu::CudaUtility::setCudaDevice(_gpuIndex); - - auto dataBase = std::make_shared<GksGpu::DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real openBoundaryVelocityLimiter = 1.0; - - SPtr<GksGpu::BoundaryCondition> bcMX = std::make_shared<GksGpu::Open>( dataBase, prim, openBoundaryVelocityLimiter ); - SPtr<GksGpu::BoundaryCondition> bcPX = std::make_shared<GksGpu::Open>( dataBase, prim, openBoundaryVelocityLimiter ); - - SPtr<GksGpu::BoundaryCondition> bcMX_2 = std::make_shared<GksGpu::Symmetry>( dataBase, 'x' ); - SPtr<GksGpu::BoundaryCondition> bcPX_2 = std::make_shared<GksGpu::Symmetry>( dataBase, 'x' ); - - bcMX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L; } ); - - bcMX_2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L && center.z > 0.9*H; } ); - bcPX_2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L && center.z > 0.9*H; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> bcMY; - SPtr<GksGpu::BoundaryCondition> bcPY; - - SPtr<GksGpu::BoundaryCondition> bcMY_2; - SPtr<GksGpu::BoundaryCondition> bcPY_2; - - if( threeDimensional ) - { - bcMY = std::make_shared<GksGpu::Open>( dataBase, prim, openBoundaryVelocityLimiter ); - bcPY = std::make_shared<GksGpu::Open>( dataBase, prim, openBoundaryVelocityLimiter ); - - bcMY_2 = std::make_shared<GksGpu::Symmetry>( dataBase, 'y' ); - bcPY_2 = std::make_shared<GksGpu::Symmetry>( dataBase, 'y' ); - - bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.5*L; } ); - bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*L; } ); - - bcMY_2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.5*L && center.z > 0.9*H; } ); - bcPY_2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*L && center.z > 0.9*H; } ); - } - else - { - bcMY = std::make_shared<GksGpu::Periodic>(dataBase); - bcPY = std::make_shared<GksGpu::Periodic>(dataBase); - - bcMY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y < -0.5*dx; }); - bcPY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y > 0.5*dx; }); - } - - ////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> bcMZ = std::make_shared<GksGpu::AdiabaticWall>( dataBase, Vec3(0, 0, 0), true ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0, 0, 0), prim.lambda, true ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<InflowComplete>( dataBase, PrimitiveVariables(rho, 0.0, 0.0, 0.0, prim.lambda, 0.0, 0.0) ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<Open>( dataBase ); - - SPtr<GksGpu::BoundaryCondition> bcPZ = std::make_shared<GksGpu::Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < 0.0; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > H ; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> burner = std::make_shared<GksGpu::CreepingMassFlux>( dataBase, rhoFuel, U, prim.lambda ); - - burner->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - - if( threeDimensional ) - return center.z < 0.0 && std::sqrt(center.x*center.x + center.y*center.y) < R; - else - return center.z < 0.0 && std::sqrt(center.x*center.x) < R && std::sqrt(center.y*center.y) < 0.5 * dx; - } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( burner ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMX_2 ); - dataBase->boundaryConditions.push_back( bcPX_2 ); - - if( threeDimensional ){ - dataBase->boundaryConditions.push_back( bcMY_2 ); - dataBase->boundaryConditions.push_back( bcPY_2 ); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint startIter = 0; - - dataBase->setMesh( meshAdapter ); - - GksGpu::CudaUtility::printCudaMemoryUsage(); - - if( restartIter == INVALID_INDEX ) - { - GksGpu::Initializer::interpret(dataBase, [&](Vec3 cellCenter) -> GksGpu::ConservedVariables { - - GksGpu::PrimitiveVariables primLocal = prim; - - return GksGpu::toConservedVariables(primLocal, parameters.K); - }); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - } - else - { - GksGpu::Restart::readRestart( dataBase, path + simulationName + "_" + std::to_string( restartIter ), startIter ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( restartIter ) + "_restart" ); - } - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, level ); - - GksGpu::Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint iterPerSecond = uint( c1o1 / parameters.dt ) + 1; - - *logging::out << logging::Logger::INFO_HIGH << "iterPerSecond = " << iterPerSecond << "\n"; - - ////////////////////////////////////////////////////////////////////////// - - GksGpu::CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0, true, 10000 ); - - GksGpu::ConvergenceAnalyzer convergenceAnalyzer( dataBase, 10000 ); - - auto turbulenceAnalyzer = std::make_shared<GksGpu::TurbulenceAnalyzer>( dataBase, 10 * iterPerSecond ); - - turbulenceAnalyzer->collect_UU = true; - turbulenceAnalyzer->collect_VV = true; - turbulenceAnalyzer->collect_WW = true; - - turbulenceAnalyzer->allocate(); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = startIter + 1; iter <= 40 * iterPerSecond; iter++ ) - { - cupsAnalyzer.run( iter, parameters.dt ); - - convergenceAnalyzer.run( iter ); - - GksGpu::TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - int crashCellIndex = dataBase->getCrashCellIndex(); - - if( crashCellIndex >= 0 ) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Simulation Crashed at CellIndex = " << crashCellIndex << "\n"; - dataBase->copyDataDeviceToHost(); - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - - break; - } - - if( - //( iter >= 39360 && iter % 1 == 0 ) || - ( iter % 10000 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - if( iter % 10000 == 0 /*|| iter == 39000*/) - { - dataBase->copyDataDeviceToHost(); - GksGpu::Restart::writeRestart( dataBase, path + simulationName + "_" + std::to_string( iter ), iter ); - } - - if( iter % 100000 == 0 ) - { - turbulenceAnalyzer->download(); - - writeTurbulenceVtkXML( dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence_" + std::to_string( iter ) ); - } - - turbulenceAnalyzer->run( iter, parameters ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - //turbulenceAnalyzer->download(); - - //writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); -} - -int main( int argc, char* argv[]) -{ - uint restartIter = INVALID_INDEX; - //uint restartIter = 30000; - - uint gpuIndex = 1; - uint nx = 100; - bool useTempLimiter = true; - - if( argc > 1 ) gpuIndex = atoi( argv[1] ); - if( argc > 2 ) nx = atoi( argv[2] ); - if( argc > 3 ) useTempLimiter = atoi( argv[3] ); - if( argc > 4 ) restartIter = atoi( argv[4] ); - - ////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/Flame7cm/" ); -#else - std::string path( "out/" ); - path += "nx_"; - path += std::to_string(nx); - if( useTempLimiter ) - path += "_withTempLimiter"; - path += "/"; -#endif - - std::string simulationName ( "Flame" ); - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precision\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - thermalCavity( path, simulationName, gpuIndex, nx, useTempLimiter, restartIter ); - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - logFile.close(); - - return 0; -} diff --git a/apps/gpu/GKS/LiFuXu/3rdPartyLinking.cmake b/apps/gpu/GKS/LiFuXu/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/LiFuXu/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/LiFuXu/CMakeLists.txt b/apps/gpu/GKS/LiFuXu/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/LiFuXu/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/LiFuXu/CMakePackage.cmake b/apps/gpu/GKS/LiFuXu/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/LiFuXu/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/LiFuXu/LiFuXu.cpp b/apps/gpu/GKS/LiFuXu/LiFuXu.cpp deleted file mode 100644 index 209bd832ac2599bea187da887990cd83adfa9fa7..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/LiFuXu/LiFuXu.cpp +++ /dev/null @@ -1,390 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" -#include "GksGpu/FlowStateData/ThermalDependencies.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" -#include "GksGpu/Definitions/MemoryAccessPattern.h" - -real solution(Vec3 point, const double U, const double V, const double D, const double time) -{ - return c1o4 * ( erf( ( 0.225 - ( point.x - U * time ) ) / ( two * sqrt( D * time ) ) ) - + erf( ( -0.175 + ( point.x - U * time ) ) / ( two * sqrt( D * time ) ) ) - ) - * ( erf( ( 0.225 - ( point.y - V * time ) ) / ( two * sqrt( D * time ) ) ) - + erf( ( -0.175 + ( point.y - V * time ) ) / ( two * sqrt( D * time ) ) ) - ); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - -Vec3 cellCenter(std::shared_ptr<DataBase> dataBase, uint cellIdx) -{ - Vec3 cellCenter; - - cellCenter.x += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][0]].x; - cellCenter.y += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][0]].y; - cellCenter.x += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][1]].x; - cellCenter.y += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][1]].y; - cellCenter.x += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][2]].x; - cellCenter.y += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][2]].y; - cellCenter.x += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][3]].x; - cellCenter.y += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][3]].y; - - cellCenter.x += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][4]].x; - cellCenter.y += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][4]].y; - cellCenter.x += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][5]].x; - cellCenter.y += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][5]].y; - cellCenter.x += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][6]].x; - cellCenter.y += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][6]].y; - cellCenter.x += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][7]].x; - cellCenter.y += c1o8 * dataBase->nodeCoordinates[dataBase->cellToNode[cellIdx][7]].y; - - return cellCenter; -} - -void printL_2Norm(const std::shared_ptr<DataBase> dataBase, const real U, const real V, const real D, const real time) -{ - dataBase->copyDataDeviceToHost(); - - double l_2 = zero; - double sum = zero; - - for (uint cellIdx = 0; cellIdx < dataBase->perLevelCount[0].numberOfBulkCells; cellIdx++) - { - Vec3 center = cellCenter(dataBase, cellIdx); - - //double simulatedResult = dataBase->dataHost[ RHO_S_1(cellIdx, dataBase->numberOfCells) ]; - double simulatedResult = dataBase->dataHost[ RHO_S_2(cellIdx, dataBase->numberOfCells) ]; - - double analyticResult = solution(center, U, V, D, time); - - double err = abs(simulatedResult - analyticResult); - - sum += analyticResult * analyticResult; - - l_2 += err * err; - - //std::cout << std::endl << err << " " << analyticResult; - } - l_2 = sqrt( l_2/sum ); - std::cout << std::endl << "The l2 norm is " << l_2 << std::endl; -} - -void printL_MaxNorm(const std::shared_ptr<DataBase> dataBase, const real U, const real V, const real D, const real time) -{ - dataBase->copyDataDeviceToHost(); - - double max = zero; - - for (uint cellIdx = 0; cellIdx < dataBase->perLevelCount[0].numberOfBulkCells; cellIdx++) - { - Vec3 center = cellCenter(dataBase, cellIdx); - - //double simulatedResult = dataBase->dataHost[ RHO_S_1(cellIdx, dataBase->numberOfCells) ]; - double simulatedResult = dataBase->dataHost[ RHO_S_2(cellIdx, dataBase->numberOfCells) ]; - - double analyticResult = solution(center, U, V, D, time); - - double err = abs(simulatedResult - analyticResult); - - if( err > max ) max = err; - - //std::cout << std::endl << err << " " << analyticResult; - } - std::cout << std::endl << "The max norm is " << max << std::endl; -} - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void thermalCavity( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 128; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - - real dx = L / real(nx); - - real U = 100.0; - - real Ma = 0.1; - - real Pr = 1.0; - real K = 2.0; - - real rho = 1.0; - - real mu = 0.01; - - real D = 1.5; - - real cs = U / Ma; - PrimitiveVariables prim( rho, U, U, 0.0, ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( 2.0 * cs * cs ) ); - - real CFL = 0.25; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * D ) / ( U * dx * rho ) ) ) ); - - dt = 1.0e-6; - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "cs = " << cs << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " kg/sm\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.D = D; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - //parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - parameters.viscosityModel = ViscosityModel::constant; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->addCoarseGrid( 0.0, 0.0, -0.5*dx, - L, L, 0.5*dx, dx); - - gridBuilder->setPeriodicBoundaryCondition(true, true, true); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(1); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMX = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPX = std::make_shared<Periodic>( dataBase ); - - bcMX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPY = std::make_shared<Periodic>( dataBase ); - - bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.5*L; } ); - bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Periodic>( dataBase ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*dx; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*dx; } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables{ - - PrimitiveVariables localPrim = prim; - - //prim.S_1 = solution(cellCenter, U, U, D, 2e-3); - prim.S_2 = solution(cellCenter, U, U, D, 2e-3); - - return toConservedVariables(localPrim, parameters.K); - }); - - //std::cout << toConservedVariables( PrimitiveVariables( rho, 0.0, 0.0, 0.0, lambdaHot, S_1, S_2 ), parameters.K ).rhoE << std::endl; - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, 0 ); - - Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - uint maxIter = 1000; - - for( uint iter = 1; iter <= maxIter; iter++ ) - { - cupsAnalyzer.run( iter ); - - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( - ( iter % 100 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - convergenceAnalyzer.run( iter ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - std::cout << 2e-3 + maxIter * dt << std::endl; - - printL_2Norm (dataBase, U, U, D, 2e-3 + maxIter * dt); - printL_MaxNorm(dataBase, U, U, D, 2e-3 + maxIter * dt); -} - -int main( int argc, char* argv[]) -{ - std::string path( "F:/Work/Computations/out/LiFuXu/" ); - //std::string path( "out/" ); - std::string simulationName ( "LiFuXu" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - thermalCavity( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/GKS/MethaneFlame/3rdPartyLinking.cmake b/apps/gpu/GKS/MethaneFlame/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/MethaneFlame/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/MethaneFlame/CMakeLists.txt b/apps/gpu/GKS/MethaneFlame/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/MethaneFlame/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/MethaneFlame/CMakePackage.cmake b/apps/gpu/GKS/MethaneFlame/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/MethaneFlame/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/MethaneFlame/MethaneFlame.cpp b/apps/gpu/GKS/MethaneFlame/MethaneFlame.cpp deleted file mode 100644 index 42192f8db68dcc294926f7a6bcb770ad59043cdd..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/MethaneFlame/MethaneFlame.cpp +++ /dev/null @@ -1,387 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" -#include "GridGenerator/geometries/TriangularMesh/TriangularMesh.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" -#include "GksGpu/BoundaryConditions/Extrapolation.h" -#include "GksGpu/BoundaryConditions/Inflow.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void thermalCavity( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 32; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 3.0; - real H = 1.0; - - real dx = H / real(nx); - - real Re = 100.0; - real Ba = 0.1; - real eps = 1.2; - real Pr = 0.71; - real K = 8.0; - - real U = 1.0; - - real g = 9.81; - real rho = 1.2; - - real S_1 = 0.0; - real S_2 = 0.5; - - real R_Mixture = S_1 * 8.31445984848 / 16.04e-3 // O2 - + S_2 * 8.31445984848 / 32.00e-3 // CH4 - + (1.0 - S_1 - S_2) * 8.31445984848 / 28.00e-3; // N2 - - real lambdaCold = 0.5 / ( R_Mixture * 300 ) * 1000.0; - real lambdaHot = 0.5 / ( R_Mixture * 1200 ) * 1000.0; - - real mu = U * rho * 0.25 * H / Re; - - real cs = sqrt( ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( 2.0 * lambdaCold ) ); - - real CFL = 0.025; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "Ma = " << U/cs << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " kg/sm\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.D = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambdaCold; - - //parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - parameters.viscosityModel = ViscosityModel::constant; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //gridBuilder->addCoarseGrid( 0.0, -0.5*H, -0.5*dx, - // L, 0.5*H, 0.5*dx, dx ); - - gridBuilder->addCoarseGrid( 0.0 , -0.5*H, -0.5*H, - 2.0*L, 0.5*H, 0.5*H, dx ); - - Cuboid box ( -H, -H, -H, - 1.1*L, H, H ); - - Sphere sphere( 0.0, 0.0, 0.0, 0.15 ); - - Sphere sphere2( 0.0, 0.0, 0.0, 0.08 ); - - TriangularMesh* refCylinder = TriangularMesh::make("F:/Work/Computations/out/MethaneFlame/refCylinder.stl"); - //TriangularMesh* refCylinder = TriangularMesh::make("inp/refCylinder.stl"); - - gridBuilder->setNumberOfLayers(0,10); - - //gridBuilder->addGrid( &box, 1 ); - - //gridBuilder->addGrid( refCylinder, 2 ); - - //gridBuilder->addGrid( &sphere, 3 ); - - //gridBuilder->addGrid( &sphere2, 4 ); - - gridBuilder->setEnableFixRefinementIntoTheWall(true); - - gridBuilder->setPeriodicBoundaryCondition(false, true, true); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcMX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - SPtr<BoundaryCondition> bcMX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, false, 1.0, 0.0 ); - SPtr<BoundaryCondition> bcPX = std::make_shared<Extrapolation>( dataBase ); - - - - bcMX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < 0.0; } ); - bcPX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPY = std::make_shared<Periodic>( dataBase ); - - bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.5*H; } ); - bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*H; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Periodic>( dataBase ); - - //bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*dx; } ); - //bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*dx; } ); - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*H; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*H; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcJetFuel = std::make_shared<Inflow>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaHot, rho, 1.0, 0.0, -64.0, 1.0, 0.0 ); - SPtr<BoundaryCondition> bcJetOxygen = std::make_shared<Inflow>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaHot, rho, 1.0, 0.0, -64.0, 0.0, 0.0 ); - - - - bcJetFuel->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - return center.x < 0.0 && - std::sqrt(center.y*center.y + center.z*center.z) < 0.125 / 4.0; - } ); - - bcJetOxygen->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - return center.x < 0.0 && - std::sqrt(center.y*center.y + center.z*center.z) < 0.125; - } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - //dataBase->boundaryConditions.push_back( bcJetOxygen ); - //dataBase->boundaryConditions.push_back( bcJetFuel ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables{ - - real rhoLocal = rho; - real lambdaLocal = lambdaCold; - //real lambdaLocal = lambdaHot; - - //real radius = sqrt( cellCenter.x*cellCenter.x + cellCenter.y*cellCenter.y + cellCenter.z*cellCenter.z ); - - //if( radius < 0.2 ) - //{ - // lambdaLocal = lambdaHot; - //} - - //lambdaLocal = lambdaCold + ( lambdaHot - lambdaCold ) * exp( - 10. * ( cellCenter.x*cellCenter.x + cellCenter.y*cellCenter.y + cellCenter.z*cellCenter.z ) ); - - //lambdaLocal = lambdaCold + ( lambdaHot - lambdaCold ) * ( 0.5 * M_PI + atan( - 1000.0 * ( radius - 0.1) ) ) / M_PI; - - //rhoLocal = rho * lambdaLocal / lambdaCold; - - //lambdaLocal = lambdaCold + ( lambdaHot - lambdaCold ) * exp( - 10. * ( (cellCenter.x-0.5)*(cellCenter.x-0.5) ) ); - - real radius = sqrt( cellCenter.y*cellCenter.y + cellCenter.z*cellCenter.z ); - - real factor = 0.0; - //if( radius < 0.125 ) factor = ( 1.0 - 64.0 * radius * radius ); - - return toConservedVariables( PrimitiveVariables( rhoLocal, factor * U, 0.0, 0.0, lambdaLocal, 0.0, 0.0 ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, 0 ); - - Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase, 1000 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= 100000; iter++ ) - { - //uint T = 10000; - //if( iter <= T ) - //{ - // std::dynamic_pointer_cast<Inflow>(bcJetFuel )->lambda = lambdaCold + ( lambdaHot - lambdaCold ) * ( real(iter) / real(T) ); - // std::dynamic_pointer_cast<Inflow>(bcJetOxygen)->lambda = lambdaCold + ( lambdaHot - lambdaCold ) * ( real(iter) / real(T) ); - //} - ////else if( iter <= 2*T ) - ////{ - //// std::dynamic_pointer_cast<Inflow>(bcJetFuel )->lambda = lambdaHot - ( lambdaHot - lambdaCold ) * ( real(iter-T) / real(T) ); - //// std::dynamic_pointer_cast<Inflow>(bcJetOxygen)->lambda = lambdaHot - ( lambdaHot - lambdaCold ) * ( real(iter-T) / real(T) ); - ////} - - //if( iter == T ) - //{ - // std::dynamic_pointer_cast<Inflow>(bcJetFuel)->S_1 = 1.0; - // std::dynamic_pointer_cast<Inflow>(bcJetFuel)->S_2 = 0.0; - //} - - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( - //( iter < 10 && iter % 1 == 0 ) || - //( iter < 100 && iter % 10 == 0 ) || - //( iter < 1000 && iter % 100 == 0 ) || - //( iter < 10000 && iter % 1000 == 0 ) || - ( iter < 1000000 && iter % 10000 == 0 ) || - ( iter < 100000000 && iter % 100000 == 0 ) - //( iter > 18400 && iter % 10 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - cupsAnalyzer.run( iter ); - - convergenceAnalyzer.run( iter ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); -} - -int main( int argc, char* argv[]) -{ - std::string path( "F:/Work/Computations/out/MethaneFlame/" ); - //std::string path( "out/" ); - std::string simulationName ( "MethaneFlame" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - thermalCavity( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/GKS/MultiGPU/3rdPartyLinking.cmake b/apps/gpu/GKS/MultiGPU/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/MultiGPU/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/MultiGPU/CMakeLists.txt b/apps/gpu/GKS/MultiGPU/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/MultiGPU/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/MultiGPU/CMakePackage.cmake b/apps/gpu/GKS/MultiGPU/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/MultiGPU/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/MultiGPU/MultiGPU.cpp b/apps/gpu/GKS/MultiGPU/MultiGPU.cpp deleted file mode 100644 index 7b0c81fa700f0d1aa0260680617050a15496e326..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/MultiGPU/MultiGPU.cpp +++ /dev/null @@ -1,400 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <sstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" -#include "GridGenerator/geometries/BoundingBox/BoundingBox.h" -#include "GridGenerator/utilities/communication.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" - -#include "GksGpu/Communication/Communicator.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" -#include "GksGpu/Communication/MpiUtility.h" - -////////////////////////////////////////////////////////////////////////// - -void performanceTest( std::string path, std::string simulationName, uint decompositionDimension, uint nx, bool strongScaling ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - int mpiWorldSize = 1; - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); - - //CudaUtility::setCudaDevice(rank % devicesPerNode); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real H = 1.0; - - real L = 1.0; - - if( strongScaling ) L = H / double( mpiWorldSize ); - - real dx = H / real(nx); - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = 0; - parameters.Pr = 1; - parameters.mu = 0.01; - - parameters.force.x = 0.1; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = 0.0001; - parameters.dx = dx; - - parameters.lambdaRef = 1.0e-2; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if( decompositionDimension == 1 && mpiWorldSize > 1 ) - { - gridBuilder->addCoarseGrid( rank*L - 0.5*L - 5.0*dx, -0.5*H, -0.5*H, - rank*L + 0.5*L + 5.0*dx, 0.5*H, 0.5*H, dx); - - gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( rank*L - 0.5*L, rank*L + 0.5*L, - -H , H, - -H , H ) ); - }else - { - gridBuilder->addCoarseGrid( -0.5*H, -0.5*H, -0.5*H, - 0.5*H, 0.5*H, 0.5*H, dx); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //gridBuilder->setPeriodicBoundaryCondition(false, true, true); - gridBuilder->setPeriodicBoundaryCondition(true, false, false); - - gridBuilder->buildGrids(GKS, false); - - MPI_Barrier(MPI_COMM_WORLD); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if( decompositionDimension == 1 && mpiWorldSize > 1 ) - { - gridBuilder->findCommunicationIndices( CommunicationDirections::PX, GKS ); - gridBuilder->setCommunicationProcess ( CommunicationDirections::PX, (rank + 1 + mpiWorldSize) % mpiWorldSize ); - - gridBuilder->findCommunicationIndices( CommunicationDirections::MX, GKS ); - gridBuilder->setCommunicationProcess ( CommunicationDirections::MX, (rank - 1 + mpiWorldSize) % mpiWorldSize ); - } - //if( decompositionDimension == 1 && mpiWorldSize > 1 && rank == 0 ) - //{ - // gridBuilder->findCommunicationIndices( CommunicationDirections::PX, GKS ); - // gridBuilder->setCommunicationProcess ( CommunicationDirections::PX, (rank + 1 + mpiWorldSize) % mpiWorldSize ); - //} - //else - //{ - // gridBuilder->findCommunicationIndices( CommunicationDirections::MX, GKS ); - // gridBuilder->setCommunicationProcess ( CommunicationDirections::MX, (rank - 1 + mpiWorldSize) % mpiWorldSize ); - //} - - //gridBuilder->writeGridsToVtk(path + "/Grid_rank_" + std::to_string(rank) + "_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //meshAdapter.writeMeshFaceVTK(path + "/Faces_rank_" + std::to_string(rank) + ".vtk"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMX = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPX = std::make_shared<Periodic>( dataBase ); - //SPtr<BoundaryCondition> bcMX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.1, 0.0), false ); - - bcMX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcMY = std::make_shared<Periodic>( dataBase ); - //SPtr<BoundaryCondition> bcPY = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcMY = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - SPtr<BoundaryCondition> bcPY = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - - bcMY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y < -0.5*H; } ); - bcPY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y > 0.5*H; } ); - - ////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcMZ = std::make_shared<Periodic>( dataBase ); - //SPtr<BoundaryCondition> bcPZ = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcMZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*H; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*H; } ); - - ////////////////////////////////////////////////////////////////////////// - if( mpiWorldSize == 1 ) - { - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - } - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - ////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_HIGH << "bcMX ==> " << bcMX->numberOfCellsPerLevel[0] << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "bcPX ==> " << bcPX->numberOfCellsPerLevel[0] << "\n"; - - *logging::out << logging::Logger::INFO_HIGH << "bcMY ==> " << bcMY->numberOfCellsPerLevel[0] << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "bcPY ==> " << bcPY->numberOfCellsPerLevel[0] << "\n"; - - *logging::out << logging::Logger::INFO_HIGH << "bcMZ ==> " << bcMZ->numberOfCellsPerLevel[0] << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "bcPZ ==> " << bcPZ->numberOfCellsPerLevel[0] << "\n"; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - dataBase->setCommunicators( meshAdapter ); - - //*logging::out << logging::Logger::WARNING << int(dataBase->communicators[0].size()) << "\n"; - //*logging::out << logging::Logger::WARNING << int(dataBase->communicators[0][0].get()) << "\n"; - //*logging::out << logging::Logger::WARNING << int(dataBase->communicators[0][1].get()) << "\n"; - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables - { - return toConservedVariables( PrimitiveVariables( 1.0, 1.0, 0.0, 0.0, parameters.lambdaRef ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, level ); - - Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - if( rank == 0 ) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_0", mpiWorldSize ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" + "_rank_" + std::to_string(rank) ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - const uint numberOfIterations = 1000; - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0, true, numberOfIterations ); - - MPI_Barrier(MPI_COMM_WORLD); - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= numberOfIterations; iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - } - - cupsAnalyzer.run( numberOfIterations, parameters.dt ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_final_rank_" + std::to_string(rank) ); - - ////////////////////////////////////////////////////////////////////////// - - int crashCellIndex = dataBase->getCrashCellIndex(); - if( crashCellIndex >= 0 ) - { - *logging::out << logging::Logger::LOGGER_ERROR << "=================================================\n"; - *logging::out << logging::Logger::LOGGER_ERROR << "=================================================\n"; - *logging::out << logging::Logger::LOGGER_ERROR << "============= Simulation Crashed!!! =============\n"; - *logging::out << logging::Logger::LOGGER_ERROR << "=================================================\n"; - *logging::out << logging::Logger::LOGGER_ERROR << "=================================================\n"; - } -} - -int main( int argc, char* argv[]) -{ - ////////////////////////////////////////////////////////////////////////// - - int rank = 0; - int mpiWorldSize = 1; -#ifdef USE_CUDA_AWARE_MPI - int rank = MpiUtility::getMpiRankBeforeInit(); - int mpiWorldSize = MpiUtility::getMpiWorldSizeBeforeInit(); -#else - MPI_Init(&argc, &argv); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); -#endif - - ////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/MultiGPU/" ); -#else - //std::string path( "/home/stephan/Computations/out/" ); - std::string path( "out/" ); -#endif - - std::string simulationName ( "MultiGPU_np_" + std::to_string(mpiWorldSize) ); - - ////////////////////////////////////////////////////////////////////////// - - bool strongScaling = false; - uint nx = 128; - - if( argc > 1 ) path += argv[1]; path += "/"; - if( argc > 2 ) nx = atoi( argv[2] ); - if( argc > 3 ) strongScaling = true; - - ////////////////////////////////////////////////////////////////////////// - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + "_rank_" + std::to_string(rank) + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - ////////////////////////////////////////////////////////////////////////// - - // Important: for Cuda-Aware MPI the device must be set before MPI_Init() - int deviceCount = CudaUtility::getCudaDeviceCount(); - - if(deviceCount == 0) - { - std::stringstream msg; - msg << "No devices devices found!" << std::endl; - *logging::out << logging::Logger::WARNING << msg.str(); msg.str(""); - } - - CudaUtility::setCudaDevice( rank % deviceCount ); - - ////////////////////////////////////////////////////////////////////////// - -#ifdef USE_CUDA_AWARE_MPI - MPI_Init(&argc, &argv); -#endif - - ////////////////////////////////////////////////////////////////////////// - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precision\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - try - { - performanceTest( path, simulationName, 1, nx, strongScaling ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - logFile.close(); - - MPI_Finalize(); - - return 0; -} diff --git a/apps/gpu/GKS/MultiGPU_nD/3rdPartyLinking.cmake b/apps/gpu/GKS/MultiGPU_nD/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/MultiGPU_nD/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/MultiGPU_nD/CMakeLists.txt b/apps/gpu/GKS/MultiGPU_nD/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/MultiGPU_nD/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/MultiGPU_nD/CMakePackage.cmake b/apps/gpu/GKS/MultiGPU_nD/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/MultiGPU_nD/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/MultiGPU_nD/MultiGPU_nD.cpp b/apps/gpu/GKS/MultiGPU_nD/MultiGPU_nD.cpp deleted file mode 100644 index bc5a488b55592345de7814febd5fb2b6d5cdf129..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/MultiGPU_nD/MultiGPU_nD.cpp +++ /dev/null @@ -1,513 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <sstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" -#include "GridGenerator/geometries/BoundingBox/BoundingBox.h" -#include "GridGenerator/utilities/communication.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" - -#include "GksGpu/Communication/Communicator.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" -#include "GksGpu/Communication/MpiUtility.h" - -////////////////////////////////////////////////////////////////////////// - -void performanceTest( std::string path, std::string simulationName, uint decompositionDimension, uint nx, bool strongScaling ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - int mpiWorldSize = 1; - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); - - //CudaUtility::setCudaDevice(rank % devicesPerNode); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - int sideLengthX, sideLengthY, sideLengthZ, rankX, rankY, rankZ; - - if( decompositionDimension == 1 ) - { - if (mpiWorldSize == 1 ) { sideLengthX = 1 ; sideLengthY = 1; sideLengthZ = 1; } - else if (mpiWorldSize == 2 ) { sideLengthX = 2 ; sideLengthY = 1; sideLengthZ = 1; } - else if (mpiWorldSize == 4 ) { sideLengthX = 4 ; sideLengthY = 1; sideLengthZ = 1; } - else if (mpiWorldSize == 8 ) { sideLengthX = 8 ; sideLengthY = 1; sideLengthZ = 1; } - else if (mpiWorldSize == 16) { sideLengthX = 16; sideLengthY = 1; sideLengthZ = 1; } - else if (mpiWorldSize == 32) { sideLengthX = 32; sideLengthY = 1; sideLengthZ = 1; } - - rankX = rank; - rankY = 0; - rankZ = 0; - } - else if( decompositionDimension == 2 ) - { - if (mpiWorldSize == 1 ) { sideLengthX = 1; sideLengthY = 1; sideLengthZ = 1; } - else if (mpiWorldSize == 2 ) { sideLengthX = 2; sideLengthY = 1; sideLengthZ = 1; } - else if (mpiWorldSize == 4 ) { sideLengthX = 2; sideLengthY = 2; sideLengthZ = 1; } - else if (mpiWorldSize == 8 ) { sideLengthX = 4; sideLengthY = 2; sideLengthZ = 1; } - else if (mpiWorldSize == 16) { sideLengthX = 4; sideLengthY = 4; sideLengthZ = 1; } - else if (mpiWorldSize == 32) { sideLengthX = 8; sideLengthY = 4; sideLengthZ = 1; } - - rankX = rank % sideLengthX; - rankY = rank / sideLengthX; - rankZ = 0; - } - else if( decompositionDimension == 3 ) - { - if (mpiWorldSize == 1 ) { sideLengthX = 1; sideLengthY = 1; sideLengthZ = 1; } - else if (mpiWorldSize == 2 ) { sideLengthX = 2; sideLengthY = 1; sideLengthZ = 1; } - else if (mpiWorldSize == 4 ) { sideLengthX = 2; sideLengthY = 2; sideLengthZ = 1; } - else if (mpiWorldSize == 8 ) { sideLengthX = 2; sideLengthY = 2; sideLengthZ = 2; } - else if (mpiWorldSize == 16) { sideLengthX = 4; sideLengthY = 2; sideLengthZ = 2; } - else if (mpiWorldSize == 32) { sideLengthX = 4; sideLengthY = 4; sideLengthZ = 2; } - - rankX = rank % sideLengthX; - rankY = ( rank % ( sideLengthX * sideLengthY ) ) / sideLengthX; - rankZ = rank / ( sideLengthY * sideLengthX ); - } - - *logging::out << logging::Logger::INFO_HIGH << "SideLength = " << sideLengthX << " " << sideLengthY << " " << sideLengthZ << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "rank = " << rankX << " " << rankY << " " << rankZ << "\n"; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - - real LX = L; - real LY = L; - real LZ = L; - - real dx = L / real(nx); - - if( strongScaling ) - { - if( decompositionDimension == 1 ) - { - LX /= double(sideLengthX); - } - else if( decompositionDimension == 2 ) - { - LX /= double(sideLengthX); - LY /= double(sideLengthY); - } - else if( decompositionDimension == 3 ) - { - LX /= double(sideLengthX); - LY /= double(sideLengthY); - LZ /= double(sideLengthZ); - } - } - - ////////////////////////////////////////////////////////////////////////// - - GksGpu::Parameters parameters; - - parameters.K = 0; - parameters.Pr = 1; - parameters.mu = 0.01; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = 0.0001 * ( double(128) / double(nx) ); - parameters.dx = dx; - - parameters.lambdaRef = 1.0e-2; - - parameters.forcingSchemeIdx = 2; - - parameters.enableReaction = true; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real xOverlap = ( sideLengthX == 1 ) ? 0.0 : 5.0*dx; - real yOverlap = ( sideLengthY == 1 ) ? 0.0 : 5.0*dx; - real zOverlap = ( sideLengthZ == 1 ) ? 0.0 : 5.0*dx; - - gridBuilder->addCoarseGrid( rankX*LX - 0.5*L - xOverlap, rankY*LY - 0.5*L - yOverlap, rankZ*LZ - 0.5*L - zOverlap, - (rankX*LX+1) - 0.5*L + xOverlap, (rankY*LY+1) - 0.5*L + yOverlap, (rankZ*LZ+1) - 0.5*L + zOverlap, dx); - - gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( rankX*LX - 0.5*L, (rankX+1)*LX - 0.5*L, - rankY*LY - 0.5*L, (rankY+1)*LY - 0.5*L, - rankZ*LZ - 0.5*L, (rankZ+1)*LZ - 0.5*L ) ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->setPeriodicBoundaryCondition(sideLengthX == 1, sideLengthY == 1, sideLengthZ == 1); - - *logging::out << logging::Logger::INFO_HIGH << "periodicity = " << (sideLengthX == 1) << " " << (sideLengthY == 1) << " " << (sideLengthZ == 1) << "\n"; - - gridBuilder->buildGrids(GKS, false); - - MPI_Barrier(MPI_COMM_WORLD); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if( mpiWorldSize > 1 ) - { - int rankPX = ( (rankX + 1 + sideLengthX) % sideLengthX ) + rankY * sideLengthX + rankZ * sideLengthX * sideLengthY; - int rankMX = ( (rankX - 1 + sideLengthX) % sideLengthX ) + rankY * sideLengthX + rankZ * sideLengthX * sideLengthY; - int rankPY = rankX + ( (rankY + 1 + sideLengthY) % sideLengthY ) * sideLengthX + rankZ * sideLengthX * sideLengthY; - int rankMY = rankX + ( (rankY - 1 + sideLengthY) % sideLengthY ) * sideLengthX + rankZ * sideLengthX * sideLengthY; - int rankPZ = rankX + rankY * sideLengthX + ( (rankZ + 1 + sideLengthZ) % sideLengthZ ) * sideLengthX * sideLengthY; - int rankMZ = rankX + rankY * sideLengthX + ( (rankZ - 1 + sideLengthZ) % sideLengthZ ) * sideLengthX * sideLengthY; - - if( sideLengthX > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PX, GKS ); - if( sideLengthX > 1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::PX, rankPX); - - if( sideLengthX > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MX, GKS ); - if( sideLengthX > 1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::MX, rankMX); - - if( sideLengthY > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PY, GKS ); - if( sideLengthY > 1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::PY, rankPY); - - if( sideLengthY > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MY, GKS ); - if( sideLengthY > 1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::MY, rankMY); - - if( sideLengthZ > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PZ, GKS ); - if( sideLengthZ > 1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::PZ, rankPZ); - - if( sideLengthZ > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MZ, GKS ); - if( sideLengthZ > 1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::MZ, rankMZ); - - *logging::out << logging::Logger::INFO_HIGH << "neighborRanks = " << rankPX << " " << rankMX << " " << rankPY << " " << rankMY << " " << rankPZ << " " << rankMZ << "\n"; - } - - //gridBuilder->writeGridsToVtk(path + "/Grid_rank_" + std::to_string(rank) + "_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto dataBase = std::make_shared<GksGpu::DataBase>("GPU"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - for ( int i = 0; i < rank % GksGpu::CudaUtility::getCudaDeviceCount(); i++ ) MPI_Barrier(MPI_COMM_WORLD); - - { - GksMeshAdapter meshAdapter(gridBuilder); - - meshAdapter.inputGrid(); - - if (sideLengthX == 1 || sideLengthY == 1 || sideLengthZ == 1) meshAdapter.findPeriodicBoundaryNeighbors(); - - gridBuilder->getGrid(0)->freeMemory(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> bcMX = std::make_shared<GksGpu::Periodic>(dataBase); - SPtr<GksGpu::BoundaryCondition> bcPX = std::make_shared<GksGpu::Periodic>(dataBase); - - if (sideLengthX == 1) bcMX->findBoundaryCells(meshAdapter, true, [&](Vec3 center) { return center.x < -0.5*L; }); - if (sideLengthX == 1) bcPX->findBoundaryCells(meshAdapter, true, [&](Vec3 center) { return center.x > 0.5*L; }); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> bcMY = std::make_shared<GksGpu::Periodic>(dataBase); - SPtr<GksGpu::BoundaryCondition> bcPY = std::make_shared<GksGpu::Periodic>(dataBase); - - if (sideLengthY == 1) bcMY->findBoundaryCells(meshAdapter, true, [&](Vec3 center) { return center.y < -0.5*L; }); - if (sideLengthY == 1) bcPY->findBoundaryCells(meshAdapter, true, [&](Vec3 center) { return center.y > 0.5*L; }); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> bcMZ = std::make_shared<GksGpu::Periodic>(dataBase); - SPtr<GksGpu::BoundaryCondition> bcPZ = std::make_shared<GksGpu::Periodic>(dataBase); - - if (sideLengthZ == 1) bcMZ->findBoundaryCells(meshAdapter, true, [&](Vec3 center) { return center.z < -0.5*L; }); - if (sideLengthZ == 1) bcPZ->findBoundaryCells(meshAdapter, true, [&](Vec3 center) { return center.z > 0.5*L; }); - - ////////////////////////////////////////////////////////////////////////// - - if (sideLengthX == 1) dataBase->boundaryConditions.push_back(bcMX); - if (sideLengthX == 1) dataBase->boundaryConditions.push_back(bcPX); - - if (sideLengthY == 1) dataBase->boundaryConditions.push_back(bcMY); - if (sideLengthY == 1) dataBase->boundaryConditions.push_back(bcPY); - - if (sideLengthZ == 1) dataBase->boundaryConditions.push_back(bcMZ); - if (sideLengthZ == 1) dataBase->boundaryConditions.push_back(bcPZ); - - ////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_HIGH << "NumberOfBoundaryConditions = " << (int)dataBase->boundaryConditions.size() << "\n"; - - if (sideLengthX == 1) *logging::out << logging::Logger::INFO_HIGH << "bcMX ==> " << bcMX->numberOfCellsPerLevel[0] << "\n"; - if (sideLengthX == 1) *logging::out << logging::Logger::INFO_HIGH << "bcPX ==> " << bcPX->numberOfCellsPerLevel[0] << "\n"; - - if (sideLengthY == 1) *logging::out << logging::Logger::INFO_HIGH << "bcMY ==> " << bcMY->numberOfCellsPerLevel[0] << "\n"; - if (sideLengthY == 1) *logging::out << logging::Logger::INFO_HIGH << "bcPY ==> " << bcPY->numberOfCellsPerLevel[0] << "\n"; - - if (sideLengthZ == 1) *logging::out << logging::Logger::INFO_HIGH << "bcMZ ==> " << bcMZ->numberOfCellsPerLevel[0] << "\n"; - if (sideLengthZ == 1) *logging::out << logging::Logger::INFO_HIGH << "bcPZ ==> " << bcPZ->numberOfCellsPerLevel[0] << "\n"; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh(meshAdapter); - - dataBase->setCommunicators(meshAdapter); - - GksGpu::CudaUtility::printCudaMemoryUsage(); - } - - for ( int i = 0; i < GksGpu::CudaUtility::getCudaDeviceCount() - rank % GksGpu::CudaUtility::getCudaDeviceCount(); i++ ) MPI_Barrier(MPI_COMM_WORLD); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksGpu::Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> GksGpu::ConservedVariables - { - real U = 0.1; - - real ULocal = 0.1 + U * sin( 2.0 * M_PI * cellCenter.x ) * cos( 2.0 * M_PI * cellCenter.y ) * cos( 2.0 * M_PI * cellCenter.z ); - real VLocal = 0.1 - U * cos( 2.0 * M_PI * cellCenter.x ) * sin( 2.0 * M_PI * cellCenter.y ) * cos( 2.0 * M_PI * cellCenter.z ); - real WLocal = 0.1; - - real rho = 1.0; - - real p0 = 0.5 * rho / parameters.lambdaRef; - - real pLocal = p0 + rho * U * U / 16.0 * ( cos( 2.0 * M_PI * 2.0 * cellCenter.x ) + cos( 2.0 * M_PI * 2.0 * cellCenter.y ) ) * ( 2.0 + cos( 2.0 * M_PI * 2.0 * cellCenter.z ) ); - - real rhoLocal = 2.0 * pLocal * parameters.lambdaRef; - - //ULocal = cellCenter.x; - //VLocal = cellCenter.y; - //WLocal = cellCenter.z; - - //rhoLocal = rank + 1; - - return GksGpu::toConservedVariables( GksGpu::PrimitiveVariables( rhoLocal, ULocal, VLocal, WLocal, parameters.lambdaRef ), parameters.K ); - }); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, level ); - - GksGpu::Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - //if( rank == 0 ) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_0", mpiWorldSize ); - - //writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" + "_rank_" + std::to_string(rank) ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - const uint numberOfIterations = 1000; - - GksGpu::CupsAnalyzer cupsAnalyzer( dataBase, false, 30.0, true, numberOfIterations ); - - MPI_Barrier(MPI_COMM_WORLD); - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= numberOfIterations; iter++ ) - { - GksGpu::TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - cupsAnalyzer.run( iter, parameters.dt ); - } - - ////////////////////////////////////////////////////////////////////////// - - //dataBase->copyDataDeviceToHost(); - - //if( rank == 0 ) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_final", mpiWorldSize ); - - //writeVtkXML( dataBase, parameters, 0, path + simulationName + "_final_rank_" + std::to_string(rank) ); - - ////////////////////////////////////////////////////////////////////////// - - int crashCellIndex = dataBase->getCrashCellIndex(); - if( crashCellIndex >= 0 ) - { - *logging::out << logging::Logger::LOGGER_ERROR << "=================================================\n"; - *logging::out << logging::Logger::LOGGER_ERROR << "=================================================\n"; - *logging::out << logging::Logger::LOGGER_ERROR << "============= Simulation Crashed!!! =============\n"; - *logging::out << logging::Logger::LOGGER_ERROR << "=================================================\n"; - *logging::out << logging::Logger::LOGGER_ERROR << "=================================================\n"; - } -} - -int main( int argc, char* argv[]) -{ - ////////////////////////////////////////////////////////////////////////// - - int rank = 0; - int mpiWorldSize = 1; -#ifdef USE_CUDA_AWARE_MPI - int rank = MpiUtility::getMpiRankBeforeInit(); - int mpiWorldSize = MpiUtility::getMpiWorldSizeBeforeInit(); -#else - MPI_Init(&argc, &argv); - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); -#endif - - ////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/MultiGPU/" ); -#else - //std::string path( "/home/stephan/Computations/out/" ); - std::string path( "out/" ); -#endif - - ////////////////////////////////////////////////////////////////////////// - - bool strongScaling = false; - uint nx = 128; - uint decompositionDimension = 3; - - if( argc > 1 ) nx = atoi( argv[1] ); - if( argc > 2 ) decompositionDimension = atoi( argv[2] ); - if( argc > 3 ) strongScaling = true; - - ////////////////////////////////////////////////////////////////////////// - - std::string simulationName ( "MultiGPU" ); - - if( strongScaling ) simulationName += "_strongScaling"; - else simulationName += "_weakScaling"; - - simulationName += "_D_" + std::to_string(decompositionDimension); - - simulationName += "_nx_" + std::to_string(nx); - - simulationName += "_np_" + std::to_string(mpiWorldSize); - - ////////////////////////////////////////////////////////////////////////// - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + "_rank_" + std::to_string(rank) + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - ////////////////////////////////////////////////////////////////////////// - - // Important: for Cuda-Aware MPI the device must be set before MPI_Init() - int deviceCount = GksGpu::CudaUtility::getCudaDeviceCount(); - - if(deviceCount == 0) - { - std::stringstream msg; - msg << "No devices devices found!" << std::endl; - *logging::out << logging::Logger::WARNING << msg.str(); msg.str(""); - } - - GksGpu::CudaUtility::setCudaDevice( rank % deviceCount ); - - ////////////////////////////////////////////////////////////////////////// - -#ifdef USE_CUDA_AWARE_MPI - MPI_Init(&argc, &argv); -#endif - - ////////////////////////////////////////////////////////////////////////// - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - try - { - performanceTest( path, simulationName, decompositionDimension, nx, strongScaling ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - logFile.close(); - - MPI_Finalize(); - - return 0; -} diff --git a/apps/gpu/GKS/PoolFire/3rdPartyLinking.cmake b/apps/gpu/GKS/PoolFire/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/PoolFire/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/PoolFire/CMakeLists.txt b/apps/gpu/GKS/PoolFire/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/PoolFire/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/PoolFire/CMakePackage.cmake b/apps/gpu/GKS/PoolFire/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/PoolFire/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/PoolFire/PoolFire.cpp b/apps/gpu/GKS/PoolFire/PoolFire.cpp deleted file mode 100644 index 0db6adb4adb24b91624fc1fd457359f758cfc19d..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/PoolFire/PoolFire.cpp +++ /dev/null @@ -1,488 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" -#include "GridGenerator/geometries/TriangularMesh/TriangularMesh.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure2.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" -#include "GksGpu/BoundaryConditions/PassiveScalarDiriclet.h" -#include "GksGpu/BoundaryConditions/InflowComplete.h" -#include "GksGpu/BoundaryConditions/Open.h" -#include "GksGpu/BoundaryConditions/Extrapolation.h" -#include "GksGpu/BoundaryConditions/Symmetry.h" -#include "GksGpu/BoundaryConditions/CreepingMassFlux.h" -#include "GksGpu/BoundaryConditions/MassCompensation.h" - -#include "GksGpu/Interface/Interface.h" -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/Restart/Restart.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void thermalCavity( std::string path, std::string simulationName, uint restartIter ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 128; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 4.0; - real H = 4.0; - real W = 0.125; - - real R = 0.5; - - real dx = H / real(nx); - - real U = 0.0125; - - real eps = 2.0; - real Pr = 0.71; - real K = 5.0; - - real g = 9.81; - real rho = 1.2; - - real mu = 1.5e-5; - - PrimitiveVariables prim( rho, 0.0, 0.0, 0.0, -1.0 ); - - setLambdaFromT( prim, 3.0 / T_FAKTOR ); - - real cs = sqrt( ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( 2.0 * prim.lambda ) ); - - real CFL = 0.125; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "cs = " << cs << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " kg/sm\n"; - - *logging::out << logging::Logger::INFO_HIGH << "HRR = " << U * rho * M_PI * R * R * 800000.0 / 0.016 / 1000.0 << " kW\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.D = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = -g; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = prim.lambda; - - parameters.rhoRef = rho; - - //parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - parameters.viscosityModel = ViscosityModel::constant; - - parameters.enableReaction = true; - - *logging::out << logging::Logger::INFO_HIGH << "Pr = " << parameters.Pr << "\n"; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - bool threeDimensional = false; - - if( threeDimensional ) - { - gridBuilder->addCoarseGrid(-0.5*L, -0.5*L, 0.0, - 0.5*L, 0.5*L, H, dx); - } - else - { - gridBuilder->addCoarseGrid(-0.5*L, -0.5*dx, 0.0, - 0.5*L, 0.5*dx, H, dx); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - //TriangularMesh* stl = TriangularMesh::make("F:/Work/Computations/inp/Unterzug.stl"); - TriangularMesh* stl = TriangularMesh::make("F:/Work/Computations/inp/Ring.stl"); -#else - //TriangularMesh* stl = TriangularMesh::make("inp/Unterzug.stl"); - TriangularMesh* stl = TriangularMesh::make("inp/Ring.stl"); -#endif - - //gridBuilder->addGeometry(stl); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - VerticalCylinder cylinder( 0.0, 0.0, 0.0, 1.1, 4.0 ); - VerticalCylinder cylinder2( 0.0, 0.0, 0.0, 0.6, 0.25 ); - - Conglomerate refRing; - - refRing.add ( new VerticalCylinder( 0.0, 0.0, 0.0, 0.6, 0.125 ) ); - refRing.subtract( new VerticalCylinder( 0.0, 0.0, 0.0, 0.4, 1.0 ) ); - //refRing.add ( new VerticalCylinder( 0.0, 0.0, 0.0, 0.15, 0.125 ) ); - //refRing.subtract( new VerticalCylinder( 0.0, 0.0, 0.0, 0.05, 1.0 ) ); - - gridBuilder->setNumberOfLayers(0,20); - - gridBuilder->addGrid( &cylinder, 1 ); - gridBuilder->addGrid( &cylinder2, 3 ); - - gridBuilder->setNumberOfLayers(10,20); - - //gridBuilder->addGrid( &refRing, 2 ); - //gridBuilder->addGrid( stl, 2 ); - - if( threeDimensional ) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - else gridBuilder->setPeriodicBoundaryCondition(false, true, false); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - if( !threeDimensional ) - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real openBoundaryVelocityLimiter = 1.0; - - SPtr<BoundaryCondition> bcMX = std::make_shared<Open>( dataBase, prim, openBoundaryVelocityLimiter ); - SPtr<BoundaryCondition> bcPX = std::make_shared<Open>( dataBase, prim, openBoundaryVelocityLimiter ); - //SPtr<BoundaryCondition> bcMX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0, 0, 0), true ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0, 0, 0), true ); - //SPtr<BoundaryCondition> bcMX = std::make_shared<MassCompensation>( dataBase, rho, U, prim.lambda ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<MassCompensation>( dataBase, rho, U, prim.lambda ); - //SPtr<BoundaryCondition> bcMX = std::make_shared<IsothermalWall>( dataBase, Vec3(0, 0, 0), prim.lambda, false ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<IsothermalWall>( dataBase, Vec3(0, 0, 0), prim.lambda, false ); - //SPtr<BoundaryCondition> bcMX = std::make_shared<Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - - bcMX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L; } ); - - //SPtr<BoundaryCondition> bcMX_2 = std::make_shared<IsothermalWall>( dataBase, Vec3(0, 0, 0), prim.lambda, false ); - //SPtr<BoundaryCondition> bcPX_2 = std::make_shared<IsothermalWall>( dataBase, Vec3(0, 0, 0), prim.lambda, false ); - SPtr<BoundaryCondition> bcMX_2 = std::make_shared<Symmetry>( dataBase, 'x' ); - SPtr<BoundaryCondition> bcPX_2 = std::make_shared<Symmetry>( dataBase, 'x' ); - //SPtr<BoundaryCondition> bcMX_2 = std::make_shared<Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - //SPtr<BoundaryCondition> bcPX_2 = std::make_shared<Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - - bcMX_2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L && center.z > H - 0.5; } ); - bcPX_2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L && center.z > H - 0.5; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY; - SPtr<BoundaryCondition> bcPY; - - if( threeDimensional ) - { - //bcMY = std::make_shared<Open>( dataBase, prim, openBoundaryVelocityLimiter ); - //bcPY = std::make_shared<Open>( dataBase, prim, openBoundaryVelocityLimiter ); - bcMY = std::make_shared<Symmetry>( dataBase, 'y' ); - bcPY = std::make_shared<Symmetry>( dataBase, 'y' ); - - bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.5*L; } ); - bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*L; } ); - } - else - { - bcMY = std::make_shared<Periodic>(dataBase); - bcPY = std::make_shared<Periodic>(dataBase); - - bcMY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y < -0.5*dx; }); - bcPY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y > 0.5*dx; }); - } - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0, 0, 0), false ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0, 0, 0), prim.lambda, true ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<InflowComplete>( dataBase, PrimitiveVariables(rho, 0.0, 0.0, 0.0, prim.lambda, 0.0, 0.0) ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<Open>( dataBase ); - - //SPtr<BoundaryCondition> bcPZ = std::make_shared<Open>( dataBase, prim ); - //SPtr<BoundaryCondition> bcPZ = std::make_shared<Extrapolation>( dataBase ); - //SPtr<BoundaryCondition> bcPZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0, 0, 0), true ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < 0.0; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > H ; } ); - - ////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> burner = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), 0.5*prim.lambda, 0.0, true ); - - //SPtr<BoundaryCondition> burner = std::make_shared<InflowComplete>( dataBase, PrimitiveVariables(rho, 0.0, 0.0, U, prim.lambda, 1.0, 1.0) ); - SPtr<BoundaryCondition> burner = std::make_shared<CreepingMassFlux>( dataBase, rho, U, prim.lambda ); - - burner->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - - if( threeDimensional ) - return center.z < 0.0 && std::sqrt(center.x*center.x + center.y*center.y) < R; - else - return center.z < 0.0 && std::sqrt(center.x*center.x) < R && std::sqrt(center.y*center.y) < 0.5 * dx; - } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( burner ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMX_2 ); - dataBase->boundaryConditions.push_back( bcPX_2 ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint startIter = 0; - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - if( restartIter == INVALID_INDEX ) - { - Initializer::interpret(dataBase, [&](Vec3 cellCenter) -> ConservedVariables { - - PrimitiveVariables primLocal = prim; - - //primLocal.rho = rho * std::exp( - ( 2.0 * g * H * prim.lambda ) * cellCenter.z / H ); - - real r = sqrt(cellCenter.x * cellCenter.x /*+ cellCenter.y * cellCenter.y*/ + cellCenter.z * cellCenter.z); - - //if( r < 0.6 ) primLocal.S_1 = 1.0 - r; - - //if( r < 0.5 ) prim.lambda /= (two - four*r*r); - - return toConservedVariables(primLocal, parameters.K); - }); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - } - else - { - Restart::readRestart( dataBase, path + simulationName + "_" + std::to_string( restartIter ), startIter ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( restartIter ) + "_restart" ); - } - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, level ); - - Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase, 1000 ); - - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 50000 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = startIter + 1; iter <= 2000000; iter++ ) - { - uint runUpTime = 10000; - - if( iter < runUpTime ) - { - //std::dynamic_pointer_cast<InflowComplete>(burner)->prim.S_1 = 1.0 * ( real(iter) / 20000.0 ); - //std::dynamic_pointer_cast<InflowComplete>(burner)->prim.S_2 = 1.0 - 1.0 * ( real(iter) / 20000.0 ); - - //std::dynamic_pointer_cast<InflowComplete>(burner)->prim.W = U * ( real(iter) / 20000.0 ); - - //std::dynamic_pointer_cast<CreepingMassFlux>(burner)->velocity = U * ( real(iter) / runUpTime ); - - //parameters.mu = mu + 10.0 * mu * ( 1.0 - ( real(iter) / 20000.0 ) ); - - //parameters.dt = 0.2 * dt + ( dt - 0.2 * dt ) * ( real(iter) / 40000.0 ); - } - - //if( iter == 5001 ) - //{ - // parameters.enableReaction = false; - // std::dynamic_pointer_cast<CreepingMassFlux>(burner)->velocity = -1.0; - //} - - cupsAnalyzer.run( iter ); - - convergenceAnalyzer.run( iter ); - - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( - //( iter >= 100 && iter % 10 == 0 ) || - ( iter % 400 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - if( iter % 4000 == 0 ) - { - Restart::writeRestart( dataBase, path + simulationName + "_" + std::to_string( iter ), iter ); - } - - //turbulenceAnalyzer->run( iter, parameters ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - //turbulenceAnalyzer->download(); - - //writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); -} - -int main( int argc, char* argv[]) -{ - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/PoolFire/" ); -#else - std::string path( "out/" ); -#endif - - std::string simulationName ( "PoolFire" ); - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precision\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - uint restartIter = INVALID_INDEX; - //uint restartIter = 33000; - - if( argc > 1 ) restartIter = atoi( argv[1] ); - - thermalCavity( path, simulationName, restartIter ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - logFile.close(); - - return 0; -} diff --git a/apps/gpu/GKS/PropaneFlame/3rdPartyLinking.cmake b/apps/gpu/GKS/PropaneFlame/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/PropaneFlame/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/PropaneFlame/CMakeLists.txt b/apps/gpu/GKS/PropaneFlame/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/PropaneFlame/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/PropaneFlame/CMakePackage.cmake b/apps/gpu/GKS/PropaneFlame/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/PropaneFlame/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/PropaneFlame/PropaneFlame.cpp b/apps/gpu/GKS/PropaneFlame/PropaneFlame.cpp deleted file mode 100644 index bdee594864925933f6afe462e45b473f7d921ed9..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/PropaneFlame/PropaneFlame.cpp +++ /dev/null @@ -1,319 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" -#include "GksGpu/BoundaryConditions/Inflow.h" -#include "GksGpu/BoundaryConditions/Extrapolation.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/Periodic.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void thermalCavity( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //uint nx = 128; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real dx = 0.2; - - real L = 33.4; - real W = 20.0; - - real H = dx; - - real Re = 1.0e1; - real U = 0.1; - real Ma = 0.1; - - real Pr = 1.0; - real K = 2.0; - - real rho = 1.0; - - real mu = U * rho * L / Re; - - real cs = U / Ma; - real lambda = c1o2 * ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( cs * cs ); - - real CFL = 0.5; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " s\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - //parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - parameters.viscosityModel = ViscosityModel::constant; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->addCoarseGrid(-0.5*L, -0.5*W, -0.5*H, - 0.5*L, 0.5*W, 0.5*H, dx); - - gridBuilder->setPeriodicBoundaryCondition(false, false, true); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMX = std::make_shared<Pressure>( dataBase, 0.5 * rho / lambda ); - SPtr<BoundaryCondition> bcPX = std::make_shared<Pressure>( dataBase, 0.5 * rho / lambda ); - - bcMX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < - 0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY = std::make_shared<Inflow>( dataBase, Vec3(0.0, U, 0.0), lambda, rho, 0.0, 1.0, 0.0, 0.0 ); - SPtr<BoundaryCondition> bcPY = std::make_shared<Inflow>( dataBase, Vec3(0.0, - U, 0.0), lambda, rho, 0.0, 1.0, 0.0, 0.0 ); - - bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < - 0.5*W; } ); - bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*W; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Periodic>( dataBase ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*H; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*H; } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables{ - - return toConservedVariables( PrimitiveVariables( rho, 0.0, 0.0, 0.0, lambda ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - { - for (SPtr<BoundaryCondition> bc : dataBase->boundaryConditions) { - bc->runBoundaryConditionKernel(dataBase, parameters, level); - } - } - - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase ); - - convergenceAnalyzer.setConvergenceThreshold( ConservedVariables( 1.0e-6, 1.0e-6, 1.0e-6, 1.0e6, 1.0e-6 ) ); - - - - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 50000 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= 1000000; iter++ ) - { - if( iter == 100000 ) - { - parameters.mu = U * rho * L / 3.0e1; - } - if( iter == 200000 ) - { - parameters.mu = U * rho * L / 1.0e2; - } - if( iter == 300000 ) - { - parameters.mu = U * rho * L / 3.0e2; - } - if( iter == 400000 ) - { - parameters.mu = U * rho * L / 1.0e3; - } - - TimeStepping::nestedTimeStep(dataBase, parameters, nullptr, 0); - - if( - //( iter < 10 && iter % 1 == 0 ) || - //( iter < 100 && iter % 10 == 0 ) || - //( iter < 1000 && iter % 100 == 0 ) || - //( iter < 100000 && iter % 1000 == 0 ) || - ( iter < 10000000 && iter % 10000 == 0 ) - ) - { - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - { - for (SPtr<BoundaryCondition> bc : dataBase->boundaryConditions) { - bc->runBoundaryConditionKernel(dataBase, parameters, level); - } - } - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - cupsAnalyzer.run( iter ); - - if( convergenceAnalyzer.run( iter ) ) break; - - //turbulenceAnalyzer->run( iter, parameters ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - //turbulenceAnalyzer->download(); - - //writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); -} - -int main( int argc, char* argv[]) -{ - std::string path( "F:/Work/Computations/out/" ); - //std::string path( "out/" ); - std::string simulationName ( "PropaneFlame" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - thermalCavity( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/GKS/RayleighBenardMultiGPU/3rdPartyLinking.cmake b/apps/gpu/GKS/RayleighBenardMultiGPU/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RayleighBenardMultiGPU/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/RayleighBenardMultiGPU/CMakeLists.txt b/apps/gpu/GKS/RayleighBenardMultiGPU/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RayleighBenardMultiGPU/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/RayleighBenardMultiGPU/CMakePackage.cmake b/apps/gpu/GKS/RayleighBenardMultiGPU/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RayleighBenardMultiGPU/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/RayleighBenardMultiGPU/RayleighBenardMultiGPU.cpp b/apps/gpu/GKS/RayleighBenardMultiGPU/RayleighBenardMultiGPU.cpp deleted file mode 100644 index 811872820c0d9fce485279d086d9b907199230ae..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RayleighBenardMultiGPU/RayleighBenardMultiGPU.cpp +++ /dev/null @@ -1,636 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <sstream> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> -#include <thread> - -#include <mpi.h> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" -#include "GridGenerator/geometries/BoundingBox/BoundingBox.h" -#include "GridGenerator/utilities/communication.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" - -#include "GksGpu/Communication/Communicator.h" -#include "GksGpu/Communication/MpiUtility.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" -#include "GksGpu/Analyzer/PointTimeSeriesCollector.h" -#include "GksGpu/Analyzer/HeatFluxAnalyzer.h" - -#include "GksGpu/Restart/Restart.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -//uint deviceMap [2] = {2,3}; -uint deviceMap [2] = {0,1}; - -void simulation( std::string path, std::string simulationName, bool fine, uint restartIter ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - int mpiWorldSize = 1; - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); - - int sideLengthX, sideLengthY, sideLengthZ, rankX, rankY, rankZ; - - if (mpiWorldSize == 1 ) { sideLengthX = 1; sideLengthY = 1; sideLengthZ = 1; } - else if (mpiWorldSize == 2 ) { sideLengthX = 1; sideLengthY = 1; sideLengthZ = 2; } - else if (mpiWorldSize == 4 ) { sideLengthX = 1; sideLengthY = 2; sideLengthZ = 2; } - else if (mpiWorldSize == 8 ) { sideLengthX = 2; sideLengthY = 2; sideLengthZ = 2; } - else - { - throw std::runtime_error( "This number of processes is not supported for this target!" ); - } - - rankZ = rank % sideLengthZ; - rankY = ( rank % ( sideLengthZ * sideLengthY ) ) / sideLengthZ; - rankX = rank / ( sideLengthY * sideLengthZ ); - - *logging::out << logging::Logger::INFO_HIGH << "SideLength = " << sideLengthX << " " << sideLengthY << " " << sideLengthZ << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "rank = " << rankX << " " << rankY << " " << rankZ << "\n"; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 64; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - - real dx = L / real(nx); - - real Ra = 3.0e6; - //real Ra = 1.0e2; - - real Ba = 0.1; - real eps = 0.8; - real Pr = 0.71; - real K = 2.0; - - real g = 1.0; - real rho = 1.0; - - real lambda = Ba / ( 2.0 * g * L ); - real lambdaHot = lambda / ( 1.0 + eps * 0.5 ); - real lambdaCold = lambda / ( 1.0 - eps * 0.5 ); - - real mu = sqrt( Pr * eps * g * L * L * L / Ra ) * rho ; - - real cs = sqrt( ( ( K + 4.0 ) / ( K + 2.0 ) ) / ( 2.0 * lambda ) ); - real U = sqrt( Ra ) * mu / ( rho * L ); - - real CFL = 0.5; - - real dt = CFL * ( dx / ( ( U + cs ) * ( c1o1 + ( c2o1 * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " s\n"; - - ////////////////////////////////////////////////////////////////////////// - - GksGpu::Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = -g; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - parameters.viscosityModel = GksGpu::ViscosityModel::sutherlandsLaw2; - //parameters.viscosityModel = ViscosityModel::constant; - - parameters.forcingSchemeIdx = 0; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // M e s h G e n e r a t i o n - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real LX = L / double(sideLengthX); - real LY = L / double(sideLengthY); - real LZ = L / double(sideLengthZ); - - real xOverlap = ( sideLengthX == 1 ) ? 0.0 : 5.0*dx; - real yOverlap = ( sideLengthY == 1 ) ? 0.0 : 5.0*dx; - real zOverlap = ( sideLengthZ == 1 ) ? 0.0 : 5.0*dx; - - real startX, endX; - real startY, endY; - real startZ, endZ; - - if( sideLengthX > 1 && rankX == 1 ) startX = -3.0 * dx; - else startX = -0.5 * L; - if( sideLengthX > 1 && rankX == 0 ) endX = 3.0 * dx; - else endX = 0.5 * L; - - if( sideLengthY > 1 && rankY == 1 ) startY = -3.0 * dx; - else startY = -0.5 * L; - if( sideLengthY > 1 && rankY == 0 ) endY = 3.0 * dx; - else endY = 0.5 * L; - - if( sideLengthZ > 1 && rankZ == 1 ) startZ = -3.0 * dx; - else startZ = -0.5 * L; - if( sideLengthZ > 1 && rankZ == 0 ) endZ = 3.0 * dx; - else endZ = 0.5 * L; - - gridBuilder->addCoarseGrid(startX, startY, startZ, - endX , endY , endZ , dx); - - std::cout << __LINE__ << std::endl; - - ////////////////////////////////////////////////////////////////////////// - - real refL[4] = { 0.05, 0.02, 0.025, 0.005 }; - - if( fine ) - { - refL[1] = 0.1; - refL[2] = 0.05; - } - - gridBuilder->setNumberOfLayers(6,6); - - ////////////////////////////////////////////////////////////////////////// - - Conglomerate coarseRefLevel; - - if( sideLengthX == 1 || rankX == 0 ) coarseRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - 100.0, -0.5*L + refL[0], 100.0 ) ); - if( sideLengthX == 1 || rankX == 1 ) coarseRefLevel.add( new Cuboid (-100.0, 0.5*L - refL[0], -100.0, - 100.0, 100.0, 100.0 ) ); - - if( sideLengthY == 1 || rankY == 0 ) coarseRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - -0.5*L + refL[0], 100.0, 100.0 ) ); - if( sideLengthY == 1 || rankY == 1 ) coarseRefLevel.add( new Cuboid ( 0.5*L - refL[0], -100.0, -100.0, - 100.0, 100.0, 100.0 ) ); - - if( sideLengthZ == 1 || rankZ == 0 ) coarseRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - 100.0, 100.0, -0.5*L + refL[0] ) ); - if( sideLengthZ == 1 || rankZ == 1 ) coarseRefLevel.add( new Cuboid (-100.0, -100.0, 0.5*L - refL[0], - 100.0, 100.0, 100.0 ) ); - - gridBuilder->addGrid( &coarseRefLevel, 1); - - ////////////////////////////////////////////////////////////////////////// - - Conglomerate firstRefLevel; - - if( sideLengthZ == 1 || rankZ == 0 ) firstRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - 100.0, 100.0, -0.5*L + refL[1] ) ); - if( sideLengthZ == 1 || rankZ == 1 ) firstRefLevel.add( new Cuboid (-100.0, -100.0, 0.5*L - refL[1], - 100.0, 100.0, 100.0 ) ); - - gridBuilder->addGrid( &firstRefLevel, 2); - - ////////////////////////////////////////////////////////////////////////// - - //Conglomerate secondRefLevel; - - //if( rank % 2 == 0 ) secondRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - // -0.5*L + refL[2], 100.0, 100.0 ) ); - //else secondRefLevel.add( new Cuboid ( 0.5*L - refL[2], -100.0, -100.0, - // 100.0, 100.0, 100.0 ) ); - - //if( rank % 2 == 0 ) secondRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - // -0.5*L + refL[0], 100.0, -0.5*H + refL[2] ) ); - //else secondRefLevel.add( new Cuboid ( 0.5*L - refL[0], -100.0, -100.0, - // 100.0, 100.0, -0.5*H + refL[2] ) ); - - //if( rank % 2 == 0 ) secondRefLevel.add( new Cuboid (-100.0, -100.0, 0.5*H - refL[2], - // -0.5*L + refL[0], 100.0, 100.0 ) ); - //else secondRefLevel.add( new Cuboid ( 0.5*L - refL[0], -100.0, 0.5*H - refL[2], - // 100.0, 100.0, 100.0 ) ); - - //gridBuilder->addGrid( &secondRefLevel, 3); - - ////////////////////////////////////////////////////////////////////////// - - //Conglomerate thirdRefLevel; - - //if( rank % 2 == 0 ) thirdRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - // -0.5*L + refL[3], 100.0, 100.0 ) ); - //else thirdRefLevel.add( new Cuboid ( 0.5*L - refL[3], -100.0, -100.0, - // 100.0, 100.0, 100.0 ) ); - - //if( fine ) gridBuilder->addGrid( &thirdRefLevel, 4); - - ////////////////////////////////////////////////////////////////////////// - - if( sideLengthX > 1 && rankX == 1 ) startX = 0.0; - else startX = -100.0; - if( sideLengthX > 1 && rankX == 0 ) endX = 0.0; - else endX = 100.0; - - if( sideLengthY > 1 && rankY == 1 ) startY = 0.0; - else startY = -100.0; - if( sideLengthY > 1 && rankY == 0 ) endY = 0.0; - else endY = 100.0; - - if( sideLengthZ > 1 && rankZ == 1 ) startZ = 0.0; - else startZ = -100.0; - if( sideLengthZ > 1 && rankZ == 0 ) endZ = 0.0; - else endZ = 100.0; - - auto subDomainBox = std::make_shared<BoundingBox>( startX, endX, - startY, endY, - startZ, endZ ); - - if( mpiWorldSize > 1 ) gridBuilder->setSubDomainBox( subDomainBox ); - - ////////////////////////////////////////////////////////////////////////// - - gridBuilder->setPeriodicBoundaryCondition(false, false, false); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk( path + simulationName + "_0" + "_rank_" + std::to_string(rank) + "_lev_" ); - - ////////////////////////////////////////////////////////////////////////// - - if( mpiWorldSize > 1 ) - { - int rankPX = ( (rankX + 1 + sideLengthX) % sideLengthX ) + rankY * sideLengthX + rankZ * sideLengthX * sideLengthY; - int rankMX = ( (rankX - 1 + sideLengthX) % sideLengthX ) + rankY * sideLengthX + rankZ * sideLengthX * sideLengthY; - int rankPY = rankX + ( (rankY + 1 + sideLengthY) % sideLengthY ) * sideLengthX + rankZ * sideLengthX * sideLengthY; - int rankMY = rankX + ( (rankY - 1 + sideLengthY) % sideLengthY ) * sideLengthX + rankZ * sideLengthX * sideLengthY; - int rankPZ = rankX + rankY * sideLengthX + ( (rankZ + 1 + sideLengthZ) % sideLengthZ ) * sideLengthX * sideLengthY; - int rankMZ = rankX + rankY * sideLengthX + ( (rankZ - 1 + sideLengthZ) % sideLengthZ ) * sideLengthX * sideLengthY; - - if( sideLengthX > 1 && rankX == 0 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PX, GKS ); - if( sideLengthX > 1 && rankX == 0 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::PX, rankPX); - - if( sideLengthX > 1 && rankX == 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MX, GKS ); - if( sideLengthX > 1 && rankX == 1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::MX, rankMX); - - if( sideLengthY > 1 && rankY == 0 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PY, GKS ); - if( sideLengthY > 1 && rankY == 0 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::PY, rankPY); - - if( sideLengthY > 1 && rankY == 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MY, GKS ); - if( sideLengthY > 1 && rankY == 1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::MY, rankMY); - - if( sideLengthZ > 1 && rankZ == 0 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PZ, GKS ); - if( sideLengthZ > 1 && rankZ == 0 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::PZ, rankPZ); - - if( sideLengthZ > 1 && rankZ == 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MZ, GKS ); - if( sideLengthZ > 1 && rankZ == 1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::MZ, rankMZ); - - *logging::out << logging::Logger::INFO_HIGH << "neighborRanks = " << rankPX << " " << rankMX << " " << rankPY << " " << rankMY << " " << rankPZ << " " << rankMZ << "\n"; - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //if( mpiWorldSize == 2 ) meshAdapter.findPeriodicBoundaryNeighbors(); - - //meshAdapter.writeMeshFaceVTK( path + simulationName + "_0" + "_rank_" + std::to_string(rank) + ".vtk" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto dataBase = std::make_shared<GksGpu::DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // B o u n d a r y C o n d i t i o n s - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> bcMX = std::make_shared<GksGpu::AdiabaticWall>( dataBase, Vec3(0,0,0), false ); - SPtr<GksGpu::BoundaryCondition> bcPX = std::make_shared<GksGpu::AdiabaticWall>( dataBase, Vec3(0,0,0), false ); - - SPtr<GksGpu::BoundaryCondition> bcMY = std::make_shared<GksGpu::AdiabaticWall>( dataBase, Vec3(0,0,0), false ); - SPtr<GksGpu::BoundaryCondition> bcPY = std::make_shared<GksGpu::AdiabaticWall>( dataBase, Vec3(0,0,0), false ); - - bcMX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 0.5*L; } ); - - bcMY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y < -0.5*L; } ); - bcPY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> bcMZ = std::make_shared<GksGpu::IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaHot , false ); - SPtr<GksGpu::BoundaryCondition> bcPZ = std::make_shared<GksGpu::IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, false ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*L; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // I n i t i a l C o n d i t i o n s - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint startIter = 0; - - dataBase->setMesh( meshAdapter ); - - dataBase->setCommunicators( meshAdapter ); - - GksGpu::CudaUtility::printCudaMemoryUsage(); - - if( restartIter == INVALID_INDEX ) - { - GksGpu::Initializer::interpret(dataBase, [&](Vec3 cellCenter) -> GksGpu::ConservedVariables { - - //real Th = 1.0 / lambdaHot; - //real Tc = 1.0 / lambdaCold; - //real T = Th - (Th - Tc)*((cellCenter.x + 0.5 * L) / L); - //real lambdaLocal = 1.0 / T; - - return GksGpu::toConservedVariables(GksGpu::PrimitiveVariables(rho, 0.0, 0.0, 0.0, lambda), parameters.K); - }); - - if (rank == 0) writeVtkXMLParallelSummaryFile(dataBase, parameters, path + simulationName + "_0", mpiWorldSize); - - writeVtkXML(dataBase, parameters, 0, path + simulationName + "_0" + "_rank_" + std::to_string(rank)); - } - else - { - GksGpu::Restart::readRestart( dataBase, path + simulationName + "_" + std::to_string( restartIter ) + "_rank_" + std::to_string(rank), startIter ); - - if (rank == 0) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_" + std::to_string( restartIter ) + "_restart", mpiWorldSize ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( restartIter ) + "_restart" + "_rank_" + std::to_string(rank) ); - - - } - - dataBase->copyDataHostToDevice(); - - GksGpu::Initializer::initializeDataUpdate(dataBase); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // R u n - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksGpu::CupsAnalyzer cupsAnalyzer( dataBase, true, 300.0 ); - - GksGpu::ConvergenceAnalyzer convergenceAnalyzer( dataBase ); - - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 0 ); - auto turbulenceAnalyzer = std::make_shared<GksGpu::TurbulenceAnalyzer>( dataBase, 50000 ); - - turbulenceAnalyzer->collect_UU = true; - turbulenceAnalyzer->collect_VV = true; - turbulenceAnalyzer->collect_WW = true; - turbulenceAnalyzer->collect_UV = true; - turbulenceAnalyzer->collect_UW = true; - turbulenceAnalyzer->collect_VW = true; - - turbulenceAnalyzer->allocate(); - - if( restartIter != INVALID_INDEX ) - turbulenceAnalyzer->readRestartFile( path + simulationName + "_Turbulence_" + std::to_string( restartIter ) + "_rank_" + std::to_string(rank) ); - - //auto pointTimeSeriesCollector = std::make_shared<PointTimeSeriesCollector>(); - - //for( real y = 0.5 * W; y < real( mpiWorldSize / 2 ) * W; y += W ) - //{ - // if( subDomainBox->isInside( -0.485, y, -0.3*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( -0.485, y, -0.3*H ), 'W', 10000 ); - // if( subDomainBox->isInside( -0.485, y, -0.1*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( -0.485, y, -0.1*H ), 'W', 10000 ); - // if( subDomainBox->isInside( -0.485, y, 0.1*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( -0.485, y, 0.1*H ), 'W', 10000 ); - // if( subDomainBox->isInside( -0.485, y, 0.3*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( -0.485, y, 0.3*H ), 'W', 10000 ); - // - // if( subDomainBox->isInside( 0.485, y, -0.3*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( 0.485, y, -0.3*H ), 'W', 10000 ); - // if( subDomainBox->isInside( 0.485, y, -0.1*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( 0.485, y, -0.1*H ), 'W', 10000 ); - // if( subDomainBox->isInside( 0.485, y, 0.1*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( 0.485, y, 0.1*H ), 'W', 10000 ); - // if( subDomainBox->isInside( 0.485, y, 0.3*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( 0.485, y, 0.3*H ), 'W', 10000 ); - //} - - GksGpu::HeatFluxAnalyzer heatFluxAnalyzerPZ(dataBase, bcPZ, 100, 10000, lambdaHot, lambdaCold, L); - GksGpu::HeatFluxAnalyzer heatFluxAnalyzerMZ(dataBase, bcMZ, 100, 10000, lambdaHot, lambdaCold, L); - //HeatFluxAnalyzer heatFluxAnalyzer(dataBase, bcPZ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = startIter + 1; iter <= 100000000; iter++ ) - { - GksGpu::TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - cupsAnalyzer.run( iter, parameters.dt ); - - convergenceAnalyzer.run( iter ); - - turbulenceAnalyzer->run( iter, parameters ); - - if(rankZ == 1) heatFluxAnalyzerPZ.run( iter, parameters ); - if(rankZ == 0) heatFluxAnalyzerMZ.run( iter, parameters ); - - if( iter % 10000 == 0 ) - //if( iter % 25 == 0 ) - { - dataBase->copyDataDeviceToHost(); - - if( rank == 0 ) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_" + std::to_string( iter ), mpiWorldSize ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) + "_rank_" + std::to_string(rank) ); - - if(rankZ == 1) heatFluxAnalyzerPZ.writeToFile( path + simulationName + "_Nu_top_" + std::to_string( iter ) + "_rank_" + std::to_string(rank) ); - if(rankZ == 0) heatFluxAnalyzerMZ.writeToFile( path + simulationName + "_Nu_bot_" + std::to_string( iter ) + "_rank_" + std::to_string(rank) ); - } - - //pointTimeSeriesCollector->run(iter, parameters); - - if( iter > 50000 && iter % 10000 == 0 ) - { - turbulenceAnalyzer->download(); - - if( rank == 0 ) writeTurbulenceVtkXMLParallelSummaryFile( dataBase, turbulenceAnalyzer, parameters, path + simulationName + "_Turbulence_" + std::to_string( iter ), mpiWorldSize ); - - writeTurbulenceVtkXML( dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence_" + std::to_string( iter ) + "_rank_" + std::to_string(rank) ); - } - - if( iter % 10000 == 0 ) - { - GksGpu::Restart::writeRestart( dataBase, path + simulationName + "_" + std::to_string( iter ) + "_rank_" + std::to_string(rank), iter ); - - turbulenceAnalyzer->writeRestartFile( path + simulationName + "_Turbulence_" + std::to_string( iter ) + "_rank_" + std::to_string(rank) ); - } - - //if( iter % 1000000 == 0 ) - //{ - // pointTimeSeriesCollector->writeToFile(path + simulationName + "_TimeSeries_" + std::to_string( iter ) + "_rank_" + std::to_string(rank)); - //} - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); -} - - - -int main( int argc, char* argv[]) -{ - ////////////////////////////////////////////////////////////////////////// - - bool fine = false; - - bool highAspect = true; - - ////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - MPI_Init(&argc, &argv); - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - int mpiWorldSize = 1; - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); -#else - int rank = GksGpu::MpiUtility::getMpiRankBeforeInit(); - int mpiWorldSize = GksGpu::MpiUtility::getMpiWorldSizeBeforeInit(); -#endif - - ////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/RayleighBenardMultiGPU/test/" ); - //std::string path( "F:/Work/Computations/out/RayleighBenardMultiGPU/" ); -#else - std::string path( "out/" ); -#endif - - std::string simulationName ( "ThermalCavity3D" ); - - if(fine) simulationName += "_fine"; - else simulationName += "_coarse"; - - ////////////////////////////////////////////////////////////////////////// - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + "_rank_" + std::to_string(rank) + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - ////////////////////////////////////////////////////////////////////////// - - // Important: for Cuda-Aware MPI the device must be set before MPI_Init() - int deviceCount = GksGpu::CudaUtility::getCudaDeviceCount(); - - if(deviceCount == 0) - { - std::stringstream msg; - msg << "No devices devices found!" << std::endl; - *logging::out << logging::Logger::WARNING << msg.str(); msg.str(""); - } - - GksGpu::CudaUtility::setCudaDevice( rank % deviceCount ); - - ////////////////////////////////////////////////////////////////////////// - -#ifndef _WIN32 - MPI_Init(&argc, &argv); -#endif - - ////////////////////////////////////////////////////////////////////////// - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precision\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - uint restartIter = INVALID_INDEX; - - if( argc > 1 ) restartIter = atoi( argv[1] ); - - simulation(path, simulationName, fine, restartIter); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - logFile.close(); - - MPI_Finalize(); - - return 0; -} diff --git a/apps/gpu/GKS/Room/3rdPartyLinking.cmake b/apps/gpu/GKS/Room/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/Room/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/Room/CMakeLists.txt b/apps/gpu/GKS/Room/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/Room/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/Room/CMakePackage.cmake b/apps/gpu/GKS/Room/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/Room/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/Room/Room.cpp b/apps/gpu/GKS/Room/Room.cpp deleted file mode 100644 index cfd245afe481b1ed2e860bca00c164fec2a74d59..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/Room/Room.cpp +++ /dev/null @@ -1,340 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void thermalCavity( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 128; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 4.0; - real H = 3.0; - - real dx = H / real(nx); - - - real Ra = 1.0e9; - - real Ba = 0.1; - real eps = 1.2; - real Pr = 0.71; - real K = 2.0; - - real g = 9.81; - real rho = 1.2; - - real lambda = Ba / ( 2.0 * g * H ); - real lambdaHot = lambda / ( 1.0 + eps * 0.5 ); - real lambdaCold = lambda / ( 1.0 - eps * 0.5 ); - - real mu = sqrt( Pr * eps * g * H * H * H / Ra ) * rho; - - real cs = sqrt( ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( 2.0 * lambda ) ); - real U = sqrt( Ra ) * mu / ( rho * L ); - - real CFL = 0.25; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " kg/sm\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = -g; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //gridBuilder->addCoarseGrid(-0.5*L, -0.5*L, -0.5*H, - // 0.5*L, 0.5*L, 0.5*H, dx); - - gridBuilder->addCoarseGrid(-0.5*L, -0.5*L, 0.0, - 0.5*L, 0.5*L, H , dx); - - Sphere sphere ( 0.0, 0.0, 0.0, 0.6 ); - VerticalCylinder cylinder( 0.0, 0.0, 0.0, 0.6, 2.0*H ); - - //gridBuilder->addGrid( &refRegion_1, 1); - //gridBuilder->addGrid( &refRegion_2, 2); - //gridBuilder->addGrid( &refRegion_3, 3); - //gridBuilder->addGrid( &refRegion_4, 4); - - gridBuilder->setNumberOfLayers(0,10); - - gridBuilder->addGrid( &sphere, 2 ); - //gridBuilder->addGrid( &cylinder, 2 ); - - gridBuilder->setPeriodicBoundaryCondition(false, false, false); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - //meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - SPtr<BoundaryCondition> bcPX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - //SPtr<BoundaryCondition> bcMX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - - bcMX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - SPtr<BoundaryCondition> bcPY = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - //SPtr<BoundaryCondition> bcMY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - //SPtr<BoundaryCondition> bcPY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - - bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.5*L; } ); - bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), true ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), true ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, true ); - //SPtr<BoundaryCondition> bcPZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, true ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < 0.0; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > H ; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> hotPlate = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaHot, true ); - - hotPlate->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - //return center.z < 0.0 && - // std::fabs(center.x) < 0.5 && - // std::fabs(center.y) < 0.5; - - return center.z < 0.0 && std::sqrt(center.x*center.x + center.y*center.y) < 0.5; - } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( hotPlate ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables{ - - real rhoLocal = rho * std::exp( - ( 2.0 * g * H * lambdaCold ) * cellCenter.z / H ); - - return toConservedVariables( PrimitiveVariables( rhoLocal, 0.0, 0.0, 0.0, lambdaCold ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, 0 ); - - Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase ); - - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 50000 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= 100000000; iter++ ) - { - if( iter < 20000 ) - { - std::dynamic_pointer_cast<IsothermalWall>(hotPlate)->lambda = lambdaCold + ( lambdaHot - lambdaCold ) * ( real(iter) / 20000.0 ); - } - else - { - std::dynamic_pointer_cast<IsothermalWall>(hotPlate)->lambda = lambdaHot; - } - - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( - //( iter < 10 && iter % 1 == 0 ) || - //( iter < 100 && iter % 10 == 0 ) || - //( iter < 1000 && iter % 100 == 0 ) || - //( iter < 10000 && iter % 1000 == 0 ) || - //( iter < 10000000 && iter % 100000 == 0 ) - ( iter >= 10000 && iter % 100000 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - cupsAnalyzer.run( iter ); - - convergenceAnalyzer.run( iter ); - - //turbulenceAnalyzer->run( iter, parameters ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - //turbulenceAnalyzer->download(); - - //writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); -} - -int main( int argc, char* argv[]) -{ - //std::string path( "F:/Work/Computations/out/" ); - std::string path( "out/" ); - std::string simulationName ( "Room" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - thermalCavity( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/GKS/RoomFire/3rdPartyLinking.cmake b/apps/gpu/GKS/RoomFire/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RoomFire/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/RoomFire/CMakeLists.txt b/apps/gpu/GKS/RoomFire/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RoomFire/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/RoomFire/CMakePackage.cmake b/apps/gpu/GKS/RoomFire/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RoomFire/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/RoomFire/RoomFire.cpp b/apps/gpu/GKS/RoomFire/RoomFire.cpp deleted file mode 100644 index 814c8fcfe40bb17775897f10eb971d0a463e847a..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RoomFire/RoomFire.cpp +++ /dev/null @@ -1,489 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" -#include "GridGenerator/geometries/TriangularMesh/TriangularMesh.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" -#include "GksGpu/FlowStateData/ThermalDependencies.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure2.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" -#include "GksGpu/BoundaryConditions/HeatFlux.h" -#include "GksGpu/BoundaryConditions/CreepingMassFlux.h" -#include "GksGpu/BoundaryConditions/Open.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/Restart/Restart.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void thermalCavity( std::string path, std::string simulationName, uint restartIter ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 128; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 3.0; - real H = 3.0; - real W = 0.125; - - real LBurner = 1.0; - - real HBurner = 0.5; - - real dx = H / real(nx); - - real Pr = 0.71; - real K = 5.0; - - real g = 9.81; - real rho = 1.2; - - PrimitiveVariables prim( rho, 0.0, 0.0, 0.0, -1.0 ); - setLambdaFromT( prim, 3.0 ); - - real mu = 1.5e-4; - - real cs = sqrt( ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( 2.0 * prim.lambda ) ); - real U = 0.0125; - - real CFL = 0.125; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "cs = " << cs << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " kg/sm\n"; - - *logging::out << logging::Logger::INFO_HIGH << "HRR = " << U * rho * LBurner * LBurner * 800000.0 / 0.016 / 1000.0 << " kW\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.D = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = -g; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = prim.lambda; - - //parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - parameters.viscosityModel = ViscosityModel::constant; - - parameters.enableReaction = true; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - bool threeDimensional = true; - - if( threeDimensional ) - gridBuilder->addCoarseGrid(-0.5*L, -0.5*L, 0.0, - 0.5*L, 0.5*L, H , dx); - else - gridBuilder->addCoarseGrid(-0.5*L, -0.5*dx, 0.0, - 0.5*L, 0.5*dx, H , dx); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//#ifdef _WIN32 -// //TriangularMesh* stl = TriangularMesh::make("F:/Work/Computations/inp/Unterzug.stl"); -// TriangularMesh* stl = TriangularMesh::make("F:/Work/Computations/inp/UnterzugObstacle.stl"); -//#else -// //TriangularMesh* stl = TriangularMesh::make("inp/Unterzug.stl"); -// TriangularMesh* stl = TriangularMesh::make("inp/UnterzugObstacle.stl"); -//#endif - - //gridBuilder->addGeometry(stl); - - Cuboid box( -0.5 * LBurner, -0.5 * LBurner, -HBurner, - 0.5 * LBurner, 0.5 * LBurner, HBurner ); - Cuboid beam( -0.15, -10.0, 2.6, 0.15, 10.0, 10.0 ); - - Conglomerate solid; - - solid.add(&box); - solid.add(&beam); - - gridBuilder->addGeometry(&solid); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - Cuboid boxRefCoarse1 ( -0.8 * LBurner, -0.8 * LBurner, -100.0, - 0.8 * LBurner, 0.8 * LBurner, 100.0 ); - Cuboid boxRefCoarse2 ( -0.8 * LBurner, -100, 2.3, - 0.8 * LBurner, 100, 100.0 ); - - Conglomerate refRegionCoarse; - - refRegionCoarse.add( &boxRefCoarse1 ); - refRegionCoarse.add( &boxRefCoarse2 ); - - gridBuilder->setNumberOfLayers(0,20); - - gridBuilder->addGrid( &refRegionCoarse, 1 ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - Cuboid boxRef ( -0.5 * LBurner, -0.5 * LBurner, -HBurner, - 0.5 * LBurner, 0.5 * LBurner, HBurner ); - Cuboid beamRef( -0.15, -10.0, 2.6, 0.15, 10.0, 10.0 ); - - boxRef.scale (0.1); - beamRef.scale(0.02); - - Conglomerate refRegion1; - - refRegion1.add( &boxRef ); - refRegion1.add( &beamRef ); - - gridBuilder->setNumberOfLayers(0,20); - - gridBuilder->addGrid( &refRegion1, 3 ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if( threeDimensional ) - gridBuilder->setPeriodicBoundaryCondition(false, false, false); - else - gridBuilder->setPeriodicBoundaryCondition(false, true, false); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - if( !threeDimensional ) - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - SPtr<BoundaryCondition> bcPX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - //SPtr<BoundaryCondition> bcMX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - - bcMX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY; - SPtr<BoundaryCondition> bcPY; - - if( threeDimensional ) - { - bcMY = std::make_shared<AdiabaticWall>(dataBase, Vec3(0.0, 0.0, 0.0), false); - bcPY = std::make_shared<AdiabaticWall>(dataBase, Vec3(0.0, 0.0, 0.0), false); - - bcMY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y < -0.5*L; }); - bcPY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y > 0.5*L; }); - } - else - { - bcMY = std::make_shared<Periodic>(dataBase); - bcPY = std::make_shared<Periodic>(dataBase); - - bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.5*dx; } ); - bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*dx; } ); - } - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), true ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), true ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, true ); - //SPtr<BoundaryCondition> bcPZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, true ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < 0.5; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > H ; } ); - - ////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcBurner = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), 0.5*prim.lambda, 0.0, true ); - //SPtr<BoundaryCondition> bcBurner = std::make_shared<HeatFlux>( dataBase, 100.0 ); - SPtr<BoundaryCondition> bcBurner = std::make_shared<CreepingMassFlux>( dataBase, rho, U, prim.lambda ); - - bcBurner->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - - if( threeDimensional ) - return center.z > HBurner - 0.125 * dx && center.z < HBurner && std::sqrt(center.x*center.x) < 0.5 * LBurner - dx && std::sqrt(center.y*center.y) < 0.5 * LBurner - dx; - else - return center.z > HBurner - 0.125 * dx && center.z < HBurner && std::sqrt(center.x*center.x) < 0.5 * LBurner - dx && std::sqrt(center.y*center.y) < 0.5 * dx; - } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcSolid = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), true ); - - bcSolid->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - - return center.z > 2.5 && std::sqrt(center.x*center.x) < 0.15; - } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcWindowOpen = std::make_shared<Open>( dataBase, prim, 1.0 ); - - bcWindowOpen->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - - return center.z > 1.0 && center.z < 2.0 && std::sqrt(center.x*center.x) > 1.5 && std::sqrt(center.y*center.y) < 1.0; - } ); - - SPtr<BoundaryCondition> bcWindowPressure = std::make_shared<Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - - bcWindowPressure->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - - return center.z > 2.0 && center.z < 2.8 && std::sqrt(center.x*center.x) > 1.5 && std::sqrt(center.y*center.y) < 1.0; - } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcBurner ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcSolid ); - - dataBase->boundaryConditions.push_back( bcWindowOpen ); - dataBase->boundaryConditions.push_back( bcWindowPressure ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint startIter = 0; - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - if( restartIter == INVALID_INDEX ) - { - Initializer::interpret(dataBase, [&](Vec3 cellCenter) -> ConservedVariables { - - //real rhoLocal = rho * std::exp(-(2.0 * g * H * prim.lambda) * cellCenter.z / H); - - //prim.rho = rhoLocal; - - //real r = sqrt(cellCenter.x * cellCenter.x + cellCenter.y * cellCenter.y + cellCenter.z * cellCenter.z); - - //if( r < 0.55 ) prim.S_2 = 1.0; - - return toConservedVariables(prim, parameters.K); - }); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - } - else - { - Restart::readRestart( dataBase, path + simulationName + "_" + std::to_string( restartIter ), startIter ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( restartIter ) + "_restart" ); - } - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, level ); - - Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0, true, 1000 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase, 1000 ); - - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 50000 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = startIter + 1; iter <= 100000000; iter++ ) - { - if( iter < 10000 ) - { - //std::dynamic_pointer_cast<PassiveScalarDiriclet>(burner)->S_1 = 10.0 * ( real(iter) / 20000.0 ); - - //parameters.mu = mu + 10.0 * mu * ( 1.0 - ( real(iter) / 10000.0 ) ); - - //parameters.dt = 0.2 * dt + ( dt - 0.2 * dt ) * ( real(iter) / 40000.0 ); - } - - cupsAnalyzer.run( iter ); - - convergenceAnalyzer.run( iter ); - - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( - //( iter >= 34920 && iter % 1 == 0 ) || - //( iter >= 35900 && iter % 10 == 0 ) || - ( iter % 1000 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - if( iter % 1000 == 0 ) - { - Restart::writeRestart( dataBase, path + simulationName + "_" + std::to_string( iter ), iter ); - } - - //turbulenceAnalyzer->run( iter, parameters ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - //turbulenceAnalyzer->download(); - - //writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); -} - -int main( int argc, char* argv[]) -{ - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/RoomFire/" ); -#else - std::string path( "out/" ); -#endif - - std::string simulationName ( "RoomFire" ); - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precision\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - uint restartIter = INVALID_INDEX; - //uint restartIter = 35000; - - if( argc > 1 ) restartIter = atoi( argv[1] ); - - thermalCavity( path, simulationName, restartIter ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - logFile.close(); - - return 0; -} diff --git a/apps/gpu/GKS/RoomFireExtended/3rdPartyLinking.cmake b/apps/gpu/GKS/RoomFireExtended/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RoomFireExtended/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/RoomFireExtended/CMakeLists.txt b/apps/gpu/GKS/RoomFireExtended/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RoomFireExtended/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/RoomFireExtended/CMakePackage.cmake b/apps/gpu/GKS/RoomFireExtended/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RoomFireExtended/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/RoomFireExtended/RoomFireExtended.cpp b/apps/gpu/GKS/RoomFireExtended/RoomFireExtended.cpp deleted file mode 100644 index 77b8c2bc53721a5f455254ebbec58a47ce36eca6..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RoomFireExtended/RoomFireExtended.cpp +++ /dev/null @@ -1,795 +0,0 @@ - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// || || || |||||| |||||||| || || |||||||| || -// || || || || || || || || || || || -// || || || |||||| || || || |||||||| || -// || || || || || || |||||| || || |||||| |||||| || |||||| |||||| |||||| -// || || || || || || || ||| || -// |||| ||||||||||||||||||||||||||||||||||||||||||||||||||||||| || |||||| |||||| ||| -// || || || || || || ||| -// i R M B @ T U B r a u n s c h w e i g || || || || |||||| ||||||| -// -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <sstream> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> -#include <algorithm> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" -#include "GridGenerator/geometries/TriangularMesh/TriangularMesh.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GridGenerator/utilities/communication.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" -#include "GksGpu/FlowStateData/ThermalDependencies.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure2.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" -#include "GksGpu/BoundaryConditions/HeatFlux.h" -#include "GksGpu/BoundaryConditions/CreepingMassFlux.h" -#include "GksGpu/BoundaryConditions/ConcreteHeatFlux.h" -#include "GksGpu/BoundaryConditions/Open.h" - -#include "GksGpu/Communication/Communicator.h" -#include "GksGpu/Communication/MpiUtility.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" -#include "GksGpu/Analyzer/PointTimeSeriesCollector.h" - -#include "GksGpu/Restart/Restart.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -real getHRR( real t ); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// from https://stackoverflow.com/questions/865668/how-to-parse-command-line-arguments-in-c -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -char* getCmdOption(char ** begin, char ** end, const std::string & option) -{ - char ** itr = std::find(begin, end, option); - if (itr != end && ++itr != end) - { - return *itr; - } - return 0; -} - -bool cmdOptionExists(char** begin, char** end, const std::string& option) -{ - return std::find(begin, end, option) != end; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void thermalCavity( std::string path, std::string simulationName, uint windowIndex, uint restartIter, bool useConreteHeatFluxBC ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - int mpiWorldSize = 1; - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - int sideLengthX, sideLengthY, sideLengthZ, rankX, rankY, rankZ; - - if (mpiWorldSize == 1 ) { sideLengthX = 1; sideLengthY = 1; sideLengthZ = 1; } - else if (mpiWorldSize == 2 ) { sideLengthX = 2; sideLengthY = 1; sideLengthZ = 1; } - else if (mpiWorldSize == 4 ) { sideLengthX = 2; sideLengthY = 2; sideLengthZ = 1; } - else if (mpiWorldSize == 8 ) { sideLengthX = 2; sideLengthY = 2; sideLengthZ = 2; } - - rankX = rank % sideLengthX; - rankY = ( rank % ( sideLengthX * sideLengthY ) ) / sideLengthX; - rankZ = rank / ( sideLengthY * sideLengthX ); - - *logging::out << logging::Logger::INFO_HIGH << "SideLength = " << sideLengthX << " " << sideLengthY << " " << sideLengthZ << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "rank = " << rankX << " " << rankY << " " << rankZ << "\n"; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real dx = 0.1; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 4.0; - real B = 3.0; - - real LBurner = 1.0; - real HBurner = 0.5; - - real Pr = 0.71; - real K = 2.0; - - real g = 9.81; - real rho = 1.2; - - PrimitiveVariables prim( rho, 0.0, 0.0, 0.0, -1.0 ); - setLambdaFromT( prim, 3.0 ); - - real cs = sqrt( ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( 2.0 * prim.lambda ) ); - - real mu = 1.8e-5; - //real U = 0.025; // 750 kW on top - //real U = 0.015; // 900 kW on top - //real U = 0.005; // 900 kW all around - real rhoFuel = 0.5405; - - real heatOfReaction = real(8000.0); // J / mol - - real specificHeatOfReaction = heatOfReaction / 0.016; - - real HRR = 750.0; // kW - - real U = HRR * 1000.0 / ( rhoFuel * LBurner * LBurner * (specificHeatOfReaction * 100.0) ); - - real CFL = 0.125; - - real dt = CFL * ( dx / ( ( U + cs ) * ( c1o1 + ( c2o1 * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "cs = " << cs << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " kg/sm\n"; - - //*logging::out << logging::Logger::INFO_HIGH << "HRR = " << U * rhoFuel * LBurner * LBurner * (heatOfReaction * 100.0) / 0.016 / 1000.0 << " kW\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.D = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = -g; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = prim.lambda; - - parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - //parameters.viscosityModel = ViscosityModel::constant; - - parameters.enableReaction = true; - - parameters.heatOfReaction = heatOfReaction; - - parameters.useHeatReleaseRateLimiter = true; - parameters.useTemperatureLimiter = true; - parameters.usePassiveScalarLimiter = true; - parameters.useSmagorinsky = true; - - parameters.reactionLimiter = 1.0005; - parameters.temperatureLimiter = 1.0e-3; - - parameters.useSpongeLayer = true; - parameters.spongeLayerIdx = 2; - - parameters.forcingSchemeIdx = 2; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->addCoarseGrid(-2.1, -1.6, -0.1, - 2.1, 6.0, 5.0, dx); - //gridBuilder->addCoarseGrid(-1.1, -1.2, -0.1, - //1.1, 1.2, 2.2, dx); - //gridBuilder->addCoarseGrid(-2.1, -1.6, -0.1, - //2.1, 1.6, 3.1, dx); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//#ifdef _WIN32 -// TriangularMesh* stl = TriangularMesh::make("F:/Work/Computations/inp/RoomExtended7.stl"); -//#else -// //TriangularMesh* stl = TriangularMesh::make("inp/Unterzug.stl"); -// TriangularMesh* stl = TriangularMesh::make("inp/RoomExtended4.stl"); -//#endif -// -// gridBuilder->addGeometry(stl); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - Conglomerate flowDomain; - - flowDomain.add( new Cuboid( -2.0, -1.5, 0.0, 2.0, 1.5, 3.0 ) ); // Room - flowDomain.add( new Cuboid( -2.0, 1.8, 0.0, 2.0, 5.0, 5.0 ) ); // Outside - //flowDomain.add( new Cuboid( -0.5, -1.8, 0.0, 0.5, -1.0, 2.0 ) ); // Door - flowDomain.subtract( new Cuboid( -0.5, -0.5, -1.0, 0.5, 0.5, 0.5 ) ); // Fire - flowDomain.subtract( new Cuboid( -3.0, -0.1, 2.6, 3.0, 0.1, 4.0 ) ); // Beam - - if( windowIndex == 0 ) flowDomain.add( new Cuboid( -1.0 , 1.0, 1.0, 1.0 , 3.0, 2.4 ) ); // Window large - if( windowIndex == 1 ) flowDomain.add( new Cuboid( -0.5 , 1.0, 1.0, 0.5 , 3.0, 2.4 ) ); // Window medium - if( windowIndex == 2 ) flowDomain.add( new Cuboid( -0.25, 1.0, 1.5, 0.25, 3.0, 2.0 ) ); // Window small - if( windowIndex == 3 ) flowDomain.add( new Cuboid( -1.0 , 1.0, 1.0, 1.0 , 3.0, 2.0 ) ); // Window low - - Conglomerate solidDomain; - - solidDomain.add( new Cuboid(-2.2, -1.7, -0.2, 2.2, 6.1, 5.1) ); - solidDomain.subtract( &flowDomain ); - - gridBuilder->addGeometry( &solidDomain ); - //gridBuilder->addGeometry( &flowDomain ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - Cuboid boxCoarse ( -2.0, -3.0, -0.5, - 3.0, 3.0, 3.5 ); - - gridBuilder->addGrid( &boxCoarse, 1 ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real startX = -1e99; - real startY = -1e99; - real startZ = -1e99; - real endX = 1e99; - real endY = 1e99; - real endZ = 1e99; - - if( mpiWorldSize == 2 ) - { - if( rank == 0 ) { endX = 0.0; } - if( rank == 1 ) { startX = 0.0; } - } - if( mpiWorldSize == 4 ) - { - if( rank == 0 ) { endX = 0.0; endY = 0.0; } - if( rank == 1 ) { startX = 0.0; endY = 0.0; } - if( rank == 2 ) { endX = 0.0; startY = 0.0; } - if( rank == 3 ) { startX = 0.0; startY = 0.0; } - } - if( mpiWorldSize == 8 ) - { - if( rank == 0 ) { endX = 0.0; endY = 0.0; endZ = 1.9; } - if( rank == 1 ) { startX = 0.0; endY = 0.0; endZ = 1.9; } - if( rank == 2 ) { endX = 0.0; startY = 0.0; endZ = 1.9; } - if( rank == 3 ) { startX = 0.0; startY = 0.0; endZ = 1.9; } - if( rank == 4 ) { endX = 0.0; endY = 0.0; startZ = 1.9; } - if( rank == 5 ) { startX = 0.0; endY = 0.0; startZ = 1.9; } - if( rank == 6 ) { endX = 0.0; startY = 0.0; startZ = 1.9; } - if( rank == 7 ) { startX = 0.0; startY = 0.0; startZ = 1.9; } - } - - auto subDomainBox = std::make_shared<BoundingBox>( startX, endX, - startY, endY, - startZ, endZ ); - - gridBuilder->setSubDomainBox( subDomainBox ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - Cuboid roomRef( -2.1, -1.8, -1.0, - 2.1, 1.7, 10.0 ); - - Cuboid windowRef( -1.1, 1.6, 0.9, - 1.1, 2.0, 3.0 ); - - Conglomerate refRegion1; - - refRegion1.add( &roomRef ); - refRegion1.add( &windowRef ); - - gridBuilder->setNumberOfLayers(0,22); - - //gridBuilder->addGrid( &refRegion1, 2 ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - Cuboid boxRef ( -0.6 * LBurner, -0.6 * LBurner, -1.0, - 0.6 * LBurner, 0.6 * LBurner, 10.0 ); - Cuboid beamRef( -10.0, -0.25, 2.4, 10.0, 0.25, 10.0 ); - - Conglomerate refRegion2; - - refRegion2.add( &boxRef ); - refRegion2.add( &beamRef ); - - gridBuilder->setNumberOfLayers(0,22); - - gridBuilder->addGrid( &refRegion2, 2 ); - //gridBuilder->addGrid( &refRegion2, 3 ); - - uint maxLevel = gridBuilder->getNumberOfGridLevels() - 1; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->setPeriodicBoundaryCondition(false, false, false); - - gridBuilder->buildGrids(GKS, false); - - MPI_Barrier(MPI_COMM_WORLD); - - //gridBuilder->writeGridsToVtk(path + "Grid_rank_" + std::to_string( rank ) + "_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - if( mpiWorldSize > 1 ) - { - int rankPX = ( (rankX + 1 + sideLengthX) % sideLengthX ) + rankY * sideLengthX + rankZ * sideLengthX * sideLengthY; - int rankMX = ( (rankX - 1 + sideLengthX) % sideLengthX ) + rankY * sideLengthX + rankZ * sideLengthX * sideLengthY; - int rankPY = rankX + ( (rankY + 1 + sideLengthY) % sideLengthY ) * sideLengthX + rankZ * sideLengthX * sideLengthY; - int rankMY = rankX + ( (rankY - 1 + sideLengthY) % sideLengthY ) * sideLengthX + rankZ * sideLengthX * sideLengthY; - int rankPZ = rankX + rankY * sideLengthX + ( (rankZ + 1 + sideLengthZ) % sideLengthZ ) * sideLengthX * sideLengthY; - int rankMZ = rankX + rankY * sideLengthX + ( (rankZ - 1 + sideLengthZ) % sideLengthZ ) * sideLengthX * sideLengthY; - - if( sideLengthX > 1 && rankX < sideLengthX-1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PX, GKS ); - if( sideLengthX > 1 && rankX < sideLengthX-1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::PX, rankPX); - - if( sideLengthX > 1 && rankX > 0 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MX, GKS ); - if( sideLengthX > 1 && rankX > 0 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::MX, rankMX); - - if( sideLengthY > 1 && rankY < sideLengthY-1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PY, GKS ); - if( sideLengthY > 1 && rankY < sideLengthY-1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::PY, rankPY); - - if( sideLengthY > 1 && rankY > 0 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MY, GKS ); - if( sideLengthY > 1 && rankY > 0 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::MY, rankMY); - - if( sideLengthZ > 1 && rankZ < sideLengthZ-1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PZ, GKS ); - if( sideLengthZ > 1 && rankZ < sideLengthZ-1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::PZ, rankPZ); - - if( sideLengthZ > 1 && rankZ > 0 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MZ, GKS ); - if( sideLengthZ > 1 && rankZ > 0 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::MZ, rankMZ); - - *logging::out << logging::Logger::INFO_HIGH << "neighborRanks = " << rankPX << " " << rankMX << " " << rankPY << " " << rankMY << " " << rankPZ << " " << rankMZ << "\n"; - } - - //gridBuilder->writeGridsToVtk(path + "Grid_rank_" + std::to_string( rank ) + "_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "MeshFaces_rank_" + std::to_string( rank ) + ".vtk" ); - - //meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //CudaUtility::setCudaDevice( rank % CudaUtility::getCudaDeviceCount() ); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcWall = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - - bcWall->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return true; } ); - - SPtr<BoundaryCondition> bcWallHeatFlux = std::make_shared<ConcreteHeatFlux>( dataBase, 64, 1.0e-6, 2400.0, 880, 0.1, 3.0 ); - - bcWallHeatFlux->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return (center.z > 3.0 && center.y < 1.6) - || (center.x > 2.0 && center.y > -1.5 && center.y < 1.5 & center.z < 3.0 && center.z > 0.0) - || (center.x < -2.0 && center.y > -1.5 && center.y < 1.5 & center.z < 3.0 && center.z > 0.0) - || (center.y < -1.5) - || (center.y > 1.5 && center.y < 1.6); } ); - - std::dynamic_pointer_cast<ConcreteHeatFlux>(bcWallHeatFlux)->init(); - - //////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcOpen = std::make_shared<Open>( dataBase, prim, 1.0 ); - - bcOpen->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -6.0 || center.y > 1.7; } ); - - //////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcPressure = std::make_shared<Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - - bcPressure->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 1.7 && center.z > 5.0; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcBurner = std::make_shared<CreepingMassFlux>( dataBase, rhoFuel, U, prim.lambda ); - - bcBurner->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - - return center.z < HBurner && - std::sqrt(center.x*center.x) < 0.5 * LBurner - dx * std::pow(0.5, maxLevel) && - std::sqrt(center.y*center.y) < 0.5 * LBurner - dx * std::pow(0.5, maxLevel); - //return center.z < HBurner && std::sqrt(center.x*center.x) < 0.5 * LBurner && std::sqrt(center.y*center.y) < 0.5 * LBurner; - } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcBurner ); - - if( useConreteHeatFluxBC ) - dataBase->boundaryConditions.push_back( bcWallHeatFlux ); - - dataBase->boundaryConditions.push_back( bcWall ); - - dataBase->boundaryConditions.push_back( bcOpen ); - - dataBase->boundaryConditions.push_back( bcPressure ); - - *logging::out << logging::Logger::INFO_HIGH << "Number of cells bcBurner = " << bcBurner->numberOfCells << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "Number of cells bcWall = " << bcWall->numberOfCells << "\n"; - - *logging::out << logging::Logger::INFO_HIGH << "Number of cells bcOpen = " << bcOpen->numberOfCells << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "Number of cells bcPressure = " << bcPressure->numberOfCells << "\n"; - - ////////////////////////////////////////////////////////////////////////// - - auto pointTimeSeriesCollector = std::make_shared<PointTimeSeriesCollector>(); - - for( real x = 0.0002; x < 2; x += 0.4449 ) - { - if( subDomainBox->isInside( x, -1.4999, 2.9999 ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( x, -1.4999, 2.9999 ), 'T' ); - if( subDomainBox->isInside( x, -1.0, 2.9999 ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( x, -1.0, 2.9999 ), 'T' ); - if( subDomainBox->isInside( x, -0.5, 2.9999 ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( x, -0.5, 2.9999 ), 'T' ); - if( subDomainBox->isInside( x, -0.2001, 2.9999 ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( x, -0.2001, 2.9999 ), 'T' ); - - if( subDomainBox->isInside( x, -0.2001, 2.5999 ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( x, -0.2001, 2.5999 ), 'T' ); - if( subDomainBox->isInside( x, 0.0001, 2.5999 ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( x, 0.0001, 2.5999 ), 'T' ); - if( subDomainBox->isInside( x, 0.2001, 2.5999 ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( x, 0.2001, 2.5999 ), 'T' ); - - if( subDomainBox->isInside( x, 0.2001, 2.9999 ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( x, 0.2001, 2.9999 ), 'T' ); - if( subDomainBox->isInside( x, 0.5, 2.9999 ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( x, 0.5, 2.9999 ), 'T' ); - if( subDomainBox->isInside( x, 1.0, 2.9999 ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( x, 1.0, 2.9999 ), 'T' ); - if( subDomainBox->isInside( x, 1.4999, 2.9999 ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( x, 1.4999, 2.9999 ), 'T' ); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint startIter = 0; - - dataBase->setMesh( meshAdapter ); - - dataBase->setCommunicators( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - if( restartIter == INVALID_INDEX ) - { - Initializer::interpret(dataBase, [&](Vec3 cellCenter) -> ConservedVariables { - - PrimitiveVariables primLocal = prim; - - //if( cellCenter.x > 0 ) primLocal.rho = 1.21; - - primLocal.lambda *= 0.5; - - return toConservedVariables(primLocal, parameters.K); - }); - - if (rank == 0) writeVtkXMLParallelSummaryFile(dataBase, parameters, path + simulationName + "_0", mpiWorldSize); - - writeVtkXML(dataBase, parameters, 0, path + simulationName + "_0" + "_rank_" + std::to_string(rank)); - - if( useConreteHeatFluxBC ) - writeConcreteHeatFluxVtkXML( dataBase, std::dynamic_pointer_cast<ConcreteHeatFlux>(bcWallHeatFlux), parameters, 0, path + simulationName + "_Solid_0" ); - } - else - { - Restart::readRestart( dataBase, path + simulationName + "_" + std::to_string( restartIter ) + "_rank_" + std::to_string(rank), startIter ); - - if (rank == 0) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_" + std::to_string( restartIter ) + "_restart", mpiWorldSize ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( restartIter ) + "_restart" + "_rank_" + std::to_string(rank) ); - } - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, level ); - - Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0, true, 10000 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase, 10000 ); - - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 50000 ); - - ////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_HIGH << "================================================================================\n"; - *logging::out << logging::Logger::INFO_HIGH << "================================================================================\n"; - *logging::out << logging::Logger::INFO_HIGH << "================== S t a r t T i m e S t e p p i n g =================\n"; - *logging::out << logging::Logger::INFO_HIGH << "================================================================================\n"; - *logging::out << logging::Logger::INFO_HIGH << "================================================================================\n"; - - MPI_Barrier(MPI_COMM_WORLD); - - cupsAnalyzer.start(); - - for( uint iter = startIter + 1; iter <= 100000000; iter++ ) - { - real currentHRR = getHRR( iter * parameters.dt ); - - //*logging::out << logging::Logger::LOGGER_ERROR << "HRR(t=" << iter * parameters.dt << ") = " << currentHRR << "\n"; - - std::dynamic_pointer_cast<CreepingMassFlux>(bcBurner)->velocity = currentHRR * 1000.0 / ( rhoFuel * LBurner * LBurner * (specificHeatOfReaction * 100.0) ); - - ////////////////////////////////////////////////////////////////////////// - - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.run( iter, parameters.dt ); - - convergenceAnalyzer.run( iter ); - - ////////////////////////////////////////////////////////////////////////// - - pointTimeSeriesCollector->run(iter, parameters); - - int crashCellIndex = dataBase->getCrashCellIndex(); - if( crashCellIndex >= 0 ) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Simulation Crashed at CellIndex = " << crashCellIndex << "\n"; - dataBase->copyDataDeviceToHost(); - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - - break; - } - - if( iter % 1000 == 0 ) - { - dataBase->copyDataDeviceToHost(); - - if( rank == 0 ) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_" + std::to_string( iter ), mpiWorldSize ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) + "_rank_" + std::to_string(rank) ); - - if( useConreteHeatFluxBC ) - //std::dynamic_pointer_cast<ConcreteHeatFlux>(bcWallHeatFlux)->writeVTKFile(dataBase, parameters, path + simulationName + "_Solid_" + std::to_string( iter )); - writeConcreteHeatFluxVtkXML( dataBase, std::dynamic_pointer_cast<ConcreteHeatFlux>(bcWallHeatFlux), parameters, 0, path + simulationName + "_Solid_" + std::to_string( iter ) ); - } - - if( iter % 10000 == 0 ) - { - Restart::writeRestart( dataBase, path + simulationName + "_" + std::to_string( iter ) + "_rank_" + std::to_string(rank), iter ); - } - - if( iter % 100000 == 0 ) - { - pointTimeSeriesCollector->writeToFile(path + simulationName + "_TimeSeries_" + std::to_string( iter ) + "_rank_" + std::to_string(rank)); - } - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - //turbulenceAnalyzer->download(); - - //writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); -} - -int main( int argc, char* argv[]) -{ - MPI_Init(&argc, &argv); - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - int mpiWorldSize = 1; - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); - - ////////////////////////////////////////////////////////////////////////// - - uint restartIter = INVALID_INDEX; - //uint restartIter = 140000; - - uint windowIndex = 2; - - bool useConcreteHeatFluxBC = true; - - uint defaultDevice = 0; - - ////////////////////////////////////////////////////////////////////////// - - if( cmdOptionExists(argv, argv+argc, "-w" ) ) - windowIndex = atoi( getCmdOption(argv, argv+argc, "-w") ); - - if( cmdOptionExists(argv, argv+argc, "--useConcreteHeatFlux" ) ) - useConcreteHeatFluxBC = true; - - if( cmdOptionExists(argv, argv+argc, "-r" ) ) - restartIter = atoi( getCmdOption(argv, argv+argc, "-r") ); - - ////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/RoomFireExtended/" ); -#else - std::string path( "out/" ); - - //if( argc > 1 ){ - // path += "Window_"; - // path += argv[1]; - // path += "/"; - //} -#endif - - std::string simulationName ( "RoomFire" ); - - if( useConcreteHeatFluxBC ) simulationName += "_heatFlux"; - else simulationName += "_adiabatic"; - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + "_rank_" + std::to_string(rank) + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - ////////////////////////////////////////////////////////////////////////// - - // Important: for Cuda-Aware MPI the device must be set before MPI_Init() - int deviceCount = CudaUtility::getCudaDeviceCount(); - - if(deviceCount == 0) - { - std::stringstream msg; - msg << "No devices devices found!" << std::endl; - *logging::out << logging::Logger::WARNING << msg.str(); msg.str(""); - } - - if( mpiWorldSize == 1 ) CudaUtility::setCudaDevice( 0 ); - else CudaUtility::setCudaDevice( rank % deviceCount ); - - ////////////////////////////////////////////////////////////////////////// - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precision\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - ////////////////////////////////////////////////////////////////////////// - - try - { - thermalCavity( path, simulationName, windowIndex, restartIter, useConcreteHeatFluxBC ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - logFile.close(); - - MPI_Finalize(); - - return 0; -} - - - - - - -real getHRR( real t ) -{ - // data from - real tInMin_table [] = - { 0.0, - 1.2998404845645375, - 1.8225528293767326, - 2.3411883091040355, - 3.690242379336123, - 5.8053588126615825, - 8.481044195158887, - 9.683816463416616, - 10.268361262016242, - 11.2607867055371, - 13.013838692038146, - 14.302516331727396, - 17.240382966469404, - 20.679801074868717, - 22.9733288897661 }; - - - real HRR_table [] = - { 0.0, - 658.3729425582654, - 590.0388596425946, - 480.1207528610856, - 440.4722692284047, - 414.659889148097, - 406.6507906206217, - 374.9279268493922, - 337.28487256561004, - 260.02439647836513, - 141.15465878904172, - 85.66658361941495, - 51.906257987905406, - 33.97096366089556, - 27.954675614199346 }; - - uint upper = 0; - - if( t / 60.0 > tInMin_table[14] ) return HRR_table[14]; - - while( tInMin_table[upper] < t / 60.0 ) upper++; - - uint lower = upper - 1; - - real HRR = HRR_table[lower] + ( ( t / 60.0 - tInMin_table[lower] )/( tInMin_table[upper] - tInMin_table[lower] ) ) * ( HRR_table[upper] - HRR_table[lower] ); - - return HRR; -} \ No newline at end of file diff --git a/apps/gpu/GKS/RoomMultiGPU/3rdPartyLinking.cmake b/apps/gpu/GKS/RoomMultiGPU/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RoomMultiGPU/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/RoomMultiGPU/CMakeLists.txt b/apps/gpu/GKS/RoomMultiGPU/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RoomMultiGPU/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/RoomMultiGPU/CMakePackage.cmake b/apps/gpu/GKS/RoomMultiGPU/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RoomMultiGPU/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/RoomMultiGPU/RoomMultiGPU.cpp b/apps/gpu/GKS/RoomMultiGPU/RoomMultiGPU.cpp deleted file mode 100644 index 2c92c5f737612167e1f092944c8b32a87f9d7215..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/RoomMultiGPU/RoomMultiGPU.cpp +++ /dev/null @@ -1,522 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" -#include "GridGenerator/geometries/BoundingBox/BoundingBox.h" -#include "GridGenerator/utilities/communication.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" - -#include "GksGpu/Communication/Communicator.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -////////////////////////////////////////////////////////////////////////// -// prescribed parameters -////////////////////////////////////////////////////////////////////////// - -uint nx = 64; - -real L = 4.0; -real H = 3.0; - -real Ra = 1.0e10; - -real Ba = 0.1; -real eps = 1.2; -real Pr = 0.71; -real K = 2.0; - -real g = 9.81; -real rho = 1.2; - -////////////////////////////////////////////////////////////////////////// - -void thermalCavity( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - int mpiWorldSize; - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); - - uint gpuPerNode = 2; - CudaUtility::setCudaDevice(rank % gpuPerNode); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real dx = 1.0 / real(nx); - - real lambda = Ba / ( 2.0 * g * H ); - real lambdaHot = lambda / ( 1.0 + eps * 0.5 ); - real lambdaCold = lambda / ( 1.0 - eps * 0.5 ); - - real mu = sqrt( Pr * eps * g * H * H * H / Ra ) * rho; - - real cs = sqrt( ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( 2.0 * lambda ) ); - real U = sqrt( Ra ) * mu / ( rho * L ); - - real CFL = 0.25; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " kg/sm\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = -g; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // <--X--> <--Y--> <------Z-----> - if( rank == 0 ) gridBuilder->addCoarseGrid( -0.5*L , -0.5*L , 0.0 , - 3.0*dx, 3.0*dx, 0.5*H + 3.0*dx, dx); - - if( rank == 1 ) gridBuilder->addCoarseGrid( -3.0*dx, -0.5*L , 0.0 , - 0.5*L , 3.0*dx, 0.5*H + 3.0*dx, dx); - - if( rank == 2 ) gridBuilder->addCoarseGrid( -0.5*L , -3.0*dx, 0.0 , - 3.0*dx, 0.5*L , 0.5*H + 3.0*dx, dx); - - if( rank == 3 ) gridBuilder->addCoarseGrid( -3.0*dx, -3.0*dx, 0.0 , - 0.5*L , 0.5*L , 0.5*H + 3.0*dx, dx); - - ////////////////////////////////////////////////////////////////////////// - - // <--X--> <--Y--> <------Z-----> - if( rank == 4 ) gridBuilder->addCoarseGrid( -0.5*L , -0.5*L , 0.5*H - 3.0*dx, - 3.0*dx, 3.0*dx, H , dx); - - if( rank == 5 ) gridBuilder->addCoarseGrid( -3.0*dx, -0.5*L , 0.5*H - 3.0*dx, - 0.5*L , 3.0*dx, H , dx); - - if( rank == 6 ) gridBuilder->addCoarseGrid( -0.5*L , -3.0*dx, 0.5*H - 3.0*dx, - 3.0*dx, 0.5*L , H , dx); - - if( rank == 7 ) gridBuilder->addCoarseGrid( -3.0*dx, -3.0*dx, 0.5*H - 3.0*dx, - 0.5*L , 0.5*L , H , dx); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - Sphere sphere ( 0.0, 0.0, 0.0, 0.6 ); - VerticalCylinder cylinder( 0.0, 0.0, 0.0, 0.6, 2.0*H ); - - gridBuilder->setNumberOfLayers(6,10); - - //gridBuilder->addGrid( &sphere, 2 ); - gridBuilder->addGrid( &cylinder, 2 ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if( rank == 0 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( -2.0*L, 0.0, - -2.0*L, 0.0, - -2.0*H, 0.5*H ) ); - - if( rank == 1 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( 0.0 , 2.0*L, - -2.0*L, 0.0, - -2.0*H, 0.5*H ) ); - - if( rank == 2 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( -2.0*L, 0.0, - 0.0 , 2.0*L, - -2.0*H, 0.5*H ) ); - - if( rank == 3 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( 0.0 , 2.0*L, - 0.0 , 2.0*L, - -2.0*H, 0.5*H ) ); - - if( rank == 4 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( -2.0*L, 0.0, - -2.0*L, 0.0, - 0.5*H, 2.0*H ) ); - - if( rank == 5 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( 0.0 , 2.0*L, - -2.0*L, 0.0, - 0.5*H, 2.0*H ) ); - - if( rank == 6 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( -2.0*L, 0.0, - 0.0 , 2.0*L, - 0.5*H, 2.0*H ) ); - - if( rank == 7 ) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( 0.0 , 2.0*L, - 0.0 , 2.0*L, - 0.5*H, 2.0*H ) ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->setPeriodicBoundaryCondition(false, false, false); - - gridBuilder->buildGrids(GKS, false); - - if( rank == 0 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PX, 1); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PY, 2); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PZ, 4); - } - - if( rank == 1 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MX, 0); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PY, 3); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PZ, 5); - } - - if( rank == 2 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PX, 3); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MY, 0); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PZ, 6); - } - - if( rank == 3 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MX, 2); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MY, 1); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PZ, 7); - } - - if( rank == 4 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PX, 5); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PY, 6); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MZ, 0); - } - - if( rank == 5 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MX, 4); - - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PY, 7); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MZ, 1); - } - - if( rank == 6 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::PX, 7); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MY, 4); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MZ, 2); - } - - if( rank == 7 ){ - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MX, 6); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MY, 5); - - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, GKS); - gridBuilder->setCommunicationProcess (CommunicationDirections::MZ, 3); - } - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_rank_" + std::to_string(rank) + "_lev_"); - - MPI_Barrier(MPI_COMM_WORLD); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - meshAdapter.getCommunicationIndices(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - //meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - SPtr<BoundaryCondition> bcPX = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - //SPtr<BoundaryCondition> bcMX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - - bcMX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - SPtr<BoundaryCondition> bcPY = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), false ); - //SPtr<BoundaryCondition> bcMY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - //SPtr<BoundaryCondition> bcPY = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, false ); - - bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.5*L; } ); - bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), true ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0), true ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, true ); - //SPtr<BoundaryCondition> bcPZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, 0.0, true ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < 0.0; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > H ; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> hotPlate = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaHot, true ); - - hotPlate->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - //return center.z < 0.0 && - // std::fabs(center.x) < 0.5 && - // std::fabs(center.y) < 0.5; - - return center.z < 0.0 && std::sqrt(center.x*center.x + center.y*center.y) < 0.5; - } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( hotPlate ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - dataBase->setCommunicators( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables{ - - real rhoLocal = rho * std::exp( - ( 2.0 * g * H * lambdaCold ) * cellCenter.z / H ); - - return toConservedVariables( PrimitiveVariables( rhoLocal, 0.0, 0.0, 0.0, lambdaCold ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, level ); - - Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - if( rank == 0 ) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_0", mpiWorldSize ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" + "_rank_" + std::to_string(rank) ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase ); - - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 50000 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= 100000000; iter++ ) - { - if( iter < 20000 ) - { - std::dynamic_pointer_cast<IsothermalWall>(hotPlate)->lambda = lambdaCold + ( lambdaHot - lambdaCold ) * ( real(iter) / 20000.0 ); - } - else - { - std::dynamic_pointer_cast<IsothermalWall>(hotPlate)->lambda = lambdaHot; - } - - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( - //( iter < 10 && iter % 1 == 0 ) || - //( iter < 100 && iter % 10 == 0 ) || - //( iter < 1000 && iter % 100 == 0 ) || - //( iter < 10000 && iter % 1000 == 0 ) || - //( iter < 10000000 && iter % 100000 == 0 ) - ( iter >= 10000 && iter % 10000 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - - if( rank == 0 ) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_" + std::to_string( iter ), mpiWorldSize ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) + "_rank_" + std::to_string(rank) ); - } - - cupsAnalyzer.run( iter ); - - convergenceAnalyzer.run( iter ); - - //turbulenceAnalyzer->run( iter, parameters ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - //turbulenceAnalyzer->download(); - - //writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); -} - -int main( int argc, char* argv[]) -{ - MPI_Init(&argc, &argv); - - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - //std::string path( "F:/Work/Computations/out/RoomMultiGPU/" ); - std::string path( "out/" ); - std::string simulationName ( "Room" ); - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + "_rank_" + std::to_string(rank) + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - thermalCavity( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - logFile.close(); - - MPI_Finalize(); - - return 0; -} diff --git a/apps/gpu/GKS/SalinasVazquez/3rdPartyLinking.cmake b/apps/gpu/GKS/SalinasVazquez/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/SalinasVazquez/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/SalinasVazquez/CMakeLists.txt b/apps/gpu/GKS/SalinasVazquez/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/SalinasVazquez/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/SalinasVazquez/CMakePackage.cmake b/apps/gpu/GKS/SalinasVazquez/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/SalinasVazquez/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/SalinasVazquez/SalinasVazquez.cpp b/apps/gpu/GKS/SalinasVazquez/SalinasVazquez.cpp deleted file mode 100644 index 1f8f352cac757c7138981d331fd7f7130b9f58a6..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/SalinasVazquez/SalinasVazquez.cpp +++ /dev/null @@ -1,564 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> -#include <thread> -#include <sstream> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" -#include "GridGenerator/geometries/BoundingBox/BoundingBox.h" -#include "GridGenerator/utilities/communication.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" -#include "GksGpu/BoundaryConditions/SalinasVazquez.h" - -#include "GksGpu/Communication/Communicator.h" -#include "GksGpu/Communication/MpiUtility.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/Restart/Restart.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -//uint deviceMap [2] = {2,3}; -uint deviceMap [2] = {0,1}; - -void simulation( std::string path, std::string simulationName, uint restartIter ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - int mpiWorldSize = 1; - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 128; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - real H = 0.25; - - real dx = L / real(nx); - - real Ra = 1.58e9; - - real Ba = 0.1; - real eps = 0.132; - real Pr = 0.71; - real K = 2.0; - - real g = 1.0; - real rho = 1.0; - - real lambda = Ba / ( 2.0 * g * L ); - real lambdaHot = lambda / ( 1.0 + eps * 0.5 ); - real lambdaCold = lambda / ( 1.0 - eps * 0.5 ); - - real mu = sqrt( Pr * eps * g * L * L * L / Ra ) * rho ; - - real cs = sqrt( ( ( K + 4.0 ) / ( K + 2.0 ) ) / ( 2.0 * lambda ) ); - real U = sqrt( Ra ) * mu / ( rho * L ); - - real CFL = 0.25; - - real dt = CFL * ( dx / ( ( U + cs ) * ( c1o1 + ( c2o1 * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " s\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = -g; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - parameters.rhoRef = rho; - - parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - - parameters.useReactionLimiter = false; - parameters.useTemperatureLimiter = false; - parameters.usePassiveScalarLimiter = false; - parameters.useSmagorinsky = true; - - parameters.forcingSchemeIdx = 0; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // M e s h G e n e r a t i o n - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real startX, endX; - real startY, endY; - real startZ, endZ; - - if( rank % 2 == 0 ) startX = -0.5 * L; - else startX = -3.0 * dx; - if( rank % 2 == 0 ) endX = 3.0 * dx; - else endX = 0.5 * L; - - if( mpiWorldSize == 2 ) - { - startY = 0.0; - endY = H; - } - else - { - startY = rank / 2 * H - 3.0 * dx; - endY = (rank / 2 + 1.0) * H + 3.0 * dx; - } - - startZ = -0.5 * L; - endZ = 0.5 * L; - - gridBuilder->addCoarseGrid(startX, startY, startZ, - endX , endY , endZ , dx); - - ////////////////////////////////////////////////////////////////////////// - - //real refL[4] = { 0.30, 0.45, 0.49, 0.4975 }; - real refL[4] = { 0.30, 0.45, 0.475, 0.495 }; - - gridBuilder->setNumberOfLayers(6,6); - - Conglomerate coarseRefLevel; - - - if( rank % 2 == 0 ) coarseRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - -refL[0], 100.0, 100.0 ) ); - else coarseRefLevel.add( new Cuboid ( refL[0], -100.0, -100.0, - 100.0, 100.0, 100.0 ) ); - - coarseRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - 100.0, 100.0, -refL[0] ) ); - coarseRefLevel.add( new Cuboid (-100.0, -100.0, refL[0], - 100.0, 100.0, 100.0 ) ); - - gridBuilder->addGrid( &coarseRefLevel, 1); - - ////////////////////////////////////////////////////////////////////////// - - Conglomerate firstRefLevel; - - if( rank % 2 == 0 ) firstRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - -refL[1], 100.0, 100.0 ) ); - else firstRefLevel.add( new Cuboid ( refL[1], -100.0, -100.0, - 100.0, 100.0, 100.0 ) ); - - firstRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - 100.0, 100.0, -refL[1] ) ); - firstRefLevel.add( new Cuboid (-100.0, -100.0, refL[1], - 100.0, 100.0, 100.0 ) ); - - gridBuilder->addGrid( &firstRefLevel, 2); - - ////////////////////////////////////////////////////////////////////////// - - Conglomerate secondRefLevel; - - if( rank % 2 == 0 ) secondRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - -refL[2], 100.0, 100.0 ) ); - else secondRefLevel.add( new Cuboid ( refL[2], -100.0, -100.0, - 100.0, 100.0, 100.0 ) ); - - if( rank % 2 == 0 ) secondRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - -refL[0], 100.0, -refL[2] ) ); - else secondRefLevel.add( new Cuboid ( refL[0], -100.0, -100.0, - 100.0, 100.0, -refL[2] ) ); - - if( rank % 2 == 0 ) secondRefLevel.add( new Cuboid (-100.0, -100.0, refL[2], - -refL[0], 100.0, 100.0 ) ); - else secondRefLevel.add( new Cuboid ( refL[0], -100.0, refL[2], - 100.0, 100.0, 100.0 ) ); - - gridBuilder->addGrid( &secondRefLevel, 3); - - ////////////////////////////////////////////////////////////////////////// - - //uint numberOfRefinements = 3; - - //for( uint ref = 2; ref < numberOfRefinements; ref++ ) - //{ - // Cuboid* refRegion; - - // if( rank % 2 == 0 ) refRegion = new Cuboid (-100.0, -100.0, -100.0, - // -refL[ref], 100.0, 100.0 ); - // else refRegion = new Cuboid ( refL[ref], -100.0, -100.0, - // 100.0, 100.0, 100.0 ); - - // gridBuilder->addGrid( refRegion, ref + 1); - //} - - ////////////////////////////////////////////////////////////////////////// - - if( rank % 2 == 0 ) startX = -100.0; - else startX = 0.0; - if( rank % 2 == 0 ) endX = 0.0; - else endX = 100.0; - - if( mpiWorldSize == 2 ) - { - startY = -100.0; - endY = 100.0; - } - else - { - startY = real(rank/2) * H; - endY = ( real(rank/2) + 1.0 ) * H; - } - - startZ = -100.0; - endZ = 100.0; - - gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>( startX, endX, - startY, endY, - startZ, endZ ) ); - - ////////////////////////////////////////////////////////////////////////// - - if( mpiWorldSize == 2 ) gridBuilder->setPeriodicBoundaryCondition(false, true, false); - else gridBuilder->setPeriodicBoundaryCondition(false, false, false); - - gridBuilder->buildGrids(GKS, false); - - ////////////////////////////////////////////////////////////////////////// - - if( rank%2 == 0 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PX, GKS ); - else gridBuilder->findCommunicationIndices( CommunicationDirections::MX, GKS ); - - if( rank%2 == 0 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::PX, rank + 1 ); - else gridBuilder->setCommunicationProcess ( CommunicationDirections::MX, rank - 1 ); - - ////////////////////////////////////////////////////////////////////////// - - if( mpiWorldSize > 2 ) - { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, GKS); - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, GKS); - - gridBuilder->setCommunicationProcess(CommunicationDirections::PY, (rank + 2 + mpiWorldSize) % mpiWorldSize); - gridBuilder->setCommunicationProcess(CommunicationDirections::MY, (rank - 2 + mpiWorldSize) % mpiWorldSize); - } - - //gridBuilder->writeGridsToVtk(path + "/Grid_rank_" + std::to_string(rank) + "_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - if( mpiWorldSize == 2 ) meshAdapter.findPeriodicBoundaryNeighbors(); - - meshAdapter.getCommunicationIndices(); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces_" + std::to_string( threadIndex ) + ".vtk" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // B o u n d a r y C o n d i t i o n s - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaHot , false ); - SPtr<BoundaryCondition> bcPX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, false ); - - bcMX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<SalinasVazquez>( dataBase, lambdaHot, lambdaCold, 0.3371, -0.2642, 0.5301, -2.6438, true ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<SalinasVazquez>( dataBase, lambdaHot, lambdaCold, 0.6559, -0.2037, -0.5420, -2.7318, true ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*L; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - if( mpiWorldSize == 2 ) - { - SPtr<BoundaryCondition> bcMY = std::make_shared<Periodic>(dataBase); - SPtr<BoundaryCondition> bcPY = std::make_shared<Periodic>(dataBase); - - bcMY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y < 0; }); - bcPY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y > H; }); - - dataBase->boundaryConditions.push_back(bcMY); - dataBase->boundaryConditions.push_back(bcPY); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // I n i t i a l C o n d i t i o n s - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint startIter = 0; - - dataBase->setMesh( meshAdapter ); - - dataBase->setCommunicators( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - if( restartIter == INVALID_INDEX ) - { - Initializer::interpret(dataBase, [&](Vec3 cellCenter) -> ConservedVariables { - - real Th = 1.0 / lambdaHot; - real Tc = 1.0 / lambdaCold; - real T = Th - (Th - Tc)*((cellCenter.x + 0.5 * L) / L); - real lambdaLocal = 1.0 / T; - - return toConservedVariables(PrimitiveVariables(rho, 0.0, 0.0, 0.0, lambda), parameters.K); - }); - - if (rank == 0) writeVtkXMLParallelSummaryFile(dataBase, parameters, path + simulationName + "_0", mpiWorldSize); - - writeVtkXML(dataBase, parameters, 0, path + simulationName + "_0" + "_rank_" + std::to_string(rank)); - } - else - { - Restart::readRestart( dataBase, path + simulationName + "_" + std::to_string( restartIter ) + "_rank_" + std::to_string(rank), startIter ); - - if (rank == 0) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_" + std::to_string( restartIter ) + "_restart", mpiWorldSize ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( restartIter ) + "_restart" + "_rank_" + std::to_string(rank) ); - } - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // R u n - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 300.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase ); - - auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 500000 ); - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 200 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = startIter + 1; iter <= 10000000; iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( - //( iter < 10 && iter % 1 == 0 ) || - //( iter < 100 && iter % 10 == 0 ) || - //( iter < 1000 && iter % 100 == 0 ) || - //( iter < 10000 && iter % 1000 == 0 ) - ( iter < 10000000 && iter % 50000 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - - if( rank == 0 ) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_" + std::to_string( iter ), mpiWorldSize ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) + "_rank_" + std::to_string(rank) ); - } - - cupsAnalyzer.run( iter, dt ); - - convergenceAnalyzer.run( iter ); - - turbulenceAnalyzer->run( iter, parameters ); - - if( iter > 500000 && iter % 100000 == 0 ) - { - turbulenceAnalyzer->download(); - - if( rank == 0 ) writeTurbulenceVtkXMLParallelSummaryFile( dataBase, turbulenceAnalyzer, parameters, path + simulationName + "_Turbulence_" + std::to_string( iter ), mpiWorldSize ); - - writeTurbulenceVtkXML( dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence_" + std::to_string( iter ) + "_rank_" + std::to_string(rank) ); - } - - if( iter % 100000 == 0 ) - { - turbulenceAnalyzer->download(); - - Restart::writeRestart( dataBase, path + simulationName + "_" + std::to_string( iter ) + "_rank_" + std::to_string(rank), iter ); - } - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); -} - -int main( int argc, char* argv[]) -{ - ////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - MPI_Init(&argc, &argv); - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - int mpiWorldSize = 1; - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); -#else - int rank = MpiUtility::getMpiRankBeforeInit(); - int mpiWorldSize = MpiUtility::getMpiWorldSizeBeforeInit(); -#endif - - if( mpiWorldSize < 2 || mpiWorldSize%2 != 0 ) - { - std::cerr << "Error: MpiWolrdSize must be multiple of 2!\n"; - return 1; - } - - ////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/SalinasVazquez/" ); -#else - std::string path( "out/" ); -#endif - - std::string simulationName ( "SalinasVazquez" ); - - ////////////////////////////////////////////////////////////////////////// - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + "_rank_" + std::to_string(rank) + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - ////////////////////////////////////////////////////////////////////////// - - // Important: for Cuda-Aware MPI the device must be set before MPI_Init() - int deviceCount = CudaUtility::getCudaDeviceCount(); - - if(deviceCount == 0) - { - std::stringstream msg; - msg << "No devices devices found!" << std::endl; - *logging::out << logging::Logger::WARNING << msg.str(); msg.str(""); - } - - CudaUtility::setCudaDevice( rank % deviceCount ); - - ////////////////////////////////////////////////////////////////////////// - -#ifndef _WIN32 - MPI_Init(&argc, &argv); -#endif - - ////////////////////////////////////////////////////////////////////////// - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precision\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - uint restartIter = INVALID_INDEX; - - if( argc > 1 ) restartIter = atoi( argv[1] ); - - simulation(path, simulationName, restartIter); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - logFile.close(); - - MPI_Finalize(); - - return 0; -} diff --git a/apps/gpu/GKS/SandiaFlame_1m/3rdPartyLinking.cmake b/apps/gpu/GKS/SandiaFlame_1m/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/SandiaFlame_1m/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/SandiaFlame_1m/CMakeLists.txt b/apps/gpu/GKS/SandiaFlame_1m/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/SandiaFlame_1m/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/SandiaFlame_1m/CMakePackage.cmake b/apps/gpu/GKS/SandiaFlame_1m/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/SandiaFlame_1m/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/SandiaFlame_1m/SandiaFlame_1m.cpp b/apps/gpu/GKS/SandiaFlame_1m/SandiaFlame_1m.cpp deleted file mode 100644 index 8c29bbb4f73109deb41e9dd4ab7402241d3079cf..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/SandiaFlame_1m/SandiaFlame_1m.cpp +++ /dev/null @@ -1,576 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <iomanip> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" -#include "Core/buildInfo.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" -#include "GksGpu/BoundaryConditions/PassiveScalarDiriclet.h" -#include "GksGpu/BoundaryConditions/InflowComplete.h" -#include "GksGpu/BoundaryConditions/Open.h" -#include "GksGpu/BoundaryConditions/Inflow.h" -#include "GksGpu/BoundaryConditions/Symmetry.h" -#include "GksGpu/BoundaryConditions/Pressure2.h" -#include "GksGpu/BoundaryConditions/CreepingMassFlux.h" - -#include "GksGpu/Interface/Interface.h" -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" -#include "GksGpu/Analyzer/PointTimeSeriesAnalyzer.h" - -#include "GksGpu/Restart/Restart.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void thermalCavity( std::string path, std::string simulationName, uint _gpuIndex, uint _testIndex, uint _nx, uint restartIter ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //uint nx = 64; - uint nx = _nx; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 3.0; - real H = 4.0; - - real R = 0.5; - - real dx = H / real(nx); - - real Pr = 0.71; - real K = 2.0; - - real g = 9.81; - real rho = 1.2; - - real mu = 1.8e-5; - - real U = 0.0; - real rhoFuel = 0.0; - - if( _testIndex == 14 ) { U = 0.074; rhoFuel = 0.5405; } // Test 14 low flow rates - if( _testIndex == 24 ) { U = 0.097; rhoFuel = 0.5464; } // Test 24 medium flow rate - if( _testIndex == 17 ) { U = 0.117; rhoFuel = 0.5641; } // Test 17 high flow rate - - GksGpu::PrimitiveVariables prim( rho, 0.0, 0.0, 0.0, -1.0 ); - - GksGpu::setLambdaFromT( prim, 2.85 ); - - real cs = sqrt( ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( 2.0 * prim.lambda ) ); - - //real CFL = 0.06125; - real CFL = 0.125; - - real dt = CFL * ( dx / ( ( U + cs ) * ( c1o1 + ( c2o1 * mu ) / ( U * dx * rho ) ) ) ); - - real dh = 8000.0; // kJ / kmol / T_FAKTOR - - ////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "cs = " << cs << " m/s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " kg/sm\n"; - *logging::out << logging::Logger::INFO_HIGH << "Pr = " << Pr << "\n"; - - *logging::out << logging::Logger::INFO_HIGH << "HRR = " << U * rhoFuel * M_PI * R * R * ( dh * 100 ) / 0.016 / 1000.0 << " kW\n"; - - ////////////////////////////////////////////////////////////////////////// - - GksGpu::Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.D = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = -g; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = prim.lambda; - - parameters.rhoRef = rho; - - parameters.heatOfReaction = dh; - - parameters.viscosityModel = GksGpu::ViscosityModel::sutherlandsLaw; - //parameters.viscosityModel = GksGpu::ViscosityModel::constant; - - parameters.enableReaction = true; - - parameters.useHeatReleaseRateLimiter = true; - parameters.useReactionLimiter = true; - parameters.useTemperatureLimiter = true; - parameters.usePassiveScalarLimiter = true; - parameters.useSmagorinsky = true; - - parameters.reactionLimiter = 1.0005; - parameters.temperatureLimiter = 1.0e-3; - - parameters.useSpongeLayer = true; - parameters.spongeLayerIdx = 1; - - parameters.forcingSchemeIdx = 2; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - bool threeDimensional = true; - - if( threeDimensional ) - { - gridBuilder->addCoarseGrid(-0.5*L, -0.5*L, 0.0, - 0.5*L, 0.5*L, H, dx); - } - else - { - gridBuilder->addCoarseGrid(-0.5*L, -0.5*dx, 0.0, - 0.5*L, 0.5*dx, H, dx); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - VerticalCylinder cylinder1( 0.0, 0.0, 0.0, 1.5*R, 0.25*H ); - VerticalCylinder cylinder2( 0.0, 0.0, 0.0, 1.1*R, 0.05*H ); - - Conglomerate refRing; - refRing.add ( new VerticalCylinder( 0.0, 0.0, 0.0, 1.2*R, 0.1 ) ); - refRing.subtract( new VerticalCylinder( 0.0, 0.0, 0.0, 0.8*R, 1.0 ) ); - - gridBuilder->setNumberOfLayers(0,10); - - //gridBuilder->addGrid( &cylinder1 ); - //gridBuilder->addGrid( &cylinder2 ); - //gridBuilder->addGrid( &refRing ); - - if( threeDimensional ) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - else gridBuilder->setPeriodicBoundaryCondition(false, true, false); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - if( !threeDimensional ) - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksGpu::CudaUtility::setCudaDevice(_gpuIndex); - - auto dataBase = std::make_shared<GksGpu::DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real openBoundaryVelocityLimiter = 1.0; - - SPtr<GksGpu::BoundaryCondition> bcMX = std::make_shared<GksGpu::Open>( dataBase, prim, openBoundaryVelocityLimiter ); - SPtr<GksGpu::BoundaryCondition> bcPX = std::make_shared<GksGpu::Open>( dataBase, prim, openBoundaryVelocityLimiter ); - - SPtr<GksGpu::BoundaryCondition> bcMX_2 = std::make_shared<GksGpu::Symmetry>( dataBase, 'x' ); - SPtr<GksGpu::BoundaryCondition> bcPX_2 = std::make_shared<GksGpu::Symmetry>( dataBase, 'x' ); - - bcMX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L; } ); - - bcMX_2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x < -0.5*L && center.z > 0.9*H; } ); - bcPX_2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.x > 0.5*L && center.z > 0.9*H; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> bcMY; - SPtr<GksGpu::BoundaryCondition> bcPY; - - SPtr<GksGpu::BoundaryCondition> bcMY_2; - SPtr<GksGpu::BoundaryCondition> bcPY_2; - - if( threeDimensional ) - { - bcMY = std::make_shared<GksGpu::Open>( dataBase, prim, openBoundaryVelocityLimiter ); - bcPY = std::make_shared<GksGpu::Open>( dataBase, prim, openBoundaryVelocityLimiter ); - - bcMY_2 = std::make_shared<GksGpu::Symmetry>( dataBase, 'y' ); - bcPY_2 = std::make_shared<GksGpu::Symmetry>( dataBase, 'y' ); - - bcMY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.5*L; } ); - bcPY->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*L; } ); - - bcMY_2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y < -0.5*L && center.z > 0.9*H; } ); - bcPY_2->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.y > 0.5*L && center.z > 0.9*H; } ); - } - else - { - bcMY = std::make_shared<GksGpu::Periodic>(dataBase); - bcPY = std::make_shared<GksGpu::Periodic>(dataBase); - - bcMY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y < -0.5*dx; }); - bcPY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y > 0.5*dx; }); - } - - ////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> bcMZ = std::make_shared<GksGpu::AdiabaticWall>( dataBase, Vec3(0, 0, 0), true ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<IsothermalWall>( dataBase, Vec3(0, 0, 0), prim.lambda, true ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<InflowComplete>( dataBase, PrimitiveVariables(rho, 0.0, 0.0, 0.0, prim.lambda, 0.0, 0.0) ); - //SPtr<BoundaryCondition> bcMZ = std::make_shared<Open>( dataBase ); - - SPtr<GksGpu::BoundaryCondition> bcPZ = std::make_shared<GksGpu::Pressure2>( dataBase, c1o2 * prim.rho / prim.lambda ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < 0.0; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > H ; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> burner = std::make_shared<GksGpu::CreepingMassFlux>( dataBase, rhoFuel, U, prim.lambda ); - //SPtr<BoundaryCondition> burner = std::make_shared<Inflow>( dataBase, Vec3(0,0,U), prim.lambda, rhoFuel, 1, 0, 0, 1.0 ); - - burner->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ - - if( threeDimensional ) - return center.z < 0.0 && std::sqrt(center.x*center.x + center.y*center.y) < R; - else - return center.z < 0.0 && std::sqrt(center.x*center.x) < R && std::sqrt(center.y*center.y) < 0.5 * dx; - } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( burner ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMX_2 ); - dataBase->boundaryConditions.push_back( bcPX_2 ); - - if( threeDimensional ){ - dataBase->boundaryConditions.push_back( bcMY_2 ); - dataBase->boundaryConditions.push_back( bcPY_2 ); - } - - //dataBase->boundaryConditions.push_back( burner ); - - ////////////////////////////////////////////////////////////////////////// - - auto pointTimeSeriesAnalyzerU_P1 = std::make_shared<GksGpu::PointTimeSeriesAnalyzer>( dataBase, meshAdapter, Vec3(0.0, 0.0, 0.505), 'U' ); - auto pointTimeSeriesAnalyzerV_P1 = std::make_shared<GksGpu::PointTimeSeriesAnalyzer>( dataBase, meshAdapter, Vec3(0.0, 0.0, 0.505), 'V' ); - auto pointTimeSeriesAnalyzerW_P1 = std::make_shared<GksGpu::PointTimeSeriesAnalyzer>( dataBase, meshAdapter, Vec3(0.0, 0.0, 0.505), 'W' ); - - auto pointTimeSeriesAnalyzerU_P2 = std::make_shared<GksGpu::PointTimeSeriesAnalyzer>( dataBase, meshAdapter, Vec3(0.5, 0.0, 0.505), 'U' ); - auto pointTimeSeriesAnalyzerV_P2 = std::make_shared<GksGpu::PointTimeSeriesAnalyzer>( dataBase, meshAdapter, Vec3(0.5, 0.0, 0.505), 'V' ); - auto pointTimeSeriesAnalyzerW_P2 = std::make_shared<GksGpu::PointTimeSeriesAnalyzer>( dataBase, meshAdapter, Vec3(0.5, 0.0, 0.505), 'W' ); - - auto pointTimeSeriesAnalyzerU_P3 = std::make_shared<GksGpu::PointTimeSeriesAnalyzer>( dataBase, meshAdapter, Vec3(0.0, 0.0, 2.0), 'U' ); - auto pointTimeSeriesAnalyzerV_P3 = std::make_shared<GksGpu::PointTimeSeriesAnalyzer>( dataBase, meshAdapter, Vec3(0.0, 0.0, 2.0), 'V' ); - auto pointTimeSeriesAnalyzerW_P3 = std::make_shared<GksGpu::PointTimeSeriesAnalyzer>( dataBase, meshAdapter, Vec3(0.0, 0.0, 2.0), 'W' ); - - auto pointTimeSeriesAnalyzerU_P4 = std::make_shared<GksGpu::PointTimeSeriesAnalyzer>( dataBase, meshAdapter, Vec3(0.5, 0.0, 2.0), 'U' ); - auto pointTimeSeriesAnalyzerV_P4 = std::make_shared<GksGpu::PointTimeSeriesAnalyzer>( dataBase, meshAdapter, Vec3(0.5, 0.0, 2.0), 'V' ); - auto pointTimeSeriesAnalyzerW_P4 = std::make_shared<GksGpu::PointTimeSeriesAnalyzer>( dataBase, meshAdapter, Vec3(0.5, 0.0, 2.0), 'W' ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint startIter = 0; - - dataBase->setMesh( meshAdapter ); - - GksGpu::CudaUtility::printCudaMemoryUsage(); - - if( restartIter == INVALID_INDEX ) - { - GksGpu::Initializer::interpret(dataBase, [&](Vec3 cellCenter) -> GksGpu::ConservedVariables { - - GksGpu::PrimitiveVariables primLocal = prim; - - return GksGpu::toConservedVariables(primLocal, parameters.K); - }); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - } - else - { - GksGpu::Restart::readRestart( dataBase, path + simulationName + "_" + std::to_string( restartIter ), startIter ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( restartIter ) + "_restart" ); - } - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, level ); - - GksGpu::Initializer::initializeDataUpdate(dataBase); - - dataBase->copyDataDeviceToHost(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint iterPerSecond = uint( c1o1 / parameters.dt ) + 1; - - *logging::out << logging::Logger::INFO_HIGH << "iterPerSecond = " << iterPerSecond << "\n"; - - ////////////////////////////////////////////////////////////////////////// - - GksGpu::CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0, true, 10000 ); - - GksGpu::ConvergenceAnalyzer convergenceAnalyzer( dataBase, 10000 ); - - auto turbulenceAnalyzer = std::make_shared<GksGpu::TurbulenceAnalyzer>( dataBase, 10 * iterPerSecond ); - - turbulenceAnalyzer->collect_UU = true; - turbulenceAnalyzer->collect_VV = true; - turbulenceAnalyzer->collect_WW = true; - - turbulenceAnalyzer->allocate(); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = startIter + 1; iter <= 40 * iterPerSecond; iter++ ) - { - cupsAnalyzer.run( iter, parameters.dt ); - - convergenceAnalyzer.run( iter ); - - GksGpu::TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - pointTimeSeriesAnalyzerU_P1->run(iter, parameters); - pointTimeSeriesAnalyzerV_P1->run(iter, parameters); - pointTimeSeriesAnalyzerW_P1->run(iter, parameters); - - pointTimeSeriesAnalyzerU_P2->run(iter, parameters); - pointTimeSeriesAnalyzerV_P2->run(iter, parameters); - pointTimeSeriesAnalyzerW_P2->run(iter, parameters); - - pointTimeSeriesAnalyzerU_P3->run(iter, parameters); - pointTimeSeriesAnalyzerV_P3->run(iter, parameters); - pointTimeSeriesAnalyzerW_P3->run(iter, parameters); - - pointTimeSeriesAnalyzerU_P4->run(iter, parameters); - pointTimeSeriesAnalyzerV_P4->run(iter, parameters); - pointTimeSeriesAnalyzerW_P4->run(iter, parameters); - - int crashCellIndex = dataBase->getCrashCellIndex(); - - if( crashCellIndex >= 0 ) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Simulation Crashed at CellIndex = " << crashCellIndex << "\n"; - dataBase->copyDataDeviceToHost(); - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - - break; - } - - if( - //( iter >= 39360 && iter % 1 == 0 ) || - ( iter % 10000 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - if( iter % 10000 == 0 /*|| iter == 39000*/) - { - dataBase->copyDataDeviceToHost(); - GksGpu::Restart::writeRestart( dataBase, path + simulationName + "_" + std::to_string( iter ), iter ); - } - - if( iter % 100000 == 0 ) - { - turbulenceAnalyzer->download(); - - writeTurbulenceVtkXML( dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence_" + std::to_string( iter ) ); - } - - if( iter % 100000 == 0 ) - { - pointTimeSeriesAnalyzerU_P1->writeToFile(path + simulationName + "_P1_TimeSeries_" + pointTimeSeriesAnalyzerU_P1->quantity + "_" + std::to_string( iter )); - pointTimeSeriesAnalyzerV_P1->writeToFile(path + simulationName + "_P1_TimeSeries_" + pointTimeSeriesAnalyzerV_P1->quantity + "_" + std::to_string( iter )); - pointTimeSeriesAnalyzerW_P1->writeToFile(path + simulationName + "_P1_TimeSeries_" + pointTimeSeriesAnalyzerW_P1->quantity + "_" + std::to_string( iter )); - - pointTimeSeriesAnalyzerU_P2->writeToFile(path + simulationName + "_P2_TimeSeries_" + pointTimeSeriesAnalyzerU_P2->quantity + "_" + std::to_string( iter )); - pointTimeSeriesAnalyzerV_P2->writeToFile(path + simulationName + "_P2_TimeSeries_" + pointTimeSeriesAnalyzerV_P2->quantity + "_" + std::to_string( iter )); - pointTimeSeriesAnalyzerW_P2->writeToFile(path + simulationName + "_P2_TimeSeries_" + pointTimeSeriesAnalyzerW_P2->quantity + "_" + std::to_string( iter )); - - pointTimeSeriesAnalyzerU_P3->writeToFile(path + simulationName + "_P3_TimeSeries_" + pointTimeSeriesAnalyzerU_P3->quantity + "_" + std::to_string( iter )); - pointTimeSeriesAnalyzerV_P3->writeToFile(path + simulationName + "_P3_TimeSeries_" + pointTimeSeriesAnalyzerV_P3->quantity + "_" + std::to_string( iter )); - pointTimeSeriesAnalyzerW_P3->writeToFile(path + simulationName + "_P3_TimeSeries_" + pointTimeSeriesAnalyzerW_P3->quantity + "_" + std::to_string( iter )); - - pointTimeSeriesAnalyzerU_P4->writeToFile(path + simulationName + "_P4_TimeSeries_" + pointTimeSeriesAnalyzerU_P4->quantity + "_" + std::to_string( iter )); - pointTimeSeriesAnalyzerV_P4->writeToFile(path + simulationName + "_P4_TimeSeries_" + pointTimeSeriesAnalyzerV_P4->quantity + "_" + std::to_string( iter )); - pointTimeSeriesAnalyzerW_P4->writeToFile(path + simulationName + "_P4_TimeSeries_" + pointTimeSeriesAnalyzerW_P4->quantity + "_" + std::to_string( iter )); - } - - turbulenceAnalyzer->run( iter, parameters ); - } - - ////////////////////////////////////////////////////////////////////////// - - //dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - turbulenceAnalyzer->download(); - - writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence_final"); - - pointTimeSeriesAnalyzerU_P1->writeToFile(path + simulationName + "_P1_TimeSeries_" + pointTimeSeriesAnalyzerU_P1->quantity + "_final"); - pointTimeSeriesAnalyzerV_P1->writeToFile(path + simulationName + "_P1_TimeSeries_" + pointTimeSeriesAnalyzerV_P1->quantity + "_final"); - pointTimeSeriesAnalyzerW_P1->writeToFile(path + simulationName + "_P1_TimeSeries_" + pointTimeSeriesAnalyzerW_P1->quantity + "_final"); - - pointTimeSeriesAnalyzerU_P2->writeToFile(path + simulationName + "_P2_TimeSeries_" + pointTimeSeriesAnalyzerU_P2->quantity + "_final"); - pointTimeSeriesAnalyzerV_P2->writeToFile(path + simulationName + "_P2_TimeSeries_" + pointTimeSeriesAnalyzerV_P2->quantity + "_final"); - pointTimeSeriesAnalyzerW_P2->writeToFile(path + simulationName + "_P2_TimeSeries_" + pointTimeSeriesAnalyzerW_P2->quantity + "_final"); - - pointTimeSeriesAnalyzerU_P3->writeToFile(path + simulationName + "_P3_TimeSeries_" + pointTimeSeriesAnalyzerU_P3->quantity + "_final"); - pointTimeSeriesAnalyzerV_P3->writeToFile(path + simulationName + "_P3_TimeSeries_" + pointTimeSeriesAnalyzerV_P3->quantity + "_final"); - pointTimeSeriesAnalyzerW_P3->writeToFile(path + simulationName + "_P3_TimeSeries_" + pointTimeSeriesAnalyzerW_P3->quantity + "_final"); - - pointTimeSeriesAnalyzerU_P4->writeToFile(path + simulationName + "_P4_TimeSeries_" + pointTimeSeriesAnalyzerU_P4->quantity + "_final"); - pointTimeSeriesAnalyzerV_P4->writeToFile(path + simulationName + "_P4_TimeSeries_" + pointTimeSeriesAnalyzerV_P4->quantity + "_final"); - pointTimeSeriesAnalyzerW_P4->writeToFile(path + simulationName + "_P4_TimeSeries_" + pointTimeSeriesAnalyzerW_P4->quantity + "_final"); -} - -int main( int argc, char* argv[]) -{ - uint restartIter = INVALID_INDEX; - //uint restartIter = 90000; - - uint gpuIndex = 1; - uint testIndex = 24; - uint nx = 64; - - if( argc > 1 ) gpuIndex = atoi( argv[1] ); - - if( argc > 2 ) testIndex = atoi( argv[2] ); - - if( argc > 3 ) nx = atoi( argv[3] ); - - if( argc > 4 ) restartIter = atoi( argv[4] ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/SandiaFlame_1m/" ); -#else - std::string path( "out/" ); -#endif - - path += "Test_" + std::to_string(testIndex) + "_" + std::to_string(nx) + "/"; - - std::string simulationName ( "Flame" ); - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - ////////////////////////////////////////////////////////////////////////// - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precision\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - thermalCavity( path, simulationName, gpuIndex, testIndex, nx, restartIter ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - logFile.close(); - - return 0; -} diff --git a/apps/gpu/GKS/ShearWave/3rdPartyLinking.cmake b/apps/gpu/GKS/ShearWave/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ShearWave/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/ShearWave/CMakeLists.txt b/apps/gpu/GKS/ShearWave/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ShearWave/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/ShearWave/CMakePackage.cmake b/apps/gpu/GKS/ShearWave/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ShearWave/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/ShearWave/ShearWave.cpp b/apps/gpu/GKS/ShearWave/ShearWave.cpp deleted file mode 100644 index e94d921fbdbb141a89eeaad46b5d4b95d174be9e..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ShearWave/ShearWave.cpp +++ /dev/null @@ -1,289 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/FlowStateData/AccessDeviceData.cuh" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void channelFlow( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 128; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - real H = 1.5; - - real dx = L / real(nx); - - real Re = 1.0e2; - real U = 0.1; - real Ma = 0.1; - - real Pr = 0.1; - real K = 2.0; - - real rho = 1.0; - - real mu = U * rho * L / Re; - - real cs = U / Ma; - real lambda = c1o2 * ( ( K + 4.0 ) / ( K + 2.0 ) ) / ( cs * cs ); - - real g = eight * mu * U / ( H * H ); - - real p0 = c1o2 * rho / lambda; - - real CFL = 0.25; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - - dt = 0.001 * ( 32.0 / real(nx) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = g; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - parameters.viscosityModel = ViscosityModel::constant; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->addCoarseGrid(-0.5*L, -0.5*H, -0.5*dx, - 0.5*L, 0.5*H, 0.5*dx, dx); - - //Cuboid cube(-1.0, -1.0, 0.45, 1.0, 1.0, 0.55); - - //gridBuilder->setNumberOfLayers(6,6); - //gridBuilder->addGrid( &cube, 1); - - gridBuilder->setPeriodicBoundaryCondition(true, true, true); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMX = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPX = std::make_shared<Periodic>( dataBase ); - - bcMX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPY = std::make_shared<Periodic>( dataBase ); - - bcMY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y < -0.5*H; } ); - bcPY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y > 0.5*H; } ); - - ////////////////////////////////////////////////////////////////////////// - SPtr<BoundaryCondition> bcMZ = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Periodic>( dataBase ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*dx; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*dx; } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables{ - - real ULocal = 0.0; - real VLocal = 0.0; - real WLocal = U * sin( 2.0 * M_PI * cellCenter.x / L ) * cos( 4.0 / 3.0 * M_PI * cellCenter.y / L ); - - return toConservedVariables( PrimitiveVariables( rho, ULocal, VLocal, WLocal, lambda, 0.0 ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + ".0." + std::to_string( nx ) ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= 10000 * ( nx / 32 ); iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, parameters, nullptr, 0); - - //if( iter % ( 100 * ( nx / 32 ) ) == 0 ) - //{ - // dataBase->copyDataDeviceToHost(); - - // writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - //} - - cupsAnalyzer.run( iter ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + ".Result." + std::to_string( nx ) ); - - - { - real sum1 = 0.0; - real sum2 = 0.0; - - for( uint cellIdx = 0; cellIdx < dataBase->perLevelCount[0].numberOfBulkCells; cellIdx++ ) - { - real velocity = dataBase->dataHost[ RHO_W(cellIdx, dataBase->numberOfCells) ] / dataBase->dataHost[ RHO__(cellIdx, dataBase->numberOfCells) ]; - - sum1 += velocity * U * sin( 2.0 * M_PI * dataBase->getCellCenter(cellIdx).x / L ) * cos( 4.0 / 3.0 * M_PI * dataBase->getCellCenter(cellIdx).y / L ); - sum2 += U * sin( 2.0 * M_PI * dataBase->getCellCenter(cellIdx).x / L ) * cos( 4.0 / 3.0 * M_PI * dataBase->getCellCenter(cellIdx).y / L ) - * U * sin( 2.0 * M_PI * dataBase->getCellCenter(cellIdx).x / L ) * cos( 4.0 / 3.0 * M_PI * dataBase->getCellCenter(cellIdx).y / L ); - } - - *logging::out << logging::Logger::INFO_HIGH << sum1 / sum2 << "\n"; - } -} - -int main( int argc, char* argv[]) -{ - std::string path( "F:/Work/Computations/out/" ); - std::string simulationName ( "ShearWave" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - channelFlow( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/GKS/SingleGPU/3rdPartyLinking.cmake b/apps/gpu/GKS/SingleGPU/3rdPartyLinking.cmake deleted file mode 100644 index f8902be1dd38d4f48cfebd807b2b4a6d1ae9e793..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/SingleGPU/3rdPartyLinking.cmake +++ /dev/null @@ -1,13 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/OpenMP/Link.cmake) -linkOpenMP(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/SingleGPU/CMakeLists.txt b/apps/gpu/GKS/SingleGPU/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/SingleGPU/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/SingleGPU/CMakePackage.cmake b/apps/gpu/GKS/SingleGPU/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/SingleGPU/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/SingleGPU/SingleGPU.cpp b/apps/gpu/GKS/SingleGPU/SingleGPU.cpp deleted file mode 100644 index 2fed78f38419af983d9818ff3f15f2e01f0c5f69..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/SingleGPU/SingleGPU.cpp +++ /dev/null @@ -1,335 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <iomanip> -#include <exception> -#include <fstream> -#include <sstream> -#include <memory> -#include <omp.h> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Sphere/Sphere.h" -#include "GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" -#include "GridGenerator/geometries/BoundingBox/BoundingBox.h" -#include "GridGenerator/utilities/communication.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" - -#include "GksGpu/Communication/Communicator.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" -#include "GksGpu/Communication/MpiUtility.h" - -////////////////////////////////////////////////////////////////////////// - -real performanceTest( std::string path, std::string simulationName, uint nx ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - - real LX = L; - real LY = L; - real LZ = L; - - real dx = L / real(nx); - - ////////////////////////////////////////////////////////////////////////// - - GksGpu::Parameters parameters; - - parameters.K = 0; - parameters.Pr = 1; - parameters.mu = 0.01; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = 0.0001 * ( double(128) / double(nx) ); - parameters.dx = dx; - - parameters.lambdaRef = 1.0e-2; - - parameters.forcingSchemeIdx = 2; - - parameters.enableReaction = true; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - gridBuilder->addCoarseGrid( - 0.5*L, - 0.5*L, - 0.5*L, - 0.5*L, 0.5*L, 0.5*L, dx); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->setPeriodicBoundaryCondition(true,true,true); - - gridBuilder->buildGrids(GKS, false); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto dataBase = std::make_shared<GksGpu::DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> bcMX = std::make_shared<GksGpu::Periodic>( dataBase ); - SPtr<GksGpu::BoundaryCondition> bcPX = std::make_shared<GksGpu::Periodic>( dataBase ); - - bcMX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> bcMY = std::make_shared<GksGpu::Periodic>( dataBase ); - SPtr<GksGpu::BoundaryCondition> bcPY = std::make_shared<GksGpu::Periodic>( dataBase ); - - bcMY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y < -0.5*L; } ); - bcPY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<GksGpu::BoundaryCondition> bcMZ = std::make_shared<GksGpu::Periodic>( dataBase ); - SPtr<GksGpu::BoundaryCondition> bcPZ = std::make_shared<GksGpu::Periodic>( dataBase ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*L; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - ////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_HIGH << "NumberOfBoundaryConditions = " << (int)dataBase->boundaryConditions.size() << "\n"; - - *logging::out << logging::Logger::INFO_HIGH << "bcMX ==> " << bcMX->numberOfCellsPerLevel[0] << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "bcPX ==> " << bcPX->numberOfCellsPerLevel[0] << "\n"; - - *logging::out << logging::Logger::INFO_HIGH << "bcMY ==> " << bcMY->numberOfCellsPerLevel[0] << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "bcPY ==> " << bcPY->numberOfCellsPerLevel[0] << "\n"; - - *logging::out << logging::Logger::INFO_HIGH << "bcMZ ==> " << bcMZ->numberOfCellsPerLevel[0] << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "bcPZ ==> " << bcPZ->numberOfCellsPerLevel[0] << "\n"; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - dataBase->setCommunicators( meshAdapter ); - - GksGpu::CudaUtility::printCudaMemoryUsage(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksGpu::Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> GksGpu::ConservedVariables - { - real U = 0.1; - - real ULocal = 0.1 + U * sin( 2.0 * M_PI * cellCenter.x ) * cos( 2.0 * M_PI * cellCenter.y ) * cos( 2.0 * M_PI * cellCenter.z ); - real VLocal = 0.1 - U * cos( 2.0 * M_PI * cellCenter.x ) * sin( 2.0 * M_PI * cellCenter.y ) * cos( 2.0 * M_PI * cellCenter.z ); - real WLocal = 0.1; - - real rho = 1.0; - - real p0 = 0.5 * rho / parameters.lambdaRef; - - real pLocal = p0 + rho * U * U / 16.0 * ( cos( 2.0 * M_PI * 2.0 * cellCenter.x ) + cos( 2.0 * M_PI * 2.0 * cellCenter.y ) ) * ( 2.0 + cos( 2.0 * M_PI * 2.0 * cellCenter.z ) ); - - real rhoLocal = 2.0 * pLocal * parameters.lambdaRef; - - return GksGpu::toConservedVariables( GksGpu::PrimitiveVariables( rhoLocal, ULocal, VLocal, WLocal, parameters.lambdaRef ), parameters.K ); - }); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataHostToDevice(); - - for( auto bc : dataBase->boundaryConditions ) - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - bc->runBoundaryConditionKernel( dataBase, parameters, level ); - - GksGpu::Initializer::initializeDataUpdate(dataBase); - - //dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - const uint numberOfIterations = 1000; - - GksGpu::CupsAnalyzer cupsAnalyzer( dataBase, false, 30.0, true, numberOfIterations ); - - real CUPS = 0; - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= numberOfIterations; iter++ ) - { - GksGpu::TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - CUPS = cupsAnalyzer.run( iter, parameters.dt ); - } - - ////////////////////////////////////////////////////////////////////////// - - //dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + simulationName + "_final" ); - - ////////////////////////////////////////////////////////////////////////// - - int crashCellIndex = dataBase->getCrashCellIndex(); - if( crashCellIndex >= 0 ) - { - *logging::out << logging::Logger::LOGGER_ERROR << "=================================================\n"; - *logging::out << logging::Logger::LOGGER_ERROR << "=================================================\n"; - *logging::out << logging::Logger::LOGGER_ERROR << "============= Simulation Crashed!!! =============\n"; - *logging::out << logging::Logger::LOGGER_ERROR << "=================================================\n"; - *logging::out << logging::Logger::LOGGER_ERROR << "=================================================\n"; - } - - return CUPS; -} - -int main( int argc, char* argv[]) -{ - ////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/SingleGPU/" ); -#else - //std::string path( "/home/stephan/Computations/out/" ); - std::string path( "out/" ); -#endif - - ////////////////////////////////////////////////////////////////////////// - - try - { - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - std::string simulationName ( "SingleGPU" ); - - std::ofstream file; - file.open( path + simulationName + ".dat" ); - - //std::vector<uint> nxList = {32,64,128,256}; - std::vector<uint> nxList = {128}; - - for( auto nx : nxList ) - { - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + "_nx_" + std::to_string(nx) + ".log" ); - logging::Logger::addStream(&logFile); - - GksGpu::CudaUtility::setCudaDevice( 0 ); - - ////////////////////////////////////////////////////////////////////////// - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - real CUPS = performanceTest( path, simulationName + "_nx_" + std::to_string(nx), nx ); - - file << std::setw(5) << nx <<std::setw(20) << CUPS << std::endl; - - logFile.close(); - - logging::Logger::resetStreams(); - } - - file.close(); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - return 0; -} diff --git a/apps/gpu/GKS/TaylorGreen3D/3rdPartyLinking.cmake b/apps/gpu/GKS/TaylorGreen3D/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/TaylorGreen3D/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/TaylorGreen3D/CMakeLists.txt b/apps/gpu/GKS/TaylorGreen3D/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/TaylorGreen3D/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/TaylorGreen3D/CMakePackage.cmake b/apps/gpu/GKS/TaylorGreen3D/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/TaylorGreen3D/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/TaylorGreen3D/TaylorGreen3D.cpp b/apps/gpu/GKS/TaylorGreen3D/TaylorGreen3D.cpp deleted file mode 100644 index 1fdd80bd207cbd688601f47de3d2ea54814112f3..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/TaylorGreen3D/TaylorGreen3D.cpp +++ /dev/null @@ -1,322 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/KineticEnergyAnalyzer.h" -#include "GksGpu/Analyzer/EnstrophyAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void writeVelocityFile( SPtr<DataBase> dataBase, std::string filename ); - -////////////////////////////////////////////////////////////////////////// -real Re = 1.6e3; - -uint dtPerL = 500; - -uint nx = 64; -uint gpuIndex = 0; -////////////////////////////////////////////////////////////////////////// - -void gksTest( std::string path ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice( gpuIndex ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - - real dx = 2.0 * M_PI * L / real(nx); - - real U = 1.0; - real Ma = 0.1; - - real Pr = 0.71; - real K = 2.0; - - real rho = 1.0; - - ////////////////////////////////////////////////////////////////////////// - - real gamma = ( K + 5 ) / ( K + 3 ); - - real mu = U * rho * L / Re; - - real cs = U / Ma; - real lambda = c1o2 * ( ( K + 5.0 ) / ( K + 3.0 ) ) / ( cs * cs ); - - real CFL = 0.5; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt(CFL=0.5) = " << dt << " s\n"; - - dt = L / U / dtPerL * ( 64.0 / real(nx) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << "\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - parameters.viscosityModel = ViscosityModel::constant; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->addCoarseGrid(-M_PI*L, -M_PI*L, -M_PI*L, - M_PI*L, M_PI*L, M_PI*L, dx); - - //gridBuilder->addCoarseGrid(-2.0 * dx, -0.5*L*2.0*M_PI, -0.5*L*2.0*M_PI, - // 2.0 * dx, 0.5*L*2.0*M_PI, 0.5*L*2.0*M_PI, dx); - - //Cuboid cube(-1.0, -1.0, 0.45, 1.0, 1.0, 0.55); - - //gridBuilder->setNumberOfLayers(6,6); - //gridBuilder->addGrid( &cube, 1); - - gridBuilder->setPeriodicBoundaryCondition(true, true, true); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "out/MeshFaces.vtk" ); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - dataBase->setMesh( meshAdapter ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMX = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPX = std::make_shared<Periodic>( dataBase ); - - bcMX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPY = std::make_shared<Periodic>( dataBase ); - - bcMY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y < -0.5*L; } ); - bcPY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Periodic>( dataBase ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*L; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - ////////////////////////////////////////////////////////////////////////// - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables{ - - real ULocal = U * sin( cellCenter.x ) * cos( cellCenter.y ) * cos( cellCenter.z ); - real VLocal = - U * cos( cellCenter.x ) * sin( cellCenter.y ) * cos( cellCenter.z ); - real WLocal = 0.0; - - real p0 = 0.5 * rho / lambda; - - real pLocal = p0 + rho * U * U / 16.0 * ( cos( 2.0 * cellCenter.x ) + cos( 2.0 * cellCenter.y ) ) * ( 2.0 + cos( 2.0 * cellCenter.z ) ); - - real rhoLocal = 2.0 * pLocal * lambda; - - return toConservedVariables( PrimitiveVariables( rhoLocal, ULocal, VLocal, WLocal, lambda ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - writeVtkXML( dataBase, parameters, 0, path + "TGV_3D_nx_" + std::to_string(nx) + "_dtPerL_" + std::to_string(dtPerL) + "_" + std::to_string( 0 ) ); - writeVelocityFile( dataBase, path + "TGV_3D_nx_" + std::to_string(nx) + "_dtPerL_" + std::to_string(dtPerL) + "_Velocity_" + std::to_string( 0 ) ); - - ////////////////////////////////////////////////////////////////////////// - - KineticEnergyAnalyzer kineticEnergyAnalyzer( dataBase, 10, 10000 ); - EnstrophyAnalyzer enstrophyAnalyzer ( dataBase, parameters, 10, 10000 ); - - CupsAnalyzer cupsAnalyzer( dataBase, true, 60.0, false, 100 ); - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= 40 * lround(L/(U*dt)); iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - kineticEnergyAnalyzer.run( iter ); - enstrophyAnalyzer.run( iter ); - - if( iter % ( 5 * lround(L/(U*dt)) ) == 0 ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + "TGV_3D_nx_" + std::to_string(nx) + "_dtPerL_" + std::to_string(dtPerL) + "_" + std::to_string( iter / lround(L/(U*dt)) ) ); - writeVelocityFile( dataBase, path + "TGV_3D_nx_" + std::to_string(nx) + "_dtPerL_" + std::to_string(dtPerL) + "_Velocity_" + std::to_string( iter / lround(L/(U*dt)) ) ); - kineticEnergyAnalyzer.writeToFile( path + "TGV_3D_nx_" + std::to_string(nx) + "_dtPerL_" + std::to_string(dtPerL) + "_EKin_" + std::to_string( iter / lround(L/(U*dt)) ) ); - enstrophyAnalyzer.writeToFile ( path + "TGV_3D_nx_" + std::to_string(nx) + "_dtPerL_" + std::to_string(dtPerL) + "_Enstrophy_"+ std::to_string( iter / lround(L/(U*dt)) ) ); - } - - cupsAnalyzer.run( iter ); - } - - ////////////////////////////////////////////////////////////////////////// -} - -int main( int argc, char* argv[]) -{ - if( argc > 1 ) gpuIndex = atoi( argv[1] ); - if( argc > 2 ) Re = atof( argv[2] ); - if( argc > 3 ) nx = atoi( argv[3] ); - if( argc > 4 ) dtPerL = atoi( argv[4] ); - - ////////////////////////////////////////////////////////////////////////// - - //std::string path( "F:/Work/Computations/TaylorGreenVortex_3D/results/GKS/" ); - std::string path( "./results/GKS/" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - ////////////////////////////////////////////////////////////////////////// - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - gksTest( path ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - return 0; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "FlowStateData/AccessDeviceData.cuh" - -void writeVelocityFile( SPtr<DataBase> dataBase, std::string filename ) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "writeVelocityFile( " << filename << " )" << "\n"; - - std::ofstream file; - - file.open(filename + ".dat" ); - - for( uint cellIndex = 0; cellIndex < dataBase->perLevelCount[0].numberOfBulkCells; cellIndex++ ) - { - real rho = dataBase->dataHost[ RHO__(cellIndex, dataBase->numberOfCells) ]; - - file << dataBase->dataHost[ RHO_U(cellIndex, dataBase->numberOfCells) ] / rho << ", "; - file << dataBase->dataHost[ RHO_V(cellIndex, dataBase->numberOfCells) ] / rho << ", "; - file << dataBase->dataHost[ RHO_W(cellIndex, dataBase->numberOfCells) ] / rho << std::endl; - } - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} \ No newline at end of file diff --git a/apps/gpu/GKS/ThermalCavity/3rdPartyLinking.cmake b/apps/gpu/GKS/ThermalCavity/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ThermalCavity/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/ThermalCavity/CMakeLists.txt b/apps/gpu/GKS/ThermalCavity/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ThermalCavity/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/ThermalCavity/CMakePackage.cmake b/apps/gpu/GKS/ThermalCavity/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ThermalCavity/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/ThermalCavity/ThermalCavity.cpp b/apps/gpu/GKS/ThermalCavity/ThermalCavity.cpp deleted file mode 100644 index ae729002cd11ba3793e6a3a98e612f6f4230ca6f..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ThermalCavity/ThermalCavity.cpp +++ /dev/null @@ -1,345 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void thermalCavity( std::string path, std::string simulationName ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 128; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - //real H = 0.25; - real H = L / real(nx); - - real dx = L / real(nx); - - - real Ra = 2.0e9; - - real Ba = 0.1; - real eps = 1.2; - real Pr = 0.71; - real K = 2.0; - - real g = 1.0; - real rho = 1.0; - - real lambda = Ba / ( 2.0 * g * L ); - real lambdaHot = lambda / ( 1.0 + eps * 0.5 ); - real lambdaCold = lambda / ( 1.0 - eps * 0.5 ); - - real mu = sqrt( Pr * eps * g * L * L * L / Ra ) * rho ; - - real cs = sqrt( ( ( K + 4.0 ) / ( K + 2.0 ) ) / ( 2.0 * lambda ) ); - real U = sqrt( Ra ) * mu / ( rho * L ); - - real CFL = 0.5; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = 0; - parameters.force.y = -g; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - parameters.viscosityModel = ViscosityModel::sutherlandsLaw; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //gridBuilder->addCoarseGrid(-0.5*L, -0.5*L, -0.5*H, - // 0.5*L, 0.5*L, 0.5*H, dx); - - gridBuilder->addCoarseGrid(-0.5*L, -0.5*L, -0.5*H, - 0.5*L, 0.5*L, 0.5*H, dx); - - real L_1 = 0.35; - real L_2 = 0.45; - real L_3 = 0.475; - real L_4 = 0.485; - - Cuboid* cubeMX_1 = new Cuboid (-1.0, -1.0, -1.0, - -L_1, 1.0, 1.0 ); - Cuboid* cubePX_1 = new Cuboid ( L_1, -1.0, -1.0, - 1.0, 1.0, 1.0 ); - - Cuboid* cubeMX_2 = new Cuboid (-1.0, -1.0, -1.0, - -L_2, 1.0, 1.0 ); - Cuboid* cubePX_2 = new Cuboid ( L_2, -1.0, -1.0, - 1.0, 1.0, 1.0 ); - - Cuboid* cubeMX_3 = new Cuboid (-1.0, -1.0, -1.0, - -L_3, 1.0, 1.0 ); - Cuboid* cubePX_3 = new Cuboid ( L_3, -1.0, -1.0, - 1.0, 1.0, 1.0 ); - - Cuboid* cubeMX_4 = new Cuboid (-1.0, -1.0, -1.0, - -L_4, 1.0, 1.0 ); - Cuboid* cubePX_4 = new Cuboid ( L_4, -1.0, -1.0, - 1.0, 1.0, 1.0 ); - - Conglomerate refRegion_1; - refRegion_1.add(cubeMX_1); - refRegion_1.add(cubePX_1); - - Conglomerate refRegion_2; - refRegion_2.add(cubeMX_2); - refRegion_2.add(cubePX_2); - - Conglomerate refRegion_3; - refRegion_3.add(cubeMX_3); - refRegion_3.add(cubePX_3); - - Conglomerate refRegion_4; - refRegion_4.add(cubeMX_4); - refRegion_4.add(cubePX_4); - - gridBuilder->setNumberOfLayers(6,6); - - gridBuilder->addGrid( &refRegion_1, 1); - //gridBuilder->addGrid( &refRegion_2, 2); - //gridBuilder->addGrid( &refRegion_3, 3); - //gridBuilder->addGrid( &refRegion_4, 4); - - gridBuilder->setPeriodicBoundaryCondition(false, false, true); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - //meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - //meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaHot, false ); - SPtr<BoundaryCondition> bcPX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, false ); - //SPtr<BoundaryCondition> bcMX = std::make_shared<Periodic>( dataBase ); - //SPtr<BoundaryCondition> bcPX = std::make_shared<Periodic>( dataBase ); - - bcMX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMY = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0) ); - SPtr<BoundaryCondition> bcPY = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0) ); - //SPtr<BoundaryCondition> bcMY = std::make_shared<Periodic>( dataBase ); - //SPtr<BoundaryCondition> bcPY = std::make_shared<Periodic>( dataBase ); - - bcMY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y < -0.5*L; } ); - bcPY->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.y > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcMZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0) ); - //SPtr<BoundaryCondition> bcPZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0.0, 0.0, 0.0) ); - SPtr<BoundaryCondition> bcMZ = std::make_shared<Periodic>( dataBase ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<Periodic>( dataBase ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*H; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*H; } ); - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - dataBase->boundaryConditions.push_back( bcMY ); - dataBase->boundaryConditions.push_back( bcPY ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables{ - - real Th = 1.0 / lambdaHot; - real Tc = 1.0 / lambdaCold; - real T = Th - (Th - Tc)*( (cellCenter.x + 0.5 * L) / L); - real lambdaLocal = 1.0 / T; - - return toConservedVariables( PrimitiveVariables( rho, 0.0, 0.0, 0.0, lambda ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase ); - - auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 50000 ); - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = 1; iter <= 100000; iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, parameters, nullptr, 0); - - if( - //( iter < 10 && iter % 1 == 0 ) || - //( iter < 100 && iter % 10 == 0 ) || - //( iter < 1000 && iter % 100 == 0 ) || - //( iter < 10000 && iter % 1000 == 0 ) || - ( iter < 10000000 && iter % 10000 == 0 ) - ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - } - - cupsAnalyzer.run( iter ); - - convergenceAnalyzer.run( iter ); - - turbulenceAnalyzer->run( iter, parameters ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - turbulenceAnalyzer->download(); - - writeTurbulenceVtkXML(dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence"); -} - -int main( int argc, char* argv[]) -{ - std::string path( "F:/Work/Computations/out/" ); - //std::string path( "out/" ); - std::string simulationName ( "ThermalCavity" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precison\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - thermalCavity( path, simulationName ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/GKS/ThermalCavityMultiGPU/3rdPartyLinking.cmake b/apps/gpu/GKS/ThermalCavityMultiGPU/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ThermalCavityMultiGPU/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/ThermalCavityMultiGPU/CMakeLists.txt b/apps/gpu/GKS/ThermalCavityMultiGPU/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ThermalCavityMultiGPU/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/ThermalCavityMultiGPU/CMakePackage.cmake b/apps/gpu/GKS/ThermalCavityMultiGPU/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ThermalCavityMultiGPU/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/ThermalCavityMultiGPU/ThermalCavityMultiGPU.cpp b/apps/gpu/GKS/ThermalCavityMultiGPU/ThermalCavityMultiGPU.cpp deleted file mode 100644 index 1af2397d4bfa06f54ee1adb39ab6f618a7829522..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/ThermalCavityMultiGPU/ThermalCavityMultiGPU.cpp +++ /dev/null @@ -1,608 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <sstream> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> -#include <thread> - -#include <mpi.h> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" -#include "GridGenerator/geometries/Conglomerate/Conglomerate.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" -#include "GridGenerator/geometries/BoundingBox/BoundingBox.h" -#include "GridGenerator/utilities/communication.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" -#include "GksGpu/BoundaryConditions/Pressure.h" -#include "GksGpu/BoundaryConditions/AdiabaticWall.h" - -#include "GksGpu/Communication/Communicator.h" -#include "GksGpu/Communication/MpiUtility.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" -#include "GksGpu/Analyzer/PointTimeSeriesCollector.h" - -#include "GksGpu/Restart/Restart.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -//uint deviceMap [2] = {2,3}; -uint deviceMap [2] = {0,1}; - -void simulation( std::string path, std::string simulationName, bool fine, bool highAspect, uint restartIter ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - int mpiWorldSize = 1; - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint nx = 64; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - real W = 0.25; - - real H = L; - - if(highAspect) H = 2.0 * L; - - real dx = L / real(nx); - - real Ra = 5.0e9; - - real Ba = 0.1; - real eps = 1.2; - real Pr = 0.71; - real K = 2.0; - - real g = 1.0; - real rho = 1.0; - - real lambda = Ba / ( 2.0 * g * L ); - real lambdaHot = lambda / ( 1.0 + eps * 0.5 ); - real lambdaCold = lambda / ( 1.0 - eps * 0.5 ); - - real mu = sqrt( Pr * eps * g * L * L * L / Ra ) * rho ; - - real cs = sqrt( ( ( K + 4.0 ) / ( K + 2.0 ) ) / ( 2.0 * lambda ) ); - real U = sqrt( Ra ) * mu / ( rho * L ); - - real CFL = 0.5; - - real dt = CFL * ( dx / ( ( U + cs ) * ( c1o1 + ( c2o1 * mu ) / ( U * dx * rho ) ) ) ); - - *logging::out << logging::Logger::INFO_HIGH << "dt = " << dt << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "U = " << U << " s\n"; - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " s\n"; - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = -g; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - parameters.viscosityModel = ViscosityModel::constant; - - parameters.forcingSchemeIdx = 0; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // M e s h G e n e r a t i o n - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real startX, endX; - real startY, endY; - real startZ, endZ; - - if( rank % 2 == 0 ) startX = -0.5 * L; - else startX = -3.0 * dx; - if( rank % 2 == 0 ) endX = 3.0 * dx; - else endX = 0.5 * L; - - if( mpiWorldSize == 2 ) - { - startY = 0.0; - endY = W; - } - else - { - startY = rank / 2 * W - 3.0 * dx; - endY = (rank / 2 + 1.0) * W + 3.0 * dx; - } - - startZ = - 0.5 * H; - endZ = 0.5 * H; - - gridBuilder->addCoarseGrid(startX, startY, startZ, - endX , endY , endZ , dx); - - std::cout << __LINE__ << std::endl; - - ////////////////////////////////////////////////////////////////////////// - - real refL[4] = { 0.2, 0.05, 0.025, 0.005 }; - - if( fine ) - { - refL[1] = 0.1; - refL[2] = 0.05; - } - - gridBuilder->setNumberOfLayers(6,6); - - ////////////////////////////////////////////////////////////////////////// - - Conglomerate coarseRefLevel; - - if( rank % 2 == 0 ) coarseRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - -0.5*L + refL[0], 100.0, 100.0 ) ); - else coarseRefLevel.add( new Cuboid ( 0.5*L - refL[0], -100.0, -100.0, - 100.0, 100.0, 100.0 ) ); - - coarseRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - 100.0, 100.0, -0.5*H + refL[0] ) ); - coarseRefLevel.add( new Cuboid (-100.0, -100.0, 0.5*H - refL[0], - 100.0, 100.0, 100.0 ) ); - - gridBuilder->addGrid( &coarseRefLevel, 1); - - ////////////////////////////////////////////////////////////////////////// - - Conglomerate firstRefLevel; - - if( rank % 2 == 0 ) firstRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - -0.5*L + refL[1], 100.0, 100.0 ) ); - else firstRefLevel.add( new Cuboid ( 0.5*L - refL[1], -100.0, -100.0, - 100.0, 100.0, 100.0 ) ); - - firstRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - 100.0, 100.0, -0.5*H + refL[1] ) ); - firstRefLevel.add( new Cuboid (-100.0, -100.0, 0.5*H - refL[1], - 100.0, 100.0, 100.0 ) ); - - gridBuilder->addGrid( &firstRefLevel, 2); - - ////////////////////////////////////////////////////////////////////////// - - Conglomerate secondRefLevel; - - if( rank % 2 == 0 ) secondRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - -0.5*L + refL[2], 100.0, 100.0 ) ); - else secondRefLevel.add( new Cuboid ( 0.5*L - refL[2], -100.0, -100.0, - 100.0, 100.0, 100.0 ) ); - - if( rank % 2 == 0 ) secondRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - -0.5*L + refL[0], 100.0, -0.5*H + refL[2] ) ); - else secondRefLevel.add( new Cuboid ( 0.5*L - refL[0], -100.0, -100.0, - 100.0, 100.0, -0.5*H + refL[2] ) ); - - if( rank % 2 == 0 ) secondRefLevel.add( new Cuboid (-100.0, -100.0, 0.5*H - refL[2], - -0.5*L + refL[0], 100.0, 100.0 ) ); - else secondRefLevel.add( new Cuboid ( 0.5*L - refL[0], -100.0, 0.5*H - refL[2], - 100.0, 100.0, 100.0 ) ); - - gridBuilder->addGrid( &secondRefLevel, 3); - - ////////////////////////////////////////////////////////////////////////// - - Conglomerate thirdRefLevel; - - if( rank % 2 == 0 ) thirdRefLevel.add( new Cuboid (-100.0, -100.0, -100.0, - -0.5*L + refL[3], 100.0, 100.0 ) ); - else thirdRefLevel.add( new Cuboid ( 0.5*L - refL[3], -100.0, -100.0, - 100.0, 100.0, 100.0 ) ); - - if( fine ) gridBuilder->addGrid( &thirdRefLevel, 4); - - ////////////////////////////////////////////////////////////////////////// - - if( rank % 2 == 0 ) startX = -100.0; - else startX = 0.0; - if( rank % 2 == 0 ) endX = 0.0; - else endX = 100.0; - - if( mpiWorldSize == 2 ) - { - startY = -100.0; - endY = 100.0; - } - else - { - startY = real(rank/2) * W; - endY = ( real(rank/2) + 1.0 ) * W; - } - - startZ = -100.0; - endZ = 100.0; - - auto subDomainBox = std::make_shared<BoundingBox>( startX, endX, - startY, endY, - startZ, endZ ); - - gridBuilder->setSubDomainBox( subDomainBox ); - - ////////////////////////////////////////////////////////////////////////// - - if( mpiWorldSize == 2 ) gridBuilder->setPeriodicBoundaryCondition(false, true, false); - else gridBuilder->setPeriodicBoundaryCondition(false, false, false); - - gridBuilder->buildGrids(GKS, false); - - //gridBuilder->writeGridsToVtk( path + simulationName + "_0" + "_rank_" + std::to_string(rank) + "_lev_" ); - - ////////////////////////////////////////////////////////////////////////// - - if( rank%2 == 0 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PX, GKS ); - else gridBuilder->findCommunicationIndices( CommunicationDirections::MX, GKS ); - - if( rank%2 == 0 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::PX, rank + 1 ); - else gridBuilder->setCommunicationProcess ( CommunicationDirections::MX, rank - 1 ); - - ////////////////////////////////////////////////////////////////////////// - - if( mpiWorldSize > 2 ) - { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, GKS); - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, GKS); - - gridBuilder->setCommunicationProcess(CommunicationDirections::PY, (rank + 2 + mpiWorldSize) % mpiWorldSize); - gridBuilder->setCommunicationProcess(CommunicationDirections::MY, (rank - 2 + mpiWorldSize) % mpiWorldSize); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - if( mpiWorldSize == 2 ) meshAdapter.findPeriodicBoundaryNeighbors(); - - //meshAdapter.writeMeshFaceVTK( path + simulationName + "_0" + "_rank_" + std::to_string(rank) + ".vtk" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // B o u n d a r y C o n d i t i o n s - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaHot , false ); - SPtr<BoundaryCondition> bcPX = std::make_shared<IsothermalWall>( dataBase, Vec3(0.0, 0.0, 0.0), lambdaCold, false ); - - bcMX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -0.5*L; } ); - bcPX->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x > 0.5*L; } ); - - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcMZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0,0,0), true ); - SPtr<BoundaryCondition> bcPZ = std::make_shared<AdiabaticWall>( dataBase, Vec3(0,0,0), true ); - - bcMZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z < -0.5*H; } ); - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5*H; } ); - - ////////////////////////////////////////////////////////////////////////// - - if( mpiWorldSize == 2 ) - { - SPtr<BoundaryCondition> bcMY = std::make_shared<Periodic>(dataBase); - SPtr<BoundaryCondition> bcPY = std::make_shared<Periodic>(dataBase); - - bcMY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y < 0; }); - bcPY->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { return center.y > W; }); - - dataBase->boundaryConditions.push_back(bcMY); - dataBase->boundaryConditions.push_back(bcPY); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->boundaryConditions.push_back( bcMZ ); - dataBase->boundaryConditions.push_back( bcPZ ); - - dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPX ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // I n i t i a l C o n d i t i o n s - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - uint startIter = 0; - - dataBase->setMesh( meshAdapter ); - - dataBase->setCommunicators( meshAdapter ); - - CudaUtility::printCudaMemoryUsage(); - - if( restartIter == INVALID_INDEX ) - { - Initializer::interpret(dataBase, [&](Vec3 cellCenter) -> ConservedVariables { - - //real Th = 1.0 / lambdaHot; - //real Tc = 1.0 / lambdaCold; - //real T = Th - (Th - Tc)*((cellCenter.x + 0.5 * L) / L); - //real lambdaLocal = 1.0 / T; - - return toConservedVariables(PrimitiveVariables(rho, 0.0, 0.0, 0.0, lambda), parameters.K); - }); - - if (rank == 0) writeVtkXMLParallelSummaryFile(dataBase, parameters, path + simulationName + "_0", mpiWorldSize); - - writeVtkXML(dataBase, parameters, 0, path + simulationName + "_0" + "_rank_" + std::to_string(rank)); - } - else - { - Restart::readRestart( dataBase, path + simulationName + "_" + std::to_string( restartIter ) + "_rank_" + std::to_string(rank), startIter ); - - if (rank == 0) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_" + std::to_string( restartIter ) + "_restart", mpiWorldSize ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( restartIter ) + "_restart" + "_rank_" + std::to_string(rank) ); - - - } - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // R u n - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 300.0 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase ); - - //auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 0 ); - auto turbulenceAnalyzer = std::make_shared<TurbulenceAnalyzer>( dataBase, 500000 ); - - turbulenceAnalyzer->collect_UU = true; - turbulenceAnalyzer->collect_VV = true; - turbulenceAnalyzer->collect_WW = true; - turbulenceAnalyzer->collect_UV = true; - turbulenceAnalyzer->collect_UW = true; - turbulenceAnalyzer->collect_VW = true; - - turbulenceAnalyzer->allocate(); - - if( restartIter != INVALID_INDEX ) - turbulenceAnalyzer->readRestartFile( path + simulationName + "_Turbulence_" + std::to_string( restartIter ) + "_rank_" + std::to_string(rank) ); - - auto pointTimeSeriesCollector = std::make_shared<PointTimeSeriesCollector>(); - - for( real y = 0.5 * W; y < real( mpiWorldSize / 2 ) * W; y += W ) - { - if( subDomainBox->isInside( -0.485, y, -0.3*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( -0.485, y, -0.3*H ), 'W', 10000 ); - if( subDomainBox->isInside( -0.485, y, -0.1*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( -0.485, y, -0.1*H ), 'W', 10000 ); - if( subDomainBox->isInside( -0.485, y, 0.1*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( -0.485, y, 0.1*H ), 'W', 10000 ); - if( subDomainBox->isInside( -0.485, y, 0.3*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( -0.485, y, 0.3*H ), 'W', 10000 ); - - if( subDomainBox->isInside( 0.485, y, -0.3*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( 0.485, y, -0.3*H ), 'W', 10000 ); - if( subDomainBox->isInside( 0.485, y, -0.1*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( 0.485, y, -0.1*H ), 'W', 10000 ); - if( subDomainBox->isInside( 0.485, y, 0.1*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( 0.485, y, 0.1*H ), 'W', 10000 ); - if( subDomainBox->isInside( 0.485, y, 0.3*H ) ) pointTimeSeriesCollector->addAnalyzer( dataBase, meshAdapter, Vec3( 0.485, y, 0.3*H ), 'W', 10000 ); - } - - ////////////////////////////////////////////////////////////////////////// - - cupsAnalyzer.start(); - - for( uint iter = startIter + 1; iter <= 100000000; iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( iter % 200000 == 0 ) - { - dataBase->copyDataDeviceToHost(); - - if( rank == 0 ) writeVtkXMLParallelSummaryFile( dataBase, parameters, path + simulationName + "_" + std::to_string( iter ), mpiWorldSize ); - - writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) + "_rank_" + std::to_string(rank) ); - } - - cupsAnalyzer.run( iter, parameters.dt ); - - convergenceAnalyzer.run( iter ); - - turbulenceAnalyzer->run( iter, parameters ); - - pointTimeSeriesCollector->run(iter, parameters); - - if( iter > 500000 && iter % 200000 == 0 ) - //if(iter % 1000 == 0) - { - turbulenceAnalyzer->download(); - - if( rank == 0 ) writeTurbulenceVtkXMLParallelSummaryFile( dataBase, turbulenceAnalyzer, parameters, path + simulationName + "_Turbulence_" + std::to_string( iter ), mpiWorldSize ); - - writeTurbulenceVtkXML( dataBase, turbulenceAnalyzer, 0, path + simulationName + "_Turbulence_" + std::to_string( iter ) + "_rank_" + std::to_string(rank) ); - } - - if( iter > 500000 && iter % 200000 == 0 ) - { - Restart::writeRestart( dataBase, path + simulationName + "_" + std::to_string( iter ) + "_rank_" + std::to_string(rank), iter ); - - turbulenceAnalyzer->writeRestartFile( path + simulationName + "_Turbulence_" + std::to_string( iter ) + "_rank_" + std::to_string(rank) ); - } - - if( iter % 1000000 == 0 ) - { - pointTimeSeriesCollector->writeToFile(path + simulationName + "_TimeSeries_" + std::to_string( iter ) + "_rank_" + std::to_string(rank)); - } - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); -} - - - -int main( int argc, char* argv[]) -{ - ////////////////////////////////////////////////////////////////////////// - - bool fine = false; - - bool highAspect = true; - - ////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - MPI_Init(&argc, &argv); - int rank = 0; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - int mpiWorldSize = 1; - MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); -#else - int rank = MpiUtility::getMpiRankBeforeInit(); - int mpiWorldSize = MpiUtility::getMpiWorldSizeBeforeInit(); -#endif - - if( mpiWorldSize < 2 || mpiWorldSize%2 != 0 ) - { - std::cerr << "Error: MpiWolrdSize must be multiple of 2!\n"; - return 1; - } - - ////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - std::string path( "F:/Work/Computations/out/ThermalCavity3D/" ); -#else - std::string path( "out/" ); -#endif - - std::string simulationName ( "ThermalCavity3D" ); - - if(fine) simulationName += "_fine"; - else simulationName += "_coarse"; - - ////////////////////////////////////////////////////////////////////////// - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + "_rank_" + std::to_string(rank) + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - ////////////////////////////////////////////////////////////////////////// - - // Important: for Cuda-Aware MPI the device must be set before MPI_Init() - int deviceCount = CudaUtility::getCudaDeviceCount(); - - if(deviceCount == 0) - { - std::stringstream msg; - msg << "No devices devices found!" << std::endl; - *logging::out << logging::Logger::WARNING << msg.str(); msg.str(""); - } - - CudaUtility::setCudaDevice( rank % deviceCount ); - - ////////////////////////////////////////////////////////////////////////// - -#ifndef _WIN32 - MPI_Init(&argc, &argv); -#endif - - ////////////////////////////////////////////////////////////////////////// - - if( sizeof(real) == 4 ) - *logging::out << logging::Logger::INFO_HIGH << "Using Single Precision\n"; - else - *logging::out << logging::Logger::INFO_HIGH << "Using Double Precision\n"; - - try - { - uint restartIter = INVALID_INDEX; - - if( argc > 1 ) restartIter = atoi( argv[1] ); - - simulation(path, simulationName, fine, highAspect, restartIter); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - logFile.close(); - - MPI_Finalize(); - - return 0; -} diff --git a/apps/gpu/GKS/gksTest/3rdPartyLinking.cmake b/apps/gpu/GKS/gksTest/3rdPartyLinking.cmake deleted file mode 100644 index 72c7afc6076b832263506ab9ce777925cfcc6a66..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/gksTest/3rdPartyLinking.cmake +++ /dev/null @@ -1,11 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOUR#CE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() diff --git a/apps/gpu/GKS/gksTest/CMakeLists.txt b/apps/gpu/GKS/gksTest/CMakeLists.txt deleted file mode 100644 index d404310177a2f53760d1c84bce79d7d070fed409..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/gksTest/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink Core GridGenerator GksMeshAdapter GksVtkAdapter GksGpu) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Core" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/GksMeshAdapter" - "${CMAKE_SOURCE_DIR}/src/GksVtkAdapter" - "${CMAKE_SOURCE_DIR}/src/GksGpu") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${gksAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) diff --git a/apps/gpu/GKS/gksTest/CMakePackage.cmake b/apps/gpu/GKS/gksTest/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/gksTest/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/GKS/gksTest/main.cpp b/apps/gpu/GKS/gksTest/main.cpp deleted file mode 100644 index b66017eeaf727def602b9ab9f41556a8dd5a984e..0000000000000000000000000000000000000000 --- a/apps/gpu/GKS/gksTest/main.cpp +++ /dev/null @@ -1,228 +0,0 @@ -//#define MPI_LOGGING - -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <iostream> -#include <exception> -#include <fstream> -#include <memory> - -#include "Core/Timer/Timer.h" -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GridGenerator/geometries/Cuboid/Cuboid.h" - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/GridFactory.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksVtkAdapter/VTKInterface.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" -#include "GksGpu/BoundaryConditions/Periodic.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -void gksTest( std::string path ) -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real L = 1.0; - - real dx = L / 8.0; - - real Re = 2.0e3; - real U = 0.1; - real Ma = 0.1; - - real Pr = 1.0; - real K = 0.0; - - real rho = 1.0; - - real mu = U * rho * L / Re; - - real cs = U / Ma; - real lambda = c1o2 * ( ( K + 4.0 ) / ( K + 2.0 ) ) / ( cs * cs ); - - real CFL = 0.5; - - real dt = CFL * ( dx / ( ( U + cs ) * ( one + ( two * mu ) / ( U * dx * rho ) ) ) ); - - ////////////////////////////////////////////////////////////////////////// - - Parameters parameters; - - parameters.K = K; - parameters.Pr = Pr; - parameters.mu = mu; - - parameters.force.x = 0; - parameters.force.y = 0; - parameters.force.z = 0; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - parameters.viscosityModel = ViscosityModel::constant; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - gridBuilder->addCoarseGrid(-0.5, -0.5, -0.5, - 0.5, 0.5, 0.5, dx); - - Cuboid refBox(-1.0, -1.0, 0, 1.0, 1.0, 0.55); - - gridBuilder->setNumberOfLayers(1,1); - gridBuilder->addGrid( &refBox, 1); - - gridBuilder->setPeriodicBoundaryCondition(true, false, false); - - gridBuilder->buildGrids(GKS, false); - - gridBuilder->writeGridsToVtk(path + "grid/Grid_lev_"); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - meshAdapter.writeMeshVTK( path + "grid/Mesh.vtk" ); - - meshAdapter.writeMeshFaceVTK( path + "grid/MeshFaces.vtk" ); - - meshAdapter.findPeriodicBoundaryNeighbors(); - - return; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CudaUtility::setCudaDevice(0); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - dataBase->setMesh( meshAdapter ); - - ////////////////////////////////////////////////////////////////////////// - - //SPtr<BoundaryCondition> bcMX = std::make_shared<Periodic>( dataBase ); - - //bcMX->findBoundaryCells( meshAdapter, [&](Vec3 center){ - // return center.x < -0.5 || center.x > 0.5; - //} ); - - SPtr<BoundaryCondition> bcPZ = std::make_shared<IsothermalWall>( dataBase, Vec3( U, U, 0.0 ), lambda, 0.0, true ); - - bcPZ->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ - return center.z > 0.5; - } ); - - SPtr<BoundaryCondition> bcWall = std::make_shared<IsothermalWall>( dataBase, Vec3( 0.0, 0.0, 0.0 ), lambda, 0.0, true ); - - bcWall->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ - return center.z < 0.5; - } ); - - //dataBase->boundaryConditions.push_back( bcMX ); - dataBase->boundaryConditions.push_back( bcPZ ); - dataBase->boundaryConditions.push_back( bcWall ); - - ////////////////////////////////////////////////////////////////////////// - - CudaUtility::printCudaMemoryUsage(); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables { - - real radius = cellCenter.length(); - - return toConservedVariables( PrimitiveVariables( 1.0, 0.0, 0.0, 0.0, lambda, 0.0 ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - writeVtkXML( dataBase, parameters, 0, path + "grid/Test_0" ); - - ////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, true, 30.0 ); - - cupsAnalyzer.start(); - - for( uint iter = 1; iter < 100000; iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, parameters, nullptr, 0); - - if( iter % 10000 == 0 ) - { - dataBase->copyDataDeviceToHost(); - - writeVtkXML( dataBase, parameters, 0, path + "grid/Test_" + std::to_string( iter ) ); - } - - cupsAnalyzer.run( iter ); - } - - ////////////////////////////////////////////////////////////////////////// - - dataBase->copyDataDeviceToHost(); - - //writeVtkXML( dataBase, parameters, 0, path + "grid/Test_1" ); - - -} - -int main( int argc, char* argv[]) -{ - std::string path( "F:/Work/Computations/" ); - //std::string path( "out/" ); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - try - { - gksTest( path ); - } - catch (const std::exception& e) - { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - } - catch (const std::bad_alloc& e) - { - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/HULC/main.cpp b/apps/gpu/HULC/main.cpp deleted file mode 100644 index 80f8ba4c62b3b0af08425f839d0f802a568db034..0000000000000000000000000000000000000000 --- a/apps/gpu/HULC/main.cpp +++ /dev/null @@ -1,411 +0,0 @@ -//#define MPI_LOGGING - - -#include <mpi.h> -#if defined( MPI_LOGGING ) - #include <mpe.h> -#endif - -#include <string> -#include <iostream> - -#include "LBM/Simulation.h" - -#include "Parameter/Parameter.h" -#include "DataStructureInitializer/GridProvider.h" -#include "VirtualFluidsBasics/utilities/input/Input.h" -#include "VirtualFluidsBasics/utilities/StringUtil/StringUtil.h" -#include "grid/GridBuilder/LevelGridBuilder.h" -#include "utilities/transformator/TransformatorImp.h" -#include "io/GridVTKWriter/GridVTKWriter.h" - -#include "io/SimulationFileWriter/SimulationFileWriter.h" -#include "grid/GridBuilder/LevelGridBuilder.h" -#include "grid/GridBuilder/ParallelGridBuilder.h" -#include "geometries/TriangularMesh/TriangularMesh.h" - -#include "grid/GridFactory.h" -#include "grid/GridBuilder/MultipleGridBuilder.h" -#include <grid/GridMocks.h> -#include "grid/GridStrategy/GridStrategyMocks.h" -#include "VirtualFluidsBasics/utilities/logger/Logger.h" -#include "geometries/Conglomerate/Conglomerate.h" -#include "io/STLReaderWriter/STLReader.h" -#include "io/STLReaderWriter/STLWriter.h" -#include "geometries/TriangularMesh/TriangularMeshStrategy.h" -#include "Output/FileWriter.h" - - -#include "Kernel/Utilities/KernelFactory/KernelFactoryImp.h" -#include "PreProcessor/PreProcessorFactory/PreProcessorFactoryImp.h" - - -std::string getGridPath(std::shared_ptr<Parameter> para, std::string Gridpath) -{ - if (para->getNumprocs() == 1) - return Gridpath + "/"; - - return Gridpath + "/" + StringUtil::toString(para->getMyID()) + "/"; -} - -void setParameters(std::shared_ptr<Parameter> para, std::unique_ptr<input::Input> &input) -{ - std::string _path = input->getValue("Path"); - std::string _prefix = input->getValue("Prefix"); - std::string _gridpath = input->getValue("GridPath"); - para->setNumprocs(1); - std::string gridPath = getGridPath(para, _gridpath); - para->setMaxDev(StringUtil::toInt(input->getValue("NumberOfDevices"))); - para->setDevices(StringUtil::toIntVector(input->getValue("Devices"))); - para->setOutputPath(_path); - para->setOutputPrefix(_prefix); - para->setPathAndFilename(_path + "/" + _prefix); - para->setPrintFiles(false); - para->setPrintFiles(StringUtil::toBool(input->getValue("WriteGrid"))); - para->setGeometryValues(StringUtil::toBool(input->getValue("GeometryValues"))); - para->setCalc2ndOrderMoments(StringUtil::toBool(input->getValue("calc2ndOrderMoments"))); - para->setCalc3rdOrderMoments(StringUtil::toBool(input->getValue("calc3rdOrderMoments"))); - para->setCalcHighOrderMoments(StringUtil::toBool(input->getValue("calcHigherOrderMoments"))); - para->setReadGeo(StringUtil::toBool(input->getValue("ReadGeometry"))); - para->setCalcMedian(StringUtil::toBool(input->getValue("calcMedian"))); - para->setConcFile(StringUtil::toBool(input->getValue("UseConcFile"))); - para->setUseMeasurePoints(StringUtil::toBool(input->getValue("UseMeasurePoints"))); - para->setUseWale(StringUtil::toBool(input->getValue("UseWale"))); - para->setSimulatePorousMedia(StringUtil::toBool(input->getValue("SimulatePorousMedia"))); - para->setD3Qxx(StringUtil::toInt(input->getValue("D3Qxx"))); - para->setTimestepEnd(StringUtil::toInt(input->getValue("TimeEnd"))); - para->setTimestepOut(StringUtil::toInt(input->getValue("TimeOut"))); - para->setTimestepStartOut(StringUtil::toInt(input->getValue("TimeStartOut"))); - para->setTimeCalcMedStart(StringUtil::toInt(input->getValue("TimeStartCalcMedian"))); - para->setTimeCalcMedEnd(StringUtil::toInt(input->getValue("TimeEndCalcMedian"))); - para->setPressInID(StringUtil::toInt(input->getValue("PressInID"))); - para->setPressOutID(StringUtil::toInt(input->getValue("PressOutID"))); - para->setPressInZ(StringUtil::toInt(input->getValue("PressInZ"))); - para->setPressOutZ(StringUtil::toInt(input->getValue("PressOutZ"))); - ////////////////////////////////////////////////////////////////////////// - para->setCompOn(StringUtil::toBool(input->getValue("CompOn"))); - para->setDiffOn(StringUtil::toBool(input->getValue("DiffOn"))); - para->setDiffMod(StringUtil::toInt(input->getValue("DiffMod"))); - para->setDiffusivity(StringUtil::toFloat(input->getValue("Diffusivity"))); - para->setTemperatureInit(StringUtil::toFloat(input->getValue("Temp"))); - para->setTemperatureBC(StringUtil::toFloat(input->getValue("TempBC"))); - ////////////////////////////////////////////////////////////////////////// - para->setViscosityLB(StringUtil::toFloat(input->getValue("Viscosity_LB"))); - para->setVelocityLB(StringUtil::toFloat(input->getValue("Velocity_LB"))); - para->setViscosityRatio(StringUtil::toFloat(input->getValue("Viscosity_Ratio_World_to_LB"))); - para->setVelocityRatio(StringUtil::toFloat(input->getValue("Velocity_Ratio_World_to_LB"))); - para->setDensityRatio(StringUtil::toFloat(input->getValue("Density_Ratio_World_to_LB"))); - para->setPressRatio(StringUtil::toFloat(input->getValue("Delta_Press"))); - para->setRealX(StringUtil::toFloat(input->getValue("SliceRealX"))); - para->setRealY(StringUtil::toFloat(input->getValue("SliceRealY"))); - para->setFactorPressBC(StringUtil::toFloat(input->getValue("dfpbc"))); - para->setGeometryFileC(input->getValue("GeometryC")); - para->setGeometryFileM(input->getValue("GeometryM")); - para->setGeometryFileF(input->getValue("GeometryF")); - ////////////////////////////////////////////////////////////////////////// - para->setgeoVec(gridPath + input->getValue("geoVec")); - para->setcoordX(gridPath + input->getValue("coordX")); - para->setcoordY(gridPath + input->getValue("coordY")); - para->setcoordZ(gridPath + input->getValue("coordZ")); - para->setneighborX(gridPath + input->getValue("neighborX")); - para->setneighborY(gridPath + input->getValue("neighborY")); - para->setneighborZ(gridPath + input->getValue("neighborZ")); - para->setscaleCFC(gridPath + input->getValue("scaleCFC")); - para->setscaleCFF(gridPath + input->getValue("scaleCFF")); - para->setscaleFCC(gridPath + input->getValue("scaleFCC")); - para->setscaleFCF(gridPath + input->getValue("scaleFCF")); - para->setscaleOffsetCF(gridPath + input->getValue("scaleOffsetCF")); - para->setscaleOffsetFC(gridPath + input->getValue("scaleOffsetFC")); - para->setgeomBoundaryBcQs(gridPath + input->getValue("geomBoundaryBcQs")); - para->setgeomBoundaryBcValues(gridPath + input->getValue("geomBoundaryBcValues")); - para->setinletBcQs(gridPath + input->getValue("inletBcQs")); - para->setinletBcValues(gridPath + input->getValue("inletBcValues")); - para->setoutletBcQs(gridPath + input->getValue("outletBcQs")); - para->setoutletBcValues(gridPath + input->getValue("outletBcValues")); - para->settopBcQs(gridPath + input->getValue("topBcQs")); - para->settopBcValues(gridPath + input->getValue("topBcValues")); - para->setbottomBcQs(gridPath + input->getValue("bottomBcQs")); - para->setbottomBcValues(gridPath + input->getValue("bottomBcValues")); - para->setfrontBcQs(gridPath + input->getValue("frontBcQs")); - para->setfrontBcValues(gridPath + input->getValue("frontBcValues")); - para->setbackBcQs(gridPath + input->getValue("backBcQs")); - para->setbackBcValues(gridPath + input->getValue("backBcValues")); - para->setnumberNodes(gridPath + input->getValue("numberNodes")); - para->setLBMvsSI(gridPath + input->getValue("LBMvsSI")); - //////////////////////////////gridPath + //////////////////////////////////////////// - para->setmeasurePoints(gridPath + input->getValue("measurePoints")); - para->setpropellerValues(gridPath + input->getValue("propellerValues")); - para->setclockCycleForMP(StringUtil::toFloat(input->getValue("measureClockCycle"))); - para->settimestepForMP(StringUtil::toInt(input->getValue("measureTimestep"))); - para->setcpTop(gridPath + input->getValue("cpTop")); - para->setcpBottom(gridPath + input->getValue("cpBottom")); - para->setcpBottom2(gridPath + input->getValue("cpBottom2")); - para->setConcentration(gridPath + input->getValue("Concentration")); - ////////////////////////////////////////////////////////////////////////// - //Normals - Geometry - para->setgeomBoundaryNormalX(gridPath + input->getValue("geomBoundaryNormalX")); - para->setgeomBoundaryNormalY(gridPath + input->getValue("geomBoundaryNormalY")); - para->setgeomBoundaryNormalZ(gridPath + input->getValue("geomBoundaryNormalZ")); - //Normals - Inlet - para->setInflowBoundaryNormalX(gridPath + input->getValue("inletBoundaryNormalX")); - para->setInflowBoundaryNormalY(gridPath + input->getValue("inletBoundaryNormalY")); - para->setInflowBoundaryNormalZ(gridPath + input->getValue("inletBoundaryNormalZ")); - //Normals - Outlet - para->setOutflowBoundaryNormalX(gridPath + input->getValue("outletBoundaryNormalX")); - para->setOutflowBoundaryNormalY(gridPath + input->getValue("outletBoundaryNormalY")); - para->setOutflowBoundaryNormalZ(gridPath + input->getValue("outletBoundaryNormalZ")); - ////////////////////////////////////////////////////////////////////////// - //Forcing - para->setForcing(StringUtil::toFloat(input->getValue("ForcingX")), StringUtil::toFloat(input->getValue("ForcingY")), StringUtil::toFloat(input->getValue("ForcingZ"))); - ////////////////////////////////////////////////////////////////////////// - //Particles - para->setCalcParticles(StringUtil::toBool(input->getValue("calcParticles"))); - para->setParticleBasicLevel(StringUtil::toInt(input->getValue("baseLevel"))); - para->setParticleInitLevel(StringUtil::toInt(input->getValue("initLevel"))); - para->setNumberOfParticles(StringUtil::toInt(input->getValue("numberOfParticles"))); - para->setneighborWSB(gridPath + input->getValue("neighborWSB")); - para->setStartXHotWall(StringUtil::toDouble(input->getValue("startXHotWall"))); - para->setEndXHotWall(StringUtil::toDouble(input->getValue("endXHotWall"))); - ////////////////////////////////////////////////////////////////////////// - //for Multi GPU - if (para->getNumprocs() > 1) - { - //////////////////////////////////////////////////////////////////////////// - ////1D domain decomposition - //std::vector<std::string> sendProcNeighbors; - //std::vector<std::string> recvProcNeighbors; - //for (int i = 0; i<para->getNumprocs();i++) - //{ - // sendProcNeighbors.push_back(gridPath + StringUtil::toString(i) + "s.dat"); - // recvProcNeighbors.push_back(gridPath + StringUtil::toString(i) + "r.dat"); - //} - //para->setPossNeighborFiles(sendProcNeighbors, "send"); - //para->setPossNeighborFiles(recvProcNeighbors, "recv"); - ////////////////////////////////////////////////////////////////////////// - //3D domain decomposition - std::vector<std::string> sendProcNeighborsX, sendProcNeighborsY, sendProcNeighborsZ; - std::vector<std::string> recvProcNeighborsX, recvProcNeighborsY, recvProcNeighborsZ; - for (int i = 0; i < para->getNumprocs(); i++) - { - sendProcNeighborsX.push_back(gridPath + StringUtil::toString(i) + "Xs.dat"); - sendProcNeighborsY.push_back(gridPath + StringUtil::toString(i) + "Ys.dat"); - sendProcNeighborsZ.push_back(gridPath + StringUtil::toString(i) + "Zs.dat"); - recvProcNeighborsX.push_back(gridPath + StringUtil::toString(i) + "Xr.dat"); - recvProcNeighborsY.push_back(gridPath + StringUtil::toString(i) + "Yr.dat"); - recvProcNeighborsZ.push_back(gridPath + StringUtil::toString(i) + "Zr.dat"); - } - para->setPossNeighborFilesX(sendProcNeighborsX, "send"); - para->setPossNeighborFilesY(sendProcNeighborsY, "send"); - para->setPossNeighborFilesZ(sendProcNeighborsZ, "send"); - para->setPossNeighborFilesX(recvProcNeighborsX, "recv"); - para->setPossNeighborFilesY(recvProcNeighborsY, "recv"); - para->setPossNeighborFilesZ(recvProcNeighborsZ, "recv"); - } - ////////////////////////////////////////////////////////////////////////// - //para->setkFull( input->getValue( "kFull" )); - //para->setgeoFull( input->getValue( "geoFull" )); - //para->setnoSlipBcPos( input->getValue( "noSlipBcPos" )); - //para->setnoSlipBcQs( input->getValue( "noSlipBcQs" )); - //para->setnoSlipBcValues( input->getValue( "noSlipBcValues" )); - //para->setnoSlipBcValue( input->getValue( "noSlipBcValue" )); - //para->setslipBcPos( input->getValue( "slipBcPos" )); - //para->setslipBcQs( input->getValue( "slipBcQs" )); - //para->setslipBcValue( input->getValue( "slipBcValue" )); - //para->setpressBcPos( input->getValue( "pressBcPos" )); - //para->setpressBcQs( input->getValue( "pressBcQs" )); - //para->setpressBcValues( input->getValue( "pressBcValues" )); - //para->setpressBcValue( input->getValue( "pressBcValue" )); - //para->setvelBcQs( input->getValue( "velBcQs" )); - //para->setvelBcValues( input->getValue( "velBcValues" )); - //para->setpropellerCylinder( input->getValue( "propellerCylinder" )); - //para->setpropellerQs( input->getValue( "propellerQs" )); - //para->setwallBcQs( input->getValue( "wallBcQs" )); - //para->setwallBcValues( input->getValue( "wallBcValues" )); - //para->setperiodicBcQs( input->getValue( "periodicBcQs" )); - //para->setperiodicBcValues( input->getValue( "periodicBcValues" )); - //cout << "Try this: " << para->getgeomBoundaryBcValues() << endl; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //Restart - para->setTimeDoCheckPoint(StringUtil::toInt(input->getValue("TimeDoCheckPoint"))); - para->setTimeDoRestart(StringUtil::toInt(input->getValue("TimeDoRestart"))); - para->setDoCheckPoint(StringUtil::toBool(input->getValue("DoCheckPoint"))); - para->setDoRestart(StringUtil::toBool(input->getValue("DoRestart"))); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -/* para->setMaxLevel(StringUtil::toInt(input->getValue("NOGL"))); - para->setGridX(StringUtil::toVector(input->getValue("GridX"))); - para->setGridY(StringUtil::toVector(input->getValue("GridY"))); - para->setGridZ(StringUtil::toVector(input->getValue("GridZ"))); - para->setDistX(StringUtil::toVector(input->getValue("DistX"))); - para->setDistY(StringUtil::toVector(input->getValue("DistY"))); - para->setDistZ(StringUtil::toVector(input->getValue("DistZ"))); */ - - para->setNeedInterface(std::vector<bool>{true, true, true, true, true, true}); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Kernel - para->setMainKernel(input->getValue("MainKernelName")); - para->setMultiKernelOn(StringUtil::toBool(input->getValue("multiKernelOn"))); - para->setMultiKernelLevel(StringUtil::toIntVector(input->getValue("multiKernelLevel"))); - para->setMultiKernelName(StringUtil::toStringVector(input->getValue("multiKernelName"))); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -} - - - -void multipleLevel(const std::string& configPath) -{ - logging::Logger::setStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - - auto gridFactory = SPtr<GridFactory>(new GridFactory()); - gridFactory->setGridStrategy(SPtr<GridStrategy>(new GridCpuStrategy())); - gridFactory->setGrid("grid"); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::RAYCASTING); - - //auto gridBuilderlevel = LevelGridBuilder::makeShared(Device::CPU, "D3Q27"); - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //Conglomerate* conglomerate = new Conglomerate(); - //conglomerate->add(new Cuboid(10, 10, 10, 30, 30, 30)); - //conglomerate->subtract(new Sphere(30, 20, 20, 4)); - //gridBuilder->addGrid(conglomerate, 2); - - -// gridBuilder->addCoarseGrid(0.0, 0.0, 0.0, 14, 10, 20, 0.25); - //TriangularMesh* triangularMesh = TriangularMesh::make("D:/GRIDGENERATION/STL/quadarBinaer.stl", DiscretizationMethod::POINT_IN_OBJECT); - - - gridBuilder->addCoarseGrid(-10, -8, -3, 50, 20, 20, 0.25); - TriangularMesh* triangularMesh = TriangularMesh::make("D:/GRIDGENERATION/STL/input/local_input/bruecke.stl", DiscretizationMethod::RAYCASTING); - - - //TriangleOffsetSurfaceGeneration::createOffsetTriangularMesh(triangularMesh, 5); - - //TriangularMesh* sphere = TriangularMesh::make("D:/GRIDGENERATION/STL/GTI.stl", DiscretizationMethod::RAYCASTING); - //TransformatorImp trans(1.0, Vertex(5.5, 1, 12)); - //trans.transformWorldToGrid(*sphere); - //STLWriter::writeSTL(sphere->triangleVec, "D:/GRIDGENERATION/STL/GTI2.stl", false); - - //gridBuilder->addGrid(new Sphere(20, 20, 20, 8)); - gridBuilder->addGrid(triangularMesh, 2); - - //gridBuilder->addFineGrid(new Cuboid(15, 15, 15, 25, 25, 25), 1); - //gridBuilder->addFineGrid(new Cuboid(17, 17, 17, 23, 23, 23), 2); - - - //gridBuilder->addFineGrid(17.0, 17.0, 17.0, 20.0, 20.0, 20.0, 3); - //gridBuilder->addFineGrid(10.0, 10.0, 10.0, 20.0, 20.0, 20.0, 3); - - - //gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTest_level_2", 2); - - gridBuilder->buildGrids(); - - gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTestSphere_level_0", 0); - gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTestSphere_level_1", 1); - gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTestSphere_level_2", 2); - - //gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTestCuboid_level_0", 0); - //gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTestCuboid_level_1", 1); - - //SimulationFileWriter::write("D:/GRIDGENERATION/couplingVF/test/simu/", gridBuilder, FILEFORMAT::ASCII); - - //const uint level = 2; - //gridBuilder->addFineGrid(0.0, 0.0, 0.0, 10.0, 10.0, 10.0, level); - //gridBuilderlevel->setGrids(gridBuilder->getGrids()); - - - //gridBuilder->addGrid(14.4921875, 14.4921875, 14.4921875, 16.5078125, 16.5078125, 16.5078125, 0.015625, "cpu", "D3Q27", false, false, false); - //gridBuilder->addGrid(13.984375, 13.984375, 13.984375, 17.015625, 17.015625, 17.015625, 0.03125, "cpu", "D3Q27", false, false, false); - //gridBuilder->addGrid(13.46875, 13.46875, 13.46875, 17.53125, 17.53125, 17.53125, 0.0625, "cpu", "D3Q27", false, false, false); - //gridBuilder->addGrid(12.4375, 12.4375, 12.4375, 18.5625, 18.5625, 18.5625, 0.125, "gpu", "D3Q27", false, false, false); - //gridBuilder->addGrid(10.375, 10.375, 10.375, 20.625, 20.625, 20.625, 0.25, "gpu", "D3Q27", false, false, false); - //gridBuilder->addGrid(5.25, 5.25, 5.25, 24.75, 24.75, 24.75, 0.5, "gpu", "D3Q27", false, false, false); - //gridBuilder->addGrid(0.0, 0.0, 0.0, 30.0, 30.0, 30.0, 1.0, "gpu", "D3Q27", true, true, true); - - - //gridBuilder->copyDataFromGpu(); - - //gridBuilder->meshGeometry("D:/GRIDGENERATION/STL/circleBinaer.stl", 1); - //gridBuilder->meshGeometry("D:/GRIDGENERATION/STL/circleBinaer.stl", 0); - //gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTest_level_1", 1); - //gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTest_level_0", 0); - //gridBuilder->writeGridToVTK("D:/GRIDGENERATION/gridTest_level_2", 2); - - SPtr<Parameter> para = Parameter::make(); - SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, communicator); - //SPtr<GridProvider> gridGenerator = GridProvider::makeGridReader(false, para); - - std::ifstream stream; - stream.open(configPath.c_str(), std::ios::in); - if (stream.fail()) - throw "can not open config file!\n"; - - UPtr<input::Input> input = input::Input::makeInput(stream, "config"); - - setParameters(para, input); - - Simulation sim; - - SPtr<KernelFactory> kernelFactory = KernelFactoryImp::getInstance(); - SPtr<PreProcessorFactory> preProcessorFactory = PreProcessorFactoryImp::getInstance(); - sim.setFactories(kernelFactory, preProcessorFactory); - - SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); - sim.init(para, gridGenerator, fileWriter); - sim.run(); - sim.free(); -} - - -int main( int argc, char* argv[]) -{ - MPI_Init(&argc, &argv); - std::string str, str2; - if ( argv != NULL ) - { - str = static_cast<std::string>(argv[0]); - if (argc > 1) - { - str2 = static_cast<std::string>(argv[1]); - try - { - multipleLevel(str2); - } - catch (std::exception e) - { - std::cout << e.what() << std::flush; - //MPI_Abort(MPI_COMM_WORLD, -1); - } - } - else - { - std::cout << "Configuration file must be set!: lbmgm <config file>" << std::endl << std::flush; - //MPI_Abort(MPI_COMM_WORLD, -1); - } - } - /* - MPE_Init_log() & MPE_Finish_log() are NOT needed when - liblmpe.a is linked with this program. In that case, - MPI_Init() would have called MPE_Init_log() already. - */ -#if defined( MPI_LOGGING ) - MPE_Init_log(); -#endif - - - -#if defined( MPI_LOGGING ) - if ( argv != NULL ) - MPE_Finish_log( argv[0] ); - if ( str != "" ) - MPE_Finish_log( str.c_str() ); - else - MPE_Finish_log( "TestLog" ); -#endif - - MPI_Finalize(); - return 0; -} diff --git a/apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp b/apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp index aa6e52d1f2c20782ed34e3e4bba97ad873cc412e..94755358f680503e19e0e204946ae51016d39802 100644 --- a/apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp +++ b/apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp @@ -42,12 +42,12 @@ ////////////////////////////////////////////////////////////////////////// -#include "Core/DataTypes.h" +#include "DataTypes.h" #include "PointerDefinitions.h" -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" + -#include "Core/VectorTypes.h" #include <basics/config/ConfigurationFile.h> @@ -97,8 +97,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -LbmOrGks lbmOrGks = LBM; - std::string path("."); std::string simulationName("ActuatorLine"); @@ -109,12 +107,6 @@ std::string simulationName("ActuatorLine"); void multipleLevel(const std::string& configPath) { - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); auto gridFactory = GridFactory::make(); @@ -161,14 +153,14 @@ void multipleLevel(const std::string& configPath) L_x, L_y, L_z, dx); gridBuilder->setNumberOfLayers(4,0); - gridBuilder->addGrid( new Cuboid( turbPos[0]-1.5*reference_diameter, turbPos[1]-1.5*reference_diameter, turbPos[2]-1.5*reference_diameter, - turbPos[0]+10.0*reference_diameter, turbPos[1]+1.5*reference_diameter, turbPos[2]+1.5*reference_diameter) , 1 ); + gridBuilder->addGrid( std::make_shared<Cuboid>( turbPos[0]-1.5*reference_diameter, turbPos[1]-1.5*reference_diameter, turbPos[2]-1.5*reference_diameter, + turbPos[0]+10.0*reference_diameter, turbPos[1]+1.5*reference_diameter, turbPos[2]+1.5*reference_diameter) , 1 ); para->setMaxLevel(2); scalingFactory.setScalingFactory(GridScalingFactory::GridScaling::ScaleCompressible); gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(lbmOrGks, false); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(false); // buildGrids() has to be called before setting the BCs!!!! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/apps/gpu/LBM/Basel/main.cpp b/apps/gpu/LBM/Basel/main.cpp index 8dc1e456ab89f88ddb36bf050f81ede37610d0c8..4999d3418b269ae4340ca550a5f2c50fc6e45231 100644 --- a/apps/gpu/LBM/Basel/main.cpp +++ b/apps/gpu/LBM/Basel/main.cpp @@ -14,12 +14,9 @@ #define _USE_MATH_DEFINES #include <math.h> -//#include "metis.h" - -#include "Core/LbmOrGks.h" -#include "Core/Input/Input.h" -#include "Core/StringUtilities/StringUtil.h" -#include "Core/Input/ConfigFileReader/ConfigFileReader.h" +#include "Input/Input.h" +#include "StringUtilities/StringUtil.h" +#include "Input/ConfigFileReader/ConfigFileReader.h" #include "VirtualFluids_GPU/LBM/Simulation.h" #include "VirtualFluids_GPU/Communication/Communicator.h" @@ -63,17 +60,6 @@ void multipleLevel(const std::string& configPath) { - //std::ofstream logFile( "F:/Work/Computations/gridGenerator/grid/gridGeneratorLog.txt" ); - //std::ofstream logFile("F:/Basel2019/log/gridGeneratorLog.txt"); - //logging::Logger::addStream(&logFile); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - - //UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG5"); - auto gridFactory = GridFactory::make(); gridFactory->setGridStrategy(Device::CPU); //gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::RAYCASTING); @@ -115,10 +101,10 @@ void multipleLevel(const std::string& configPath) #ifdef _WIN32 //Baumbart - TriangularMesh* BaselSTL = TriangularMesh::make("M:/Basel2019/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND.stl"); + auto BaselSTL = std::make_shared<TriangularMesh>("M:/Basel2019/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND.stl"); #else //Phoenix - TriangularMesh* BaselSTL = TriangularMesh::make(gridpath + "/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND.stl"); + auto BaselSTL = std::make_shared<TriangularMesh>(gridpath + "/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND.stl"); #endif @@ -130,7 +116,7 @@ void multipleLevel(const std::string& configPath) //Merged for Wind in X Direction gridBuilder->setPeriodicBoundaryCondition(true, true, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// @@ -232,7 +218,6 @@ int main(int argc, char* argv[]) } catch (const std::exception& e) { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) @@ -252,22 +237,17 @@ int main(int argc, char* argv[]) } catch (const std::exception& e) { - - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (const std::bad_alloc e) { - - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - //std::cout << "unknown exeption" << std::endl; + std::cout << "unknown exeption" << std::endl; } std::cout << "\nConfiguration file must be set!: lbmgm <config file>" << std::endl << std::flush; diff --git a/apps/gpu/LBM/BaselMultiGPU/main.cpp b/apps/gpu/LBM/BaselMultiGPU/main.cpp index 454f0d261e5a01d049bf5593bcf2a7036856b7ab..bfd64d42b428907e08c3a3b7fdb99319e0f05382 100644 --- a/apps/gpu/LBM/BaselMultiGPU/main.cpp +++ b/apps/gpu/LBM/BaselMultiGPU/main.cpp @@ -14,12 +14,9 @@ #define _USE_MATH_DEFINES #include <math.h> -//#include "metis.h" - -#include "Core/LbmOrGks.h" -#include "Core/Input/Input.h" -#include "Core/StringUtilities/StringUtil.h" -#include "Core/Input/ConfigFileReader/ConfigFileReader.h" +#include "Input/Input.h" +#include "StringUtilities/StringUtil.h" +#include "Input/ConfigFileReader/ConfigFileReader.h" #include "VirtualFluids_GPU/LBM/Simulation.h" #include "VirtualFluids_GPU/Communication/Communicator.h" @@ -60,14 +57,6 @@ void multipleLevel(const std::string& configPath) { - //std::ofstream logFile( "F:/Work/Computations/gridGenerator/grid/gridGeneratorLog.txt" ); - //std::ofstream logFile( "grid/gridGeneratorLog.txt" ); - //logging::Logger::addStream(&logFile); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); //UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG5"); @@ -98,28 +87,26 @@ void multipleLevel(const std::string& configPath) logFile2.open(gridpath + std::to_string(generatePart) + "/gridGeneratorLog.txt");//Phoenix //logFile2.open(std::string("M:/Basel2019/grids4/") + std::to_string(generatePart) + "/gridGeneratorLog.txt");//Baumbart - logging::Logger::addStream(&logFile2); - bool useGridGenerator = false; if(useGridGenerator){ real dx = 1.0; real vx = 0.05; - TriangularMesh* BaselSTL; + SPtr<TriangularMesh> BaselSTL; if (generatePart == 0) - BaselSTL = TriangularMesh::make("/work/marschoe/Basel4GPU/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND.stl"); //Phoenix - //BaselSTL = TriangularMesh::make("M:/Basel2019/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND.stl"); //Baumbart + BaselSTL = std::make_shared<TriangularMesh>("/work/marschoe/Basel4GPU/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND.stl"); //Phoenix + //BaselSTL = std::make_shared<TriangularMesh>("M:/Basel2019/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND.stl"); //Baumbart if (generatePart == 1) - BaselSTL = TriangularMesh::make("/work/marschoe/Basel4GPU/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND_MIRROR_X.stl"); //Phoenix - //BaselSTL = TriangularMesh::make("M:/Basel2019/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND_MIRROR_X.stl"); //Baumbart + BaselSTL = std::make_shared<TriangularMesh>("/work/marschoe/Basel4GPU/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND_MIRROR_X.stl"); //Phoenix + //BaselSTL = std::make_shared<TriangularMesh>("M:/Basel2019/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND_MIRROR_X.stl"); //Baumbart if (generatePart == 2) - BaselSTL = TriangularMesh::make("/work/marschoe/Basel4GPU/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND_MIRROR_X_Y.stl"); //Phoenix - //BaselSTL = TriangularMesh::make("M:/Basel2019/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND_MIRROR_X_Y.stl"); //Baumbart + BaselSTL = std::make_shared<TriangularMesh>("/work/marschoe/Basel4GPU/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND_MIRROR_X_Y.stl"); //Phoenix + //BaselSTL = std::make_shared<TriangularMesh>("M:/Basel2019/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND_MIRROR_X_Y.stl"); //Baumbart if (generatePart == 3) - BaselSTL = TriangularMesh::make("/work/marschoe/Basel4GPU/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND_MIRROR_Y.stl"); //Phoenix - //BaselSTL = TriangularMesh::make("M:/Basel2019/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND_MIRROR_Y.stl"); //Baumbart + BaselSTL = std::make_shared<TriangularMesh>("/work/marschoe/Basel4GPU/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND_MIRROR_Y.stl"); //Phoenix + //BaselSTL = std::make_shared<TriangularMesh>("M:/Basel2019/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND_MIRROR_Y.stl"); //Baumbart real lengthInXDirection = 512.0; real lengthInYDirection = 512.0; @@ -144,7 +131,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// @@ -252,7 +239,6 @@ int main( int argc, char* argv[]) } catch (const std::exception& e) { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) @@ -271,22 +257,17 @@ int main( int argc, char* argv[]) } catch (const std::exception& e) { - - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (const std::bad_alloc e) { - - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - //std::cout << "unknown exeption" << std::endl; + std::cout << "unknown exeption" << std::endl; } std::cout << "\nConfiguration file must be set!: lbmgm <config file>" << std::endl << std::flush; diff --git a/apps/gpu/LBM/BaselNU/main.cpp b/apps/gpu/LBM/BaselNU/main.cpp index f3a3122ed92b410df56dff719878096692625d89..9600785063018ce140606ef66b1ea466dc4bdb40 100644 --- a/apps/gpu/LBM/BaselNU/main.cpp +++ b/apps/gpu/LBM/BaselNU/main.cpp @@ -14,12 +14,9 @@ #define _USE_MATH_DEFINES #include <math.h> -//#include "metis.h" - -#include "Core/LbmOrGks.h" -#include "Core/Input/Input.h" -#include "Core/StringUtilities/StringUtil.h" -#include "Core/Input/ConfigFileReader/ConfigFileReader.h" +#include "Input/Input.h" +#include "StringUtilities/StringUtil.h" +#include "Input/ConfigFileReader/ConfigFileReader.h" #include "VirtualFluids_GPU/LBM/Simulation.h" #include "VirtualFluids_GPU/Communication/Communicator.h" @@ -60,16 +57,6 @@ void multipleLevel(const std::string& configPath) { - std::ofstream logFile("F:/Basel2019NU/grid/gridGeneratorLog.txt"); - logging::Logger::addStream(&logFile); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - - //UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG5"); - auto gridFactory = GridFactory::make(); gridFactory->setGridStrategy(Device::CPU); //gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::RAYCASTING); @@ -98,7 +85,7 @@ void multipleLevel(const std::string& configPath) real dx = 4.0; real vx = 0.05; - TriangularMesh* BaselSTL = TriangularMesh::make("M:/Basel2019/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND.stl"); + auto BaselSTL = std::make_shared<TriangularMesh>("M:/Basel2019/stl/BaselUrbanProfile_066_deg_bridge_3_All_CLOSED_WIDE_GROUND.stl"); gridBuilder->addCoarseGrid(-256.0, -256.0, -8.0, 256.0, 256.0, 160.0, dx); @@ -107,14 +94,14 @@ void multipleLevel(const std::string& configPath) ////////////////////////////////////////////////////////////////////////// - Cuboid* refBoxMX = new Cuboid( -300, -300, - 20, - -254, 300, 200 ); - Cuboid* refBoxPX = new Cuboid( 254, -300, - 20, - 300, 300, 200 ); - Cuboid* refBoxMY = new Cuboid( -300, -300, - 20, - 300, -254, 200 ); - Cuboid* refBoxPY = new Cuboid( -300, 254, - 20, - 300, 300, 200 ); + Cuboid* refBoxMX = std::make_shared<Cuboid>( -300, -300, - 20, + -254, 300, 200 ); + Cuboid* refBoxPX = std::make_shared<Cuboid>( 254, -300, - 20, + 300, 300, 200 ); + Cuboid* refBoxMY = std::make_shared<Cuboid>( -300, -300, - 20, + 300, -254, 200 ); + Cuboid* refBoxPY = std::make_shared<Cuboid>( -300, 254, - 20, + 300, 300, 200 ); Conglomerate* refRegion = new Conglomerate(); @@ -133,7 +120,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(true, true, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// @@ -225,7 +212,6 @@ int main(int argc, char* argv[]) } catch (const std::exception& e) { - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) @@ -245,22 +231,17 @@ int main(int argc, char* argv[]) } catch (const std::exception& e) { - - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (const std::bad_alloc e) { - - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - //std::cout << "unknown exeption" << std::endl; + std::cout << "unknown exeption" << std::endl; } std::cout << "\nConfiguration file must be set!: lbmgm <config file>" << std::endl << std::flush; diff --git a/apps/gpu/LBM/BoundaryLayer/BoundaryLayer.cpp b/apps/gpu/LBM/BoundaryLayer/BoundaryLayer.cpp index 3921c85244ad27456e98c750fd64638453546ff5..298c5d9c344a1873a2612a518f72f33f7d6b6f64 100644 --- a/apps/gpu/LBM/BoundaryLayer/BoundaryLayer.cpp +++ b/apps/gpu/LBM/BoundaryLayer/BoundaryLayer.cpp @@ -43,15 +43,13 @@ ////////////////////////////////////////////////////////////////////////// -#include "Core/DataTypes.h" +#include "DataTypes.h" #include "PointerDefinitions.h" -#include "Core/StringUtilities/StringUtil.h" - -#include "Core/VectorTypes.h" +#include "StringUtilities/StringUtil.h" #include <basics/config/ConfigurationFile.h> -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include <logger/Logger.h> @@ -100,17 +98,11 @@ std::string path("."); std::string simulationName("BoundaryLayer"); -using namespace vf::lbm::constant; +using namespace vf::basics::constant; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void multipleLevel(const std::string& configPath) { - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - auto gridFactory = GridFactory::make(); auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); @@ -142,8 +134,6 @@ void multipleLevel(const std::string& configPath) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - LbmOrGks lbmOrGks = LBM; - const real H = config.getValue("boundaryLayerHeight", 1000.0); // boundary layer height in m const real L_x = 6*H; @@ -283,7 +273,7 @@ void multipleLevel(const std::string& configPath) { gridBuilder->setNumberOfLayers(4,0); real xMaxRefinement = readPrecursor? xGridMax-H: xGridMax; //Stop refinement some distance before outlet if domain ist not periodic - gridBuilder->addGrid( new Cuboid( xGridMin, 0.f, 0.f, xMaxRefinement, L_y, 0.5*L_z) , 1 ); + gridBuilder->addGrid( std::make_shared<Cuboid>( xGridMin, 0.f, 0.f, xMaxRefinement, L_y, 0.5*L_z) , 1 ); para->setMaxLevel(2); scalingFactory.setScalingFactory(GridScalingFactory::GridScaling::ScaleCompressible); } @@ -299,28 +289,28 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(!readPrecursor, true, false); } - gridBuilder->buildGrids(lbmOrGks, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! std::cout << "nProcs: "<< nProcs << "Proc: " << procID << " isFirstSubDomain: " << isFirstSubDomain << " isLastSubDomain: " << isLastSubDomain << " isMidSubDomain: " << isMidSubDomain << std::endl; if(nProcs > 1){ if (isFirstSubDomain || isMidSubDomain) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, lbmOrGks); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, procID+1); } if (isLastSubDomain || isMidSubDomain) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, lbmOrGks); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, procID-1); } if (isFirstSubDomain && !readPrecursor) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, lbmOrGks); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, nProcs-1); } if (isLastSubDomain && !readPrecursor) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, lbmOrGks); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 0); } } diff --git a/apps/gpu/LBM/ChannelFlow/ChannelFlow.cpp b/apps/gpu/LBM/ChannelFlow/ChannelFlow.cpp index a05f3243040a2fbd0617daa65ac29322f45f7025..f553c255b882596ea4614e8e2fa33403e3d9a0f8 100644 --- a/apps/gpu/LBM/ChannelFlow/ChannelFlow.cpp +++ b/apps/gpu/LBM/ChannelFlow/ChannelFlow.cpp @@ -45,13 +45,11 @@ ////////////////////////////////////////////////////////////////////////// -#include "Core/DataTypes.h" -#include "Core/LbmOrGks.h" -#include "Core/Logger/Logger.h" -#include "Core/VectorTypes.h" +#include "DataTypes.h" + #include "PointerDefinitions.h" #include "config/ConfigurationFile.h" -#include "logger/Logger.h" +#include <logger/Logger.h> ////////////////////////////////////////////////////////////////////////// @@ -110,14 +108,6 @@ int main(int argc, char *argv[]) // setup logger ////////////////////////////////////////////////////////////////////////// - std::ofstream logFile("output/log_process" + std::to_string(vf::gpu::Communicator::getInstance().getPID()) + - ".txt"); - logging::Logger::addStream(&logFile); - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - vf::logging::Logger::changeLogPath("output/vflog_process" + std::to_string(vf::gpu::Communicator::getInstance().getPID()) + ".txt"); vf::logging::Logger::initializeLogger(); @@ -203,7 +193,7 @@ int main(int argc, char *argv[]) // build grids ////////////////////////////////////////////////////////////////////////// - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// // configure communication neighbors diff --git a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp index a57191a4dd54c9b7ecb06048377acfe59d883277..a802de12c032766f9bf14d2a43b4d16078e230f6 100644 --- a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp +++ b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp @@ -41,10 +41,7 @@ ////////////////////////////////////////////////////////////////////////// -#include "Core/DataTypes.h" -#include "Core/LbmOrGks.h" -#include "Core/Logger/Logger.h" -#include "Core/VectorTypes.h" +#include "DataTypes.h" #include "PointerDefinitions.h" #include <logger/Logger.h> @@ -92,15 +89,6 @@ int main() const uint timeStepOut = 1000; const uint timeStepEnd = 10000; - ////////////////////////////////////////////////////////////////////////// - // setup logger - ////////////////////////////////////////////////////////////////////////// - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - ////////////////////////////////////////////////////////////////////////// // setup gridGenerator ////////////////////////////////////////////////////////////////////////// @@ -127,13 +115,13 @@ int main() gridBuilder->addCoarseGrid(-0.5 * L, -0.5 * L, -0.5 * L, 0.5 * L, 0.5 * L, 0.5 * L, dx); - gridBuilder->addGrid(new Cuboid(-0.25, -0.25, -0.25, 0.25, 0.25, 0.25), 1); // add fine grid + gridBuilder->addGrid(std::make_shared<Cuboid>(-0.25, -0.25, -0.25, 0.25, 0.25, 0.25), 1); // add fine grid GridScalingFactory scalingFactory = GridScalingFactory(); scalingFactory.setScalingFactory(GridScalingFactory::GridScaling::ScaleCompressible); gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LbmOrGks::LBM, false); + gridBuilder->buildGrids(false); ////////////////////////////////////////////////////////////////////////// // set parameters diff --git a/apps/gpu/LBM/DrivenCavityMultiGPU/DrivenCavityMultiGPU.cpp b/apps/gpu/LBM/DrivenCavityMultiGPU/DrivenCavityMultiGPU.cpp index 1bbb35310e3dcc0a1b56be7d486acfb7370a00f8..acab426b4868cc736710c883776c5626ec6b5753 100755 --- a/apps/gpu/LBM/DrivenCavityMultiGPU/DrivenCavityMultiGPU.cpp +++ b/apps/gpu/LBM/DrivenCavityMultiGPU/DrivenCavityMultiGPU.cpp @@ -12,15 +12,12 @@ ////////////////////////////////////////////////////////////////////////// -#include "basics/Core/DataTypes.h" -#include "basics/Core/VectorTypes.h" +#include "basics/DataTypes.h" #include "basics/PointerDefinitions.h" -#include "basics/Core/LbmOrGks.h" -#include "basics/Core/Logger/Logger.h" -#include "basics/Core/StringUtilities/StringUtil.h" +#include "basics/StringUtilities/StringUtil.h" #include "basics/config/ConfigurationFile.h" -#include "logger/Logger.h" +#include <logger/Logger.h> ////////////////////////////////////////////////////////////////////////// @@ -63,22 +60,14 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void multipleLevel(std::filesystem::path& configPath) +void runVirtualFluids(const vf::basics::ConfigurationFile& config) { - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); auto gridFactory = GridFactory::make(); gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - vf::basics::ConfigurationFile config; - std::cout << configPath << std::endl; - config.load(configPath.string()); SPtr<Parameter> para = std::make_shared<Parameter>(communicator.getNumberOfProcess(), communicator.getPID(), &config); BoundaryConditionFactory bcFactory = BoundaryConditionFactory(); GridScalingFactory scalingFactory = GridScalingFactory(); @@ -150,9 +139,9 @@ void multipleLevel(std::filesystem::path& configPath) const real zGridMin = -0.5 * L; const real zGridMax = 0.5 * L; - Cuboid *level1 = nullptr; + SPtr<Cuboid> level1 = nullptr; if (useLevels) - level1 = new Cuboid(-0.25 * L, -0.25 * L, -0.25 * L, 0.25 * L, 0.25 * L, 0.25 * L); + level1 = std::make_shared<Cuboid>(-0.25 * L, -0.25 * L, -0.25 * L, 0.25 * L, 0.25 * L, 0.25 * L); if (para->getNumprocs() > 1) { @@ -188,15 +177,15 @@ void multipleLevel(std::filesystem::path& configPath) std::make_shared<BoundingBox>(xGridMin, xGridMax, yGridMin, yGridMax, zSplit, zGridMax)); } - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! if (generatePart == 0) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 1); } if (generatePart == 1) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 0); } @@ -247,30 +236,30 @@ void multipleLevel(std::filesystem::path& configPath) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>(xSplit, xGridMax, yGridMin, yGridMax, zSplit, zGridMax)); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! if (generatePart == 0) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 1); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 2); } if (generatePart == 1) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 0); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 3); } if (generatePart == 2) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 3); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 0); } if (generatePart == 3) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 2); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 1); } @@ -359,71 +348,71 @@ void multipleLevel(std::filesystem::path& configPath) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>(xSplit, xGridMax, ySplit, yGridMax, zSplit, zGridMax)); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! gridBuilder->setPeriodicBoundaryCondition(false, false, false); if (generatePart == 0) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 1); - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 2); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 4); } if (generatePart == 1) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 0); - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 3); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 5); } if (generatePart == 2) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 3); - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 0); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 6); } if (generatePart == 3) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 2); - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 1); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 7); } if (generatePart == 4) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 5); - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 6); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 0); } if (generatePart == 5) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 4); - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 7); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 1); } if (generatePart == 6) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 7); - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 4); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 2); } if (generatePart == 7) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 6); - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 5); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 3); } @@ -484,7 +473,7 @@ void multipleLevel(std::filesystem::path& configPath) gridBuilder->addGrid(level1, 1); } - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! gridBuilder->setPeriodicBoundaryCondition(false, false, false); ////////////////////////////////////////////////////////////////////////// gridBuilder->setVelocityBoundaryCondition(SideType::MX, 0.0, 0.0, 0.0); @@ -527,20 +516,9 @@ int main(int argc, char *argv[]) if (argv != NULL) { try { - ////////////////////////////////////////////////////////////////////////// - // assuming that a config files is stored parallel to this file. - std::filesystem::path configPath = __FILE__; - - // the config file's default name can be replaced by passing a command line argument - std::string configName("configDrivenCavityMultiGPU.txt"); - if (argc == 2) { - configName = argv[1]; - std::cout << "Using configFile command line argument: " << configName << std::endl; - } - - configPath.replace_filename(configName); - - multipleLevel(configPath); + VF_LOG_TRACE("For the default config path to work, execute the app from the project root."); + vf::basics::ConfigurationFile config = vf::basics::ConfigurationFile::loadConfig(argc, argv, "./apps/gpu/LBM/DrivenCavityMultiGPU/configDrivenCavityMultiGPU.txt"); + runVirtualFluids(config); ////////////////////////////////////////////////////////////////////////// } catch (const spdlog::spdlog_ex &ex) { diff --git a/apps/gpu/LBM/DrivenCavityUniform/DrivenCavity.cpp b/apps/gpu/LBM/DrivenCavityUniform/DrivenCavity.cpp index 83e5f41d2b7c9569744167ee1d1f674ab46c8439..dfa1256c80e6aeb0e209638ba0c7425ff437e2d5 100644 --- a/apps/gpu/LBM/DrivenCavityUniform/DrivenCavity.cpp +++ b/apps/gpu/LBM/DrivenCavityUniform/DrivenCavity.cpp @@ -41,10 +41,9 @@ ////////////////////////////////////////////////////////////////////////// -#include "Core/DataTypes.h" -#include "Core/LbmOrGks.h" -#include "Core/Logger/Logger.h" -#include "Core/VectorTypes.h" +#include "DataTypes.h" +#include <logger/Logger.h> + #include "PointerDefinitions.h" #include <logger/Logger.h> @@ -92,15 +91,6 @@ int main() const uint timeStepOut = 1000; const uint timeStepEnd = 10000; - ////////////////////////////////////////////////////////////////////////// - // setup logger - ////////////////////////////////////////////////////////////////////////// - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - ////////////////////////////////////////////////////////////////////////// // setup gridGenerator ////////////////////////////////////////////////////////////////////////// @@ -117,13 +107,13 @@ int main() gridBuilder->addCoarseGrid(-0.5 * L, -0.5 * L, -0.5 * L, 0.5 * L, 0.5 * L, 0.5 * L, dx); - // gridBuilder->addGrid(new Cuboid(-0.25, -0.25, -0.25, 0.25, 0.25, 0.25), 1); // add fine grid + // gridBuilder->addGrid(std::make_shared<Cuboid>(-0.25, -0.25, -0.25, 0.25, 0.25, 0.25), 1); // add fine grid GridScalingFactory scalingFactory = GridScalingFactory(); scalingFactory.setScalingFactory(GridScalingFactory::GridScaling::ScaleCompressible); gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LbmOrGks::LBM, false); + gridBuilder->buildGrids(false); ////////////////////////////////////////////////////////////////////////// // compute parameters in lattice units diff --git a/apps/gpu/LBM/MusselOyster/MusselOyster.cpp b/apps/gpu/LBM/MusselOyster/MusselOyster.cpp index 2e43e20f33c061c3d25da0ea2ff53e2351ad3cad..b583633b50542795fe4b27aca42c08cca1a5331c 100644 --- a/apps/gpu/LBM/MusselOyster/MusselOyster.cpp +++ b/apps/gpu/LBM/MusselOyster/MusselOyster.cpp @@ -13,15 +13,12 @@ ////////////////////////////////////////////////////////////////////////// -#include "basics/Core/DataTypes.h" -#include "basics/Core/VectorTypes.h" +#include "basics/DataTypes.h" #include "basics/PointerDefinitions.h" -#include "basics/Core/LbmOrGks.h" -#include "basics/Core/Logger/Logger.h" -#include "basics/Core/StringUtilities/StringUtil.h" +#include "basics/StringUtilities/StringUtil.h" #include "basics/config/ConfigurationFile.h" -#include "logger/Logger.h" +#include <logger/Logger.h> ////////////////////////////////////////////////////////////////////////// @@ -87,21 +84,14 @@ const std::string simulationName("MusselOyster"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void multipleLevel(std::filesystem::path &configPath) +void runVirtualFluids(const vf::basics::ConfigurationFile& config) { - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - vf::gpu::Communicator &communicator = vf::gpu::Communicator::getInstance(); auto gridFactory = GridFactory::make(); gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - vf::basics::ConfigurationFile config; - config.load(configPath.string()); SPtr<Parameter> para = std::make_shared<Parameter>(communicator.getNumberOfProcess(), communicator.getPID(), &config); BoundaryConditionFactory bcFactory = BoundaryConditionFactory(); @@ -195,10 +185,10 @@ void multipleLevel(std::filesystem::path &configPath) // height MUSSEL = 35.0 // height Oyster = 72.0 - TriangularMesh *bivalveSTL = TriangularMesh::make(stlPath + bivalveType + ".stl"); - TriangularMesh *bivalveRef_1_STL = nullptr; + SPtr<TriangularMesh> bivalveSTL = std::make_shared<TriangularMesh>(stlPath + bivalveType + ".stl"); + SPtr<TriangularMesh> bivalveRef_1_STL = nullptr; if (useLevels) - bivalveRef_1_STL = TriangularMesh::make(stlPath + bivalveType + "_Level1.stl"); + bivalveRef_1_STL = std::make_shared<TriangularMesh>(stlPath + bivalveType + "_Level1.stl"); if (para->getNumprocs() > 1) { const uint generatePart = vf::gpu::Communicator::getInstance().getPID(); @@ -233,15 +223,15 @@ void multipleLevel(std::filesystem::path &configPath) std::make_shared<BoundingBox>(xGridMin, xGridMax, yGridMin, yGridMax, zSplit, zGridMax)); } - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! if (generatePart == 0) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 1); } if (generatePart == 1) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 0); } @@ -298,30 +288,30 @@ void multipleLevel(std::filesystem::path &configPath) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>(xSplit, xGridMax, yGridMin, yGridMax, zSplit, zGridMax)); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! if (generatePart == 0) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 1); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 2); } if (generatePart == 1) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 0); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 3); } if (generatePart == 2) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 3); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 0); } if (generatePart == 3) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 2); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 1); } @@ -416,71 +406,71 @@ void multipleLevel(std::filesystem::path &configPath) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>(xSplit, xGridMax, ySplit, yGridMax, zSplit, zGridMax)); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! gridBuilder->setPeriodicBoundaryCondition(false, false, false); if (generatePart == 0) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 1); - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 2); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 4); } if (generatePart == 1) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 0); - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 3); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 5); } if (generatePart == 2) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 3); - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 0); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 6); } if (generatePart == 3) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 2); - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 1); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 7); } if (generatePart == 4) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 5); - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 6); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 0); } if (generatePart == 5) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 4); - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 7); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 1); } if (generatePart == 6) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 7); - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 4); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 2); } if (generatePart == 7) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 6); - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 5); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 3); } @@ -544,7 +534,7 @@ void multipleLevel(std::filesystem::path &configPath) gridBuilder->addGeometry(bivalveSTL); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! gridBuilder->setPeriodicBoundaryCondition(false, false, false); ////////////////////////////////////////////////////////////////////////// @@ -593,20 +583,9 @@ int main(int argc, char *argv[]) if (argv != NULL) { try { - ////////////////////////////////////////////////////////////////////////// - // assuming that a config files is stored parallel to this file. - std::filesystem::path configPath = __FILE__; - - // the config file's default name can be replaced by passing a command line argument - std::string configName("configMusselOyster.txt"); - if (argc == 2) { - configName = argv[1]; - std::cout << "Using configFile command line argument: " << configName << std::endl; - } - - configPath.replace_filename(configName); - - multipleLevel(configPath); + VF_LOG_TRACE("For the default config path to work, execute the app from the project root."); + vf::basics::ConfigurationFile config = vf::basics::ConfigurationFile::loadConfig(argc, argv, "./apps/gpu/LBM/MusselOyster/configMusselOyster.txt"); + runVirtualFluids(config); ////////////////////////////////////////////////////////////////////////// } catch (const spdlog::spdlog_ex &ex) { diff --git a/apps/gpu/LBM/SphereGPU/Sphere.cpp b/apps/gpu/LBM/SphereGPU/Sphere.cpp index 6b749b564368bc6223c1283351521221d4950411..a20383b8e7eab9ce61fb8d8c21de95d6033f5c5f 100644 --- a/apps/gpu/LBM/SphereGPU/Sphere.cpp +++ b/apps/gpu/LBM/SphereGPU/Sphere.cpp @@ -42,13 +42,10 @@ ////////////////////////////////////////////////////////////////////////// -#include "Core/DataTypes.h" -#include "Core/LbmOrGks.h" -#include "Core/Logger/Logger.h" -#include "Core/VectorTypes.h" +#include "DataTypes.h" +#include <logger/Logger.h> #include "PointerDefinitions.h" #include "config/ConfigurationFile.h" -#include "logger/Logger.h" ////////////////////////////////////////////////////////////////////////// @@ -87,26 +84,17 @@ int main(int argc, char *argv[]) const real L = 1.0; const real dSphere = 0.2; - const real Re = 1000.0; // related to the sphere's diameter + const real Re = 300.0; // related to the sphere's diameter const real velocity = 1.0; const real dt = (real)0.5e-3; - const uint nx = 64; + const uint nx = 50; - const uint timeStepOut = 1000; + const uint timeStepOut = 10000; const uint timeStepEnd = 10000; - ////////////////////////////////////////////////////////////////////////// - // setup logger - ////////////////////////////////////////////////////////////////////////// - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - ////////////////////////////////////////////////////////////////////////// // setup simulation parameters (with or without config file) - ////////////////////////////////////////////////////////////////////////// + ////////////////////////// vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance();; SPtr<Parameter> para; @@ -114,23 +102,8 @@ int main(int argc, char *argv[]) GridScalingFactory scalingFactory = GridScalingFactory(); vf::basics::ConfigurationFile config; if (useConfigFile) { - ////////////////////////////////////////////////////////////////////////// - // read simulation parameters from config file - ////////////////////////////////////////////////////////////////////////// - - // assuming that a config files is stored parallel to this file. - std::filesystem::path configPath = __FILE__; - - // the config file's default name can be replaced by passing a command line argument - std::string configName("config.txt"); - if (argc == 2) { - configName = argv[1]; - std::cout << "Using configFile command line argument: " << configName << std::endl; - } - - configPath.replace_filename(configName); - config.load(configPath.string()); - + VF_LOG_TRACE("For the default config path to work, execute the app from the project root."); + vf::basics::ConfigurationFile config = vf::basics::ConfigurationFile::loadConfig(argc, argv, "./apps/gpu/LBM/SphereGPU/config.txt"); para = std::make_shared<Parameter>(&config); } else { para = std::make_shared<Parameter>(); @@ -150,10 +123,10 @@ int main(int argc, char *argv[]) real dx = L / real(nx); gridBuilder->addCoarseGrid(-1.0 * L, -0.6 * L, -0.6 * L, - 8.0 * L, 0.6 * L, 0.6 * L, dx); + 3.0 * L, 0.6 * L, 0.6 * L, dx); // use primitive - // Object *sphere = new Sphere(0.0, 0.0, 0.0, dSphere / 2.0); + // auto sphere = std::make_shared<Sphere>(0.0, 0.0, 0.0, dSphere / 2.0); // use stl std::string stlPath = "./apps/gpu/LBM/SphereGPU/sphere02.stl"; @@ -161,7 +134,7 @@ int main(int argc, char *argv[]) stlPath = config.getValue<std::string>("STLPath"); } std::cout << "Reading stl from " << stlPath << "." << std::endl; - Object *sphere = TriangularMesh::make(stlPath); + auto sphere = std::make_shared<TriangularMesh>(stlPath); gridBuilder->addGeometry(sphere); gridBuilder->setPeriodicBoundaryCondition(false, false, false); @@ -171,7 +144,7 @@ int main(int argc, char *argv[]) ////////////////////////////////////////////////////////////////////////// // gridBuilder->setNumberOfLayers(10, 8); - // gridBuilder->addGrid(new Sphere(0.0, 0.0, 0.0, 2.0 * dSphere), 1); + // gridBuilder->addGrid(std::make_shared<Sphere>(0.0, 0.0, 0.0, 2.0 * dSphere), 1); // para->setMaxLevel(2); // scalingFactory.setScalingFactory(GridScalingFactory::GridScaling::ScaleK17); @@ -179,7 +152,7 @@ int main(int argc, char *argv[]) // build grid ////////////////////////////////////////////////////////////////////////// - gridBuilder->buildGrids(LBM, false); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(false); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// // compute parameters in lattice units diff --git a/apps/gpu/LBM/SphereScaling/SphereScaling.cpp b/apps/gpu/LBM/SphereScaling/SphereScaling.cpp index c632e9649f7461e8af4a6e9e73d740406283edbf..da80302e9e9b5b6f43c7eb3eea0ae8be08f22b93 100755 --- a/apps/gpu/LBM/SphereScaling/SphereScaling.cpp +++ b/apps/gpu/LBM/SphereScaling/SphereScaling.cpp @@ -1,4 +1,3 @@ - #define _USE_MATH_DEFINES #include <exception> #include <fstream> @@ -14,15 +13,12 @@ ////////////////////////////////////////////////////////////////////////// -#include "basics/Core/DataTypes.h" -#include "basics/Core/VectorTypes.h" +#include "basics/DataTypes.h" #include "basics/PointerDefinitions.h" -#include "basics/Core/LbmOrGks.h" -#include "basics/Core/Logger/Logger.h" -#include "basics/Core/StringUtilities/StringUtil.h" +#include "basics/StringUtilities/StringUtil.h" #include "basics/config/ConfigurationFile.h" -#include "logger/Logger.h" +#include <logger/Logger.h> ////////////////////////////////////////////////////////////////////////// @@ -67,21 +63,14 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void multipleLevel(std::filesystem::path& configPath) +void runVirtualFluids(const vf::basics::ConfigurationFile& config) { - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); auto gridFactory = GridFactory::make(); gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - vf::basics::ConfigurationFile config; - config.load(configPath.string()); SPtr<Parameter> para = std::make_shared<Parameter>(communicator.getNumberOfProcess(), communicator.getPID(), &config); BoundaryConditionFactory bcFactory = BoundaryConditionFactory(); GridScalingFactory scalingFactory = GridScalingFactory(); @@ -206,10 +195,10 @@ void multipleLevel(std::filesystem::path& configPath) if (useLevels) { if (scalingType == "strong") { gridBuilder->addGrid( - new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), + std::make_shared<Sphere>(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), 1); } else if (scalingType == "weak") { - gridBuilder->addGrid(new Cuboid(-0.5 * dCubeLev1, -0.5 * dCubeLev1, + gridBuilder->addGrid(std::make_shared<Cuboid>(-0.5 * dCubeLev1, -0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, 0.5 * dCubeLev1, 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1), 1); @@ -218,14 +207,14 @@ void multipleLevel(std::filesystem::path& configPath) if (scalingType == "weak") { if (useLevels) { - gridBuilder->addGeometry(new Sphere(0.0, 0.0, sideLengthCube, dSphere)); + gridBuilder->addGeometry(std::make_shared<Sphere>(0.0, 0.0, sideLengthCube, dSphere)); } else { - TriangularMesh *sphereSTL = TriangularMesh::make(stlPath + "Spheres_2GPU.stl"); + auto sphereSTL = std::make_shared<TriangularMesh>(stlPath + "Spheres_2GPU.stl"); gridBuilder->addGeometry(sphereSTL); } } else if (scalingType == "strong") { gridBuilder->addGeometry( - new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); + std::make_shared<Sphere>(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); } if (generatePart == 0) @@ -235,15 +224,15 @@ void multipleLevel(std::filesystem::path& configPath) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>(xGridMin, xGridMax, yGridMin, yGridMax, zSplit, zGridMax)); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! if (generatePart == 0) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 1); } if (generatePart == 1) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 0); } @@ -291,10 +280,10 @@ void multipleLevel(std::filesystem::path& configPath) if (useLevels) { if (scalingType == "strong") { gridBuilder->addGrid( - new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), + std::make_shared<Sphere>(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), 1); } else if (scalingType == "weak") { - gridBuilder->addGrid(new Cuboid(-0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, + gridBuilder->addGrid(std::make_shared<Cuboid>(-0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1), @@ -304,14 +293,14 @@ void multipleLevel(std::filesystem::path& configPath) if (scalingType == "weak") { if (useLevels) { - gridBuilder->addGeometry(new Sphere(0.0, sideLengthCube, sideLengthCube, dSphere)); + gridBuilder->addGeometry(std::make_shared<Sphere>(0.0, sideLengthCube, sideLengthCube, dSphere)); } else { - TriangularMesh *sphereSTL = TriangularMesh::make(stlPath + "Spheres_4GPU.stl"); + auto sphereSTL = std::make_shared<TriangularMesh>(stlPath + "Spheres_4GPU.stl"); gridBuilder->addGeometry(sphereSTL); } } else if (scalingType == "strong") { gridBuilder->addGeometry( - new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); + std::make_shared<Sphere>(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); } if (generatePart == 0) @@ -327,31 +316,31 @@ void multipleLevel(std::filesystem::path& configPath) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>(xGridMin, xGridMax, ySplit, yGridMax, zSplit, zGridMax)); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! gridBuilder->setPeriodicBoundaryCondition(false, false, false); if (generatePart == 0) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 1); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 2); } if (generatePart == 1) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 0); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 3); } if (generatePart == 2) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 3); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 0); } if (generatePart == 3) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 2); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 1); } @@ -426,11 +415,11 @@ void multipleLevel(std::filesystem::path& configPath) if (useLevels) { if (scalingType == "strong") { gridBuilder->addGrid( - new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), + std::make_shared<Sphere>(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), 1); } else if (scalingType == "weak") { gridBuilder->addGrid( - new Cuboid(sideLengthCube - 0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, + std::make_shared<Cuboid>(sideLengthCube - 0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1), 1); @@ -439,14 +428,14 @@ void multipleLevel(std::filesystem::path& configPath) if (scalingType == "weak") { if (useLevels) { - gridBuilder->addGeometry(new Sphere(sideLengthCube, sideLengthCube, sideLengthCube, dSphere)); + gridBuilder->addGeometry(std::make_shared<Sphere>(sideLengthCube, sideLengthCube, sideLengthCube, dSphere)); } else { - TriangularMesh *sphereSTL = TriangularMesh::make(stlPath + "Spheres_8GPU.stl"); + auto sphereSTL = std::make_shared<TriangularMesh>(stlPath + "Spheres_8GPU.stl"); gridBuilder->addGeometry(sphereSTL); } } else if (scalingType == "strong") { gridBuilder->addGeometry( - new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); + std::make_shared<Sphere>(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); } if (generatePart == 0) @@ -474,71 +463,71 @@ void multipleLevel(std::filesystem::path& configPath) gridBuilder->setSubDomainBox( std::make_shared<BoundingBox>(xSplit, xGridMax, ySplit, yGridMax, zSplit, zGridMax)); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! gridBuilder->setPeriodicBoundaryCondition(false, false, false); if (generatePart == 0) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 1); - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 2); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 4); } if (generatePart == 1) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 0); - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 3); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 5); } if (generatePart == 2) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 3); - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 0); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 6); } if (generatePart == 3) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 2); - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 1); - gridBuilder->findCommunicationIndices(CommunicationDirections::PZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PZ); gridBuilder->setCommunicationProcess(CommunicationDirections::PZ, 7); } if (generatePart == 4) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 5); - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 6); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 0); } if (generatePart == 5) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 4); - gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PX); gridBuilder->setCommunicationProcess(CommunicationDirections::PX, 7); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 1); } if (generatePart == 6) { - gridBuilder->findCommunicationIndices(CommunicationDirections::PY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::PY); gridBuilder->setCommunicationProcess(CommunicationDirections::PY, 7); - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 4); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 2); } if (generatePart == 7) { - gridBuilder->findCommunicationIndices(CommunicationDirections::MY, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MY); gridBuilder->setCommunicationProcess(CommunicationDirections::MY, 6); - gridBuilder->findCommunicationIndices(CommunicationDirections::MX, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MX); gridBuilder->setCommunicationProcess(CommunicationDirections::MX, 5); - gridBuilder->findCommunicationIndices(CommunicationDirections::MZ, LBM); + gridBuilder->findCommunicationIndices(CommunicationDirections::MZ); gridBuilder->setCommunicationProcess(CommunicationDirections::MZ, 3); } @@ -600,9 +589,9 @@ void multipleLevel(std::filesystem::path& configPath) gridBuilder->setNumberOfLayers(10, 8); if (scalingType == "strong") { gridBuilder->addGrid( - new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), 1); + std::make_shared<Sphere>(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphereLev1), 1); } else if (scalingType == "weak") - gridBuilder->addGrid(new Cuboid(sideLengthCube - 0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, + gridBuilder->addGrid(std::make_shared<Cuboid>(sideLengthCube - 0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, sideLengthCube - 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1, sideLengthCube + 0.5 * dCubeLev1), 1); @@ -610,17 +599,17 @@ void multipleLevel(std::filesystem::path& configPath) if (scalingType == "weak") { if (useLevels) { - gridBuilder->addGeometry(new Sphere(sideLengthCube, sideLengthCube, sideLengthCube, dSphere)); + gridBuilder->addGeometry(std::make_shared<Sphere>(sideLengthCube, sideLengthCube, sideLengthCube, dSphere)); } else { - TriangularMesh *sphereSTL = TriangularMesh::make(stlPath + "Spheres_1GPU.stl"); + auto sphereSTL = std::make_shared<TriangularMesh>(stlPath + "Spheres_1GPU.stl"); gridBuilder->addGeometry(sphereSTL); } } else { gridBuilder->addGeometry( - new Sphere(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); + std::make_shared<Sphere>(0.5 * sideLengthCube, 0.5 * sideLengthCube, 0.5 * sideLengthCube, dSphere)); } - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! gridBuilder->setPeriodicBoundaryCondition(false, false, false); ////////////////////////////////////////////////////////////////////////// @@ -668,20 +657,9 @@ int main(int argc, char *argv[]) if (argv != NULL) { try { - ////////////////////////////////////////////////////////////////////////// - // assuming that a config files is stored parallel to this file. - std::filesystem::path configPath = __FILE__; - - // the config file's default name can be replaced by passing a command line argument - std::string configName("config.txt"); - if (argc == 2) { - configName = argv[1]; - std::cout << "Using configFile command line argument: " << configName << std::endl; - } - - configPath.replace_filename(configName); - - multipleLevel(configPath); + VF_LOG_INFO("For the default config path to work, execute the app from the project root."); + vf::basics::ConfigurationFile config = vf::basics::ConfigurationFile::loadConfig(argc, argv, "./apps/gpu/LBM/SphereScaling/config.txt"); + runVirtualFluids(config); ////////////////////////////////////////////////////////////////////////// } catch (const spdlog::spdlog_ex &ex) { diff --git a/apps/gpu/LBM/TGV_3D/TGV_3D.cpp b/apps/gpu/LBM/TGV_3D/TGV_3D.cpp index cf092ddf00325caa5ca8f2f280d1de18d30eee16..050efc6d0f0f2b80ca2da2df26cdb71b1e52f3ad 100644 --- a/apps/gpu/LBM/TGV_3D/TGV_3D.cpp +++ b/apps/gpu/LBM/TGV_3D/TGV_3D.cpp @@ -45,10 +45,9 @@ ////////////////////////////////////////////////////////////////////////// -#include "Core/DataTypes.h" -#include "Core/LbmOrGks.h" -#include "Core/Logger/Logger.h" -#include "Core/VectorTypes.h" +#include "DataTypes.h" +#include <logger/Logger.h> + #include "PointerDefinitions.h" ////////////////////////////////////////////////////////////////////////// @@ -78,7 +77,6 @@ #include "VirtualFluids_GPU/Output/FileWriter.h" #include "VirtualFluids_GPU/Parameter/Parameter.h" -#include <logger/Logger.h> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -134,15 +132,6 @@ std::string simulationName("TGV_3D"); void multipleLevel(const std::string& configPath) { - //std::ofstream logFile( "F:/Work/Computations/gridGenerator/grid/gridGeneratorLog.txt" ); - //std::ofstream logFile( "grid/gridGeneratorLog.txt" ); - //logging::Logger::addStream(&logFile); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); //UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG5"); @@ -171,9 +160,8 @@ void multipleLevel(const std::string& configPath) const real viscosity = nx / ( 2.0 * PI ) * velocity / Re; - *logging::out << logging::Logger::INFO_HIGH << "velocity = " << velocity << " s\n"; - - *logging::out << logging::Logger::INFO_HIGH << "viscosity = " << viscosity << "\n"; + VF_LOG_INFO("velocity = {}", velocity); + VF_LOG_INFO("viscosity = {}", viscosity); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -184,7 +172,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(true, true, true); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -343,22 +331,17 @@ int main( int argc, char* argv[]) } catch (const std::bad_alloc& e) { - - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (const std::exception& e) { - - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - //std::cout << "unknown exeption" << std::endl; + std::cout << "unknown exeption" << std::endl; } //std::cout << "\nConfiguration file must be set!: lbmgm <config file>" << std::endl << std::flush; diff --git a/apps/gpu/LBM/TGV_3D_GridRef/TGV_3D_GridRef.cpp b/apps/gpu/LBM/TGV_3D_GridRef/TGV_3D_GridRef.cpp index a6c31c7039d027ad62d5b46ae84517c55b171624..0f945e32d9fbcb2e18d4888a4fa0a2c6e03c21b4 100644 --- a/apps/gpu/LBM/TGV_3D_GridRef/TGV_3D_GridRef.cpp +++ b/apps/gpu/LBM/TGV_3D_GridRef/TGV_3D_GridRef.cpp @@ -45,10 +45,9 @@ ////////////////////////////////////////////////////////////////////////// -#include "Core/DataTypes.h" -#include "Core/LbmOrGks.h" -#include "Core/Logger/Logger.h" -#include "Core/VectorTypes.h" +#include "DataTypes.h" +#include <logger/Logger.h> + #include "PointerDefinitions.h" ////////////////////////////////////////////////////////////////////////// @@ -79,8 +78,6 @@ #include "VirtualFluids_GPU/Output/FileWriter.h" #include "VirtualFluids_GPU/Parameter/Parameter.h" -#include <logger/Logger.h> - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -134,11 +131,6 @@ std::string simulationName("TGV_3D_Gridref_noSqPress"); void multipleLevel(const std::string& configPath) { - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); auto gridFactory = GridFactory::make(); @@ -179,14 +171,14 @@ void multipleLevel(const std::string& configPath) gridBuilder->setNumberOfLayers(0, 0); - auto fineGrid = new Cuboid(-PI * 0.5, -PI * 0.5, -PI * 0.5, + auto fineGrid = std::make_shared<Cuboid>(-PI * 0.5, -PI * 0.5, -PI * 0.5, 0.0, PI * 0.5, 0.0); gridBuilder->addGrid(fineGrid, 1); gridBuilder->setPeriodicBoundaryCondition(true, true, true); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -353,22 +345,17 @@ int main( int argc, char* argv[]) } catch (const std::bad_alloc& e) { - - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << "Bad alloc: " << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (const std::exception& e) { - - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - //std::cout << "unknown exeption" << std::endl; + std::cout << "unknown exeption" << std::endl; } //std::cout << "\nConfiguration file must be set!: lbmgm <config file>" << std::endl << std::flush; diff --git a/apps/gpu/LBM/TGV_3D_MultiGPU/TGV_3D_MultiGPU.cpp b/apps/gpu/LBM/TGV_3D_MultiGPU/TGV_3D_MultiGPU.cpp index c6d78e2634e9728958b6f933d6f517553a7fae42..0c7b9b9606201b32a8376ea637858eb14ec817bb 100644 --- a/apps/gpu/LBM/TGV_3D_MultiGPU/TGV_3D_MultiGPU.cpp +++ b/apps/gpu/LBM/TGV_3D_MultiGPU/TGV_3D_MultiGPU.cpp @@ -50,8 +50,7 @@ //#include "metis.h" -#include "Core/LbmOrGks.h" -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" #include "basics/config/ConfigurationFile.h" #include "VirtualFluids_GPU/LBM/Simulation.h" @@ -157,17 +156,6 @@ void multipleLevel(const std::string& configPath) rankY = ( mpirank % ( sideLengthX * sideLengthY ) ) / sideLengthX; rankZ = mpirank / ( sideLengthY * sideLengthX ); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - logging::Logger::addStream(&std::cout); - - std::ofstream logFile( path + simulationName + "_rank_" + std::to_string(mpirank) + ".log" ); - logging::Logger::addStream(&logFile); - - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); //UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG5"); @@ -231,7 +219,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(sideLengthX == 1, sideLengthY == 1, sideLengthZ == 1); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! if( mpiWorldSize > 1 ) { @@ -242,12 +230,12 @@ void multipleLevel(const std::string& configPath) int rankPZ = rankX + rankY * sideLengthX + ( (rankZ + 1 + sideLengthZ) % sideLengthZ ) * sideLengthX * sideLengthY; int rankMZ = rankX + rankY * sideLengthX + ( (rankZ - 1 + sideLengthZ) % sideLengthZ ) * sideLengthX * sideLengthY; - if( sideLengthX > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PX, GKS ); - if( sideLengthX > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MX, GKS ); - if( sideLengthY > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PY, GKS ); - if( sideLengthY > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MY, GKS ); - if( sideLengthZ > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PZ, GKS ); - if( sideLengthZ > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MZ, GKS ); + if( sideLengthX > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PX ); + if( sideLengthX > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MX ); + if( sideLengthY > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PY ); + if( sideLengthY > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MY ); + if( sideLengthZ > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::PZ ); + if( sideLengthZ > 1 ) gridBuilder->findCommunicationIndices( CommunicationDirections::MZ ); if( sideLengthX > 1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::MX, rankMX); if( sideLengthY > 1 ) gridBuilder->setCommunicationProcess ( CommunicationDirections::MY, rankMY); diff --git a/apps/gpu/LBM/TrafficTest/3rdPartyLinking.cmake b/apps/gpu/LBM/TrafficTest/3rdPartyLinking.cmake deleted file mode 100644 index 7fb2e8a6d603bc12cd403934bfb4866fc67d498c..0000000000000000000000000000000000000000 --- a/apps/gpu/LBM/TrafficTest/3rdPartyLinking.cmake +++ /dev/null @@ -1,13 +0,0 @@ -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -#linkMPI(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -#linkCuda(${targetName}) -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Boost/Link.cmake) -#linkBoost(${targetName} "serialization") -#include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -#linkMetis(${targetName}) - -#if(HULC.BUILD_JSONCPP) -# include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) -# linkJsonCpp(${targetName}) -#endif() \ No newline at end of file diff --git a/apps/gpu/LBM/TrafficTest/CMakeLists.txt b/apps/gpu/LBM/TrafficTest/CMakeLists.txt deleted file mode 100644 index 766debd8705a7123decd8a11bb885e8e35b6f2d0..0000000000000000000000000000000000000000 --- a/apps/gpu/LBM/TrafficTest/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ - -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" - "${CMAKE_SOURCE_DIR}/src/Traffic" - "${CMAKE_SOURCE_DIR}/src/GridGenerator" - "${CMAKE_SOURCE_DIR}/src/Core") - - - -vf_add_library(BUILDTYPE binary PRIVATE_LINK Traffic basics GridGenerator) - -vf_get_library_name(library_name) -target_include_directories(${library_name} PRIVATE "${CMAKE_SOURCE_DIR}/src/basics") -target_include_directories(${library_name} PRIVATE "${CMAKE_SOURCE_DIR}/src/gpu") \ No newline at end of file diff --git a/apps/gpu/LBM/TrafficTest/CMakePackage.cmake b/apps/gpu/LBM/TrafficTest/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/LBM/TrafficTest/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/LBM/TrafficTest/Traffic_Main.cpp b/apps/gpu/LBM/TrafficTest/Traffic_Main.cpp deleted file mode 100644 index 487b51e7515d9001de0cd6be5938e75ce7832da0..0000000000000000000000000000000000000000 --- a/apps/gpu/LBM/TrafficTest/Traffic_Main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include <iostream> -#include <vector> -#include <memory> -#include <ctime> - -#include "Core/DataTypes.h" -#include "Core/Logger/Logger.h" - -#include "Traffic/TrafficMovementFactory.h" -#include "Traffic/TrafficMovementFactory - Kopie.h" - -int main() -{ - - //////Basel - - for (uint i = 0; i < 2; i++) { - - { - uint numberOfTimesteps = 1000*1000; - bool useGPU = false; - - - //Stephans Logger - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - - - //init TrafficMovement - TrafficMovementFactory * factory = new TrafficMovementFactory(); - std::string path = "C:/Users/hiwi/BaselDokumente/"; - factory->initTrafficMovement(path, useGPU); - - - //clock - std::clock_t start; - double duration; - start = std::clock(); - - - //loop through timestep - for (uint step = 1; step <= numberOfTimesteps; step++) { - factory->calculateTimestep(step); - factory->writeReducedTimestep(step); - } - - - //end simulation - duration = (std::clock() - start) / (double)CLOCKS_PER_SEC; - - factory->endSimulation(numberOfTimesteps, duration); - - std::cout << "Dauer: " << duration << '\n'; - - factory->writeTimestep(numberOfTimesteps); - } - } - - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ////Testcases - - //{uint numberOfTimesteps = 20; - - //TrafficMovementFactoryTest * factory = new TrafficMovementFactoryTest(); - //factory->initTrafficMovement(useGPU); - //factory->loopThroughTimesteps(numberOfTimesteps); - - //std::cout << std::endl << std::endl; } - - -} - diff --git a/apps/gpu/LBM/TrafficTest/a.exp b/apps/gpu/LBM/TrafficTest/a.exp deleted file mode 100644 index 7d295d48b1c52dfbd8db4278642942f1cbbbd6e1..0000000000000000000000000000000000000000 Binary files a/apps/gpu/LBM/TrafficTest/a.exp and /dev/null differ diff --git a/apps/gpu/LBM/TrafficTest/resources/ExampleStreets.txt b/apps/gpu/LBM/TrafficTest/resources/ExampleStreets.txt deleted file mode 100644 index 9e2df6c6dad1adc8fbfcdb7f8e91d794c56d0773..0000000000000000000000000000000000000000 --- a/apps/gpu/LBM/TrafficTest/resources/ExampleStreets.txt +++ /dev/null @@ -1,11 +0,0 @@ -10 - 256 5 87 5 1 - 87 5 -85 5 1 - -85 5 -80 256 1 - -85 5 -256 5 1 - -185 -256 -85 5 1 - -92 0 87 0 1 - -85 256 -92 0 1 - -256 0 -92 0 1 - 87 0 256 0 1 - -92 0 -190 -256 1 \ No newline at end of file diff --git a/apps/gpu/LBM/TrafficTest/resources/FlatGround.stl b/apps/gpu/LBM/TrafficTest/resources/FlatGround.stl deleted file mode 100644 index 8b18606cc5050121d3d724f248f7b7bd9d2425e8..0000000000000000000000000000000000000000 --- a/apps/gpu/LBM/TrafficTest/resources/FlatGround.stl +++ /dev/null @@ -1,86 +0,0 @@ -solid FlatGround -facet normal 0.0 0.0 -1.0 - outer loop - vertex 300.0 299.9999999999999 -10.000000000000002 - vertex -300.0 -299.99999999999994 -10.000000000000002 - vertex -300.0 299.9999999999999 -10.000000000000002 - endloop -endfacet -facet normal 0.0 0.0 -1.0 - outer loop - vertex -300.0 -299.99999999999994 -10.000000000000002 - vertex 300.0 299.9999999999999 -10.000000000000002 - vertex 300.0 -299.99999999999994 -10.000000000000002 - endloop -endfacet -facet normal -0.0 -0.0 1.0 - outer loop - vertex 300.0 -299.99999999999994 0.0 - vertex -300.0 299.9999999999999 0.0 - vertex -300.0 -299.99999999999994 0.0 - endloop -endfacet -facet normal -0.0 -0.0 1.0 - outer loop - vertex -300.0 299.9999999999999 0.0 - vertex 300.0 -299.99999999999994 0.0 - vertex 300.0 299.9999999999999 0.0 - endloop -endfacet -facet normal 0.0 -1.0 0.0 - outer loop - vertex 300.0 -299.99999999999994 0.0 - vertex -300.0 -299.99999999999994 -10.000000000000002 - vertex 300.0 -299.99999999999994 -10.000000000000002 - endloop -endfacet -facet normal 0.0 -1.0 0.0 - outer loop - vertex -300.0 -299.99999999999994 -10.000000000000002 - vertex 300.0 -299.99999999999994 0.0 - vertex -300.0 -299.99999999999994 0.0 - endloop -endfacet -facet normal -1.0 0.0 0.0 - outer loop - vertex -300.0 299.9999999999999 0.0 - vertex -300.0 -299.99999999999994 -10.000000000000002 - vertex -300.0 -299.99999999999994 0.0 - endloop -endfacet -facet normal -1.0 0.0 0.0 - outer loop - vertex -300.0 -299.99999999999994 -10.000000000000002 - vertex -300.0 299.9999999999999 0.0 - vertex -300.0 299.9999999999999 -10.000000000000002 - endloop -endfacet -facet normal -0.0 1.0 -0.0 - outer loop - vertex -300.0 299.9999999999999 0.0 - vertex 300.0 299.9999999999999 -10.000000000000002 - vertex -300.0 299.9999999999999 -10.000000000000002 - endloop -endfacet -facet normal -0.0 1.0 -0.0 - outer loop - vertex 300.0 299.9999999999999 -10.000000000000002 - vertex -300.0 299.9999999999999 0.0 - vertex 300.0 299.9999999999999 0.0 - endloop -endfacet -facet normal 1.0 -0.0 -0.0 - outer loop - vertex 300.0 299.9999999999999 -10.000000000000002 - vertex 300.0 -299.99999999999994 0.0 - vertex 300.0 -299.99999999999994 -10.000000000000002 - endloop -endfacet -facet normal 1.0 -0.0 -0.0 - outer loop - vertex 300.0 -299.99999999999994 0.0 - vertex 300.0 299.9999999999999 -10.000000000000002 - vertex 300.0 299.9999999999999 0.0 - endloop -endfacet -endsolid FlatGround diff --git a/apps/gpu/LBM/WTG_RUB/WTG_RUB.cpp b/apps/gpu/LBM/WTG_RUB/WTG_RUB.cpp index 168954898b060c70885c8f160e9aebf0a39ec8d3..d925eef7e7f452e19b63284f9ad3a6af25740e79 100644 --- a/apps/gpu/LBM/WTG_RUB/WTG_RUB.cpp +++ b/apps/gpu/LBM/WTG_RUB/WTG_RUB.cpp @@ -45,11 +45,10 @@ ////////////////////////////////////////////////////////////////////////// -#include "Core/DataTypes.h" +#include "DataTypes.h" #include "PointerDefinitions.h" -#include "Core/LbmOrGks.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" + +#include <logger/Logger.h> ////////////////////////////////////////////////////////////////////////// @@ -78,7 +77,6 @@ #include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" #include "VirtualFluids_GPU/Factories/BoundaryConditionFactory.h" -#include <logger/Logger.h> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -90,8 +88,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -LbmOrGks lbmOrGks = LBM; - // const real L = 1.0; const real velocity = 1.0; @@ -133,11 +129,6 @@ std::string chooseVariation(); void multipleLevel(const std::string& configPath) { - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); auto gridFactory = GridFactory::make(); @@ -176,8 +167,8 @@ void multipleLevel(const std::string& configPath) real z_min = 0.0 + z_offset; real z_max = 160.0 + z_offset; - //TriangularMesh *RubSTL = TriangularMesh::make(inputPath + "stl/Var02_0deg_FD_b.stl"); - TriangularMesh *RubSTL = TriangularMesh::make(inputPath + "stl/" + chooseVariation() + ".stl"); + //auto RubSTL = std::make_shared<TriangularMesh>(inputPath + "stl/Var02_0deg_FD_b.stl"); + auto RubSTL = std::make_shared<TriangularMesh>(inputPath + "stl/" + chooseVariation() + ".stl"); std::vector<real> originOfCityXY = { 600.0, y_max / 2, z_offset }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -213,7 +204,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(lbmOrGks, false); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(false); // buildGrids() has to be called before setting the BCs!!!! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -236,8 +227,8 @@ void multipleLevel(const std::string& configPath) //const real vx = velocityLB / (real)sqrt(2.0); // LB units //const real vy = velocityLB / (real)sqrt(2.0); // LB units - *logging::out << logging::Logger::INFO_HIGH << "velocity [dx/dt] = " << velocityLB << " \n"; - *logging::out << logging::Logger::INFO_HIGH << "viscosity [dx^2/dt] = " << viscosityLB << "\n"; + VF_LOG_INFO("velocityLB [dx/dt] = " << velocityLB); + VF_LOG_INFO("viscosityLB [dx^2/dt] = " << viscosityLB); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -410,18 +401,18 @@ void addFineGrids(SPtr<MultipleGridBuilder> gridBuilder, uint &maxLevel, real &r // FG5 -> dx = 1,25 mm; lvl 5 // // FineGrid Level 1 ->dx = 2 cm; lvl 1 - auto FG1 = new Cuboid(-20, -20, -5 + z_offset, 800, 200, 75 + z_offset); + auto FG1 = std::make_shared<Cuboid>(-20, -20, -5 + z_offset, 800, 200, 75 + z_offset); // FineGrid Level 2 -> dx = 1 cm; lvl 2 - auto FG2_1 = new Cuboid(-20, -20, -5 + z_offset, 760, 200, 10 + z_offset); - auto FG2_2 = new Cuboid(500, -20, 5 + z_offset, 680, 210, 50 + z_offset); + auto FG2_1 = std::make_shared<Cuboid>(-20, -20, -5 + z_offset, 760, 200, 10 + z_offset); + auto FG2_2 = std::make_shared<Cuboid>(500, -20, 5 + z_offset, 680, 210, 50 + z_offset); auto FG2 = new Conglomerate(); FG2->add(FG2_1); FG2->add(FG2_2); // FineGrid Level 3 ->dx = 5 mm; lvl 3 - auto FG3_1 = new Cuboid(517, -20, -5 + z_offset, 665, 200, 30 + z_offset); - auto FG3_2 = new Cuboid(550, 58, -5 + z_offset, 650, 132, 40 + z_offset); + auto FG3_1 = std::make_shared<Cuboid>(517, -20, -5 + z_offset, 665, 200, 30 + z_offset); + auto FG3_2 = std::make_shared<Cuboid>(550, 58, -5 + z_offset, 650, 132, 40 + z_offset); auto FG3 = new Conglomerate(); FG3->add(FG3_1); FG3->add(FG3_2); @@ -436,19 +427,19 @@ void addFineGrids(SPtr<MultipleGridBuilder> gridBuilder, uint &maxLevel, real &r gridBuilder->addGrid(FG3, 3); if (maxLevel >= 4) { if (rotationOfCity == 0.0) { - TriangularMesh *FG4 = TriangularMesh::make(inputPath + "stl/FG4_0deg.stl"); + auto FG4 = std::make_shared<TriangularMesh>(inputPath + "stl/FG4_0deg.stl"); gridBuilder->addGrid(FG4, 4); } else { - TriangularMesh *FG4 = TriangularMesh::make(inputPath + "stl/FG4_63deg.stl"); + auto FG4 = std::make_shared<TriangularMesh>(inputPath + "stl/FG4_63deg.stl"); gridBuilder->addGrid(FG4, 4); } if (maxLevel == 5) { if (rotationOfCity == 0.0) { - TriangularMesh *FG5 = TriangularMesh::make(inputPath + "stl/FG5_0deg.stl"); + auto FG5 = std::make_shared<TriangularMesh>(inputPath + "stl/FG5_0deg.stl"); gridBuilder->addGrid(FG5, 5); } else { - TriangularMesh *FG5 = TriangularMesh::make(inputPath + "stl/FG5_63deg.stl"); + auto FG5 = std::make_shared<TriangularMesh>(inputPath + "stl/FG5_63deg.stl"); gridBuilder->addGrid(FG5, 5); } } @@ -469,9 +460,9 @@ void addFineGrids(SPtr<MultipleGridBuilder> gridBuilder, uint &maxLevel, real &r // FG3 -> dx = 1,25 mm; lvl 3 // // FineGrid Level 1 -> dx = 5 mm; lvl 1 - //auto FG1_1 = new Cuboid(-20, -20, -5 + z_offset, 760, 200, 10 + z_offset); - auto FG1_1 = new Cuboid(-20, -20, -5 + z_offset, 760, 200, 20 + z_offset); - auto FG1_2 = new Cuboid(500, -20, 5 + z_offset, 680, 210, 50 + z_offset); + //auto FG1_1 = std::make_shared<Cuboid>(-20, -20, -5 + z_offset, 760, 200, 10 + z_offset); + auto FG1_1 = std::make_shared<Cuboid>(-20, -20, -5 + z_offset, 760, 200, 20 + z_offset); + auto FG1_2 = std::make_shared<Cuboid>(500, -20, 5 + z_offset, 680, 210, 50 + z_offset); auto FG1 = new Conglomerate(); FG1->add(FG1_1); FG1->add(FG1_2); @@ -482,19 +473,19 @@ void addFineGrids(SPtr<MultipleGridBuilder> gridBuilder, uint &maxLevel, real &r gridBuilder->addGrid(FG1, 1); if (maxLevel >= 2) { if (rotationOfCity == 0.0) { - TriangularMesh *FG2 = TriangularMesh::make(inputPath + "stl/FG4_0deg.stl"); + auto FG2 = std::make_shared<TriangularMesh>(inputPath + "stl/FG4_0deg.stl"); gridBuilder->addGrid(FG2, 2); } else { - TriangularMesh *FG2 = TriangularMesh::make(inputPath + "stl/FG4_63deg.stl"); + auto FG2 = std::make_shared<TriangularMesh>(inputPath + "stl/FG4_63deg.stl"); gridBuilder->addGrid(FG2, 2); } if (maxLevel == 3) { if (rotationOfCity == 0.0) { - TriangularMesh *FG3 = TriangularMesh::make(inputPath + "stl/FG5_0deg.stl"); + auto FG3 = std::make_shared<TriangularMesh>(inputPath + "stl/FG5_0deg.stl"); gridBuilder->addGrid(FG3, 3); } else { - TriangularMesh *FG3 = TriangularMesh::make(inputPath + "stl/FG5_63deg.stl"); + auto FG3 = std::make_shared<TriangularMesh>(inputPath + "stl/FG5_63deg.stl"); gridBuilder->addGrid(FG3, 3); } } @@ -514,18 +505,18 @@ void addFineGrids(SPtr<MultipleGridBuilder> gridBuilder, uint &maxLevel, real &r // FG4 -> dx = 1.0 mm; lvl 4 // //// FineGrid Level 1 ->dx = 8.0 mm; lvl 1 - // auto FG1 = new Cuboid(-20, -20, -5 + z_offset, 800, 200, 75 + z_offset); + // auto FG1 = std::make_shared<Cuboid>(-20, -20, -5 + z_offset, 800, 200, 75 + z_offset); // FineGrid Level 1 -> dx = 8.0 mm; lvl 1 - auto FG1_1 = new Cuboid(-20, -20, -5 + z_offset, 780, 200, 30 + z_offset); - auto FG1_2 = new Cuboid(500, -20, 5 + z_offset, 720, 210, 75 + z_offset); + auto FG1_1 = std::make_shared<Cuboid>(-20, -20, -5 + z_offset, 780, 200, 30 + z_offset); + auto FG1_2 = std::make_shared<Cuboid>(500, -20, 5 + z_offset, 720, 210, 75 + z_offset); auto FG1 = new Conglomerate(); FG1->add(FG1_1); FG1->add(FG1_2); // FineGrid Level 2 -> dx = 4.0 mm; lvl 2 - auto FG2_1 = new Cuboid(-20, -20, -5 + z_offset, 760, 200, 10 + z_offset); - auto FG2_2 = new Cuboid(520, -20, 5 + z_offset, 700, 210, 50 + z_offset); + auto FG2_1 = std::make_shared<Cuboid>(-20, -20, -5 + z_offset, 760, 200, 10 + z_offset); + auto FG2_2 = std::make_shared<Cuboid>(520, -20, 5 + z_offset, 700, 210, 50 + z_offset); auto FG2 = new Conglomerate(); FG2->add(FG2_1); FG2->add(FG2_2); @@ -538,19 +529,19 @@ void addFineGrids(SPtr<MultipleGridBuilder> gridBuilder, uint &maxLevel, real &r gridBuilder->addGrid(FG2, 2); if (maxLevel >= 3) { if (rotationOfCity == 0.0) { - TriangularMesh *FG3 = TriangularMesh::make(inputPath + "stl/FG4_0deg.stl"); + auto FG3 = std::make_shared<TriangularMesh>(inputPath + "stl/FG4_0deg.stl"); gridBuilder->addGrid(FG3, 3); } else { - TriangularMesh *FG3 = TriangularMesh::make(inputPath + "stl/FG4_63deg.stl"); + auto FG3 = std::make_shared<TriangularMesh>(inputPath + "stl/FG4_63deg.stl"); gridBuilder->addGrid(FG3, 3); } if (maxLevel == 4) { if (rotationOfCity == 0.0) { - TriangularMesh *FG4 = TriangularMesh::make(inputPath + "stl/FG5_0deg.stl"); + auto FG4 = std::make_shared<TriangularMesh>(inputPath + "stl/FG5_0deg.stl"); gridBuilder->addGrid(FG4, 4); } else { - TriangularMesh *FG4 = TriangularMesh::make(inputPath + "stl/FG5_63deg.stl"); + auto FG4 = std::make_shared<TriangularMesh>(inputPath + "stl/FG5_63deg.stl"); gridBuilder->addGrid(FG4, 4); } } @@ -569,11 +560,11 @@ void addFineGrids(SPtr<MultipleGridBuilder> gridBuilder, uint &maxLevel, real &r // FG2 -> dx = 1 cm; lvl 2 // // FineGrid Level 1 ->dx = 2 cm; lvl 1 - auto FG1 = new Cuboid(-20, -20, -5 + z_offset, 800, 200, 75 + z_offset); + auto FG1 = std::make_shared<Cuboid>(-20, -20, -5 + z_offset, 800, 200, 75 + z_offset); // FineGrid Level 2 -> dx = 1 cm; lvl 2 - auto FG2_1 = new Cuboid(-20, -20, -5 + z_offset, 760, 200, 10 + z_offset); - auto FG2_2 = new Cuboid(500, -20, 5 + z_offset, 680, 210, 50 + z_offset); + auto FG2_1 = std::make_shared<Cuboid>(-20, -20, -5 + z_offset, 760, 200, 10 + z_offset); + auto FG2_2 = std::make_shared<Cuboid>(500, -20, 5 + z_offset, 680, 210, 50 + z_offset); auto FG2 = new Conglomerate(); FG2->add(FG2_1); FG2->add(FG2_2); diff --git a/apps/gpu/LBM/gridGeneratorTest/gridGenerator.cpp b/apps/gpu/LBM/gridGeneratorTest/gridGenerator.cpp index 41ef914f2dae32d0ce5e5e6df1df7ff0879cf4d8..93ff9de0f0a156d9d9aec0ec1b6615ae728e7811 100644 --- a/apps/gpu/LBM/gridGeneratorTest/gridGenerator.cpp +++ b/apps/gpu/LBM/gridGeneratorTest/gridGenerator.cpp @@ -14,8 +14,7 @@ #define _USE_MATH_DEFINES #include <math.h> -#include "Core/LbmOrGks.h" -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" #include "basics/config/ConfigurationFile.h" #include "VirtualFluids_GPU/LBM/Simulation.h" @@ -59,17 +58,6 @@ void multipleLevel(const std::string& configPath) { - std::ofstream logFile( "F:/Work/Computations/out/Sphere/gridGeneratorLog.txt" ); - //std::ofstream logFile( "grid/gridGeneratorLog.txt" ); - logging::Logger::addStream(&logFile); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - - //UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG5"); - auto gridFactory = GridFactory::make(); //gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::RAYCASTING); gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); @@ -118,7 +106,7 @@ void multipleLevel(const std::string& configPath) ////////////////////////////////////////////////////////////////////////// gridBuilder->setPeriodicBoundaryCondition(true, true, true); ////////////////////////////////////////////////////////////////////////// - gridBuilder->buildGrids(LBM, true); + gridBuilder->buildGrids(true); ////////////////////////////////////////////////////////////////////////// SPtr<Grid> grid = gridBuilder->getGrid(gridBuilder->getNumberOfLevels() - 1); ////////////////////////////////////////////////////////////////////////// @@ -147,7 +135,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(true, true, true); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// SPtr<Grid> grid = gridBuilder->getGrid(gridBuilder->getNumberOfLevels() - 1); @@ -196,13 +184,13 @@ void multipleLevel(const std::string& configPath) ////////////////////////////////////////////////////////////////////////// - // TriangularMesh* sphereSTL = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/Sphere/SphereNotOptimal.stl"); + // auto sphereSTL = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/Sphere/SphereNotOptimal.stl"); - TriangularMesh* sphereRef_1_STL = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/Sphere/SphereRef_1.stl"); + auto sphereRef_1_STL = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/Sphere/SphereRef_1.stl"); - // TriangularMesh* sphereRef_2_STL = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/Sphere/SphereRef_2.stl"); + // auto sphereRef_2_STL = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/Sphere/SphereRef_2.stl"); - Object* sphere = new Sphere( 0, 0, 0, 0.5*D ); + auto sphere = std::make_shared<Sphere>( 0, 0, 0, 0.5*D ); gridBuilder->addCoarseGrid(-2.0*D, -2.5*D, -2.5*D, 9.0*D, 2.5*D, 2.5*D, dx); // DrivAer @@ -224,7 +212,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// gridBuilder->setVelocityBoundaryCondition(SideType::PY, vx , 0.0, 0.0); gridBuilder->setVelocityBoundaryCondition(SideType::MY, vx , 0.0, 0.0); @@ -281,21 +269,21 @@ void multipleLevel(const std::string& configPath) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - TriangularMesh* DrivAerSTL = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/DrivAer_Fastback_Coarse.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("M:/TestGridGeneration/STL/DrivAer_NoSTLGroups.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("M:/TestGridGeneration/STL/DrivAer_Coarse.stl"); - //TriangularMesh* DrivAerSTL = TriangularMesh::make("stl/DrivAer_Fastback_Coarse.stl"); + auto DrivAerSTL = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/DrivAer_Fastback_Coarse.stl"); + //auto triangularMesh = std::make_shared<TriangularMesh>("M:/TestGridGeneration/STL/DrivAer_NoSTLGroups.stl"); + //auto triangularMesh = std::make_shared<TriangularMesh>("M:/TestGridGeneration/STL/DrivAer_Coarse.stl"); + //auto DrivAerSTL = std::make_shared<TriangularMesh>("stl/DrivAer_Fastback_Coarse.stl"); - TriangularMesh* DrivAerRefBoxSTL = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/DrivAer_REF_BOX_Adrea.stl"); - //TriangularMesh* DrivAerRefBoxSTL = TriangularMesh::make("stl/DrivAer_REF_BOX_Adrea.stl"); + auto DrivAerRefBoxSTL = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/DrivAer_REF_BOX_Adrea.stl"); + //auto DrivAerRefBoxSTL = std::make_shared<TriangularMesh>("stl/DrivAer_REF_BOX_Adrea.stl"); real z0 = 0.318; gridBuilder->addCoarseGrid(- 5.0, -5.0, 0.0 - z0, 15.0, 5.0, 5.0 - z0, dx); // DrivAer - //Object* floorBox = new Cuboid( -0.3, -1, -1, 4.0, 1, 0.2 ); - //Object* wakeBox = new Cuboid( 3.5, -1, -1, 5.5, 1, 0.8 ); + //auto floorBox = std::make_shared<Cuboid>( -0.3, -1, -1, 4.0, 1, 0.2 ); + //auto wakeBox = std::make_shared<Cuboid>( 3.5, -1, -1, 5.5, 1, 0.8 ); //Conglomerate* refRegion = new Conglomerate(); @@ -313,7 +301,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// @@ -384,11 +372,11 @@ void multipleLevel(const std::string& configPath) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - TriangularMesh* STL = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/PaperPlane_1.stl"); - //TriangularMesh* STL = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/PaperPlane_1_winglet.stl"); + auto STL = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/PaperPlane_1.stl"); + //auto STL = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/PaperPlane_1_winglet.stl"); - TriangularMesh* RefBoxSTL = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/PaperPlane_1_ref.stl"); - //TriangularMesh* RefBoxSTL = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/PaperPlane_1_winglet_ref.stl"); + auto RefBoxSTL = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/PaperPlane_1_ref.stl"); + //auto RefBoxSTL = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/PaperPlane_1_winglet_ref.stl"); gridBuilder->addCoarseGrid(- 0.5, -0.3, -0.3, 1.0, 0.3, 0.3, dx); @@ -400,7 +388,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// @@ -463,7 +451,7 @@ void multipleLevel(const std::string& configPath) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - TriangularMesh* STL = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/STL_Group_Test_2_Cylinders.stl"); + auto STL = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/STL_Group_Test_2_Cylinders.stl"); gridBuilder->addCoarseGrid(- 2.0, -4.5, -2.0, 4.0, 4.5, 2.0, dx); @@ -472,7 +460,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// @@ -519,34 +507,34 @@ void multipleLevel(const std::string& configPath) std::vector<uint> ignorePatches = { 152, 153, 154 }; - //TriangularMesh* VW370_SERIE_STL = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/VW370_SERIE.stl", ignorePatches); - TriangularMesh* VW370_SERIE_STL = TriangularMesh::make("stl/VW370_SERIE.stl", ignorePatches); + //auto VW370_SERIE_STL = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/VW370_SERIE.stl", ignorePatches); + auto VW370_SERIE_STL = std::make_shared<TriangularMesh>("stl/VW370_SERIE.stl", ignorePatches); - //TriangularMesh* DLC_RefBox = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox.stl"); + //auto DLC_RefBox = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox.stl"); - //TriangularMesh* DLC_RefBox_1 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_4m.stl"); - //TriangularMesh* DLC_RefBox_2 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_3m.stl"); - //TriangularMesh* DLC_RefBox_3 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_2m.stl"); - //TriangularMesh* DLC_RefBox_4 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_1m.stl"); + //auto DLC_RefBox_1 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_4m.stl"); + //auto DLC_RefBox_2 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_3m.stl"); + //auto DLC_RefBox_3 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_2m.stl"); + //auto DLC_RefBox_4 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_1m.stl"); - //TriangularMesh* DLC_RefBox_Level_3 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC/DLC_RefBox_Level_3.stl"); - //TriangularMesh* DLC_RefBox_Level_4 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC/DLC_RefBox_Level_4.stl"); - //TriangularMesh* DLC_RefBox_Level_5 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC/DLC_RefBox_Level_5.stl"); + //auto DLC_RefBox_Level_3 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC/DLC_RefBox_Level_3.stl"); + //auto DLC_RefBox_Level_4 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC/DLC_RefBox_Level_4.stl"); + //auto DLC_RefBox_Level_5 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC/DLC_RefBox_Level_5.stl"); - TriangularMesh* DLC_RefBox_Level_3 = TriangularMesh::make("stl/DLC/DLC_RefBox_Level_3.stl"); - TriangularMesh* DLC_RefBox_Level_4 = TriangularMesh::make("stl/DLC/DLC_RefBox_Level_4.stl"); - TriangularMesh* DLC_RefBox_Level_5 = TriangularMesh::make("stl/DLC/DLC_RefBox_Level_5.stl"); + auto DLC_RefBox_Level_3 = std::make_shared<TriangularMesh>("stl/DLC/DLC_RefBox_Level_3.stl"); + auto DLC_RefBox_Level_4 = std::make_shared<TriangularMesh>("stl/DLC/DLC_RefBox_Level_4.stl"); + auto DLC_RefBox_Level_5 = std::make_shared<TriangularMesh>("stl/DLC/DLC_RefBox_Level_5.stl"); - //TriangularMesh* VW370_SERIE_STL = TriangularMesh::make("stl/VW370_SERIE.stl", ignorePatches); - //TriangularMesh* DLC_RefBox = TriangularMesh::make("stl/DLC_RefBox.lnx.stl"); - //TriangularMesh* DLC_RefBox_4 = TriangularMesh::make("stl/DLC_RefBox_withWake/DLC_RefBox_withWake_1m.lnx.stl"); + //auto VW370_SERIE_STL = std::make_shared<TriangularMesh>("stl/VW370_SERIE.stl", ignorePatches); + //auto DLC_RefBox = std::make_shared<TriangularMesh>("stl/DLC_RefBox.lnx.stl"); + //auto DLC_RefBox_4 = std::make_shared<TriangularMesh>("stl/DLC_RefBox_withWake/DLC_RefBox_withWake_1m.lnx.stl"); gridBuilder->addCoarseGrid(-30.0, -20.0, 0.0 - z0, 50.0, 20.0, 25.0 - z0, dx); gridBuilder->setNumberOfLayers(10,8); - gridBuilder->addGrid( new Cuboid( - 6.6, -6, -0.7, 20.6 , 6, 5.3 ), 1 ); - gridBuilder->addGrid( new Cuboid( -3.75, -3, -0.7, 11.75, 3, 2.65 ), 2 ); + gridBuilder->addGrid( std::make_shared<Cuboid>( - 6.6, -6, -0.7, 20.6 , 6, 5.3 ), 1 ); + gridBuilder->addGrid( std::make_shared<Cuboid>( -3.75, -3, -0.7, 11.75, 3, 2.65 ), 2 ); gridBuilder->setNumberOfLayers(10,8); gridBuilder->addGrid(DLC_RefBox_Level_3, 3); @@ -563,7 +551,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// @@ -673,10 +661,9 @@ void multipleLevel(const std::string& configPath) logFile2.open( "F:/Work/Computations/gridGenerator/grid/1/gridGeneratorLog.txt" ); //logFile2.open( "grid/1/gridGeneratorLog.txt" ); - logging::Logger::addStream(&logFile2); - TriangularMesh* triangularMesh = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/Sphere/SphereNotOptimal.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("stl/ShpereNotOptimal.lnx.stl"); + auto triangularMesh = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/Sphere/SphereNotOptimal.stl"); + //auto triangularMesh = std::make_shared<TriangularMesh>("stl/ShpereNotOptimal.lnx.stl"); // all //gridBuilder->addCoarseGrid(-2, -2, -2, @@ -710,7 +697,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! if( generatePart == 0 ){ gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); @@ -821,18 +808,17 @@ int main( int argc, char* argv[]) } catch (const std::bad_alloc& e) { - - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; + std::cout << "Bad alloc: " << e.what() << std::flush; } catch (const std::exception& e) { - - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; + std::cout << e.what() << std::flush; } catch (...) { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; + std::cout << "unknown exeption" << std::endl; } + } MPI_Finalize(); diff --git a/apps/gpu/LBM/lbmTest/main.cpp b/apps/gpu/LBM/lbmTest/main.cpp index 295d85ec99e556e27ee95121cea599b74eb96c4e..abe8e7488a55c773896ef6cb362db2bb8247fa4e 100644 --- a/apps/gpu/LBM/lbmTest/main.cpp +++ b/apps/gpu/LBM/lbmTest/main.cpp @@ -16,9 +16,8 @@ #include "metis.h" -#include "Core/LbmOrGks.h" -#include "Core/Input/Input.h" -#include "Core/StringUtilities/StringUtil.h" +#include "Input/Input.h" +#include "StringUtilities/StringUtil.h" #include "VirtualFluids_GPU/LBM/Simulation.h" #include "VirtualFluids_GPU/Communication/Communicator.h" @@ -263,17 +262,6 @@ void setParameters(std::shared_ptr<Parameter> para, std::unique_ptr<input::Input void multipleLevel(const std::string& configPath) { - //std::ofstream logFile( "F:/Work/Computations/gridGenerator/grid/gridGeneratorLog.txt" ); - std::ofstream logFile( "grid/gridGeneratorLog.txt" ); - logging::Logger::addStream(&logFile); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - - //UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG5"); - auto gridFactory = GridFactory::make(); gridFactory->setGridStrategy(Device::CPU); //gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::RAYCASTING); @@ -318,7 +306,7 @@ void multipleLevel(const std::string& configPath) ////////////////////////////////////////////////////////////////////////// gridBuilder->setPeriodicBoundaryCondition(true, true, true); ////////////////////////////////////////////////////////////////////////// - gridBuilder->buildGrids(LBM, true); + gridBuilder->buildGrids(true); ////////////////////////////////////////////////////////////////////////// SPtr<Grid> grid = gridBuilder->getGrid(gridBuilder->getNumberOfLevels() - 1); ////////////////////////////////////////////////////////////////////////// @@ -348,7 +336,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(true, true, true); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// SPtr<Grid> grid = gridBuilder->getGrid(gridBuilder->getNumberOfLevels() - 1); ////////////////////////////////////////////////////////////////////////// @@ -373,7 +361,7 @@ void multipleLevel(const std::string& configPath) real dx = 0.2; real vx = 0.05; - TriangularMesh* SphereSTL = TriangularMesh::make("E:/temp/GridSphere/2018/STL/SphereNotOptimal.stl"); + auto SphereSTL = std::make_shared<TriangularMesh>("E:/temp/GridSphere/2018/STL/SphereNotOptimal.stl"); gridBuilder->addCoarseGrid(- 5.0, -5.0, -5.0, 10.0, 5.0, 5.0, dx); // DrivAer @@ -385,7 +373,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// gridBuilder->setVelocityBoundaryCondition(SideType::PY, vx , 0.0, 0.0); gridBuilder->setVelocityBoundaryCondition(SideType::MY, vx , 0.0, 0.0); @@ -421,21 +409,21 @@ void multipleLevel(const std::string& configPath) real dx = 0.2; real vx = 0.05; - TriangularMesh* DrivAerSTL = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/DrivAer_Fastback_Coarse.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("M:/TestGridGeneration/STL/DrivAer_NoSTLGroups.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("M:/TestGridGeneration/STL/DrivAer_Coarse.stl"); - //TriangularMesh* DrivAerSTL = TriangularMesh::make("stl/DrivAer_Fastback_Coarse.stl"); + auto DrivAerSTL = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/DrivAer_Fastback_Coarse.stl"); + //auto triangularMesh = std::make_shared<TriangularMesh>("M:/TestGridGeneration/STL/DrivAer_NoSTLGroups.stl"); + //auto triangularMesh = std::make_shared<TriangularMesh>("M:/TestGridGeneration/STL/DrivAer_Coarse.stl"); + //auto DrivAerSTL = std::make_shared<TriangularMesh>("stl/DrivAer_Fastback_Coarse.stl"); - TriangularMesh* DrivAerRefBoxSTL = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/DrivAer_REF_BOX_Adrea.stl"); - //TriangularMesh* DrivAerRefBoxSTL = TriangularMesh::make("stl/DrivAer_REF_BOX_Adrea.stl"); + auto DrivAerRefBoxSTL = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/DrivAer_REF_BOX_Adrea.stl"); + //auto DrivAerRefBoxSTL = std::make_shared<TriangularMesh>("stl/DrivAer_REF_BOX_Adrea.stl"); real z0 = 0.318+0.5*dx; gridBuilder->addCoarseGrid(- 5.0, -5.0, 0.0 - z0, 15.0, 5.0, 5.0 - z0, dx); // DrivAer - //Object* floorBox = new Cuboid( -0.3, -1, -1, 4.0, 1, 0.2 ); - //Object* wakeBox = new Cuboid( 3.5, -1, -1, 5.5, 1, 0.8 ); + //Object* floorBox = std::make_shared<Cuboid>( -0.3, -1, -1, 4.0, 1, 0.2 ); + //Object* wakeBox = std::make_shared<Cuboid>( 3.5, -1, -1, 5.5, 1, 0.8 ); //Conglomerate* refRegion = new Conglomerate(); @@ -453,7 +441,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// @@ -508,34 +496,34 @@ void multipleLevel(const std::string& configPath) std::vector<uint> ignorePatches = { 152, 153, 154 }; - //TriangularMesh* VW370_SERIE_STL = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/VW370_SERIE.stl", ignorePatches); - TriangularMesh* VW370_SERIE_STL = TriangularMesh::make("stl/VW370_SERIE.stl", ignorePatches); + //auto VW370_SERIE_STL = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/VW370_SERIE.stl", ignorePatches); + auto VW370_SERIE_STL = std::make_shared<TriangularMesh>("stl/VW370_SERIE.stl", ignorePatches); - //TriangularMesh* DLC_RefBox = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox.stl"); + //auto DLC_RefBox = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox.stl"); - //TriangularMesh* DLC_RefBox_1 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_4m.stl"); - //TriangularMesh* DLC_RefBox_2 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_3m.stl"); - //TriangularMesh* DLC_RefBox_3 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_2m.stl"); - //TriangularMesh* DLC_RefBox_4 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_1m.stl"); + //auto DLC_RefBox_1 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_4m.stl"); + //auto DLC_RefBox_2 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_3m.stl"); + //auto DLC_RefBox_3 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_2m.stl"); + //auto DLC_RefBox_4 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC_RefBox_withWake/DLC_RefBox_withWake_1m.stl"); - //TriangularMesh* DLC_RefBox_Level_3 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC/DLC_RefBox_Level_3.stl"); - //TriangularMesh* DLC_RefBox_Level_4 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC/DLC_RefBox_Level_4.stl"); - //TriangularMesh* DLC_RefBox_Level_5 = TriangularMesh::make("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC/DLC_RefBox_Level_5.stl"); + //auto DLC_RefBox_Level_3 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC/DLC_RefBox_Level_3.stl"); + //auto DLC_RefBox_Level_4 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC/DLC_RefBox_Level_4.stl"); + //auto DLC_RefBox_Level_5 = std::make_shared<TriangularMesh>("C:/Users/lenz/Desktop/Work/gridGenerator/stl/DLC/DLC_RefBox_Level_5.stl"); - TriangularMesh* DLC_RefBox_Level_3 = TriangularMesh::make("stl/DLC/DLC_RefBox_Level_3.stl"); - TriangularMesh* DLC_RefBox_Level_4 = TriangularMesh::make("stl/DLC/DLC_RefBox_Level_4.stl"); - TriangularMesh* DLC_RefBox_Level_5 = TriangularMesh::make("stl/DLC/DLC_RefBox_Level_5.stl"); + auto DLC_RefBox_Level_3 = std::make_shared<TriangularMesh>("stl/DLC/DLC_RefBox_Level_3.stl"); + auto DLC_RefBox_Level_4 = std::make_shared<TriangularMesh>("stl/DLC/DLC_RefBox_Level_4.stl"); + auto DLC_RefBox_Level_5 = std::make_shared<TriangularMesh>("stl/DLC/DLC_RefBox_Level_5.stl"); - //TriangularMesh* VW370_SERIE_STL = TriangularMesh::make("stl/VW370_SERIE.stl", ignorePatches); - //TriangularMesh* DLC_RefBox = TriangularMesh::make("stl/DLC_RefBox.lnx.stl"); - //TriangularMesh* DLC_RefBox_4 = TriangularMesh::make("stl/DLC_RefBox_withWake/DLC_RefBox_withWake_1m.lnx.stl"); + //auto VW370_SERIE_STL = std::make_shared<TriangularMesh>("stl/VW370_SERIE.stl", ignorePatches); + //auto DLC_RefBox = std::make_shared<TriangularMesh>("stl/DLC_RefBox.lnx.stl"); + //auto DLC_RefBox_4 = std::make_shared<TriangularMesh>("stl/DLC_RefBox_withWake/DLC_RefBox_withWake_1m.lnx.stl"); gridBuilder->addCoarseGrid(-30.0, -20.0, 0.0 - z0, 50.0, 20.0, 25.0 - z0, dx); gridBuilder->setNumberOfLayers(10,8); - gridBuilder->addGrid( new Cuboid( - 6.6, -6, -0.7, 20.6 , 6, 5.3 ), 1 ); - gridBuilder->addGrid( new Cuboid( -3.75, -3, -0.7, 11.75, 3, 2.65 ), 2 ); + gridBuilder->addGrid( std::make_shared<Cuboid>( - 6.6, -6, -0.7, 20.6 , 6, 5.3 ), 1 ); + gridBuilder->addGrid( std::make_shared<Cuboid>( -3.75, -3, -0.7, 11.75, 3, 2.65 ), 2 ); gridBuilder->setNumberOfLayers(10,8); gridBuilder->addGrid(DLC_RefBox_Level_3, 3); @@ -552,7 +540,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// @@ -633,13 +621,11 @@ void multipleLevel(const std::string& configPath) logFile2.open( "F:/Work/Computations/gridGenerator/grid/1/gridGeneratorLog.txt" ); //logFile2.open( "grid/1/gridGeneratorLog.txt" ); - logging::Logger::addStream(&logFile2); - real dx = 1.0 / 40.0; real vx = 0.05; - TriangularMesh* triangularMesh = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/ShpereNotOptimal.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("stl/ShpereNotOptimal.lnx.stl"); + auto triangularMesh = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/ShpereNotOptimal.stl"); + //auto triangularMesh = std::make_shared<TriangularMesh>("stl/ShpereNotOptimal.lnx.stl"); // all //gridBuilder->addCoarseGrid(-2, -2, -2, @@ -673,7 +659,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! if( generatePart == 0 ){ gridBuilder->findCommunicationIndices(CommunicationDirections::PX, LBM); @@ -775,7 +761,6 @@ int main( int argc, char* argv[]) } catch (const std::exception& e) { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) @@ -792,22 +777,17 @@ int main( int argc, char* argv[]) } catch (const std::exception& e) { - - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (const std::bad_alloc e) { - - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - //std::cout << "unknown exeption" << std::endl; + std::cout << "unknown exeption" << std::endl; } std::cout << "\nConfiguration file must be set!: lbmgm <config file>" << std::endl << std::flush; diff --git a/apps/gpu/LBM/metisTest/main.cpp b/apps/gpu/LBM/metisTest/main.cpp index 3cbb6838119625d13759662dda4a020126c896af..b9879c16c32afd0ec27c5841a0b2dad7e4191055 100644 --- a/apps/gpu/LBM/metisTest/main.cpp +++ b/apps/gpu/LBM/metisTest/main.cpp @@ -15,9 +15,8 @@ #include "metis.h" -#include "Core/LbmOrGks.h" -#include "Core/Input/Input.h" -#include "Core/StringUtilities/StringUtil.h" +#include "Input/Input.h" +#include "StringUtilities/StringUtil.h" #include "VirtualFluids_GPU/LBM/Simulation.h" #include "VirtualFluids_GPU/Communication/Communicator.h" @@ -263,17 +262,6 @@ void setParameters(std::shared_ptr<Parameter> para, std::unique_ptr<input::Input void multipleLevel(const std::string& configPath) { - //std::ofstream logFile( "F:/Work/Computations/gridGenerator/grid/gridGeneratorLog.txt" ); - std::ofstream logFile( "grid/gridGeneratorLog.txt" ); - logging::Logger::addStream(&logFile); - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - - //UbLog::reportingLevel() = UbLog::logLevelFromString("DEBUG5"); - auto gridFactory = GridFactory::make(); gridFactory->setGridStrategy(Device::CPU); //gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::RAYCASTING); @@ -299,8 +287,8 @@ void multipleLevel(const std::string& configPath) real dx = 1.0 / 20.0; real vx = 0.05; - TriangularMesh* triangularMesh = TriangularMesh::make("F:/Work/Computations/gridGenerator/stl/ShpereNotOptimal.stl"); - //TriangularMesh* triangularMesh = TriangularMesh::make("stl/ShpereNotOptimal.lnx.stl"); + auto triangularMesh = std::make_shared<TriangularMesh>("F:/Work/Computations/gridGenerator/stl/ShpereNotOptimal.stl"); + //auto triangularMesh = std::make_shared<TriangularMesh>("stl/ShpereNotOptimal.lnx.stl"); // all //gridBuilder->addCoarseGrid(-2, -2, -2, @@ -319,7 +307,7 @@ void multipleLevel(const std::string& configPath) gridBuilder->setPeriodicBoundaryCondition(false, false, false); - gridBuilder->buildGrids(LBM, true); // buildGrids() has to be called before setting the BCs!!!! + gridBuilder->buildGrids(true); // buildGrids() has to be called before setting the BCs!!!! ////////////////////////////////////////////////////////////////////////// @@ -784,7 +772,6 @@ int main( int argc, char* argv[]) } catch (const std::exception& e) { - *logging::out << logging::Logger::ERROR << e.what() << "\n"; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) @@ -800,22 +787,17 @@ int main( int argc, char* argv[]) } catch (const std::exception& e) { - - *logging::out << logging::Logger::ERROR << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (const std::bad_alloc e) { - - *logging::out << logging::Logger::ERROR << "Bad Alloc:" << e.what() << "\n"; - //std::cout << e.what() << std::flush; + std::cout << e.what() << std::flush; //MPI_Abort(MPI_COMM_WORLD, -1); } catch (...) { - *logging::out << logging::Logger::ERROR << "Unknown exception!\n"; - //std::cout << "unknown exeption" << std::endl; + std::cout << "unknown exeption" << std::endl; } std::cout << "\nConfiguration file must be set!: lbmgm <config file>" << std::endl << std::flush; diff --git a/apps/gpu/LBM/streetTest/3rdPartyLinking.cmake b/apps/gpu/LBM/streetTest/3rdPartyLinking.cmake deleted file mode 100644 index 6dd6ba1bc73e73dfbf01a3cc36aaeb3664e1c04c..0000000000000000000000000000000000000000 --- a/apps/gpu/LBM/streetTest/3rdPartyLinking.cmake +++ /dev/null @@ -1,13 +0,0 @@ -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/MPI/Link.cmake) -linkMPI(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Cuda/Link.cmake) -linkCuda(${targetName}) -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Boost/Link.cmake) -linkBoost(${targetName} "serialization") -include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/Metis/Link.cmake) -linkMetis(${targetName}) - -if(HULC.BUILD_JSONCPP) - include (${CMAKE_SOURCE_DIR}/${cmakeMacroPath}/JsonCpp/Link.cmake) - linkJsonCpp(${targetName}) -endif() \ No newline at end of file diff --git a/apps/gpu/LBM/streetTest/CMakeLists.txt b/apps/gpu/LBM/streetTest/CMakeLists.txt deleted file mode 100644 index 6ef6241b52aa9b5dc73a19b82f2b9fd5248c77c5..0000000000000000000000000000000000000000 --- a/apps/gpu/LBM/streetTest/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -setTargetNameToFolderName(${CMAKE_CURRENT_LIST_DIR}) - -set(linkDirectories "") -set(libsToLink VirtualFluids_GPU GridGenerator) -set(includeDirectories "${CMAKE_SOURCE_DIR}/src" "${CMAKE_SOURCE_DIR}/src/VirtualFluids_GPU" "${CMAKE_SOURCE_DIR}/src/GridGenerator" "${CMAKE_SOURCE_DIR}/src/VirtualFluidsBasics") - -#glob files and save in MY_SRCS -include(CMakePackage.cmake) - -buildExe(${targetName} "${MY_SRCS}" "${linkDirectories}" "${libsToLink}" "${includeDirectories}") -groupTarget(${targetName} ${lbmAppFolder}) - -# Specify the linking to 3rdParty libs -include(3rdPartyLinking.cmake) \ No newline at end of file diff --git a/apps/gpu/LBM/streetTest/CMakePackage.cmake b/apps/gpu/LBM/streetTest/CMakePackage.cmake deleted file mode 100644 index 5d39e3804dbd180790629111449a7dc918292430..0000000000000000000000000000000000000000 --- a/apps/gpu/LBM/streetTest/CMakePackage.cmake +++ /dev/null @@ -1,9 +0,0 @@ -#FILE ENDINGS -resetFileEndingsToCollect() -addCAndCPPFileTypes() -addFileEndingToCollect("*.cu") -addFileEndingToCollect("*.cuh") - -#GLOB SOURCE FILES IN MY_SRCS -unset(MY_SRCS) -includeRecursiveAllFilesFrom(${targetName} ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/apps/gpu/LBM/streetTest/resources/ExampleStreets.txt b/apps/gpu/LBM/streetTest/resources/ExampleStreets.txt deleted file mode 100644 index 9e2df6c6dad1adc8fbfcdb7f8e91d794c56d0773..0000000000000000000000000000000000000000 --- a/apps/gpu/LBM/streetTest/resources/ExampleStreets.txt +++ /dev/null @@ -1,11 +0,0 @@ -10 - 256 5 87 5 1 - 87 5 -85 5 1 - -85 5 -80 256 1 - -85 5 -256 5 1 - -185 -256 -85 5 1 - -92 0 87 0 1 - -85 256 -92 0 1 - -256 0 -92 0 1 - 87 0 256 0 1 - -92 0 -190 -256 1 \ No newline at end of file diff --git a/apps/gpu/LBM/streetTest/resources/FlatGround.stl b/apps/gpu/LBM/streetTest/resources/FlatGround.stl deleted file mode 100644 index 8b18606cc5050121d3d724f248f7b7bd9d2425e8..0000000000000000000000000000000000000000 --- a/apps/gpu/LBM/streetTest/resources/FlatGround.stl +++ /dev/null @@ -1,86 +0,0 @@ -solid FlatGround -facet normal 0.0 0.0 -1.0 - outer loop - vertex 300.0 299.9999999999999 -10.000000000000002 - vertex -300.0 -299.99999999999994 -10.000000000000002 - vertex -300.0 299.9999999999999 -10.000000000000002 - endloop -endfacet -facet normal 0.0 0.0 -1.0 - outer loop - vertex -300.0 -299.99999999999994 -10.000000000000002 - vertex 300.0 299.9999999999999 -10.000000000000002 - vertex 300.0 -299.99999999999994 -10.000000000000002 - endloop -endfacet -facet normal -0.0 -0.0 1.0 - outer loop - vertex 300.0 -299.99999999999994 0.0 - vertex -300.0 299.9999999999999 0.0 - vertex -300.0 -299.99999999999994 0.0 - endloop -endfacet -facet normal -0.0 -0.0 1.0 - outer loop - vertex -300.0 299.9999999999999 0.0 - vertex 300.0 -299.99999999999994 0.0 - vertex 300.0 299.9999999999999 0.0 - endloop -endfacet -facet normal 0.0 -1.0 0.0 - outer loop - vertex 300.0 -299.99999999999994 0.0 - vertex -300.0 -299.99999999999994 -10.000000000000002 - vertex 300.0 -299.99999999999994 -10.000000000000002 - endloop -endfacet -facet normal 0.0 -1.0 0.0 - outer loop - vertex -300.0 -299.99999999999994 -10.000000000000002 - vertex 300.0 -299.99999999999994 0.0 - vertex -300.0 -299.99999999999994 0.0 - endloop -endfacet -facet normal -1.0 0.0 0.0 - outer loop - vertex -300.0 299.9999999999999 0.0 - vertex -300.0 -299.99999999999994 -10.000000000000002 - vertex -300.0 -299.99999999999994 0.0 - endloop -endfacet -facet normal -1.0 0.0 0.0 - outer loop - vertex -300.0 -299.99999999999994 -10.000000000000002 - vertex -300.0 299.9999999999999 0.0 - vertex -300.0 299.9999999999999 -10.000000000000002 - endloop -endfacet -facet normal -0.0 1.0 -0.0 - outer loop - vertex -300.0 299.9999999999999 0.0 - vertex 300.0 299.9999999999999 -10.000000000000002 - vertex -300.0 299.9999999999999 -10.000000000000002 - endloop -endfacet -facet normal -0.0 1.0 -0.0 - outer loop - vertex 300.0 299.9999999999999 -10.000000000000002 - vertex -300.0 299.9999999999999 0.0 - vertex 300.0 299.9999999999999 0.0 - endloop -endfacet -facet normal 1.0 -0.0 -0.0 - outer loop - vertex 300.0 299.9999999999999 -10.000000000000002 - vertex 300.0 -299.99999999999994 0.0 - vertex 300.0 -299.99999999999994 -10.000000000000002 - endloop -endfacet -facet normal 1.0 -0.0 -0.0 - outer loop - vertex 300.0 -299.99999999999994 0.0 - vertex 300.0 299.9999999999999 -10.000000000000002 - vertex 300.0 299.9999999999999 0.0 - endloop -endfacet -endsolid FlatGround diff --git a/apps/gpu/LBM/streetTest/streetTest.cpp b/apps/gpu/LBM/streetTest/streetTest.cpp deleted file mode 100644 index 8b197e7098fd7c0c446aa4587bff14d5cc8e57af..0000000000000000000000000000000000000000 --- a/apps/gpu/LBM/streetTest/streetTest.cpp +++ /dev/null @@ -1,75 +0,0 @@ - -#include <iostream> - -#include "GridGenerator/StreetPointFinder/StreetPointFinder.h" - - -#include "GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.h" -#include "GridGenerator/geometries/TriangularMesh/TriangularMesh.h" -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/BoundaryConditions/Side.h" -#include "GridGenerator/grid/BoundaryConditions/BoundaryCondition.h" -#include "GridGenerator/grid/GridFactory.h" -#include "GridGenerator/io/GridVTKWriter/GridVTKWriter.h" -#include "GridGenerator/io/STLReaderWriter/STLReader.h" -#include "GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h" - -int main( int argc, char* argv[]) -{ - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_INTERMEDIATE); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - real dx = 1.0; - - gridBuilder->addCoarseGrid(-256, -256, -10, - 256, 256, 40, dx); - - TriangularMesh* flatGroundSTL = TriangularMesh::make("F:/Work/Computations/NagelSchreckenberg/FlatGround.stl"); - - gridBuilder->addGeometry(flatGroundSTL); - - gridBuilder->setPeriodicBoundaryCondition(true, true, false); - - gridBuilder->buildGrids(LBM, false); - - gridBuilder->setVelocityBoundaryCondition(SideType::GEOMETRY, 0.0, 0.0, 0.0); - - gridBuilder->writeGridsToVtk("F:/Work/Computations/NagelSchreckenberg/ExampleGrid"); - - SimulationFileWriter::write("F:/Work/Computations/NagelSchreckenberg/grid/", gridBuilder, FILEFORMAT::BINARY); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - StreetPointFinder finder; - - finder.readStreets( "F:/Work/Computations/NagelSchreckenberg/ExampleStreets.txt" ); - - finder.writeVTK( "F:/Work/Computations/NagelSchreckenberg/ExampleStreets.vtk" ); - - finder.findIndicesLB( gridBuilder->getGrid(0) ); - - finder.writeConnectionVTK( "F:/Work/Computations/NagelSchreckenberg/ExampleStreetsConnection.vtk", gridBuilder->getGrid(0) ); - - finder.writeSimulationFile("F:/Work/Computations/NagelSchreckenberg/grid/", 1.0, gridBuilder->getNumberOfLevels(), 0); - - return 0; -} diff --git a/apps/gpu/LidDrivenCavity/CMakeLists.txt b/apps/gpu/LidDrivenCavity/CMakeLists.txt deleted file mode 100644 index 108ab3c676e1abf2466f0b7ca61dce2df7eee792..0000000000000000000000000000000000000000 --- a/apps/gpu/LidDrivenCavity/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ - - -PROJECT(LidDrivenCavity) - - -vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator VirtualFluids_GPU GksMeshAdapter GksGpu FILES LidDrivenCavity.cpp) diff --git a/apps/gpu/LidDrivenCavity/LidDrivenCavity.cpp b/apps/gpu/LidDrivenCavity/LidDrivenCavity.cpp deleted file mode 100644 index 7c1f51f3415e381692f82fcd4822a7b8ca4517f7..0000000000000000000000000000000000000000 --- a/apps/gpu/LidDrivenCavity/LidDrivenCavity.cpp +++ /dev/null @@ -1,370 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file LidDrivenCavity.cpp -//! \ingroup Applications -//! \author Martin Schoenherr, Stephan Lenz -//======================================================================================= -#define _USE_MATH_DEFINES -#include <math.h> -#include <string> -#include <sstream> -#include <iostream> -#include <stdexcept> -#include <fstream> -#include <exception> -#include <memory> - -////////////////////////////////////////////////////////////////////////// - -#include "Core/DataTypes.h" -#include "PointerDefinitions.h" -#include "Core/LbmOrGks.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -////////////////////////////////////////////////////////////////////////// - -#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/BoundaryConditions/Side.h" -#include "GridGenerator/grid/GridFactory.h" - -////////////////////////////////////////////////////////////////////////// - -#include "VirtualFluids_GPU/LBM/Simulation.h" -#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" -#include "VirtualFluids_GPU/DataStructureInitializer/GridProvider.h" -#include "VirtualFluids_GPU/Parameter/Parameter.h" -#include "VirtualFluids_GPU/Output/FileWriter.h" -#include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" -#include "VirtualFluids_GPU/Factories/BoundaryConditionFactory.h" - -////////////////////////////////////////////////////////////////////////// - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "GksGpu/DataBase/DataBase.h" -#include "GksGpu/Parameters/Parameters.h" -#include "GksGpu/Initializer/Initializer.h" - -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -#include "GksGpu/BoundaryConditions/IsothermalWall.h" - -#include "GksGpu/TimeStepping/NestedTimeStep.h" - -#include "GksGpu/Analyzer/CupsAnalyzer.h" -#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" - -#include "GksGpu/CudaUtility/CudaUtility.h" - -#include "GksGpu/Output/VtkWriter.h" - -////////////////////////////////////////////////////////////////////////// - -int main( int argc, char* argv[]) -{ - try - { - ////////////////////////////////////////////////////////////////////////// - // Simulation parameters - ////////////////////////////////////////////////////////////////////////// - std::string path("./output"); - std::string simulationName("LidDrivenCavity"); - - const real L = 1.0; - const real Re = 1000.0; - const real velocity = 1.0; - const real dt = 0.5e-3; - const uint nx = 64; - - const uint timeStepOut = 10000; - const uint timeStepEnd = 250000; - - // switch between LBM and GKS solver here - //LbmOrGks lbmOrGks = GKS; - LbmOrGks lbmOrGks = LBM; - - ////////////////////////////////////////////////////////////////////////// - // setup logger - ////////////////////////////////////////////////////////////////////////// - - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); - - ////////////////////////////////////////////////////////////////////////// - // setup gridGenerator - ////////////////////////////////////////////////////////////////////////// - - auto gridFactory = GridFactory::make(); - gridFactory->setGridStrategy(Device::CPU); - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - ////////////////////////////////////////////////////////////////////////// - // create grid - ////////////////////////////////////////////////////////////////////////// - - real dx = L / real(nx); - - gridBuilder->addCoarseGrid(-0.5 * L, -0.5 * L, -0.5 * L, - 0.5 * L, 0.5 * L, 0.5 * L, dx); - - gridBuilder->setPeriodicBoundaryCondition(false, false, false); - - gridBuilder->buildGrids(lbmOrGks, false); - - ////////////////////////////////////////////////////////////////////////// - // branch between LBM and GKS - ////////////////////////////////////////////////////////////////////////// - - if( lbmOrGks == LBM ) - { - SPtr<Parameter> para = Parameter::make(); - BoundaryConditionFactory bcFactory = BoundaryConditionFactory(); - - ////////////////////////////////////////////////////////////////////////// - // compute parameters in lattice units - ////////////////////////////////////////////////////////////////////////// - - const real velocityLB = velocity * dt / dx; // LB units - - const real vx = velocityLB / sqrt(2.0); // LB units - const real vy = velocityLB / sqrt(2.0); // LB units - - const real viscosityLB = nx * velocityLB / Re; // LB units - - *logging::out << logging::Logger::INFO_HIGH << "velocity [dx/dt] = " << velocityLB << " \n"; - *logging::out << logging::Logger::INFO_HIGH << "viscosity [dx^2/dt] = " << viscosityLB << "\n"; - - ////////////////////////////////////////////////////////////////////////// - // set parameters - ////////////////////////////////////////////////////////////////////////// - - para->setOutputPath( path ); - para->setOutputPrefix( simulationName ); - - para->setPrintFiles(true); - - para->setVelocityLB(velocityLB); - para->setViscosityLB(viscosityLB); - - para->setVelocityRatio(velocity / velocityLB); - - para->setTimestepOut( timeStepOut ); - para->setTimestepEnd( timeStepEnd ); - - ////////////////////////////////////////////////////////////////////////// - // set boundary conditions - ////////////////////////////////////////////////////////////////////////// - - gridBuilder->setNoSlipBoundaryCondition (SideType::PX); - gridBuilder->setNoSlipBoundaryCondition (SideType::MX); - gridBuilder->setNoSlipBoundaryCondition (SideType::PY); - gridBuilder->setNoSlipBoundaryCondition (SideType::MY); - gridBuilder->setVelocityBoundaryCondition(SideType::PZ, vx, vy, 0.0); - gridBuilder->setNoSlipBoundaryCondition (SideType::MZ); - - bcFactory.setNoSlipBoundaryCondition(BoundaryConditionFactory::NoSlipBC::NoSlipBounceBack); - bcFactory.setVelocityBoundaryCondition(BoundaryConditionFactory::VelocityBC::VelocitySimpleBounceBackCompressible); - - ////////////////////////////////////////////////////////////////////////// - // set copy mesh to simulation - ////////////////////////////////////////////////////////////////////////// - - SPtr<CudaMemoryManager> cudaMemoryManager = CudaMemoryManager::make(para); - - SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager, communicator); - - ////////////////////////////////////////////////////////////////////////// - // run simulation - ////////////////////////////////////////////////////////////////////////// - - Simulation sim; - SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); - sim.init(para, gridGenerator, fileWriter, cudaMemoryManager); - sim.run(); - sim.free(); - } - else - { - CudaUtility::setCudaDevice(0); - - Parameters parameters; - - ////////////////////////////////////////////////////////////////////////// - // compute remaining parameters - ////////////////////////////////////////////////////////////////////////// - - const real vx = velocity / sqrt(2.0); - const real vy = velocity / sqrt(2.0); - - parameters.K = 2.0; - parameters.Pr = 1.0; - - const real Ma = 0.1; - - real rho = 1.0; - - real cs = velocity / Ma; - real lambda = c1o2 * ( ( parameters.K + 5.0 ) / ( parameters.K + 3.0 ) ) / ( cs * cs ); - - const real mu = velocity * L * rho / Re; - - *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " m^2/s\n"; - - *logging::out << logging::Logger::INFO_HIGH << "CFL = " << dt * ( velocity + cs ) / dx << "\n"; - - ////////////////////////////////////////////////////////////////////////// - // set parameters - ////////////////////////////////////////////////////////////////////////// - - parameters.mu = mu; - - parameters.dt = dt; - parameters.dx = dx; - - parameters.lambdaRef = lambda; - - ////////////////////////////////////////////////////////////////////////// - // set copy mesh to simulation - ////////////////////////////////////////////////////////////////////////// - - GksMeshAdapter meshAdapter( gridBuilder ); - - meshAdapter.inputGrid(); - - auto dataBase = std::make_shared<DataBase>( "GPU" ); - - ////////////////////////////////////////////////////////////////////////// - // set boundary conditions - ////////////////////////////////////////////////////////////////////////// - - SPtr<BoundaryCondition> bcLid = std::make_shared<IsothermalWall>( dataBase, Vec3( vx, vy, 0.0 ), lambda, false ); - SPtr<BoundaryCondition> bcWall = std::make_shared<IsothermalWall>( dataBase, Vec3( 0.0, 0.0, 0.0 ), lambda, false ); - - bcLid->findBoundaryCells ( meshAdapter, false, [&](Vec3 center){ return center.z > 0.5 && - center.x > -0.5 && - center.x < 0.5 && - center.y > -0.5 && - center.y < 0.5; } ); - - bcWall->findBoundaryCells( meshAdapter, true, [&](Vec3 center){ return center.x < -0.5 || - center.x > 0.5 || - center.y < -0.5 || - center.y > 0.5 || - center.z < -0.5; } ); - - dataBase->boundaryConditions.push_back( bcLid ); - dataBase->boundaryConditions.push_back( bcWall ); - - ////////////////////////////////////////////////////////////////////////// - // set initial condition and upload mesh and initial condition to GPGPU - ////////////////////////////////////////////////////////////////////////// - - dataBase->setMesh( meshAdapter ); - - Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables { - - return toConservedVariables( PrimitiveVariables( rho, 0.0, 0.0, 0.0, lambda ), parameters.K ); - }); - - dataBase->copyDataHostToDevice(); - - Initializer::initializeDataUpdate(dataBase); - - VtkWriter::write( dataBase, parameters, path + "/" + simulationName + "_0" ); - - ////////////////////////////////////////////////////////////////////////// - // set analyzers - ////////////////////////////////////////////////////////////////////////// - - CupsAnalyzer cupsAnalyzer( dataBase, false, 60.0, true, 10000 ); - - ConvergenceAnalyzer convergenceAnalyzer( dataBase, 10000 ); - - cupsAnalyzer.start(); - - ////////////////////////////////////////////////////////////////////////// - // run simulation - ////////////////////////////////////////////////////////////////////////// - - for( uint iter = 1; iter <= timeStepEnd; iter++ ) - { - TimeStepping::nestedTimeStep(dataBase, parameters, 0); - - if( iter % timeStepOut == 0 ) - { - dataBase->copyDataDeviceToHost(); - - VtkWriter::write( dataBase, parameters, path + "/" + simulationName + "_" + std::to_string( iter ) ); - } - - int crashCellIndex = dataBase->getCrashCellIndex(); - if( crashCellIndex >= 0 ) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Simulation crashed at CellIndex = " << crashCellIndex << "\n"; - dataBase->copyDataDeviceToHost(); - VtkWriter::write( dataBase, parameters, path + "/" + simulationName + "_" + std::to_string( iter ) ); - - break; - } - - dataBase->getCrashCellIndex(); - - cupsAnalyzer.run( iter, parameters.dt ); - - convergenceAnalyzer.run( iter ); - } - } - } - catch (const std::bad_alloc e) - { - - *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; - } - catch (const std::exception& e) - { - - *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; - } - catch (std::string& s) - { - - *logging::out << logging::Logger::LOGGER_ERROR << s << "\n"; - } - catch (...) - { - *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; - } - - return 0; -} diff --git a/apps/gpu/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.cpp b/apps/gpu/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.cpp index 5a469b44ab21c9a0fc3850baf9f1a82c1f3a0314..580aab90988215ef010de23b47946158e69fb88e 100644 --- a/apps/gpu/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.cpp +++ b/apps/gpu/tests/NumericalTestPostProcessing/Utilities/LogFileReader/LogFileReader.cpp @@ -12,7 +12,7 @@ #include "Utilities/LogFileData/LogFileDataImp.h" #include <basics/config/ConfigurationFile.h> -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" #include "Utilities/AlmostEquals.h" diff --git a/apps/gpu/tests/NumericalTestPostProcessing/Utilities/PostProcessingConfigFileReader/PostProcessingConfigFileReaderImp.cpp b/apps/gpu/tests/NumericalTestPostProcessing/Utilities/PostProcessingConfigFileReader/PostProcessingConfigFileReaderImp.cpp index 7bff82d2118e449ea19a1cfd56ff261b730ff0d4..6c52eeb93f3e556ebfad4e993eb56c63c95b56fd 100644 --- a/apps/gpu/tests/NumericalTestPostProcessing/Utilities/PostProcessingConfigFileReader/PostProcessingConfigFileReaderImp.cpp +++ b/apps/gpu/tests/NumericalTestPostProcessing/Utilities/PostProcessingConfigFileReader/PostProcessingConfigFileReaderImp.cpp @@ -1,7 +1,7 @@ #include "PostProcessingConfigFileReaderImp.h" #include <basics/config/ConfigurationFile.h> -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" #include "Utilities/PostProcessingConfigData/PostProcessingConfigDataImp.h" diff --git a/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.cpp b/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.cpp index 26d4045fe4b14cf9ffc5dea16815d70c716de000..0d0dc94a911acb7c3f3f995922e5ce34ddffa303 100644 --- a/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.cpp +++ b/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.cpp @@ -1,7 +1,7 @@ #include "ConfigFileReaderNT.h" #include <basics/config/ConfigurationFile.h> -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" #include <memory> #include <fstream> @@ -391,17 +391,8 @@ int calcNumberOfSimulations(ConfigFilePtr input, ConfigDataPtr configData) return counter; } -ConfigDataPtr vf::gpu::tests::readConfigFile(const std::string aFilePath) +ConfigDataPtr vf::gpu::tests::readConfigFile(const std::string aFilePath, const std::string &pathNumericalTests) { - // If PATH_NUMERICAL_TESTS is not defined, the grid definitions for the tests needs to be placed in the project root - // directories. -#ifdef PATH_NUMERICAL_TESTS - auto pathNumericalTests = TOSTRING(PATH_NUMERICAL_TESTS) + std::string("/"); -#else - auto pathNumericalTests = TOSTRING(SOURCE_ROOT) + std::string("/"); -#endif - std::cout << pathNumericalTests << "\n"; - auto configData = std::make_shared<ConfigDataStruct>(); auto input = std::make_shared<vf::basics::ConfigurationFile>(); input->load(aFilePath); @@ -409,6 +400,8 @@ ConfigDataPtr vf::gpu::tests::readConfigFile(const std::string aFilePath) if (!checkConfigFile(input)) exit(1); + std::cout << pathNumericalTests << "\n"; + configData->viscosity = StringUtil::toDoubleVector(input->getValue<std::string>("Viscosity")); configData->kernelsToTest = readKernelList(input); configData->writeAnalyticalToVTK = StringUtil::toBool(input->getValue<std::string>("WriteAnalyResultsToVTK")); diff --git a/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.h b/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.h index cd4ad56b4c23a8a973385839aa1b0736e1d2fda1..381e2d980ad3808d18c1f7f3b2ffff5bede6f664 100644 --- a/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.h +++ b/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.h @@ -14,6 +14,6 @@ class ConfigurationFile; namespace vf::gpu::tests { - std::shared_ptr<ConfigDataStruct> readConfigFile(const std::string aFilePath); + std::shared_ptr<ConfigDataStruct> readConfigFile(const std::string aFilePath, const std::string &pathNumericalTests); } #endif \ No newline at end of file diff --git a/apps/gpu/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.cpp b/apps/gpu/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.cpp index b9b4dd3a8d13ddcce87c555312c0d0a422de5a05..126ff07a31c4f434cc82b4bb8b7e1d944b22cae1 100644 --- a/apps/gpu/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.cpp +++ b/apps/gpu/tests/NumericalTests/Utilities/DataWriter/AnalyticalResults2DToVTKWriter/AnalyticalResults2DToVTKWriterImp.cpp @@ -5,7 +5,7 @@ #include <sstream> #include <stdio.h> -#include <Core/StringUtilities/StringUtil.h> +#include <StringUtilities/StringUtil.h> #include "Parameter/Parameter.h" diff --git a/apps/gpu/tests/NumericalTests/Utilities/NumericalTestGridReader/NumericalTestGridReader.cpp b/apps/gpu/tests/NumericalTests/Utilities/NumericalTestGridReader/NumericalTestGridReader.cpp index 97ccf92dc72e253d5f38f88353ba564320e8fd65..cdf82c32ef982dec19df49ae347e5601017a538b 100644 --- a/apps/gpu/tests/NumericalTests/Utilities/NumericalTestGridReader/NumericalTestGridReader.cpp +++ b/apps/gpu/tests/NumericalTests/Utilities/NumericalTestGridReader/NumericalTestGridReader.cpp @@ -13,10 +13,10 @@ std::shared_ptr<NumericalTestGridReader> NumericalTestGridReader::getNewInstance return std::shared_ptr<NumericalTestGridReader>(new NumericalTestGridReader(para, initialCondition, cudaManager)); } -void NumericalTestGridReader::setInitalNodeValues(const int numberOfNodes, const int level) const +void NumericalTestGridReader::setInitalNodeValues(uint numberOfNodes, int level) const { initialCondition->init(level); - for (int j = 0; j <= numberOfNodes; j++){ + for (uint j = 0; j <= numberOfNodes; j++){ para->getParH(level)->velocityX[j] = initialCondition->getInitVX(j, level); para->getParH(level)->velocityY[j] = initialCondition->getInitVY(j, level); para->getParH(level)->velocityZ[j] = initialCondition->getInitVZ(j, level); diff --git a/apps/gpu/tests/NumericalTests/Utilities/NumericalTestGridReader/NumericalTestGridReader.h b/apps/gpu/tests/NumericalTests/Utilities/NumericalTestGridReader/NumericalTestGridReader.h index b766e4bab7e0f2667d35f416b9130bea657c823c..84f5d72705db06349f0b31a42eb99ded45bb0e1d 100644 --- a/apps/gpu/tests/NumericalTests/Utilities/NumericalTestGridReader/NumericalTestGridReader.h +++ b/apps/gpu/tests/NumericalTests/Utilities/NumericalTestGridReader/NumericalTestGridReader.h @@ -13,8 +13,8 @@ public: static std::shared_ptr<NumericalTestGridReader> getNewInstance(std::shared_ptr<Parameter> para, std::shared_ptr<InitialCondition> initialCondition, std::shared_ptr<CudaMemoryManager> cudaManager); protected: - void setInitalNodeValues(const int numberOfNodes, const int level) const; - + virtual void setInitalNodeValues(uint numberOfNodes, int level) const override; + private: NumericalTestGridReader(std::shared_ptr<Parameter> para, std::shared_ptr<InitialCondition> initialCondition, std::shared_ptr<CudaMemoryManager> cudaManager); diff --git a/apps/gpu/tests/NumericalTests/main.cpp b/apps/gpu/tests/NumericalTests/main.cpp index fda9d14a7b752eab2585b300ee6aef606437913e..017c6551ae57f47c14332683aecb6650fb10a5f0 100644 --- a/apps/gpu/tests/NumericalTests/main.cpp +++ b/apps/gpu/tests/NumericalTests/main.cpp @@ -12,9 +12,9 @@ #include <fstream> #include <iostream> -static TestSuiteResult startNumericalTests(const std::string &configFile) +static TestSuiteResult startNumericalTests(const std::string &configFile, const std::string &pathNumericalTests) { - auto configData = vf::gpu::tests::readConfigFile(configFile); + auto configData = vf::gpu::tests::readConfigFile(configFile, pathNumericalTests); std::shared_ptr<NumericalTestFactoryImp> numericalTestFactory = NumericalTestFactoryImp::getNewInstance(configData); @@ -33,10 +33,11 @@ int main(int argc, char **argv) auto tests_passed = TestSuiteResult::FAILED; - if (argc > 1) - tests_passed = startNumericalTests(argv[1]); + if (argc == 3) { + tests_passed = startNumericalTests(argv[1], argv[2]); + } else - std::cout << "Configuration file must be set!: lbmgm <config file>" << std::endl << std::flush; + std::cout << "Configuration file must be set!: lbmgm <config file> <path to grid data>" << std::endl << std::flush; MPI_Finalize(); diff --git a/gpu.cmake b/gpu.cmake index 5b175ca2a5fe7d289bd948e905ada612413333d2..6bdbf656326c4d733ec2c5b5d08751b3055a7b00 100644 --- a/gpu.cmake +++ b/gpu.cmake @@ -1,73 +1,30 @@ -IF( BUILD_VF_GKS ) - # only use this with device of CC larger than 6.0 - set(CMAKE_CUDA_FLAGS "-Xptxas=\"-v\"" CACHE STRING "" FORCE) - set(CMAKE_CUDA_ARCHITECTURES 60) -ENDIF() - -set(CMAKE_CUDA_FLAGS_DEBUG " -G" CACHE STRING "" FORCE) - - -########################################################################################################################## -### Subdirectories ### -########################################################################################################################## - ############################################################# ### Core ### ############################################################# add_subdirectory(src/gpu/GridGenerator) -#add_subdirectory(3rdParty/metis/metis-5.1.0) +add_subdirectory(src/gpu/VirtualFluids_GPU) -############################################################# -### Virtual Fluids GPU ### -############################################################# - -IF (BUILD_VF_GPU) - add_subdirectory(src/gpu/VirtualFluids_GPU) - - add_subdirectory(apps/gpu/LBM/DrivenCavity) - add_subdirectory(apps/gpu/LBM/SphereGPU) - add_subdirectory(apps/gpu/LBM/BoundaryLayer) -ELSE() - MESSAGE( STATUS "exclude Virtual Fluids GPU." ) -ENDIF() +if(BUILD_VF_ALL_SAMPLES) + list(APPEND USER_APPS + "apps/gpu/LBM/ActuatorLine" + "apps/gpu/LBM/SphereScaling" + "apps/gpu/LBM/TGV_3D") +endif() ############################################################# -### Virtual Fluids GKS ### +### Apps ### ############################################################# -IF (BUILD_VF_GKS) - add_subdirectory(src/gpu/GksMeshAdapter) - add_subdirectory(src/gpu/GksVtkAdapter) - - add_subdirectory(src/gpu/GksGpu) - - add_subdirectory(apps/gpu/GKS/Flame7cm) -ELSE() - MESSAGE( STATUS "exclude Virtual Fluids GKS." ) -ENDIF() - -############################################################# -### JSONCPP ### -############################################################# -IF (NOT BUILD_JSONCPP) - MESSAGE( STATUS "Build Input Project without JsonCpp." ) -ELSE() - add_subdirectory(3rdParty/jsoncpp) - add_definitions(-DBUILD_JSONCPP) -ENDIF() +add_subdirectory(apps/gpu/LBM/DrivenCavity) +add_subdirectory(apps/gpu/LBM/SphereGPU) +add_subdirectory(apps/gpu/LBM/BoundaryLayer) ############################################################# ### Numeric Tests ### ############################################################# if(BUILD_NUMERIC_TESTS) - - # PATH_NUMERICAL_TESTS can be passed to cmake e.g. cmake .. -DPATH_NUMERICAL_TESTS=/data/ - if(PATH_NUMERICAL_TESTS) - LIST(APPEND VF_COMPILER_DEFINITION "PATH_NUMERICAL_TESTS=${PATH_NUMERICAL_TESTS}") - endif() - if(NOT BUILD_VF_UNIT_TESTS) # in this case googletest is already included. add_subdirectory(${VF_THIRD_DIR}/googletest) endif() @@ -76,12 +33,3 @@ if(BUILD_NUMERIC_TESTS) add_subdirectory(apps/gpu/tests/NumericalTests) add_subdirectory(apps/gpu/tests/NumericalTestPostProcessing) endif() - -############################################################# -### Annas Traffic Sim ### -############################################################# - -if(BUILD_VF_TRAFFIC) - add_subdirectory(src/gpu/Traffic) - add_subdirectory(apps/gpu/LBM/TrafficTest) -endif() diff --git a/pythonbindings/CMakeLists.txt b/pythonbindings/CMakeLists.txt index 815a4b59cf6c3e4e5ac4a7a72a5bd4e374d64c96..037b68baf53d5da8a1ccd20155cb0e7be483176b 100644 --- a/pythonbindings/CMakeLists.txt +++ b/pythonbindings/CMakeLists.txt @@ -7,12 +7,13 @@ endif() project(VirtualFluidsPython LANGUAGES ${PYFLUIDS_LANGUAGES}) pybind11_add_module(python_bindings MODULE src/VirtualFluids.cpp) +target_compile_definitions(python_bindings PUBLIC VF_DOUBLE_ACCURACY) set_target_properties( python_bindings PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/pythonbindings/pyfluids OUTPUT_NAME "bindings") -target_link_libraries(python_bindings PRIVATE basics logger mpi) +target_link_libraries(python_bindings PRIVATE basics logger mpi lbm) IF(BUILD_VF_GPU) set_source_files_properties(src/VirtualFluids.cpp PROPERTIES LANGUAGE CUDA) @@ -20,12 +21,12 @@ IF(BUILD_VF_GPU) target_include_directories(python_bindings PRIVATE ${VF_THIRD_DIR}/cuda_samples/) target_compile_definitions(python_bindings PRIVATE VF_GPU_PYTHONBINDINGS) - target_link_libraries(python_bindings PRIVATE GridGenerator VirtualFluids_GPU lbm) + target_link_libraries(python_bindings PRIVATE GridGenerator VirtualFluids_GPU) ENDIF() IF(BUILD_VF_CPU) target_compile_definitions(python_bindings PRIVATE VF_METIS VF_MPI VF_CPU_PYTHONBINDINGS) - target_link_libraries(python_bindings PRIVATE simulationconfig VirtualFluidsCore muparser lbm) + target_link_libraries(python_bindings PRIVATE simulationconfig VirtualFluidsCore muparser) # include bindings for muparsers pybind11_add_module(pymuparser MODULE src/muParser.cpp) diff --git a/pythonbindings/pyfluids-stubs/bindings/basics/__init__.pyi b/pythonbindings/pyfluids-stubs/bindings/basics/__init__.pyi index a41b7934ca706dc0db5bd6188fee3150456e0cd9..a646f7e590e2aba91ab1c367f75b8c6ebe8f79ae 100644 --- a/pythonbindings/pyfluids-stubs/bindings/basics/__init__.pyi +++ b/pythonbindings/pyfluids-stubs/bindings/basics/__init__.pyi @@ -64,19 +64,3 @@ class ConfigurationFile: @overload def get_uint_value(self, key: str, default_value: int) -> int: ... def load(self, file: str) -> bool: ... - -class LbmOrGks: - __members__: ClassVar[dict] = ... # read-only - GKS: ClassVar[LbmOrGks] = ... - LBM: ClassVar[LbmOrGks] = ... - __entries: ClassVar[dict] = ... - def __init__(self, arg0: int) -> None: ... - def __eq__(self, arg0: object) -> bool: ... - def __getstate__(self) -> int: ... - def __hash__(self) -> int: ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... - def __ne__(self, arg0: object) -> bool: ... - def __setstate__(self, arg0: int) -> None: ... - @property - def name(self) -> str: ... diff --git a/pythonbindings/pyfluids-stubs/bindings/basics/logger.pyi b/pythonbindings/pyfluids-stubs/bindings/basics/logger.pyi deleted file mode 100644 index 43938ff7646efd3c596ae29971cce39fed865fa6..0000000000000000000000000000000000000000 --- a/pythonbindings/pyfluids-stubs/bindings/basics/logger.pyi +++ /dev/null @@ -1,83 +0,0 @@ -r""" -======================================================================================= - ____ ____ __ ______ __________ __ __ __ __ - \ \ | | | | | _ \ |___ ___| | | | | / \ | | - \ \ | | | | | |_) | | | | | | | / \ | | - \ \ | | | | | _ / | | | | | | / /\ \ | | - \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ - \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| - \ \ | | ________________________________________________________________ - \ \ | | | ______________________________________________________________| - \ \| | | | __ __ __ __ ______ _______ - \ | | |_____ | | | | | | | | | _ \ / _____) - \ | | _____| | | | | | | | | | | \ \ \_______ - \ | | | | |_____ | \_/ | | | | |_/ / _____ | - \ _____| |__| |________| \_______/ |__| |______/ (_______/ - - This file is part of VirtualFluids. VirtualFluids is free software: you can - redistribute it and/or modify it under the terms of the GNU General Public - License as published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - VirtualFluids is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. - -! \file logger.pyi -! \ingroup basics -! \author Henry Korb -======================================================================================= -""" -from typing import Any, ClassVar - -log: None - -class Level: - __members__: ClassVar[dict] = ... # read-only - INFO_HIGH: ClassVar[Level] = ... - INFO_INTERMEDIATE: ClassVar[Level] = ... - INFO_LOW: ClassVar[Level] = ... - LOGGER_ERROR: ClassVar[Level] = ... - WARNING: ClassVar[Level] = ... - __entries: ClassVar[dict] = ... - def __init__(self, arg0: int) -> None: ... - def __eq__(self, arg0: object) -> bool: ... - def __getstate__(self) -> int: ... - def __hash__(self) -> int: ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... - def __ne__(self, arg0: object) -> bool: ... - def __setstate__(self, arg0: int) -> None: ... - @property - def name(self) -> str: ... - -class Logger: - def __init__(self, *args, **kwargs) -> None: ... - @staticmethod - def add_stdout() -> None: ... - @staticmethod - def enable_printed_rank_numbers(print: bool) -> None: ... - @staticmethod - def set_debug_level(level: int) -> None: ... - @staticmethod - def time_stamp(time_stemp: TimeStamp) -> None: ... - -class TimeStamp: - __members__: ClassVar[dict] = ... # read-only - DISABLE: ClassVar[TimeStamp] = ... - ENABLE: ClassVar[TimeStamp] = ... - __entries: ClassVar[dict] = ... - def __init__(self, arg0: int) -> None: ... - def __eq__(self, arg0: object) -> bool: ... - def __getstate__(self) -> int: ... - def __hash__(self) -> int: ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... - def __ne__(self, arg0: object) -> bool: ... - def __setstate__(self, arg0: int) -> None: ... - @property - def name(self) -> str: ... diff --git a/pythonbindings/pyfluids-stubs/bindings/gpu/grid_generator.pyi b/pythonbindings/pyfluids-stubs/bindings/gpu/grid_generator.pyi index 514dc5053e9574b452d80f61eb3d4e1ebb0f4396..433a20e7efe472bd791b1d2a0f43859676e8fcf0 100644 --- a/pythonbindings/pyfluids-stubs/bindings/gpu/grid_generator.pyi +++ b/pythonbindings/pyfluids-stubs/bindings/gpu/grid_generator.pyi @@ -81,7 +81,7 @@ class MultipleGridBuilder(LevelGridBuilder): def add_grid(self, grid_shape: Object) -> None: ... @overload def add_grid(self, grid_shape: Object, level_fine: int) -> None: ... - def build_grids(self, lbm_or_gks: pyfluids.bindings.basics.LbmOrGks, enable_thin_walls: bool) -> None: ... + def build_grids(self, enable_thin_walls: bool) -> None: ... def get_number_of_levels(self) -> int: ... @staticmethod def make_shared(grid_factory: GridFactory) -> MultipleGridBuilder: ... diff --git a/pythonbindings/src/VirtualFluids.cpp b/pythonbindings/src/VirtualFluids.cpp index 20e5012e0af325440e502c704d6f372100306ab1..91682b79e8125a7513565b28e2e22e74e0b2dac1 100644 --- a/pythonbindings/src/VirtualFluids.cpp +++ b/pythonbindings/src/VirtualFluids.cpp @@ -49,7 +49,8 @@ namespace py_bindings PYBIND11_MODULE(bindings, m) { - py::add_ostream_redirect(m, "ostream_redirect"); + // because we do not use the old logger (src/basics/logger) anymore and cout is not passed anymore to the old logger, we probably do not need this anymore + // pybind11::add_ostream_redirect(m, "ostream_redirect"); basics::makeModule(m); lbm::makeModule(m); logging::makeModule(m); @@ -60,4 +61,4 @@ namespace py_bindings cpu::makeModule(m); #endif } -} \ No newline at end of file +} diff --git a/pythonbindings/src/basics/basics.cpp b/pythonbindings/src/basics/basics.cpp index e67dfb05308511c8bf79d7e860299f062f317194..0b294b7a8de2f4f396dac418b0544b5f99ecec3d 100644 --- a/pythonbindings/src/basics/basics.cpp +++ b/pythonbindings/src/basics/basics.cpp @@ -31,9 +31,7 @@ //! \author Henry Korb //======================================================================================= #include <pybind11/pybind11.h> -#include "submodules/logger.cpp" #include "submodules/configuration_file.cpp" -#include "submodules/lbm_or_gks.cpp" namespace basics { @@ -43,10 +41,8 @@ namespace basics { py::module basicsModule = parentModule.def_submodule("basics"); - logger::makeModule(basicsModule); configuration::makeModule(basicsModule); - lbmOrGks::makeModule(basicsModule); - + return basicsModule; } } \ No newline at end of file diff --git a/pythonbindings/src/basics/submodules/lbm_or_gks.cpp b/pythonbindings/src/basics/submodules/lbm_or_gks.cpp deleted file mode 100644 index d20cf2d1f631f6d36a80c36f1fb6c9c59d192090..0000000000000000000000000000000000000000 --- a/pythonbindings/src/basics/submodules/lbm_or_gks.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file lbm_or_gks.cpp -//! \ingroup submodules -//! \author Henry Korb -//======================================================================================= -#include <pybind11/pybind11.h> -#include "basics/Core/LbmOrGks.h" - -namespace lbmOrGks -{ - namespace py = pybind11; - - void makeModule(py::module_ &parentModule) - { - py::enum_<LbmOrGks>(parentModule, "LbmOrGks") - .value("LBM", LbmOrGks::LBM) - .value("GKS", LbmOrGks::GKS); - } -} \ No newline at end of file diff --git a/pythonbindings/src/basics/submodules/logger.cpp b/pythonbindings/src/basics/submodules/logger.cpp deleted file mode 100644 index fa7e00e4dca06581b7a14d2bcf2628ed6af60001..0000000000000000000000000000000000000000 --- a/pythonbindings/src/basics/submodules/logger.cpp +++ /dev/null @@ -1,68 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file logger.cpp -//! \ingroup submodules -//! \author Henry Korb -//======================================================================================= -#include <pybind11/pybind11.h> -#include <pybind11/iostream.h> -#include <basics/Core/Logger/Logger.h> -#include <basics/Core/Logger/implementations/LoggerImp.h> - -namespace logger -{ - namespace py = pybind11; - - py::module makeModule(py::module_ &parentModule) - { - py::module loggerModule = parentModule.def_submodule("logger"); - - py::class_<logging::Logger>(loggerModule, "Logger") - .def_static("add_stdout", [](){ - logging::Logger::addStream(&std::cout); - }) - .def_static("set_debug_level", &logging::Logger::setDebugLevel) - .def_static("time_stamp", &logging::Logger::timeStamp, py::arg("time_stamp")) - .def_static("enable_printed_rank_numbers", &logging::Logger::enablePrintedRankNumbers, py::arg("print")); - - loggerModule.attr("log") = logging::out; - py::enum_<logging::Logger::Level>(loggerModule, "Level") - .value("INFO_LOW", logging::Logger::Level::INFO_LOW) - .value("INFO_INTERMEDIATE", logging::Logger::Level::INFO_INTERMEDIATE) - .value("INFO_HIGH", logging::Logger::Level::INFO_HIGH) - .value("WARNING", logging::Logger::Level::WARNING) - .value("LOGGER_ERROR", logging::Logger::Level::LOGGER_ERROR); - - py::enum_<logging::Logger::TimeStamp>(loggerModule, "TimeStamp") - .value("ENABLE", logging::Logger::TimeStamp::ENABLE) - .value("DISABLE", logging::Logger::TimeStamp::DISABLE); - - return loggerModule; - } -} \ No newline at end of file diff --git a/pythonbindings/src/cpu/submodules/boundaryconditions.cpp b/pythonbindings/src/cpu/submodules/boundaryconditions.cpp index ac9ec8605dec51e8374c850b1c1b58314674c426..d7cd0b578a52c369923db0e31b01200f0389c9eb 100644 --- a/pythonbindings/src/cpu/submodules/boundaryconditions.cpp +++ b/pythonbindings/src/cpu/submodules/boundaryconditions.cpp @@ -77,14 +77,14 @@ namespace boundaryconditions bc_class<VelocityBCAdapter, VelocityBCAlgorithm>(bcModule, "VelocityBoundaryCondition") .def(py::init()) - .def(py::init<bool &, bool &, bool &, mu::Parser &, double &, double &>(), + .def(py::init<bool &, bool &, bool &, mu::Parser &, real &, real &>(), "vx1"_a, "vx2"_a, "vx3"_a, "function"_a, "start_time"_a, "end_time"_a) - .def(py::init<bool &, bool &, bool &, mu::Parser &, mu::Parser &, mu::Parser &, double &, double &>(), + .def(py::init<bool &, bool &, bool &, mu::Parser &, mu::Parser &, mu::Parser &, real &, real &>(), "vx1"_a, "vx2"_a, "vx3"_a, "function_vx1"_a, "function_vx2"_a, "function_vx2"_a, "start_time"_a, "end_time"_a) - .def(py::init<double &, double &, double &, double &, double &, double &, double &, double &, double &>(), + .def(py::init<real &, real &, real &, real &, real &, real &, real &, real &, real &>(), "vx1"_a, "vx1_start_time"_a, "vx1_end_time"_a, "vx2"_a, "vx2_start_time"_a, "vx2_end_time"_a, "vx3"_a, "vx3_start_time"_a, "vx3_end_time"_a); diff --git a/pythonbindings/src/cpu/submodules/kernel.cpp b/pythonbindings/src/cpu/submodules/kernel.cpp index b00d86579540a299e4bf3ed47bc09d4386f420a2..2f2effa7ef28600e67fb2e2954409a0963df1f37 100644 --- a/pythonbindings/src/cpu/submodules/kernel.cpp +++ b/pythonbindings/src/cpu/submodules/kernel.cpp @@ -55,7 +55,7 @@ namespace kernel .def_readwrite("forcing_in_x1", &LBMKernelConfiguration::forcingX1) .def_readwrite("forcing_in_x2", &LBMKernelConfiguration::forcingX2) .def_readwrite("forcing_in_x3", &LBMKernelConfiguration::forcingX3) - .def("set_forcing", [](LBMKernelConfiguration &kernelConfig, double x1, double x2, double x3) + .def("set_forcing", [](LBMKernelConfiguration &kernelConfig, real x1, real x2, real x3) { kernelConfig.forcingX1 = x1; kernelConfig.forcingX2 = x2; diff --git a/pythonbindings/src/gpu/submodules/grid_generator.cpp b/pythonbindings/src/gpu/submodules/grid_generator.cpp index 3e9fb5655e26ffa6053a205da5a3e3f0f2ecd49f..59d0bd5708b11f246664d1e8c7ee198f986d80c1 100644 --- a/pythonbindings/src/gpu/submodules/grid_generator.cpp +++ b/pythonbindings/src/gpu/submodules/grid_generator.cpp @@ -102,7 +102,7 @@ namespace grid_generator .def("add_geometry", py::overload_cast<Object*>(&MultipleGridBuilder::addGeometry), py::arg("solid_object")) .def("add_geometry", py::overload_cast<Object*, uint>(&MultipleGridBuilder::addGeometry), py::arg("solid_object"), py::arg("level")) .def("get_number_of_levels", &MultipleGridBuilder::getNumberOfLevels) - .def("build_grids", &MultipleGridBuilder::buildGrids, py::arg("lbm_or_gks"), py::arg("enable_thin_walls")) + .def("build_grids", &MultipleGridBuilder::buildGrids, py::arg("enable_thin_walls")) .def("set_subdomain_box", &MultipleGridBuilder::setSubDomainBox, py::arg("bounding_box")) .def("find_communication_indices", &MultipleGridBuilder::findCommunicationIndices) .def("set_communication_process", &MultipleGridBuilder::setCommunicationProcess) diff --git a/pythonbindings/src/gpu/submodules/parameter.cpp b/pythonbindings/src/gpu/submodules/parameter.cpp index a7c42223e6a5bfa3caa89c0879e4133fc4123ad0..e1d8a1f63eb877ec7ae42beb858b0b7cb9253815 100644 --- a/pythonbindings/src/gpu/submodules/parameter.cpp +++ b/pythonbindings/src/gpu/submodules/parameter.cpp @@ -34,12 +34,12 @@ #include <pybind11/functional.h> #include <pybind11/stl.h> #include <gpu/VirtualFluids_GPU/Parameter/Parameter.h> -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include <basics/config/ConfigurationFile.h> #include <gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; namespace parameter { diff --git a/regression-tests/README.md b/regression-tests/README.md new file mode 100644 index 0000000000000000000000000000000000000000..471ce331cc90dbfcfa323011419f201031bc48bd --- /dev/null +++ b/regression-tests/README.md @@ -0,0 +1,3 @@ +# Adding Regression Tests. + +How to add regression test is described in [this document](https://git.rz.tu-bs.de/irmb/virtualfluids/-/wikis/Regression-Tests). \ No newline at end of file diff --git a/regression-tests/__regression_test_executer.sh b/regression-tests/__regression_test_executer.sh new file mode 100644 index 0000000000000000000000000000000000000000..2541619299110bfcb872e48035c6e5e9fb8d7672 --- /dev/null +++ b/regression-tests/__regression_test_executer.sh @@ -0,0 +1,29 @@ + + +download_reference_data () { + rm -rf reference_data && mkdir -p reference_data + git clone --depth 1 --filter=blob:none --sparse https://github.com/irmb/test_data reference_data + cd reference_data + git sparse-checkout add $1 + cd .. +} + + +# run regression test - arguments: +# 1. REFERENCE_DATA_DIR - to download the reference data and compare against +# 2. CMAKE_FLAGS - cmake flags for the build of VirtualFluids +# 3. APPLICATION - the application to be executed +# 4. RESULT_DATA_DIR - the path to the produced data to be compared +run_regression_test () { + download_reference_data $1 + + rm -rf build && mkdir -p build + cmake -B build $2 + cmake --build build --parallel 8 + + # execute the application + $3 + + # execute fieldcompare (A more comprehensive manual can be found here https://gitlab.com/dglaeser/fieldcompare) + fieldcompare dir $4 reference_data/$1 --include-files "*.vtu" +} \ No newline at end of file diff --git a/regression-tests/driven_cavity_test.sh b/regression-tests/driven_cavity_test.sh index 7f799facb4459ddafcd8b210a5477954af1444cb..e4a7dcf050c81ea7f3ccd99cffd58edab80959bd 100755 --- a/regression-tests/driven_cavity_test.sh +++ b/regression-tests/driven_cavity_test.sh @@ -1,24 +1,19 @@ #!/bin/bash +source ./regression-tests/__regression_test_executer.sh -################################# -# Driven Cavity Regression Test -################################# -# build VirtualFluids accordingly to our specific test scenario. -# in this case adding -DUSER_APPS="apps/gpu/LBM/DrivenCavity to the cmake command is not necessary, because the DrivenCavity is added to VirtualFluids by default. -mkdir -p build -cmake -B build --preset=make_gpu -DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES=75 #-DUSER_APPS="apps/gpu/LBM/DrivenCavity" -cmake --build build --parallel 8 +# 1. set reference data directory (must match the folder structure in https://github.com/irmb/test_data) +REFERENCE_DATA_DIR=regression_tests/gpu/DrivenCavity_2Levels -# execute VirtualFluids -./build/bin/DrivenCavity +# 2. set cmake flags for the build of VirtualFluids +CMAKE_FLAGS="--preset=make_gpu -DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES=75" -# set the path to the produced data -PATH_TO_DIR=output/DrivenCavity +# 3. define the application to be executed +APPLICATION=./build/bin/DrivenCavity -# set the path to the reference data. -# `regression-tests/reference_data` is fix `regression_tests/gpu/DrivenCavity_2Levels` must match the structure in https://github.com/irmb/test_data: -PATH_TO_REFERENCE_DIR=regression-tests/reference_data/regression_tests/gpu/DrivenCavity_2Levels +# 4. set the path to the produced data +RESULT_DATA_DIR=output/DrivenCavity + + +run_regression_test "$REFERENCE_DATA_DIR" "$CMAKE_FLAGS" "$APPLICATION" "$RESULT_DATA_DIR" -# execute fieldcompare (A more comprehensive manual can be found here https://gitlab.com/dglaeser/fieldcompare) -fieldcompare dir $PATH_TO_DIR $PATH_TO_REFERENCE_DIR --include-files "*.vtu" diff --git a/regression-tests/driven_cavity_uniform_test.sh b/regression-tests/driven_cavity_uniform_test.sh index 95e2bab635d3a6a73fb514a1f67902083c98e5d3..deb1300cad5914e69a4f2c01428bbef31d7af6d3 100755 --- a/regression-tests/driven_cavity_uniform_test.sh +++ b/regression-tests/driven_cavity_uniform_test.sh @@ -1,25 +1,19 @@ #!/bin/bash -################################# -# Driven Cavity Regression Test -################################# +source ./regression-tests/__regression_test_executer.sh -# build VirtualFluids accordingly to our specific test scenario. -# in this case adding -DUSER_APPS="apps/gpu/LBM/DrivenCavity to the cmake command is not necessary, because the DrivenCavity is added to VirtualFluids by default. -mkdir -p build -cmake -B build --preset=make_gpu -DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES=75 -DUSER_APPS="apps/gpu/LBM/DrivenCavityUniform" -cmake --build build --parallel 8 -# execute VirtualFluids -./build/bin/DrivenCavityUniform +# 1. set reference data directory (must match the folder structure in https://github.com/irmb/test_data) +REFERENCE_DATA_DIR=regression_tests/gpu/DrivenCavity_uniform +# 2. set cmake flags for the build of VirtualFluids +CMAKE_FLAGS="--preset=make_gpu -DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES=75 -DUSER_APPS="apps/gpu/LBM/DrivenCavityUniform"" -# set the path to the produced data -PATH_TO_DIR=output/DrivenCavity_uniform +# 3. define the application to be executed +APPLICATION=./build/bin/DrivenCavityUniform -# set the path to the reference data. -# `regression-tests/reference_data` is fix `regression_tests/gpu/DrivenCavity_uniform_2022_12_16` must match the structure in https://github.com/irmb/test_data: -PATH_TO_REFERENCE_DIR=regression-tests/reference_data/regression_tests/gpu/DrivenCavity_uniform +# 4. set the path to the produced data +RESULT_DATA_DIR=output/DrivenCavity_uniform -# execute fieldcompare (A more comprehensive manual can be found here https://gitlab.com/dglaeser/fieldcompare) -fieldcompare dir $PATH_TO_DIR $PATH_TO_REFERENCE_DIR --include-files "*.vtu" + +run_regression_test "$REFERENCE_DATA_DIR" "$CMAKE_FLAGS" "$APPLICATION" "$RESULT_DATA_DIR" diff --git a/regression-tests/reference_data b/regression-tests/reference_data deleted file mode 160000 index 794c3f838577d2b1f4db22c19861cbf0fed4fee6..0000000000000000000000000000000000000000 --- a/regression-tests/reference_data +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 794c3f838577d2b1f4db22c19861cbf0fed4fee6 diff --git a/regression-tests/regression-tests.sh b/regression-tests/regression-tests.sh deleted file mode 100755 index 9f5dc8cf758b380709fcc9ad8020d1335f760f64..0000000000000000000000000000000000000000 --- a/regression-tests/regression-tests.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -################################# -# VirtualFludis regression tests -################################# - - -# 1. Cloning the reference data from github -mkdir -p regression-tests/reference_data -git clone https://github.com/irmb/test_data regression-tests/reference_data - -# 2. set up the python environnement -# by cloning our meshio patch and fieldcompare into a venv -python3 -m venv .venv -source .venv/bin/activate -pip install fieldcompare - -# 3. Running the specific tests -./regression-tests/driven_cavity_uniform_test.sh -./regression-tests/driven_cavity_test.sh - - - -# How to add a new regression test? -# 1. setup the specfic simulation and run it to create reference data. -# 2. fork https://github.com/irmb/test_data and create a pull request containing the reference data. -# 3. copy ./regression-tests/driven_cavity_test.sh and adjust the file accordingly to the new test scenario. -# 4. execute this file from here accordingly to #3. \ No newline at end of file diff --git a/regression-tests/sphere_in_channel_test.sh b/regression-tests/sphere_in_channel_test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e416d535d274537d008a442435f66a38dd69fac1 --- /dev/null +++ b/regression-tests/sphere_in_channel_test.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +source ./regression-tests/__regression_test_executer.sh + +# 1. set reference data directory (must match the folder structure in https://github.com/irmb/test_data) +REFERENCE_DATA_DIR=regression_tests/gpu/SphereInChannel + +# 2. set cmake flags for the build of VirtualFluids +CMAKE_FLAGS="--preset=make_gpu -DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES=75" + +# 3. define the application to be executed +APPLICATION=./build/bin/SphereGPU + +# 4. set the path to the produced data +RESULT_DATA_DIR=output/Sphere + + +run_regression_test "$REFERENCE_DATA_DIR" "$CMAKE_FLAGS" "$APPLICATION" "$RESULT_DATA_DIR" + +# fieldcompare dir output/Sphere reference_data/regression_tests/gpu/SphereInChannel --include-files "*.vtu" \ No newline at end of file diff --git a/src/basics/CMakeLists.txt b/src/basics/CMakeLists.txt index 14e1760fe3cb6f9b1e122f4adc5adbfb3e30b5c7..7e4cccf26f0c54a47d720f8d33fad435800838b7 100644 --- a/src/basics/CMakeLists.txt +++ b/src/basics/CMakeLists.txt @@ -1,19 +1,18 @@ -include(Core/buildInfo.cmake) +include(buildInfo.cmake) vf_add_library(PUBLIC_LINK logger MPI::MPI_CXX EXCLUDE buildInfo.in.cpp) vf_get_library_name (library_name) -target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Core) target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/geometry3d) target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/geometry3d/KdTree) -target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/basics/container) -target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/basics/memory) -target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/basics/objects) -target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/basics/parallel) -target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/basics/transmitter) -target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/basics/utilities) -target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/basics/writer) +target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/container) +target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/memory) +target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/objects) +target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/parallel) +target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/transmitter) +target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/utilities) +target_include_directories(${library_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/writer) diff --git a/src/basics/Core/ArrayTypes.h b/src/basics/Core/ArrayTypes.h deleted file mode 100644 index f899c92a7be4f29065b55b13fb1a1181da0eaf7e..0000000000000000000000000000000000000000 --- a/src/basics/Core/ArrayTypes.h +++ /dev/null @@ -1,94 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file ArrayTypes.h -//! \ingroup Core -//! \author Konstantin Kutscher, Soeren Textor, Sebastian Geller -//======================================================================================= -#ifndef ARRAYTYPES_H -#define ARRAYTYPES_H - -#include <array> - -#include "DataTypes.h" - -typedef std::array<uint, 2> uint_2; -typedef std::array<uint, 3> uint_3; -typedef std::array<uint, 4> uint_4; -typedef std::array<uint, 5> uint_5; -typedef std::array<uint, 6> uint_6; -typedef std::array<uint, 7> uint_7; -typedef std::array<uint, 8> uint_8; -typedef std::array<uint, 9> uint_9; -typedef std::array<uint, 10> uint_10; -typedef std::array<uint, 11> uint_11; -typedef std::array<uint, 12> uint_12; -typedef std::array<uint, 13> uint_13; -typedef std::array<uint, 14> uint_14; -typedef std::array<uint, 15> uint_15; -typedef std::array<uint, 16> uint_16; -typedef std::array<uint, 17> uint_17; -typedef std::array<uint, 18> uint_18; -typedef std::array<uint, 19> uint_19; -typedef std::array<uint, 20> uint_20; -typedef std::array<uint, 21> uint_21; -typedef std::array<uint, 22> uint_22; -typedef std::array<uint, 23> uint_23; -typedef std::array<uint, 24> uint_24; -typedef std::array<uint, 25> uint_25; -typedef std::array<uint, 26> uint_26; -typedef std::array<uint, 27> uint_27; - -typedef std::array<bool, 2> bool_2; -typedef std::array<bool, 3> bool_3; -typedef std::array<bool, 4> bool_4; -typedef std::array<bool, 5> bool_5; -typedef std::array<bool, 6> bool_6; -typedef std::array<bool, 7> bool_7; -typedef std::array<bool, 8> bool_8; -typedef std::array<bool, 9> bool_9; -typedef std::array<bool, 10> bool_10; -typedef std::array<bool, 11> bool_11; -typedef std::array<bool, 12> bool_12; -typedef std::array<bool, 13> bool_13; -typedef std::array<bool, 14> bool_14; -typedef std::array<bool, 15> bool_15; -typedef std::array<bool, 16> bool_16; -typedef std::array<bool, 17> bool_17; -typedef std::array<bool, 18> bool_18; -typedef std::array<bool, 19> bool_19; -typedef std::array<bool, 20> bool_20; -typedef std::array<bool, 21> bool_21; -typedef std::array<bool, 22> bool_22; -typedef std::array<bool, 23> bool_23; -typedef std::array<bool, 24> bool_24; -typedef std::array<bool, 25> bool_25; -typedef std::array<bool, 26> bool_26; -typedef std::array<bool, 27> bool_27; - -#endif diff --git a/src/basics/Core/LbmOrGks.h b/src/basics/Core/LbmOrGks.h deleted file mode 100644 index ae4a17cad6488ee8ec95c19c3e3766abd408b0bf..0000000000000000000000000000000000000000 --- a/src/basics/Core/LbmOrGks.h +++ /dev/null @@ -1,38 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file LbmOrGks.h -//! \ingroup Core -//! \author Stephan Lenz -//======================================================================================= -#ifndef LBMORGKS_H -#define LBMORGKS_H - -enum LbmOrGks { LBM, GKS }; - -#endif diff --git a/src/basics/Core/Logger/Logger.cpp b/src/basics/Core/Logger/Logger.cpp deleted file mode 100644 index 1a27ef6f2a33bf46b9f488a4cf8d17705c2a64e6..0000000000000000000000000000000000000000 --- a/src/basics/Core/Logger/Logger.cpp +++ /dev/null @@ -1,92 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file Logger.cpp -//! \ingroup Logger -//! \author Stephan Lenz -//======================================================================================= -#include "Logger.h" -#include <iostream> -#include <memory> - -#include "implementations/LoggerImp.h" - -namespace logging -{ - -std::shared_ptr<Logger> out = nullptr; - -logging::Logger::Level logging::Logger::globalLogLevel = logging::Logger::INFO_LOW; -logging::Logger::Level logging::Logger::localLogLevel = logging::Logger::INFO_LOW; -bool logging::Logger::printRankNumber = false; -bool logging::Logger::timeStampEnabled = false; - -logging::Logger::Logger(std::ostream *stream) { streams.push_back(stream); } - -logging::Logger::~Logger() = default; - -void Logger::addStreamToList(std::ostream *stream) { streams.push_back(stream); } - -void Logger::resetStreamList() { streams.clear(); } - -//-----------static methods----------------// -void logging::Logger::resetStreams() -{ - if (!out) - out = std::make_shared<LoggerImp>(&std::cout); - - out->resetStreamList(); -} - -void logging::Logger::setStream(std::ostream *stream) { out = std::make_shared<LoggerImp>(stream); } - -void logging::Logger::addStream(std::ostream *stream) -{ - if (!out) - out = std::make_shared<LoggerImp>(stream); - else - out->addStreamToList(stream); -} - -void logging::Logger::timeStamp(TimeStamp timeStamp) -{ - switch (timeStamp) { - case ENABLE: - timeStampEnabled = true; - break; - case DISABLE: - timeStampEnabled = false; - break; - } -} - -void logging::Logger::setDebugLevel(const Level &level) { globalLogLevel = level; } - -void logging::Logger::enablePrintedRankNumbers(bool print) { printRankNumber = print; } - -} // namespace logging diff --git a/src/basics/Core/Logger/Logger.h b/src/basics/Core/Logger/Logger.h deleted file mode 100644 index 53cb974b8e409a8ba6eb555abac41ca99eb2bbcf..0000000000000000000000000000000000000000 --- a/src/basics/Core/Logger/Logger.h +++ /dev/null @@ -1,88 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file Logger.h -//! \ingroup Logger -//! \author Stephan Lenz -//======================================================================================= -#ifndef Logger_H -#define Logger_H - -#include "basics_export.h" - -#include <memory> -#include <ostream> -#include <string> -#include <vector> - -namespace logging -{ -class BASICS_EXPORT Logger -{ -protected: - Logger(std::ostream *stream); - -public: - virtual ~Logger(); - - enum Level { INFO_LOW = 3, INFO_INTERMEDIATE = 2, INFO_HIGH = 1, WARNING = 0, LOGGER_ERROR = -1 }; - - enum TimeStamp { ENABLE, DISABLE }; - - static void setStream(std::ostream *stream); - static void addStream(std::ostream *stream); - static void resetStreams(); - - static void timeStamp(TimeStamp timeStamp); - - static void setDebugLevel(const Level &level = Level::LOGGER_ERROR); - static void enablePrintedRankNumbers(bool printRankNumbers); - - virtual Logger &operator<<(const Level &level) = 0; - virtual Logger &operator<<(const std::string &log) = 0; - virtual Logger &operator<<(const int &log) = 0; - virtual Logger &operator<<(const unsigned int &log) = 0; - virtual Logger &operator<<(const unsigned long &log) = 0; - virtual Logger &operator<<(const float &log) = 0; - virtual Logger &operator<<(const double &log) = 0; - -protected: - void addStreamToList(std::ostream *stream); - void resetStreamList(); - - std::vector<std::ostream *> streams; - - static Level globalLogLevel; - static Level localLogLevel; - static bool printRankNumber; - static bool timeStampEnabled; -}; -extern BASICS_EXPORT std::shared_ptr<Logger> out; -} // namespace logging - -#endif diff --git a/src/basics/Core/Logger/implementations/LoggerImp.cpp b/src/basics/Core/Logger/implementations/LoggerImp.cpp deleted file mode 100644 index 086c0e3aa5153f017905cd8476248ea7a7434335..0000000000000000000000000000000000000000 --- a/src/basics/Core/Logger/implementations/LoggerImp.cpp +++ /dev/null @@ -1,126 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file LoggerImp.cpp -//! \ingroup Logger -//! \author Stephan Lenz -//======================================================================================= -#include "LoggerImp.h" - -#include <chrono> -#include <iomanip> -#include <iostream> -#include <mpi.h> -#include <sstream> - -logging::LoggerImp::LoggerImp(std::ostream *stream) : logging::Logger(stream) -{ - levelString[Level::WARNING] = "[WARNING] "; - levelString[Level::LOGGER_ERROR] = "[ERROR] "; - levelString[Level::INFO_LOW] = "[INFO_LOW] "; - levelString[Level::INFO_INTERMEDIATE] = "[INFO_INTERMEDIATE]"; - levelString[Level::INFO_HIGH] = "[INFO_HIGH] "; -} - -logging::LoggerImp::~LoggerImp() = default; - -logging::Logger &logging::LoggerImp::operator<<(const Level &level) -{ - localLogLevel = level; - return *this; -} - -logging::Logger &logging::LoggerImp::operator<<(const std::string &message) { return this->log(message); } - -logging::Logger &logging::LoggerImp::operator<<(const int &message) { return this->log(std::to_string(message)); } - -logging::Logger &logging::LoggerImp::operator<<(const unsigned int &message) -{ - return this->log(std::to_string(message)); -} - -logging::Logger &logging::LoggerImp::operator<<(const unsigned long &message) -{ - return this->log(std::to_string(message)); -} - -logging::Logger &logging::LoggerImp::operator<<(const float &message) { return this->log(std::to_string(message)); } - -logging::Logger &logging::LoggerImp::operator<<(const double &message) { return this->log(std::to_string(message)); } - -logging::Logger &logging::LoggerImp::log(const std::string &message) -{ - if (shouldBeLogged()) { - std::string modifiedMessage = message; - addDebugInformation(modifiedMessage); - for (auto stream : streams) - *stream << modifiedMessage << std::flush; - } - std::size_t found = message.find(std::string("\n")); - if (found != std::string::npos) - newLoggingLine = true; - else - newLoggingLine = false; - - return *this; -} - -bool logging::LoggerImp::shouldBeLogged() { return localLogLevel <= globalLogLevel; } - -void logging::LoggerImp::addDebugInformation(std::string &message) -{ - if (newLoggingLine) { - std::stringstream os; - os << levelString[localLogLevel] << getTimeStamp() << " " << message; - message = os.str(); - } -} - -std::string logging::LoggerImp::getTimeStamp() -{ - if (!timeStampEnabled) - return ""; - - const auto now = std::chrono::system_clock::now(); - time_t tt = std::chrono::system_clock::to_time_t(now); - // const tm utc_tm = *gmtime(&tt); - const tm local_tm = *localtime(&tt); - - std::stringstream os; - os << " [" << std::setw(2) << std::setfill('0') << local_tm.tm_hour << ":"; - os << std::setw(2) << std::setfill('0') << local_tm.tm_min << ":"; - os << std::setw(2) << std::setfill('0') << local_tm.tm_sec << "]"; - return os.str(); -} - -std::string logging::LoggerImp::getRankString() -{ - int rank; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - return printRankNumber ? "[" + std::to_string(rank) + "] " : ""; -} diff --git a/src/basics/Core/Logger/implementations/LoggerImp.h b/src/basics/Core/Logger/implementations/LoggerImp.h deleted file mode 100644 index 070b06a23ee59a1d387f09fc86960dd3083c4e61..0000000000000000000000000000000000000000 --- a/src/basics/Core/Logger/implementations/LoggerImp.h +++ /dev/null @@ -1,75 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file LoggerImp.h -//! \ingroup Logger -//! \author Stephan Lenz -//======================================================================================= -#ifndef LoggerImp_H -#define LoggerImp_H - -#include "basics_export.h" - -#include <string> - -#include "../Logger.h" -#include <map> - -namespace logging -{ - -class BASICS_EXPORT LoggerImp : public Logger -{ -public: - LoggerImp(std::ostream *stream); - ~LoggerImp() override; - - Logger &operator<<(const Level &level) override; - Logger &operator<<(const std::string &message) override; - Logger &operator<<(const int &message) override; - Logger &operator<<(const unsigned int &message) override; - Logger &operator<<(const unsigned long &log) override; - Logger &operator<<(const float &message) override; - Logger &operator<<(const double &message) override; - -private: - std::string getRankString(); - static bool shouldBeLogged(); - - static std::string getTimeStamp(); - void addDebugInformation(std::string &message); - logging::Logger &log(const std::string &message); - -private: - std::map<Logger::Level, std::string> levelString; - bool newLoggingLine = true; -}; - -} // namespace logging - -#endif diff --git a/src/basics/Core/Logger/implementations/LoggerTest.cpp b/src/basics/Core/Logger/implementations/LoggerTest.cpp deleted file mode 100644 index 2c4e4e6819a19497c3061caddbfa4c2a54953054..0000000000000000000000000000000000000000 --- a/src/basics/Core/Logger/implementations/LoggerTest.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "gmock/gmock.h" -#include <fstream> -#include <memory> - -#include "../Logger.h" - -TEST(DISABLED_LoggerTest, logStringWithoutSettingLevels_WillPutTheLogMesssageIntoTheStream) -{ - std::ostringstream stream; - logging::Logger::setStream(&stream); - - *logging::out << logging::Logger::INFO_LOW << "Hello World\n"; - - EXPECT_THAT(stream.str(), "[LOW] Hello World\n"); -} - -TEST(DISABLED_LoggerTest, logStringWithHighDebugLevel_logOnlyHighLevelMessages) -{ - std::ostringstream stream; - logging::Logger::setStream(&stream); - - logging::Logger::setDebugLevel(logging::Logger::INFO_HIGH); - *logging::out << logging::Logger::INFO_LOW << "Low Debug Message\n" - << logging::Logger::INFO_HIGH << "HIGH Debug Message\n"; - - EXPECT_THAT(stream.str(), "[HIGH] HIGH Debug Message\n"); -} - -TEST(DISABLED_LoggerTest, addTwoStreams_shouldWriteToBoth) -{ - logging::Logger::resetStreams(); - - std::ostringstream stream1, stream2; - logging::out->addStream(&stream1); - logging::out->addStream(&stream2); - logging::Logger::setDebugLevel(logging::Logger::INFO_LOW); - - *logging::out << logging::Logger::INFO_LOW << "Hello World\n"; - - EXPECT_THAT(stream1.str(), "[LOW] Hello World\n"); - EXPECT_THAT(stream2.str(), "[LOW] Hello World\n"); -} - -TEST(DISABLED_LoggerTest, splittetOutputShouldHaveDebugInformationOnce) -{ - std::ostringstream stream; - logging::Logger::setStream(&stream); - - *logging::out << logging::Logger::INFO_LOW << "Hello" - << " World\n"; - - EXPECT_THAT(stream.str(), "[LOW] Hello World\n"); -} - -TEST(DISABLED_LoggerTest, enableTimeStampInOutput) -{ - std::ostringstream stream; - logging::Logger::setStream(&stream); - logging::Logger::timeStamp(logging::Logger::TimeStamp::ENABLE); - - *logging::out << logging::Logger::INFO_LOW << "Hello" - << " World\n"; - - EXPECT_THAT(stream.str(), testing::StrNe("[LOW] Hello World\n")); -} diff --git a/src/basics/Core/NonCreatable.h b/src/basics/Core/NonCreatable.h deleted file mode 100644 index c581a19ec92b666f45109f1e3c66b9e57fb54614..0000000000000000000000000000000000000000 --- a/src/basics/Core/NonCreatable.h +++ /dev/null @@ -1,44 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file NonCreatable.h -//! \ingroup Core -//! \author Soeren Peters -//======================================================================================= -#ifndef NON_CREATABLE_H -#define NON_CREATABLE_H - -class NonCreatable -{ -private: - NonCreatable() = delete; - NonCreatable(const NonCreatable &) = delete; - NonCreatable &operator=(const NonCreatable &) = delete; -}; - -#endif diff --git a/src/basics/Core/RealConstants.h b/src/basics/Core/RealConstants.h deleted file mode 100644 index 5cb42584e29d0e0a1a9cf1b40f50736dd13169f0..0000000000000000000000000000000000000000 --- a/src/basics/Core/RealConstants.h +++ /dev/null @@ -1,255 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file RealConstants.h -//! \ingroup Core -//! \author Martin Schoenherr -//======================================================================================= -//#ifndef REAL_CONSTANT_H -//#define REAL_CONSTANT_H -// -//#ifdef VF_DOUBLE_ACCURACY -//#define c1o2 0.5 -//#define c3o2 1.5 -//#define c1o3 0.333333333333333 -//#define c2o3 0.666666666666667 -//#define c1o4 0.25 -//#define c3o4 0.75 -//#define c1o6 0.166666666666667 -//#define c1o7 0.142857142857143 -//#define c1o8 0.125 -//#define c1o9 0.111111111111111 -//#define c2o9 0.222222222222222 -//#define c4o9 0.444444444444444 -//#define c1o10 0.1 -//#define c1o12 0.083333333333333 -//#define c1o16 0.0625 -//#define c3o16 0.1875 -//#define c9o16 0.5625 -//#define c1o18 0.055555555555556 -//#define c1o20 0.05 -//#define c19o20 0.95 -//#define c21o20 1.05 -//#define c1o24 0.041666666666667 -//#define c1o27 0.037037037037037 -//#define c3o32 0.09375 -//#define c4o32 0.125 -//#define c1o36 0.027777777777778 -//#define c1o48 0.020833333333333 -//#define c1o64 0.015625 -//#define c3o64 0.046875 -//#define c9o64 0.140625 -//#define c27o64 0.421875 -//#define c1o66 0.015151515151515 -//#define c1o72 0.013888888888889 -//#define c1o264 0.003787878787879 -//#define c8o27 0.296296296296296 -//#define c2o27 0.074074074074074 -//#define c1o54 0.018518518518519 -//#define c1o100 0.01 -//#define c99o100 0.99 -//#define c1o126 0.007936507936508 -//#define c1o216 0.004629629629630 -//#define c5o4 1.25 -//#define c9o4 2.25 -//#define c5o2 2.5 -//#define c9o2 4.5 -// -//#define c0o1 0. -//#define c1o1 1. -//#define c2o1 2. -//#define c3o1 3. -//#define c4o1 4. -//#define c5o1 5. -//#define c6o1 6. -//#define c7o1 7. -//#define c8o1 8. -//#define c9o1 9. -//#define c10o1 10. -//#define c11o1 11. -//#define c12o1 12. -//#define c13o1 13. -//#define c14o1 14. -//#define c15o1 15. -//#define c16o1 16. -//#define c17o1 17. -//#define c18o1 18. -//#define c21o1 21. -//#define c24o1 24. -//#define c25o1 25. -//#define c26o1 26. -//#define c27o1 27. -//#define c28o1 28. -//#define c29o1 29. -//#define c30o1 30. -//#define c32o1 32. -//#define c33o1 33. -//#define c34o1 34. -//#define c36o1 36. -//#define c40o1 40. -//#define c42o1 42. -//#define c46o1 46. -//#define c48o1 48. -//#define c50o1 50. -//#define c52o1 52. -//#define c54o1 54. -//#define c56o1 56. -//#define c64o1 64. -//#define c66o1 66. -//#define c68o1 68. -//#define c69o1 69. -//#define c72o1 72. -//#define c84o1 84. -//#define c88o1 88. -//#define c96o1 96. -//#define c100o1 100.0 -//#define c130o1 130.0 -//#define c152o1 152.0 -//#define c166o1 166.0 -//#define c195o1 195.0 -//#define c216o1 216.0 -//#define c264o1 264.0 -//#define c290o1 290.0 -//#define c367o1 367.0 -// -//#define Op0000002 0.0000002 -//#define c10eM30 1e-30 -//#define c10eM10 1e-10 -//#define smallSingle 0.0000000002 -// -//#else -//#define c1o2 0.5f -//#define c3o2 1.5f -//#define c1o3 (1.0f / 3.0f) -//#define c2o3 (2.0f / 3.0f) -//#define c1o4 0.25f -//#define c3o4 0.75f -//#define c1o6 (1.0f / 6.0f) -//#define c1o7 (1.0f / 7.0f) -//#define c1o8 0.125f -//#define c1o9 (1.0f / 9.0f) -//#define c2o9 (2.0f / 9.0f) -//#define c4o9 (4.0f / 9.0f) -//#define c1o10 0.1f -//#define c1o12 (1.0f / 12.0f) -//#define c1o16 0.0625f -//#define c3o16 0.1875f -//#define c9o16 0.5625f -//#define c1o18 (1.0f / 18.0f) -//#define c1o20 0.05f -//#define c19o20 0.95f -//#define c21o20 1.05f -//#define c1o24 (1.0f / 24.0f) -//#define c1o27 (1.0f / 27.0f) -//#define c3o32 0.09375f -//#define c4o32 0.125f -//#define c1o36 (1.0f / 36.0f) -//#define c1o48 (1.0f / 48.0f) -//#define c1o64 0.015625f -//#define c3o64 0.046875f -//#define c9o64 0.140625f -//#define c27o64 0.421875f -//#define c1o66 (1.0f / 66.0f) -//#define c1o72 (1.0f / 72.0f) -//#define c1o264 (1.0f / 264.0f) -//#define c8o27 (8.0f / 27.0f) -//#define c2o27 (2.0f / 27.0f) -//#define c1o54 (1.0f / 54.0f) -//#define c1o100 0.01f -//#define c99o100 0.99f -//#define c1o126 (1.0f / 126.0f) -//#define c1o216 (1.0f / 216.0f) -//#define c5o4 1.25f -//#define c9o4 2.25f -//#define c5o2 2.5f -//#define c9o2 4.5f -// -//#define c0o1 0.f -//#define c1o1 1.f -//#define c2o1 2.f -//#define c3o1 3.f -//#define c4o1 4.f -//#define c5o1 5.f -//#define c6o1 6.f -//#define c7o1 7.f -//#define c8o1 8.f -//#define c9o1 9.f -//#define c10o1 10.f -//#define c11o1 11.f -//#define c12o1 12.f -//#define c13o1 13.f -//#define c14o1 14.f -//#define c15o1 15.f -//#define c16o1 16.f -//#define c17o1 17.f -//#define c18o1 18.f -//#define c21o1 21.f -//#define c24o1 24.f -//#define c25o1 25.f -//#define c26o1 26.f -//#define c27o1 27.f -//#define c28o1 28.f -//#define c29o1 29.f -//#define c30o1 30.f -//#define c32o1 32.f -//#define c33o1 33.f -//#define c34o1 34.f -//#define c36o1 36.f -//#define c40o1 40.f -//#define c42o1 42.f -//#define c46o1 46.f -//#define c48o1 48.f -//#define c50o1 50.f -//#define c52o1 52.f -//#define c54o1 54.f -//#define c56o1 56.f -//#define c64o1 64.f -//#define c66o1 66.f -//#define c68o1 68.f -//#define c69o1 69.f -//#define c72o1 72.f -//#define c84o1 84.f -//#define c88o1 88.f -//#define c96o1 96.f -//#define c100o1 100.0f -//#define c130o1 130.0f -//#define c152o1 152.0f -//#define c166o1 166.0f -//#define c195o1 195.0f -//#define c216o1 216.0f -//#define c264o1 264.0f -//#define c290o1 290.0f -//#define c367o1 367.0f -// -//#define Op0000002 0.0000002f -//#define c10eM30 1e-30 -//#define c10eM10 1e-10 -//#define smallSingle 0.0000000002f -//#endif -// -//#endif \ No newline at end of file diff --git a/src/basics/Core/VectorTypes.cpp b/src/basics/Core/VectorTypes.cpp deleted file mode 100644 index ecc986be836cb3c85d760f4db408707bfb1180b4..0000000000000000000000000000000000000000 --- a/src/basics/Core/VectorTypes.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file VectorTypes.cpp -//! \ingroup Core -//! \author Soeren Peters -//======================================================================================= -#include "VectorTypes.h" - -// Vec3 Vec3::operator+( Vec3& left, Vec3& right ){ -Vec3 Vec3::operator+(Vec3 &right) { return { this->x + right.x, this->y + right.y, this->z + right.z }; } - -Vec3 Vec3::operator-(Vec3 &right) { return { this->x - right.x, this->y - right.y, this->z - right.z }; } - -Vec3 operator*(real scalar, Vec3 &vec) { return { scalar * vec.x, scalar * vec.y, scalar * vec.z }; } diff --git a/src/basics/Core/VectorTypes.h b/src/basics/Core/VectorTypes.h deleted file mode 100644 index 2ca45b359397c712b8b8695b9a99b4c5f8c324d1..0000000000000000000000000000000000000000 --- a/src/basics/Core/VectorTypes.h +++ /dev/null @@ -1,70 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file VectorTypes.h -//! \ingroup Core -//! \author Soeren Peters -//======================================================================================= -#ifndef VECTORTYPES_H -#define VECTORTYPES_H - -#ifdef __CUDACC__ -#include <cuda_runtime.h> -#else -#ifndef __host__ -#define __host__ -#endif -#ifndef __device__ -#define __device__ -#endif -#endif - -#include <cmath> - -#include "basics_export.h" - -#include "DataTypes.h" -#include "RealConstants.h" - -struct BASICS_EXPORT Vec3 { - real x{ 0. }, y{ 0. }, z{ 0. }; - - __host__ __device__ Vec3(real x, real y, real z) : x(x), y(y), z(z) {} - Vec3() = default; - - __host__ __device__ real length() { return std::sqrt(x * x + y * y + z * z); } - - Vec3 operator+(Vec3 &right); - Vec3 operator-(Vec3 &right); -}; - -// BASICS_EXPORT Vec3 operator+( Vec3& left, Vec3& right ); -// BASICS_EXPORT Vec3 operator-( Vec3& left, Vec3& right ); -BASICS_EXPORT Vec3 operator*(real scalar, Vec3 &vec); - -#endif diff --git a/src/basics/Core/DataTypes.h b/src/basics/DataTypes.h similarity index 100% rename from src/basics/Core/DataTypes.h rename to src/basics/DataTypes.h diff --git a/src/basics/Singelton.h b/src/basics/Singelton.h deleted file mode 100644 index f0979b5dd3d89e26ebbe4b4e82d2336e1f59a07e..0000000000000000000000000000000000000000 --- a/src/basics/Singelton.h +++ /dev/null @@ -1,58 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \author Soeren Peters -//======================================================================================= - -#ifndef BASICS_SINGELTON_H -#define BASICS_SINGELTON_H - -namespace vf::basics -{ - -template<typename T> -class Singleton -{ -public: - Singleton(const Singleton&) = delete; - Singleton & operator=(const Singleton& rhs) = delete; - -protected: - Singleton() = default; - -public: - static std::shared_ptr<Singleton> getInstance() - { - static std::shared_ptr<Singleton> s{new T}; - return s; - } -}; - -} - -#endif \ No newline at end of file diff --git a/src/basics/Core/StringUtilities/StringUtil.cpp b/src/basics/StringUtilities/StringUtil.cpp similarity index 100% rename from src/basics/Core/StringUtilities/StringUtil.cpp rename to src/basics/StringUtilities/StringUtil.cpp diff --git a/src/basics/Core/StringUtilities/StringUtil.h b/src/basics/StringUtilities/StringUtil.h similarity index 100% rename from src/basics/Core/StringUtilities/StringUtil.h rename to src/basics/StringUtilities/StringUtil.h diff --git a/src/basics/Core/StringUtilities/StringUtilTest.cpp b/src/basics/StringUtilities/StringUtilTest.cpp similarity index 100% rename from src/basics/Core/StringUtilities/StringUtilTest.cpp rename to src/basics/StringUtilities/StringUtilTest.cpp diff --git a/src/basics/Core/Timer/Timer.cpp b/src/basics/Timer/Timer.cpp similarity index 100% rename from src/basics/Core/Timer/Timer.cpp rename to src/basics/Timer/Timer.cpp diff --git a/src/basics/Core/Timer/Timer.h b/src/basics/Timer/Timer.h similarity index 100% rename from src/basics/Core/Timer/Timer.h rename to src/basics/Timer/Timer.h diff --git a/src/basics/Core/Timer/TimerImp.cpp b/src/basics/Timer/TimerImp.cpp similarity index 100% rename from src/basics/Core/Timer/TimerImp.cpp rename to src/basics/Timer/TimerImp.cpp diff --git a/src/basics/Core/Timer/TimerImp.h b/src/basics/Timer/TimerImp.h similarity index 100% rename from src/basics/Core/Timer/TimerImp.h rename to src/basics/Timer/TimerImp.h diff --git a/src/basics/Core/buildInfo.cmake b/src/basics/buildInfo.cmake similarity index 100% rename from src/basics/Core/buildInfo.cmake rename to src/basics/buildInfo.cmake diff --git a/src/basics/Core/buildInfo.h b/src/basics/buildInfo.h similarity index 100% rename from src/basics/Core/buildInfo.h rename to src/basics/buildInfo.h diff --git a/src/basics/Core/buildInfo.in.cpp b/src/basics/buildInfo.in.cpp similarity index 100% rename from src/basics/Core/buildInfo.in.cpp rename to src/basics/buildInfo.in.cpp diff --git a/src/basics/config/ConfigurationFile.cpp b/src/basics/config/ConfigurationFile.cpp index 026d13e15486c46a7056e061ea075a03c9c06f9f..547468cd2fd6aadccbdc5017230fcf6cdb803733 100644 --- a/src/basics/config/ConfigurationFile.cpp +++ b/src/basics/config/ConfigurationFile.cpp @@ -8,8 +8,9 @@ #include <fstream> #include <iostream> #include <stdlib.h> +#include <filesystem> -#include <basics/basics/utilities/UbException.h> +#include <basics/utilities/UbException.h> namespace vf::basics @@ -26,7 +27,7 @@ bool ConfigurationFile::load(const std::string& file) if (!inFile.good()) { - UB_THROW(UbException(UB_EXARGS, "Cannot read configuration file "+file+"!")); + UB_THROW(UbException(UB_EXARGS, "Cannot read configuration file " + file + "! Your current directory is " + std::filesystem::current_path().string() + ".")); } while (inFile.good() && ! inFile.eof()) diff --git a/src/basics/config/ConfigurationFile.h b/src/basics/config/ConfigurationFile.h index 4a53f7add85b9c6461fda0bab20fa6656eebc5d3..8ca12306e0ef321832efb19a2a428e6dc753df41 100644 --- a/src/basics/config/ConfigurationFile.h +++ b/src/basics/config/ConfigurationFile.h @@ -1,6 +1,8 @@ #ifndef BASICS_CONFIGURATIONFILE_H #define BASICS_CONFIGURATIONFILE_H +#include "Logger.h" +#include <filesystem> #include <map> #include <vector> #include <sstream> @@ -9,7 +11,7 @@ #include <iostream> #include <stdlib.h> -#include <basics/basics/utilities/UbException.h> +#include <basics/utilities/UbException.h> //! \brief Simple configuration file //! \details The Configuration class presented here can read and keep values of any configuration file written in a format like this: @@ -68,6 +70,23 @@ public: template<class T> T getValue(const std::string& key, T defaultValue) const; + static ConfigurationFile loadConfig(int argc, char *argv[], std::string configPath = "./config.txt") + { + // the config file's default path can be replaced by passing a command line argument + + if (argc > 1) + { + configPath = argv[1]; + VF_LOG_INFO("Using command line argument for config path: {}", configPath); + } else { + VF_LOG_INFO("Using default config path: {}", configPath); + } + + vf::basics::ConfigurationFile config; + config.load(configPath); + return config; + } + private: //! the container std::map<std::string, std::string> data; diff --git a/src/basics/constants/NumericConstants.h b/src/basics/constants/NumericConstants.h new file mode 100644 index 0000000000000000000000000000000000000000..305805de4f1532de51bae15b92cfda80a5b2f4ab --- /dev/null +++ b/src/basics/constants/NumericConstants.h @@ -0,0 +1,271 @@ +#ifndef BASICS_NUMERIC_CONSTANT_H +#define BASICS_NUMERIC_CONSTANT_H + +#ifndef __CUDACC__ +#include <cmath> +#endif + +namespace vf::basics::constant +{ + +#ifdef VF_DOUBLE_ACCURACY +static constexpr double c1o2 = 1. / 2.; +static constexpr double c3o2 = 3. / 2.; +static constexpr double c1o3 = 1. / 3.; +static constexpr double c2o3 = 2. / 3.; +static constexpr double c1o4 = 1. / 4.; +static constexpr double c3o4 = 3. / 4.; +static constexpr double c1o6 = 1. / 6.; +static constexpr double c1o7 = 1. / 7.; +static constexpr double c1o8 = 1. / 8.; +static constexpr double c1o9 = 1. / 9.; +static constexpr double c2o9 = 2. / 9.; +static constexpr double c4o9 = 4. / 9.; +static constexpr double c4o10 = 4. / 10.; +static constexpr double c1o10 = 1. / 10.; +static constexpr double c1o12 = 1. / 12.; +static constexpr double c1o16 = 1. / 16.; +static constexpr double c3o16 = 3. / 16.; +static constexpr double c9o16 = 9. / 16.; +static constexpr double c1o18 = 1. / 18.; +static constexpr double c1o20 = 1. / 20.; +static constexpr double c19o20 = 19. / 20.; +static constexpr double c21o20 = 21. / 20.; +static constexpr double c1o24 = 1. / 24.; +static constexpr double c1o27 = 1. / 27.; +static constexpr double c3o32 = 3. / 32.; +static constexpr double c4o32 = 4. / 32.; +static constexpr double c1o36 = 1. / 36.; +static constexpr double c1o48 = 1. / 48.; +static constexpr double c1o64 = 1. / 64.; +static constexpr double c3o64 = 3. / 64.; +static constexpr double c9o64 = 9. / 64.; +static constexpr double c27o64 = 27. / 64.; +static constexpr double c1o66 = 1. / 66.; +static constexpr double c1o72 = 1. / 72.; +static constexpr double c1o264 = 1. / 264.; +static constexpr double c8o27 = 8. / 27.; +static constexpr double c2o27 = 2. / 27.; +static constexpr double c1o54 = 1. / 54.; +static constexpr double c1o100 = 1. / 100.; +static constexpr double c99o100 = 99. / 100; +static constexpr double c1o126 = 1. / 126.; +static constexpr double c1o216 = 1. / 216.; +static constexpr double c5o4 = 5. / 4.; +static constexpr double c4o3 = 4. / 3.; +static constexpr double c9o4 = 9. / 4.; +static constexpr double c5o2 = 5. / 2.; +static constexpr double c9o2 = 9. / 2.; + +static constexpr double c0o1 = 0.; +static constexpr double c1o1 = 1.; +static constexpr double c2o1 = 2.; +static constexpr double c3o1 = 3.; +static constexpr double c4o1 = 4.; +static constexpr double c5o1 = 5.; +static constexpr double c6o1 = 6.; +static constexpr double c7o1 = 7.; +static constexpr double c8o1 = 8.; +static constexpr double c9o1 = 9.; +static constexpr double c10o1 = 10.; +static constexpr double c11o1 = 11.; +static constexpr double c12o1 = 12.; +static constexpr double c13o1 = 13.; +static constexpr double c14o1 = 14.; +static constexpr double c15o1 = 15.; +static constexpr double c16o1 = 16.; +static constexpr double c17o1 = 17.; +static constexpr double c18o1 = 18.; +static constexpr double c21o1 = 21.; +static constexpr double c24o1 = 24.; +static constexpr double c25o1 = 25.; +static constexpr double c26o1 = 26.; +static constexpr double c27o1 = 27.; +static constexpr double c28o1 = 28.; +static constexpr double c29o1 = 29.; +static constexpr double c30o1 = 30.; +static constexpr double c32o1 = 32.; +static constexpr double c33o1 = 33.; +static constexpr double c34o1 = 34.; +static constexpr double c36o1 = 36.; +static constexpr double c40o1 = 40.; +static constexpr double c42o1 = 42.; +static constexpr double c46o1 = 46.; +static constexpr double c48o1 = 48.; +static constexpr double c50o1 = 50.; +static constexpr double c52o1 = 52.; +static constexpr double c54o1 = 54.; +static constexpr double c56o1 = 56.; +static constexpr double c64o1 = 64.; +static constexpr double c66o1 = 66.; +static constexpr double c68o1 = 68.; +static constexpr double c69o1 = 69.; +static constexpr double c72o1 = 72.; +static constexpr double c84o1 = 84.; +static constexpr double c88o1 = 88.; +static constexpr double c96o1 = 96.; +static constexpr double c100o1 = 100.; +static constexpr double c130o1 = 130.; +static constexpr double c152o1 = 152.; +static constexpr double c166o1 = 166.; +static constexpr double c195o1 = 195.; +static constexpr double c216o1 = 216.; +static constexpr double c264o1 = 264.; +static constexpr double c290o1 = 290.; +static constexpr double c367o1 = 367.; + +static constexpr double Op0000002 = 0.0000002; +static constexpr double c10eM30 = 1e-30; +static constexpr double c10eM10 = 1e-10; +static constexpr double smallSingle = 0.0000000002; + +#ifndef __CUDACC__ +static const double cPi = 4.0 * std::atan(1.0); // 3.1415926535 +static const double c2Pi = 8.0 * std::atan(1.0); // 6.2831853071 +static const double cPio180 = 4.0 * std::atan(1.0) / 180.0; // 1.74532925199e-2 +static const double c180oPi = 180.0 / (4.0 * std::atan(1.0)); // 57.2957795131 +#else +static constexpr double cPi = 3.1415926535; +static constexpr double c2Pi = 6.28318530717; +static constexpr double cPio180 = 1.74532925199e-2; +static constexpr double c180oPi = 57.2957795131; +#endif + +static const double one_over_sqrt2 = 1.0 / sqrt(2.0); // 0.707106781 +static const double one_over_sqrt3 = 1.0 / sqrt(3.0); // 0.577350269 +static const double sqrt2 = sqrt(2.0); // 1.4142135 +static const double sqrt3 = sqrt(3.0); // 1.7320508 + +#else +static constexpr float c1o2 = 1.0f / 2.0f; +static constexpr float c3o2 = 3.0f / 2.0f; +static constexpr float c1o3 = 1.0f / 3.0f; +static constexpr float c2o3 = 2.0f / 3.0f; +static constexpr float c1o4 = 1.0f / 4.0f; +static constexpr float c3o4 = 3.0f / 4.0f; +static constexpr float c1o6 = 1.0f / 6.0f; +static constexpr float c1o7 = 1.0f / 7.0f; +static constexpr float c1o8 = 1.0f / 8.0f; +static constexpr float c1o9 = 1.0f / 9.0f; +static constexpr float c2o9 = 2.0f / 9.0f; +static constexpr float c4o9 = 4.0f / 9.0f; +static constexpr float c4o10 = 4.0f / 10.0f; +static constexpr float c1o10 = 1.0f / 10.0f; +static constexpr float c1o12 = 1.0f / 12.0f; +static constexpr float c1o16 = 1.0f / 16.0f; +static constexpr float c3o16 = 3.0f / 16.0f; +static constexpr float c9o16 = 9.0f / 16.0f; +static constexpr float c1o18 = 1.0f / 18.0f; +static constexpr float c1o20 = 1.0f / 20.0f; +static constexpr float c19o20 = 19.0f / 20.0f; +static constexpr float c21o20 = 21.0f / 20.0f; +static constexpr float c1o24 = 1.0f / 24.0f; +static constexpr float c1o27 = 1.0f / 27.0f; +static constexpr float c3o32 = 3.0f / 32.0f; +static constexpr float c4o32 = 4.0f / 32.0f; +static constexpr float c1o36 = 1.0f / 36.0f; +static constexpr float c1o48 = 1.0f / 48.0f; +static constexpr float c1o64 = 1.0f / 64.0f; +static constexpr float c3o64 = 3.0f / 64.0f; +static constexpr float c9o64 = 9.0f / 64.0f; +static constexpr float c27o64 = 27.0f / 64.0f; +static constexpr float c1o66 = 1.0f / 66.0f; +static constexpr float c1o72 = 1.0f / 72.0f; +static constexpr float c1o264 = 1.0f / 264.0f; +static constexpr float c8o27 = 8.0f / 27.0f; +static constexpr float c2o27 = 2.0f / 27.0f; +static constexpr float c1o54 = 1.0f / 54.0f; +static constexpr float c1o100 = 1.0f / 100.0f; +static constexpr float c99o100 = 99.0f / 100.0f; +static constexpr float c1o126 = 1.0f / 126.0f; +static constexpr float c1o216 = 1.0f / 216.0f; +static constexpr float c5o4 = 5.0f / 4.0f; +static constexpr float c4o3 = 4.0f / 3.0f; +static constexpr float c9o4 = 9.0f / 4.0f; +static constexpr float c5o2 = 5.0f / 2.0f; +static constexpr float c9o2 = 9.0f / 2.0f; + +static constexpr float c0o1 = 0.f; +static constexpr float c1o1 = 1.f; +static constexpr float c2o1 = 2.f; +static constexpr float c3o1 = 3.f; +static constexpr float c4o1 = 4.f; +static constexpr float c5o1 = 5.f; +static constexpr float c6o1 = 6.f; +static constexpr float c7o1 = 7.f; +static constexpr float c8o1 = 8.f; +static constexpr float c9o1 = 9.f; +static constexpr float c10o1 = 10.f; +static constexpr float c11o1 = 11.f; +static constexpr float c12o1 = 12.f; +static constexpr float c13o1 = 13.f; +static constexpr float c14o1 = 14.f; +static constexpr float c15o1 = 15.f; +static constexpr float c16o1 = 16.f; +static constexpr float c17o1 = 17.f; +static constexpr float c18o1 = 18.f; +static constexpr float c21o1 = 21.f; +static constexpr float c24o1 = 24.f; +static constexpr float c25o1 = 25.f; +static constexpr float c26o1 = 26.f; +static constexpr float c27o1 = 27.f; +static constexpr float c28o1 = 28.f; +static constexpr float c29o1 = 29.f; +static constexpr float c30o1 = 30.f; +static constexpr float c32o1 = 32.f; +static constexpr float c33o1 = 33.f; +static constexpr float c34o1 = 34.f; +static constexpr float c36o1 = 36.f; +static constexpr float c40o1 = 40.f; +static constexpr float c42o1 = 42.f; +static constexpr float c46o1 = 46.f; +static constexpr float c48o1 = 48.f; +static constexpr float c50o1 = 50.f; +static constexpr float c52o1 = 52.f; +static constexpr float c54o1 = 54.f; +static constexpr float c56o1 = 56.f; +static constexpr float c64o1 = 64.f; +static constexpr float c66o1 = 66.f; +static constexpr float c68o1 = 68.f; +static constexpr float c69o1 = 69.f; +static constexpr float c72o1 = 72.f; +static constexpr float c84o1 = 84.f; +static constexpr float c88o1 = 88.f; +static constexpr float c96o1 = 96.f; +static constexpr float c100o1 = 100.0f; +static constexpr float c130o1 = 130.0f; +static constexpr float c152o1 = 152.0f; +static constexpr float c166o1 = 166.0f; +static constexpr float c195o1 = 195.0f; +static constexpr float c216o1 = 216.0f; +static constexpr float c264o1 = 264.0f; +static constexpr float c290o1 = 290.0f; +static constexpr float c367o1 = 367.0f; + +static constexpr float Op0000002 = 0.0000002f; +static constexpr float c10eM30 = 1e-30f; +static constexpr float c10eM10 = 1e-10f; +static constexpr float smallSingle = 0.0000000002f; + +#ifndef __CUDACC__ +static const float cPi = 4.0f * std::atan(1.0f); // 3.1415926535 +static const float c2Pi = 8.0f * std::atan(1.0f); // 6.2831853071 +static const float cPio180 = 4.0f * std::atan(1.0f) / 180.0f; // 1.74532925199e-2 +static const float c180oPi = 180.0f / (4.0f * std::atan(1.0f)); // 57.2957795131 +#else +static constexpr float cPi = 3.1415926535f; +static constexpr float c2Pi = 6.28318530717f; +static constexpr float cPio180 = 1.74532925199e-2f; +static constexpr float c180oPi = 57.2957795131f; +#endif + +static const float one_over_sqrt2 = 1.0 / sqrtf(2.0); // 0.707106781 +static const float one_over_sqrt3 = 1.0 / sqrtf(3.0); // 0.577350269 +static const float sqrt2 = sqrtf(2.0); // 1.4142135 +static const float sqrt3 = sqrtf(3.0); // 1.7320508 + +#endif + +} + +#endif diff --git a/src/basics/basics/container/CbArray2D.h b/src/basics/container/CbArray2D.h similarity index 100% rename from src/basics/basics/container/CbArray2D.h rename to src/basics/container/CbArray2D.h diff --git a/src/basics/basics/container/CbArray3D.h b/src/basics/container/CbArray3D.h similarity index 100% rename from src/basics/basics/container/CbArray3D.h rename to src/basics/container/CbArray3D.h diff --git a/src/basics/basics/container/CbArray4D.h b/src/basics/container/CbArray4D.h similarity index 100% rename from src/basics/basics/container/CbArray4D.h rename to src/basics/container/CbArray4D.h diff --git a/src/basics/basics/container/CbVector.h b/src/basics/container/CbVector.h similarity index 100% rename from src/basics/basics/container/CbVector.h rename to src/basics/container/CbVector.h diff --git a/src/basics/basics/container/CbVectorPool.h b/src/basics/container/CbVectorPool.h similarity index 100% rename from src/basics/basics/container/CbVectorPool.h rename to src/basics/container/CbVectorPool.h diff --git a/src/basics/geometry3d/GbVoxelMatrix3D.cpp b/src/basics/geometry3d/GbVoxelMatrix3D.cpp index dd0fbfc164f951090eedccc4d9bd7d32a7a038f8..5040b54c8dacbd17317a35c451d82f1ad20b0edf 100644 --- a/src/basics/geometry3d/GbVoxelMatrix3D.cpp +++ b/src/basics/geometry3d/GbVoxelMatrix3D.cpp @@ -39,7 +39,7 @@ #include <geometry3d/GbTriangle3D.h> #include <basics/utilities/UbSystem.h> -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #ifdef MC_CUBES #include <MarchingCubes/MarchingCubes.h> @@ -174,11 +174,11 @@ double GbVoxelMatrix3D::getIntersectionRaytraceFactor(const double &x1, const do const double &rx1, const double &rx2, const double &rx3) { if (!((UbMath::equal(rx1, 0.0) || UbMath::equal(fabs(rx1), 1.0) || - UbMath::equal(fabs(rx1), vf::lbm::constant::one_over_sqrt2) || UbMath::equal(fabs(rx1), vf::lbm::constant::one_over_sqrt3)) && + UbMath::equal(fabs(rx1), vf::basics::constant::one_over_sqrt2) || UbMath::equal(fabs(rx1), vf::basics::constant::one_over_sqrt3)) && (UbMath::equal(rx2, 0.0) || UbMath::equal(fabs(rx2), 1.0) || - UbMath::equal(fabs(rx2), vf::lbm::constant::one_over_sqrt2) || UbMath::equal(fabs(rx2), vf::lbm::constant::one_over_sqrt3)) && + UbMath::equal(fabs(rx2), vf::basics::constant::one_over_sqrt2) || UbMath::equal(fabs(rx2), vf::basics::constant::one_over_sqrt3)) && (UbMath::equal(rx3, 0.0) || UbMath::equal(fabs(rx3), 1.0) || - UbMath::equal(fabs(rx3), vf::lbm::constant::one_over_sqrt2) || UbMath::equal(fabs(rx3), vf::lbm::constant::one_over_sqrt3)))) { + UbMath::equal(fabs(rx3), vf::basics::constant::one_over_sqrt2) || UbMath::equal(fabs(rx3), vf::basics::constant::one_over_sqrt3)))) { throw UbException(UB_EXARGS, "nur fuer diskrete Boltzmannrichungen implementiert!!!"); } diff --git a/src/basics/basics/memory/MbSmartPtr.h b/src/basics/memory/MbSmartPtr.h similarity index 100% rename from src/basics/basics/memory/MbSmartPtr.h rename to src/basics/memory/MbSmartPtr.h diff --git a/src/basics/basics/memory/MbSmartPtrBase.cpp b/src/basics/memory/MbSmartPtrBase.cpp similarity index 100% rename from src/basics/basics/memory/MbSmartPtrBase.cpp rename to src/basics/memory/MbSmartPtrBase.cpp diff --git a/src/basics/basics/memory/MbSmartPtrBase.h b/src/basics/memory/MbSmartPtrBase.h similarity index 100% rename from src/basics/basics/memory/MbSmartPtrBase.h rename to src/basics/memory/MbSmartPtrBase.h diff --git a/src/basics/basics/objects/ObObject.h b/src/basics/objects/ObObject.h similarity index 100% rename from src/basics/basics/objects/ObObject.h rename to src/basics/objects/ObObject.h diff --git a/src/basics/basics/parallel/PbMpi.h b/src/basics/parallel/PbMpi.h similarity index 100% rename from src/basics/basics/parallel/PbMpi.h rename to src/basics/parallel/PbMpi.h diff --git a/src/basics/tests/testUtilities.h b/src/basics/tests/testUtilities.h index 57606edc130b0471b957202420cb12859a9cde84..43fd5d822a10c6e9756c348f3e7dfb71c285ab71 100644 --- a/src/basics/tests/testUtilities.h +++ b/src/basics/tests/testUtilities.h @@ -11,4 +11,12 @@ inline auto RealEq = [](auto value) { #endif }; +inline auto RealNear = [](auto value, auto max_abs_error) { +#ifdef VF_DOUBLE_ACCURACY + return testing::DoubleNear(value, max_abs_error); +#else + return testing::FloatNear(value, max_abs_error); +#endif +}; + #endif diff --git a/src/basics/basics/transmitter/TbTransmitter.h b/src/basics/transmitter/TbTransmitter.h similarity index 100% rename from src/basics/basics/transmitter/TbTransmitter.h rename to src/basics/transmitter/TbTransmitter.h diff --git a/src/basics/basics/transmitter/TbTransmitterLocal.h b/src/basics/transmitter/TbTransmitterLocal.h similarity index 100% rename from src/basics/basics/transmitter/TbTransmitterLocal.h rename to src/basics/transmitter/TbTransmitterLocal.h diff --git a/src/basics/basics/transmitter/TbTransmitterMpiPool.h b/src/basics/transmitter/TbTransmitterMpiPool.h similarity index 100% rename from src/basics/basics/transmitter/TbTransmitterMpiPool.h rename to src/basics/transmitter/TbTransmitterMpiPool.h diff --git a/src/basics/basics/utilities/UbComparators.h b/src/basics/utilities/UbComparators.h similarity index 100% rename from src/basics/basics/utilities/UbComparators.h rename to src/basics/utilities/UbComparators.h diff --git a/src/basics/basics/utilities/UbEqual.h b/src/basics/utilities/UbEqual.h similarity index 100% rename from src/basics/basics/utilities/UbEqual.h rename to src/basics/utilities/UbEqual.h diff --git a/src/basics/basics/utilities/UbException.h b/src/basics/utilities/UbException.h similarity index 100% rename from src/basics/basics/utilities/UbException.h rename to src/basics/utilities/UbException.h diff --git a/src/basics/basics/utilities/UbFileInput.h b/src/basics/utilities/UbFileInput.h similarity index 100% rename from src/basics/basics/utilities/UbFileInput.h rename to src/basics/utilities/UbFileInput.h diff --git a/src/basics/basics/utilities/UbFileInputASCII.cpp b/src/basics/utilities/UbFileInputASCII.cpp similarity index 100% rename from src/basics/basics/utilities/UbFileInputASCII.cpp rename to src/basics/utilities/UbFileInputASCII.cpp diff --git a/src/basics/basics/utilities/UbFileInputASCII.h b/src/basics/utilities/UbFileInputASCII.h similarity index 100% rename from src/basics/basics/utilities/UbFileInputASCII.h rename to src/basics/utilities/UbFileInputASCII.h diff --git a/src/basics/basics/utilities/UbFileInputASCIITest.cfg b/src/basics/utilities/UbFileInputASCIITest.cfg similarity index 100% rename from src/basics/basics/utilities/UbFileInputASCIITest.cfg rename to src/basics/utilities/UbFileInputASCIITest.cfg diff --git a/src/basics/basics/utilities/UbFileInputASCIITest.cpp b/src/basics/utilities/UbFileInputASCIITest.cpp similarity index 100% rename from src/basics/basics/utilities/UbFileInputASCIITest.cpp rename to src/basics/utilities/UbFileInputASCIITest.cpp diff --git a/src/basics/basics/utilities/UbFileInputBinary.cpp b/src/basics/utilities/UbFileInputBinary.cpp similarity index 100% rename from src/basics/basics/utilities/UbFileInputBinary.cpp rename to src/basics/utilities/UbFileInputBinary.cpp diff --git a/src/basics/basics/utilities/UbFileInputBinary.h b/src/basics/utilities/UbFileInputBinary.h similarity index 100% rename from src/basics/basics/utilities/UbFileInputBinary.h rename to src/basics/utilities/UbFileInputBinary.h diff --git a/src/basics/basics/utilities/UbFileOutput.h b/src/basics/utilities/UbFileOutput.h similarity index 100% rename from src/basics/basics/utilities/UbFileOutput.h rename to src/basics/utilities/UbFileOutput.h diff --git a/src/basics/basics/utilities/UbFileOutputASCII.cpp b/src/basics/utilities/UbFileOutputASCII.cpp similarity index 100% rename from src/basics/basics/utilities/UbFileOutputASCII.cpp rename to src/basics/utilities/UbFileOutputASCII.cpp diff --git a/src/basics/basics/utilities/UbFileOutputASCII.h b/src/basics/utilities/UbFileOutputASCII.h similarity index 100% rename from src/basics/basics/utilities/UbFileOutputASCII.h rename to src/basics/utilities/UbFileOutputASCII.h diff --git a/src/basics/basics/utilities/UbFileOutputBinary.cpp b/src/basics/utilities/UbFileOutputBinary.cpp similarity index 100% rename from src/basics/basics/utilities/UbFileOutputBinary.cpp rename to src/basics/utilities/UbFileOutputBinary.cpp diff --git a/src/basics/basics/utilities/UbFileOutputBinary.h b/src/basics/utilities/UbFileOutputBinary.h similarity index 100% rename from src/basics/basics/utilities/UbFileOutputBinary.h rename to src/basics/utilities/UbFileOutputBinary.h diff --git a/src/basics/basics/utilities/UbInfinity.h b/src/basics/utilities/UbInfinity.h similarity index 100% rename from src/basics/basics/utilities/UbInfinity.h rename to src/basics/utilities/UbInfinity.h diff --git a/src/basics/basics/utilities/UbKeys.h b/src/basics/utilities/UbKeys.h similarity index 100% rename from src/basics/basics/utilities/UbKeys.h rename to src/basics/utilities/UbKeys.h diff --git a/src/basics/basics/utilities/UbLimits.h b/src/basics/utilities/UbLimits.h similarity index 100% rename from src/basics/basics/utilities/UbLimits.h rename to src/basics/utilities/UbLimits.h diff --git a/src/basics/basics/utilities/UbLogger.cpp b/src/basics/utilities/UbLogger.cpp similarity index 100% rename from src/basics/basics/utilities/UbLogger.cpp rename to src/basics/utilities/UbLogger.cpp diff --git a/src/basics/basics/utilities/UbLogger.h b/src/basics/utilities/UbLogger.h similarity index 100% rename from src/basics/basics/utilities/UbLogger.h rename to src/basics/utilities/UbLogger.h diff --git a/src/basics/basics/utilities/UbMath.cpp b/src/basics/utilities/UbMath.cpp similarity index 100% rename from src/basics/basics/utilities/UbMath.cpp rename to src/basics/utilities/UbMath.cpp diff --git a/src/basics/basics/utilities/UbMath.h b/src/basics/utilities/UbMath.h similarity index 100% rename from src/basics/basics/utilities/UbMath.h rename to src/basics/utilities/UbMath.h diff --git a/src/basics/basics/utilities/UbNupsTimer.h b/src/basics/utilities/UbNupsTimer.h similarity index 100% rename from src/basics/basics/utilities/UbNupsTimer.h rename to src/basics/utilities/UbNupsTimer.h diff --git a/src/basics/basics/utilities/UbObservable.h b/src/basics/utilities/UbObservable.h similarity index 100% rename from src/basics/basics/utilities/UbObservable.h rename to src/basics/utilities/UbObservable.h diff --git a/src/basics/basics/utilities/UbObserver.h b/src/basics/utilities/UbObserver.h similarity index 100% rename from src/basics/basics/utilities/UbObserver.h rename to src/basics/utilities/UbObserver.h diff --git a/src/basics/basics/utilities/UbRandom.h b/src/basics/utilities/UbRandom.h similarity index 100% rename from src/basics/basics/utilities/UbRandom.h rename to src/basics/utilities/UbRandom.h diff --git a/src/basics/basics/utilities/UbScheduler.h b/src/basics/utilities/UbScheduler.h similarity index 100% rename from src/basics/basics/utilities/UbScheduler.h rename to src/basics/utilities/UbScheduler.h diff --git a/src/basics/basics/utilities/UbStringInputASCII.cpp b/src/basics/utilities/UbStringInputASCII.cpp similarity index 100% rename from src/basics/basics/utilities/UbStringInputASCII.cpp rename to src/basics/utilities/UbStringInputASCII.cpp diff --git a/src/basics/basics/utilities/UbStringInputASCII.h b/src/basics/utilities/UbStringInputASCII.h similarity index 100% rename from src/basics/basics/utilities/UbStringInputASCII.h rename to src/basics/utilities/UbStringInputASCII.h diff --git a/src/basics/basics/utilities/UbSystem.h b/src/basics/utilities/UbSystem.h similarity index 100% rename from src/basics/basics/utilities/UbSystem.h rename to src/basics/utilities/UbSystem.h diff --git a/src/basics/basics/utilities/UbTiming.h b/src/basics/utilities/UbTiming.h similarity index 100% rename from src/basics/basics/utilities/UbTiming.h rename to src/basics/utilities/UbTiming.h diff --git a/src/basics/basics/utilities/UbTuple.h b/src/basics/utilities/UbTuple.h similarity index 100% rename from src/basics/basics/utilities/UbTuple.h rename to src/basics/utilities/UbTuple.h diff --git a/src/basics/basics/utilities/Vector3D.cpp b/src/basics/utilities/Vector3D.cpp similarity index 100% rename from src/basics/basics/utilities/Vector3D.cpp rename to src/basics/utilities/Vector3D.cpp diff --git a/src/basics/basics/utilities/Vector3D.h b/src/basics/utilities/Vector3D.h similarity index 100% rename from src/basics/basics/utilities/Vector3D.h rename to src/basics/utilities/Vector3D.h diff --git a/src/basics/basics/utilities/Vector3DTest.cpp b/src/basics/utilities/Vector3DTest.cpp similarity index 100% rename from src/basics/basics/utilities/Vector3DTest.cpp rename to src/basics/utilities/Vector3DTest.cpp diff --git a/src/basics/basics/writer/WbWriter.h b/src/basics/writer/WbWriter.h similarity index 100% rename from src/basics/basics/writer/WbWriter.h rename to src/basics/writer/WbWriter.h diff --git a/src/basics/basics/writer/WbWriterAvsASCII.cpp b/src/basics/writer/WbWriterAvsASCII.cpp similarity index 100% rename from src/basics/basics/writer/WbWriterAvsASCII.cpp rename to src/basics/writer/WbWriterAvsASCII.cpp diff --git a/src/basics/basics/writer/WbWriterAvsASCII.h b/src/basics/writer/WbWriterAvsASCII.h similarity index 100% rename from src/basics/basics/writer/WbWriterAvsASCII.h rename to src/basics/writer/WbWriterAvsASCII.h diff --git a/src/basics/basics/writer/WbWriterAvsBinary.cpp b/src/basics/writer/WbWriterAvsBinary.cpp similarity index 100% rename from src/basics/basics/writer/WbWriterAvsBinary.cpp rename to src/basics/writer/WbWriterAvsBinary.cpp diff --git a/src/basics/basics/writer/WbWriterAvsBinary.h b/src/basics/writer/WbWriterAvsBinary.h similarity index 100% rename from src/basics/basics/writer/WbWriterAvsBinary.h rename to src/basics/writer/WbWriterAvsBinary.h diff --git a/src/basics/basics/writer/WbWriterBOBJ.cpp b/src/basics/writer/WbWriterBOBJ.cpp similarity index 100% rename from src/basics/basics/writer/WbWriterBOBJ.cpp rename to src/basics/writer/WbWriterBOBJ.cpp diff --git a/src/basics/basics/writer/WbWriterBOBJ.h b/src/basics/writer/WbWriterBOBJ.h similarity index 100% rename from src/basics/basics/writer/WbWriterBOBJ.h rename to src/basics/writer/WbWriterBOBJ.h diff --git a/src/basics/basics/writer/WbWriterSunflow.cpp b/src/basics/writer/WbWriterSunflow.cpp similarity index 100% rename from src/basics/basics/writer/WbWriterSunflow.cpp rename to src/basics/writer/WbWriterSunflow.cpp diff --git a/src/basics/basics/writer/WbWriterSunflow.h b/src/basics/writer/WbWriterSunflow.h similarity index 100% rename from src/basics/basics/writer/WbWriterSunflow.h rename to src/basics/writer/WbWriterSunflow.h diff --git a/src/basics/basics/writer/WbWriterTecPlotASCII.cpp b/src/basics/writer/WbWriterTecPlotASCII.cpp similarity index 100% rename from src/basics/basics/writer/WbWriterTecPlotASCII.cpp rename to src/basics/writer/WbWriterTecPlotASCII.cpp diff --git a/src/basics/basics/writer/WbWriterTecPlotASCII.h b/src/basics/writer/WbWriterTecPlotASCII.h similarity index 100% rename from src/basics/basics/writer/WbWriterTecPlotASCII.h rename to src/basics/writer/WbWriterTecPlotASCII.h diff --git a/src/basics/basics/writer/WbWriterVtkASCII.cpp b/src/basics/writer/WbWriterVtkASCII.cpp similarity index 100% rename from src/basics/basics/writer/WbWriterVtkASCII.cpp rename to src/basics/writer/WbWriterVtkASCII.cpp diff --git a/src/basics/basics/writer/WbWriterVtkASCII.h b/src/basics/writer/WbWriterVtkASCII.h similarity index 100% rename from src/basics/basics/writer/WbWriterVtkASCII.h rename to src/basics/writer/WbWriterVtkASCII.h diff --git a/src/basics/basics/writer/WbWriterVtkBinary.cpp b/src/basics/writer/WbWriterVtkBinary.cpp similarity index 100% rename from src/basics/basics/writer/WbWriterVtkBinary.cpp rename to src/basics/writer/WbWriterVtkBinary.cpp diff --git a/src/basics/basics/writer/WbWriterVtkBinary.h b/src/basics/writer/WbWriterVtkBinary.h similarity index 100% rename from src/basics/basics/writer/WbWriterVtkBinary.h rename to src/basics/writer/WbWriterVtkBinary.h diff --git a/src/basics/basics/writer/WbWriterVtkXmlASCII.cpp b/src/basics/writer/WbWriterVtkXmlASCII.cpp similarity index 100% rename from src/basics/basics/writer/WbWriterVtkXmlASCII.cpp rename to src/basics/writer/WbWriterVtkXmlASCII.cpp diff --git a/src/basics/basics/writer/WbWriterVtkXmlASCII.h b/src/basics/writer/WbWriterVtkXmlASCII.h similarity index 100% rename from src/basics/basics/writer/WbWriterVtkXmlASCII.h rename to src/basics/writer/WbWriterVtkXmlASCII.h diff --git a/src/basics/basics/writer/WbWriterVtkXmlBinary.cpp b/src/basics/writer/WbWriterVtkXmlBinary.cpp similarity index 100% rename from src/basics/basics/writer/WbWriterVtkXmlBinary.cpp rename to src/basics/writer/WbWriterVtkXmlBinary.cpp diff --git a/src/basics/basics/writer/WbWriterVtkXmlBinary.h b/src/basics/writer/WbWriterVtkXmlBinary.h similarity index 100% rename from src/basics/basics/writer/WbWriterVtkXmlBinary.h rename to src/basics/writer/WbWriterVtkXmlBinary.h diff --git a/src/basics/basics/writer/WbWriterVtkXmlImageBinary.cpp b/src/basics/writer/WbWriterVtkXmlImageBinary.cpp similarity index 100% rename from src/basics/basics/writer/WbWriterVtkXmlImageBinary.cpp rename to src/basics/writer/WbWriterVtkXmlImageBinary.cpp diff --git a/src/basics/basics/writer/WbWriterVtkXmlImageBinary.h b/src/basics/writer/WbWriterVtkXmlImageBinary.h similarity index 100% rename from src/basics/basics/writer/WbWriterVtkXmlImageBinary.h rename to src/basics/writer/WbWriterVtkXmlImageBinary.h diff --git a/src/basics/basics/writer/WbWriterX3D.cpp b/src/basics/writer/WbWriterX3D.cpp similarity index 100% rename from src/basics/basics/writer/WbWriterX3D.cpp rename to src/basics/writer/WbWriterX3D.cpp diff --git a/src/basics/basics/writer/WbWriterX3D.h b/src/basics/writer/WbWriterX3D.h similarity index 100% rename from src/basics/basics/writer/WbWriterX3D.h rename to src/basics/writer/WbWriterX3D.h diff --git a/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.cpp b/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.cpp deleted file mode 100644 index 6f32a053afb4f6f45ae74e32b7f8665ab4fd58db..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include "CreateDemObjectsCoProcessor.h" -#include <mpi/Communicator.h> -#include "DemCoProcessor.h" -#include "EquilibriumReconstructor.h" -#include "ExtrapolationReconstructor.h" -#include "GbSphere3D.h" -#include "Grid3D.h" -#include "LBMReconstructor.h" -#include "MovableObjectInteractor.h" -#include "NoSlipBCAlgorithm.h" -#include "PePhysicsEngineMaterialAdapter.h" -#include "PhysicsEngineMaterialAdapter.h" -#include "SetBcBlocksBlockVisitor.h" -#include "UbScheduler.h" -#include "VelocityBCAdapter.h" -#include "VelocityBCAlgorithm.h" -#include "VelocityBcReconstructor.h" -#include "VelocityWithDensityBCAlgorithm.h" -#include "muParser.h" - -CreateDemObjectsCoProcessor::CreateDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - std::shared_ptr<vf::mpi::Communicator> comm, - SPtr<DemCoProcessor> demCoProcessor, - SPtr<PhysicsEngineMaterialAdapter> demObjectMaterial, - double tolerance) - : CoProcessor(grid, s), comm(comm), demCoProcessor(demCoProcessor), demObjectMaterial(demObjectMaterial), - tolerance(tolerance) -{ - mu::Parser fct; - fct.SetExpr("U"); - fct.DefineConst("U", 0.0); - velocityBcParticleAdapter = - SPtr<BCAdapter>(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST)); - velocityBcParticleAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityWithDensityBCAlgorithm())); - - // const std::shared_ptr<Reconstructor> velocityReconstructor(new VelocityBcReconstructor()); - std::shared_ptr<Reconstructor> equilibriumReconstructor(new EquilibriumReconstructor()); - // const std::shared_ptr<Reconstructor> lbmReconstructor(new LBMReconstructor(false)); - extrapolationReconstructor = SPtr<Reconstructor>(new ExtrapolationReconstructor(equilibriumReconstructor)); - demCounter = 0; -} -////////////////////////////////////////////////////////////////////////// -void CreateDemObjectsCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) { - int istep = static_cast<int>(step); - -#ifdef TIMING - if (comm->isRoot()) - UBLOG(logINFO, "CreateDemObjectsCoProcessor::process start step: " << istep); - timer.resetAndStart(); -#endif - - createGeoObjects(); - -#ifdef TIMING - // if (comm->isRoot()) UBLOG(logINFO, "createGeoObjects() time = "<<timer.stop()<<" s"); - // if (comm->isRoot()) UBLOG(logINFO, "number of objects = "<<(int)(geoObjectPrototypeVector.size())); - // if (comm->isRoot()) UBLOG(logINFO, "total number of objects = "<<demCounter); - if (comm->isRoot()) - UBLOG(logINFO, "CreateDemObjectsCoProcessor::process stop step: " << istep); -#endif - - // demCoProcessor->distributeIDs(); - - //#ifdef TIMING - // if (comm->isRoot()) UBLOG(logINFO, "demCoProcessor->distributeIDs() time = "<<timer.stop()<<" s"); - //#endif - } -} -////////////////////////////////////////////////////////////////////////// -void CreateDemObjectsCoProcessor::addGeoObject(SPtr<GbObject3D> geoObjectPrototype, Vector3D initalVelocity) -{ - geoObjectPrototypeVector.push_back(geoObjectPrototype); - this->initalVelocity.push_back(initalVelocity); -} - -void CreateDemObjectsCoProcessor::clearGeoObjects() -{ - geoObjectPrototypeVector.clear(); - initalVelocity.clear(); -} - -void CreateDemObjectsCoProcessor::createGeoObjects() -{ - int size = (int)(geoObjectPrototypeVector.size()); - - std::vector<std::shared_ptr<Block3D>> blockVector; - - for (int i = 0; i < size; i++) { - SPtr<GbSphere3D> sphere = std::dynamic_pointer_cast<GbSphere3D>(geoObjectPrototypeVector[i]); - if (demCoProcessor->isSpheresIntersection(sphere->getX1Centroid(), sphere->getX2Centroid(), - sphere->getX3Centroid(), - sphere->getRadius() * 2.0 * (1.0 - tolerance))) { - continue; - } - - SPtr<GbObject3D> geoObject((GbObject3D *)(geoObjectPrototypeVector[i]->clone())); - SPtr<MovableObjectInteractor> geoObjectInt = SPtr<MovableObjectInteractor>(new MovableObjectInteractor( - geoObject, grid, velocityBcParticleAdapter, Interactor3D::SOLID, extrapolationReconstructor, State::UNPIN)); - demCoProcessor->addInteractor(geoObjectInt, demObjectMaterial, initalVelocity[i]); - demCounter++; - } - -#ifdef TIMING - if (comm->isRoot()) - UBLOG(logINFO, "createGeoObjects() time = " << timer.stop() << " s"); - if (comm->isRoot()) - UBLOG(logINFO, "number of objects = " << (int)(geoObjectPrototypeVector.size())); - if (comm->isRoot()) - UBLOG(logINFO, "total number of objects = " << demCounter); - // if (comm->isRoot()) UBLOG(logINFO, "CreateDemObjectsCoProcessor::process stop step: " << istep); -#endif - - demCoProcessor->distributeIDs(); - -#ifdef TIMING - if (comm->isRoot()) - UBLOG(logINFO, "demCoProcessor->distributeIDs() time = " << timer.stop() << " s"); -#endif -} diff --git a/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.h b/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.h deleted file mode 100644 index 7da317e67bd932f7d594c68d63ebc117b50c1e85..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef CreateSphereCoProcessor_h__ -#define CreateSphereCoProcessor_h__ - -#include "CoProcessor.h" -#include "Vector3D.h" -#include <array> -#include <vector> - -//#define TIMING - -#ifdef TIMING -#include "UbTiming.h" -#endif - -class Grid3D; -class UbScheduler; -namespace vf::mpi {class Communicator;} -class DemCoProcessor; -class GbObject3D; -class BCAdapter; -class Reconstructor; -class PhysicsEngineMaterialAdapter; - -class CreateDemObjectsCoProcessor : public CoProcessor -{ -public: - CreateDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, std::shared_ptr<vf::mpi::Communicator> comm, - SPtr<DemCoProcessor> demCoProcessor, - SPtr<PhysicsEngineMaterialAdapter> geoObjectMaterial, double tolerance = 0); - void process(double step) override; - void addGeoObject(SPtr<GbObject3D> geoObjectPrototype, Vector3D initalVelocity); - void clearGeoObjects(); - void createGeoObjects(); - double getToleranz() const { return tolerance; } - void setToleranz(double val) { tolerance = val; } - -protected: -private: - std::shared_ptr<vf::mpi::Communicator> comm; - SPtr<DemCoProcessor> demCoProcessor; - std::vector<SPtr<GbObject3D>> geoObjectPrototypeVector; - SPtr<PhysicsEngineMaterialAdapter> demObjectMaterial; - std::vector<Vector3D> initalVelocity; - SPtr<BCAdapter> velocityBcParticleAdapter; - SPtr<Reconstructor> extrapolationReconstructor; - int demCounter; - double tolerance; -#ifdef TIMING - UbTimer timer; -#endif -}; -#endif // CreateSphereCoProcessor_h__ diff --git a/src/cpu/DemCoupling/DemCoProcessor.cpp b/src/cpu/DemCoupling/DemCoProcessor.cpp deleted file mode 100644 index 642a942d7d96b73af898690a5737f53d2d88b1a5..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/DemCoProcessor.cpp +++ /dev/null @@ -1,515 +0,0 @@ -#include "DemCoProcessor.h" - -#include "BCProcessor.h" -#include <mpi/Communicator.h> -#include "DataSet3D.h" -#include "DistributionArray3D.h" -#include "ForceCalculator.h" -#include "GbSphere3D.h" -#include "Grid3D.h" -#include "ILBMKernel.h" -#include "MovableObjectInteractor.h" -#include "SetBcBlocksBlockVisitor.h" -#include "UbScheduler.h" - -#include "PePhysicsEngineGeometryAdapter.h" -#include "PePhysicsEngineSolverAdapter.h" -#include "PhysicsEngineGeometryAdapter.h" -#include "PhysicsEngineMaterialAdapter.h" -#include "PhysicsEngineSolverAdapter.h" - -#include "BCArray3D.h" -#include "Block3D.h" -#include "BoundaryConditions.h" -#include "BoundaryConditionsBlockVisitor.h" -#include "MPICommunicator.h" - -#include "UbLogger.h" - -#include <array> -#include <functional> - -DemCoProcessor::DemCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, std::shared_ptr<vf::mpi::Communicator> comm, - std::shared_ptr<ForceCalculator> forceCalculator, - std::shared_ptr<PhysicsEngineSolverAdapter> physicsEngineSolver, - double intermediatePeSteps) - : CoProcessor(grid, s), comm(comm), forceCalculator(forceCalculator), - physicsEngineSolver(std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)), - intermediateDemSteps(intermediatePeSteps) -{ -#ifdef TIMING - timer.resetAndStart(); -#endif - - std::shared_ptr<walberla::blockforest::BlockForest> forest = - std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getBlockForest(); - std::shared_ptr<walberla::domain_decomposition::BlockDataID> storageId = - std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getStorageId(); - - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) { - walberla::pe::Storage *storage = blockIt->getData<walberla::pe::Storage>(*storageId.get()); - walberla::pe::BodyStorage *bodyStorage = &(*storage)[0]; - walberla::pe::BodyStorage *bodyStorageShadowCopies = &(*storage)[1]; - - bodyStorage->registerAddCallback("DemCoProcessor", std::bind1st(std::mem_fun(&DemCoProcessor::addPeGeo), this)); - bodyStorage->registerRemoveCallback("DemCoProcessor", - std::bind1st(std::mem_fun(&DemCoProcessor::removePeGeo), this)); - - bodyStorageShadowCopies->registerAddCallback("DemCoProcessor", - std::bind1st(std::mem_fun(&DemCoProcessor::addPeShadowGeo), this)); - bodyStorageShadowCopies->registerRemoveCallback( - "DemCoProcessor", std::bind1st(std::mem_fun(&DemCoProcessor::removePeShadowGeo), this)); - } -} - -DemCoProcessor::~DemCoProcessor() -{ - std::shared_ptr<walberla::blockforest::BlockForest> forest = - std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getBlockForest(); - std::shared_ptr<walberla::domain_decomposition::BlockDataID> storageId = - std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getStorageId(); - - for (auto ¤tBlock : *forest) { - walberla::pe::Storage *storage = currentBlock.getData<walberla::pe::Storage>(*storageId.get()); - walberla::pe::BodyStorage &localStorage = (*storage)[0]; - walberla::pe::BodyStorage &shadowStorage = (*storage)[1]; - - localStorage.clearAddCallbacks(); - localStorage.clearRemoveCallbacks(); - - shadowStorage.clearAddCallbacks(); - shadowStorage.clearRemoveCallbacks(); - } -} - -void DemCoProcessor::addInteractor(std::shared_ptr<MovableObjectInteractor> interactor, - std::shared_ptr<PhysicsEngineMaterialAdapter> physicsEngineMaterial, - Vector3D initalVelocity) -{ - interactors.push_back(interactor); - const int id = static_cast<int>(interactors.size() - 1); - interactor->setID(id); - const auto peGeometryAdapter = this->createPhysicsEngineGeometryAdapter(interactor, physicsEngineMaterial); - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(peGeometryAdapter)->isActive()) { - peGeometryAdapter->setLinearVelolocity(initalVelocity); - geoIdMap.insert( - std::make_pair(std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(peGeometryAdapter)->getSystemID(), - std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(peGeometryAdapter))); - } - SetBcBlocksBlockVisitor setBcVisitor(interactor); - grid->accept(setBcVisitor); - - // std::vector< std::shared_ptr<Block3D> > blockVector; - // UbTupleInt3 blockNX=grid->getBlockNX(); - // SPtr<GbObject3D> geoObject(interactor->getGbObject3D()); - // double ext = 0.0; - // std::array<double, 6> AABB ={ - // geoObject->getX1Minimum(),geoObject->getX2Minimum(),geoObject->getX3Minimum(),geoObject->getX1Maximum(),geoObject->getX2Maximum(),geoObject->getX3Maximum() - // }; grid->getBlocksByCuboid(AABB[0]-(double)val<1>(blockNX)*ext, AABB[1]-(double)val<2>(blockNX)*ext, - // AABB[2]-(double)val<3>(blockNX)*ext, AABB[3]+(double)val<1>(blockNX)*ext, AABB[4]+(double)val<2>(blockNX)*ext, - // AABB[5]+(double)val<3>(blockNX)*ext, blockVector); for (std::shared_ptr<Block3D> block : blockVector) - //{ - // if (block->getKernel()) - // { - // interactor->setBCBlock(block); - // //UBLOG(logINFO, "DemCoProcessor::addInteractor() rank = "<<comm->getProcessID()); - // } - //} - - interactor->initInteractor(); - - physicsEngineGeometrieAdapters.push_back(peGeometryAdapter); -} - -std::shared_ptr<PhysicsEngineGeometryAdapter> DemCoProcessor::createPhysicsEngineGeometryAdapter( - std::shared_ptr<MovableObjectInteractor> interactor, - std::shared_ptr<PhysicsEngineMaterialAdapter> physicsEngineMaterial) const -{ - const int id = static_cast<int>(interactors.size() - 1); - SPtr<GbSphere3D> vfSphere = std::static_pointer_cast<GbSphere3D>(interactor->getGbObject3D()); - const Vector3D position(vfSphere->getX1Centroid(), vfSphere->getX2Centroid(), vfSphere->getX3Centroid()); - auto peGeometryAdapter = this->physicsEngineSolver->createPhysicsEngineGeometryAdapter( - id, position, vfSphere->getRadius(), physicsEngineMaterial); - interactor->setPhysicsEngineGeometry(peGeometryAdapter); - return peGeometryAdapter; -} - -void DemCoProcessor::process(double actualTimeStep) -{ -#ifdef TIMING - timer.resetAndStart(); -#endif - - this->applyForcesOnGeometries(); - -#ifdef TIMING - if (comm->isRoot()) - UBLOG(logINFO, "DemCoProcessor::process start step: " << actualTimeStep); - if (comm->isRoot()) - UBLOG(logINFO, "DemCoProcessor::applyForcesOnGeometries() time = " << timer.stop() << " s"); -#endif - - if (scheduler->isDue(actualTimeStep)) { - // UBLOG(logINFO, "DemCoProcessor::update - START - timestep = " << actualTimeStep); - const double demTimeStepsPerIteration = scheduler->getMinStep(); - - if (demTimeStepsPerIteration != 1) - this->scaleForcesAndTorques(1.0 / demTimeStepsPerIteration); - -#ifdef TIMING - if (comm->isRoot()) - UBLOG(logINFO, "DemCoProcessor::scaleForcesAndTorques() time = " << timer.stop() << " s"); - if (comm->isRoot()) - UBLOG(logINFO, "DemCoProcessor::calculateDemTimeStep():"); -#endif - - if (this->intermediateDemSteps == 1) - this->calculateDemTimeStep(demTimeStepsPerIteration); - - //#ifdef TIMING - // if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::calculateDemTimeStep() time = "<<timer.stop()<<" - // s"); - //#endif - // if ((int)actualTimeStep % 100 == 0) - //{ - // if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometries[0])->isActive()) - // { - // //UBLOG(logINFO, "v: (x,y,z) " << physicsEngineGeometries[0]->getLinearVelocity() << " actualTimeStep - // = " << UbSystem::toString(actualTimeStep)); - // } - //} - - // during the intermediate time steps of the collision response, the currently acting forces - // (interaction forces, gravitational force, ...) have to remain constant. - // Since they are reset after the call to collision response, they have to be stored explicitly before. - // Then they are set again after each intermediate step. - - this->moveVfGeoObjects(); - -#ifdef TIMING - if (comm->isRoot()) - UBLOG(logINFO, "DemCoProcessor::moveVfGeoObject() time = " << timer.stop() << " s"); -#endif - - grid->accept(*boundaryConditionsBlockVisitor.get()); - -#ifdef TIMING - if (comm->isRoot()) - UBLOG(logINFO, "grid->accept(*boundaryConditionsBlockVisitor.get()) time = " << timer.stop() << " s"); -#endif - - // UBLOG(logINFO, "DemCoProcessor::update - END - timestep = " << actualTimeStep); - } - -#ifdef TIMING - if (comm->isRoot()) - UBLOG(logINFO, "DemCoProcessor::process stop step: " << actualTimeStep); -#endif -} -////////////////////////////////////////////////////////////////////////// -std::shared_ptr<PhysicsEngineSolverAdapter> DemCoProcessor::getPhysicsEngineSolver() { return physicsEngineSolver; } - -void DemCoProcessor::applyForcesOnGeometries() -{ - for (int i = 0; i < physicsEngineGeometrieAdapters.size(); i++) { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) { - this->setForcesToObject(grid, interactors[i], physicsEngineGeometrieAdapters[i]); - - // physicsEngineGeometries[i]->setLinearVelolocity(Vector3D(-0.001, 0.0, 0.0)); - // physicsEngineGeometries[i]->setAngularVelocity(Vector3D(0.01, 0.01, 0.01)); - // UBLOG(logINFO, "v: (x,y,z) " << physicsEngineGeometries[i]->getLinearVelocity()); - } - } -} - -void DemCoProcessor::setForcesToObject(SPtr<Grid3D> grid, SPtr<MovableObjectInteractor> interactor, - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry) -{ - for (BcNodeIndicesMap::value_type t : interactor->getBcNodeIndicesMap()) { - SPtr<Block3D> block = t.first; - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - distributions->swap(); - - std::set<std::vector<int>> &transNodeIndicesSet = t.second; - for (std::vector<int> node : transNodeIndicesSet) { - int x1 = node[0]; - int x2 = node[1]; - int x3 = node[2]; - - if (kernel->isInsideOfDomain(x1, x2, x3) && bcArray->isFluid(x1, x2, x3)) { - // TODO: calculate assumed boundary position - - const Vector3D worldCoordinates = grid->getNodeCoordinates(block, x1, x2, x3); - const auto boundaryVelocity = physicsEngineGeometry->getVelocityAtPosition(worldCoordinates); - - SPtr<BoundaryConditions> bc = bcArray->getBC(x1, x2, x3); - const Vector3D force = forceCalculator->getForces(x1, x2, x3, distributions, bc, boundaryVelocity); - physicsEngineGeometry->addForceAtPosition(force, worldCoordinates); - } - } - distributions->swap(); - } -} - -void DemCoProcessor::scaleForcesAndTorques(double scalingFactor) -{ - for (int i = 0; i < physicsEngineGeometrieAdapters.size(); i++) { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) { - const Vector3D force = physicsEngineGeometrieAdapters[i]->getForce() * scalingFactor; - const Vector3D torque = physicsEngineGeometrieAdapters[i]->getTorque() * scalingFactor; - - physicsEngineGeometrieAdapters[i]->resetForceAndTorque(); - - physicsEngineGeometrieAdapters[i]->setForce(force); - physicsEngineGeometrieAdapters[i]->setTorque(torque); - - // UBLOG(logINFO, "F: (x,y,z) " << force); - // UBLOG(logINFO, "T: (x,y,z) " << torque); - } - } -} - -void DemCoProcessor::calculateDemTimeStep(double step) -{ - physicsEngineSolver->runTimestep(step); - -#ifdef TIMING - if (comm->isRoot()) - UBLOG(logINFO, " physicsEngineSolver->runTimestep() time = " << timer.stop() << " s"); -#endif -} - -void DemCoProcessor::moveVfGeoObjects() -{ - for (int i = 0; i < interactors.size(); i++) { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i]) - ->getSemiactive()) { - walberla::pe::RigidBody *peGeoObject = getPeGeoObject( - std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i]) - ->getSystemID()); - if (peGeoObject != nullptr) { - std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i]) - ->setGeometry(peGeoObject); - interactors[i]->moveGbObjectTo(physicsEngineGeometrieAdapters[i]->getPosition()); - std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i]) - ->setSemiactive(false); - } else { - std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i]) - ->setInactive(); - } - } else { - interactors[i]->moveGbObjectTo(physicsEngineGeometrieAdapters[i]->getPosition()); - } - } - } -} - -bool DemCoProcessor::isDemObjectInAABB(std::array<double, 6> AABB) -{ - bool result = false; - for (int i = 0; i < interactors.size(); i++) { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) { - SPtr<GbObject3D> geoObject = interactors[i]->getGbObject3D(); - std::array<double, 2> minMax1; - std::array<double, 2> minMax2; - std::array<double, 2> minMax3; - minMax1[0] = geoObject->getX1Minimum(); - minMax2[0] = geoObject->getX2Minimum(); - minMax3[0] = geoObject->getX3Minimum(); - minMax1[1] = geoObject->getX1Maximum(); - minMax2[1] = geoObject->getX2Maximum(); - minMax3[1] = geoObject->getX3Maximum(); - - for (int x3 = 0; x3 < 2; x3++) - for (int x2 = 0; x2 < 2; x2++) - for (int x1 = 0; x1 < 2; x1++) { - result = - result || (minMax1[x1] >= AABB[0] && minMax2[x2] >= AABB[1] && minMax3[x3] >= AABB[2] && - minMax1[x1] <= AABB[3] && minMax2[x2] <= AABB[4] && minMax3[x3] <= AABB[5]); - } - } - } - - std::vector<int> values; - values.push_back((int)result); - std::vector<int> rvalues = comm->gather(values); - - if (comm->isRoot()) { - for (int i = 0; i < (int)rvalues.size(); i++) { - result = result || (bool)rvalues[i]; - } - } - int iresult = (int)result; - comm->broadcast(iresult); - result = (bool)iresult; - - return result; -} - -int DemCoProcessor::addSurfaceTriangleSet(std::vector<UbTupleFloat3> &nodes, std::vector<UbTupleInt3> &triangles) -{ - for (int i = 0; i < interactors.size(); i++) { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) { - interactors[i]->getGbObject3D()->addSurfaceTriangleSet(nodes, triangles); - } - } - return (int)interactors.size(); -} - -void DemCoProcessor::getObjectsPropertiesVector(std::vector<double> &p) -{ - for (int i = 0; i < interactors.size(); i++) { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) { - p.push_back(i); - p.push_back(interactors[i]->getGbObject3D()->getX1Centroid()); - p.push_back(interactors[i]->getGbObject3D()->getX2Centroid()); - p.push_back(interactors[i]->getGbObject3D()->getX3Centroid()); - Vector3D v = physicsEngineGeometrieAdapters[i]->getLinearVelocity(); - p.push_back(v[0]); - p.push_back(v[1]); - p.push_back(v[2]); - } - } -} - -void DemCoProcessor::addPeGeo(walberla::pe::RigidBody *peGeo) -{ - auto geometry = getPeGeoAdapter(peGeo->getSystemID()); - if (geometry != nullptr) { - geometry->setActive(); - geometry->setGeometry(peGeo); - return; - } else - return; -} - -void DemCoProcessor::removePeGeo(walberla::pe::RigidBody *peGeo) -{ - auto geometry = getPeGeoAdapter(peGeo->getSystemID()); - if (geometry != nullptr) { - geometry->setSemiactive(true); - } else - throw UbException(UB_EXARGS, "PeGeo SystemId=" + UbSystem::toString(peGeo->getSystemID()) + - " is not matching geometry ID"); -} - -void DemCoProcessor::addPeShadowGeo(walberla::pe::RigidBody *peGeo) -{ - auto geometry = getPeGeoAdapter(peGeo->getSystemID()); - if (geometry != nullptr) { - geometry->setActive(); - geometry->setGeometry(peGeo); - return; - } else - throw UbException(UB_EXARGS, - "PeGeo ID=" + UbSystem::toString(peGeo->getSystemID()) + " is not matching geometry ID"); -} - -void DemCoProcessor::removePeShadowGeo(walberla::pe::RigidBody *peGeo) -{ - auto geometry = getPeGeoAdapter(peGeo->getSystemID()); - - if (geometry != nullptr) { - geometry->setSemiactive(true); - } else - throw UbException(UB_EXARGS, - "PeGeo ID=" + UbSystem::toString(peGeo->getSystemID()) + " is not matching geometry ID"); -} - -bool DemCoProcessor::isSpheresIntersection(double centerX1, double centerX2, double centerX3, double d) -{ - bool result = false; - for (int i = 0; i < interactors.size(); i++) { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) { - SPtr<GbObject3D> sphere = interactors[i]->getGbObject3D(); - result = result || - (sqrt(pow(sphere->getX1Centroid() - centerX1, 2.0) + pow(sphere->getX2Centroid() - centerX2, 2.0) + - pow(sphere->getX3Centroid() - centerX3, 2.0)) <= d); - } - } - std::vector<int> values; - values.push_back((int)result); - std::vector<int> rvalues = comm->gather(values); - - if (comm->isRoot()) { - for (int i = 0; i < (int)rvalues.size(); i++) { - result = result || (bool)rvalues[i]; - } - } - int iresult = (int)result; - comm->broadcast(iresult); - result = (bool)iresult; - - return result; -} - -void DemCoProcessor::distributeIDs() -{ - std::vector<unsigned long long> peIDsSend; - std::vector<int> vfIDsSend; - - for (int i = 0; i < interactors.size(); i++) { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) { - peIDsSend.push_back( - std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i]) - ->getSystemID()); - vfIDsSend.push_back(interactors[i]->getID()); - } - } - - std::vector<unsigned long long> peIDsRecv; - std::vector<int> vfIDsRecv; - - comm->allGather(peIDsSend, peIDsRecv); - comm->allGather(vfIDsSend, vfIDsRecv); - - std::map<int, unsigned long long> idMap; - - for (int i = 0; i < peIDsRecv.size(); i++) { - idMap.insert(std::make_pair(vfIDsRecv[i], peIDsRecv[i])); - } - - for (int i = 0; i < interactors.size(); i++) { - std::map<int, unsigned long long>::const_iterator it; - if ((it = idMap.find(interactors[i]->getID())) == idMap.end()) { - throw UbException(UB_EXARGS, "Interactor ID = " + UbSystem::toString(interactors[i]->getID()) + - " is invalid! The DEM object may be not in PE domain!"); - } - - std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i]) - ->setSystemID(it->second); - - geoIdMap.insert(std::make_pair( - it->second, std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i]))); - } -} -////////////////////////////////////////////////////////////////////////// -void DemCoProcessor::setBlockVisitor(std::shared_ptr<BoundaryConditionsBlockVisitor> boundaryConditionsBlockVisitor) -{ - this->boundaryConditionsBlockVisitor = boundaryConditionsBlockVisitor; -} -////////////////////////////////////////////////////////////////////////// -walberla::pe::RigidBody *DemCoProcessor::getPeGeoObject(walberla::id_t id) -{ - std::shared_ptr<walberla::blockforest::BlockForest> forest = - std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getBlockForest(); - std::shared_ptr<walberla::domain_decomposition::BlockDataID> storageId = - std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getStorageId(); - std::shared_ptr<walberla::pe::BodyStorage> globalBodyStorage = - std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getGlobalBodyStorage(); - - return walberla::pe::getBody(*globalBodyStorage, *forest, *storageId, id, - walberla::pe::StorageSelect::LOCAL | walberla::pe::StorageSelect::SHADOW); -} -//////////////////////////////////////////////////////////////////////////// -std::shared_ptr<PePhysicsEngineGeometryAdapter> DemCoProcessor::getPeGeoAdapter(unsigned long long systemId) -{ - std::map<unsigned long long, std::shared_ptr<PePhysicsEngineGeometryAdapter>>::const_iterator it; - if ((it = geoIdMap.find(systemId)) == geoIdMap.end()) { - return nullptr; - } else - return it->second; -} diff --git a/src/cpu/DemCoupling/DemCoProcessor.h b/src/cpu/DemCoupling/DemCoProcessor.h deleted file mode 100644 index d2946f1e93fcaedc69d44a83a68dc2079910e48f..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/DemCoProcessor.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef DEM_CO_PROCESSOR_H -#define DEM_CO_PROCESSOR_H - -#include <map> -#include <memory> -#include <vector> - -#include "Vector3D.h" - -#include "CoProcessor.h" -#include "UbTuple.h" - -#include <pe/basic.h> - -//#define TIMING - -#ifdef TIMING -#include "UbTiming.h" -#endif - -class PhysicsEngineGeometryAdapter; -class PhysicsEngineSolverAdapter; -class PePhysicsEngineSolverAdapter; -class PhysicsEngineMaterialAdapter; -class PePhysicsEngineGeometryAdapter; - -class UbScheduler; -class Grid3D; -class ForceCalculator; -namespace vf::mpi {class Communicator;} -class MovableObjectInteractor; -class BoundaryConditionsBlockVisitor; - -class DemCoProcessor : public CoProcessor -{ -public: - DemCoProcessor(std::shared_ptr<Grid3D> grid, std::shared_ptr<UbScheduler> s, std::shared_ptr<vf::mpi::Communicator> comm, - std::shared_ptr<ForceCalculator> forceCalculator, - std::shared_ptr<PhysicsEngineSolverAdapter> physicsEngineSolver, double intermediatePeSteps = 1.0); - virtual ~DemCoProcessor(); - - void addInteractor(std::shared_ptr<MovableObjectInteractor> interactor, - std::shared_ptr<PhysicsEngineMaterialAdapter> physicsEngineMaterial, - Vector3D initalVelocity = Vector3D(0.0, 0.0, 0.0)); - void process(double step) override; - std::shared_ptr<PhysicsEngineSolverAdapter> getPhysicsEngineSolver(); - void distributeIDs(); - void setBlockVisitor(std::shared_ptr<BoundaryConditionsBlockVisitor> blockVisitor); - bool isDemObjectInAABB(std::array<double, 6> AABB); - int addSurfaceTriangleSet(std::vector<UbTupleFloat3> &nodes, std::vector<UbTupleInt3> &triangles); - void getObjectsPropertiesVector(std::vector<double> &p); - void addPeGeo(walberla::pe::RigidBody *peGeo); - void removePeGeo(walberla::pe::RigidBody *peGeo); - void addPeShadowGeo(walberla::pe::RigidBody *peGeo); - void removePeShadowGeo(walberla::pe::RigidBody *peGeo); - bool isSpheresIntersection(double centerX1, double centerX2, double centerX3, double d); - -private: - std::shared_ptr<PhysicsEngineGeometryAdapter> - createPhysicsEngineGeometryAdapter(std::shared_ptr<MovableObjectInteractor> interactor, - std::shared_ptr<PhysicsEngineMaterialAdapter> physicsEngineMaterial) const; - void applyForcesOnGeometries(); - void setForcesToObject(SPtr<Grid3D> grid, std::shared_ptr<MovableObjectInteractor> interactor, - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry); - void scaleForcesAndTorques(double scalingFactor); - void calculateDemTimeStep(double step); - void moveVfGeoObjects(); - walberla::pe::RigidBody *getPeGeoObject(walberla::id_t id); - std::shared_ptr<PePhysicsEngineGeometryAdapter> getPeGeoAdapter(unsigned long long systemId); - -private: - std::shared_ptr<vf::mpi::Communicator> comm; - std::vector<std::shared_ptr<MovableObjectInteractor>> interactors; - std::shared_ptr<ForceCalculator> forceCalculator; - std::shared_ptr<PePhysicsEngineSolverAdapter> physicsEngineSolver; - std::vector<std::shared_ptr<PhysicsEngineGeometryAdapter>> physicsEngineGeometrieAdapters; - double intermediateDemSteps; - SPtr<BoundaryConditionsBlockVisitor> boundaryConditionsBlockVisitor; - // walberla::pe::BodyStorage* bodyStorage; //!< Reference to the central body storage. - // walberla::pe::BodyStorage* bodyStorageShadowCopies; //!< Reference to the body storage containing body shadow - // copies. - - std::map<unsigned long long, std::shared_ptr<PePhysicsEngineGeometryAdapter>> geoIdMap; - -#ifdef TIMING - UbTimer timer; -#endif -}; - -#endif diff --git a/src/cpu/DemCoupling/DemCoupling.cmake b/src/cpu/DemCoupling/DemCoupling.cmake deleted file mode 100644 index 927c08b6dadae76d2ed023253503f8e7bd804601..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/DemCoupling.cmake +++ /dev/null @@ -1,31 +0,0 @@ -INCLUDE(${SOURCE_ROOT}/DemCoupling/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/dummy/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/pe/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/DemCoupling/reconstructor/CMakePackage.txt) - -INCLUDE(${SOURCE_ROOT}/DemCoupling/IncludsList.cmake) - -SET(LINK_LIBRARY optimized ${PE_RELEASE_LIBRARY} debug ${PE_DEBUG_LIBRARY}) -SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - -SET(LINK_LIBRARY optimized ${BLOCKFOREST_RELEASE_LIBRARY} debug ${BLOCKFOREST_DEBUG_LIBRARY}) -SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - -SET(LINK_LIBRARY optimized ${DOMAIN_DECOMPOSITION_RELEASE_LIBRARY} debug ${DOMAIN_DECOMPOSITION_DEBUG_LIBRARY}) -SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - -SET(LINK_LIBRARY optimized ${GEOMETRY_RELEASE_LIBRARY} debug ${GEOMETRY_DEBUG_LIBRARY}) -SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - -SET(LINK_LIBRARY optimized ${CORE_RELEASE_LIBRARY} debug ${CORE_DEBUG_LIBRARY}) -SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - -IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} "stdc++fs") -ENDIF() - -IF(${USE_METIS}) - SET(LINK_LIBRARY optimized ${METIS_RELEASE_LIBRARY} debug ${METIS_DEBUG_LIBRARY}) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) -ENDIF() \ No newline at end of file diff --git a/src/cpu/DemCoupling/IncludsList.cmake b/src/cpu/DemCoupling/IncludsList.cmake deleted file mode 100644 index 7ebf198e6082131956d5c1e146031394f39e37d5..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/IncludsList.cmake +++ /dev/null @@ -1,8 +0,0 @@ -INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling) -INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter) -INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/dummy) -INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/pe) -INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling/reconstructor) - -INCLUDE_DIRECTORIES(${PE_ROOT}/src) -INCLUDE_DIRECTORIES(${PE_BINARY_DIR}/src) \ No newline at end of file diff --git a/src/cpu/DemCoupling/MovableObjectInteractor.cpp b/src/cpu/DemCoupling/MovableObjectInteractor.cpp deleted file mode 100644 index 17185c8bb1cdfedfca1d76fa799cc0810a3fb43d..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/MovableObjectInteractor.cpp +++ /dev/null @@ -1,254 +0,0 @@ -#include "MovableObjectInteractor.h" - -#include "GbObject3D.h" -#include "UbLogger.h" -#include "Vector3D.h" - -#include "BCAdapter.h" -#include "BCArray3D.h" -#include "BCProcessor.h" -#include "Block3D.h" -#include "CoordinateTransformation3D.h" -#include "Grid3D.h" -#include "ILBMKernel.h" - -#include "BoundaryConditionsBlockVisitor.h" -#include "SetBcBlocksBlockVisitor.h" - -#include "PhysicsEngineGeometryAdapter.h" -#include "Reconstructor.h" - -#include <array> - -//#define TIMING - -#ifdef TIMING -#include "UbTiming.h" -#endif - -MovableObjectInteractor::MovableObjectInteractor(std::shared_ptr<GbObject3D> geoObject3D, std::shared_ptr<Grid3D> grid, - std::shared_ptr<BCAdapter> bcAdapter, int type, - std::shared_ptr<Reconstructor> reconstructor, State state) - : D3Q27Interactor(geoObject3D, grid, bcAdapter, type), reconstructor(reconstructor), state(state) -{ - // grid->getBlocks(0, grid->getRank(), true, blockVector); -} - -MovableObjectInteractor::~MovableObjectInteractor() {} - -void MovableObjectInteractor::setPhysicsEngineGeometry( - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry) -{ - this->physicsEngineGeometry = physicsEngineGeometry; - physicsEngineGeometry->changeState(this->state); -} - -void MovableObjectInteractor::moveGbObjectTo(const Vector3D &position) -{ - // UBLOG(logINFO, "new position: (x,y,z) " << val<1>(position) << ", " << val<2>(position) << ", " << - // val<3>(position)); - - this->getGbObject3D()->setCenterCoordinates(UbTupleDouble3(position[0], position[1], position[2])); - this->rearrangeGrid(); -} - -void MovableObjectInteractor::rearrangeGrid() -{ -#ifdef TIMING - UbTimer timer; - timer.resetAndStart(); -#endif - -#ifdef TIMING - UBLOG(logINFO, "MovableObjectInteractor::rearrangeGrid():start"); -#endif - - this->reconstructDistributionOnSolidNodes(); - -#ifdef TIMING - UBLOG(logINFO, "reconstructDistributionOnSolidNodes() time = " << timer.stop() << " s"); -#endif - - this->setSolidNodesToFluid(); - -#ifdef TIMING - UBLOG(logINFO, "setSolidNodesToFluid() time = " << timer.stop() << " s"); -#endif - - this->setBcNodesToFluid(); - -#ifdef TIMING - UBLOG(logINFO, "setBcNodesToFluid() time = " << timer.stop() << " s"); -#endif - - this->removeSolidBlocks(); - -#ifdef TIMING - UBLOG(logINFO, "removeSolidBlocks() time = " << timer.stop() << " s"); -#endif - - this->removeBcBlocks(); - -#ifdef TIMING - UBLOG(logINFO, "removeBcBlocks() time = " << timer.stop() << " s"); -#endif - - this->setBcBlocks(); - -#ifdef TIMING - UBLOG(logINFO, "setBcBlocks() time = " << timer.stop() << " s"); -#endif - - this->initInteractor(); - -#ifdef TIMING - UBLOG(logINFO, "initInteractor() time = " << timer.stop() << " s"); -#endif - - this->updateVelocityBc(); - -#ifdef TIMING - UBLOG(logINFO, "updateVelocityBc() time = " << timer.stop() << " s"); -#endif -} - -void MovableObjectInteractor::updateNodeLists() -{ - // for (BcNodeIndicesMap::value_type t : bcNodeIndicesMap) - //{ - // SPtr<Block3D> block = t.first; - // std::set< UbTupleInt3 >& bcNodeIndices = t.second; - - // SPtr<ILBMKernel> kernel = block->getKernel(); - - // for (UbTupleInt3 node : bcNodeIndices) - // { - - // } - //} -} - -void MovableObjectInteractor::reconstructDistributionOnSolidNodes() -{ - for (SolidNodeIndicesMap::value_type t : solidNodeIndicesMap) { - SPtr<Block3D> block = t.first; - std::set<UbTupleInt3> &solidNodeIndices = t.second; - - SPtr<ILBMKernel> kernel = block->getKernel(); - - for (UbTupleInt3 node : solidNodeIndices) { - const int x1 = val<1>(node); - const int x2 = val<2>(node); - const int x3 = val<3>(node); - - const Vector3D worldCoordinates = this->grid.lock()->getNodeCoordinates(block, x1, x2, x3); - - if (kernel->isInsideOfDomain(x1, x2, x3)) - reconstructor->reconstructNode(x1, x2, x3, worldCoordinates, physicsEngineGeometry, kernel); - } - } -} - -void MovableObjectInteractor::setSolidNodesToFluid() -{ - for (SolidNodeIndicesMap::value_type t : solidNodeIndicesMap) { - SPtr<Block3D> block = t.first; - std::set<UbTupleInt3> &solidNodeIndices = t.second; - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - - for (UbTupleInt3 node : solidNodeIndices) - bcArray->setFluid(val<1>(node), val<2>(node), val<3>(node)); - } -} - -void MovableObjectInteractor::setBcNodesToFluid() -{ - for (BcNodeIndicesMap::value_type t : bcNodeIndicesMap) { - SPtr<Block3D> block = t.first; - std::set<std::vector<int>> &bcNodeIndices = t.second; - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - - for (std::vector<int> node : bcNodeIndices) - bcArray->setFluid(node[0], node[1], node[2]); - } -} - -void MovableObjectInteractor::setBcBlocks() -{ - SetBcBlocksBlockVisitor v(shared_from_this()); - this->grid.lock()->accept(v); - - ////////////////////////////////////////////////////////////////////////// - // SPtr<GbObject3D> geoObject = this->getGbObject3D(); - // std::array<double, 6> AABB ={ - // geoObject->getX1Minimum(),geoObject->getX2Minimum(),geoObject->getX3Minimum(),geoObject->getX1Maximum(),geoObject->getX2Maximum(),geoObject->getX3Maximum() - // }; blockVector.clear(); UbTupleInt3 blockNX=grid.lock()->getBlockNX(); double ext = 0.0; - // grid.lock()->getBlocksByCuboid(AABB[0]-(double)val<1>(blockNX)*ext, AABB[1]-(double)val<2>(blockNX)*ext, - // AABB[2]-(double)val<3>(blockNX)*ext, AABB[3]+(double)val<1>(blockNX)*ext, AABB[4]+(double)val<2>(blockNX)*ext, - // AABB[5]+(double)val<3>(blockNX)*ext, blockVector); - - // for(std::shared_ptr<Block3D> block : this->blockVector) - //{ - // if (block->getKernel()) - // { - // setBCBlock(block); - // } - //} - ////////////////////////////////////////////////////////////////////////// - // SPtr<GbObject3D> geoObject = this->getGbObject3D(); - // std::array <double, 2> minMax1; - // std::array <double, 2> minMax2; - // std::array <double, 2> minMax3; - // minMax1[0] = geoObject->getX1Minimum(); - // minMax2[0] = geoObject->getX2Minimum(); - // minMax3[0] = geoObject->getX3Minimum(); - // minMax1[1] = geoObject->getX1Maximum(); - // minMax2[1] = geoObject->getX2Maximum(); - // minMax3[1] = geoObject->getX3Maximum(); - - // SPtr<CoordinateTransformation3D> trafo = grid.lock()->getCoordinateTransformator(); - - // for (int x3 = 0; x3 < 2; x3++) - // for (int x2 = 0; x2 < 2; x2++) - // for (int x1 = 0; x1 < 2; x1++) - // { - // int ix1 = (int)trafo->transformForwardToX1Coordinate(minMax1[x1], minMax2[x2], minMax3[x3]); - // int ix2 = (int)trafo->transformForwardToX2Coordinate(minMax1[x1], minMax2[x2], minMax3[x3]); - // int ix3 = (int)trafo->transformForwardToX3Coordinate(minMax1[x1], minMax2[x2], minMax3[x3]); - // blockVector.push_back(grid.lock()->getBlock(ix1, ix2, ix3, 0)); - // } - // for(std::shared_ptr<Block3D> block : this->blockVector) - //{ - // if (block->getKernel()) - // { - // setBCBlock(block); - // } - //} -} - -void MovableObjectInteractor::updateVelocityBc() -{ - for (BcNodeIndicesMap::value_type t : this->getBcNodeIndicesMap()) { - SPtr<Block3D> block = t.first; - std::set<std::vector<int>> &bcNodeIndices = t.second; - - SPtr<BCArray3D> bcArray = block->getKernel()->getBCProcessor()->getBCArray(); - - for (std::vector<int> node : bcNodeIndices) - setGeometryVelocityToBoundaryCondition(node, block, bcArray); - } -} - -void MovableObjectInteractor::setGeometryVelocityToBoundaryCondition(std::vector<int> node, SPtr<Block3D> block, - SPtr<BCArray3D> bcArray) const -{ - const SPtr<BoundaryConditions> bc = bcArray->getBC(node[0], node[1], node[2]); - const Vector3D worldCoordinates = this->grid.lock()->getNodeCoordinates(block, node[0], node[1], node[2]); - const Vector3D velocity = this->physicsEngineGeometry->getVelocityAtPosition(worldCoordinates); - - bc->setBoundaryVelocity(velocity); -} diff --git a/src/cpu/DemCoupling/MovableObjectInteractor.h b/src/cpu/DemCoupling/MovableObjectInteractor.h deleted file mode 100644 index e0e4343a066d5fd69ddb3cf68d2106337a51d031..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/MovableObjectInteractor.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef D3Q27_MOVABLE_OBJECT_INTERACTOR_H -#define D3Q27_MOVABLE_OBJECT_INTERACTOR_H - -#include <memory> -#include <vector> - -#include "D3Q27Interactor.h" - -#include "PhysicsEngineGeometryAdapter.h" -#include "Vector3D.h" - -class Grid3D; -class Block3D; -class BCArray3D; -class BCAdapter; -class GbObject3D; - -class PhysicsEngineGeometryAdapter; -class Reconstructor; - -class MovableObjectInteractor : public D3Q27Interactor -{ -public: - typedef std::map<SPtr<Block3D>, std::set<std::array<int, 3>>> InBcNodeIndicesMap; - typedef std::map<SPtr<Block3D>, std::set<std::array<int, 3>>> OutBcNodeIndicesMap; - -public: - MovableObjectInteractor(std::shared_ptr<GbObject3D> geoObject3D, std::shared_ptr<Grid3D> grid, - std::shared_ptr<BCAdapter> bcAdapter, int type, - std::shared_ptr<Reconstructor> reconstructor, State isPinned); - virtual ~MovableObjectInteractor(); - - void setPhysicsEngineGeometry(std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry); - - void moveGbObjectTo(const Vector3D &position); - -private: - void rearrangeGrid(); - void updateNodeLists(); - void setSolidNodesToFluid(); - void setBcNodesToFluid(); - void reconstructDistributionOnSolidNodes(); - void setBcBlocks(); - - void updateVelocityBc(); - void setGeometryVelocityToBoundaryCondition(std::vector<int> node, std::shared_ptr<Block3D> block, - std::shared_ptr<BCArray3D> bcArray) const; - - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry; - - std::shared_ptr<Reconstructor> reconstructor; - State state; - std::vector<std::shared_ptr<Block3D>> blockVector; -}; - -#endif diff --git a/src/cpu/DemCoupling/PePartitioningGridVisitor.cpp b/src/cpu/DemCoupling/PePartitioningGridVisitor.cpp deleted file mode 100644 index 429eaeb8be0d3a601b64199e5e86279f7d05ce8f..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/PePartitioningGridVisitor.cpp +++ /dev/null @@ -1,148 +0,0 @@ -#if defined VF_METIS && defined VF_MPI - -#include "PePartitioningGridVisitor.h" -#include "Block3D.h" -#include <mpi/Communicator.h> -#include "CoordinateTransformation3D.h" -#include "Grid3D.h" -#include "UbLogger.h" -#include <math.h> -#include <shared_mutex> - -#include "DemCoProcessor.h" - -using namespace std; - -PePartitioningGridVisitor::PePartitioningGridVisitor(std::shared_ptr<vf::mpi::Communicator> comm, std::shared_ptr<DemCoProcessor> dem) - : Grid3DVisitor(), comm(comm), dem(dem) -{ - forest = dynamicPointerCast<PePhysicsEngineSolverAdapter>(dem->getPhysicsEngineSolver())->getForest(); -} -////////////////////////////////////////////////////////////////////////// -PePartitioningGridVisitor::~PePartitioningGridVisitor() {} -////////////////////////////////////////////////////////////////////////// -void PePartitioningGridVisitor::visit(SPtr<Grid3D> grid) -{ - UBLOG(logDEBUG1, "PePartitioningGridVisitor::visit() - start"); - - collectData(grid); - distributePartitionData(grid); - - UBLOG(logDEBUG1, "PePartitioningGridVisitor::visit() - end"); -} -////////////////////////////////////////////////////////////////////////// -void PePartitioningGridVisitor::collectData(SPtr<Grid3D> grid) -{ - // int minInitLevel = grid->getCoarsestInitializedLevel(); - // int maxInitLevel = grid->getFinestInitializedLevel(); - - walberla::uint_t peRank; - - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) { - forest->getProcessRank(peRank, blockIt->getId()); - vector<SPtr<Block3D>> blocks; - walberla::AABB aabb = blockIt->getAABB(); - - // getBlocksByCuboid((double)aabb.xMin(), (double)aabb.yMin(), (double)aabb.zMin(), (double)aabb.xMax(), - // (double)aabb.yMax(), (double)aabb.zMax(), blocks, grid); for (SPtr<Block3D> block : blocks) - //{ - // ids.push_back(block->getGlobalID()); - // ranks.push_back((int)peRank); - //} - SPtr<Block3D> block = getBlockByMinUniform((double)aabb.xMin(), (double)aabb.yMin(), (double)aabb.zMin(), grid); - if (block) { - ids.push_back(block->getGlobalID()); - ranks.push_back((int)peRank); - } - } -} -////////////////////////////////////////////////////////////////////////// -// void PePartitioningGridVisitor::getBlocksByCuboid(double minX1, double minX2, double minX3, double maxX1, double -// maxX2, double maxX3, std::vector<SPtr<Block3D>>& blocks, SPtr<Grid3D> grid) -//{ -// int coarsestLevel = grid->getCoarsestInitializedLevel(); -// int finestLevel = grid->getFinestInitializedLevel(); -// -// SPtr<CoordinateTransformation3D> trafo = grid->getCoordinateTransformator(); -// -// ////////////////////////////////////////////////////////////////////////// -// //MINIMALE BLOCK-INDIZES BESTIMMEN -// // -// //min: -// double dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3)*(1<<finestLevel); -// double dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3)*(1<<finestLevel); -// double dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3)*(1<<finestLevel); -// -// //Achtung, wenn minX1 genau auf grenze zwischen zwei bloecken -> der "kleinere" muss genommen werden, -// //da beim Transformieren der "groessere" Index rauskommt -// int iMinX1 = (int)dMinX1; //if (UbMath::zero(dMinX1-iMinX1)) iMinX1-=1; -// int iMinX2 = (int)dMinX2; //if (UbMath::zero(dMinX2-iMinX2)) iMinX2-=1; -// int iMinX3 = (int)dMinX3; //if (UbMath::zero(dMinX3-iMinX3)) iMinX3-=1; -// -// //max (hier kann die Zusatzabfrage vernachlaessigt werden): -// int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel)); -// int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel)); -// int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel)); -// -// SPtr<Block3D> block; -// -// //set, um doppelte bloecke zu vermeiden, die u.U. bei periodic auftreten koennen -// std::set<SPtr<Block3D>> blockset; -// for (int level=coarsestLevel; level<=finestLevel; level++) -// { -// //damit bei negativen werten auch der "kleinere" genommen wird -> floor! -// int minx1 = (int)std::floor((double)iMinX1/(1<<(finestLevel-level))); -// int minx2 = (int)std::floor((double)iMinX2/(1<<(finestLevel-level))); -// int minx3 = (int)std::floor((double)iMinX3/(1<<(finestLevel-level))); -// -// int maxx1 = iMaxX1/(1<<(finestLevel-level)); -// int maxx2 = iMaxX2/(1<<(finestLevel-level)); -// int maxx3 = iMaxX3/(1<<(finestLevel-level)); -// -// for (int ix1=minx1; ix1<maxx1; ix1++) -// for (int ix2=minx2; ix2<maxx2; ix2++) -// for (int ix3=minx3; ix3<maxx3; ix3++) -// if ((block=grid->getBlock(ix1, ix2, ix3, level))) -// { -// blockset.insert(block); -// } -// } -// -// blocks.resize(blockset.size()); -// std::copy(blockset.begin(), blockset.end(), blocks.begin()); -//} - -SPtr<Block3D> PePartitioningGridVisitor::getBlockByMinUniform(double minX1, double minX2, double minX3, - SPtr<Grid3D> grid) -{ - SPtr<CoordinateTransformation3D> trafo = grid->getCoordinateTransformator(); - - int ix1 = (int)trafo->transformForwardToX1Coordinate(minX1, minX2, minX3); - int ix2 = (int)trafo->transformForwardToX2Coordinate(minX1, minX2, minX3); - int ix3 = (int)trafo->transformForwardToX3Coordinate(minX1, minX2, minX3); - - return grid->getBlock(ix1, ix2, ix3, 0); -} - -////////////////////////////////////////////////////////////////////////// -void PePartitioningGridVisitor::distributePartitionData(SPtr<Grid3D> grid) -{ - std::vector<int> totalIDs; - std::vector<int> totalRanks; - - assert(ids.size() != 0); - assert(ranks.size() != 0); - - comm->allGather(ids, totalIDs); - comm->allGather(ranks, totalRanks); - - assert(totalIDs.size() == totalRanks.size()); - for (int i = 0; i < totalIDs.size(); i++) { - SPtr<Block3D> block = grid->getBlock(totalIDs[i]); - if (block) - block->setRank(totalRanks[i]); - } -} -////////////////////////////////////////////////////////////////////////// - -#endif // VF_METIS diff --git a/src/cpu/DemCoupling/PePartitioningGridVisitor.h b/src/cpu/DemCoupling/PePartitioningGridVisitor.h deleted file mode 100644 index cad80c0f4d986c45560c6111e8943226df136d24..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/PePartitioningGridVisitor.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef PePartitioningGridVisitor_h -#define PePartitioningGridVisitor_h - -#if defined VF_MPI - -#include <PointerDefinitions.h> -#include <vector> - -#include "Grid3DVisitor.h" - -#include "PePhysicsEngineSolverAdapter.h" - -#include <array> - -//////////////////////////////////////////////////////////////////////// -//! \brief The class implements domain decomposition with PE library -//! \author Konstantin Kutscher -////////////////////////////////////////////////////////////////////////// -namespace vf::mpi {class Communicator;} -class Grid3D; -class Block3D; -class DemCoProcessor; -// class walberla::blockforest::BlockForest; - -class PePartitioningGridVisitor : public Grid3DVisitor -{ -public: - //! This describe different types of decomposition - enum GraphType { LevelIntersected, LevelBased }; - -public: - //! Constructor - //! \param comm - communicator - - PePartitioningGridVisitor(std::shared_ptr<vf::mpi::Communicator> comm, std::shared_ptr<DemCoProcessor> dem); - virtual ~PePartitioningGridVisitor(); - void visit(SPtr<Grid3D> grid) override; - -protected: - void collectData(SPtr<Grid3D> grid); - void distributePartitionData(SPtr<Grid3D> grid); - // void getBlocksByCuboid(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, - // std::vector<SPtr<Block3D>>& blocks, SPtr<Grid3D> grid); - SPtr<Block3D> getBlockByMinUniform(double minX1, double minX2, double minX3, SPtr<Grid3D> grid); - -private: - std::shared_ptr<vf::mpi::Communicator> comm; - std::shared_ptr<DemCoProcessor> dem; - - std::vector<int> ids; - std::vector<int> ranks; - - std::shared_ptr<walberla::blockforest::BlockForest> forest; -}; - -#endif // VF_MPI -#endif diff --git a/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.cpp b/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.cpp deleted file mode 100644 index ff6cbe7e5a3e394bac18016507a57308d0f1ecbf..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "RestartDemObjectsCoProcessor.h" - -#include <mpi/Communicator.h> -#include "CreateDemObjectsCoProcessor.h" -#include "DemCoProcessor.h" -#include "GbSphere3D.h" -#include "Grid3D.h" -#include "UbFileInputBinary.h" -#include "UbFileOutputBinary.h" -#include "UbScheduler.h" -#include "UbSystem.h" -#include "Vector3D.h" - -RestartDemObjectsCoProcessor::RestartDemObjectsCoProcessor() {} - -RestartDemObjectsCoProcessor::RestartDemObjectsCoProcessor( - SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<DemCoProcessor> demCoProcessor, - SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor, double radius, std::shared_ptr<vf::mpi::Communicator> comm) - : CoProcessor(grid, s), path(path), demCoProcessor(demCoProcessor), - createDemObjectsCoProcessor(createDemObjectsCoProcessor), radius(radius), comm(comm) -{ -} - -void RestartDemObjectsCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) { - int istep = static_cast<int>(step); - - if (comm->isRoot()) - UBLOG(logINFO, "RestartDemObjectsCoProcessor::write step: " << istep); - - write(istep); - } -} - -void RestartDemObjectsCoProcessor::restart(double step) -{ - if (comm->isRoot()) - UBLOG(logINFO, "RestartDemObjectsCoProcessor::read step: " << (int)step); - - read((int)step); -} - -void RestartDemObjectsCoProcessor::write(int step) -{ - if (comm->isRoot()) - UBLOG(logINFO, "RestartDemObjectsCoProcessor::write start "); - std::vector<double> p; - - demCoProcessor->getObjectsPropertiesVector(p); - - // TODO implement getherv - std::vector<double> rvalues; - comm->allGather(p, rvalues); - - if (comm->isRoot()) { - std::map<int, std::vector<double>> infMap; - int size = (int)rvalues.size(); - for (int i = 0; i < size; i += 7) { - std::vector<double> infVector(6); - for (int j = 0; j < 6; j++) { - infVector[j] = rvalues[i + 1 + j]; - } - infMap.insert(std::make_pair((int)rvalues[i], infVector)); - } - std::vector<double> wvalues; - typedef std::map<int, std::vector<double>>::iterator it_type; - for (it_type iterator = infMap.begin(); iterator != infMap.end(); iterator++) { - // iterator->first = key - // iterator->second = value - std::vector<double>::iterator it = wvalues.end(); - it = wvalues.insert(it, iterator->second.begin(), iterator->second.end()); - } - std::string subfolder = "dem_cp_" + UbSystem::toString(step); - std::string filePath = path + "/dem_cp/" + subfolder + "/dem_cp.bin"; - UbFileOutputBinary fo(filePath); - fo.writeInteger((int)wvalues.size()); - fo.writeVector<double>(wvalues); - UBLOG(logINFO, "RestartDemObjectsCoProcessor::write number of objects = " << wvalues.size() / 6); - } - if (comm->isRoot()) - UBLOG(logINFO, "RestartDemObjectsCoProcessor::write stop "); -} - -void RestartDemObjectsCoProcessor::read(int step) -{ - if (comm->isRoot()) - UBLOG(logINFO, "RestartDemObjectsCoProcessor::read start "); - std::vector<double> p; - - if (comm->isRoot()) { - std::string subfolder = "dem_cp_" + UbSystem::toString(step); - std::string filePath = path + "/dem_cp/" + subfolder + "/dem_cp.bin"; - UbFileInputBinary fi(filePath); - int size = fi.readInteger(); - p.resize(size); - fi.readVector<double>(p); - } - comm->broadcast(p); - - if (comm->isRoot()) - UBLOG(logINFO, "RestartDemObjectsCoProcessor::read number of objects = " << p.size() / 6); - - createDemObjectsCoProcessor->clearGeoObjects(); - - int size = (int)p.size(); - - for (int i = 0; i < size; i += 6) { - SPtr<GbObject3D> sphere(new GbSphere3D(p[i], p[i + 1], p[i + 2], radius)); - createDemObjectsCoProcessor->addGeoObject(sphere, Vector3D(p[i + 3], p[i + 4], p[i + 5])); - } - - createDemObjectsCoProcessor->createGeoObjects(); - - createDemObjectsCoProcessor->clearGeoObjects(); - - if (comm->isRoot()) - UBLOG(logINFO, "RestartDemObjectsCoProcessor::read stop "); -} diff --git a/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.h b/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.h deleted file mode 100644 index 5123a2d6e51ece8e96d6623d573141a8c272026f..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Author: K. Kutscher - * mail: kutscher@irmb.tu-bs.de - */ -#ifndef RestartDemObjectsCoProcessor_H -#define RestartDemObjectsCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" - -namespace vf::mpi {class Communicator;} -class Grid3D; -class UbScheduler; -class DemCoProcessor; -class CreateDemObjectsCoProcessor; - -class RestartDemObjectsCoProcessor : public CoProcessor -{ -public: - RestartDemObjectsCoProcessor(); - RestartDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - SPtr<DemCoProcessor> demCoProcessor, - SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor, double radius, - std::shared_ptr<vf::mpi::Communicator> comm); - ~RestartDemObjectsCoProcessor() {} - void process(double step) override; - void restart(double step); - void write(int step); - void read(int step); - -private: - std::string path; - double radius; - std::shared_ptr<vf::mpi::Communicator> comm; - SPtr<DemCoProcessor> demCoProcessor; - SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor; -}; -#endif diff --git a/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.cpp b/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.cpp deleted file mode 100644 index 3e22c90cf266fa8593b0036d160d79080a3ad31c..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "WriteDemObjectsCoProcessor.h" - -#include "basics/writer/WbWriterVtkXmlASCII.h" -#include "basics/writer/WbWriterVtkXmlBinary.h" - -#include <mpi/Communicator.h> -#include "DemCoProcessor.h" -#include "Grid3D.h" -#include "UbScheduler.h" -#include "UbSystem.h" - -WriteDemObjectsCoProcessor::WriteDemObjectsCoProcessor() {} -////////////////////////////////////////////////////////////////////////// -WriteDemObjectsCoProcessor::WriteDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - WbWriter *const writer, SPtr<DemCoProcessor> demCoProcessor, - std::shared_ptr<vf::mpi::Communicator> comm) - : CoProcessor(grid, s), path(path), writer(writer), demCoProcessor(demCoProcessor), comm(comm) -{ -} -////////////////////////////////////////////////////////////////////////// -void WriteDemObjectsCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) { - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleInt3> triangles; - - int numObjcts = demCoProcessor->addSurfaceTriangleSet(nodes, triangles); - - int istep = static_cast<int>(step); - - std::string pfilePath, partPath, subfolder, cfilePath; - - subfolder = "dem" + UbSystem::toString(istep); - pfilePath = path + "/dem/" + subfolder; - cfilePath = path + "/dem/dem_collection"; - partPath = pfilePath + "/dem" + UbSystem::toString(comm->getProcessID()) + "_" + UbSystem::toString(istep); - - std::string partName = writer->writeTriangles(partPath, nodes, triangles); - size_t found = partName.find_last_of("/"); - std::string piece = partName.substr(found + 1); - piece = subfolder + "/" + piece; - - std::vector<std::string> datanames; - std::vector<std::string> cellDataNames; - std::vector<std::string> pieces = comm->gather(piece); - if (comm->isRoot()) { - std::string pname = - WbWriterVtkXmlASCII::getInstance()->writeParallelFile(pfilePath, pieces, datanames, cellDataNames); - found = pname.find_last_of("/"); - piece = pname.substr(found + 1); - - std::vector<std::string> filenames; - filenames.push_back(piece); - if (step == CoProcessor::scheduler->getMinBegin()) { - WbWriterVtkXmlASCII::getInstance()->writeCollection(cfilePath, filenames, istep, false); - } else { - WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(cfilePath, filenames, istep, false); - } - UBLOG(logINFO, "WriteDemObjectsCoProcessor number of objects: " << numObjcts); - UBLOG(logINFO, "WriteDemObjectsCoProcessor step: " << istep); - } - } -} diff --git a/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.h b/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.h deleted file mode 100644 index 7fb3b045ccd439d772ef565c2013af32c75a7a2d..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Author: K. Kutscher - * mail: kutscher@irmb.tu-bs.de - */ -#ifndef WriteDemObjectsCoProcessor_H -#define WriteDemObjectsCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" - -namespace vf::mpi {class Communicator;} -class Grid3D; -class UbScheduler; -class DemCoProcessor; -class WbWriter; - -class WriteDemObjectsCoProcessor : public CoProcessor -{ -public: - WriteDemObjectsCoProcessor(); - WriteDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, WbWriter *const writer, - SPtr<DemCoProcessor> demCoProcessor, std::shared_ptr<vf::mpi::Communicator> comm); - ~WriteDemObjectsCoProcessor() {} - void process(double step) override; - -private: - std::string path; - WbWriter *writer; - std::shared_ptr<vf::mpi::Communicator> comm; - SPtr<DemCoProcessor> demCoProcessor; -}; -#endif diff --git a/src/cpu/DemCoupling/WritePeBlocksCoProcessor.cpp b/src/cpu/DemCoupling/WritePeBlocksCoProcessor.cpp deleted file mode 100644 index 401ea91bc7225eea7f871cbc2e92be44d1a5c9d7..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/WritePeBlocksCoProcessor.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "WritePeBlocksCoProcessor.h" - -#include "basics/writer/WbWriterVtkXmlASCII.h" - -#include "Block3D.h" -#include <mpi/Communicator.h> -#include "D3Q27System.h" -#include "Grid3D.h" -#include "UbScheduler.h" - -WritePeBlocksCoProcessor::WritePeBlocksCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - WbWriter *const writer, std::shared_ptr<vf::mpi::Communicator> comm, - SPtr<walberla::blockforest::BlockForest> forest) - : CoProcessor(grid, s), path(path), writer(writer), comm(comm), forest(forest) -{ -} - -WritePeBlocksCoProcessor::~WritePeBlocksCoProcessor() {} - -void WritePeBlocksCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - collectData(step); -} - -void WritePeBlocksCoProcessor::collectData(double step) -{ - if (comm->getProcessID() == comm->getRoot()) { - int istep = int(step); - std::vector<std::string> filenames; - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleInt8> cells; - std::vector<std::string> celldatanames; - - celldatanames.push_back("ID"); - celldatanames.push_back("rank"); - - walberla::uint_t rank = 0; - - std::vector<std::vector<double>> celldata(celldatanames.size()); - - int nr = 0; - - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) { - walberla::AABB aabb = blockIt->getAABB(); - - nodes.push_back(makeUbTuple((float)aabb.xMin(), (float)aabb.yMin(), (float)aabb.zMin())); - nodes.push_back(makeUbTuple((float)aabb.xMax(), (float)aabb.yMin(), (float)aabb.zMin())); - nodes.push_back(makeUbTuple((float)aabb.xMax(), (float)aabb.yMax(), (float)aabb.zMin())); - nodes.push_back(makeUbTuple((float)aabb.xMin(), (float)aabb.yMax(), (float)aabb.zMin())); - nodes.push_back(makeUbTuple((float)aabb.xMin(), (float)aabb.yMin(), (float)aabb.zMax())); - nodes.push_back(makeUbTuple((float)aabb.xMax(), (float)aabb.yMin(), (float)aabb.zMax())); - nodes.push_back(makeUbTuple((float)aabb.xMax(), (float)aabb.yMax(), (float)aabb.zMax())); - nodes.push_back(makeUbTuple((float)aabb.xMin(), (float)aabb.yMax(), (float)aabb.zMax())); - cells.push_back(makeUbTuple(nr, nr + 1, nr + 2, nr + 3, nr + 4, nr + 5, nr + 6, nr + 7)); - nr += 8; - - // data - celldata[0].push_back((double)blockIt->getId().getID()); - forest->getProcessRank(rank, blockIt->getId()); - celldata[1].push_back((double)rank); - } - - filenames.push_back(writer->writeOctsWithCellData( - path + "/peBlocks/peBlocks_" + UbSystem::toString(grid->getRank()) + "_" + UbSystem::toString(istep), nodes, - cells, celldatanames, celldata)); - - if (istep == CoProcessor::scheduler->getMinBegin()) { - WbWriterVtkXmlASCII::getInstance()->writeCollection(path + "/peBlocks/peBlocks_collection", filenames, - istep, false); - } else { - WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(path + "/peBlocks/peBlocks_collection", filenames, - istep, false); - } - - UBLOG(logINFO, "WritePeBlocksCoProcessor step: " << istep); - } -} \ No newline at end of file diff --git a/src/cpu/DemCoupling/WritePeBlocksCoProcessor.h b/src/cpu/DemCoupling/WritePeBlocksCoProcessor.h deleted file mode 100644 index ae27d50b3f0bba867db7ad8cce79f2e5d8fd5681..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/WritePeBlocksCoProcessor.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * WritePeBlocksCoProcessor.h - * - * Created on: 07.09.2018 - * Author: K. Kutscher - */ - -#ifndef WritePeBlocksCoProcessor_H_ -#define WritePeBlocksCoProcessor_H_ - -#include <PointerDefinitions.h> -#include <string> - -#include "CoProcessor.h" - -#include <pe/basic.h> - -namespace vf::mpi {class Communicator;} -class Grid3D; -class UbScheduler; -class WbWriter; - -class WritePeBlocksCoProcessor : public CoProcessor -{ -public: - WritePeBlocksCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, WbWriter *const writer, - std::shared_ptr<vf::mpi::Communicator> comm, SPtr<walberla::blockforest::BlockForest> forest); - virtual ~WritePeBlocksCoProcessor(); - - void process(double step) override; - -protected: - void collectData(double step); - - std::string path; - WbWriter *writer; - std::shared_ptr<vf::mpi::Communicator> comm; - SPtr<walberla::blockforest::BlockForest> forest; -}; - -#endif diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineGeometryAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineGeometryAdapter.h deleted file mode 100644 index 490c1f979eaba285f1c39f834396acf9646584d9..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineGeometryAdapter.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef PHYSICS_ENGINE_GEOMETRY_ADAPTER_H -#define PHYSICS_ENGINE_GEOMETRY_ADAPTER_H - -#include "Vector3D.h" - -enum class State { PIN, UNPIN }; - -class PhysicsEngineGeometryAdapter -{ -public: - virtual ~PhysicsEngineGeometryAdapter() {} - - virtual void addForce(const Vector3D &force) = 0; - virtual void addTorque(const Vector3D &torque) = 0; - - virtual void setForce(const Vector3D &force) = 0; - virtual void setTorque(const Vector3D &torque) = 0; - - virtual void addForceAtPosition(const Vector3D &force, const Vector3D &position) = 0; - virtual void setLinearVelolocity(const Vector3D &velocity) = 0; - virtual void setAngularVelocity(const Vector3D &velocity) = 0; - - virtual void resetForceAndTorque() = 0; - - virtual Vector3D getPosition() const = 0; - virtual Vector3D getVelocityAtPosition(const Vector3D &position) const = 0; - virtual Vector3D getLinearVelocity() const = 0; - virtual Vector3D getAngularVelocity() const = 0; - - virtual Vector3D getForce() const = 0; - virtual Vector3D getTorque() const = 0; - - virtual void changeState(State state) = 0; -}; - -#endif diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineMaterialAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineMaterialAdapter.h deleted file mode 100644 index 30504bee98580f25f23e37030d5ec8180fce3ebc..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineMaterialAdapter.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef PHYSICS_ENGINE_MATERIAL_ADAPTER_H -#define PHYSICS_ENGINE_MATERIAL_ADAPTER_H - -#include <string> - -class PhysicsEngineMaterialAdapter -{ -public: - PhysicsEngineMaterialAdapter(std::string name, double density, double restitution, double staticFriction, - double dynamicFriction, double poissonRatio, double youngModul, - double stiffnessInNormalDirection, double dampingoefficientNormalDirection, - double dampingTangentialDirection) - : name(name), density(density), restitution(restitution), staticFriction(staticFriction), - dynamicFriction(dynamicFriction), poissonRatio(poissonRatio), youngModul(youngModul), - stiffnessInNormalDirection(stiffnessInNormalDirection), - dampingoefficientNormalDirection(dampingoefficientNormalDirection), - dampingTangentialDirection(dampingTangentialDirection) - { - } - virtual ~PhysicsEngineMaterialAdapter() {} - -protected: - std::string name; - double density; - double restitution; - double staticFriction; // Note: pe doubles the input coefficient of friction for material-material contacts. - double dynamicFriction; // Similar to static friction for low speed friction. - double poissonRatio; - double youngModul; - double stiffnessInNormalDirection; - double dampingoefficientNormalDirection; - double dampingTangentialDirection; -}; - -#endif diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineSolverAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineSolverAdapter.h deleted file mode 100644 index 8e03bf1d6e651f993012acc1e8297e309e993cc8..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineSolverAdapter.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef PHYSICS_ENGINE_SOLVER_ADAPTER_H -#define PHYSICS_ENGINE_SOLVER_ADAPTER_H - -#include "Vector3D.h" - -class PhysicsEngineGeometryAdapter; -class PhysicsEngineMaterialAdapter; - -class PhysicsEngineSolverAdapter -{ -public: - virtual ~PhysicsEngineSolverAdapter() {} - - virtual std::shared_ptr<PhysicsEngineGeometryAdapter> - createPhysicsEngineGeometryAdapter(int id, const Vector3D &position, double radius, - std::shared_ptr<PhysicsEngineMaterialAdapter> material) const = 0; - virtual void runTimestep(double step) = 0; -}; - -#endif diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.cpp deleted file mode 100644 index b18a57532880491a2419ff9d78bc0c64aac108f8..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "DummyPhysicsEngineGeometryAdapter.h" - -void DummyPhysicsEngineGeometryAdapter::addForce(const Vector3D &force) {} - -void DummyPhysicsEngineGeometryAdapter::addTorque(const Vector3D &torque) {} - -void DummyPhysicsEngineGeometryAdapter::setForce(const Vector3D &force) {} - -void DummyPhysicsEngineGeometryAdapter::setTorque(const Vector3D &torque) {} - -void DummyPhysicsEngineGeometryAdapter::addForceAtPosition(const Vector3D &force, const Vector3D &position) {} - -void DummyPhysicsEngineGeometryAdapter::setLinearVelolocity(const Vector3D &velocity) { this->velocity = velocity; } - -void DummyPhysicsEngineGeometryAdapter::setAngularVelocity(const Vector3D &velocity) {} - -void DummyPhysicsEngineGeometryAdapter::resetForceAndTorque() {} - -Vector3D DummyPhysicsEngineGeometryAdapter::getVelocityAtPosition(const Vector3D &position) const { return velocity; } - -Vector3D DummyPhysicsEngineGeometryAdapter::getLinearVelocity() const { return Vector3D(); } - -Vector3D DummyPhysicsEngineGeometryAdapter::getAngularVelocity() const { return Vector3D(); } - -Vector3D DummyPhysicsEngineGeometryAdapter::getPosition() const { return Vector3D(); } - -Vector3D DummyPhysicsEngineGeometryAdapter::getForce() const { return Vector3D(); } - -Vector3D DummyPhysicsEngineGeometryAdapter::getTorque() const { return Vector3D(); } - -void DummyPhysicsEngineGeometryAdapter::changeState(State state) {} diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.h deleted file mode 100644 index 70620d3c0681a2d2dc702c4a74f5c8d5a94141ea..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef DUMMY_PHYSICS_ENGINE_GEOMETRY_ADAPTER_H -#define DUMMY_PHYSICS_ENGINE_GEOMETRY_ADAPTER_H - -#include "UbTuple.h" - -#include "PhysicsEngineGeometryAdapter.h" - -class DummyPhysicsEngineGeometryAdapter : public PhysicsEngineGeometryAdapter -{ -public: - DummyPhysicsEngineGeometryAdapter() {} - virtual ~DummyPhysicsEngineGeometryAdapter() {} - - void addForce(const Vector3D &force) override; - void addTorque(const Vector3D &torque) override; - - void setForce(const Vector3D &force) override; - void setTorque(const Vector3D &torque) override; - - void addForceAtPosition(const Vector3D &force, const Vector3D &position) override; - void setLinearVelolocity(const Vector3D &velocity) override; - void setAngularVelocity(const Vector3D &velocity) override; - - void resetForceAndTorque() override; - - Vector3D getVelocityAtPosition(const Vector3D &position) const override; - Vector3D getLinearVelocity() const override; - Vector3D getAngularVelocity() const override; - Vector3D getPosition() const override; - Vector3D getForce() const override; - Vector3D getTorque() const override; - - void changeState(State state) override; - -private: - Vector3D velocity; -}; - -#endif diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.cpp deleted file mode 100644 index 7890f966872d5433efa5b40b6358ca0b5a25a40d..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "DummyPhysicsEngineMaterialAdapter.h" diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.h deleted file mode 100644 index e84e0f1089a017ed9135383995c96e55cdf0cee6..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef DUMMY_PHYSICS_ENGINE_MATERIAL_ADAPTER -#define DUMMY_PHYSICS_ENGINE_MATERIAL_ADAPTER - -#include "PhysicsEngineMaterialAdapter.h" - -class DummyPhysicsEngineMaterialAdapter : public PhysicsEngineMaterialAdapter -{ -public: - DummyPhysicsEngineMaterialAdapter(std::string name, double density, double restitution, double staticFriction, - double dynamicFriction, double poissonRatio, double youngModul, - double stiffnessInNormalDirection, double dampingoefficientNormalDirection, - double dampingTangentialDirection) - : PhysicsEngineMaterialAdapter(name, density, restitution, staticFriction, dynamicFriction, poissonRatio, - youngModul, stiffnessInNormalDirection, dampingoefficientNormalDirection, - dampingTangentialDirection) - { - } - virtual ~DummyPhysicsEngineMaterialAdapter() {} -}; - -#endif diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.cpp deleted file mode 100644 index 321b523ead35a6a8d16d7b48b1fbb7cb66b0fdc8..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "DummyPhysicsEngineSolverAdapter.h" - -#include "DummyPhysicsEngineGeometryAdapter.h" - -std::shared_ptr<PhysicsEngineGeometryAdapter> DummyPhysicsEngineSolverAdapter::createPhysicsEngineGeometryAdapter( - int id, const Vector3D &position, double radius, std::shared_ptr<PhysicsEngineMaterialAdapter> material) const -{ - return std::static_pointer_cast<PhysicsEngineGeometryAdapter>( - std::make_shared<DummyPhysicsEngineGeometryAdapter>()); -} - -void DummyPhysicsEngineSolverAdapter::runTimestep(double step) {} diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.h deleted file mode 100644 index 38e9e7f055b415266cfd35c055951707ba4cda44..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef DUMMY_PHYSICS_ENGINE_SOLVER_ADAPTER_H -#define DUMMY_PHYSICS_ENGINE_SOLVER_ADAPTER_H - -#include <memory> - -#include "UbTuple.h" - -#include "PhysicsEngineSolverAdapter.h" - -class DummyPhysicsEngineSolverAdapter : public PhysicsEngineSolverAdapter -{ -public: - DummyPhysicsEngineSolverAdapter(){}; - virtual ~DummyPhysicsEngineSolverAdapter() {} - - std::shared_ptr<PhysicsEngineGeometryAdapter> - createPhysicsEngineGeometryAdapter(int id, const Vector3D &position, double radius, - std::shared_ptr<PhysicsEngineMaterialAdapter> material) const override; - void runTimestep(double step) override; -}; - -#endif diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapter.h deleted file mode 100644 index 0373281d60b6618555de3d48190816d79b9ade5b..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapter.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef PE_ADAPTER_H -#define PE_ADAPTER_H - -#include "Vector3D.h" -#include <pe/basic.h> - -class PeConverter -{ -public: - static Vector3D convert(walberla::pe::Vec3 vec3) { return Vector3D(vec3[0], vec3[1], vec3[2]); } - - static walberla::pe::Vec3 convert(const Vector3D &vec3) { return walberla::pe::Vec3(vec3[0], vec3[1], vec3[2]); } -}; - -#endif diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapterTest.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapterTest.cpp deleted file mode 100644 index a92127c3fd0e2b10ad2d73ee88e7fbd00b8ace85..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapterTest.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//#include "gmock/gmock.h" -// -//#include "PeAdapter.h" -//#include <pe/basic.h> -// -//#include "UbTuple.h" -// -// -// TEST(PeAdapterTest, convert_WalberlaVec3_to_Vector3D) -//{ -// walberla::pe::Vec3 walberlaVec(1.0, -2.0, 3.4); -// Vector3D ubTuple = PeConverter::convert(walberlaVec); -// -// EXPECT_THAT(ubTuple[0], testing::DoubleEq(walberlaVec[0])); -// EXPECT_THAT(ubTuple[1], testing::DoubleEq(walberlaVec[1])); -// EXPECT_THAT(ubTuple[2], testing::DoubleEq(walberlaVec[2])); -//} -// -// TEST(PeAdapterTest, convert_Vector3D_to_WalberlaVec3) -//{ -// Vector3D ubTuple(1.0, -2.0, 3.4); -// walberla::pe::Vec3 walberlaVec = PeConverter::convert(ubTuple); -// -// EXPECT_THAT(ubTuple[0], testing::DoubleEq(walberlaVec[0])); -// EXPECT_THAT(ubTuple[1], testing::DoubleEq(walberlaVec[1])); -// EXPECT_THAT(ubTuple[2], testing::DoubleEq(walberlaVec[2])); -//} diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.cpp deleted file mode 100644 index 6c597698d608a287cc3a8bd5db84fbf061539234..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "PeLoadBalancerAdapter.h" -#include "Block3D.h" -#include "CoordinateTransformation3D.h" -#include "Grid3D.h" -#include "UbLogger.h" - -#include "core/debug/CheckFunctions.h" - -PeLoadBalancerAdapter::PeLoadBalancerAdapter(SPtr<Grid3D> grid, unsigned numberOfProcesses, int rank) - : grid(grid), numberOfProcesses(numberOfProcesses), rank(rank) -{ -} - -walberla::uint_t PeLoadBalancerAdapter::operator()(walberla::SetupBlockForest &forest, - const walberla::uint_t numberOfProcesses, - const walberla::memory_t perProcessMemoryLimit) -{ - std::vector<walberla::SetupBlock *> peBlocks; - forest.getBlocks(peBlocks); - - for (auto peBlock = peBlocks.begin(); peBlock != peBlocks.end(); ++peBlock) { - walberla::AABB aabb = (*peBlock)->getAABB(); - SPtr<Block3D> block = getBlockByMinUniform(aabb.xMin() + 0.5 * (aabb.xMax() - aabb.xMin()), - aabb.yMin() + 0.5 * (aabb.yMax() - aabb.yMin()), - aabb.zMin() + 0.5 * (aabb.zMax() - aabb.zMin()), grid); - if (block) { - (*peBlock)->assignTargetProcess((walberla::uint_t)block->getRank()); - } else { - // TODO: the rank of pe blocks is not consistent with VF blocks - (*peBlock)->assignTargetProcess(0); - // UBLOG(logINFO, "PeLoadBalancerAdapter::operator() peBlockId="<<(*peBlock)->getId()); - } - } - - return numberOfProcesses; -} - -SPtr<Block3D> PeLoadBalancerAdapter::getBlockByMinUniform(double minX1, double minX2, double minX3, SPtr<Grid3D> grid) -{ - SPtr<CoordinateTransformation3D> trafo = grid->getCoordinateTransformator(); - - int ix1 = (int)trafo->transformForwardToX1Coordinate(minX1, minX2, minX3); - int ix2 = (int)trafo->transformForwardToX2Coordinate(minX1, minX2, minX3); - int ix3 = (int)trafo->transformForwardToX3Coordinate(minX1, minX2, minX3); - - return grid->getBlock(ix1, ix2, ix3, 0); -} diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.h deleted file mode 100644 index 9e1c64dd330cd9b1aa06857d4d441b736c8a39a1..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef PeLoadBalancerAdapter_h__ -#define PeLoadBalancerAdapter_h__ - -#include "PointerDefinitions.h" -#include "blockforest/SetupBlockForest.h" - -class Grid3D; -class Block3D; - -class PeLoadBalancerAdapter -{ -public: - PeLoadBalancerAdapter(SPtr<Grid3D> grid, unsigned numberOfProcesses, int rank); - walberla::uint_t operator()(walberla::SetupBlockForest &forest, const walberla::uint_t numberOfProcesses, - const walberla::memory_t perProcessMemoryLimit); - unsigned getNumberOfProcesses() const { return numberOfProcesses; } - int getRank() const { return rank; } - -protected: - SPtr<Block3D> getBlockByMinUniform(double minX1, double minX2, double minX3, SPtr<Grid3D> grid); - -private: - SPtr<Grid3D> grid; - unsigned numberOfProcesses; - int rank; -}; - -#endif // PeLoadBalancerAdapter_h__ \ No newline at end of file diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.cpp deleted file mode 100644 index 9800d75b18a78b7eaf0b46c4193b93a55f3ff91b..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "PePhysicsEngineGeometryAdapter.h" - -#include <pe/basic.h> - -#include "PeAdapter.h" - -// PePhysicsEngineGeometryAdapter::PePhysicsEngineGeometryAdapter(walberla::pe::RigidBody* peGeoObject) : -// peGeoObject(peGeoObject) -//{ -// this->id = peGeoObject->getID(); -// this->active = true; -//} - -PePhysicsEngineGeometryAdapter::PePhysicsEngineGeometryAdapter() -{ - this->id = -999; - this->systemID = -999; - this->active = false; - this->semiactive = false; - shadowCounter = 0; - counter = 0; -} - -void PePhysicsEngineGeometryAdapter::addForce(const Vector3D &force) -{ - peGeoObject->addForce(PeConverter::convert(force)); -} - -void PePhysicsEngineGeometryAdapter::addTorque(const Vector3D &torque) -{ - peGeoObject->addTorque(PeConverter::convert(torque)); -} - -void PePhysicsEngineGeometryAdapter::setForce(const Vector3D &force) -{ - peGeoObject->setForce(PeConverter::convert(force)); -} - -void PePhysicsEngineGeometryAdapter::setTorque(const Vector3D &torque) -{ - peGeoObject->setTorque(PeConverter::convert(torque)); -} - -void PePhysicsEngineGeometryAdapter::addForceAtPosition(const Vector3D &force, const Vector3D &position) -{ - peGeoObject->addForceAtPos(PeConverter::convert(force), PeConverter::convert(position)); -} - -void PePhysicsEngineGeometryAdapter::setLinearVelolocity(const Vector3D &velocity) -{ - peGeoObject->setLinearVel(PeConverter::convert(velocity)); -} - -void PePhysicsEngineGeometryAdapter::setAngularVelocity(const Vector3D &velocity) -{ - peGeoObject->setAngularVel(PeConverter::convert(velocity)); -} - -void PePhysicsEngineGeometryAdapter::resetForceAndTorque() { peGeoObject->resetForceAndTorque(); } - -Vector3D PePhysicsEngineGeometryAdapter::getVelocityAtPosition(const Vector3D &position) const -{ - return PeConverter::convert(peGeoObject->velFromWF(PeConverter::convert(position))); -} - -Vector3D PePhysicsEngineGeometryAdapter::getLinearVelocity() const -{ - return PeConverter::convert(peGeoObject->getLinearVel()); -} - -Vector3D PePhysicsEngineGeometryAdapter::getAngularVelocity() const -{ - return PeConverter::convert(peGeoObject->getAngularVel()); -} - -Vector3D PePhysicsEngineGeometryAdapter::getPosition() const -{ - return PeConverter::convert(peGeoObject->getPosition()); -} - -Vector3D PePhysicsEngineGeometryAdapter::getForce() const { return PeConverter::convert(peGeoObject->getForce()); } - -Vector3D PePhysicsEngineGeometryAdapter::getTorque() const { return PeConverter::convert(peGeoObject->getTorque()); } - -void PePhysicsEngineGeometryAdapter::changeState(State state) -{ - if (state == State::PIN) - peGeoObject->setMassAndInertiaToInfinity(); -} - -int PePhysicsEngineGeometryAdapter::getId() const { return id; } - -void PePhysicsEngineGeometryAdapter::setId(int id) { this->id = id; } - -void PePhysicsEngineGeometryAdapter::setGeometry(walberla::pe::RigidBody *peGeoObject) -{ - this->peGeoObject = peGeoObject; -} - -////////////////////////////////////////////////////////////////////////// -void PePhysicsEngineGeometryAdapter::setActive() { active = true; } -////////////////////////////////////////////////////////////////////////// -void PePhysicsEngineGeometryAdapter::setInactive() { active = false; } -////////////////////////////////////////////////////////////////////////// -bool PePhysicsEngineGeometryAdapter::isActive() { return active; } diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h deleted file mode 100644 index a8eaa7d33ede840f4d76ae90ffb44bef30139f99..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef PE_PHYSICS_ENGINE_GEOMETRY_ADAPTER_H -#define PE_PHYSICS_ENGINE_GEOMETRY_ADAPTER_H - -#include "PhysicsEngineGeometryAdapter.h" -#include <core/DataTypes.h> - -namespace walberla -{ -namespace pe -{ -class RigidBody; -} -} // namespace walberla - -class PePhysicsEngineGeometryAdapter : public PhysicsEngineGeometryAdapter -{ -public: - PePhysicsEngineGeometryAdapter(); - // PePhysicsEngineGeometryAdapter(walberla::pe::RigidBody* peGeoObject); - virtual ~PePhysicsEngineGeometryAdapter() {} - - void addForce(const Vector3D &force) override; - void addTorque(const Vector3D &torque) override; - - void setForce(const Vector3D &force) override; - void setTorque(const Vector3D &torque) override; - - void addForceAtPosition(const Vector3D &force, const Vector3D &position) override; - void setLinearVelolocity(const Vector3D &velocity) override; - void setAngularVelocity(const Vector3D &velocity) override; - - void resetForceAndTorque() override; - - Vector3D getVelocityAtPosition(const Vector3D &position) const override; - Vector3D getLinearVelocity() const override; - Vector3D getAngularVelocity() const override; - Vector3D getPosition() const override; - Vector3D getForce() const override; - Vector3D getTorque() const override; - - void changeState(State state) override; - - int getId() const; - void setId(int id); - void setGeometry(walberla::pe::RigidBody *peGeoObject); - - void setActive(); - void setInactive(); - bool isActive(); - // void increaseShadowCounter(); - // void decreaseShad - int shadowCounter; - int counter; - - unsigned long long getSystemID() const { return systemID; } - void setSystemID(unsigned long long val) { systemID = val; } - bool getSemiactive() const { return semiactive; } - void setSemiactive(bool val) { semiactive = val; } - -private: - walberla::pe::RigidBody *peGeoObject; - // unsigned long long id; - int id; - // walberla::id_t systemId; - unsigned long long systemID; - bool active; - bool semiactive; -}; - -#endif diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.cpp deleted file mode 100644 index 6a36fa1a3b6415e255e0083ec621f1bcea03e3de..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "PePhysicsEngineMaterialAdapter.h" - -walberla::pe::MaterialID PePhysicsEngineMaterialAdapter::getPeMaterial() const -{ - if (walberla::pe::Material::find(name) != -1) - return walberla::pe::Material::find(name); - - return walberla::pe::createMaterial(name, density, restitution, staticFriction, dynamicFriction, poissonRatio, - youngModul, stiffnessInNormalDirection, dampingoefficientNormalDirection, - dampingTangentialDirection); -} diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.h deleted file mode 100644 index 6ebfa8d1d9ca67760bffb9e06cafec256b19cf4f..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef PE_PHYSICS_ENGINE_MATERIAL_ADAPTER -#define PE_PHYSICS_ENGINE_MATERIAL_ADAPTER - -#include "../PhysicsEngineMaterialAdapter.h" -#include <pe/basic.h> - -class PePhysicsEngineMaterialAdapter : public PhysicsEngineMaterialAdapter -{ -public: - PePhysicsEngineMaterialAdapter(std::string name, double density, double restitution, double staticFriction, - double dynamicFriction, double poissonRatio, double youngModul, - double stiffnessInNormalDirection, double dampingoefficientNormalDirection, - double dampingTangentialDirection) - : PhysicsEngineMaterialAdapter(name, density, restitution, staticFriction, dynamicFriction, poissonRatio, - youngModul, stiffnessInNormalDirection, dampingoefficientNormalDirection, - dampingTangentialDirection) - { - } - virtual ~PePhysicsEngineMaterialAdapter() {} - - virtual walberla::pe::MaterialID getPeMaterial() const; -}; - -#endif diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp deleted file mode 100644 index 14cef406392fbfbd9862a71b0c054df85a8608ec..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp +++ /dev/null @@ -1,235 +0,0 @@ -#include "PePhysicsEngineSolverAdapter.h" - -#include <exception> - -#include "pe/rigidbody/BoxFactory.h" -#include "pe/rigidbody/PlaneFactory.h" -#include "pe/rigidbody/SphereFactory.h" -#include <pe/basic.h> -#include <pe/rigidbody/UnionFactory.h> -//#include "geometry/GeometricalFunctions.h" -#include <mpi/Communicator.h> -#include "PeAdapter.h" -#include "PeLoadBalancerAdapter.h" -#include "PePhysicsEngineGeometryAdapter.h" -#include "PePhysicsEngineMaterialAdapter.h" -#include "UbException.h" -#include "UbLogger.h" -#include "UbSystem.h" -#include <boost/tuple/tuple.hpp> -#include <memory> - -using namespace walberla; -using namespace walberla::pe; - -typedef boost::tuple<walberla::pe::Box, walberla::pe::Sphere, walberla::pe::Plane> BodyTypeTuple; - -PePhysicsEngineSolverAdapter::PePhysicsEngineSolverAdapter(std::shared_ptr<PeParameter> peParameter, - std::shared_ptr<PeLoadBalancerAdapter> loadBalancer) - : peParameter(peParameter), loadBalancer(loadBalancer) -{ - this->initalizePeEnvironment(); -} - -void PePhysicsEngineSolverAdapter::initalizePeEnvironment() -{ - this->initialPeBodyStorage(); - this->initialPeBlockForest(); - this->initalBlockData(); - this->initalPeIntegrator(); - this->executePeBodyTypeTuple(); - this->initialPeChannel(); -} - -std::shared_ptr<PhysicsEngineGeometryAdapter> PePhysicsEngineSolverAdapter::createPhysicsEngineGeometryAdapter( - int id, const Vector3D &position, double radius, std::shared_ptr<PhysicsEngineMaterialAdapter> material) const -{ - const std::shared_ptr<PePhysicsEngineMaterialAdapter> peMaterial = - std::dynamic_pointer_cast<PePhysicsEngineMaterialAdapter>(material); - std::shared_ptr<PePhysicsEngineGeometryAdapter> peGeometryAdapter(new PePhysicsEngineGeometryAdapter()); - - // UBLOG(logINFO, "PePhysicsEngineSolverAdapter::createSphere():start"); - walberla::pe::GeomID peGeometry = createSphere(*globalBodyStorage, *forest, *storageId, id, - PeConverter::convert(position), radius, peMaterial->getPeMaterial()); - // UBLOG(logINFO, "PePhysicsEngineSolverAdapter::createSphere():end"); - - if (peGeometry) { - peGeometryAdapter->setId(id); - peGeometryAdapter->setSystemID(peGeometry->getSystemID()); - peGeometryAdapter->setActive(); - peGeometryAdapter->setGeometry(peGeometry); - return peGeometryAdapter; - } else { - peGeometryAdapter->setId(id); - peGeometryAdapter->setInactive(); - return peGeometryAdapter; - } - - walberla::pe::syncNextNeighbors<BodyTypeTuple>(*forest, *storageId); -} - -void PePhysicsEngineSolverAdapter::runTimestep(double step) -{ - cr->timestep(walberla::real_c(step)); - walberla::pe::syncNextNeighbors<BodyTypeTuple>(*forest, *storageId); -} - -void PePhysicsEngineSolverAdapter::initialPeBodyStorage() -{ - globalBodyStorage = std::make_shared<walberla::pe::BodyStorage>(); -} - -void PePhysicsEngineSolverAdapter::initialPeBlockForest() -{ - - // walberla::SetupBlockForest sforest = - // walberla::blockforest::createUniformBlockGrid(walberla::AABB(peParameter->simulationDomain[0], - // peParameter->simulationDomain[1], peParameter->simulationDomain[2], - // peParameter->simulationDomain[3], peParameter->simulationDomain[4], peParameter->simulationDomain[5]), // - // simulationDomain walberla::uint_t(val<1>(peParameter->numberOfBlocks)), - // walberla::uint_t(val<2>(peParameter->numberOfBlocks)), - // walberla::uint_t(val<3>(peParameter->numberOfBlocks)),walberla::uint_t(10),walberla::uint_t(10),walberla::uint_t(10), - // 5.0,false); - walberla::SetupBlockForest sforest; - // sforest.addWorkloadMemorySUIDAssignmentFunction( uniformWorkloadAndMemoryAssignment ); - sforest.init(walberla::AABB(peParameter->simulationDomain[0], peParameter->simulationDomain[1], - peParameter->simulationDomain[2], peParameter->simulationDomain[3], - peParameter->simulationDomain[4], peParameter->simulationDomain[5]), // simulationDomain - walberla::uint_t(val<1>(peParameter->numberOfBlocks)), - walberla::uint_t(val<2>(peParameter->numberOfBlocks)), - walberla::uint_t(val<3>(peParameter->numberOfBlocks)), // blocks in each direction - val<1>(peParameter->isPeriodic), val<2>(peParameter->isPeriodic), val<3>(peParameter->isPeriodic)); - sforest.balanceLoad(*loadBalancer.get(), loadBalancer->getNumberOfProcesses()); - forest = std::shared_ptr<walberla::blockforest::BlockForest>( - new walberla::blockforest::BlockForest(walberla::uint_c(loadBalancer->getRank()), sforest)); - - auto mpiManager = walberla::MPIManager::instance(); - mpiManager->useWorldComm(); - if (!forest) - throw std::runtime_error("No PE BlockForest created ... "); -} - -void PePhysicsEngineSolverAdapter::initalBlockData() -{ - storageId = std::make_shared<walberla::domain_decomposition::BlockDataID>( - forest->addBlockData(walberla::pe::createStorageDataHandling<BodyTypeTuple>(), "Storage")); -} - -void PePhysicsEngineSolverAdapter::initalPeIntegrator() -{ - auto ccdID = - forest->addBlockData(walberla::pe::ccd::createHashGridsDataHandling(globalBodyStorage, *storageId), "CCD"); - auto fcdID = forest->addBlockData( - walberla::pe::fcd::createGenericFCDDataHandling<BodyTypeTuple, walberla::pe::fcd::AnalyticCollideFunctor>(), - "FCD"); - - cr = std::make_shared<walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers>(globalBodyStorage, forest, - *storageId, ccdID, fcdID); - cr->setMaxIterations(peParameter->maxPeIterations); - cr->setRelaxationModel( - walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers::ApproximateInelasticCoulombContactByDecoupling); - cr->setRelaxationParameter(walberla::real_t(peParameter->relaxationParameter)); - cr->setGlobalLinearAcceleration(PeConverter::convert(peParameter->globalLinearAcceleration)); -} - -void PePhysicsEngineSolverAdapter::executePeBodyTypeTuple() { walberla::pe::SetBodyTypeIDs<BodyTypeTuple>::execute(); } - -void PePhysicsEngineSolverAdapter::initialPeChannel() const -{ - const walberla::pe::MaterialID material = peParameter->planes->getPeMaterial(); - - auto simulationDomain = forest->getDomain(); - - // createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(1, 0, 0), simulationDomain.minCorner(), material); - // createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(-1, 0, 0), simulationDomain.maxCorner(), material); - // createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, 1, 0), simulationDomain.minCorner(), material); - // createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, -1, 0), simulationDomain.maxCorner(), material); - // createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, 0, 1), simulationDomain.minCorner(), material); - // createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, 0, -1), simulationDomain.maxCorner(), material); - - Vector3D minOffset = peParameter->minOffset; - Vector3D maxOffset = peParameter->maxOffset; - - walberla::pe::Vec3 minX1_Offset(minOffset.X1(), 0, 0); - walberla::pe::Vec3 maxX1_Offset(maxOffset.X1(), 0, 0); - walberla::pe::Vec3 minX2_Offset(0, minOffset.X2(), 0); - walberla::pe::Vec3 maxX2_Offset(0, maxOffset.X2(), 0); - walberla::pe::Vec3 minX3_Offset(0, 0, minOffset.X3()); - walberla::pe::Vec3 maxX3_Offset(0, 0, maxOffset.X3()); - - walberla::pe::Vec3 minCorner = simulationDomain.minCorner(); - walberla::pe::Vec3 maxCorner = simulationDomain.maxCorner(); - - createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(1, 0, 0), minCorner + minX1_Offset, material); - createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(-1, 0, 0), maxCorner + maxX1_Offset, material); - createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, 1, 0), minCorner + minX2_Offset, material); - createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, -1, 0), maxCorner + maxX2_Offset, material); - createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, 0, 1), minCorner + minX3_Offset, material); - createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, 0, -1), maxCorner + maxX3_Offset, material); -} - -std::shared_ptr<walberla::blockforest::BlockForest> PePhysicsEngineSolverAdapter::getForest() { return forest; } - -void PePhysicsEngineSolverAdapter::saveToFile(const std::string &path) -{ - forest->saveToFile(path + "SerializeDeserialize.sbf"); - forest->saveBlockData("SerializeDeserialize.dump", *storageId.get()); -} - -void PePhysicsEngineSolverAdapter::loadFromFile(const std::string &path) -{ - // forest = std::make_shared< walberla::blockforest::BlockForest >( walberla::uint_c( - // walberla::MPIManager::instance()->rank() ), path+"SerializeDeserialize.sbf", true, false ); - std::string file = path + "SerializeDeserialize.sbf"; - forest = std::shared_ptr<walberla::blockforest::BlockForest>(new walberla::blockforest::BlockForest( - walberla::uint_c(walberla::MPIManager::instance()->rank()), file.c_str(), true, false)); - storageId = std::make_shared<walberla::domain_decomposition::BlockDataID>(forest->loadBlockData( - path + "SerializeDeserialize.dump", walberla::pe::createStorageDataHandling<BodyTypeTuple>(), "Storage")); - - this->initalPeIntegrator(); - - auto ccdID = - forest->addBlockData(walberla::pe::ccd::createHashGridsDataHandling(globalBodyStorage, *storageId), "CCD"); - auto fcdID = forest->addBlockData( - walberla::pe::fcd::createGenericFCDDataHandling<BodyTypeTuple, walberla::pe::fcd::AnalyticCollideFunctor>(), - "FCD"); - - cr = std::make_shared<walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers>(globalBodyStorage, forest, - *storageId, ccdID, fcdID); - cr->setMaxIterations(peParameter->maxPeIterations); - cr->setRelaxationModel( - walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers::ApproximateInelasticCoulombContactByDecoupling); - cr->setRelaxationParameter(walberla::real_t(peParameter->relaxationParameter)); - cr->setGlobalLinearAcceleration(PeConverter::convert(peParameter->globalLinearAcceleration)); - - this->executePeBodyTypeTuple(); - this->initialPeChannel(); - - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) { - walberla::pe::ccd::ICCD *ccd = blockIt->getData<walberla::pe::ccd::ICCD>(ccdID); - ccd->reloadBodies(); - } -} - -std::shared_ptr<walberla::blockforest::BlockForest> PePhysicsEngineSolverAdapter::getBlockForest() { return forest; } - -std::shared_ptr<walberla::domain_decomposition::BlockDataID> PePhysicsEngineSolverAdapter::getStorageId() -{ - return storageId; -} - -std::shared_ptr<walberla::pe::BodyStorage> PePhysicsEngineSolverAdapter::getGlobalBodyStorage() -{ - return globalBodyStorage; -} - -void PePhysicsEngineSolverAdapter::createObstacle(const Vector3D ¢er, const Vector3D &lengths) -{ - const walberla::pe::MaterialID material = peParameter->planes->getPeMaterial(); - bool global = true; - bool communicating = false; - bool infiniteMass = true; - - walberla::pe::createBox(*globalBodyStorage, *forest, *storageId, 0, PeConverter::convert(center), - PeConverter::convert(lengths), material, global, communicating, infiniteMass); -} diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.h deleted file mode 100644 index 5b2ef94b8a59b5073aebc7eb999db6e9eb860e3d..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef PE_PHYSICS_ENGINE_SOLVER_ADAPTER_H -#define PE_PHYSICS_ENGINE_SOLVER_ADAPTER_H - -#include <memory> -#include <shared_mutex> - -#include "UbTuple.h" -#include <pe/basic.h> - -#include "PePhysicsEngineSolverAdapter.h" -#include "PhysicsEngineSolverAdapter.h" - -class PePhysicsEngineMaterialAdapter; -class PhysicsEngineGeometryAdapter; -class PePhysicsEngineGeometryAdapter; -class PeLoadBalancerAdapter; - -namespace walberla -{ -namespace domain_decomposition -{ -class BlockDataID; -} -namespace blockforest -{ -class BlockForest; -} -namespace pe -{ -class BodyStorage; -class RigidBody; -namespace cr -{ -class HardContactSemiImplicitTimesteppingSolvers; -} -} // namespace pe -} // namespace walberla - -struct PeParameter { - PeParameter(double relaxationParameter, int maxPeIterations, Vector3D globalLinearAcceleration, - std::shared_ptr<PePhysicsEngineMaterialAdapter> planes, std::array<double, 6> simulationDomain, - UbTupleInt3 numberOfBlocks, UbTupleBool3 isPeriodic, Vector3D minOffset, Vector3D maxOffset) - : relaxationParameter(relaxationParameter), maxPeIterations(maxPeIterations), - globalLinearAcceleration(globalLinearAcceleration), simulationDomain(simulationDomain), - numberOfBlocks(numberOfBlocks), isPeriodic(isPeriodic), planes(planes), minOffset(minOffset), - maxOffset(maxOffset) - { - } - - double relaxationParameter; - int maxPeIterations; - Vector3D globalLinearAcceleration; - - std::array<double, 6> simulationDomain; - UbTupleInt3 numberOfBlocks; - UbTupleBool3 isPeriodic; - - std::shared_ptr<PePhysicsEngineMaterialAdapter> planes; - - Vector3D minOffset; - Vector3D maxOffset; -}; - -class PePhysicsEngineSolverAdapter : public PhysicsEngineSolverAdapter -{ -public: - PePhysicsEngineSolverAdapter(std::shared_ptr<PeParameter> peParameter, - std::shared_ptr<PeLoadBalancerAdapter> loadBalancer); - virtual ~PePhysicsEngineSolverAdapter() {} - - std::shared_ptr<PhysicsEngineGeometryAdapter> - createPhysicsEngineGeometryAdapter(int id, const Vector3D &position, double radius, - std::shared_ptr<PhysicsEngineMaterialAdapter> material) const override; - void runTimestep(double step) override; - std::shared_ptr<walberla::blockforest::BlockForest> getForest(); - void saveToFile(const std::string &path); - void loadFromFile(const std::string &path); - std::shared_ptr<walberla::blockforest::BlockForest> getBlockForest(); - std::shared_ptr<walberla::domain_decomposition::BlockDataID> getStorageId(); - std::shared_ptr<walberla::pe::BodyStorage> getGlobalBodyStorage(); - void createObstacle(const Vector3D ¢er, const Vector3D &lengths); - -private: - void initalizePeEnvironment(); - void initialPeBodyStorage(); - void initialPeBlockForest(); - void initalBlockData(); - - void initalPeIntegrator(); - static void executePeBodyTypeTuple(); - void initialPeChannel() const; - -private: - std::shared_ptr<PeParameter> peParameter; - std::shared_ptr<PeLoadBalancerAdapter> loadBalancer; - - std::shared_ptr<walberla::pe::BodyStorage> globalBodyStorage; - std::shared_ptr<walberla::blockforest::BlockForest> forest; - std::shared_ptr<walberla::domain_decomposition::BlockDataID> storageId; - std::shared_ptr<walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers> cr; -}; - -#endif diff --git a/src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.cpp b/src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.cpp deleted file mode 100644 index c5486db0e23d6df29a04e724471bac74c01ceec8..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "EquilibriumReconstructor.h" - -#include "BCArray3D.h" -#include "BCProcessor.h" -#include "D3Q27System.h" -#include "DataSet3D.h" -#include "ILBMKernel.h" - -#include "PhysicsEngineGeometryAdapter.h" - -void EquilibriumReconstructor::reconstructNode(const int &x1, const int &x2, const int &x3, - const Vector3D &worldCoordinates, - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, - std::shared_ptr<ILBMKernel> kernel) const -{ - const double averageDensity = this->getLocalAverageDensity(x1, x2, x3, kernel); - LBMReal feq[27]; - const Vector3D boundaryVelocity = physicsEngineGeometry->getVelocityAtPosition(worldCoordinates); - - if (kernel->getCompressible()) - D3Q27System::calcCompFeq(feq, averageDensity, boundaryVelocity[0], boundaryVelocity[1], boundaryVelocity[2]); - else - D3Q27System::calcIncompFeq(feq, averageDensity, boundaryVelocity[0], boundaryVelocity[1], boundaryVelocity[2]); - - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - // distributions->setDistribution(feq, x1, x2, x3); - distributions->setDistributionInv(feq, x1, x2, x3); -} - -double EquilibriumReconstructor::getLocalAverageDensity(const int &x1, const int &x2, const int &x3, - std::shared_ptr<ILBMKernel> kernel) const -{ - int nAverage = 0; - double averageDensity = 0.0; - - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - - LBMReal f[D3Q27System::ENDF + 1]; - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - - int neighborX1, neighborX2, neighborX3; - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) { - neighborX1 = x1 + D3Q27System::DX1[fDir]; - neighborX2 = x2 + D3Q27System::DX2[fDir]; - neighborX3 = x3 + D3Q27System::DX3[fDir]; - - if (bcArray->isFluid(neighborX1, neighborX2, neighborX3)) { - distributions->getDistribution(f, neighborX1, neighborX2, neighborX3); - averageDensity += D3Q27System::getDensity(f); - ++nAverage; - } - } - return (nAverage > 0) ? averageDensity / nAverage : 0.0; -} diff --git a/src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.h b/src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.h deleted file mode 100644 index 4a5c0071922645f66baeb6dcf8577f7003ca9078..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef EQUILIBRIUM_RECONSTRUCTOR_H -#define EQUILIBRIUM_RECONSTRUCTOR_H - -#include "UbTuple.h" - -#include "Reconstructor.h" - -class ILBMKernel; -class PhysicsEngineGeometryAdapter; - -class EquilibriumReconstructor : public Reconstructor -{ -public: - virtual ~EquilibriumReconstructor() {} - - void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D &worldCoordinates, - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, - std::shared_ptr<ILBMKernel> kernel) const override; - -private: - double getLocalAverageDensity(const int &x1, const int &x2, const int &x3, - std::shared_ptr<ILBMKernel> kernel) const; -}; - -#endif diff --git a/src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.cpp b/src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.cpp deleted file mode 100644 index 8bd915b6c130fd8a1b70cf9e54cbfdfc60b6efcc..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "ExtrapolationReconstructor.h" - -#include "BCArray3D.h" -#include "BCProcessor.h" -#include "D3Q27System.h" -#include "DataSet3D.h" -#include "ILBMKernel.h" - -#include "DistributionArray3D.h" -#include "PhysicsEngineGeometryAdapter.h" - -void ExtrapolationReconstructor::setAlternativeReconstructor(std::shared_ptr<Reconstructor> alternativeReconstructor) -{ - this->alternativeReconstructor = alternativeReconstructor; -} - -ExtrapolationReconstructor::ExtrapolationReconstructor(std::shared_ptr<Reconstructor> alternativeReconstructor) - : alternativeReconstructor(alternativeReconstructor) -{ -} - -void ExtrapolationReconstructor::reconstructNode(const int &x1, const int &x2, const int &x3, - const Vector3D &worldCoordinates, - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, - std::shared_ptr<ILBMKernel> kernel) const -{ - const UbTupleInt3 extrapolationDirection = getSphereDirection(worldCoordinates, physicsEngineGeometry); - const int numberOfCellsForExtrapolation = getNumberOfExtrapolationCells(x1, x2, x3, extrapolationDirection, kernel); - - // if (numberOfCellsForExtrapolation < 2) - alternativeReconstructor->reconstructNode(x1, x2, x3, worldCoordinates, physicsEngineGeometry, kernel); - // else - //{ - // //UBLOG(logINFO, "point (x,y,z) " << val<1>(worldCoordinates) << ", " << val<2>(worldCoordinates) << ", " << - // val<3>(worldCoordinates)); - // //UBLOG(logINFO, "extradir (x,y,z) " << val<1>(extrapolationDirection) << ", " << - // val<2>(extrapolationDirection) << ", " << val<3>(extrapolationDirection)); - // //UBLOG(logINFO, "numberOfCellsForExtrapolation: " << numberOfCellsForExtrapolation ); - - // this->extrapolatePdFs(x1, x2, x3, extrapolationDirection, numberOfCellsForExtrapolation, kernel); - //} -} - -UbTupleInt3 ExtrapolationReconstructor::getSphereDirection( - const Vector3D &worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry) const -{ - const Vector3D spherePosition = physicsEngineGeometry->getPosition(); - const Vector3D bodyNormal = worldCoordinates - spherePosition; - return this->getCorrespondingLatticeDirection(bodyNormal); -} - -UbTupleInt3 ExtrapolationReconstructor::getCorrespondingLatticeDirection(const Vector3D &direction) const -{ - int correspondingDirection = 0; - double innerProduct = 0.0; - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) { - // compute inner product <dir,c_i> - const double temporaryInnerProduct = direction[0] * D3Q27System::cNorm[0][fDir] + - direction[1] * D3Q27System::cNorm[1][fDir] + - direction[2] * D3Q27System::cNorm[2][fDir]; - if (temporaryInnerProduct > innerProduct) { - innerProduct = temporaryInnerProduct; - correspondingDirection = fDir; - } - } - - return UbTupleInt3(D3Q27System::DX1[correspondingDirection], D3Q27System::DX2[correspondingDirection], - D3Q27System::DX3[correspondingDirection]); -} - -int ExtrapolationReconstructor::getNumberOfExtrapolationCells(const int x1, const int x2, const int x3, - const UbTupleInt3 &extrapolationDirection, - std::shared_ptr<ILBMKernel> kernel) const -{ - if (extrapolationDirection == UbTupleInt3(0, 0, 0)) - return 0; - - const int desiredCellsInExtrapolationDirection = 3; - - for (int numCells = 1; numCells <= desiredCellsInExtrapolationDirection; ++numCells) { - UbTupleInt3 neighbor(x1 + numCells * val<1>(extrapolationDirection), - x2 + numCells * val<2>(extrapolationDirection), - x3 + numCells * val<3>(extrapolationDirection)); - - if (!kernel->isInsideOfDomain(val<1>(neighbor), val<2>(neighbor), val<3>(neighbor))) - return numCells - 1; - - if (!kernel->getBCProcessor()->getBCArray()->isFluid(val<1>(neighbor), val<2>(neighbor), val<3>(neighbor))) - return numCells - 1; - } - return desiredCellsInExtrapolationDirection; -} - -void ExtrapolationReconstructor::extrapolatePdFs(const int x1, const int x2, const int x3, - const UbTupleInt3 &extrapolationDirection, - int numberOfCellsForExtrapolation, - std::shared_ptr<ILBMKernel> kernel) const -{ - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - - const int nx1 = val<1>(extrapolationDirection); - const int nx2 = val<2>(extrapolationDirection); - const int nx3 = val<3>(extrapolationDirection); - - LBMReal pdf[D3Q27System::ENDF + 1]; - LBMReal pdfNeighbor1[D3Q27System::ENDF + 1]; - LBMReal pdfNeighbor2[D3Q27System::ENDF + 1]; - - distributions->getDistribution(pdf, x1, x2, x3); - distributions->getDistribution(pdfNeighbor1, x1 + nx1, x2 + nx2, x3 + nx3); - distributions->getDistribution(pdfNeighbor2, x1 + 2 * nx1, x2 + 2 * nx2, x3 + 2 * nx3); - - if (numberOfCellsForExtrapolation == 3) // quadratic normal extrapolation - { - LBMReal pdfNeighbor3[D3Q27System::ENDF + 1]; - distributions->getDistribution(pdfNeighbor3, x1 + 3 * nx1, x2 + 3 * nx2, x3 + 3 * nx3); - - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) - pdf[fDir] = 3 * pdfNeighbor1[fDir] - 3 * pdfNeighbor2[fDir] + pdfNeighbor3[fDir]; - } else // numberOfCellsForExtrapolation == 2 // linear normal extrapolation - { - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) - pdf[fDir] = 2 * pdfNeighbor1[fDir] - pdfNeighbor2[fDir]; - } - - distributions->setDistribution(pdf, x1, x2, x3); -} diff --git a/src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.h b/src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.h deleted file mode 100644 index 2844fdf2490a43e6db31ea9bf32dbcdea67d6f34..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef EXTRAPOLATION_RECONSTRUCTOR_H -#define EXTRAPOLATION_RECONSTRUCTOR_H - -#include <memory> - -#include "UbTuple.h" - -#include "Reconstructor.h" - -class ILBMKernel; -class PhysicsEngineGeometryAdapter; - -class ExtrapolationReconstructor : public Reconstructor -{ -public: - ExtrapolationReconstructor(std::shared_ptr<Reconstructor> alternativeReconstructor); - virtual ~ExtrapolationReconstructor() {} - - void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D &worldCoordinates, - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, - std::shared_ptr<ILBMKernel> kernel) const override; - - void setAlternativeReconstructor(std::shared_ptr<Reconstructor> alternativeReconstructor); - -private: - int getNumberOfExtrapolationCells(const int x1, const int x2, const int x3, const UbTupleInt3 &ubTuple, - std::shared_ptr<ILBMKernel> kernel) const; - UbTupleInt3 getSphereDirection(const Vector3D &worldCoordinates, - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry) const; - UbTupleInt3 getCorrespondingLatticeDirection(const Vector3D &direction) const; - void extrapolatePdFs(const int x1, const int x2, const int x3, const UbTupleInt3 &ubTuple, - int numberOfCellsForExtrapolation, std::shared_ptr<ILBMKernel> kernel) const; - - std::shared_ptr<Reconstructor> alternativeReconstructor; -}; - -#endif diff --git a/src/cpu/DemCoupling/reconstructor/LBMReconstructor.cpp b/src/cpu/DemCoupling/reconstructor/LBMReconstructor.cpp deleted file mode 100644 index c6dfdc6dfbe064918fc50faf3222ed14d2b3a8d3..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/reconstructor/LBMReconstructor.cpp +++ /dev/null @@ -1,133 +0,0 @@ -#include "LBMReconstructor.h" - -#include "BCArray3D.h" -#include "BCProcessor.h" -#include "D3Q27System.h" -#include "DataSet3D.h" -#include "ILBMKernel.h" - -#include "PhysicsEngineGeometryAdapter.h" - -using namespace D3Q27System; - -LBMReconstructor::LBMReconstructor(bool compressible) -{ - if (compressible) { - calcMacrosFct = &D3Q27System::calcCompMacroscopicValues; - } else { - calcMacrosFct = &D3Q27System::calcIncompMacroscopicValues; - } -} - -void LBMReconstructor::reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D &worldCoordinates, - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, - std::shared_ptr<ILBMKernel> kernel) const -{ - LBMReal pdf[D3Q27System::ENDF + 1]; - - LBMReal rho, vx1, vx2, vx3; - calcMacrosFct(pdf, rho, vx1, vx2, vx3); - - LBMReal rho_dif = 1; - - while (rho_dif > 1e-5) { - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) { - - UbTupleInt3 neighbor(x1 + D3Q27System::DX1[fDir], x2 + D3Q27System::DX2[fDir], x3 + D3Q27System::DX3[fDir]); - - if (!kernel->getBCProcessor()->getBCArray()->isFluid(val<1>(neighbor), val<2>(neighbor), - val<3>(neighbor))) { - LBMReal pdfNeighbor[D3Q27System::ENDF + 1]; - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - const int invDir = D3Q27System::INVDIR[fDir]; - distributions->getDistributionForDirection(pdfNeighbor[invDir], val<1>(neighbor), val<2>(neighbor), - val<3>(neighbor)); - distributions->setDistributionInvForDirection(pdf[invDir], x1, x2, x3, invDir); - } - } - } - - LBMReal collFactor = kernel->getCollisionFactor(); - collide(pdf, collFactor); -} - -void LBMReconstructor::collide(LBMReal *f, LBMReal collFactor) -{ - - LBMReal drho, vx1, vx2, vx3; - LBMReal feq[D3Q27System::ENDF + 1]; - - drho = ((f[TNE] + f[BSW]) + (f[TSE] + f[BNW])) + ((f[BSE] + f[TNW]) + (f[TSW] + f[BNE])) + - (((f[NE] + f[SW]) + (f[SE] + f[NW])) + ((f[TE] + f[BW]) + (f[BE] + f[TW])) + - ((f[BN] + f[TS]) + (f[TN] + f[BS]))) + - ((f[E] + f[W]) + (f[N] + f[S]) + (f[T] + f[B])) + f[ZERO]; - - vx1 = ((((f[TNE] - f[BSW]) + (f[TSE] - f[BNW])) + ((f[BSE] - f[TNW]) + (f[BNE] - f[TSW]))) + - (((f[BE] - f[TW]) + (f[TE] - f[BW])) + ((f[SE] - f[NW]) + (f[NE] - f[SW]))) + (f[E] - f[W])); - - vx2 = ((((f[TNE] - f[BSW]) + (f[BNW] - f[TSE])) + ((f[TNW] - f[BSE]) + (f[BNE] - f[TSW]))) + - (((f[BN] - f[TS]) + (f[TN] - f[BS])) + ((f[NW] - f[SE]) + (f[NE] - f[SW]))) + (f[N] - f[S])); - - vx3 = ((((f[TNE] - f[BSW]) + (f[TSE] - f[BNW])) + ((f[TNW] - f[BSE]) + (f[TSW] - f[BNE]))) + - (((f[TS] - f[BN]) + (f[TN] - f[BS])) + ((f[TW] - f[BE]) + (f[TE] - f[BW]))) + (f[T] - f[B])); - - LBMReal cu_sq = 1.5 * (vx1 * vx1 + vx2 * vx2 + vx3 * vx3); - - feq[ZERO] = c8o27 * (drho - cu_sq); - feq[E] = c2o27 * (drho + 3.0 * (vx1) + c9o2 * (vx1) * (vx1)-cu_sq); - feq[W] = c2o27 * (drho + 3.0 * (-vx1) + c9o2 * (-vx1) * (-vx1) - cu_sq); - feq[N] = c2o27 * (drho + 3.0 * (vx2) + c9o2 * (vx2) * (vx2)-cu_sq); - feq[S] = c2o27 * (drho + 3.0 * (-vx2) + c9o2 * (-vx2) * (-vx2) - cu_sq); - feq[T] = c2o27 * (drho + 3.0 * (vx3) + c9o2 * (vx3) * (vx3)-cu_sq); - feq[B] = c2o27 * (drho + 3.0 * (-vx3) + c9o2 * (-vx3) * (-vx3) - cu_sq); - feq[NE] = c1o54 * (drho + 3.0 * (vx1 + vx2) + c9o2 * (vx1 + vx2) * (vx1 + vx2) - cu_sq); - feq[SW] = c1o54 * (drho + 3.0 * (-vx1 - vx2) + c9o2 * (-vx1 - vx2) * (-vx1 - vx2) - cu_sq); - feq[SE] = c1o54 * (drho + 3.0 * (vx1 - vx2) + c9o2 * (vx1 - vx2) * (vx1 - vx2) - cu_sq); - feq[NW] = c1o54 * (drho + 3.0 * (-vx1 + vx2) + c9o2 * (-vx1 + vx2) * (-vx1 + vx2) - cu_sq); - feq[TE] = c1o54 * (drho + 3.0 * (vx1 + vx3) + c9o2 * (vx1 + vx3) * (vx1 + vx3) - cu_sq); - feq[BW] = c1o54 * (drho + 3.0 * (-vx1 - vx3) + c9o2 * (-vx1 - vx3) * (-vx1 - vx3) - cu_sq); - feq[BE] = c1o54 * (drho + 3.0 * (vx1 - vx3) + c9o2 * (vx1 - vx3) * (vx1 - vx3) - cu_sq); - feq[TW] = c1o54 * (drho + 3.0 * (-vx1 + vx3) + c9o2 * (-vx1 + vx3) * (-vx1 + vx3) - cu_sq); - feq[TN] = c1o54 * (drho + 3.0 * (vx2 + vx3) + c9o2 * (vx2 + vx3) * (vx2 + vx3) - cu_sq); - feq[BS] = c1o54 * (drho + 3.0 * (-vx2 - vx3) + c9o2 * (-vx2 - vx3) * (-vx2 - vx3) - cu_sq); - feq[BN] = c1o54 * (drho + 3.0 * (vx2 - vx3) + c9o2 * (vx2 - vx3) * (vx2 - vx3) - cu_sq); - feq[TS] = c1o54 * (drho + 3.0 * (-vx2 + vx3) + c9o2 * (-vx2 + vx3) * (-vx2 + vx3) - cu_sq); - feq[TNE] = c1o216 * (drho + 3.0 * (vx1 + vx2 + vx3) + c9o2 * (vx1 + vx2 + vx3) * (vx1 + vx2 + vx3) - cu_sq); - feq[BSW] = c1o216 * (drho + 3.0 * (-vx1 - vx2 - vx3) + c9o2 * (-vx1 - vx2 - vx3) * (-vx1 - vx2 - vx3) - cu_sq); - feq[BNE] = c1o216 * (drho + 3.0 * (vx1 + vx2 - vx3) + c9o2 * (vx1 + vx2 - vx3) * (vx1 + vx2 - vx3) - cu_sq); - feq[TSW] = c1o216 * (drho + 3.0 * (-vx1 - vx2 + vx3) + c9o2 * (-vx1 - vx2 + vx3) * (-vx1 - vx2 + vx3) - cu_sq); - feq[TSE] = c1o216 * (drho + 3.0 * (vx1 - vx2 + vx3) + c9o2 * (vx1 - vx2 + vx3) * (vx1 - vx2 + vx3) - cu_sq); - feq[BNW] = c1o216 * (drho + 3.0 * (-vx1 + vx2 - vx3) + c9o2 * (-vx1 + vx2 - vx3) * (-vx1 + vx2 - vx3) - cu_sq); - feq[BSE] = c1o216 * (drho + 3.0 * (vx1 - vx2 - vx3) + c9o2 * (vx1 - vx2 - vx3) * (vx1 - vx2 - vx3) - cu_sq); - feq[TNW] = c1o216 * (drho + 3.0 * (-vx1 + vx2 + vx3) + c9o2 * (-vx1 + vx2 + vx3) * (-vx1 + vx2 + vx3) - cu_sq); - - // Relaxation - f[ZERO] += (feq[ZERO] - f[ZERO]) * collFactor; - f[E] += (feq[E] - f[E]) * collFactor; - f[W] += (feq[W] - f[W]) * collFactor; - f[N] += (feq[N] - f[N]) * collFactor; - f[S] += (feq[S] - f[S]) * collFactor; - f[T] += (feq[T] - f[T]) * collFactor; - f[B] += (feq[B] - f[B]) * collFactor; - f[NE] += (feq[NE] - f[NE]) * collFactor; - f[SW] += (feq[SW] - f[SW]) * collFactor; - f[SE] += (feq[SE] - f[SE]) * collFactor; - f[NW] += (feq[NW] - f[NW]) * collFactor; - f[TE] += (feq[TE] - f[TE]) * collFactor; - f[BW] += (feq[BW] - f[BW]) * collFactor; - f[BE] += (feq[BE] - f[BE]) * collFactor; - f[TW] += (feq[TW] - f[TW]) * collFactor; - f[TN] += (feq[TN] - f[TN]) * collFactor; - f[BS] += (feq[BS] - f[BS]) * collFactor; - f[BN] += (feq[BN] - f[BN]) * collFactor; - f[TS] += (feq[TS] - f[TS]) * collFactor; - - f[TNE] += (feq[TNE] - f[TNE]) * collFactor; - f[BSW] += (feq[BSW] - f[BSW]) * collFactor; - f[BNE] += (feq[BNE] - f[BNE]) * collFactor; - f[TSW] += (feq[TSW] - f[TSW]) * collFactor; - f[TSE] += (feq[TSE] - f[TSE]) * collFactor; - f[BNW] += (feq[BNW] - f[BNW]) * collFactor; - f[BSE] += (feq[BSE] - f[BSE]) * collFactor; - f[TNW] += (feq[TNW] - f[TNW]) * collFactor; -} \ No newline at end of file diff --git a/src/cpu/DemCoupling/reconstructor/LBMReconstructor.h b/src/cpu/DemCoupling/reconstructor/LBMReconstructor.h deleted file mode 100644 index 173f008a30bc9f1edf4b79eecce87fc0941d9f62..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/reconstructor/LBMReconstructor.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef LBM_RECONSTRUCTOR_H -#define LBM_RECONSTRUCTOR_H - -#include "UbTuple.h" - -#include "Reconstructor.h" - -#include "LBMSystem.h" - -class ILBMKernel; -class PhysicsEngineGeometryAdapter; - -class LBMReconstructor : public Reconstructor -{ -public: - LBMReconstructor(bool compressible); - virtual ~LBMReconstructor() {} - - void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D &worldCoordinates, - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, - std::shared_ptr<ILBMKernel> kernel) const override; - -private: - static void collide(LBMReal *f, LBMReal collFactor); - - typedef void (*CalcMacrosFct)(const LBMReal *const & /*f[27]*/, LBMReal & /*rho*/, LBMReal & /*vx1*/, - LBMReal & /*vx2*/, LBMReal & /*vx3*/); - CalcMacrosFct calcMacrosFct; -}; - -#endif diff --git a/src/cpu/DemCoupling/reconstructor/Reconstructor.h b/src/cpu/DemCoupling/reconstructor/Reconstructor.h deleted file mode 100644 index 15355d515dc332521583955f225c3e8758bb5fb7..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/reconstructor/Reconstructor.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef RECONSTRCUTOR_H -#define RECONSTRCUTOR_H - -#include <PointerDefinitions.h> - -#include "Vector3D.h" - -class ILBMKernel; -class PhysicsEngineGeometryAdapter; - -class Reconstructor -{ -public: - virtual ~Reconstructor() {} - - virtual void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D &worldCoordinates, - SPtr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, - std::shared_ptr<ILBMKernel> kernel) const = 0; -}; - -#endif diff --git a/src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.cpp b/src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.cpp deleted file mode 100644 index c48586ca4ed170d7129990590a7e7ec32154c5f7..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "VelocityBcReconstructor.h" - -#include <exception> - -#include "BCArray3D.h" -#include "BCProcessor.h" -#include "D3Q27System.h" -#include "DataSet3D.h" -#include "EsoTwist3D.h" -#include "ILBMKernel.h" - -#include "PhysicsEngineGeometryAdapter.h" - -void VelocityBcReconstructor::reconstructNode(const int &x1, const int &x2, const int &x3, - const Vector3D &worldCoordinates, - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, - std::shared_ptr<ILBMKernel> kernel) const -{ - if (kernel->getCompressible()) - throw std::runtime_error("not implemented yet!"); - - const Vector3D boundaryVelocity = physicsEngineGeometry->getVelocityAtPosition(worldCoordinates); - // TODO: move to D3Q27 system - LBMReal wijk[D3Q27System::ENDF + 1]; - D3Q27System::calcIncompFeq(wijk, 1, 0, 0, 0); - - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - - SPtr<BoundaryConditions> bc = SPtr<BoundaryConditions>(new BoundaryConditions()); - bc->setBoundaryVelocityX1((float)boundaryVelocity[0]); - bc->setBoundaryVelocityX2((float)boundaryVelocity[1]); - bc->setBoundaryVelocityX3((float)boundaryVelocity[2]); - - LBMReal feqNullRho[D3Q27System::ENDF + 1]; - D3Q27System::calcIncompFeq(feqNullRho, 0, boundaryVelocity[0], boundaryVelocity[1], boundaryVelocity[2]); - - LBMReal fpre[D3Q27System::ENDF + 1]; - LBMReal fpost[D3Q27System::ENDF + 1]; - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - - distributions->swap(); - distributions->getDistributionInv(fpost, x1, x2, x3); - distributions->swap(); - distributions->getDistribution(fpre, x1, x2, x3); - - int neighborX1, neighborX2, neighborX3; - int neighborX1Inv, neighborX2Inv, neighborX3Inv; - - double sumRho = 0, sumWijk = 0; - double collFactor = kernel->getCollisionFactor(); - - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) { - neighborX1 = x1 + D3Q27System::DX1[fDir]; - neighborX2 = x2 + D3Q27System::DX2[fDir]; - neighborX3 = x3 + D3Q27System::DX3[fDir]; - - if (bcArray->isFluid(neighborX1, neighborX2, neighborX3)) { - int invDir = D3Q27System::INVDIR[fDir]; - - neighborX1Inv = x1 + D3Q27System::DX1[invDir]; - neighborX2Inv = x2 + D3Q27System::DX2[invDir]; - neighborX3Inv = x3 + D3Q27System::DX3[invDir]; - if (!bcArray->isFluid(neighborX1Inv, neighborX2Inv, neighborX3Inv)) { - - double velocity = bc->getBoundaryVelocity(invDir); - - fpre[fDir] = fpre[invDir] - velocity; - double Omega = fpost[fDir] - fpre[fDir]; - - sumRho += Omega / collFactor + fpre[fDir] - feqNullRho[fDir]; - sumWijk += wijk[fDir]; - } - } - } - - double rho = 0.0; - if (sumWijk > 0.0) - rho = sumRho / sumWijk; - - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) { - neighborX1 = x1 + D3Q27System::DX1[fDir]; - neighborX2 = x2 + D3Q27System::DX2[fDir]; - neighborX3 = x3 + D3Q27System::DX3[fDir]; - - if (!bcArray->isFluid(neighborX1, neighborX2, neighborX3)) { - int invDir = D3Q27System::INVDIR[fDir]; - neighborX1Inv = x1 + D3Q27System::DX1[invDir]; - neighborX2Inv = x2 + D3Q27System::DX2[invDir]; - neighborX3Inv = x3 + D3Q27System::DX3[invDir]; - if (!bcArray->isFluid(neighborX1Inv, neighborX2Inv, neighborX3Inv)) { - fpre[fDir] = D3Q27System::getIncompFeqForDirection( - fDir, rho, bc->getBoundaryVelocityX1(), bc->getBoundaryVelocityX2(), bc->getBoundaryVelocityX3()); - } - } - } -} diff --git a/src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.h b/src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.h deleted file mode 100644 index 9f5b3f0b67be91edbcfcdadbc8f5c637a87827dc..0000000000000000000000000000000000000000 --- a/src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef VELOCITY_BC_RECONSTRUCTOR_H -#define VELOCITY_BC_RECONSTRUCTOR_H - -#include "UbTuple.h" - -#include "Reconstructor.h" - -class ILBMKernel; -class PhysicsEngineGeometryAdapter; - -class VelocityBcReconstructor : public Reconstructor -{ -public: - virtual ~VelocityBcReconstructor() {} - - void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D &worldCoordinates, - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, - std::shared_ptr<ILBMKernel> kernel) const override; -}; - -#endif diff --git a/src/cpu/LiggghtsCoupling/IBcumulantK17LBMKernel.cpp b/src/cpu/LiggghtsCoupling/IBcumulantK17LBMKernel.cpp index 838cd086adf298f53776ae5dc50e3e0e8279a7c7..ea39fc17d606498a4b977d77a5151f4fff6e216c 100644 --- a/src/cpu/LiggghtsCoupling/IBcumulantK17LBMKernel.cpp +++ b/src/cpu/LiggghtsCoupling/IBcumulantK17LBMKernel.cpp @@ -111,7 +111,7 @@ void IBcumulantK17LBMKernel::calculate(int step) //! using namespace std; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; //initializing of forcing stuff if (withForcing) diff --git a/src/cpu/LiggghtsCoupling/IBcumulantK17LBMKernel.h b/src/cpu/LiggghtsCoupling/IBcumulantK17LBMKernel.h index c13233ba733762fce9122f24b354cf10feef1c9a..985ba75df5f0d726868e4ff854c384ad62eeb630 100644 --- a/src/cpu/LiggghtsCoupling/IBcumulantK17LBMKernel.h +++ b/src/cpu/LiggghtsCoupling/IBcumulantK17LBMKernel.h @@ -94,7 +94,7 @@ protected: //////////////////////////////////////////////////////////////////////////////// inline void IBcumulantK17LBMKernel::forwardInverseChimeraWithK(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K) { - using namespace vf::lbm::constant; + using namespace vf::basics::constant; LBMReal m2 = mfa + mfc; LBMReal m1 = mfc - mfa; LBMReal m0 = m2 + mfb; @@ -112,7 +112,7 @@ inline void IBcumulantK17LBMKernel::forwardInverseChimeraWithK(LBMReal& mfa, LBM //////////////////////////////////////////////////////////////////////////////// inline void IBcumulantK17LBMKernel::backwardInverseChimeraWithK(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K) { - using namespace vf::lbm::constant; + using namespace vf::basics::constant; LBMReal m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + c1o1) * (v2 - vv) * c1o2) * K; LBMReal m1 = (((mfa - mfc) - c2o1 * mfb * vv) * Kinverse + (mfa * Kinverse + c1o1) * (-v2)) * K; mfc = (((mfc + mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + c1o1) * (v2 + vv) * c1o2) * K; @@ -128,7 +128,7 @@ inline void IBcumulantK17LBMKernel::backwardInverseChimeraWithK(LBMReal& mfa, LB //////////////////////////////////////////////////////////////////////////////// inline void IBcumulantK17LBMKernel::forwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2) { - using namespace vf::lbm::constant; + using namespace vf::basics::constant; LBMReal m1 = (mfa + mfc) + mfb; LBMReal m2 = mfc - mfa; mfc = (mfc + mfa) + (v2 * m1 - c2o1 * vv * m2); @@ -144,7 +144,7 @@ inline void IBcumulantK17LBMKernel::forwardChimera(LBMReal& mfa, LBMReal& mfb, L //////////////////////////////////////////////////////////////////////////////// inline void IBcumulantK17LBMKernel::backwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2) { - using namespace vf::lbm::constant; + using namespace vf::basics::constant; LBMReal ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); LBMReal mb = ((mfa - mfc) - mfa * v2) - c2o1 * mfb * vv; mfc = (mfc + mfa * (v2 + vv)) * c1o2 + mfb * (vv + c1o2); diff --git a/src/cpu/MultiphaseFlow/BoundaryConditions/MultiphaseNonReflectingOutflowBCStrategy.cpp b/src/cpu/MultiphaseFlow/BoundaryConditions/MultiphaseNonReflectingOutflowBCStrategy.cpp index 58faec07f46d9b6d708ce83dfc823838bcfcc4df..aae7dec82bde0bd3477558fd937f4058a26eddd0 100644 --- a/src/cpu/MultiphaseFlow/BoundaryConditions/MultiphaseNonReflectingOutflowBCStrategy.cpp +++ b/src/cpu/MultiphaseFlow/BoundaryConditions/MultiphaseNonReflectingOutflowBCStrategy.cpp @@ -72,7 +72,7 @@ void MultiphaseNonReflectingOutflowBCStrategy::applyBC() using namespace D3Q27System; // using namespace UbMath; using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real f[ENDF + 1]; real ftemp[ENDF + 1]; diff --git a/src/cpu/MultiphaseFlow/BoundaryConditions/MultiphaseSlipBCStrategy.cpp b/src/cpu/MultiphaseFlow/BoundaryConditions/MultiphaseSlipBCStrategy.cpp index 904a0ff19ff5b54c6aa083bbce3ba24d9766e720..59c44bcdd186fc49adc2f0f6e040e6ad826239c6 100644 --- a/src/cpu/MultiphaseFlow/BoundaryConditions/MultiphaseSlipBCStrategy.cpp +++ b/src/cpu/MultiphaseFlow/BoundaryConditions/MultiphaseSlipBCStrategy.cpp @@ -104,32 +104,32 @@ void MultiphaseSlipBCStrategy::applyBC() real velocity = vf::lbm::constant::c0o1; switch (invDir) { - case DIR_P00: velocity = (vf::lbm::constant::c4o9*(+vx1)); break; //(2/cs^2)(=6)*rho_0(=1 bei imkompr)*wi*u*ei mit cs=1/sqrt(3) - case DIR_M00: velocity = (vf::lbm::constant::c4o9*(-vx1)); break; //z.B. aus paper manfred MRT LB models in three dimensions (2002) - case DIR_0P0: velocity = (vf::lbm::constant::c4o9*(+vx2)); break; - case DIR_0M0: velocity = (vf::lbm::constant::c4o9*(-vx2)); break; - case DIR_00P: velocity = (vf::lbm::constant::c4o9*(+vx3)); break; - case DIR_00M: velocity = (vf::lbm::constant::c4o9*(-vx3)); break; - case DIR_PP0: velocity = (vf::lbm::constant::c1o9*(+vx1+vx2)); break; - case DIR_MM0: velocity = (vf::lbm::constant::c1o9*(-vx1-vx2)); break; - case DIR_PM0: velocity = (vf::lbm::constant::c1o9*(+vx1-vx2)); break; - case DIR_MP0: velocity = (vf::lbm::constant::c1o9*(-vx1+vx2)); break; - case DIR_P0P: velocity = (vf::lbm::constant::c1o9*(+vx1+vx3)); break; - case DIR_M0M: velocity = (vf::lbm::constant::c1o9*(-vx1-vx3)); break; - case DIR_P0M: velocity = (vf::lbm::constant::c1o9*(+vx1-vx3)); break; - case DIR_M0P: velocity = (vf::lbm::constant::c1o9*(-vx1+vx3)); break; - case DIR_0PP: velocity = (vf::lbm::constant::c1o9*(+vx2+vx3)); break; - case DIR_0MM: velocity = (vf::lbm::constant::c1o9*(-vx2-vx3)); break; - case DIR_0PM: velocity = (vf::lbm::constant::c1o9*(+vx2-vx3)); break; - case DIR_0MP: velocity = (vf::lbm::constant::c1o9*(-vx2+vx3)); break; - case DIR_PPP: velocity = (vf::lbm::constant::c1o36*(+vx1+vx2+vx3)); break; - case DIR_MMM: velocity = (vf::lbm::constant::c1o36*(-vx1-vx2-vx3)); break; - case DIR_PPM: velocity = (vf::lbm::constant::c1o36*(+vx1+vx2-vx3)); break; - case DIR_MMP: velocity = (vf::lbm::constant::c1o36*(-vx1-vx2+vx3)); break; - case DIR_PMP: velocity = (vf::lbm::constant::c1o36*(+vx1-vx2+vx3)); break; - case DIR_MPM: velocity = (vf::lbm::constant::c1o36*(-vx1+vx2-vx3)); break; - case DIR_PMM: velocity = (vf::lbm::constant::c1o36*(+vx1-vx2-vx3)); break; - case DIR_MPP: velocity = (vf::lbm::constant::c1o36*(-vx1+vx2+vx3)); break; + case DIR_P00: velocity = (vf::basics::constant::c4o9*(+vx1)); break; //(2/cs^2)(=6)*rho_0(=1 bei imkompr)*wi*u*ei mit cs=1/sqrt(3) + case DIR_M00: velocity = (vf::basics::constant::c4o9*(-vx1)); break; //z.B. aus paper manfred MRT LB models in three dimensions (2002) + case DIR_0P0: velocity = (vf::basics::constant::c4o9*(+vx2)); break; + case DIR_0M0: velocity = (vf::basics::constant::c4o9*(-vx2)); break; + case DIR_00P: velocity = (vf::basics::constant::c4o9*(+vx3)); break; + case DIR_00M: velocity = (vf::basics::constant::c4o9*(-vx3)); break; + case DIR_PP0: velocity = (vf::basics::constant::c1o9*(+vx1+vx2)); break; + case DIR_MM0: velocity = (vf::basics::constant::c1o9*(-vx1-vx2)); break; + case DIR_PM0: velocity = (vf::basics::constant::c1o9*(+vx1-vx2)); break; + case DIR_MP0: velocity = (vf::basics::constant::c1o9*(-vx1+vx2)); break; + case DIR_P0P: velocity = (vf::basics::constant::c1o9*(+vx1+vx3)); break; + case DIR_M0M: velocity = (vf::basics::constant::c1o9*(-vx1-vx3)); break; + case DIR_P0M: velocity = (vf::basics::constant::c1o9*(+vx1-vx3)); break; + case DIR_M0P: velocity = (vf::basics::constant::c1o9*(-vx1+vx3)); break; + case DIR_0PP: velocity = (vf::basics::constant::c1o9*(+vx2+vx3)); break; + case DIR_0MM: velocity = (vf::basics::constant::c1o9*(-vx2-vx3)); break; + case DIR_0PM: velocity = (vf::basics::constant::c1o9*(+vx2-vx3)); break; + case DIR_0MP: velocity = (vf::basics::constant::c1o9*(-vx2+vx3)); break; + case DIR_PPP: velocity = (vf::basics::constant::c1o36*(+vx1+vx2+vx3)); break; + case DIR_MMM: velocity = (vf::basics::constant::c1o36*(-vx1-vx2-vx3)); break; + case DIR_PPM: velocity = (vf::basics::constant::c1o36*(+vx1+vx2-vx3)); break; + case DIR_MMP: velocity = (vf::basics::constant::c1o36*(-vx1-vx2+vx3)); break; + case DIR_PMP: velocity = (vf::basics::constant::c1o36*(+vx1-vx2+vx3)); break; + case DIR_MPM: velocity = (vf::basics::constant::c1o36*(-vx1+vx2-vx3)); break; + case DIR_PMM: velocity = (vf::basics::constant::c1o36*(+vx1-vx2-vx3)); break; + case DIR_MPP: velocity = (vf::basics::constant::c1o36*(-vx1+vx2+vx3)); break; default: throw UbException(UB_EXARGS, "unknown error"); } real fReturn = ((vf::lbm::constant::c1o1-q)/(vf::lbm::constant::c1o1+q))*((f[invDir]-feq[invDir])/(vf::lbm::constant::c1o1-collFactor)+feq[invDir])+((q*(f[invDir]+f[fdir])-velocity*rho)/(vf::lbm::constant::c1o1+q)); diff --git a/src/cpu/MultiphaseFlow/LBM/MultiphaseCumulantLBMKernel.cpp b/src/cpu/MultiphaseFlow/LBM/MultiphaseCumulantLBMKernel.cpp index 834d37944bc0b47ac5d3fc5dd10194bdf63184d9..2655e916025b1d2b085348c06cb95c425813d83d 100644 --- a/src/cpu/MultiphaseFlow/LBM/MultiphaseCumulantLBMKernel.cpp +++ b/src/cpu/MultiphaseFlow/LBM/MultiphaseCumulantLBMKernel.cpp @@ -85,7 +85,7 @@ void MultiphaseCumulantLBMKernel::calculate(int step) using namespace D3Q27System; // using namespace UbMath; using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; forcingX1 = 0.0; forcingX2 = 0.0; diff --git a/src/cpu/MultiphaseFlow/LBM/MultiphasePressureFilterCompressibleAirLBMKernel.cpp b/src/cpu/MultiphaseFlow/LBM/MultiphasePressureFilterCompressibleAirLBMKernel.cpp index 92302b342927ccaf4e6d49e3a073fec732fac6ba..6dc3b454e1874382bb539d716147867f03514c38 100644 --- a/src/cpu/MultiphaseFlow/LBM/MultiphasePressureFilterCompressibleAirLBMKernel.cpp +++ b/src/cpu/MultiphaseFlow/LBM/MultiphasePressureFilterCompressibleAirLBMKernel.cpp @@ -94,7 +94,7 @@ SPtr<LBMKernel> MultiphasePressureFilterCompressibleAirLBMKernel::clone() ////////////////////////////////////////////////////////////////////////// void MultiphasePressureFilterCompressibleAirLBMKernel::forwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m2 = mfa + mfc; real m1 = mfc - mfa; @@ -109,7 +109,7 @@ void MultiphasePressureFilterCompressibleAirLBMKernel::forwardInverseChimeraWit //////////////////////////////////////////////////////////////////////////////// void MultiphasePressureFilterCompressibleAirLBMKernel::backwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 - vv) * c1o2) * K; real m1 = (((mfa - mfc) - c2o1 * mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (-v2)) * K; @@ -122,7 +122,7 @@ void MultiphasePressureFilterCompressibleAirLBMKernel::backwardInverseChimeraWi //////////////////////////////////////////////////////////////////////////////// void MultiphasePressureFilterCompressibleAirLBMKernel::forwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m1 = (mfa + mfc) + mfb; real m2 = mfc - mfa; @@ -134,7 +134,7 @@ void MultiphasePressureFilterCompressibleAirLBMKernel::forwardChimera(real& mfa void MultiphasePressureFilterCompressibleAirLBMKernel::backwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); real mb = ((mfa - mfc) - mfa * v2) - c2o1 * mfb * vv; @@ -149,7 +149,7 @@ void MultiphasePressureFilterCompressibleAirLBMKernel::calculate(int step) using namespace D3Q27System; // using namespace UbMath; using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; forcingX1 = 0.0; forcingX2 = 0.0; diff --git a/src/cpu/MultiphaseFlow/LBM/MultiphasePressureFilterLBMKernel.cpp b/src/cpu/MultiphaseFlow/LBM/MultiphasePressureFilterLBMKernel.cpp index 7e167838ad9ce09f2fd16769c1217602e700e607..1d0d66a1803968f98cdff629d0578ecb197ddc31 100644 --- a/src/cpu/MultiphaseFlow/LBM/MultiphasePressureFilterLBMKernel.cpp +++ b/src/cpu/MultiphaseFlow/LBM/MultiphasePressureFilterLBMKernel.cpp @@ -95,7 +95,7 @@ SPtr<LBMKernel> MultiphasePressureFilterLBMKernel::clone() ////////////////////////////////////////////////////////////////////////// void MultiphasePressureFilterLBMKernel::forwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m2 = mfa + mfc; real m1 = mfc - mfa; real m0 = m2 + mfb; @@ -109,7 +109,7 @@ void MultiphasePressureFilterLBMKernel::forwardInverseChimeraWithKincompressibl //////////////////////////////////////////////////////////////////////////////// void MultiphasePressureFilterLBMKernel::backwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 - vv) * c1o2) * K; real m1 = (((mfa - mfc) - c2o1 * mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (-v2)) * K; @@ -122,7 +122,7 @@ void MultiphasePressureFilterLBMKernel::backwardInverseChimeraWithKincompressib //////////////////////////////////////////////////////////////////////////////// void MultiphasePressureFilterLBMKernel::forwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m1 = (mfa + mfc) + mfb; real m2 = mfc - mfa; @@ -134,7 +134,7 @@ void MultiphasePressureFilterLBMKernel::forwardChimera(real& mfa, real& mfb, re void MultiphasePressureFilterLBMKernel::backwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); real mb = ((mfa - mfc) - mfa * v2) - c2o1 * mfb * vv; @@ -149,7 +149,7 @@ void MultiphasePressureFilterLBMKernel::calculate(int step) using namespace D3Q27System; // using namespace UbMath; using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; forcingX1 = 0.0; forcingX2 = 0.0; diff --git a/src/cpu/MultiphaseFlow/LBM/MultiphaseScratchCumulantLBMKernel.cpp b/src/cpu/MultiphaseFlow/LBM/MultiphaseScratchCumulantLBMKernel.cpp index 45e3131c29cd6dfa3364c72ab4642cc7fc4acc62..85d6dcadcd3f8ebf661d7f32f18dcbc54c4eb5c4 100644 --- a/src/cpu/MultiphaseFlow/LBM/MultiphaseScratchCumulantLBMKernel.cpp +++ b/src/cpu/MultiphaseFlow/LBM/MultiphaseScratchCumulantLBMKernel.cpp @@ -83,7 +83,7 @@ SPtr<LBMKernel> MultiphaseScratchCumulantLBMKernel::clone() ////////////////////////////////////////////////////////////////////////// void MultiphaseScratchCumulantLBMKernel::forwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m2 = mfa + mfc; real m1 = mfc - mfa; @@ -98,7 +98,7 @@ SPtr<LBMKernel> MultiphaseScratchCumulantLBMKernel::clone() //////////////////////////////////////////////////////////////////////////////// void MultiphaseScratchCumulantLBMKernel::backwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 - vv) * c1o2) * K; real m1 = (((mfa - mfc) - c2o1 * mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (-v2)) * K; @@ -111,7 +111,7 @@ SPtr<LBMKernel> MultiphaseScratchCumulantLBMKernel::clone() //////////////////////////////////////////////////////////////////////////////// void MultiphaseScratchCumulantLBMKernel::forwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m1 = (mfa + mfc) + mfb; real m2 = mfc - mfa; @@ -123,7 +123,7 @@ SPtr<LBMKernel> MultiphaseScratchCumulantLBMKernel::clone() void MultiphaseScratchCumulantLBMKernel::backwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); real mb = ((mfa - mfc) - mfa * v2) - c2o1 * mfb * vv; @@ -138,7 +138,7 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) using namespace D3Q27System; // using namespace UbMath; using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; forcingX1 = 0.0; forcingX2 = 0.0; diff --git a/src/cpu/MultiphaseFlow/LBM/MultiphaseSimpleVelocityBaseExternalPressureLBMKernel.cpp b/src/cpu/MultiphaseFlow/LBM/MultiphaseSimpleVelocityBaseExternalPressureLBMKernel.cpp index c1cbdd6256f86f5307f2df2ebc36549126020c66..047da3666e9f77cd5624f5a3479b3cb79a43990b 100644 --- a/src/cpu/MultiphaseFlow/LBM/MultiphaseSimpleVelocityBaseExternalPressureLBMKernel.cpp +++ b/src/cpu/MultiphaseFlow/LBM/MultiphaseSimpleVelocityBaseExternalPressureLBMKernel.cpp @@ -41,7 +41,7 @@ #include <cmath> #include <iostream> #include <string> -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" //#include <basics/utilities/UbMath.h> #define PROOF_CORRECTNESS @@ -99,7 +99,7 @@ SPtr<LBMKernel> MultiphaseSimpleVelocityBaseExternalPressureLBMKernel::clone() } ////////////////////////////////////////////////////////////////////////// void MultiphaseSimpleVelocityBaseExternalPressureLBMKernel::forwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m2 = mfa + mfc; real m1 = mfc - mfa; real m0 = m2 + mfb; @@ -112,7 +112,7 @@ void MultiphaseSimpleVelocityBaseExternalPressureLBMKernel::forwardInverseChime //////////////////////////////////////////////////////////////////////////////// void MultiphaseSimpleVelocityBaseExternalPressureLBMKernel::backwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 - vv) * c1o2) * K; real m1 = (((mfa - mfc) - c2o1 * mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (-v2)) * K; mfc = (((mfc + mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 + vv) * c1o2) * K; @@ -123,7 +123,7 @@ void MultiphaseSimpleVelocityBaseExternalPressureLBMKernel::backwardInverseChim //////////////////////////////////////////////////////////////////////////////// void MultiphaseSimpleVelocityBaseExternalPressureLBMKernel::forwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m1 = (mfa + mfc) + mfb; real m2 = mfc - mfa; mfc = (mfc + mfa) + (v2 * m1 - c2o1 * vv * m2); @@ -133,7 +133,7 @@ void MultiphaseSimpleVelocityBaseExternalPressureLBMKernel::forwardChimera(real void MultiphaseSimpleVelocityBaseExternalPressureLBMKernel::backwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); real mb = ((mfa - mfc) - mfa * v2) - c2o1 * mfb * vv; mfc = (mfc + mfa * (v2 + vv)) * c1o2 + mfb * (vv + c1o2); @@ -145,7 +145,7 @@ void MultiphaseSimpleVelocityBaseExternalPressureLBMKernel::backwardChimera(rea void MultiphaseSimpleVelocityBaseExternalPressureLBMKernel::calculate(int step) { using namespace D3Q27System; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; using namespace vf::lbm::dir; forcingX1 = 0.0; @@ -2980,7 +2980,7 @@ void MultiphaseSimpleVelocityBaseExternalPressureLBMKernel::findNeighbors(CbArra { using namespace D3Q27System; using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; SPtr<BCArray3D> bcArray = this->getBCSet()->getBCArray(); diff --git a/src/cpu/MultiphaseFlow/LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.cpp b/src/cpu/MultiphaseFlow/LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.cpp index c5bb37f3c04ae2b8bb1164bc34e69a55b38298e0..8abd71133dd7088199066b1de0975b8efb16ebc8 100644 --- a/src/cpu/MultiphaseFlow/LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.cpp +++ b/src/cpu/MultiphaseFlow/LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.cpp @@ -84,7 +84,7 @@ SPtr<LBMKernel> MultiphaseTwoPhaseFieldsCumulantLBMKernel::clone() ////////////////////////////////////////////////////////////////////////// void MultiphaseTwoPhaseFieldsCumulantLBMKernel::forwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m2 = mfa + mfc; real m1 = mfc - mfa; @@ -99,7 +99,7 @@ SPtr<LBMKernel> MultiphaseTwoPhaseFieldsCumulantLBMKernel::clone() //////////////////////////////////////////////////////////////////////////////// void MultiphaseTwoPhaseFieldsCumulantLBMKernel::backwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 - vv) * c1o2) * K; real m1 = (((mfa - mfc) - c2o1 * mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (-v2)) * K; @@ -112,7 +112,7 @@ SPtr<LBMKernel> MultiphaseTwoPhaseFieldsCumulantLBMKernel::clone() //////////////////////////////////////////////////////////////////////////////// void MultiphaseTwoPhaseFieldsCumulantLBMKernel::forwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m1 = (mfa + mfc) + mfb; real m2 = mfc - mfa; @@ -124,7 +124,7 @@ SPtr<LBMKernel> MultiphaseTwoPhaseFieldsCumulantLBMKernel::clone() void MultiphaseTwoPhaseFieldsCumulantLBMKernel::backwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); real mb = ((mfa - mfc) - mfa * v2) - c2o1 * mfb * vv; @@ -139,7 +139,7 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) using namespace D3Q27System; // using namespace UbMath; using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; forcingX1 = 0.0; forcingX2 = 0.0; diff --git a/src/cpu/MultiphaseFlow/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.cpp b/src/cpu/MultiphaseFlow/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.cpp index 1b0e6c85a4ffe371611423a7f9200065a7ef31a3..8a6c2bde6d5031a1b379bdd391aaa1051ca6217f 100644 --- a/src/cpu/MultiphaseFlow/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.cpp +++ b/src/cpu/MultiphaseFlow/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.cpp @@ -98,7 +98,7 @@ SPtr<LBMKernel> MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::clone() ////////////////////////////////////////////////////////////////////////// void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::forwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m2 = mfa + mfc; real m1 = mfc - mfa; @@ -113,7 +113,7 @@ SPtr<LBMKernel> MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::clone() //////////////////////////////////////////////////////////////////////////////// void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::backwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 - vv) * c1o2) * K; real m1 = (((mfa - mfc) - c2o1 * mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (-v2)) * K; @@ -126,7 +126,7 @@ SPtr<LBMKernel> MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::clone() //////////////////////////////////////////////////////////////////////////////// void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::forwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m1 = (mfa + mfc) + mfb; real m2 = mfc - mfa; @@ -138,7 +138,7 @@ SPtr<LBMKernel> MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::clone() void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::backwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); real mb = ((mfa - mfc) - mfa * v2) - c2o1 * mfb * vv; @@ -153,7 +153,7 @@ void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::calculate(int step) using namespace D3Q27System; // using namespace UbMath; using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; forcingX1 = 0.0; forcingX2 = 0.0; diff --git a/src/cpu/MultiphaseFlow/LBM/MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.cpp b/src/cpu/MultiphaseFlow/LBM/MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.cpp index 020549cf976714bcde5b5bb01fd9cc0d6dfec16d..ef0d033bc0c255d02e51a08fa1a0a85d1b20f0b4 100644 --- a/src/cpu/MultiphaseFlow/LBM/MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.cpp +++ b/src/cpu/MultiphaseFlow/LBM/MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.cpp @@ -86,7 +86,7 @@ SPtr<LBMKernel> MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::clone() ////////////////////////////////////////////////////////////////////////// void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::forwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m2 = mfa + mfc; real m1 = mfc - mfa; @@ -101,7 +101,7 @@ SPtr<LBMKernel> MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::clone() //////////////////////////////////////////////////////////////////////////////// void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::backwardInverseChimeraWithKincompressible(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K, real oneMinusRho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 - vv) * c1o2) * K; real m1 = (((mfa - mfc) - c2o1 * mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (-v2)) * K; @@ -114,7 +114,7 @@ SPtr<LBMKernel> MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::clone() //////////////////////////////////////////////////////////////////////////////// void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::forwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m1 = (mfa + mfc) + mfb; real m2 = mfc - mfa; @@ -126,7 +126,7 @@ SPtr<LBMKernel> MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::clone() void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::backwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); real mb = ((mfa - mfc) - mfa * v2) - c2o1 * mfb * vv; @@ -141,7 +141,7 @@ void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::calculate(int step) using namespace D3Q27System; // using namespace UbMath; using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; forcingX1 = 0.0; forcingX2 = 0.0; diff --git a/src/cpu/MultiphaseFlow/SimulationObservers/WriteMultiphaseQuantitiesSimulationObserver.cpp b/src/cpu/MultiphaseFlow/SimulationObservers/WriteMultiphaseQuantitiesSimulationObserver.cpp index 7669dec49c77bc2621bd903f614d2c3d3d03e2a4..adc6a4f81f77cc57a4030643517cc583b61b3c7d 100644 --- a/src/cpu/MultiphaseFlow/SimulationObservers/WriteMultiphaseQuantitiesSimulationObserver.cpp +++ b/src/cpu/MultiphaseFlow/SimulationObservers/WriteMultiphaseQuantitiesSimulationObserver.cpp @@ -149,7 +149,7 @@ void WriteMultiphaseQuantitiesSimulationObserver::addDataMQ(SPtr<Block3D> block) using namespace D3Q27System; // using namespace UbMath; using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; SPtr<LBMKernel> kernel = dynamicPointerCast<LBMKernel>(block->getKernel()); //double level = (double)block->getLevel(); diff --git a/src/cpu/MultiphaseFlow/Visitors/MultiphaseInitDistributionsBlockVisitor.cpp b/src/cpu/MultiphaseFlow/Visitors/MultiphaseInitDistributionsBlockVisitor.cpp index 3588e502583fd1a60ffa7a8113bc8c6eeb2fac69..ded01d95428ce53dc09f1371961d68ee1b005c00 100644 --- a/src/cpu/MultiphaseFlow/Visitors/MultiphaseInitDistributionsBlockVisitor.cpp +++ b/src/cpu/MultiphaseFlow/Visitors/MultiphaseInitDistributionsBlockVisitor.cpp @@ -224,7 +224,7 @@ void MultiphaseInitDistributionsBlockVisitor::visit(const SPtr<Grid3D> grid, SPt //geq[dir] = p1*WEIGTH[dir] + gamma; //geq[dir] = p1*WEIGTH[dir]/(rho*UbMath::c1o3) + gamma*rho; //geq[dir] = (p1*WEIGTH[dir]/(rho*UbMath::c1o3) + gamma*rho)*UbMath::c1o3; - geq[dir] = (gamma*rho)* vf::lbm::constant::c1o3; + geq[dir] = (gamma*rho)* vf::basics::constant::c1o3; } diff --git a/src/cpu/MultiphaseFlow/Visitors/MultiphaseVelocityFormInitDistributionsBlockVisitor.cpp b/src/cpu/MultiphaseFlow/Visitors/MultiphaseVelocityFormInitDistributionsBlockVisitor.cpp index 1ba1863af98cdff2967a43985d0314b8d827e0cc..9afa7612a577395c06dffdf40a7448c17c2f5dae 100644 --- a/src/cpu/MultiphaseFlow/Visitors/MultiphaseVelocityFormInitDistributionsBlockVisitor.cpp +++ b/src/cpu/MultiphaseFlow/Visitors/MultiphaseVelocityFormInitDistributionsBlockVisitor.cpp @@ -233,7 +233,7 @@ void MultiphaseVelocityFormInitDistributionsBlockVisitor::visit(const SPtr<Grid3 feq[dir] = WEIGTH[dir] * (1 + 3 * velProd + 4.5 * velSq1 - 1.5 * (vx1Sq + vx2Sq + vx3Sq)); //geq[dir] = p1*WEIGTH1[dir] + gamma; //geq[dir] = p1*WEIGTH[dir]/(rho*UbMath::c1o3) + gamma*rho; - geq[dir] = p1 * WEIGTH[dir] / (vf::lbm::constant::c1o3) + gamma ; + geq[dir] = p1 * WEIGTH[dir] / (vf::basics::constant::c1o3) + gamma ; } diff --git a/src/cpu/NonNewtonianFluids/LBM/Rheology.h b/src/cpu/NonNewtonianFluids/LBM/Rheology.h index ef0efc76e170a79c644e7cc6a94f592fdc119572..782810ca3f68290310af3e70d440488c27bf96de 100644 --- a/src/cpu/NonNewtonianFluids/LBM/Rheology.h +++ b/src/cpu/NonNewtonianFluids/LBM/Rheology.h @@ -38,7 +38,7 @@ #include <LBMSystem.h> #include <UbMath.h> #include <math.h> -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" class Rheology { @@ -89,10 +89,10 @@ private: ////////////////////////////////////////////////////////////////////////// inline real Rheology::getBinghamCollFactor(real omegaInf, real shearRate, real drho) { - real cs2 = vf::lbm::constant::one_over_sqrt3 * vf::lbm::constant::one_over_sqrt3; - real rho = vf::lbm::constant::c1o1 + drho; + real cs2 = vf::basics::constant::one_over_sqrt3 * vf::basics::constant::one_over_sqrt3; + real rho = vf::basics::constant::c1o1 + drho; //analytical solution - real omega = omegaInf * (vf::lbm::constant::c1o1 - (omegaInf * tau0) / (shearRate * cs2 * rho + UbMath::Epsilon<real>::val())); + real omega = omegaInf * (vf::basics::constant::c1o1 - (omegaInf * tau0) / (shearRate * cs2 * rho + UbMath::Epsilon<real>::val())); //LBMReal omega = cs2 * cs2 * shearRate * shearRate * omegaInf * rho * rho / (cs2 * cs2 * shearRate * shearRate * rho * rho + cs2 * shearRate * omegaInf * rho * tau0+omegaInf*omegaInf*tau0*tau0); @@ -120,10 +120,10 @@ inline real Rheology::getBinghamCollFactor(real omegaInf, real shearRate, real d inline real Rheology::getBinghamCollFactorOld(real omegaInf, real shearRate, real drho) { - const real cs2 = vf::lbm::constant::c1o3; // UbMath::one_over_sqrt3* UbMath::one_over_sqrt3; - real rho = vf::lbm::constant::c1o1 + drho; + const real cs2 = vf::basics::constant::c1o3; // UbMath::one_over_sqrt3* UbMath::one_over_sqrt3; + real rho = vf::basics::constant::c1o1 + drho; - if (rho * cs2 * (vf::lbm::constant::c1o1 / omegaInf - vf::lbm::constant::c1o2) * shearRate < tau0) + if (rho * cs2 * (vf::basics::constant::c1o1 / omegaInf - vf::basics::constant::c1o2) * shearRate < tau0) return 0.0; else return omegaInf; @@ -131,8 +131,8 @@ inline real Rheology::getBinghamCollFactorOld(real omegaInf, real shearRate, rea ////////////////////////////////////////////////////////////////////////// inline real Rheology::getHerschelBulkleyCollFactor(real omegaInf, real shearRate, real drho) { - real cs2 = vf::lbm::constant::one_over_sqrt3 * vf::lbm::constant::one_over_sqrt3; - real rho = vf::lbm::constant::c1o1 + drho; + real cs2 = vf::basics::constant::one_over_sqrt3 * vf::basics::constant::one_over_sqrt3; + real rho = vf::basics::constant::c1o1 + drho; real gammaDot = shearRate; real omega = omegaInf; real epsilon = 1; @@ -152,7 +152,7 @@ inline real Rheology::getHerschelBulkleyCollFactor(real omegaInf, real shearRate real numerator = (2.0 * gammaDotPowN * k * omegaByOmegaInfPowN * omegaInf + cs2 * gammaDot * (omega - 2.0) * rho + 2.0 * omegaInf * tau0); real denominator = (2.0 * k * n * gammaDotPowN * omegaByOmegaInfPowN * omegaInf + cs2 * gammaDot * rho * omega) + UbMath::Epsilon<real>::val(); omega = omega - omega * numerator / denominator; - omega = (omega < vf::lbm::constant::c0o1) ? vf::lbm::constant::c1o2 * omegaOld : omega; + omega = (omega < vf::basics::constant::c0o1) ? vf::basics::constant::c1o2 * omegaOld : omega; //omega = (omega < omegaMin) ? UbMath::c1o2 * (omegaOld-omegaMin)+omegaMin : omega; epsilon = std::abs(omega - omegaOld); } @@ -162,17 +162,17 @@ inline real Rheology::getHerschelBulkleyCollFactor(real omegaInf, real shearRate ////////////////////////////////////////////////////////////////////////// inline real Rheology::getHerschelBulkleyCollFactorBackward(real shearRate, real drho) { - real rho = vf::lbm::constant::c1o1 + drho; + real rho = vf::basics::constant::c1o1 + drho; real gamma = shearRate + UbMath::Epsilon<real>::val(); - real cs2 = vf::lbm::constant::one_over_sqrt3 * vf::lbm::constant::one_over_sqrt3; + real cs2 = vf::basics::constant::one_over_sqrt3 * vf::basics::constant::one_over_sqrt3; - return 1.0 / ((tau0 + k * std::pow(gamma, n)) / (cs2 * rho * gamma) + vf::lbm::constant::c1o2); + return 1.0 / ((tau0 + k * std::pow(gamma, n)) / (cs2 * rho * gamma) + vf::basics::constant::c1o2); } ////////////////////////////////////////////////////////////////////////// inline real Rheology::getPowellEyringCollFactor(real omegaInf, real shearRate, real drho) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real cs2 = c1o3; // UbMath::one_over_sqrt3* UbMath::one_over_sqrt3; real rho = c1o1 + drho; diff --git a/src/cpu/NonNewtonianFluids/LBM/RheologyK17LBMKernel.cpp b/src/cpu/NonNewtonianFluids/LBM/RheologyK17LBMKernel.cpp index a85b63c9391b83f6b329dd56abc035c3f74d54a5..a9c7a05da6eefb4f44834d1c91f5e5b43d4f5eb4 100644 --- a/src/cpu/NonNewtonianFluids/LBM/RheologyK17LBMKernel.cpp +++ b/src/cpu/NonNewtonianFluids/LBM/RheologyK17LBMKernel.cpp @@ -44,7 +44,7 @@ #define PROOF_CORRECTNESS //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; ////////////////////////////////////////////////////////////////////////// RheologyK17LBMKernel::RheologyK17LBMKernel() diff --git a/src/cpu/NonNewtonianFluids/LBM/RheologyModelLBMKernel.cpp b/src/cpu/NonNewtonianFluids/LBM/RheologyModelLBMKernel.cpp index 4906cb2a6e34cc14df2d9acaca52736c23da4816..7f1c8c884d4cf3b4a174f7d2c58e2f070c459b6b 100644 --- a/src/cpu/NonNewtonianFluids/LBM/RheologyModelLBMKernel.cpp +++ b/src/cpu/NonNewtonianFluids/LBM/RheologyModelLBMKernel.cpp @@ -42,7 +42,7 @@ #define PROOF_CORRECTNESS //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; RheologyModelLBMKernel::RheologyModelLBMKernel() : forcingX1(0), forcingX2(0), forcingX3(0) { diff --git a/src/cpu/NonNewtonianFluids/LBM/RheologyModelLBMKernel2.cpp b/src/cpu/NonNewtonianFluids/LBM/RheologyModelLBMKernel2.cpp index 9306686160f642d0f67cb40be2c78cce45fa0484..380bb9861343803b3ec2165af96c684ac4722c47 100644 --- a/src/cpu/NonNewtonianFluids/LBM/RheologyModelLBMKernel2.cpp +++ b/src/cpu/NonNewtonianFluids/LBM/RheologyModelLBMKernel2.cpp @@ -11,7 +11,7 @@ #define PROOF_CORRECTNESS using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; RheologyModelLBMKernel2::RheologyModelLBMKernel2() : forcingX1(0), forcingX2(0), forcingX3(0) @@ -381,7 +381,7 @@ void RheologyModelLBMKernel2::calculate(int step) m1 = mfcca - mfaca; m0 = m2 + mfbca; mfaca = m0; - m0 += vf::lbm::constant::c1o3 * oMdrho; + m0 += vf::basics::constant::c1o3 * oMdrho; mfbca = m1 - m0 * vvx; mfcca = m2 - 2. * m1 * vvx + vx2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -412,7 +412,7 @@ void RheologyModelLBMKernel2::calculate(int step) m1 = mfcac - mfaac; m0 = m2 + mfbac; mfaac = m0; - m0 += vf::lbm::constant::c1o3 * oMdrho; + m0 += vf::basics::constant::c1o3 * oMdrho; mfbac = m1 - m0 * vvx; mfcac = m2 - 2. * m1 * vvx + vx2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -445,18 +445,18 @@ void RheologyModelLBMKernel2::calculate(int step) //LBMReal CUMbcb = mfbcb - ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 //LBMReal CUMbbc = mfbbc - ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 - real CUMcbb = mfcbb - ((mfcaa + vf::lbm::constant::c1o3) * mfabb + 2. * mfbba * mfbab); - real CUMbcb = mfbcb - ((mfaca + vf::lbm::constant::c1o3) * mfbab + 2. * mfbba * mfabb); - real CUMbbc = mfbbc - ((mfaac + vf::lbm::constant::c1o3) * mfbba + 2. * mfbab * mfabb); + real CUMcbb = mfcbb - ((mfcaa + vf::basics::constant::c1o3) * mfabb + 2. * mfbba * mfbab); + real CUMbcb = mfbcb - ((mfaca + vf::basics::constant::c1o3) * mfbab + 2. * mfbba * mfabb); + real CUMbbc = mfbbc - ((mfaac + vf::basics::constant::c1o3) * mfbba + 2. * mfbab * mfabb); - real CUMcca = mfcca - ((mfcaa * mfaca + 2. * mfbba * mfbba) + vf::lbm::constant::c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho); - real CUMcac = mfcac - ((mfcaa * mfaac + 2. * mfbab * mfbab) + vf::lbm::constant::c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho); - real CUMacc = mfacc - ((mfaac * mfaca + 2. * mfabb * mfabb) + vf::lbm::constant::c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho); + real CUMcca = mfcca - ((mfcaa * mfaca + 2. * mfbba * mfbba) + vf::basics::constant::c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho); + real CUMcac = mfcac - ((mfcaa * mfaac + 2. * mfbab * mfbab) + vf::basics::constant::c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho); + real CUMacc = mfacc - ((mfaac * mfaca + 2. * mfabb * mfabb) + vf::basics::constant::c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho); //Cum 5. - real CUMbcc = mfbcc - (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) - vf::lbm::constant::c1o3 * (mfbca + mfbac) * oMdrho; - real CUMcbc = mfcbc - (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) - vf::lbm::constant::c1o3 * (mfcba + mfabc) * oMdrho; - real CUMccb = mfccb - (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) - vf::lbm::constant::c1o3 * (mfacb + mfcab) * oMdrho; + real CUMbcc = mfbcc - (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) - vf::basics::constant::c1o3 * (mfbca + mfbac) * oMdrho; + real CUMcbc = mfcbc - (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) - vf::basics::constant::c1o3 * (mfcba + mfabc) * oMdrho; + real CUMccb = mfccb - (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) - vf::basics::constant::c1o3 * (mfacb + mfcab) * oMdrho; //Cum 6. real CUMccc = mfccc + ((-4. * mfbbb * mfbbb @@ -466,7 +466,7 @@ void RheologyModelLBMKernel2::calculate(int step) + (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + 2. * (mfcaa * mfaca * mfaac) + 16. * mfbba * mfbab * mfabb) - - vf::lbm::constant::c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho + - vf::basics::constant::c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho - c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3 * oMdrho) + c1o27 * oMdrho; @@ -488,7 +488,7 @@ void RheologyModelLBMKernel2::calculate(int step) //non Newtonian fluid collision factor // LBMReal shearRate = sqrt(c2 * (dxux * dxux + dyuy * dyuy + dzuz * dzuz) + Dxy * Dxy + Dxz * Dxz + Dyz * Dyz) / (rho + one); - real shearFactor = sqrt(c1o2 * ((mfcaa - mfaaa * vf::lbm::constant::c1o3) * (mfcaa - mfaaa * vf::lbm::constant::c1o3) + (mfaca - mfaaa * vf::lbm::constant::c1o3) * (mfaca - mfaaa * vf::lbm::constant::c1o3) + (mfaac - mfaaa * vf::lbm::constant::c1o3) * (mfaac - mfaaa * vf::lbm::constant::c1o3)) + mfbba * mfbba + mfbab * mfbab + mfabb * mfabb) + UbMath::Epsilon<real>::val(); + real shearFactor = sqrt(c1o2 * ((mfcaa - mfaaa * vf::basics::constant::c1o3) * (mfcaa - mfaaa * vf::basics::constant::c1o3) + (mfaca - mfaaa * vf::basics::constant::c1o3) * (mfaca - mfaaa * vf::basics::constant::c1o3) + (mfaac - mfaaa * vf::basics::constant::c1o3) * (mfaac - mfaaa * vf::basics::constant::c1o3)) + mfbba * mfbba + mfbab * mfbab + mfabb * mfabb) + UbMath::Epsilon<real>::val(); //collFactorF = getRheologyCollFactor(collFactorF, shearRate, rho); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -529,9 +529,9 @@ void RheologyModelLBMKernel2::calculate(int step) // linear combinations back - mfcaa = vf::lbm::constant::c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); - mfaca = vf::lbm::constant::c1o3 * (-2. * mxxMyy + mxxMzz + mxxPyyPzz); - mfaac = vf::lbm::constant::c1o3 * (mxxMyy - 2. * mxxMzz + mxxPyyPzz); + mfcaa = vf::basics::constant::c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); + mfaca = vf::basics::constant::c1o3 * (-2. * mxxMyy + mxxMzz + mxxPyyPzz); + mfaac = vf::basics::constant::c1o3 * (mxxMyy - 2. * mxxMzz + mxxPyyPzz); //3. // linear combinations @@ -591,18 +591,18 @@ void RheologyModelLBMKernel2::calculate(int step) //mfbcb = CUMbcb + ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 //mfbbc = CUMbbc + ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 - mfcbb = CUMcbb + ((mfcaa + vf::lbm::constant::c1o3) * mfabb + 2. * mfbba * mfbab); - mfbcb = CUMbcb + ((mfaca + vf::lbm::constant::c1o3) * mfbab + 2. * mfbba * mfabb); - mfbbc = CUMbbc + ((mfaac + vf::lbm::constant::c1o3) * mfbba + 2. * mfbab * mfabb); + mfcbb = CUMcbb + ((mfcaa + vf::basics::constant::c1o3) * mfabb + 2. * mfbba * mfbab); + mfbcb = CUMbcb + ((mfaca + vf::basics::constant::c1o3) * mfbab + 2. * mfbba * mfabb); + mfbbc = CUMbbc + ((mfaac + vf::basics::constant::c1o3) * mfbba + 2. * mfbab * mfabb); - mfcca = CUMcca + (mfcaa * mfaca + 2. * mfbba * mfbba) + vf::lbm::constant::c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho; - mfcac = CUMcac + (mfcaa * mfaac + 2. * mfbab * mfbab) + vf::lbm::constant::c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho; - mfacc = CUMacc + (mfaac * mfaca + 2. * mfabb * mfabb) + vf::lbm::constant::c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho; + mfcca = CUMcca + (mfcaa * mfaca + 2. * mfbba * mfbba) + vf::basics::constant::c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho; + mfcac = CUMcac + (mfcaa * mfaac + 2. * mfbab * mfbab) + vf::basics::constant::c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho; + mfacc = CUMacc + (mfaac * mfaca + 2. * mfabb * mfabb) + vf::basics::constant::c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho; //5. - mfbcc = CUMbcc + (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) + vf::lbm::constant::c1o3 * (mfbca + mfbac) * oMdrho; - mfcbc = CUMcbc + (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) + vf::lbm::constant::c1o3 * (mfcba + mfabc) * oMdrho; - mfccb = CUMccb + (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) + vf::lbm::constant::c1o3 * (mfacb + mfcab) * oMdrho; + mfbcc = CUMbcc + (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) + vf::basics::constant::c1o3 * (mfbca + mfbac) * oMdrho; + mfcbc = CUMcbc + (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) + vf::basics::constant::c1o3 * (mfcba + mfabc) * oMdrho; + mfccb = CUMccb + (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) + vf::basics::constant::c1o3 * (mfacb + mfcab) * oMdrho; //6. mfccc = CUMccc - ((-4. * mfbbb * mfbbb @@ -612,7 +612,7 @@ void RheologyModelLBMKernel2::calculate(int step) + (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + 2. * (mfcaa * mfaca * mfaac) + 16. * mfbba * mfbab * mfabb) - - vf::lbm::constant::c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho + - vf::basics::constant::c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho - c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3 * oMdrho) - c1o27 * oMdrho; @@ -644,9 +644,9 @@ void RheologyModelLBMKernel2::calculate(int step) mfabb = m1; mfabc = m2; //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfacb * (vvz - c1o2) + (mfaca + vf::lbm::constant::c1o3 * oMdrho) * (vz2 - vvz) * c1o2; - m1 = -mfacc - 2. * mfacb * vvz + mfaca * (1. - vz2) - vf::lbm::constant::c1o3 * oMdrho * vz2; - m2 = mfacc * c1o2 + mfacb * (vvz + c1o2) + (mfaca + vf::lbm::constant::c1o3 * oMdrho) * (vz2 + vvz) * c1o2; + m0 = mfacc * c1o2 + mfacb * (vvz - c1o2) + (mfaca + vf::basics::constant::c1o3 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfacc - 2. * mfacb * vvz + mfaca * (1. - vz2) - vf::basics::constant::c1o3 * oMdrho * vz2; + m2 = mfacc * c1o2 + mfacb * (vvz + c1o2) + (mfaca + vf::basics::constant::c1o3 * oMdrho) * (vz2 + vvz) * c1o2; mfaca = m0; mfacb = m1; mfacc = m2; @@ -674,9 +674,9 @@ void RheologyModelLBMKernel2::calculate(int step) mfbcc = m2; //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfcab * (vvz - c1o2) + (mfcaa + vf::lbm::constant::c1o3 * oMdrho) * (vz2 - vvz) * c1o2; - m1 = -mfcac - 2. * mfcab * vvz + mfcaa * (1. - vz2) - vf::lbm::constant::c1o3 * oMdrho * vz2; - m2 = mfcac * c1o2 + mfcab * (vvz + c1o2) + (mfcaa + vf::lbm::constant::c1o3 * oMdrho) * (vz2 + vvz) * c1o2; + m0 = mfcac * c1o2 + mfcab * (vvz - c1o2) + (mfcaa + vf::basics::constant::c1o3 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfcac - 2. * mfcab * vvz + mfcaa * (1. - vz2) - vf::basics::constant::c1o3 * oMdrho * vz2; + m2 = mfcac * c1o2 + mfcab * (vvz + c1o2) + (mfcaa + vf::basics::constant::c1o3 * oMdrho) * (vz2 + vvz) * c1o2; mfcaa = m0; mfcab = m1; mfcac = m2; diff --git a/src/cpu/NonNewtonianFluids/LBM/ThixotropyExpLBMKernel.cpp b/src/cpu/NonNewtonianFluids/LBM/ThixotropyExpLBMKernel.cpp index 00f5e89b3b1e8fc8a05facaa165655f81d0a8532..cbfa924405109fa03dfef6532c538fb2917d2d43 100644 --- a/src/cpu/NonNewtonianFluids/LBM/ThixotropyExpLBMKernel.cpp +++ b/src/cpu/NonNewtonianFluids/LBM/ThixotropyExpLBMKernel.cpp @@ -9,7 +9,7 @@ #define PROOF_CORRECTNESS //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; ////////////////////////////////////////////////////////////////////////// ThixotropyExpLBMKernel::ThixotropyExpLBMKernel() diff --git a/src/cpu/NonNewtonianFluids/LBM/ThixotropyLBMKernel.cpp b/src/cpu/NonNewtonianFluids/LBM/ThixotropyLBMKernel.cpp index 1524104ce69a9bceec685f6912a76b12e5480c76..368436088dc72bb10677f046aa9e954f9120be42 100644 --- a/src/cpu/NonNewtonianFluids/LBM/ThixotropyLBMKernel.cpp +++ b/src/cpu/NonNewtonianFluids/LBM/ThixotropyLBMKernel.cpp @@ -9,7 +9,7 @@ #define PROOF_CORRECTNESS //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; ////////////////////////////////////////////////////////////////////////// ThixotropyLBMKernel::ThixotropyLBMKernel() diff --git a/src/cpu/NonNewtonianFluids/SimulationObservers/WriteThixotropyQuantitiesSimulationObserver.cpp b/src/cpu/NonNewtonianFluids/SimulationObservers/WriteThixotropyQuantitiesSimulationObserver.cpp index 08b05e4475301137394fdbf5c2536c641c2e742e..9ff3fe0982d43ed119e7cfb3fba497a61e2c201b 100644 --- a/src/cpu/NonNewtonianFluids/SimulationObservers/WriteThixotropyQuantitiesSimulationObserver.cpp +++ b/src/cpu/NonNewtonianFluids/SimulationObservers/WriteThixotropyQuantitiesSimulationObserver.cpp @@ -26,13 +26,13 @@ // You should have received a copy of the GNU General Public License along // with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. // -//! \file WriteMultiphaseQuantitiesSimulationObserver.h -//! \ingroup SimulationObservers +//! \file WriteMultiphaseQuantitiesCoProcessor.h +//! \ingroup CoProcessors //! \author Konstantin Kutscher //======================================================================================= -#include "WriteThixotropyQuantitiesSimulationObserver.h" +#include "WriteThixotropyQuantitiesCoProcessor.h" #include "LBMKernel.h" -#include "BCSet.h" +#include "BCProcessor.h" #include "UbScheduler.h" #include "DataSet3D.h" #include "D3Q27System.h" @@ -42,17 +42,17 @@ #include <algorithm> #include <numeric> #include "basics/writer/WbWriterVtkXmlASCII.h" -//#include "ThixotropyExpLBMKernel.h" -#include "NonNewtonianFluids/LBM/Rheology.h" +#include "ThixotropyExpLBMKernel.h" +#include "Rheology.h" using namespace std; -WriteThixotropyQuantitiesSimulationObserver::WriteThixotropyQuantitiesSimulationObserver() +WriteThixotropyQuantitiesCoProcessor::WriteThixotropyQuantitiesCoProcessor() { } ////////////////////////////////////////////////////////////////////////// -WriteThixotropyQuantitiesSimulationObserver::WriteThixotropyQuantitiesSimulationObserver(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<LBMUnitConverter> conv, std::shared_ptr<vf::mpi::Communicator> comm) : SimulationObserver(grid, s), path(path), writer(writer), conv(conv), comm(comm) +WriteThixotropyQuantitiesCoProcessor::WriteThixotropyQuantitiesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<LBMUnitConverter> conv, std::shared_ptr<vf::mpi::Communicator> comm) : CoProcessor(grid, s), path(path), writer(writer), conv(conv), comm(comm) { gridRank = comm->getProcessID(); minInitLevel = this->grid->getCoarsestInitializedLevel(); @@ -66,20 +66,20 @@ WriteThixotropyQuantitiesSimulationObserver::WriteThixotropyQuantitiesSimulation } } ////////////////////////////////////////////////////////////////////////// -void WriteThixotropyQuantitiesSimulationObserver::init() +void WriteThixotropyQuantitiesCoProcessor::init() { } ////////////////////////////////////////////////////////////////////////// -void WriteThixotropyQuantitiesSimulationObserver::update(real step) +void WriteThixotropyQuantitiesCoProcessor::process(real step) { if (scheduler->isDue(step)) collectData(step); - UBLOG(logDEBUG3, "WriteThixotropyQuantitiesSimulationObserver::update:" << step); + UBLOG(logDEBUG3, "WriteThixotropyQuantitiesCoProcessor::update:" << step); } ////////////////////////////////////////////////////////////////////////// -void WriteThixotropyQuantitiesSimulationObserver::collectData(real step) +void WriteThixotropyQuantitiesCoProcessor::collectData(real step) { int istep = static_cast<int>(step); //ConcentrationSum = 0; @@ -118,7 +118,7 @@ void WriteThixotropyQuantitiesSimulationObserver::collectData(real step) vector<string> filenames; filenames.push_back(piece); - if (step == SimulationObserver::scheduler->getMinBegin()) + if (step == CoProcessor::scheduler->getMinBegin()) { WbWriterVtkXmlASCII::getInstance()->writeCollection(cfilePath, filenames, istep, false); } @@ -126,13 +126,13 @@ void WriteThixotropyQuantitiesSimulationObserver::collectData(real step) { WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(cfilePath, filenames, istep, false); } - UBLOG(logINFO, "WriteThixotropyQuantitiesSimulationObserver step: " << istep); + UBLOG(logINFO, "WriteThixotropyQuantitiesCoProcessor step: " << istep); } clearData(); } ////////////////////////////////////////////////////////////////////////// -void WriteThixotropyQuantitiesSimulationObserver::clearData() +void WriteThixotropyQuantitiesCoProcessor::clearData() { nodes.clear(); cells.clear(); @@ -140,7 +140,7 @@ void WriteThixotropyQuantitiesSimulationObserver::clearData() data.clear(); } ////////////////////////////////////////////////////////////////////////// -void WriteThixotropyQuantitiesSimulationObserver::addDataMQ(SPtr<Block3D> block) +void WriteThixotropyQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) { UbTupleDouble3 org = grid->getBlockWorldCoordinates(block);; UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); @@ -153,16 +153,8 @@ void WriteThixotropyQuantitiesSimulationObserver::addDataMQ(SPtr<Block3D> block) datanames.resize(0); datanames.push_back("viscosity"); //datanames.push_back("lambda"); - datanames.push_back("ShearRate"); + //datanames.push_back("ShearRate"); datanames.push_back("omega"); - - datanames.push_back("MP"); - datanames.push_back("MXXMYY"); - datanames.push_back("MXXMZZ"); - datanames.push_back("MXY"); - datanames.push_back("MXZ"); - datanames.push_back("MYZ"); - //datanames.push_back("Fluxx"); //datanames.push_back("Fluxy"); //datanames.push_back("Fluxz"); @@ -178,7 +170,7 @@ void WriteThixotropyQuantitiesSimulationObserver::addDataMQ(SPtr<Block3D> block) data.resize(datanames.size()); SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCSet()->getBCArray(); + SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); SPtr<DistributionArray3D> distributionsF = kernel->getDataSet()->getFdistributions(); //SPtr<DistributionArray3D> distributionsH = kernel->getDataSet()->getHdistributions(); //LBMReal collFactorF = staticPointerCast<ThixotropyExpLBMKernel>(kernel)->getCollisionFactorF(); @@ -256,21 +248,11 @@ void WriteThixotropyQuantitiesSimulationObserver::addDataMQ(SPtr<Block3D> block) //LBMReal omega = Rheology::getHerschelBulkleyCollFactor(collFactor, shearRate, rho); //LBMReal omega = Rheology::getPowellEyringCollFactor(collFactor, shearRate, rho); real omega = Rheology::getBinghamCollFactor(collFactor, shearRate, rho); - real viscosity = (omega == 0) ? 0 : vf::lbm::constant::c1o3 * (vf::lbm::constant::c1o1/omega- vf::lbm::constant::c1o2); - std::array<real, 6> moments = D3Q27System::getSecondMoments(f, omega); - + real viscosity = (omega == 0) ? 0 : vf::basics::constant::c1o3 * (vf::basics::constant::c1o1/omega- vf::basics::constant::c1o2); data[index++].push_back(viscosity); - data[index++].push_back(shearRate); data[index++].push_back(omega); - - data[index++].push_back(moments[0]); - data[index++].push_back(moments[1]); - data[index++].push_back(moments[2]); - data[index++].push_back(moments[3]); - data[index++].push_back(moments[4]); - data[index++].push_back(moments[5]); } } } diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h index 963c2df627cb3780a03b91cb62d1ad21472a6952..5d838ff656525f747fe8aa72cc4ae334d1b5ac1e 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h @@ -197,59 +197,59 @@ public: switch (direction) { case DIR_P00: - return (float)(vf::lbm::constant::c4o9 * + return (float)(vf::basics::constant::c4o9 * (+bcVelocityX1)); //(2/cs^2)(=6)*rho_0(=1 bei inkompr)*wi*u*ei mit cs=1/sqrt(3) case DIR_M00: - return (float)(vf::lbm::constant::c4o9 * + return (float)(vf::basics::constant::c4o9 * (-bcVelocityX1)); // z.B. aus paper manfred MRT LB models in three dimensions (2002) case DIR_0P0: - return (float)(vf::lbm::constant::c4o9 * (+bcVelocityX2)); + return (float)(vf::basics::constant::c4o9 * (+bcVelocityX2)); case DIR_0M0: - return (float)(vf::lbm::constant::c4o9 * (-bcVelocityX2)); + return (float)(vf::basics::constant::c4o9 * (-bcVelocityX2)); case DIR_00P: - return (float)(vf::lbm::constant::c4o9 * (+bcVelocityX3)); + return (float)(vf::basics::constant::c4o9 * (+bcVelocityX3)); case DIR_00M: - return (float)(vf::lbm::constant::c4o9 * (-bcVelocityX3)); + return (float)(vf::basics::constant::c4o9 * (-bcVelocityX3)); case DIR_PP0: - return (float)(vf::lbm::constant::c1o9 * (+bcVelocityX1 + bcVelocityX2)); + return (float)(vf::basics::constant::c1o9 * (+bcVelocityX1 + bcVelocityX2)); case DIR_MM0: - return (float)(vf::lbm::constant::c1o9 * (-bcVelocityX1 - bcVelocityX2)); + return (float)(vf::basics::constant::c1o9 * (-bcVelocityX1 - bcVelocityX2)); case DIR_PM0: - return (float)(vf::lbm::constant::c1o9 * (+bcVelocityX1 - bcVelocityX2)); + return (float)(vf::basics::constant::c1o9 * (+bcVelocityX1 - bcVelocityX2)); case DIR_MP0: - return (float)(vf::lbm::constant::c1o9 * (-bcVelocityX1 + bcVelocityX2)); + return (float)(vf::basics::constant::c1o9 * (-bcVelocityX1 + bcVelocityX2)); case DIR_P0P: - return (float)(vf::lbm::constant::c1o9 * (+bcVelocityX1 + bcVelocityX3)); + return (float)(vf::basics::constant::c1o9 * (+bcVelocityX1 + bcVelocityX3)); case DIR_M0M: - return (float)(vf::lbm::constant::c1o9 * (-bcVelocityX1 - bcVelocityX3)); + return (float)(vf::basics::constant::c1o9 * (-bcVelocityX1 - bcVelocityX3)); case DIR_P0M: - return (float)(vf::lbm::constant::c1o9 * (+bcVelocityX1 - bcVelocityX3)); + return (float)(vf::basics::constant::c1o9 * (+bcVelocityX1 - bcVelocityX3)); case DIR_M0P: - return (float)(vf::lbm::constant::c1o9 * (-bcVelocityX1 + bcVelocityX3)); + return (float)(vf::basics::constant::c1o9 * (-bcVelocityX1 + bcVelocityX3)); case DIR_0PP: - return (float)(vf::lbm::constant::c1o9 * (+bcVelocityX2 + bcVelocityX3)); + return (float)(vf::basics::constant::c1o9 * (+bcVelocityX2 + bcVelocityX3)); case DIR_0MM: - return (float)(vf::lbm::constant::c1o9 * (-bcVelocityX2 - bcVelocityX3)); + return (float)(vf::basics::constant::c1o9 * (-bcVelocityX2 - bcVelocityX3)); case DIR_0PM: - return (float)(vf::lbm::constant::c1o9 * (+bcVelocityX2 - bcVelocityX3)); + return (float)(vf::basics::constant::c1o9 * (+bcVelocityX2 - bcVelocityX3)); case DIR_0MP: - return (float)(vf::lbm::constant::c1o9 * (-bcVelocityX2 + bcVelocityX3)); + return (float)(vf::basics::constant::c1o9 * (-bcVelocityX2 + bcVelocityX3)); case DIR_PPP: - return (float)(vf::lbm::constant::c1o36 * (+bcVelocityX1 + bcVelocityX2 + bcVelocityX3)); + return (float)(vf::basics::constant::c1o36 * (+bcVelocityX1 + bcVelocityX2 + bcVelocityX3)); case DIR_MMM: - return (float)(vf::lbm::constant::c1o36 * (-bcVelocityX1 - bcVelocityX2 - bcVelocityX3)); + return (float)(vf::basics::constant::c1o36 * (-bcVelocityX1 - bcVelocityX2 - bcVelocityX3)); case DIR_PPM: - return (float)(vf::lbm::constant::c1o36 * (+bcVelocityX1 + bcVelocityX2 - bcVelocityX3)); + return (float)(vf::basics::constant::c1o36 * (+bcVelocityX1 + bcVelocityX2 - bcVelocityX3)); case DIR_MMP: - return (float)(vf::lbm::constant::c1o36 * (-bcVelocityX1 - bcVelocityX2 + bcVelocityX3)); + return (float)(vf::basics::constant::c1o36 * (-bcVelocityX1 - bcVelocityX2 + bcVelocityX3)); case DIR_PMP: - return (float)(vf::lbm::constant::c1o36 * (+bcVelocityX1 - bcVelocityX2 + bcVelocityX3)); + return (float)(vf::basics::constant::c1o36 * (+bcVelocityX1 - bcVelocityX2 + bcVelocityX3)); case DIR_MPM: - return (float)(vf::lbm::constant::c1o36 * (-bcVelocityX1 + bcVelocityX2 - bcVelocityX3)); + return (float)(vf::basics::constant::c1o36 * (-bcVelocityX1 + bcVelocityX2 - bcVelocityX3)); case DIR_PMM: - return (float)(vf::lbm::constant::c1o36 * (+bcVelocityX1 - bcVelocityX2 - bcVelocityX3)); + return (float)(vf::basics::constant::c1o36 * (+bcVelocityX1 - bcVelocityX2 - bcVelocityX3)); case DIR_MPP: - return (float)(vf::lbm::constant::c1o36 * (-bcVelocityX1 + bcVelocityX2 + bcVelocityX3)); + return (float)(vf::basics::constant::c1o36 * (-bcVelocityX1 + bcVelocityX2 + bcVelocityX3)); default: throw UbException(UB_EXARGS, "unknown error"); } diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingInflowBCStrategy.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingInflowBCStrategy.cpp index d67de5342a716dc0da076518109908540945aa78..7f5eaf840c721f65cc030d5e6fad2995858af1b3 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingInflowBCStrategy.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingInflowBCStrategy.cpp @@ -60,7 +60,7 @@ void NonReflectingInflowBCStrategy::applyBC() using namespace vf::lbm::dir; using namespace D3Q27System; // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; LBMReal f[ENDF + 1]; LBMReal ftemp[ENDF + 1]; diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowWithRelaxationBCStrategy.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowWithRelaxationBCStrategy.cpp index 3c52e1a4b0eac33d7eaf2ece785f6f917993d633..3e10421e59bac7e260e95ccf491d1f749f28c640 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowWithRelaxationBCStrategy.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowWithRelaxationBCStrategy.cpp @@ -61,7 +61,7 @@ void NonReflectingOutflowWithRelaxationBCStrategy::applyBC() using namespace D3Q27System; // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; LBMReal f[ENDF + 1]; LBMReal ftemp[ENDF + 1]; diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/SimpleSlipBCStrategy.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/SimpleSlipBCStrategy.cpp index fee0f71a25ad90b44a61f946925a842bb10531f3..65bdc1c2218a73cb9f98a878836f7ad3bdf52de5 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/SimpleSlipBCStrategy.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/SimpleSlipBCStrategy.cpp @@ -85,32 +85,32 @@ void SimpleSlipBCStrategy::applyBC() real velocity = vf::lbm::constant::c0o1; switch (invDir) { - case DIR_P00: velocity = (vf::lbm::constant::c4o9*(+vx1)); break; //(2/cs^2)(=6)*rho_0(=1 bei imkompr)*wi*u*ei mit cs=1/sqrt(3) - case DIR_M00: velocity = (vf::lbm::constant::c4o9*(-vx1)); break; //z.B. aus paper manfred MRT LB models in three dimensions (2002) - case DIR_0P0: velocity = (vf::lbm::constant::c4o9*(+vx2)); break; - case DIR_0M0: velocity = (vf::lbm::constant::c4o9*(-vx2)); break; - case DIR_00P: velocity = (vf::lbm::constant::c4o9*(+vx3)); break; - case DIR_00M: velocity = (vf::lbm::constant::c4o9*(-vx3)); break; - case DIR_PP0: velocity = (vf::lbm::constant::c1o9*(+vx1+vx2)); break; - case DIR_MM0: velocity = (vf::lbm::constant::c1o9*(-vx1-vx2)); break; - case DIR_PM0: velocity = (vf::lbm::constant::c1o9*(+vx1-vx2)); break; - case DIR_MP0: velocity = (vf::lbm::constant::c1o9*(-vx1+vx2)); break; - case DIR_P0P: velocity = (vf::lbm::constant::c1o9*(+vx1+vx3)); break; - case DIR_M0M: velocity = (vf::lbm::constant::c1o9*(-vx1-vx3)); break; - case DIR_P0M: velocity = (vf::lbm::constant::c1o9*(+vx1-vx3)); break; - case DIR_M0P: velocity = (vf::lbm::constant::c1o9*(-vx1+vx3)); break; - case DIR_0PP: velocity = (vf::lbm::constant::c1o9*(+vx2+vx3)); break; - case DIR_0MM: velocity = (vf::lbm::constant::c1o9*(-vx2-vx3)); break; - case DIR_0PM: velocity = (vf::lbm::constant::c1o9*(+vx2-vx3)); break; - case DIR_0MP: velocity = (vf::lbm::constant::c1o9*(-vx2+vx3)); break; - case DIR_PPP: velocity = (vf::lbm::constant::c1o36*(+vx1+vx2+vx3)); break; - case DIR_MMM: velocity = (vf::lbm::constant::c1o36*(-vx1-vx2-vx3)); break; - case DIR_PPM: velocity = (vf::lbm::constant::c1o36*(+vx1+vx2-vx3)); break; - case DIR_MMP: velocity = (vf::lbm::constant::c1o36*(-vx1-vx2+vx3)); break; - case DIR_PMP: velocity = (vf::lbm::constant::c1o36*(+vx1-vx2+vx3)); break; - case DIR_MPM: velocity = (vf::lbm::constant::c1o36*(-vx1+vx2-vx3)); break; - case DIR_PMM: velocity = (vf::lbm::constant::c1o36*(+vx1-vx2-vx3)); break; - case DIR_MPP: velocity = (vf::lbm::constant::c1o36*(-vx1+vx2+vx3)); break; + case DIR_P00: velocity = (vf::basics::constant::c4o9*(+vx1)); break; //(2/cs^2)(=6)*rho_0(=1 bei imkompr)*wi*u*ei mit cs=1/sqrt(3) + case DIR_M00: velocity = (vf::basics::constant::c4o9*(-vx1)); break; //z.B. aus paper manfred MRT LB models in three dimensions (2002) + case DIR_0P0: velocity = (vf::basics::constant::c4o9*(+vx2)); break; + case DIR_0M0: velocity = (vf::basics::constant::c4o9*(-vx2)); break; + case DIR_00P: velocity = (vf::basics::constant::c4o9*(+vx3)); break; + case DIR_00M: velocity = (vf::basics::constant::c4o9*(-vx3)); break; + case DIR_PP0: velocity = (vf::basics::constant::c1o9*(+vx1+vx2)); break; + case DIR_MM0: velocity = (vf::basics::constant::c1o9*(-vx1-vx2)); break; + case DIR_PM0: velocity = (vf::basics::constant::c1o9*(+vx1-vx2)); break; + case DIR_MP0: velocity = (vf::basics::constant::c1o9*(-vx1+vx2)); break; + case DIR_P0P: velocity = (vf::basics::constant::c1o9*(+vx1+vx3)); break; + case DIR_M0M: velocity = (vf::basics::constant::c1o9*(-vx1-vx3)); break; + case DIR_P0M: velocity = (vf::basics::constant::c1o9*(+vx1-vx3)); break; + case DIR_M0P: velocity = (vf::basics::constant::c1o9*(-vx1+vx3)); break; + case DIR_0PP: velocity = (vf::basics::constant::c1o9*(+vx2+vx3)); break; + case DIR_0MM: velocity = (vf::basics::constant::c1o9*(-vx2-vx3)); break; + case DIR_0PM: velocity = (vf::basics::constant::c1o9*(+vx2-vx3)); break; + case DIR_0MP: velocity = (vf::basics::constant::c1o9*(-vx2+vx3)); break; + case DIR_PPP: velocity = (vf::basics::constant::c1o36*(+vx1+vx2+vx3)); break; + case DIR_MMM: velocity = (vf::basics::constant::c1o36*(-vx1-vx2-vx3)); break; + case DIR_PPM: velocity = (vf::basics::constant::c1o36*(+vx1+vx2-vx3)); break; + case DIR_MMP: velocity = (vf::basics::constant::c1o36*(-vx1-vx2+vx3)); break; + case DIR_PMP: velocity = (vf::basics::constant::c1o36*(+vx1-vx2+vx3)); break; + case DIR_MPM: velocity = (vf::basics::constant::c1o36*(-vx1+vx2-vx3)); break; + case DIR_PMM: velocity = (vf::basics::constant::c1o36*(+vx1-vx2-vx3)); break; + case DIR_MPP: velocity = (vf::basics::constant::c1o36*(-vx1+vx2+vx3)); break; default: throw UbException(UB_EXARGS, "unknown error"); } real fReturn = f[invDir] - velocity * rho; diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCStrategy.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCStrategy.cpp index cac20a5e73bdf52cecd2b612a5330006fc62f775..a4ceaeea2600408938fab8020f856b8b5cf2a2e1 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCStrategy.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCStrategy.cpp @@ -49,32 +49,32 @@ void SlipBCStrategy::applyBC() real velocity = vf::lbm::constant::c0o1; switch (invDir) { - case DIR_P00: velocity = (vf::lbm::constant::c4o9*(+vx1)); break; //(2/cs^2)(=6)*rho_0(=1 bei imkompr)*wi*u*ei mit cs=1/sqrt(3) - case DIR_M00: velocity = (vf::lbm::constant::c4o9*(-vx1)); break; //z.B. aus paper manfred MRT LB models in three dimensions (2002) - case DIR_0P0: velocity = (vf::lbm::constant::c4o9*(+vx2)); break; - case DIR_0M0: velocity = (vf::lbm::constant::c4o9*(-vx2)); break; - case DIR_00P: velocity = (vf::lbm::constant::c4o9*(+vx3)); break; - case DIR_00M: velocity = (vf::lbm::constant::c4o9*(-vx3)); break; - case DIR_PP0: velocity = (vf::lbm::constant::c1o9*(+vx1+vx2)); break; - case DIR_MM0: velocity = (vf::lbm::constant::c1o9*(-vx1-vx2)); break; - case DIR_PM0: velocity = (vf::lbm::constant::c1o9*(+vx1-vx2)); break; - case DIR_MP0: velocity = (vf::lbm::constant::c1o9*(-vx1+vx2)); break; - case DIR_P0P: velocity = (vf::lbm::constant::c1o9*(+vx1+vx3)); break; - case DIR_M0M: velocity = (vf::lbm::constant::c1o9*(-vx1-vx3)); break; - case DIR_P0M: velocity = (vf::lbm::constant::c1o9*(+vx1-vx3)); break; - case DIR_M0P: velocity = (vf::lbm::constant::c1o9*(-vx1+vx3)); break; - case DIR_0PP: velocity = (vf::lbm::constant::c1o9*(+vx2+vx3)); break; - case DIR_0MM: velocity = (vf::lbm::constant::c1o9*(-vx2-vx3)); break; - case DIR_0PM: velocity = (vf::lbm::constant::c1o9*(+vx2-vx3)); break; - case DIR_0MP: velocity = (vf::lbm::constant::c1o9*(-vx2+vx3)); break; - case DIR_PPP: velocity = (vf::lbm::constant::c1o36*(+vx1+vx2+vx3)); break; - case DIR_MMM: velocity = (vf::lbm::constant::c1o36*(-vx1-vx2-vx3)); break; - case DIR_PPM: velocity = (vf::lbm::constant::c1o36*(+vx1+vx2-vx3)); break; - case DIR_MMP: velocity = (vf::lbm::constant::c1o36*(-vx1-vx2+vx3)); break; - case DIR_PMP: velocity = (vf::lbm::constant::c1o36*(+vx1-vx2+vx3)); break; - case DIR_MPM: velocity = (vf::lbm::constant::c1o36*(-vx1+vx2-vx3)); break; - case DIR_PMM: velocity = (vf::lbm::constant::c1o36*(+vx1-vx2-vx3)); break; - case DIR_MPP: velocity = (vf::lbm::constant::c1o36*(-vx1+vx2+vx3)); break; + case DIR_P00: velocity = (vf::basics::constant::c4o9*(+vx1)); break; //(2/cs^2)(=6)*rho_0(=1 bei imkompr)*wi*u*ei mit cs=1/sqrt(3) + case DIR_M00: velocity = (vf::basics::constant::c4o9*(-vx1)); break; //z.B. aus paper manfred MRT LB models in three dimensions (2002) + case DIR_0P0: velocity = (vf::basics::constant::c4o9*(+vx2)); break; + case DIR_0M0: velocity = (vf::basics::constant::c4o9*(-vx2)); break; + case DIR_00P: velocity = (vf::basics::constant::c4o9*(+vx3)); break; + case DIR_00M: velocity = (vf::basics::constant::c4o9*(-vx3)); break; + case DIR_PP0: velocity = (vf::basics::constant::c1o9*(+vx1+vx2)); break; + case DIR_MM0: velocity = (vf::basics::constant::c1o9*(-vx1-vx2)); break; + case DIR_PM0: velocity = (vf::basics::constant::c1o9*(+vx1-vx2)); break; + case DIR_MP0: velocity = (vf::basics::constant::c1o9*(-vx1+vx2)); break; + case DIR_P0P: velocity = (vf::basics::constant::c1o9*(+vx1+vx3)); break; + case DIR_M0M: velocity = (vf::basics::constant::c1o9*(-vx1-vx3)); break; + case DIR_P0M: velocity = (vf::basics::constant::c1o9*(+vx1-vx3)); break; + case DIR_M0P: velocity = (vf::basics::constant::c1o9*(-vx1+vx3)); break; + case DIR_0PP: velocity = (vf::basics::constant::c1o9*(+vx2+vx3)); break; + case DIR_0MM: velocity = (vf::basics::constant::c1o9*(-vx2-vx3)); break; + case DIR_0PM: velocity = (vf::basics::constant::c1o9*(+vx2-vx3)); break; + case DIR_0MP: velocity = (vf::basics::constant::c1o9*(-vx2+vx3)); break; + case DIR_PPP: velocity = (vf::basics::constant::c1o36*(+vx1+vx2+vx3)); break; + case DIR_MMM: velocity = (vf::basics::constant::c1o36*(-vx1-vx2-vx3)); break; + case DIR_PPM: velocity = (vf::basics::constant::c1o36*(+vx1+vx2-vx3)); break; + case DIR_MMP: velocity = (vf::basics::constant::c1o36*(-vx1-vx2+vx3)); break; + case DIR_PMP: velocity = (vf::basics::constant::c1o36*(+vx1-vx2+vx3)); break; + case DIR_MPM: velocity = (vf::basics::constant::c1o36*(-vx1+vx2-vx3)); break; + case DIR_PMM: velocity = (vf::basics::constant::c1o36*(+vx1-vx2-vx3)); break; + case DIR_MPP: velocity = (vf::basics::constant::c1o36*(-vx1+vx2+vx3)); break; default: throw UbException(UB_EXARGS, "unknown error"); } real fReturn = ((vf::lbm::constant::c1o1-q)/(vf::lbm::constant::c1o1+q))*((f[invDir]-feq[invDir])/(vf::lbm::constant::c1o1-collFactor)+feq[invDir])+((q*(f[invDir]+f[fdir])-velocity*rho)/(vf::lbm::constant::c1o1+q)); diff --git a/src/cpu/VirtualFluidsCore/Interactors/D3Q27Interactor.cpp b/src/cpu/VirtualFluidsCore/Interactors/D3Q27Interactor.cpp index d90d8ec696140a9325be1c2662f03e604a420fa2..02a94f573ed04a5509c71fb7890fe418d230f0fe 100644 --- a/src/cpu/VirtualFluidsCore/Interactors/D3Q27Interactor.cpp +++ b/src/cpu/VirtualFluidsCore/Interactors/D3Q27Interactor.cpp @@ -90,8 +90,8 @@ void D3Q27Interactor::initRayVectors() using namespace vf::lbm::dir; int fdir; - real c1oS2 = vf::lbm::constant::one_over_sqrt2; - real c1oS3 = vf::lbm::constant::one_over_sqrt3; + real c1oS2 = vf::basics::constant::one_over_sqrt2; + real c1oS3 = vf::basics::constant::one_over_sqrt3; fdir = DIR_P00; rayX1[fdir] = 1.0; rayX2[fdir] = 0.0; @@ -330,19 +330,19 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block) throw UbException( UB_EXARGS, "fuer den bei LB nicht vorkommenden Fall deltaX1!=deltaX2!=deltaX3 nicht implementiert "); - vector<real> distNeigh(D3Q27System::FENDDIR + 1, vf::lbm::constant::sqrt2 * deltaX1); + vector<real> distNeigh(D3Q27System::FENDDIR + 1, vf::basics::constant::sqrt2 * deltaX1); distNeigh[DIR_P00] = distNeigh[DIR_M00] = distNeigh[DIR_0P0] = deltaX1; distNeigh[DIR_0M0] = distNeigh[DIR_00P] = distNeigh[DIR_00M] = deltaX1; distNeigh[DIR_PP0] = distNeigh[DIR_MP0] = distNeigh[DIR_MM0] = - distNeigh[DIR_PM0] = vf::lbm::constant::sqrt2 * deltaX1; + distNeigh[DIR_PM0] = vf::basics::constant::sqrt2 * deltaX1; distNeigh[DIR_P0P] = distNeigh[DIR_0PP] = distNeigh[DIR_M0P] = - distNeigh[DIR_0MP] = vf::lbm::constant::sqrt2 * deltaX1; + distNeigh[DIR_0MP] = vf::basics::constant::sqrt2 * deltaX1; distNeigh[DIR_P0M] = distNeigh[DIR_0PM] = distNeigh[DIR_M0M] = - distNeigh[DIR_0MM] = vf::lbm::constant::sqrt2 * deltaX1; + distNeigh[DIR_0MM] = vf::basics::constant::sqrt2 * deltaX1; distNeigh[DIR_PPP] = distNeigh[DIR_MPP] = distNeigh[DIR_PMP] = - distNeigh[DIR_MMP] = vf::lbm::constant::sqrt3 * deltaX1; + distNeigh[DIR_MMP] = vf::basics::constant::sqrt3 * deltaX1; distNeigh[DIR_PPM] = distNeigh[DIR_MPM] = distNeigh[DIR_PMM] = - distNeigh[DIR_MMM] = vf::lbm::constant::sqrt3 * deltaX1; + distNeigh[DIR_MMM] = vf::basics::constant::sqrt3 * deltaX1; real q; bool pointOnBoundary = false; diff --git a/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.cpp index 8b1b78b73f8ad2ec43bd63dedcde6dbfb6c1c107..02b9f71f0479bbc2d448654cff48fc52b5cc307c 100644 --- a/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.cpp @@ -6,7 +6,7 @@ #include "D3Q27System.h" #include "DataSet3D.h" #include "Block3D.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #define PROOF_CORRECTNESS @@ -42,7 +42,7 @@ void BGKLBMKernel::calculate(int step) { using namespace D3Q27System; // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; using namespace vf::lbm::dir; // initializing of forcing stuff diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.cpp index 6ff48d9d1e3f2bc36c0709a8051e8ad5905faccf..ec2fe072a994f864678acf90758e838c8c776c31 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.cpp @@ -10,7 +10,7 @@ #define PROOF_CORRECTNESS //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; ////////////////////////////////////////////////////////////////////////// CompressibleCumulant4thOrderViscosityLBMKernel::CompressibleCumulant4thOrderViscosityLBMKernel() diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp index a68c625380e75af1d0f927cccad2bdf9b9f72f57..3c0795c21ed41c1f22dc06268e5fc1fa7922c845 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp @@ -8,7 +8,7 @@ #define PROOF_CORRECTNESS //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; ////////////////////////////////////////////////////////////////////////// CompressibleCumulantLBMKernel::CompressibleCumulantLBMKernel() diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp index ed0ce941ed5e1d4ee967391cec080105848e8b11..5cf501e20012804b7e84090243dad466e06ad06c 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp @@ -2,7 +2,7 @@ #include "D3Q27System.h" //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; ////////////////////////////////////////////////////////////////////////// CompressibleOffsetInterpolationProcessor::CompressibleOffsetInterpolationProcessor(real omegaC, real omegaF) @@ -62,7 +62,7 @@ void CompressibleOffsetInterpolationProcessor::calcMoments(const real* const f, { using namespace D3Q27System; using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real drho = c0o1; D3Q27System::calcCompMacroscopicValues(f,drho,vx1,vx2,vx3); diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.cpp index f3511fd7a48a7e58ddefb397e681f182b121c499..74527c0c39d5255a4ca3e647a288fffa027373ac 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.cpp @@ -2,7 +2,7 @@ #include "D3Q27System.h" //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; CompressibleOffsetMomentsInterpolationProcessor::CompressibleOffsetMomentsInterpolationProcessor() @@ -489,7 +489,7 @@ void CompressibleOffsetMomentsInterpolationProcessor::calcInterpolatedNodeCF(rea { using namespace D3Q27System; using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real eps_new = c1o2; real o = omega; diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.cpp index 1e82ff96f950eb84a2ef7e1da636ef91e51b85f4..dee6d12a5812e29d91aa1c12c25d61ade0759ef8 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.cpp @@ -2,7 +2,7 @@ #include "D3Q27System.h" //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; CompressibleOffsetSquarePressureInterpolationProcessor::CompressibleOffsetSquarePressureInterpolationProcessor() diff --git a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp index 5ffc4ca1397100854e7c0c4b6902f87be3765618..9c89f6c6b549fed93fca097232bcc086e3c380a8 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp @@ -42,8 +42,7 @@ #define PROOF_CORRECTNESS //using namespace UbMath; -using namespace vf::lbm::constant -; +using namespace vf::basics::constant; ////////////////////////////////////////////////////////////////////////// CumulantK17LBMKernel::CumulantK17LBMKernel() diff --git a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h index 39dd0a2c75d39d27bda587f8810cb76691fea99d..2bcdf8551bef28aa46932a180268f05873d7ecc0 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h @@ -87,7 +87,7 @@ protected: inline void CumulantK17LBMKernel::forwardInverseChimeraWithK(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m2 = mfa + mfc; real m1 = mfc - mfa; real m0 = m2 + mfb; @@ -106,7 +106,7 @@ inline void CumulantK17LBMKernel::forwardInverseChimeraWithK(real& mfa, real& mf inline void CumulantK17LBMKernel::backwardInverseChimeraWithK(real& mfa, real& mfb, real& mfc, real vv, real v2, real Kinverse, real K) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + c1o1) * (v2 - vv) * c1o2) * K; real m1 = (((mfa - mfc) - c2o1 * mfb * vv) * Kinverse + (mfa * Kinverse + c1o1) * (-v2)) * K; @@ -124,7 +124,7 @@ inline void CumulantK17LBMKernel::backwardInverseChimeraWithK(real& mfa, real& m inline void CumulantK17LBMKernel::forwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real m1 = (mfa + mfc) + mfb; real m2 = mfc - mfa; @@ -142,7 +142,7 @@ inline void CumulantK17LBMKernel::forwardChimera(real& mfa, real& mfb, real& mfc inline void CumulantK17LBMKernel::backwardChimera(real& mfa, real& mfb, real& mfc, real vv, real v2) { // using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); real mb = ((mfa - mfc) - mfa * v2) - c2o1 * mfb * vv; diff --git a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernelUnified.cpp b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernelUnified.cpp index 1b8bdd340ff20facf0d91cbb3ff424357508446f..2a791636d42e8f17761873cd5e95c8dcf933e0b6 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernelUnified.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernelUnified.cpp @@ -47,7 +47,7 @@ //#define PROOF_CORRECTNESS //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; ////////////////////////////////////////////////////////////////////////// CumulantK17LBMKernelUnified::CumulantK17LBMKernelUnified() diff --git a/src/cpu/VirtualFluidsCore/LBM/CumulantLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/CumulantLBMKernel.cpp index b30884d386279bf2d8243fe68338c7a45cac8073..548339f940d45ab2239ce6cb1cebbfa9bf0082b5 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CumulantLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CumulantLBMKernel.cpp @@ -9,7 +9,7 @@ #define PROOF_CORRECTNESS //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; ////////////////////////////////////////////////////////////////////////// CumulantLBMKernel::CumulantLBMKernel() diff --git a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp index b7aed29bbf30f3081633df6f45eaf7ade9d93572..5c9be26b7b1ace78e81f1a1c1f28a1e089c9a013 100644 --- a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp @@ -5,7 +5,7 @@ namespace D3Q27System { //using namespace UbMath; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; // index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 // f: E, W, N, S, T, B, NE, SW, SE, NW, TE, BW, BE, TW, TN, BS, BN, TS, TNE TNW TSE TSW BNE BNW BSE BSW diff --git a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h index a8bf297c55d656f5e277fe6e280fb0502a32c283..57226cb5ee9c69aa7a497525f6decb75638d7899 100644 --- a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h +++ b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h @@ -43,7 +43,7 @@ #include "LBMSystem.h" #include "UbException.h" #include "UbMath.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" //using namespace vf::lbm::dir; @@ -399,7 +399,7 @@ static inline void setNeighborCoordinatesForDirection(int &x1, int &x2, int &x3, /*=====================================================================*/ real getDensity(const real *const &f /*[27]*/); /*=====================================================================*/ -static real getPressure(const real *const &f /*[27]*/) { return REAL_CAST(vf::lbm::constant::c1o3) * getDensity(f); } +static real getPressure(const real *const &f /*[27]*/) { return REAL_CAST(vf::basics::constant::c1o3) * getDensity(f); } /*=====================================================================*/ real getIncompVelocityX1(const real *const &f /*[27]*/); /*=====================================================================*/ @@ -514,8 +514,8 @@ static void calcCompMacroscopicValues(const real *const &f /*[27]*/, real &drho, D3Q27System::calcIncompVelocityX1(f, vx1); D3Q27System::calcIncompVelocityX2(f, vx2); D3Q27System::calcIncompVelocityX3(f, vx3); - //real rho = drho + vf::lbm::constant::one; - real rho = drho + vf::lbm::constant::c1o1; + //real rho = drho + vf::basics::constant::one; + real rho = drho + vf::basics::constant::c1o1; vx1 /= rho; vx2 /= rho; vx3 /= rho; @@ -527,90 +527,90 @@ static real getCompFeqForDirection(const int &direction, const real &drho, const using namespace vf::lbm::dir; real cu_sq = 1.5 * (vx1 * vx1 + vx2 * vx2 + vx3 * vx3); - real rho = drho + vf::lbm::constant::c1o1; + real rho = drho + vf::basics::constant::c1o1; switch (direction) { case DIR_000: - return REAL_CAST(vf::lbm::constant::c8o27 * (drho + rho * (-cu_sq))); + return REAL_CAST(vf::basics::constant::c8o27 * (drho + rho * (-cu_sq))); case DIR_P00: - return REAL_CAST(vf::lbm::constant::c2o27 * (drho + rho * (3.0 * (vx1) +vf::lbm::constant::c9o2 * (vx1) * (vx1)-cu_sq))); + return REAL_CAST(vf::basics::constant::c2o27 * (drho + rho * (3.0 * (vx1) +vf::basics::constant::c9o2 * (vx1) * (vx1)-cu_sq))); case DIR_M00: - return REAL_CAST(vf::lbm::constant::c2o27 * (drho + rho * (3.0 * (-vx1) + vf::lbm::constant::c9o2 * (-vx1) * (-vx1) - cu_sq))); + return REAL_CAST(vf::basics::constant::c2o27 * (drho + rho * (3.0 * (-vx1) + vf::basics::constant::c9o2 * (-vx1) * (-vx1) - cu_sq))); case DIR_0P0: - return REAL_CAST(vf::lbm::constant::c2o27 * (drho + rho * (3.0 * (vx2) +vf::lbm::constant::c9o2 * (vx2) * (vx2)-cu_sq))); + return REAL_CAST(vf::basics::constant::c2o27 * (drho + rho * (3.0 * (vx2) +vf::basics::constant::c9o2 * (vx2) * (vx2)-cu_sq))); case DIR_0M0: - return REAL_CAST(vf::lbm::constant::c2o27 * (drho + rho * (3.0 * (-vx2) + vf::lbm::constant::c9o2 * (-vx2) * (-vx2) - cu_sq))); + return REAL_CAST(vf::basics::constant::c2o27 * (drho + rho * (3.0 * (-vx2) + vf::basics::constant::c9o2 * (-vx2) * (-vx2) - cu_sq))); case DIR_00P: - return REAL_CAST(vf::lbm::constant::c2o27 * (drho + rho * (3.0 * (vx3) + vf::lbm::constant::c9o2 * (vx3) * (vx3)-cu_sq))); + return REAL_CAST(vf::basics::constant::c2o27 * (drho + rho * (3.0 * (vx3) + vf::basics::constant::c9o2 * (vx3) * (vx3)-cu_sq))); case DIR_00M: - return REAL_CAST(vf::lbm::constant::c2o27 * (drho + rho * (3.0 * (-vx3) + vf::lbm::constant::c9o2 * (-vx3) * (-vx3) - cu_sq))); + return REAL_CAST(vf::basics::constant::c2o27 * (drho + rho * (3.0 * (-vx3) + vf::basics::constant::c9o2 * (-vx3) * (-vx3) - cu_sq))); case DIR_PP0: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + rho * (3.0 * (vx1 + vx2) + vf::lbm::constant::c9o2 * (vx1 + vx2) * (vx1 + vx2) - cu_sq))); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + rho * (3.0 * (vx1 + vx2) + vf::basics::constant::c9o2 * (vx1 + vx2) * (vx1 + vx2) - cu_sq))); case DIR_MM0: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + rho * (3.0 * (-vx1 - vx2) + vf::lbm::constant::c9o2 * (-vx1 - vx2) * (-vx1 - vx2) - cu_sq))); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + rho * (3.0 * (-vx1 - vx2) + vf::basics::constant::c9o2 * (-vx1 - vx2) * (-vx1 - vx2) - cu_sq))); case DIR_PM0: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + rho * (3.0 * (vx1 - vx2) + vf::lbm::constant::c9o2 * (vx1 - vx2) * (vx1 - vx2) - cu_sq))); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + rho * (3.0 * (vx1 - vx2) + vf::basics::constant::c9o2 * (vx1 - vx2) * (vx1 - vx2) - cu_sq))); case DIR_MP0: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + rho * (3.0 * (-vx1 + vx2) + vf::lbm::constant::c9o2 * (-vx1 + vx2) * (-vx1 + vx2) - cu_sq))); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + rho * (3.0 * (-vx1 + vx2) + vf::basics::constant::c9o2 * (-vx1 + vx2) * (-vx1 + vx2) - cu_sq))); case DIR_P0P: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + rho * (3.0 * (vx1 + vx3) + vf::lbm::constant::c9o2 * (vx1 + vx3) * (vx1 + vx3) - cu_sq))); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + rho * (3.0 * (vx1 + vx3) + vf::basics::constant::c9o2 * (vx1 + vx3) * (vx1 + vx3) - cu_sq))); case DIR_M0M: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + rho * (3.0 * (-vx1 - vx3) + vf::lbm::constant::c9o2 * (-vx1 - vx3) * (-vx1 - vx3) - cu_sq))); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + rho * (3.0 * (-vx1 - vx3) + vf::basics::constant::c9o2 * (-vx1 - vx3) * (-vx1 - vx3) - cu_sq))); case DIR_P0M: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + rho * (3.0 * (vx1 - vx3) + vf::lbm::constant::c9o2 * (vx1 - vx3) * (vx1 - vx3) - cu_sq))); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + rho * (3.0 * (vx1 - vx3) + vf::basics::constant::c9o2 * (vx1 - vx3) * (vx1 - vx3) - cu_sq))); case DIR_M0P: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + rho * (3.0 * (-vx1 + vx3) + vf::lbm::constant::c9o2 * (-vx1 + vx3) * (-vx1 + vx3) - cu_sq))); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + rho * (3.0 * (-vx1 + vx3) + vf::basics::constant::c9o2 * (-vx1 + vx3) * (-vx1 + vx3) - cu_sq))); case DIR_0PP: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + rho * (3.0 * (vx2 + vx3) + vf::lbm::constant::c9o2 * (vx2 + vx3) * (vx2 + vx3) - cu_sq))); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + rho * (3.0 * (vx2 + vx3) + vf::basics::constant::c9o2 * (vx2 + vx3) * (vx2 + vx3) - cu_sq))); case DIR_0MM: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + rho * (3.0 * (-vx2 - vx3) + vf::lbm::constant::c9o2 * (-vx2 - vx3) * (-vx2 - vx3) - cu_sq))); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + rho * (3.0 * (-vx2 - vx3) + vf::basics::constant::c9o2 * (-vx2 - vx3) * (-vx2 - vx3) - cu_sq))); case DIR_0PM: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + rho * (3.0 * (vx2 - vx3) + vf::lbm::constant::c9o2 * (vx2 - vx3) * (vx2 - vx3) - cu_sq))); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + rho * (3.0 * (vx2 - vx3) + vf::basics::constant::c9o2 * (vx2 - vx3) * (vx2 - vx3) - cu_sq))); case DIR_0MP: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + rho * (3.0 * (-vx2 + vx3) + vf::lbm::constant::c9o2 * (-vx2 + vx3) * (-vx2 + vx3) - cu_sq))); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + rho * (3.0 * (-vx2 + vx3) + vf::basics::constant::c9o2 * (-vx2 + vx3) * (-vx2 + vx3) - cu_sq))); case DIR_PPP: - return REAL_CAST(vf::lbm::constant::c1o216 * + return REAL_CAST(vf::basics::constant::c1o216 * (drho + rho * (3.0 * (vx1 + vx2 + vx3) + - vf::lbm::constant::c9o2 * (vx1 + vx2 + vx3) * (vx1 + vx2 + vx3) - cu_sq))); + vf::basics::constant::c9o2 * (vx1 + vx2 + vx3) * (vx1 + vx2 + vx3) - cu_sq))); case DIR_MMM: - return REAL_CAST(vf::lbm::constant::c1o216 * + return REAL_CAST(vf::basics::constant::c1o216 * (drho + rho * (3.0 * (-vx1 - vx2 - vx3) + - vf::lbm::constant::c9o2 * (-vx1 - vx2 - vx3) * (-vx1 - vx2 - vx3) - cu_sq))); + vf::basics::constant::c9o2 * (-vx1 - vx2 - vx3) * (-vx1 - vx2 - vx3) - cu_sq))); case DIR_PPM: - return REAL_CAST(vf::lbm::constant::c1o216 * + return REAL_CAST(vf::basics::constant::c1o216 * (drho + rho * (3.0 * (vx1 + vx2 - vx3) + - vf::lbm::constant::c9o2 * (vx1 + vx2 - vx3) * (vx1 + vx2 - vx3) - cu_sq))); + vf::basics::constant::c9o2 * (vx1 + vx2 - vx3) * (vx1 + vx2 - vx3) - cu_sq))); case DIR_MMP: - return REAL_CAST(vf::lbm::constant::c1o216 * + return REAL_CAST(vf::basics::constant::c1o216 * (drho + rho * (3.0 * (-vx1 - vx2 + vx3) + - vf::lbm::constant::c9o2 * (-vx1 - vx2 + vx3) * (-vx1 - vx2 + vx3) - cu_sq))); + vf::basics::constant::c9o2 * (-vx1 - vx2 + vx3) * (-vx1 - vx2 + vx3) - cu_sq))); case DIR_PMP: - return REAL_CAST(vf::lbm::constant::c1o216 * + return REAL_CAST(vf::basics::constant::c1o216 * (drho + rho * (3.0 * (vx1 - vx2 + vx3) + - vf::lbm::constant::c9o2 * (vx1 - vx2 + vx3) * (vx1 - vx2 + vx3) - cu_sq))); + vf::basics::constant::c9o2 * (vx1 - vx2 + vx3) * (vx1 - vx2 + vx3) - cu_sq))); case DIR_MPM: - return REAL_CAST(vf::lbm::constant::c1o216 * + return REAL_CAST(vf::basics::constant::c1o216 * (drho + rho * (3.0 * (-vx1 + vx2 - vx3) + - vf::lbm::constant::c9o2 * (-vx1 + vx2 - vx3) * (-vx1 + vx2 - vx3) - cu_sq))); + vf::basics::constant::c9o2 * (-vx1 + vx2 - vx3) * (-vx1 + vx2 - vx3) - cu_sq))); case DIR_PMM: - return REAL_CAST(vf::lbm::constant::c1o216 * + return REAL_CAST(vf::basics::constant::c1o216 * (drho + rho * (3.0 * (vx1 - vx2 - vx3) + - vf::lbm::constant::c9o2 * (vx1 - vx2 - vx3) * (vx1 - vx2 - vx3) - cu_sq))); + vf::basics::constant::c9o2 * (vx1 - vx2 - vx3) * (vx1 - vx2 - vx3) - cu_sq))); case DIR_MPP: - return REAL_CAST(vf::lbm::constant::c1o216 * + return REAL_CAST(vf::basics::constant::c1o216 * (drho + rho * (3.0 * (-vx1 + vx2 + vx3) + - vf::lbm::constant::c9o2 * (-vx1 + vx2 + vx3) * (-vx1 + vx2 + vx3) - cu_sq))); + vf::basics::constant::c9o2 * (-vx1 + vx2 + vx3) * (-vx1 + vx2 + vx3) - cu_sq))); default: throw UbException(UB_EXARGS, "unknown dir"); } @@ -622,47 +622,47 @@ static void calcCompFeq(real *const &feq /*[27]*/, const real &drho, const real using namespace vf::lbm::dir; real cu_sq = 1.5 * (vx1 * vx1 + vx2 * vx2 + vx3 * vx3); - real rho = drho + vf::lbm::constant::c1o1; - - feq[DIR_000] = vf::lbm::constant::c8o27 * (drho + rho * (-cu_sq)); - feq[DIR_P00] = vf::lbm::constant::c2o27 * (drho + rho * (3.0 * (vx1) + vf::lbm::constant::c9o2 * (vx1) * (vx1)-cu_sq)); - feq[DIR_M00] = vf::lbm::constant::c2o27 * (drho + rho * (3.0 * (-vx1) + vf::lbm::constant::c9o2 * (-vx1) * (-vx1) - cu_sq)); - feq[DIR_0P0] = vf::lbm::constant::c2o27 * (drho + rho * (3.0 * (vx2) + vf::lbm::constant::c9o2 * (vx2) * (vx2)-cu_sq)); - feq[DIR_0M0] = vf::lbm::constant::c2o27 * (drho + rho * (3.0 * (-vx2) + vf::lbm::constant::c9o2 * (-vx2) * (-vx2) - cu_sq)); - feq[DIR_00P] = vf::lbm::constant::c2o27 * (drho + rho * (3.0 * (vx3) + vf::lbm::constant::c9o2 * (vx3) * (vx3)-cu_sq)); - feq[DIR_00M] = vf::lbm::constant::c2o27 * (drho + rho * (3.0 * (-vx3) + vf::lbm::constant::c9o2 * (-vx3) * (-vx3) - cu_sq)); - feq[DIR_PP0] = vf::lbm::constant::c1o54 * (drho + rho * (3.0 * (vx1 + vx2) + vf::lbm::constant::c9o2 * (vx1 + vx2) * (vx1 + vx2) - cu_sq)); - feq[DIR_MM0] = vf::lbm::constant::c1o54 * (drho + rho * (3.0 * (-vx1 - vx2) + vf::lbm::constant::c9o2 * (-vx1 - vx2) * (-vx1 - vx2) - cu_sq)); - feq[DIR_PM0] = vf::lbm::constant::c1o54 * (drho + rho * (3.0 * (vx1 - vx2) + vf::lbm::constant::c9o2 * (vx1 - vx2) * (vx1 - vx2) - cu_sq)); - feq[DIR_MP0] = vf::lbm::constant::c1o54 * (drho + rho * (3.0 * (-vx1 + vx2) + vf::lbm::constant::c9o2 * (-vx1 + vx2) * (-vx1 + vx2) - cu_sq)); - feq[DIR_P0P] = vf::lbm::constant::c1o54 * (drho + rho * (3.0 * (vx1 + vx3) + vf::lbm::constant::c9o2 * (vx1 + vx3) * (vx1 + vx3) - cu_sq)); - feq[DIR_M0M] = vf::lbm::constant::c1o54 * (drho + rho * (3.0 * (-vx1 - vx3) + vf::lbm::constant::c9o2 * (-vx1 - vx3) * (-vx1 - vx3) - cu_sq)); - feq[DIR_P0M] = vf::lbm::constant::c1o54 * (drho + rho * (3.0 * (vx1 - vx3) + vf::lbm::constant::c9o2 * (vx1 - vx3) * (vx1 - vx3) - cu_sq)); - feq[DIR_M0P] = vf::lbm::constant::c1o54 * (drho + rho * (3.0 * (-vx1 + vx3) + vf::lbm::constant::c9o2 * (-vx1 + vx3) * (-vx1 + vx3) - cu_sq)); - feq[DIR_0PP] = vf::lbm::constant::c1o54 * (drho + rho * (3.0 * (vx2 + vx3) + vf::lbm::constant::c9o2 * (vx2 + vx3) * (vx2 + vx3) - cu_sq)); - feq[DIR_0MM] = vf::lbm::constant::c1o54 * (drho + rho * (3.0 * (-vx2 - vx3) + vf::lbm::constant::c9o2 * (-vx2 - vx3) * (-vx2 - vx3) - cu_sq)); - feq[DIR_0PM] = vf::lbm::constant::c1o54 * (drho + rho * (3.0 * (vx2 - vx3) + vf::lbm::constant::c9o2 * (vx2 - vx3) * (vx2 - vx3) - cu_sq)); - feq[DIR_0MP] = vf::lbm::constant::c1o54 * (drho + rho * (3.0 * (-vx2 + vx3) + vf::lbm::constant::c9o2 * (-vx2 + vx3) * (-vx2 + vx3) - cu_sq)); - feq[DIR_PPP] = vf::lbm::constant::c1o216 * - (drho + rho * (3.0 * (vx1 + vx2 + vx3) + vf::lbm::constant::c9o2 * (vx1 + vx2 + vx3) * (vx1 + vx2 + vx3) - cu_sq)); + real rho = drho + vf::basics::constant::c1o1; + + feq[DIR_000] = vf::basics::constant::c8o27 * (drho + rho * (-cu_sq)); + feq[DIR_P00] = vf::basics::constant::c2o27 * (drho + rho * (3.0 * (vx1) + vf::basics::constant::c9o2 * (vx1) * (vx1)-cu_sq)); + feq[DIR_M00] = vf::basics::constant::c2o27 * (drho + rho * (3.0 * (-vx1) + vf::basics::constant::c9o2 * (-vx1) * (-vx1) - cu_sq)); + feq[DIR_0P0] = vf::basics::constant::c2o27 * (drho + rho * (3.0 * (vx2) + vf::basics::constant::c9o2 * (vx2) * (vx2)-cu_sq)); + feq[DIR_0M0] = vf::basics::constant::c2o27 * (drho + rho * (3.0 * (-vx2) + vf::basics::constant::c9o2 * (-vx2) * (-vx2) - cu_sq)); + feq[DIR_00P] = vf::basics::constant::c2o27 * (drho + rho * (3.0 * (vx3) + vf::basics::constant::c9o2 * (vx3) * (vx3)-cu_sq)); + feq[DIR_00M] = vf::basics::constant::c2o27 * (drho + rho * (3.0 * (-vx3) + vf::basics::constant::c9o2 * (-vx3) * (-vx3) - cu_sq)); + feq[DIR_PP0] = vf::basics::constant::c1o54 * (drho + rho * (3.0 * (vx1 + vx2) + vf::basics::constant::c9o2 * (vx1 + vx2) * (vx1 + vx2) - cu_sq)); + feq[DIR_MM0] = vf::basics::constant::c1o54 * (drho + rho * (3.0 * (-vx1 - vx2) + vf::basics::constant::c9o2 * (-vx1 - vx2) * (-vx1 - vx2) - cu_sq)); + feq[DIR_PM0] = vf::basics::constant::c1o54 * (drho + rho * (3.0 * (vx1 - vx2) + vf::basics::constant::c9o2 * (vx1 - vx2) * (vx1 - vx2) - cu_sq)); + feq[DIR_MP0] = vf::basics::constant::c1o54 * (drho + rho * (3.0 * (-vx1 + vx2) + vf::basics::constant::c9o2 * (-vx1 + vx2) * (-vx1 + vx2) - cu_sq)); + feq[DIR_P0P] = vf::basics::constant::c1o54 * (drho + rho * (3.0 * (vx1 + vx3) + vf::basics::constant::c9o2 * (vx1 + vx3) * (vx1 + vx3) - cu_sq)); + feq[DIR_M0M] = vf::basics::constant::c1o54 * (drho + rho * (3.0 * (-vx1 - vx3) + vf::basics::constant::c9o2 * (-vx1 - vx3) * (-vx1 - vx3) - cu_sq)); + feq[DIR_P0M] = vf::basics::constant::c1o54 * (drho + rho * (3.0 * (vx1 - vx3) + vf::basics::constant::c9o2 * (vx1 - vx3) * (vx1 - vx3) - cu_sq)); + feq[DIR_M0P] = vf::basics::constant::c1o54 * (drho + rho * (3.0 * (-vx1 + vx3) + vf::basics::constant::c9o2 * (-vx1 + vx3) * (-vx1 + vx3) - cu_sq)); + feq[DIR_0PP] = vf::basics::constant::c1o54 * (drho + rho * (3.0 * (vx2 + vx3) + vf::basics::constant::c9o2 * (vx2 + vx3) * (vx2 + vx3) - cu_sq)); + feq[DIR_0MM] = vf::basics::constant::c1o54 * (drho + rho * (3.0 * (-vx2 - vx3) + vf::basics::constant::c9o2 * (-vx2 - vx3) * (-vx2 - vx3) - cu_sq)); + feq[DIR_0PM] = vf::basics::constant::c1o54 * (drho + rho * (3.0 * (vx2 - vx3) + vf::basics::constant::c9o2 * (vx2 - vx3) * (vx2 - vx3) - cu_sq)); + feq[DIR_0MP] = vf::basics::constant::c1o54 * (drho + rho * (3.0 * (-vx2 + vx3) + vf::basics::constant::c9o2 * (-vx2 + vx3) * (-vx2 + vx3) - cu_sq)); + feq[DIR_PPP] = vf::basics::constant::c1o216 * + (drho + rho * (3.0 * (vx1 + vx2 + vx3) + vf::basics::constant::c9o2 * (vx1 + vx2 + vx3) * (vx1 + vx2 + vx3) - cu_sq)); feq[DIR_MMM] = - vf::lbm::constant::c1o216 * - (drho + rho * (3.0 * (-vx1 - vx2 - vx3) + vf::lbm::constant::c9o2 * (-vx1 - vx2 - vx3) * (-vx1 - vx2 - vx3) - cu_sq)); - feq[DIR_PPM] = vf::lbm::constant::c1o216 * - (drho + rho * (3.0 * (vx1 + vx2 - vx3) + vf::lbm::constant::c9o2 * (vx1 + vx2 - vx3) * (vx1 + vx2 - vx3) - cu_sq)); + vf::basics::constant::c1o216 * + (drho + rho * (3.0 * (-vx1 - vx2 - vx3) + vf::basics::constant::c9o2 * (-vx1 - vx2 - vx3) * (-vx1 - vx2 - vx3) - cu_sq)); + feq[DIR_PPM] = vf::basics::constant::c1o216 * + (drho + rho * (3.0 * (vx1 + vx2 - vx3) + vf::basics::constant::c9o2 * (vx1 + vx2 - vx3) * (vx1 + vx2 - vx3) - cu_sq)); feq[DIR_MMP] = - vf::lbm::constant::c1o216 * - (drho + rho * (3.0 * (-vx1 - vx2 + vx3) + vf::lbm::constant::c9o2 * (-vx1 - vx2 + vx3) * (-vx1 - vx2 + vx3) - cu_sq)); - feq[DIR_PMP] = vf::lbm::constant::c1o216 * - (drho + rho * (3.0 * (vx1 - vx2 + vx3) + vf::lbm::constant::c9o2 * (vx1 - vx2 + vx3) * (vx1 - vx2 + vx3) - cu_sq)); + vf::basics::constant::c1o216 * + (drho + rho * (3.0 * (-vx1 - vx2 + vx3) + vf::basics::constant::c9o2 * (-vx1 - vx2 + vx3) * (-vx1 - vx2 + vx3) - cu_sq)); + feq[DIR_PMP] = vf::basics::constant::c1o216 * + (drho + rho * (3.0 * (vx1 - vx2 + vx3) + vf::basics::constant::c9o2 * (vx1 - vx2 + vx3) * (vx1 - vx2 + vx3) - cu_sq)); feq[DIR_MPM] = - vf::lbm::constant::c1o216 * - (drho + rho * (3.0 * (-vx1 + vx2 - vx3) + vf::lbm::constant::c9o2 * (-vx1 + vx2 - vx3) * (-vx1 + vx2 - vx3) - cu_sq)); - feq[DIR_PMM] = vf::lbm::constant::c1o216 * - (drho + rho * (3.0 * (vx1 - vx2 - vx3) + vf::lbm::constant::c9o2 * (vx1 - vx2 - vx3) * (vx1 - vx2 - vx3) - cu_sq)); + vf::basics::constant::c1o216 * + (drho + rho * (3.0 * (-vx1 + vx2 - vx3) + vf::basics::constant::c9o2 * (-vx1 + vx2 - vx3) * (-vx1 + vx2 - vx3) - cu_sq)); + feq[DIR_PMM] = vf::basics::constant::c1o216 * + (drho + rho * (3.0 * (vx1 - vx2 - vx3) + vf::basics::constant::c9o2 * (vx1 - vx2 - vx3) * (vx1 - vx2 - vx3) - cu_sq)); feq[DIR_MPP] = - vf::lbm::constant::c1o216 * - (drho + rho * (3.0 * (-vx1 + vx2 + vx3) + vf::lbm::constant::c9o2 * (-vx1 + vx2 + vx3) * (-vx1 + vx2 + vx3) - cu_sq)); + vf::basics::constant::c1o216 * + (drho + rho * (3.0 * (-vx1 + vx2 + vx3) + vf::basics::constant::c9o2 * (-vx1 + vx2 + vx3) * (-vx1 + vx2 + vx3) - cu_sq)); } ////////////////////////////////////////////////////////////////////////// static real getIncompFeqForDirection(const int &direction, const real &drho, const real &vx1, @@ -674,79 +674,79 @@ static real getIncompFeqForDirection(const int &direction, const real &drho, con switch (direction) { case DIR_000: - return REAL_CAST(vf::lbm::constant::c8o27 * (drho - cu_sq)); + return REAL_CAST(vf::basics::constant::c8o27 * (drho - cu_sq)); case DIR_P00: - return REAL_CAST(vf::lbm::constant::c2o27 * (drho + 3.0 * (vx1) + vf::lbm::constant::c9o2 * (vx1) * (vx1)-cu_sq)); + return REAL_CAST(vf::basics::constant::c2o27 * (drho + 3.0 * (vx1) + vf::basics::constant::c9o2 * (vx1) * (vx1)-cu_sq)); case DIR_M00: - return REAL_CAST(vf::lbm::constant::c2o27 * (drho + 3.0 * (-vx1) + vf::lbm::constant::c9o2 * (-vx1) * (-vx1) - cu_sq)); + return REAL_CAST(vf::basics::constant::c2o27 * (drho + 3.0 * (-vx1) + vf::basics::constant::c9o2 * (-vx1) * (-vx1) - cu_sq)); case DIR_0P0: - return REAL_CAST(vf::lbm::constant::c2o27 * (drho + 3.0 * (vx2) + vf::lbm::constant::c9o2 * (vx2) * (vx2)-cu_sq)); + return REAL_CAST(vf::basics::constant::c2o27 * (drho + 3.0 * (vx2) + vf::basics::constant::c9o2 * (vx2) * (vx2)-cu_sq)); case DIR_0M0: - return REAL_CAST(vf::lbm::constant::c2o27 * (drho + 3.0 * (-vx2) + vf::lbm::constant::c9o2 * (-vx2) * (-vx2) - cu_sq)); + return REAL_CAST(vf::basics::constant::c2o27 * (drho + 3.0 * (-vx2) + vf::basics::constant::c9o2 * (-vx2) * (-vx2) - cu_sq)); case DIR_00P: - return REAL_CAST(vf::lbm::constant::c2o27 * (drho + 3.0 * (vx3) + vf::lbm::constant::c9o2 * (vx3) * (vx3)-cu_sq)); + return REAL_CAST(vf::basics::constant::c2o27 * (drho + 3.0 * (vx3) + vf::basics::constant::c9o2 * (vx3) * (vx3)-cu_sq)); case DIR_00M: - return REAL_CAST(vf::lbm::constant::c2o27 * (drho + 3.0 * (-vx3) + vf::lbm::constant::c9o2 * (-vx3) * (-vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c2o27 * (drho + 3.0 * (-vx3) + vf::basics::constant::c9o2 * (-vx3) * (-vx3) - cu_sq)); case DIR_PP0: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + 3.0 * (vx1 + vx2) + vf::lbm::constant::c9o2 * (vx1 + vx2) * (vx1 + vx2) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + 3.0 * (vx1 + vx2) + vf::basics::constant::c9o2 * (vx1 + vx2) * (vx1 + vx2) - cu_sq)); case DIR_MM0: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + 3.0 * (-vx1 - vx2) + vf::lbm::constant::c9o2 * (-vx1 - vx2) * (-vx1 - vx2) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + 3.0 * (-vx1 - vx2) + vf::basics::constant::c9o2 * (-vx1 - vx2) * (-vx1 - vx2) - cu_sq)); case DIR_PM0: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + 3.0 * (vx1 - vx2) + vf::lbm::constant::c9o2 * (vx1 - vx2) * (vx1 - vx2) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + 3.0 * (vx1 - vx2) + vf::basics::constant::c9o2 * (vx1 - vx2) * (vx1 - vx2) - cu_sq)); case DIR_MP0: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + 3.0 * (-vx1 + vx2) + vf::lbm::constant::c9o2 * (-vx1 + vx2) * (-vx1 + vx2) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + 3.0 * (-vx1 + vx2) + vf::basics::constant::c9o2 * (-vx1 + vx2) * (-vx1 + vx2) - cu_sq)); case DIR_P0P: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + 3.0 * (vx1 + vx3) + vf::lbm::constant::c9o2 * (vx1 + vx3) * (vx1 + vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + 3.0 * (vx1 + vx3) + vf::basics::constant::c9o2 * (vx1 + vx3) * (vx1 + vx3) - cu_sq)); case DIR_M0M: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + 3.0 * (-vx1 - vx3) + vf::lbm::constant::c9o2 * (-vx1 - vx3) * (-vx1 - vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + 3.0 * (-vx1 - vx3) + vf::basics::constant::c9o2 * (-vx1 - vx3) * (-vx1 - vx3) - cu_sq)); case DIR_P0M: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + 3.0 * (vx1 - vx3) + vf::lbm::constant::c9o2 * (vx1 - vx3) * (vx1 - vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + 3.0 * (vx1 - vx3) + vf::basics::constant::c9o2 * (vx1 - vx3) * (vx1 - vx3) - cu_sq)); case DIR_M0P: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + 3.0 * (-vx1 + vx3) + vf::lbm::constant::c9o2 * (-vx1 + vx3) * (-vx1 + vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + 3.0 * (-vx1 + vx3) + vf::basics::constant::c9o2 * (-vx1 + vx3) * (-vx1 + vx3) - cu_sq)); case DIR_0PP: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + 3.0 * (vx2 + vx3) + vf::lbm::constant::c9o2 * (vx2 + vx3) * (vx2 + vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + 3.0 * (vx2 + vx3) + vf::basics::constant::c9o2 * (vx2 + vx3) * (vx2 + vx3) - cu_sq)); case DIR_0MM: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + 3.0 * (-vx2 - vx3) + vf::lbm::constant::c9o2 * (-vx2 - vx3) * (-vx2 - vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + 3.0 * (-vx2 - vx3) + vf::basics::constant::c9o2 * (-vx2 - vx3) * (-vx2 - vx3) - cu_sq)); case DIR_0PM: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + 3.0 * (vx2 - vx3) + vf::lbm::constant::c9o2 * (vx2 - vx3) * (vx2 - vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + 3.0 * (vx2 - vx3) + vf::basics::constant::c9o2 * (vx2 - vx3) * (vx2 - vx3) - cu_sq)); case DIR_0MP: - return REAL_CAST(vf::lbm::constant::c1o54 * - (drho + 3.0 * (-vx2 + vx3) + vf::lbm::constant::c9o2 * (-vx2 + vx3) * (-vx2 + vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o54 * + (drho + 3.0 * (-vx2 + vx3) + vf::basics::constant::c9o2 * (-vx2 + vx3) * (-vx2 + vx3) - cu_sq)); case DIR_PPP: - return REAL_CAST(vf::lbm::constant::c1o216 * (drho + 3.0 * (vx1 + vx2 + vx3) + - vf::lbm::constant::c9o2 * (vx1 + vx2 + vx3) * (vx1 + vx2 + vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o216 * (drho + 3.0 * (vx1 + vx2 + vx3) + + vf::basics::constant::c9o2 * (vx1 + vx2 + vx3) * (vx1 + vx2 + vx3) - cu_sq)); case DIR_MMM: - return REAL_CAST(vf::lbm::constant::c1o216 * (drho + 3.0 * (-vx1 - vx2 - vx3) + - vf::lbm::constant::c9o2 * (-vx1 - vx2 - vx3) * (-vx1 - vx2 - vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o216 * (drho + 3.0 * (-vx1 - vx2 - vx3) + + vf::basics::constant::c9o2 * (-vx1 - vx2 - vx3) * (-vx1 - vx2 - vx3) - cu_sq)); case DIR_PPM: - return REAL_CAST(vf::lbm::constant::c1o216 * (drho + 3.0 * (vx1 + vx2 - vx3) + - vf::lbm::constant::c9o2 * (vx1 + vx2 - vx3) * (vx1 + vx2 - vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o216 * (drho + 3.0 * (vx1 + vx2 - vx3) + + vf::basics::constant::c9o2 * (vx1 + vx2 - vx3) * (vx1 + vx2 - vx3) - cu_sq)); case DIR_MMP: - return REAL_CAST(vf::lbm::constant::c1o216 * (drho + 3.0 * (-vx1 - vx2 + vx3) + - vf::lbm::constant::c9o2 * (-vx1 - vx2 + vx3) * (-vx1 - vx2 + vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o216 * (drho + 3.0 * (-vx1 - vx2 + vx3) + + vf::basics::constant::c9o2 * (-vx1 - vx2 + vx3) * (-vx1 - vx2 + vx3) - cu_sq)); case DIR_PMP: - return REAL_CAST(vf::lbm::constant::c1o216 * (drho + 3.0 * (vx1 - vx2 + vx3) + - vf::lbm::constant::c9o2 * (vx1 - vx2 + vx3) * (vx1 - vx2 + vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o216 * (drho + 3.0 * (vx1 - vx2 + vx3) + + vf::basics::constant::c9o2 * (vx1 - vx2 + vx3) * (vx1 - vx2 + vx3) - cu_sq)); case DIR_MPM: - return REAL_CAST(vf::lbm::constant::c1o216 * (drho + 3.0 * (-vx1 + vx2 - vx3) + - vf::lbm::constant::c9o2 * (-vx1 + vx2 - vx3) * (-vx1 + vx2 - vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o216 * (drho + 3.0 * (-vx1 + vx2 - vx3) + + vf::basics::constant::c9o2 * (-vx1 + vx2 - vx3) * (-vx1 + vx2 - vx3) - cu_sq)); case DIR_PMM: - return REAL_CAST(vf::lbm::constant::c1o216 * (drho + 3.0 * (vx1 - vx2 - vx3) + - vf::lbm::constant::c9o2 * (vx1 - vx2 - vx3) * (vx1 - vx2 - vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o216 * (drho + 3.0 * (vx1 - vx2 - vx3) + + vf::basics::constant::c9o2 * (vx1 - vx2 - vx3) * (vx1 - vx2 - vx3) - cu_sq)); case DIR_MPP: - return REAL_CAST(vf::lbm::constant::c1o216 * (drho + 3.0 * (-vx1 + vx2 + vx3) + - vf::lbm::constant::c9o2 * (-vx1 + vx2 + vx3) * (-vx1 + vx2 + vx3) - cu_sq)); + return REAL_CAST(vf::basics::constant::c1o216 * (drho + 3.0 * (-vx1 + vx2 + vx3) + + vf::basics::constant::c9o2 * (-vx1 + vx2 + vx3) * (-vx1 + vx2 + vx3) - cu_sq)); default: throw UbException(UB_EXARGS, "unknown dir"); } @@ -759,41 +759,41 @@ static void calcIncompFeq(real *const &feq /*[27]*/, const real &drho, const rea real cu_sq = 1.5 * (vx1 * vx1 + vx2 * vx2 + vx3 * vx3); - feq[DIR_000] = vf::lbm::constant::c8o27 * (drho - cu_sq); - feq[DIR_P00] = vf::lbm::constant::c2o27 * (drho + 3.0 * (vx1) + vf::lbm::constant::c9o2 * (vx1) * (vx1)-cu_sq); - feq[DIR_M00] = vf::lbm::constant::c2o27 * (drho + 3.0 * (-vx1) + vf::lbm::constant::c9o2 * (-vx1) * (-vx1) - cu_sq); - feq[DIR_0P0] = vf::lbm::constant::c2o27 * (drho + 3.0 * (vx2) + vf::lbm::constant::c9o2 * (vx2) * (vx2)-cu_sq); - feq[DIR_0M0] = vf::lbm::constant::c2o27 * (drho + 3.0 * (-vx2) + vf::lbm::constant::c9o2 * (-vx2) * (-vx2) - cu_sq); - feq[DIR_00P] = vf::lbm::constant::c2o27 * (drho + 3.0 * (vx3) + vf::lbm::constant::c9o2 * (vx3) * (vx3)-cu_sq); - feq[DIR_00M] = vf::lbm::constant::c2o27 * (drho + 3.0 * (-vx3) + vf::lbm::constant::c9o2 * (-vx3) * (-vx3) - cu_sq); - feq[DIR_PP0] = vf::lbm::constant::c1o54 * (drho + 3.0 * (vx1 + vx2) + vf::lbm::constant::c9o2 * (vx1 + vx2) * (vx1 + vx2) - cu_sq); - feq[DIR_MM0] = vf::lbm::constant::c1o54 * (drho + 3.0 * (-vx1 - vx2) + vf::lbm::constant::c9o2 * (-vx1 - vx2) * (-vx1 - vx2) - cu_sq); - feq[DIR_PM0] = vf::lbm::constant::c1o54 * (drho + 3.0 * (vx1 - vx2) + vf::lbm::constant::c9o2 * (vx1 - vx2) * (vx1 - vx2) - cu_sq); - feq[DIR_MP0] = vf::lbm::constant::c1o54 * (drho + 3.0 * (-vx1 + vx2) + vf::lbm::constant::c9o2 * (-vx1 + vx2) * (-vx1 + vx2) - cu_sq); - feq[DIR_P0P] = vf::lbm::constant::c1o54 * (drho + 3.0 * (vx1 + vx3) + vf::lbm::constant::c9o2 * (vx1 + vx3) * (vx1 + vx3) - cu_sq); - feq[DIR_M0M] = vf::lbm::constant::c1o54 * (drho + 3.0 * (-vx1 - vx3) + vf::lbm::constant::c9o2 * (-vx1 - vx3) * (-vx1 - vx3) - cu_sq); - feq[DIR_P0M] = vf::lbm::constant::c1o54 * (drho + 3.0 * (vx1 - vx3) + vf::lbm::constant::c9o2 * (vx1 - vx3) * (vx1 - vx3) - cu_sq); - feq[DIR_M0P] = vf::lbm::constant::c1o54 * (drho + 3.0 * (-vx1 + vx3) + vf::lbm::constant::c9o2 * (-vx1 + vx3) * (-vx1 + vx3) - cu_sq); - feq[DIR_0PP] = vf::lbm::constant::c1o54 * (drho + 3.0 * (vx2 + vx3) + vf::lbm::constant::c9o2 * (vx2 + vx3) * (vx2 + vx3) - cu_sq); - feq[DIR_0MM] = vf::lbm::constant::c1o54 * (drho + 3.0 * (-vx2 - vx3) + vf::lbm::constant::c9o2 * (-vx2 - vx3) * (-vx2 - vx3) - cu_sq); - feq[DIR_0PM] = vf::lbm::constant::c1o54 * (drho + 3.0 * (vx2 - vx3) + vf::lbm::constant::c9o2 * (vx2 - vx3) * (vx2 - vx3) - cu_sq); - feq[DIR_0MP] = vf::lbm::constant::c1o54 * (drho + 3.0 * (-vx2 + vx3) + vf::lbm::constant::c9o2 * (-vx2 + vx3) * (-vx2 + vx3) - cu_sq); - feq[DIR_PPP] = vf::lbm::constant::c1o216 * - (drho + 3.0 * (vx1 + vx2 + vx3) + vf::lbm::constant::c9o2 * (vx1 + vx2 + vx3) * (vx1 + vx2 + vx3) - cu_sq); - feq[DIR_MMM] = vf::lbm::constant::c1o216 * - (drho + 3.0 * (-vx1 - vx2 - vx3) + vf::lbm::constant::c9o2 * (-vx1 - vx2 - vx3) * (-vx1 - vx2 - vx3) - cu_sq); - feq[DIR_PPM] = vf::lbm::constant::c1o216 * - (drho + 3.0 * (vx1 + vx2 - vx3) + vf::lbm::constant::c9o2 * (vx1 + vx2 - vx3) * (vx1 + vx2 - vx3) - cu_sq); - feq[DIR_MMP] = vf::lbm::constant::c1o216 * - (drho + 3.0 * (-vx1 - vx2 + vx3) + vf::lbm::constant::c9o2 * (-vx1 - vx2 + vx3) * (-vx1 - vx2 + vx3) - cu_sq); - feq[DIR_PMP] = vf::lbm::constant::c1o216 * - (drho + 3.0 * (vx1 - vx2 + vx3) + vf::lbm::constant::c9o2 * (vx1 - vx2 + vx3) * (vx1 - vx2 + vx3) - cu_sq); - feq[DIR_MPM] = vf::lbm::constant::c1o216 * - (drho + 3.0 * (-vx1 + vx2 - vx3) + vf::lbm::constant::c9o2 * (-vx1 + vx2 - vx3) * (-vx1 + vx2 - vx3) - cu_sq); - feq[DIR_PMM] = vf::lbm::constant::c1o216 * - (drho + 3.0 * (vx1 - vx2 - vx3) + vf::lbm::constant::c9o2 * (vx1 - vx2 - vx3) * (vx1 - vx2 - vx3) - cu_sq); - feq[DIR_MPP] = vf::lbm::constant::c1o216 * - (drho + 3.0 * (-vx1 + vx2 + vx3) + vf::lbm::constant::c9o2 * (-vx1 + vx2 + vx3) * (-vx1 + vx2 + vx3) - cu_sq); + feq[DIR_000] = vf::basics::constant::c8o27 * (drho - cu_sq); + feq[DIR_P00] = vf::basics::constant::c2o27 * (drho + 3.0 * (vx1) + vf::basics::constant::c9o2 * (vx1) * (vx1)-cu_sq); + feq[DIR_M00] = vf::basics::constant::c2o27 * (drho + 3.0 * (-vx1) + vf::basics::constant::c9o2 * (-vx1) * (-vx1) - cu_sq); + feq[DIR_0P0] = vf::basics::constant::c2o27 * (drho + 3.0 * (vx2) + vf::basics::constant::c9o2 * (vx2) * (vx2)-cu_sq); + feq[DIR_0M0] = vf::basics::constant::c2o27 * (drho + 3.0 * (-vx2) + vf::basics::constant::c9o2 * (-vx2) * (-vx2) - cu_sq); + feq[DIR_00P] = vf::basics::constant::c2o27 * (drho + 3.0 * (vx3) + vf::basics::constant::c9o2 * (vx3) * (vx3)-cu_sq); + feq[DIR_00M] = vf::basics::constant::c2o27 * (drho + 3.0 * (-vx3) + vf::basics::constant::c9o2 * (-vx3) * (-vx3) - cu_sq); + feq[DIR_PP0] = vf::basics::constant::c1o54 * (drho + 3.0 * (vx1 + vx2) + vf::basics::constant::c9o2 * (vx1 + vx2) * (vx1 + vx2) - cu_sq); + feq[DIR_MM0] = vf::basics::constant::c1o54 * (drho + 3.0 * (-vx1 - vx2) + vf::basics::constant::c9o2 * (-vx1 - vx2) * (-vx1 - vx2) - cu_sq); + feq[DIR_PM0] = vf::basics::constant::c1o54 * (drho + 3.0 * (vx1 - vx2) + vf::basics::constant::c9o2 * (vx1 - vx2) * (vx1 - vx2) - cu_sq); + feq[DIR_MP0] = vf::basics::constant::c1o54 * (drho + 3.0 * (-vx1 + vx2) + vf::basics::constant::c9o2 * (-vx1 + vx2) * (-vx1 + vx2) - cu_sq); + feq[DIR_P0P] = vf::basics::constant::c1o54 * (drho + 3.0 * (vx1 + vx3) + vf::basics::constant::c9o2 * (vx1 + vx3) * (vx1 + vx3) - cu_sq); + feq[DIR_M0M] = vf::basics::constant::c1o54 * (drho + 3.0 * (-vx1 - vx3) + vf::basics::constant::c9o2 * (-vx1 - vx3) * (-vx1 - vx3) - cu_sq); + feq[DIR_P0M] = vf::basics::constant::c1o54 * (drho + 3.0 * (vx1 - vx3) + vf::basics::constant::c9o2 * (vx1 - vx3) * (vx1 - vx3) - cu_sq); + feq[DIR_M0P] = vf::basics::constant::c1o54 * (drho + 3.0 * (-vx1 + vx3) + vf::basics::constant::c9o2 * (-vx1 + vx3) * (-vx1 + vx3) - cu_sq); + feq[DIR_0PP] = vf::basics::constant::c1o54 * (drho + 3.0 * (vx2 + vx3) + vf::basics::constant::c9o2 * (vx2 + vx3) * (vx2 + vx3) - cu_sq); + feq[DIR_0MM] = vf::basics::constant::c1o54 * (drho + 3.0 * (-vx2 - vx3) + vf::basics::constant::c9o2 * (-vx2 - vx3) * (-vx2 - vx3) - cu_sq); + feq[DIR_0PM] = vf::basics::constant::c1o54 * (drho + 3.0 * (vx2 - vx3) + vf::basics::constant::c9o2 * (vx2 - vx3) * (vx2 - vx3) - cu_sq); + feq[DIR_0MP] = vf::basics::constant::c1o54 * (drho + 3.0 * (-vx2 + vx3) + vf::basics::constant::c9o2 * (-vx2 + vx3) * (-vx2 + vx3) - cu_sq); + feq[DIR_PPP] = vf::basics::constant::c1o216 * + (drho + 3.0 * (vx1 + vx2 + vx3) + vf::basics::constant::c9o2 * (vx1 + vx2 + vx3) * (vx1 + vx2 + vx3) - cu_sq); + feq[DIR_MMM] = vf::basics::constant::c1o216 * + (drho + 3.0 * (-vx1 - vx2 - vx3) + vf::basics::constant::c9o2 * (-vx1 - vx2 - vx3) * (-vx1 - vx2 - vx3) - cu_sq); + feq[DIR_PPM] = vf::basics::constant::c1o216 * + (drho + 3.0 * (vx1 + vx2 - vx3) + vf::basics::constant::c9o2 * (vx1 + vx2 - vx3) * (vx1 + vx2 - vx3) - cu_sq); + feq[DIR_MMP] = vf::basics::constant::c1o216 * + (drho + 3.0 * (-vx1 - vx2 + vx3) + vf::basics::constant::c9o2 * (-vx1 - vx2 + vx3) * (-vx1 - vx2 + vx3) - cu_sq); + feq[DIR_PMP] = vf::basics::constant::c1o216 * + (drho + 3.0 * (vx1 - vx2 + vx3) + vf::basics::constant::c9o2 * (vx1 - vx2 + vx3) * (vx1 - vx2 + vx3) - cu_sq); + feq[DIR_MPM] = vf::basics::constant::c1o216 * + (drho + 3.0 * (-vx1 + vx2 - vx3) + vf::basics::constant::c9o2 * (-vx1 + vx2 - vx3) * (-vx1 + vx2 - vx3) - cu_sq); + feq[DIR_PMM] = vf::basics::constant::c1o216 * + (drho + 3.0 * (vx1 - vx2 - vx3) + vf::basics::constant::c9o2 * (vx1 - vx2 - vx3) * (vx1 - vx2 - vx3) - cu_sq); + feq[DIR_MPP] = vf::basics::constant::c1o216 * + (drho + 3.0 * (-vx1 + vx2 + vx3) + vf::basics::constant::c9o2 * (-vx1 + vx2 + vx3) * (-vx1 + vx2 + vx3) - cu_sq); } ////////////////////////////////////////////////////////////////////////// static inline real getBoundaryVelocityForDirection(const int &direction, const real &bcVelocityX1, @@ -803,57 +803,57 @@ static inline real getBoundaryVelocityForDirection(const int &direction, const r switch (direction) { case DIR_P00: - return (real)(vf::lbm::constant::c4o9 * (+bcVelocityX1)); + return (real)(vf::basics::constant::c4o9 * (+bcVelocityX1)); case DIR_M00: - return (real)(vf::lbm::constant::c4o9 * (-bcVelocityX1)); + return (real)(vf::basics::constant::c4o9 * (-bcVelocityX1)); case DIR_0P0: - return (real)(vf::lbm::constant::c4o9 * (+bcVelocityX2)); + return (real)(vf::basics::constant::c4o9 * (+bcVelocityX2)); case DIR_0M0: - return (real)(vf::lbm::constant::c4o9 * (-bcVelocityX2)); + return (real)(vf::basics::constant::c4o9 * (-bcVelocityX2)); case DIR_00P: - return (real)(vf::lbm::constant::c4o9 * (+bcVelocityX3)); + return (real)(vf::basics::constant::c4o9 * (+bcVelocityX3)); case DIR_00M: - return (real)(vf::lbm::constant::c4o9 * (-bcVelocityX3)); + return (real)(vf::basics::constant::c4o9 * (-bcVelocityX3)); case DIR_PP0: - return (real)(vf::lbm::constant::c1o9 * (+bcVelocityX1 + bcVelocityX2)); + return (real)(vf::basics::constant::c1o9 * (+bcVelocityX1 + bcVelocityX2)); case DIR_MM0: - return (real)(vf::lbm::constant::c1o9 * (-bcVelocityX1 - bcVelocityX2)); + return (real)(vf::basics::constant::c1o9 * (-bcVelocityX1 - bcVelocityX2)); case DIR_PM0: - return (real)(vf::lbm::constant::c1o9 * (+bcVelocityX1 - bcVelocityX2)); + return (real)(vf::basics::constant::c1o9 * (+bcVelocityX1 - bcVelocityX2)); case DIR_MP0: - return (real)(vf::lbm::constant::c1o9 * (-bcVelocityX1 + bcVelocityX2)); + return (real)(vf::basics::constant::c1o9 * (-bcVelocityX1 + bcVelocityX2)); case DIR_P0P: - return (real)(vf::lbm::constant::c1o9 * (+bcVelocityX1 + bcVelocityX3)); + return (real)(vf::basics::constant::c1o9 * (+bcVelocityX1 + bcVelocityX3)); case DIR_M0M: - return (real)(vf::lbm::constant::c1o9 * (-bcVelocityX1 - bcVelocityX3)); + return (real)(vf::basics::constant::c1o9 * (-bcVelocityX1 - bcVelocityX3)); case DIR_P0M: - return (real)(vf::lbm::constant::c1o9 * (+bcVelocityX1 - bcVelocityX3)); + return (real)(vf::basics::constant::c1o9 * (+bcVelocityX1 - bcVelocityX3)); case DIR_M0P: - return (real)(vf::lbm::constant::c1o9 * (-bcVelocityX1 + bcVelocityX3)); + return (real)(vf::basics::constant::c1o9 * (-bcVelocityX1 + bcVelocityX3)); case DIR_0PP: - return (real)(vf::lbm::constant::c1o9 * (+bcVelocityX2 + bcVelocityX3)); + return (real)(vf::basics::constant::c1o9 * (+bcVelocityX2 + bcVelocityX3)); case DIR_0MM: - return (real)(vf::lbm::constant::c1o9 * (-bcVelocityX2 - bcVelocityX3)); + return (real)(vf::basics::constant::c1o9 * (-bcVelocityX2 - bcVelocityX3)); case DIR_0PM: - return (real)(vf::lbm::constant::c1o9 * (+bcVelocityX2 - bcVelocityX3)); + return (real)(vf::basics::constant::c1o9 * (+bcVelocityX2 - bcVelocityX3)); case DIR_0MP: - return (real)(vf::lbm::constant::c1o9 * (-bcVelocityX2 + bcVelocityX3)); + return (real)(vf::basics::constant::c1o9 * (-bcVelocityX2 + bcVelocityX3)); case DIR_PPP: - return (real)(vf::lbm::constant::c1o36 * (+bcVelocityX1 + bcVelocityX2 + bcVelocityX3)); + return (real)(vf::basics::constant::c1o36 * (+bcVelocityX1 + bcVelocityX2 + bcVelocityX3)); case DIR_MMM: - return (real)(vf::lbm::constant::c1o36 * (-bcVelocityX1 - bcVelocityX2 - bcVelocityX3)); + return (real)(vf::basics::constant::c1o36 * (-bcVelocityX1 - bcVelocityX2 - bcVelocityX3)); case DIR_PPM: - return (real)(vf::lbm::constant::c1o36 * (+bcVelocityX1 + bcVelocityX2 - bcVelocityX3)); + return (real)(vf::basics::constant::c1o36 * (+bcVelocityX1 + bcVelocityX2 - bcVelocityX3)); case DIR_MMP: - return (real)(vf::lbm::constant::c1o36 * (-bcVelocityX1 - bcVelocityX2 + bcVelocityX3)); + return (real)(vf::basics::constant::c1o36 * (-bcVelocityX1 - bcVelocityX2 + bcVelocityX3)); case DIR_PMP: - return (real)(vf::lbm::constant::c1o36 * (+bcVelocityX1 - bcVelocityX2 + bcVelocityX3)); + return (real)(vf::basics::constant::c1o36 * (+bcVelocityX1 - bcVelocityX2 + bcVelocityX3)); case DIR_MPM: - return (real)(vf::lbm::constant::c1o36 * (-bcVelocityX1 + bcVelocityX2 - bcVelocityX3)); + return (real)(vf::basics::constant::c1o36 * (-bcVelocityX1 + bcVelocityX2 - bcVelocityX3)); case DIR_PMM: - return (real)(vf::lbm::constant::c1o36 * (+bcVelocityX1 - bcVelocityX2 - bcVelocityX3)); + return (real)(vf::basics::constant::c1o36 * (+bcVelocityX1 - bcVelocityX2 - bcVelocityX3)); case DIR_MPP: - return (real)(vf::lbm::constant::c1o36 * (-bcVelocityX1 + bcVelocityX2 + bcVelocityX3)); + return (real)(vf::basics::constant::c1o36 * (-bcVelocityX1 + bcVelocityX2 + bcVelocityX3)); default: throw UbException(UB_EXARGS, "unknown direction"); } @@ -914,11 +914,11 @@ static inline void calcDistanceToNeighbors(std::vector<real> &distNeigh, const r distNeigh[DIR_P00] = distNeigh[DIR_M00] = distNeigh[DIR_0P0] = deltaX1; distNeigh[DIR_0M0] = distNeigh[DIR_00P] = distNeigh[DIR_00M] = deltaX1; - distNeigh[DIR_PP0] = distNeigh[DIR_MP0] = distNeigh[DIR_MM0] = distNeigh[DIR_PM0] = vf::lbm::constant::sqrt2 * deltaX1; - distNeigh[DIR_P0P] = distNeigh[DIR_0PP] = distNeigh[DIR_M0P] = distNeigh[DIR_0MP] = vf::lbm::constant::sqrt2 * deltaX1; - distNeigh[DIR_P0M] = distNeigh[DIR_0PM] = distNeigh[DIR_M0M] = distNeigh[DIR_0MM] = vf::lbm::constant::sqrt2 * deltaX1; - distNeigh[DIR_PPP] = distNeigh[DIR_MPP] = distNeigh[DIR_PMP] = distNeigh[DIR_MMP] = vf::lbm::constant::sqrt3 * deltaX1; - distNeigh[DIR_PPM] = distNeigh[DIR_MPM] = distNeigh[DIR_PMM] = distNeigh[DIR_MMM] = vf::lbm::constant::sqrt3 * deltaX1; + distNeigh[DIR_PP0] = distNeigh[DIR_MP0] = distNeigh[DIR_MM0] = distNeigh[DIR_PM0] = vf::basics::constant::sqrt2 * deltaX1; + distNeigh[DIR_P0P] = distNeigh[DIR_0PP] = distNeigh[DIR_M0P] = distNeigh[DIR_0MP] = vf::basics::constant::sqrt2 * deltaX1; + distNeigh[DIR_P0M] = distNeigh[DIR_0PM] = distNeigh[DIR_M0M] = distNeigh[DIR_0MM] = vf::basics::constant::sqrt2 * deltaX1; + distNeigh[DIR_PPP] = distNeigh[DIR_MPP] = distNeigh[DIR_PMP] = distNeigh[DIR_MMP] = vf::basics::constant::sqrt3 * deltaX1; + distNeigh[DIR_PPM] = distNeigh[DIR_MPM] = distNeigh[DIR_PMM] = distNeigh[DIR_MMM] = vf::basics::constant::sqrt3 * deltaX1; } ////////////////////////////////////////////////////////////////////////// static inline void calcDistanceToNeighbors(std::vector<real> &distNeigh, const real &deltaX1, const real &deltaX2, @@ -944,8 +944,8 @@ static inline void initRayVectors(real *const &rayX1, real *const &rayX2, real * using namespace vf::lbm::dir; int fdir; - real c1oS2 = vf::lbm::constant::one_over_sqrt2; - real c1oS3 = vf::lbm::constant::one_over_sqrt3; + real c1oS2 = vf::basics::constant::one_over_sqrt2; + real c1oS3 = vf::basics::constant::one_over_sqrt3; fdir = DIR_P00; rayX1[fdir] = 1.0; rayX2[fdir] = 0.0; @@ -1063,7 +1063,7 @@ static inline real calcPress(const real *const f, real rho, real vx1, real vx2, (vx1 * vx1 + vx2 * vx2 + vx3 * vx3)) * (1 - 0.5 * op) + op * 0.5 * (rho)) * - vf::lbm::constant::c1o3; + vf::basics::constant::c1o3; } ////////////////////////////////////////////////////////////////////////// static inline real getShearRate(const real *const f, real collFactorF) @@ -1157,7 +1157,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfaac - mfaaa; m0 = m2 + mfaab; mfaaa = m0; - m0 += vf::lbm::constant::c1o36 * oMdrho; + m0 += vf::basics::constant::c1o36 * oMdrho; mfaab = m1 - m0 * vvz; mfaac = m2 - 2. * m1 * vvz + vz2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1165,7 +1165,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfabc - mfaba; m0 = m2 + mfabb; mfaba = m0; - m0 += vf::lbm::constant::c1o9 * oMdrho; + m0 += vf::basics::constant::c1o9 * oMdrho; mfabb = m1 - m0 * vvz; mfabc = m2 - 2. * m1 * vvz + vz2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1173,7 +1173,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfacc - mfaca; m0 = m2 + mfacb; mfaca = m0; - m0 += vf::lbm::constant::c1o36 * oMdrho; + m0 += vf::basics::constant::c1o36 * oMdrho; mfacb = m1 - m0 * vvz; mfacc = m2 - 2. * m1 * vvz + vz2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1182,7 +1182,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfbac - mfbaa; m0 = m2 + mfbab; mfbaa = m0; - m0 += vf::lbm::constant::c1o9 * oMdrho; + m0 += vf::basics::constant::c1o9 * oMdrho; mfbab = m1 - m0 * vvz; mfbac = m2 - 2. * m1 * vvz + vz2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1190,7 +1190,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfbbc - mfbba; m0 = m2 + mfbbb; mfbba = m0; - m0 += vf::lbm::constant::c4o9 * oMdrho; + m0 += vf::basics::constant::c4o9 * oMdrho; mfbbb = m1 - m0 * vvz; mfbbc = m2 - 2. * m1 * vvz + vz2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1198,7 +1198,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfbcc - mfbca; m0 = m2 + mfbcb; mfbca = m0; - m0 += vf::lbm::constant::c1o9 * oMdrho; + m0 += vf::basics::constant::c1o9 * oMdrho; mfbcb = m1 - m0 * vvz; mfbcc = m2 - 2. * m1 * vvz + vz2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1207,7 +1207,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfcac - mfcaa; m0 = m2 + mfcab; mfcaa = m0; - m0 += vf::lbm::constant::c1o36 * oMdrho; + m0 += vf::basics::constant::c1o36 * oMdrho; mfcab = m1 - m0 * vvz; mfcac = m2 - 2. * m1 * vvz + vz2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1215,7 +1215,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfcbc - mfcba; m0 = m2 + mfcbb; mfcba = m0; - m0 += vf::lbm::constant::c1o9 * oMdrho; + m0 += vf::basics::constant::c1o9 * oMdrho; mfcbb = m1 - m0 * vvz; mfcbc = m2 - 2. * m1 * vvz + vz2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1223,7 +1223,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfccc - mfcca; m0 = m2 + mfccb; mfcca = m0; - m0 += vf::lbm::constant::c1o36 * oMdrho; + m0 += vf::basics::constant::c1o36 * oMdrho; mfccb = m1 - m0 * vvz; mfccc = m2 - 2. * m1 * vvz + vz2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1235,7 +1235,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfaca - mfaaa; m0 = m2 + mfaba; mfaaa = m0; - m0 += vf::lbm::constant::c1o6 * oMdrho; + m0 += vf::basics::constant::c1o6 * oMdrho; mfaba = m1 - m0 * vvy; mfaca = m2 - 2. * m1 * vvy + vy2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1250,7 +1250,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfacc - mfaac; m0 = m2 + mfabc; mfaac = m0; - m0 += vf::lbm::constant::c1o18 * oMdrho; + m0 += vf::basics::constant::c1o18 * oMdrho; mfabc = m1 - m0 * vvy; mfacc = m2 - 2. * m1 * vvy + vy2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1259,7 +1259,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfbca - mfbaa; m0 = m2 + mfbba; mfbaa = m0; - m0 += vf::lbm::constant::c2o3 * oMdrho; + m0 += vf::basics::constant::c2o3 * oMdrho; mfbba = m1 - m0 * vvy; mfbca = m2 - 2. * m1 * vvy + vy2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1274,7 +1274,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfbcc - mfbac; m0 = m2 + mfbbc; mfbac = m0; - m0 += vf::lbm::constant::c2o9 * oMdrho; + m0 += vf::basics::constant::c2o9 * oMdrho; mfbbc = m1 - m0 * vvy; mfbcc = m2 - 2. * m1 * vvy + vy2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1283,7 +1283,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfcca - mfcaa; m0 = m2 + mfcba; mfcaa = m0; - m0 += vf::lbm::constant::c1o6 * oMdrho; + m0 += vf::basics::constant::c1o6 * oMdrho; mfcba = m1 - m0 * vvy; mfcca = m2 - 2. * m1 * vvy + vy2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1298,7 +1298,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfccc - mfcac; m0 = m2 + mfcbc; mfcac = m0; - m0 += vf::lbm::constant::c1o18 * oMdrho; + m0 += vf::basics::constant::c1o18 * oMdrho; mfcbc = m1 - m0 * vvy; mfccc = m2 - 2. * m1 * vvy + vy2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1325,7 +1325,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfcca - mfaca; m0 = m2 + mfbca; mfaca = m0; - m0 += vf::lbm::constant::c1o3 * oMdrho; + m0 += vf::basics::constant::c1o3 * oMdrho; mfbca = m1 - m0 * vvx; mfcca = m2 - 2. * m1 * vvx + vx2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1356,7 +1356,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfcac - mfaac; m0 = m2 + mfbac; mfaac = m0; - m0 += vf::lbm::constant::c1o3 * oMdrho; + m0 += vf::basics::constant::c1o3 * oMdrho; mfbac = m1 - m0 * vvx; mfcac = m2 - 2. * m1 * vvx + vx2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1371,7 +1371,7 @@ static inline real getShearRate(const real *const f, real collFactorF) m1 = mfccc - mfacc; m0 = m2 + mfbcc; mfacc = m0; - m0 += vf::lbm::constant::c1o9 * oMdrho; + m0 += vf::basics::constant::c1o9 * oMdrho; mfbcc = m1 - m0 * vvx; mfccc = m2 - 2. * m1 * vvx + vx2 * m0; //////////////////////////////////////////////////////////////////////////////////// @@ -1383,16 +1383,16 @@ static inline real getShearRate(const real *const f, real collFactorF) real mxxMyy = mfcaa - mfaca; real mxxMzz = mfcaa - mfaac; - real dxux = -vf::lbm::constant::c1o2 * collFactorF * (mxxMyy + mxxMzz) + vf::lbm::constant::c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); - real dyuy = dxux + collFactorF * vf::lbm::constant::c3o2 * mxxMyy; - real dzuz = dxux + collFactorF * vf::lbm::constant::c3o2 * mxxMzz; + real dxux = -vf::basics::constant::c1o2 * collFactorF * (mxxMyy + mxxMzz) + vf::basics::constant::c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); + real dyuy = dxux + collFactorF * vf::basics::constant::c3o2 * mxxMyy; + real dzuz = dxux + collFactorF * vf::basics::constant::c3o2 * mxxMzz; - real Dxy = -vf::lbm::constant::c3o1 * collFactorF * mfbba; - real Dxz = -vf::lbm::constant::c3o1 * collFactorF * mfbab; - real Dyz = -vf::lbm::constant::c3o1 * collFactorF * mfabb; + real Dxy = -vf::basics::constant::c3o1 * collFactorF * mfbba; + real Dxz = -vf::basics::constant::c3o1 * collFactorF * mfbab; + real Dyz = -vf::basics::constant::c3o1 * collFactorF * mfabb; - return sqrt(vf::lbm::constant::c2o1 * (dxux * dxux + dyuy * dyuy + dzuz * dzuz) + Dxy * Dxy + Dxz * Dxz + Dyz * Dyz) / - (rho + vf::lbm::constant::c1o1); + return sqrt(vf::basics::constant::c2o1 * (dxux * dxux + dyuy * dyuy + dzuz * dzuz) + Dxy * Dxy + Dxz * Dxz + Dyz * Dyz) / + (rho + vf::basics::constant::c1o1); } static inline std::array<real,6> getSecondMoments(const real *const f, real collFactorF) @@ -2057,7 +2057,7 @@ static void calcMultiphaseFeq(real *const &feq /*[27]*/, const real &rho, const { using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real cu_sq = 1.5 * (vx1 * vx1 + vx2 * vx2 + vx3 * vx3); feq[DIR_000] = c8o27 * (p1 + rho * c1o3 * (-cu_sq)); @@ -2102,7 +2102,7 @@ static void calcMultiphaseFeqVB(real *const &feq /*[27]*/, const real &p1, const { using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real cu_sq = 1.5 * (vx1 * vx1 + vx2 * vx2 + vx3 * vx3); feq[DIR_000] = p1 + c8o27 * (-cu_sq); @@ -2138,7 +2138,7 @@ static void calcMultiphaseHeq(real *const &heq /*[27]*/, const real &phi, const const real &vx3) { using namespace vf::lbm::dir; - using namespace vf::lbm::constant; + using namespace vf::basics::constant; real cu_sq = 1.5 * (vx1 * vx1 + vx2 * vx2 + vx3 * vx3); diff --git a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp index 23ea001f3d754f274d103b8c4f13458506705654..990bb8f89f4b6abb1a0e77b550af4d751ad49a40 100644 --- a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp @@ -9,7 +9,7 @@ #define PROOF_CORRECTNESS //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; ////////////////////////////////////////////////////////////////////////// IncompressibleCumulantLBMKernel::IncompressibleCumulantLBMKernel() diff --git a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp index ec4d2a5a89ea066c7aa89d8632fb305f7dcdc10e..0ac578d90615b0ab0ba4989b6b70d680eb0e8c44 100644 --- a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp @@ -9,7 +9,7 @@ #define PROOF_CORRECTNESS //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; ////////////////////////////////////////////////////////////////////////// IncompressibleCumulantWithSpongeLayerLBMKernel::IncompressibleCumulantWithSpongeLayerLBMKernel() diff --git a/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp index 49d66b39ccd887516f2be1caa78df0349b01b883..bf68b4d43930eb431b6cb23f0647266225298165 100644 --- a/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp @@ -3,10 +3,10 @@ #include "BCSet.h" #include "DataSet3D.h" #include "BCArray3D.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" //using namespace UbMath; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; InitDensityLBMKernel::InitDensityLBMKernel() { diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.cpp b/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.cpp index d0c914707688ebf7c2abd839f8e1c698d33d947c..318b8cc037581a2239d0a1a487d70afdcd2d8685 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.cpp @@ -5,9 +5,9 @@ #include "DataSet3D.h" #include "BCSet.h" #include "BCArray3D.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; //using namespace UbMath; //#define PROOF_CORRECTNESS diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h b/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h index 14b4d223b2e07e3dbca9947cefd89de045bfb3cf..5cea71cd2054cc6755266e1b0b9b314ea06cb476 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h +++ b/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h @@ -37,7 +37,7 @@ #include <iostream> #include <string> -#include "basics/Core/DataTypes.h" +#include "basics/DataTypes.h" //! \brief namespace for global system-functions diff --git a/src/cpu/pythonbindings/CMakeLists.txt b/src/cpu/pythonbindings/CMakeLists.txt deleted file mode 100644 index 3b4e7e5a1506899710dc03ea275c0d4ac1cff66d..0000000000000000000000000000000000000000 --- a/src/cpu/pythonbindings/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -project(VirtualFluidsPython) - -pybind11_add_module(pyfluids src/VirtualfluidsModule.cpp) -pybind11_add_module(pymuparser src/muParser.cpp) - -# TODO: Move this to MuParser CMakeLists.txt -set_target_properties(muparser PROPERTIES POSITION_INDEPENDENT_CODE ON) - -target_compile_definitions(pyfluids PRIVATE VF_METIS VF_MPI) -target_compile_definitions(pymuparser PRIVATE VF_METIS VF_MPI) - -target_link_libraries(pyfluids PRIVATE simulationconfig VirtualFluidsCore muparser basics) -target_link_libraries(pymuparser PRIVATE muparser) - -target_include_directories(pyfluids PRIVATE ${CMAKE_SOURCE_DIR}/src/) -target_include_directories(pyfluids PRIVATE ${CMAKE_BINARY_DIR}) \ No newline at end of file diff --git a/src/cpu/pythonbindings/src/VirtualfluidsModule.cpp b/src/cpu/pythonbindings/src/VirtualfluidsModule.cpp deleted file mode 100644 index 564dc1838d48a92340fa5491779177b299bcb270..0000000000000000000000000000000000000000 --- a/src/cpu/pythonbindings/src/VirtualfluidsModule.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include <pybind11/pybind11.h> -#include "submodules/boundaryconditions.cpp" -#include "submodules/simulationconfig.cpp" -#include "submodules/geometry.cpp" -#include "submodules/kernel.cpp" -#include "submodules/simulationparameters.cpp" -#include "submodules/writer.cpp" - -namespace py_bindings -{ - namespace py = pybind11; - - PYBIND11_MODULE(pyfluids, m) - { - boundaryconditions::makeModule(m); - simulation::makeModule(m); - geometry::makeModule(m); - kernel::makeModule(m); - parameters::makeModule(m); - writer::makeModule(m); - } -} \ No newline at end of file diff --git a/src/cpu/pythonbindings/src/submodules/boundaryconditions.cpp b/src/cpu/pythonbindings/src/submodules/boundaryconditions.cpp deleted file mode 100644 index 3bff7bc069ca20fe1c0cf3d1847b9714e0381505..0000000000000000000000000000000000000000 --- a/src/cpu/pythonbindings/src/submodules/boundaryconditions.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> -#include <BoundaryConditions/DensityBCAdapter.h> -#include <BoundaryConditions/NonReflectingOutflowBCAlgorithm.h> -#include <BoundaryConditions/BCAdapter.h> -#include <BoundaryConditions/NoSlipBCAdapter.h> -#include <BoundaryConditions/VelocityBCAdapter.h> -#include <BoundaryConditions/NoSlipBCAlgorithm.h> -#include <BoundaryConditions/VelocityBCAlgorithm.h> -#include <BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h> - -namespace boundaryconditions -{ - namespace py = pybind11; - using namespace py::literals; - - template<class adapter, class algorithm, - class = std::enable_if_t<std::is_base_of<BCAdapter, adapter>::value>, - class = std::enable_if_t<std::is_base_of<BCAlgorithm, algorithm>::value>> - class PyBoundaryCondition : public adapter - { - public: - template<typename ...Args> - PyBoundaryCondition(Args &&... args) : adapter(std::forward<Args>(args)...) - { - this->setBcAlgorithm(std::make_shared<algorithm>()); - } - }; - - template<class adapter, class algorithm> - using bc_class = py::class_<PyBoundaryCondition<adapter, algorithm>, BCAdapter, - std::shared_ptr<PyBoundaryCondition<adapter, algorithm>>>; - - void makeModule(py::module_ &parentModule) - { - py::module_ bcModule = parentModule.def_submodule("boundaryconditions"); - - auto _ = py::class_<BCAdapter, std::shared_ptr<BCAdapter>>(bcModule, "BCAdapter"); - - bc_class<NoSlipBCAdapter, NoSlipBCAlgorithm>(bcModule, "NoSlipBoundaryCondition") - .def(py::init()); - - bc_class<NoSlipBCAdapter, HighViscosityNoSlipBCAlgorithm>(bcModule, "HighViscosityNoSlipBoundaryCondition") - .def(py::init()); - - bc_class<VelocityBCAdapter, VelocityBCAlgorithm>(bcModule, "VelocityBoundaryCondition") - .def(py::init()) - .def(py::init<bool &, bool &, bool &, mu::Parser &, double &, double &>(), - "vx1"_a, "vx2"_a, "vx3"_a, - "function"_a, "start_time"_a, "end_time"_a) - .def(py::init<bool &, bool &, bool &, mu::Parser &, mu::Parser &, mu::Parser &, double &, double &>(), - "vx1"_a, "vx2"_a, "vx3"_a, - "function_vx1"_a, "function_vx2"_a, "function_vx2"_a, - "start_time"_a, "end_time"_a) - .def(py::init<double &, double &, double &, double &, double &, double &, double &, double &, double &>(), - "vx1"_a, "vx1_start_time"_a, "vx1_end_time"_a, - "vx2"_a, "vx2_start_time"_a, "vx2_end_time"_a, - "vx3"_a, "vx3_start_time"_a, "vx3_end_time"_a); - - bc_class<DensityBCAdapter, NonReflectingOutflowBCAlgorithm>(bcModule, "NonReflectingOutflow") - .def(py::init()); - } - -} \ No newline at end of file diff --git a/src/cpu/pythonbindings/src/submodules/geometry.cpp b/src/cpu/pythonbindings/src/submodules/geometry.cpp deleted file mode 100644 index b7ff4dd761258d41687589d2dd89c3479093753e..0000000000000000000000000000000000000000 --- a/src/cpu/pythonbindings/src/submodules/geometry.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include <pybind11/pybind11.h> -#include <geometry3d/GbPoint3D.h> -#include <geometry3d/GbObject3D.h> -#include <geometry3d/GbCuboid3D.h> -#include <geometry3d/GbLine3D.h> -#include <Interactors/Interactor3D.h> - - -namespace geometry -{ - namespace py = pybind11; - - template<class GeoObject> - using py_geometry = py::class_<GeoObject, GbObject3D, std::shared_ptr<GeoObject>>; - - std::string GbPoint3D_repr_(const GbPoint3D &instance) - { - std::ostringstream stream; - stream << "<GbPoint3D" - << " x1: " << instance.getX1Coordinate() - << " x2: " << instance.getX2Coordinate() - << " x3: " << instance.getX3Coordinate() << ">"; - - return stream.str(); - } - - void makeModule(py::module_ &parentModule) - { - py::module geometry = parentModule.def_submodule("geometry"); - - py::class_<GbObject3D, std::shared_ptr<GbObject3D>>(geometry, "GbObject3D"); - - py_geometry<GbPoint3D>(geometry, "GbPoint3D") - .def(py::init()) - .def(py::init<double &, double &, double &>()) - .def(py::init<GbPoint3D *>()) - .def_property("x1", &GbPoint3D::getX1Coordinate, &GbPoint3D::setX1) - .def_property("x2", &GbPoint3D::getX2Coordinate, &GbPoint3D::setX2) - .def_property("x3", &GbPoint3D::getX3Coordinate, &GbPoint3D::setX3) - .def("get_distance", &GbPoint3D::getDistance) - .def("__repr__", &GbPoint3D_repr_); - - py_geometry<GbCuboid3D>(geometry, "GbCuboid3D") - .def(py::init()) - .def(py::init<double &, double &, double &, double &, double &, double &>()) - .def(py::init<GbPoint3D *, GbPoint3D *>()) - .def(py::init<GbCuboid3D *>()) - .def_property("point1", &GbCuboid3D::getPoint1, &GbCuboid3D::setPoint1) - .def_property("point2", &GbCuboid3D::getPoint2, &GbCuboid3D::setPoint2) - .def("__repr__", [&](GbCuboid3D &instance) - { - std::ostringstream stream; - stream << "<GbCuboid3D" << std::endl - << "point1: " << GbPoint3D_repr_(instance.getPoint1()) << std::endl - << "point2: " << GbPoint3D_repr_(instance.getPoint2()) << ">"; - return stream.str(); - }); - - py_geometry<GbLine3D>(geometry, "GbLine3D") - .def(py::init()) - .def(py::init<GbPoint3D *, GbPoint3D *>()) - .def(py::init<GbLine3D>()) - .def_property("point1", &GbLine3D::getPoint1, &GbLine3D::setPoint1) - .def_property("point2", &GbLine3D::getPoint2, &GbLine3D::setPoint2) - .def("__repr__", [&](GbLine3D &instance) - { - std::ostringstream stream; - stream << "<GbLine3D" << std::endl - << "point1: " << GbPoint3D_repr_(instance.getPoint1()) << std::endl - << "point2: " << GbPoint3D_repr_(instance.getPoint2()) << ">"; - return stream.str(); - }); - - - py::class_<Interactor3D, std::shared_ptr<Interactor3D>>(geometry, "State") - .def_readonly_static("SOLID", &Interactor3D::SOLID) - .def_readonly_static("INVERSESOLID", &Interactor3D::INVERSESOLID) - .def_readonly_static("TIMEDEPENDENT", &Interactor3D::TIMEDEPENDENT) - .def_readonly_static("FLUID", &Interactor3D::FLUID) - .def_readonly_static("MOVEABLE", &Interactor3D::MOVEABLE) - .def_readonly_static("CHANGENOTNECESSARY", &Interactor3D::CHANGENOTNECESSARY); - } - -} \ No newline at end of file diff --git a/src/cpu/pythonbindings/src/submodules/kernel.cpp b/src/cpu/pythonbindings/src/submodules/kernel.cpp deleted file mode 100644 index fb291790632cc2041410f60a14fca8d966283343..0000000000000000000000000000000000000000 --- a/src/cpu/pythonbindings/src/submodules/kernel.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include <memory> -#include <pybind11/pybind11.h> -#include <simulationconfig/KernelFactory.h> -#include <simulationconfig/KernelConfigStructs.h> - -namespace kernel -{ - namespace py = pybind11; - - void makeModule(py::module_ &parentModule) - { - py::module kernelModule = parentModule.def_submodule("kernel"); - - py::enum_<KernelFactory::KernelType>(kernelModule, "KernelType") - .value("BGK", KernelFactory::BGK) - .value("CompressibleCumulantFourthOrderViscosity", - KernelFactory::COMPRESSIBLE_CUMULANT_4TH_ORDER_VISCOSITY); - - py::class_<LBMKernelConfiguration, std::shared_ptr<LBMKernelConfiguration>>(kernelModule, "LBMKernel") - .def(py::init<KernelFactory::KernelType>()) - .def_readwrite("type", &LBMKernelConfiguration::kernelType) - .def_readwrite("use_forcing", &LBMKernelConfiguration::useForcing) - .def_readwrite("forcing_in_x1", &LBMKernelConfiguration::forcingX1) - .def_readwrite("forcing_in_x2", &LBMKernelConfiguration::forcingX2) - .def_readwrite("forcing_in_x3", &LBMKernelConfiguration::forcingX3) - .def("set_forcing", [](LBMKernelConfiguration &kernelConfig, double x1, double x2, double x3) - { - kernelConfig.forcingX1 = x1; - kernelConfig.forcingX2 = x2; - kernelConfig.forcingX3 = x3; - }) - .def("__repr__", [](LBMKernelConfiguration &kernelConfig) - { - std::ostringstream stream; - stream << "<" << kernelConfig.kernelType << std::endl - << "Use forcing: " << kernelConfig.useForcing << std::endl - << "Forcing in x1: " << kernelConfig.forcingX1 << std::endl - << "Forcing in x2: " << kernelConfig.forcingX2 << std::endl - << "Forcing in x3: " << kernelConfig.forcingX3 << ">" << std::endl; - - return stream.str(); - }); - } - -} \ No newline at end of file diff --git a/src/cpu/pythonbindings/src/submodules/simulationconfig.cpp b/src/cpu/pythonbindings/src/submodules/simulationconfig.cpp deleted file mode 100644 index 60af4e36af4dca67e9262dd9f5ee1f46d5b7bb58..0000000000000000000000000000000000000000 --- a/src/cpu/pythonbindings/src/submodules/simulationconfig.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include <pybind11/pybind11.h> -#include <simulationconfig/Simulation.h> - -namespace simulation -{ - namespace py = pybind11; - - void makeModule(py::module_ &parentModule) - { - py::class_<Simulation, std::shared_ptr<Simulation>>(parentModule, "Simulation") - .def(py::init()) - .def("set_writer", &Simulation::setWriterConfiguration) - .def("set_grid_parameters", &Simulation::setGridParameters) - .def("set_physical_parameters", &Simulation::setPhysicalParameters) - .def("set_runtime_parameters", &Simulation::setRuntimeParameters) - .def("set_kernel_config", &Simulation::setKernelConfiguration) - .def("add_object", &Simulation::addObject) - .def("add_bc_adapter", &Simulation::addBCAdapter) - .def("run_simulation", &Simulation::run); - } - -} \ No newline at end of file diff --git a/src/cpu/pythonbindings/src/submodules/simulationparameters.cpp b/src/cpu/pythonbindings/src/submodules/simulationparameters.cpp deleted file mode 100644 index acc272f2ee412cfbafd9007b4b18610cfd0a1e9b..0000000000000000000000000000000000000000 --- a/src/cpu/pythonbindings/src/submodules/simulationparameters.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> -#include <complex> -#include <simulationconfig/SimulationParameters.h> - -namespace parameters -{ - namespace py = pybind11; - - void makeModule(py::module_ &parentModule) - { - py::module parametersModule = parentModule.def_submodule("parameters"); - - py::class_<PhysicalParameters, std::shared_ptr<PhysicalParameters>>(parametersModule, "PhysicalParameters") - .def(py::init()) - .def_readwrite("bulk_viscosity_factor", &PhysicalParameters::bulkViscosityFactor, - "The viscosity of the fluid will be multiplied with this factor to calculate its bulk viscosity. Default is 1.0") - .def_readwrite("lattice_viscosity", &PhysicalParameters::latticeViscosity, "Lattice viscosity"); - - py::class_<GridParameters, std::shared_ptr<GridParameters>>(parametersModule, "GridParameters") - .def(py::init()) - .def_readwrite("node_distance", &GridParameters::nodeDistance) - .def_readwrite("reference_direction_index", &GridParameters::referenceDirectionIndex) - .def_readwrite("number_of_nodes_per_direction", &GridParameters::numberOfNodesPerDirection) - .def_readwrite("blocks_per_direction", &GridParameters::blocksPerDirection) - .def_readwrite("periodic_boundary_in_x1", &GridParameters::periodicBoundaryInX1) - .def_readwrite("periodic_boundary_in_x2", &GridParameters::periodicBoundaryInX2) - .def_readwrite("periodic_boundary_in_x3", &GridParameters::periodicBoundaryInX3) - .def_property_readonly("bounding_box", &GridParameters::boundingBox); - - py::class_<BoundingBox, std::shared_ptr<BoundingBox>>(parametersModule, "BoundingBox") - .def_readonly("min_x1", &BoundingBox::minX1) - .def_readonly("min_x2", &BoundingBox::minX2) - .def_readonly("min_x3", &BoundingBox::minX3) - .def_readonly("max_x1", &BoundingBox::maxX1) - .def_readonly("max_x2", &BoundingBox::maxX2) - .def_readonly("max_x3", &BoundingBox::maxX3) - .def("__repr__", [](BoundingBox &self) - { - std::ostringstream stream; - stream << "<BoundingBox" << std::endl - << "min x1: " << self.minX1 << std::endl - << "min x2: " << self.minX2 << std::endl - << "min x3: " << self.minX3 << std::endl - << "max x1: " << self.maxX1 << std::endl - << "max x2: " << self.maxX2 << std::endl - << "max x3: " << self.maxX3 << std::endl << ">"; - - return stream.str(); - }); - - py::class_<RuntimeParameters, std::shared_ptr<RuntimeParameters>>(parametersModule, "RuntimeParameters") - .def(py::init()) - .def_readwrite("number_of_timesteps", &RuntimeParameters::numberOfTimeSteps) - .def_readwrite("timestep_log_interval", &RuntimeParameters::timeStepLogInterval) - .def_readwrite("number_of_threads", &RuntimeParameters::numberOfThreads); - - } -} \ No newline at end of file diff --git a/src/cpu/pythonbindings/src/submodules/writer.cpp b/src/cpu/pythonbindings/src/submodules/writer.cpp deleted file mode 100644 index d5ec527a27caf63d9a3066c51e1f675b307fe0b2..0000000000000000000000000000000000000000 --- a/src/cpu/pythonbindings/src/submodules/writer.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include <pybind11/pybind11.h> -#include <simulationconfig/WriterConfiguration.h> - -namespace writer -{ - namespace py = pybind11; - - void makeModule(py::module_ &parentModule) - { - py::module writerModule = parentModule.def_submodule("writer"); - - py::enum_<OutputFormat>(writerModule, "OutputFormat") - .value("ASCII", OutputFormat::ASCII) - .value("BINARY", OutputFormat::BINARY); - - py::class_<WriterConfiguration>(writerModule, "Writer") - .def(py::init()) - .def_readwrite("output_path", &WriterConfiguration::outputPath) - .def_readwrite("output_format", &WriterConfiguration::outputFormat); - } -} \ No newline at end of file diff --git a/src/cpu/simulationconfig/CMakeLists.txt b/src/cpu/simulationconfig/CMakeLists.txt index 95ee969a049fd65cfadc6cc95d814e788a02aa8e..f0659f67a2af8d40a20991be42b4b49e1cab8ff1 100644 --- a/src/cpu/simulationconfig/CMakeLists.txt +++ b/src/cpu/simulationconfig/CMakeLists.txt @@ -1,7 +1,7 @@ project(simulationconfig) -vf_add_library(NAME simulationconfig PUBLIC_LINK VirtualFluidsCore basics muparser) +vf_add_library(NAME simulationconfig PUBLIC_LINK VirtualFluidsCore basics muparser lbm) set_target_properties(simulationconfig PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/src/cpu/simulationconfig/include/simulationconfig/KernelConfigStructs.h b/src/cpu/simulationconfig/include/simulationconfig/KernelConfigStructs.h index 88e621a3fe00a522b23fda4101e84d39305e80a2..53ea667c9da3a9c57d5aeeac67588cab0afbff3f 100644 --- a/src/cpu/simulationconfig/include/simulationconfig/KernelConfigStructs.h +++ b/src/cpu/simulationconfig/include/simulationconfig/KernelConfigStructs.h @@ -2,14 +2,14 @@ #define VIRTUALFLUIDSPYTHONBINDINGS_KERNELCONFIGSTRUCTS_H #include <string> -#include <LBM/LBMSystem.h> +#include <basics/DataTypes.h> struct LBMKernelConfiguration { KernelFactory::KernelType kernelType; bool useForcing = false; - LBMReal forcingX1{}; - LBMReal forcingX2{}; - LBMReal forcingX3{}; + real forcingX1{}; + real forcingX2{}; + real forcingX3{}; explicit LBMKernelConfiguration(KernelFactory::KernelType kernelType) : kernelType(kernelType) { diff --git a/src/cpu/simulationconfig/src/Simulation.cpp b/src/cpu/simulationconfig/src/Simulation.cpp index 1fc777192d7b707ee28c1e1d2e8ae20d61df455b..098f913d61a87b0dd2692faad07de691ca7e04a1 100644 --- a/src/cpu/simulationconfig/src/Simulation.cpp +++ b/src/cpu/simulationconfig/src/Simulation.cpp @@ -33,6 +33,8 @@ #include <simulationconfig/SimulationParameters.h> #include <simulationconfig/Simulation.h> +#include <lbm/constants/D3Q27.h> + Simulation::Simulation() { diff --git a/src/gpu/GksGpu/Analyzer/ConvergenceAnalyzer.cpp b/src/gpu/GksGpu/Analyzer/ConvergenceAnalyzer.cpp deleted file mode 100644 index 2125ceb6c10d2074c6e5f804e3944cd031601f1c..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/ConvergenceAnalyzer.cpp +++ /dev/null @@ -1,138 +0,0 @@ -#include "ConvergenceAnalyzer.h" - -#include <cmath> -#include <sstream> -#include <iomanip> - -#include "Core/Logger/Logger.h" - -#include "DataBase/DataBase.h" - -#include "FlowStateData/AccessDeviceData.cuh" - -namespace GksGpu { - -ConvergenceAnalyzer::ConvergenceAnalyzer(SPtr<DataBase> dataBase, uint outputIter, real convergenceThreshold) -{ - this->dataBase = dataBase; - - this->outputIter = outputIter; - - this->setConvergenceThreshold( convergenceThreshold ); - - this->dataHostOld = dataBase->dataHost; - this->dataHostNew = dataBase->dataHost; -} - -void ConvergenceAnalyzer::setConvergenceThreshold(real convergenceThreshold) -{ - this->convergenceThreshold.rho = convergenceThreshold; - this->convergenceThreshold.rhoU = convergenceThreshold; - this->convergenceThreshold.rhoV = convergenceThreshold; - this->convergenceThreshold.rhoW = convergenceThreshold; - this->convergenceThreshold.rhoE = convergenceThreshold; -#ifdef USE_PASSIVE_SCALAR - this->convergenceThreshold.rhoS_1 = convergenceThreshold; - this->convergenceThreshold.rhoS_2 = convergenceThreshold; -#endif //USE_PASSIVE_SCALAR -} - -void ConvergenceAnalyzer::setConvergenceThreshold(ConservedVariables convergenceThreshold) -{ - this->convergenceThreshold.rho = convergenceThreshold.rho ; - this->convergenceThreshold.rhoU = convergenceThreshold.rhoU; - this->convergenceThreshold.rhoV = convergenceThreshold.rhoV; - this->convergenceThreshold.rhoW = convergenceThreshold.rhoW; - this->convergenceThreshold.rhoE = convergenceThreshold.rhoE; -#ifdef USE_PASSIVE_SCALAR - this->convergenceThreshold.rhoS_1 = convergenceThreshold.rhoS_1; - this->convergenceThreshold.rhoS_2 = convergenceThreshold.rhoS_2; -#endif //USE_PASSIVE_SCALAR -} - -bool ConvergenceAnalyzer::run(uint iter) -{ - if( iter % outputIter != 0 ) return false; - - this->dataBase->copyDataDeviceToHost( this->dataHostNew.data() ); - - ConservedVariables changeSquareSum, consSquareSum; - - for( uint cellIdx = 0; cellIdx < this->dataBase->numberOfCells; cellIdx++ ){ - - ConservedVariables change, cons; - - cons.rho = this->dataHostNew[ RHO__(cellIdx, dataBase->numberOfCells) ]; - cons.rhoU = this->dataHostNew[ RHO_U(cellIdx, dataBase->numberOfCells) ]; - cons.rhoV = this->dataHostNew[ RHO_V(cellIdx, dataBase->numberOfCells) ]; - cons.rhoW = this->dataHostNew[ RHO_W(cellIdx, dataBase->numberOfCells) ]; - cons.rhoE = this->dataHostNew[ RHO_E(cellIdx, dataBase->numberOfCells) ]; - - change.rho = cons.rho - this->dataHostOld[ RHO__(cellIdx, dataBase->numberOfCells) ]; - change.rhoU = cons.rhoU - this->dataHostOld[ RHO_U(cellIdx, dataBase->numberOfCells) ]; - change.rhoV = cons.rhoV - this->dataHostOld[ RHO_V(cellIdx, dataBase->numberOfCells) ]; - change.rhoW = cons.rhoW - this->dataHostOld[ RHO_W(cellIdx, dataBase->numberOfCells) ]; - change.rhoE = cons.rhoE - this->dataHostOld[ RHO_E(cellIdx, dataBase->numberOfCells) ]; - - changeSquareSum.rho += change.rho * change.rho ; - changeSquareSum.rhoU += change.rhoU * change.rhoU; - changeSquareSum.rhoV += change.rhoV * change.rhoV; - changeSquareSum.rhoW += change.rhoW * change.rhoW; - changeSquareSum.rhoE += change.rhoE * change.rhoE; - - consSquareSum.rho += cons.rho * cons.rho ; - consSquareSum.rhoU += cons.rhoU * cons.rhoU; - consSquareSum.rhoV += cons.rhoV * cons.rhoV; - consSquareSum.rhoW += cons.rhoW * cons.rhoW; - consSquareSum.rhoE += cons.rhoE * cons.rhoE; - } - - ConservedVariables L2Change; - - L2Change.rho = std::sqrt( changeSquareSum.rho / consSquareSum.rho ); - L2Change.rhoU = std::sqrt( changeSquareSum.rhoU / consSquareSum.rhoU ); - L2Change.rhoV = std::sqrt( changeSquareSum.rhoV / consSquareSum.rhoV ); - L2Change.rhoW = std::sqrt( changeSquareSum.rhoW / consSquareSum.rhoW ); - L2Change.rhoE = std::sqrt( changeSquareSum.rhoE / consSquareSum.rhoE ); - - this->dataHostOld = this->dataHostNew; - - this->printL2Change( L2Change ); - - if( L2Change.rho < this->convergenceThreshold.rho && - L2Change.rhoU < this->convergenceThreshold.rhoU && - L2Change.rhoV < this->convergenceThreshold.rhoV && - L2Change.rhoW < this->convergenceThreshold.rhoW && - L2Change.rhoE < this->convergenceThreshold.rhoE ) - { - return true; - } - - return false; -} - -void ConvergenceAnalyzer::printL2Change(ConservedVariables L2Change) -{ - std::stringstream header; - std::stringstream body; - - header << "| "; - header << " rho" << " | "; - header << " rhoU" << " | "; - header << " rhoV" << " | "; - header << " rhoW" << " | "; - header << " rhoE" << " | "; - - body << "| "; - body << std::setw(10) << std::setprecision(4) << L2Change.rho << " | "; - body << std::setw(10) << std::setprecision(4) << L2Change.rhoU << " | "; - body << std::setw(10) << std::setprecision(4) << L2Change.rhoV << " | "; - body << std::setw(10) << std::setprecision(4) << L2Change.rhoW << " | "; - body << std::setw(10) << std::setprecision(4) << L2Change.rhoE << " | "; - - *logging::out << logging::Logger::INFO_HIGH << "Residual L2-Change:" << "\n"; - *logging::out << logging::Logger::INFO_HIGH << header.str() << "\n"; - *logging::out << logging::Logger::INFO_HIGH << body.str() << "\n"; -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/Analyzer/ConvergenceAnalyzer.h b/src/gpu/GksGpu/Analyzer/ConvergenceAnalyzer.h deleted file mode 100644 index 52b1896a20430ea45c6ddf3f513c0902e521a825..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/ConvergenceAnalyzer.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef ConvergenceAnalyzer_H -#define ConvergenceAnalyzer_H - -#include <vector> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/Timer/Timer.h" - -#include "FlowStateData/FlowStateData.cuh" - -#include "GksGpu_export.h" - -namespace GksGpu { - -struct DataBase; - -class GKSGPU_EXPORT ConvergenceAnalyzer -{ -private: - - SPtr<DataBase> dataBase; - - std::vector<real> dataHostOld; - std::vector<real> dataHostNew; - - uint outputIter; - - ConservedVariables convergenceThreshold; - -public: - - ConvergenceAnalyzer( SPtr<DataBase> dataBase, uint outputIter = 10000, real convergenceThreshold = 1.0e-6 ); - - void setConvergenceThreshold( real convergenceThreshold ); - void setConvergenceThreshold( ConservedVariables convergenceThreshold ); - - bool run( uint iter ); - -private: - - void printL2Change( ConservedVariables L2Change ); - -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Analyzer/CupsAnalyzer.cpp b/src/gpu/GksGpu/Analyzer/CupsAnalyzer.cpp deleted file mode 100644 index 1d23a82bef8ea9c3e22eef18db57a4365f603eb3..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/CupsAnalyzer.cpp +++ /dev/null @@ -1,135 +0,0 @@ -#include "CupsAnalyzer.h" - -#include <cmath> -#include <sstream> -#include <iomanip> - -#include "Core/Logger/Logger.h" - - -#include "GksGpu_export.h" - -#include "DataBase/DataBase.h" - -namespace GksGpu { - -CupsAnalyzer::CupsAnalyzer(SPtr<DataBase> dataBase, - bool outputPerTime, real outputTime, - bool outputPerIter, uint outputIter) - : outputPerTime(outputPerTime), - outputTime(outputTime), - outputPerIter(outputPerIter), - outputIter(outputIter), - outputPerTimeCounter(1), - counter(0) -{ - this->timer = Timer::makeStart(); - this->timerRestart = Timer::makeStart(); - - this->numberOfCellUpdatesPerTimeStep = 0; - - for( uint level = 0; level < dataBase->numberOfLevels; level++ ) - { - numberOfCellUpdatesPerTimeStep += std::pow( 2, level ) * dataBase->perLevelCount[level].numberOfBulkCells; - } -} - -void CupsAnalyzer::start() -{ - this->counter = 0; - this->timer->start(); - this->timerRestart->start(); -} - -void CupsAnalyzer::restart() -{ - this->counter = 0; - this->timerRestart->start(); -} - -real CupsAnalyzer::run( uint iter, real dt ) -{ - real currentRuntime = this->timer->getCurrentRuntimeInSeconds(); - real currentRuntimeSinceRestart = this->timerRestart->getCurrentRuntimeInSeconds(); - - real CUPS = -1.0; - - this->counter++; - - if( checkOutputPerTime(currentRuntime) || checkOutputPerIter(iter) ) - { - unsigned long long numberOfCellUpdates = this->numberOfCellUpdatesPerTimeStep * (unsigned long long)counter; - - CUPS = real(numberOfCellUpdates) / currentRuntimeSinceRestart; - - this->printCups( iter, iter * dt, currentRuntime, CUPS ); - - this->restart(); - } - - if( checkOutputPerTime(currentRuntime) ) - { - outputPerTimeCounter++; - } - - return CUPS; -} - -bool CupsAnalyzer::checkOutputPerTime(real currentRuntime) -{ - return outputPerTime && ( ( currentRuntime - outputPerTimeCounter * outputTime ) > 0 ); -} - -bool CupsAnalyzer::checkOutputPerIter(uint iter) -{ - return outputPerIter && (iter % outputIter == 0); -} - -void CupsAnalyzer::printCups(uint iter, real simTime, real currentRunTime, real cups) -{ - std::stringstream header; - std::stringstream body; - - header << "| "; - header << " Iter" << " | "; - header << " sim. time" << " | "; - header << " wall time" << " | "; - header << " MCUPS" << " | "; - - body << "| "; - body << std::setw(15) << std::setprecision(4) << iter << " | "; - body << std::setw(15) << std::setprecision(4) << this->getTimeString(simTime).c_str() << " | "; - body << std::setw(15) << std::setprecision(4) << this->getTimeString(currentRunTime).c_str() << " | "; - body << std::setw(15) << std::setprecision(4) << cups / 1.0e6 << " | "; - - *logging::out << logging::Logger::INFO_HIGH << "Performance:" << "\n"; - *logging::out << logging::Logger::INFO_HIGH << header.str() << "\n"; - *logging::out << logging::Logger::INFO_HIGH << body.str() << "\n"; -} - -std::string CupsAnalyzer::getTimeString(real time) -{ - int seconds = int(time); - int minutes = seconds / 60; - int hours = minutes / 60; - int days = hours / 24; - - int milliseconds = int( 1000.0 * ( time - real(seconds)) ); - - hours -= days * 24; - minutes -= ( days * 24 + hours ) * 60; - seconds -= ( ( days * 24 + hours ) * 60 + minutes ) * 60; - - std::stringstream timeString; - timeString << std::setw(2) << std::setfill('0') << days << ":"; - timeString << std::setw(2) << std::setfill('0') << hours << ":"; - timeString << std::setw(2) << std::setfill('0') << minutes << ":"; - timeString << std::setw(2) << std::setfill('0') << seconds << "."; - timeString << std::setw(3) << std::setfill('0') << milliseconds; - - return timeString.str(); -} - -} // namespace GksGpu - - diff --git a/src/gpu/GksGpu/Analyzer/CupsAnalyzer.h b/src/gpu/GksGpu/Analyzer/CupsAnalyzer.h deleted file mode 100644 index 095e795501adf019bb9eb1e54dda3329b98bb9d8..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/CupsAnalyzer.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef CupsAnalyzer_H -#define CupsAnalyzer_H - -#include <string> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/Timer/Timer.h" -#include "GksGpu_export.h" - -namespace GksGpu { - -struct DataBase; - -class GKSGPU_EXPORT CupsAnalyzer -{ -private: - SPtr<Timer> timer; - SPtr<Timer> timerRestart; - - bool outputPerTime; - - bool outputPerIter; - - real outputTime; - uint outputPerTimeCounter; - - uint outputIter; - - unsigned long long numberOfCellUpdatesPerTimeStep; - - uint counter; - -public: - - CupsAnalyzer( SPtr<DataBase> dataBase, - bool outputPerTime = true, real outputTime = 600.0, - bool outputPerIter = true, uint outputIter = 10000 ); - - void start(); - - void restart(); - - real run( uint iter, real dt ); - -private: - - bool checkOutputPerTime( real currentRuntime ); - bool checkOutputPerIter( uint iter ); - - void printCups(uint iter, real simTime, real currentRunTime, real cups); - - std::string getTimeString( real time ); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Analyzer/EnstrophyAnalyzer.cu b/src/gpu/GksGpu/Analyzer/EnstrophyAnalyzer.cu deleted file mode 100644 index 346692bfdf8c8daf9a659a3a0ef04aa57f487545..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/EnstrophyAnalyzer.cu +++ /dev/null @@ -1,346 +0,0 @@ -#include "EnstrophyAnalyzer.h" - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include <cmath> -#include <sstream> - -#include <thrust/device_vector.h> -#include <thrust/reduce.h> -#include <thrust/device_ptr.h> - -#include <iomanip> - -#include "Core/Logger/Logger.h" - -#include "DataBase/DataBase.h" - -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu { - -__global__ void enstrophyKernel ( DataBaseStruct dataBase, Parameters parameters, real* enstrophy, uint nx, uint startIndex, uint numberOfEntities ); - -__host__ __device__ inline void enstrophyFunction( DataBaseStruct dataBase, Parameters parameters, real* enstrophy, uint nx, uint startIndex, uint index ); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -bool EnstrophyAnalyzer::run(uint iter) -{ - if( iter % this->analyzeIter != 0 ) return false; - - thrust::device_vector<real> enstrophy( this->dataBase->perLevelCount[ 0 ].numberOfBulkCells ); - - CudaUtility::CudaGrid grid( dataBase->perLevelCount[ 0 ].numberOfBulkCells, 32 ); - - uint nx; - if ( dataBase->perLevelCount[ 0 ].numberOfBulkCells == 64* 64* 64 ) nx = 64; - else if( dataBase->perLevelCount[ 0 ].numberOfBulkCells == 128*128*128 ) nx = 128; - else if( dataBase->perLevelCount[ 0 ].numberOfBulkCells == 256*256*256 ) nx = 256; - - runKernel( enstrophyKernel, - enstrophyFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - parameters, - enstrophy.data().get(), - nx, - dataBase->perLevelCount[ 0 ].startOfCells ); - - getLastCudaError("KineticEnergyAnalyzer::run(uint iter)"); - - real EnstrophyTmp = thrust::reduce( enstrophy.begin(), enstrophy.end(), c0o1, thrust::plus<real>() ) - / real(dataBase->perLevelCount[ 0 ].numberOfBulkCells); - - this->enstrophyTimeSeries.push_back( EnstrophyTmp ); - - //*logging::out << logging::Logger::INFO_HIGH << "EKin = " << EKin << "\n"; - - return true; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__global__ void enstrophyKernel(DataBaseStruct dataBase, Parameters parameters, real* enstrophy, uint nx, uint startIndex, uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - enstrophyFunction( dataBase, parameters, enstrophy, nx, startIndex, index ); -} - -__host__ __device__ void enstrophyFunction(DataBaseStruct dataBase, Parameters parameters, real* enstrophy, uint nx, uint startIndex, uint index) -{ - uint cellIndex = startIndex + index; - - ////////////////////////////////////////////////////////////////////////// - - uint xIndex = ( cellIndex % ( nx*nx ) ) % nx; - uint yIndex = ( cellIndex % ( nx*nx ) ) / nx; - uint zIndex = ( cellIndex / ( nx*nx ) ); - - uint xP1 = (( xIndex + 1 )%nx) + (( yIndex )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint xP2 = (( xIndex + 2 )%nx) + (( yIndex )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint xP3 = (( xIndex + 3 )%nx) + (( yIndex )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint xP4 = (( xIndex + 4 )%nx) + (( yIndex )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint xM1 = (( xIndex - 1 )%nx) + (( yIndex )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint xM2 = (( xIndex - 2 )%nx) + (( yIndex )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint xM3 = (( xIndex - 3 )%nx) + (( yIndex )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint xM4 = (( xIndex - 4 )%nx) + (( yIndex )%nx)*nx + (( zIndex )%nx)*nx*nx; - - uint yP1 = (( xIndex )%nx) + (( yIndex + 1 )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint yP2 = (( xIndex )%nx) + (( yIndex + 2 )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint yP3 = (( xIndex )%nx) + (( yIndex + 3 )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint yP4 = (( xIndex )%nx) + (( yIndex + 4 )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint yM1 = (( xIndex )%nx) + (( yIndex - 1 )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint yM2 = (( xIndex )%nx) + (( yIndex - 2 )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint yM3 = (( xIndex )%nx) + (( yIndex - 3 )%nx)*nx + (( zIndex )%nx)*nx*nx; - uint yM4 = (( xIndex )%nx) + (( yIndex - 4 )%nx)*nx + (( zIndex )%nx)*nx*nx; - - uint zP1 = (( xIndex )%nx) + (( yIndex )%nx)*nx + (( zIndex + 1 )%nx)*nx*nx; - uint zP2 = (( xIndex )%nx) + (( yIndex )%nx)*nx + (( zIndex + 2 )%nx)*nx*nx; - uint zP3 = (( xIndex )%nx) + (( yIndex )%nx)*nx + (( zIndex + 3 )%nx)*nx*nx; - uint zP4 = (( xIndex )%nx) + (( yIndex )%nx)*nx + (( zIndex + 4 )%nx)*nx*nx; - uint zM1 = (( xIndex )%nx) + (( yIndex )%nx)*nx + (( zIndex - 1 )%nx)*nx*nx; - uint zM2 = (( xIndex )%nx) + (( yIndex )%nx)*nx + (( zIndex - 2 )%nx)*nx*nx; - uint zM3 = (( xIndex )%nx) + (( yIndex )%nx)*nx + (( zIndex - 3 )%nx)*nx*nx; - uint zM4 = (( xIndex )%nx) + (( yIndex )%nx)*nx + (( zIndex - 4 )%nx)*nx*nx; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real rho_xP1 = dataBase.data[ RHO__( xP1, dataBase.numberOfCells ) ]; - real rho_xP2 = dataBase.data[ RHO__( xP2, dataBase.numberOfCells ) ]; - real rho_xP3 = dataBase.data[ RHO__( xP3, dataBase.numberOfCells ) ]; - real rho_xP4 = dataBase.data[ RHO__( xP4, dataBase.numberOfCells ) ]; - real rho_xM1 = dataBase.data[ RHO__( xM1, dataBase.numberOfCells ) ]; - real rho_xM2 = dataBase.data[ RHO__( xM2, dataBase.numberOfCells ) ]; - real rho_xM3 = dataBase.data[ RHO__( xM3, dataBase.numberOfCells ) ]; - real rho_xM4 = dataBase.data[ RHO__( xM4, dataBase.numberOfCells ) ]; - - real rho_yP1 = dataBase.data[ RHO__( yP1, dataBase.numberOfCells ) ]; - real rho_yP2 = dataBase.data[ RHO__( yP2, dataBase.numberOfCells ) ]; - real rho_yP3 = dataBase.data[ RHO__( yP3, dataBase.numberOfCells ) ]; - real rho_yP4 = dataBase.data[ RHO__( yP4, dataBase.numberOfCells ) ]; - real rho_yM1 = dataBase.data[ RHO__( yM1, dataBase.numberOfCells ) ]; - real rho_yM2 = dataBase.data[ RHO__( yM2, dataBase.numberOfCells ) ]; - real rho_yM3 = dataBase.data[ RHO__( yM3, dataBase.numberOfCells ) ]; - real rho_yM4 = dataBase.data[ RHO__( yM4, dataBase.numberOfCells ) ]; - - real rho_zP1 = dataBase.data[ RHO__( zP1, dataBase.numberOfCells ) ]; - real rho_zP2 = dataBase.data[ RHO__( zP2, dataBase.numberOfCells ) ]; - real rho_zP3 = dataBase.data[ RHO__( zP3, dataBase.numberOfCells ) ]; - real rho_zP4 = dataBase.data[ RHO__( zP4, dataBase.numberOfCells ) ]; - real rho_zM1 = dataBase.data[ RHO__( zM1, dataBase.numberOfCells ) ]; - real rho_zM2 = dataBase.data[ RHO__( zM2, dataBase.numberOfCells ) ]; - real rho_zM3 = dataBase.data[ RHO__( zM3, dataBase.numberOfCells ) ]; - real rho_zM4 = dataBase.data[ RHO__( zM4, dataBase.numberOfCells ) ]; - - ////////////////////////////////////////////////////////////////////////// - - real U_xP1 = dataBase.data[ RHO_U( xP1, dataBase.numberOfCells ) ] / rho_xP1; - real U_xP2 = dataBase.data[ RHO_U( xP2, dataBase.numberOfCells ) ] / rho_xP2; - real U_xP3 = dataBase.data[ RHO_U( xP3, dataBase.numberOfCells ) ] / rho_xP3; - real U_xP4 = dataBase.data[ RHO_U( xP4, dataBase.numberOfCells ) ] / rho_xP4; - real U_xM1 = dataBase.data[ RHO_U( xM1, dataBase.numberOfCells ) ] / rho_xM1; - real U_xM2 = dataBase.data[ RHO_U( xM2, dataBase.numberOfCells ) ] / rho_xM2; - real U_xM3 = dataBase.data[ RHO_U( xM3, dataBase.numberOfCells ) ] / rho_xM3; - real U_xM4 = dataBase.data[ RHO_U( xM4, dataBase.numberOfCells ) ] / rho_xM4; - - real U_yP1 = dataBase.data[ RHO_U( yP1, dataBase.numberOfCells ) ] / rho_yP1; - real U_yP2 = dataBase.data[ RHO_U( yP2, dataBase.numberOfCells ) ] / rho_yP2; - real U_yP3 = dataBase.data[ RHO_U( yP3, dataBase.numberOfCells ) ] / rho_yP3; - real U_yP4 = dataBase.data[ RHO_U( yP4, dataBase.numberOfCells ) ] / rho_yP4; - real U_yM1 = dataBase.data[ RHO_U( yM1, dataBase.numberOfCells ) ] / rho_yM1; - real U_yM2 = dataBase.data[ RHO_U( yM2, dataBase.numberOfCells ) ] / rho_yM2; - real U_yM3 = dataBase.data[ RHO_U( yM3, dataBase.numberOfCells ) ] / rho_yM3; - real U_yM4 = dataBase.data[ RHO_U( yM4, dataBase.numberOfCells ) ] / rho_yM4; - - real U_zP1 = dataBase.data[ RHO_U( zP1, dataBase.numberOfCells ) ] / rho_zP1; - real U_zP2 = dataBase.data[ RHO_U( zP2, dataBase.numberOfCells ) ] / rho_zP2; - real U_zP3 = dataBase.data[ RHO_U( zP3, dataBase.numberOfCells ) ] / rho_zP3; - real U_zP4 = dataBase.data[ RHO_U( zP4, dataBase.numberOfCells ) ] / rho_zP4; - real U_zM1 = dataBase.data[ RHO_U( zM1, dataBase.numberOfCells ) ] / rho_zM1; - real U_zM2 = dataBase.data[ RHO_U( zM2, dataBase.numberOfCells ) ] / rho_zM2; - real U_zM3 = dataBase.data[ RHO_U( zM3, dataBase.numberOfCells ) ] / rho_zM3; - real U_zM4 = dataBase.data[ RHO_U( zM4, dataBase.numberOfCells ) ] / rho_zM4; - - ////////////////////////////////////////////////////////////////////////// - - real V_xP1 = dataBase.data[ RHO_V( xP1, dataBase.numberOfCells ) ] / rho_xP1; - real V_xP2 = dataBase.data[ RHO_V( xP2, dataBase.numberOfCells ) ] / rho_xP2; - real V_xP3 = dataBase.data[ RHO_V( xP3, dataBase.numberOfCells ) ] / rho_xP3; - real V_xP4 = dataBase.data[ RHO_V( xP4, dataBase.numberOfCells ) ] / rho_xP4; - real V_xM1 = dataBase.data[ RHO_V( xM1, dataBase.numberOfCells ) ] / rho_xM1; - real V_xM2 = dataBase.data[ RHO_V( xM2, dataBase.numberOfCells ) ] / rho_xM2; - real V_xM3 = dataBase.data[ RHO_V( xM3, dataBase.numberOfCells ) ] / rho_xM3; - real V_xM4 = dataBase.data[ RHO_V( xM4, dataBase.numberOfCells ) ] / rho_xM4; - - real V_yP1 = dataBase.data[ RHO_V( yP1, dataBase.numberOfCells ) ] / rho_yP1; - real V_yP2 = dataBase.data[ RHO_V( yP2, dataBase.numberOfCells ) ] / rho_yP2; - real V_yP3 = dataBase.data[ RHO_V( yP3, dataBase.numberOfCells ) ] / rho_yP3; - real V_yP4 = dataBase.data[ RHO_V( yP4, dataBase.numberOfCells ) ] / rho_yP4; - real V_yM1 = dataBase.data[ RHO_V( yM1, dataBase.numberOfCells ) ] / rho_yM1; - real V_yM2 = dataBase.data[ RHO_V( yM2, dataBase.numberOfCells ) ] / rho_yM2; - real V_yM3 = dataBase.data[ RHO_V( yM3, dataBase.numberOfCells ) ] / rho_yM3; - real V_yM4 = dataBase.data[ RHO_V( yM4, dataBase.numberOfCells ) ] / rho_yM4; - - real V_zP1 = dataBase.data[ RHO_V( zP1, dataBase.numberOfCells ) ] / rho_zP1; - real V_zP2 = dataBase.data[ RHO_V( zP2, dataBase.numberOfCells ) ] / rho_zP2; - real V_zP3 = dataBase.data[ RHO_V( zP3, dataBase.numberOfCells ) ] / rho_zP3; - real V_zP4 = dataBase.data[ RHO_V( zP4, dataBase.numberOfCells ) ] / rho_zP4; - real V_zM1 = dataBase.data[ RHO_V( zM1, dataBase.numberOfCells ) ] / rho_zM1; - real V_zM2 = dataBase.data[ RHO_V( zM2, dataBase.numberOfCells ) ] / rho_zM2; - real V_zM3 = dataBase.data[ RHO_V( zM3, dataBase.numberOfCells ) ] / rho_zM3; - real V_zM4 = dataBase.data[ RHO_V( zM4, dataBase.numberOfCells ) ] / rho_zM4; - - ////////////////////////////////////////////////////////////////////////// - - real W_xP1 = dataBase.data[ RHO_W( xP1, dataBase.numberOfCells ) ] / rho_xP1; - real W_xP2 = dataBase.data[ RHO_W( xP2, dataBase.numberOfCells ) ] / rho_xP2; - real W_xP3 = dataBase.data[ RHO_W( xP3, dataBase.numberOfCells ) ] / rho_xP3; - real W_xP4 = dataBase.data[ RHO_W( xP4, dataBase.numberOfCells ) ] / rho_xP4; - real W_xM1 = dataBase.data[ RHO_W( xM1, dataBase.numberOfCells ) ] / rho_xM1; - real W_xM2 = dataBase.data[ RHO_W( xM2, dataBase.numberOfCells ) ] / rho_xM2; - real W_xM3 = dataBase.data[ RHO_W( xM3, dataBase.numberOfCells ) ] / rho_xM3; - real W_xM4 = dataBase.data[ RHO_W( xM4, dataBase.numberOfCells ) ] / rho_xM4; - - real W_yP1 = dataBase.data[ RHO_W( yP1, dataBase.numberOfCells ) ] / rho_yP1; - real W_yP2 = dataBase.data[ RHO_W( yP2, dataBase.numberOfCells ) ] / rho_yP2; - real W_yP3 = dataBase.data[ RHO_W( yP3, dataBase.numberOfCells ) ] / rho_yP3; - real W_yP4 = dataBase.data[ RHO_W( yP4, dataBase.numberOfCells ) ] / rho_yP4; - real W_yM1 = dataBase.data[ RHO_W( yM1, dataBase.numberOfCells ) ] / rho_yM1; - real W_yM2 = dataBase.data[ RHO_W( yM2, dataBase.numberOfCells ) ] / rho_yM2; - real W_yM3 = dataBase.data[ RHO_W( yM3, dataBase.numberOfCells ) ] / rho_yM3; - real W_yM4 = dataBase.data[ RHO_W( yM4, dataBase.numberOfCells ) ] / rho_yM4; - - real W_zP1 = dataBase.data[ RHO_W( zP1, dataBase.numberOfCells ) ] / rho_zP1; - real W_zP2 = dataBase.data[ RHO_W( zP2, dataBase.numberOfCells ) ] / rho_zP2; - real W_zP3 = dataBase.data[ RHO_W( zP3, dataBase.numberOfCells ) ] / rho_zP3; - real W_zP4 = dataBase.data[ RHO_W( zP4, dataBase.numberOfCells ) ] / rho_zP4; - real W_zM1 = dataBase.data[ RHO_W( zM1, dataBase.numberOfCells ) ] / rho_zM1; - real W_zM2 = dataBase.data[ RHO_W( zM2, dataBase.numberOfCells ) ] / rho_zM2; - real W_zM3 = dataBase.data[ RHO_W( zM3, dataBase.numberOfCells ) ] / rho_zM3; - real W_zM4 = dataBase.data[ RHO_W( zM4, dataBase.numberOfCells ) ] / rho_zM4; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real dVdx = ( (c28o1 * c8o1) * ( V_xP1 - V_xM1 ) - (c7o1 * c8o1) * ( V_xP2 - V_xM2 ) + (c8o1 * c4o1 * c1o3) * ( V_xP3 - V_xM3 ) - ( V_xP4 - V_xM4 ) ) / (c7o1 * c10o1 * c4o1 * parameters.dx); - real dWdx = ( (c28o1 * c8o1) * ( W_xP1 - W_xM1 ) - (c7o1 * c8o1) * ( W_xP2 - W_xM2 ) + (c8o1 * c4o1 * c1o3) * ( W_xP3 - W_xM3 ) - ( W_xP4 - W_xM4 ) ) / (c7o1 * c10o1 * c4o1 * parameters.dx); - real dUdy = ( (c28o1 * c8o1) * ( U_yP1 - U_yM1 ) - (c7o1 * c8o1) * ( U_yP2 - U_yM2 ) + (c8o1 * c4o1 * c1o3) * ( U_yP3 - U_yM3 ) - ( U_yP4 - U_yM4 ) ) / (c7o1 * c10o1 * c4o1 * parameters.dx); - real dWdy = ( (c28o1 * c8o1) * ( W_yP1 - W_yM1 ) - (c7o1 * c8o1) * ( W_yP2 - W_yM2 ) + (c8o1 * c4o1 * c1o3) * ( W_yP3 - W_yM3 ) - ( W_yP4 - W_yM4 ) ) / (c7o1 * c10o1 * c4o1 * parameters.dx); - real dUdz = ( (c28o1 * c8o1) * ( U_zP1 - U_zM1 ) - (c7o1 * c8o1) * ( U_zP2 - U_zM2 ) + (c8o1 * c4o1 * c1o3) * ( U_zP3 - U_zM3 ) - ( U_zP4 - U_zM4 ) ) / (c7o1 * c10o1 * c4o1 * parameters.dx); - real dVdz = ( (c28o1 * c8o1) * ( V_zP1 - V_zM1 ) - (c7o1 * c8o1) * ( V_zP2 - V_zM2 ) + (c8o1 * c4o1 * c1o3) * ( V_zP3 - V_zM3 ) - ( V_zP4 - V_zM4 ) ) / (c7o1 * c10o1 * c4o1 * parameters.dx); - - real tmpX = dWdy - dVdz; - real tmpY = dUdz - dWdx; - real tmpZ = dVdx - dUdy; - - ////////////////////////////////////////////////////////////////////////// - - real rho = dataBase.data[ RHO__( cellIndex, dataBase.numberOfCells ) ]; - - enstrophy[ cellIndex ] = c1o2 * rho * ( tmpX*tmpX + tmpY*tmpY + tmpZ*tmpZ ); -} - -//__host__ __device__ void enstrophyFunction(DataBaseStruct dataBase, Parameters parameters, real* enstrophy, uint startIndex, uint index) -//{ -// uint cellIndex = startIndex + index; -// -// ////////////////////////////////////////////////////////////////////////// -// -// uint cellToCell [6]; -// -// cellToCell[0] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 0, dataBase.numberOfCells ) ]; -// cellToCell[1] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 1, dataBase.numberOfCells ) ]; -// cellToCell[2] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 2, dataBase.numberOfCells ) ]; -// cellToCell[3] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 3, dataBase.numberOfCells ) ]; -// cellToCell[4] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 4, dataBase.numberOfCells ) ]; -// cellToCell[5] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 5, dataBase.numberOfCells ) ]; -// -// real rho [7]; -// real U [6]; -// real V [6]; -// real W [6]; -// -// rho[0] = dataBase.data[ RHO__( cellToCell[0], dataBase.numberOfCells ) ]; -// rho[1] = dataBase.data[ RHO__( cellToCell[1], dataBase.numberOfCells ) ]; -// rho[2] = dataBase.data[ RHO__( cellToCell[2], dataBase.numberOfCells ) ]; -// rho[3] = dataBase.data[ RHO__( cellToCell[3], dataBase.numberOfCells ) ]; -// rho[4] = dataBase.data[ RHO__( cellToCell[4], dataBase.numberOfCells ) ]; -// rho[5] = dataBase.data[ RHO__( cellToCell[5], dataBase.numberOfCells ) ]; -// rho[6] = dataBase.data[ RHO__( cellIndex , dataBase.numberOfCells ) ]; -// -// U [0] = dataBase.data[ RHO_U( cellToCell[0], dataBase.numberOfCells ) ] / rho[0]; -// U [1] = dataBase.data[ RHO_U( cellToCell[1], dataBase.numberOfCells ) ] / rho[1]; -// U [2] = dataBase.data[ RHO_U( cellToCell[2], dataBase.numberOfCells ) ] / rho[2]; -// U [3] = dataBase.data[ RHO_U( cellToCell[3], dataBase.numberOfCells ) ] / rho[3]; -// U [4] = dataBase.data[ RHO_U( cellToCell[4], dataBase.numberOfCells ) ] / rho[4]; -// U [5] = dataBase.data[ RHO_U( cellToCell[5], dataBase.numberOfCells ) ] / rho[5]; -// -// V [0] = dataBase.data[ RHO_V( cellToCell[0], dataBase.numberOfCells ) ] / rho[0]; -// V [1] = dataBase.data[ RHO_V( cellToCell[1], dataBase.numberOfCells ) ] / rho[1]; -// V [2] = dataBase.data[ RHO_V( cellToCell[2], dataBase.numberOfCells ) ] / rho[2]; -// V [3] = dataBase.data[ RHO_V( cellToCell[3], dataBase.numberOfCells ) ] / rho[3]; -// V [4] = dataBase.data[ RHO_V( cellToCell[4], dataBase.numberOfCells ) ] / rho[4]; -// V [5] = dataBase.data[ RHO_V( cellToCell[5], dataBase.numberOfCells ) ] / rho[5]; -// -// W [0] = dataBase.data[ RHO_W( cellToCell[0], dataBase.numberOfCells ) ] / rho[0]; -// W [1] = dataBase.data[ RHO_W( cellToCell[1], dataBase.numberOfCells ) ] / rho[1]; -// W [2] = dataBase.data[ RHO_W( cellToCell[2], dataBase.numberOfCells ) ] / rho[2]; -// W [3] = dataBase.data[ RHO_W( cellToCell[3], dataBase.numberOfCells ) ] / rho[3]; -// W [4] = dataBase.data[ RHO_W( cellToCell[4], dataBase.numberOfCells ) ] / rho[4]; -// W [5] = dataBase.data[ RHO_W( cellToCell[5], dataBase.numberOfCells ) ] / rho[5]; -// -// real dVdx = c1o2 * ( V[1] - V[0] ) / parameters.dx; -// real dWdx = c1o2 * ( W[1] - W[0] ) / parameters.dx; -// -// real dUdy = c1o2 * ( U[3] - U[2] ) / parameters.dx; -// real dWdy = c1o2 * ( W[3] - W[2] ) / parameters.dx; -// -// real dUdz = c1o2 * ( U[5] - U[4] ) / parameters.dx; -// real dVdz = c1o2 * ( V[5] - V[4] ) / parameters.dx; -// -// real tmpX = dWdy - dVdz; -// real tmpY = dUdz - dWdx; -// real tmpZ = dVdx - dUdy; -// -// ////////////////////////////////////////////////////////////////////////// -// -// enstrophy[ cellIndex ] = c1o2 * rho[6] * ( tmpX*tmpX + tmpY*tmpY + tmpZ*tmpZ ); -//} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -EnstrophyAnalyzer::EnstrophyAnalyzer(SPtr<DataBase> dataBase, Parameters parameters, uint analyzeIter, uint outputIter) -{ - this->dataBase = dataBase; - this->parameters = parameters; - - this->analyzeIter = analyzeIter; - this->outputIter = outputIter; -} - -void EnstrophyAnalyzer::writeToFile(std::string filename) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "EnstrophyAnalyzer::writeToFile( " << filename << " )" << "\n"; - - std::ofstream file; - - file.open(filename + ".dat" ); - - for( auto& EKin : this->enstrophyTimeSeries ) - file << std::setprecision(15) << EKin << std::endl; - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -} // namespace GksGpu - - diff --git a/src/gpu/GksGpu/Analyzer/EnstrophyAnalyzer.h b/src/gpu/GksGpu/Analyzer/EnstrophyAnalyzer.h deleted file mode 100644 index 43acf5b51f06a7182d4c212811fcce56b3f7ae3d..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/EnstrophyAnalyzer.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef EnstrophyAnalyzer_H -#define EnstrophyAnalyzer_H - -#include <vector> -#include <string> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" - -#include "Parameters/Parameters.h" - -#include "FlowStateData/FlowStateData.cuh" - -namespace GksGpu { - -struct DataBase; - -class GKSGPU_EXPORT EnstrophyAnalyzer -{ -private: - - SPtr<DataBase> dataBase; - - Parameters parameters; - - uint outputIter; - - uint analyzeIter; - - std::vector<real> enstrophyTimeSeries; - -public: - - EnstrophyAnalyzer( SPtr<DataBase> dataBase, Parameters parameters, uint analyzeIter, uint outputIter ); - - bool run( uint iter ); - - void writeToFile( std::string filename ); - -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Analyzer/HeatFluxAnalyzer.cu b/src/gpu/GksGpu/Analyzer/HeatFluxAnalyzer.cu deleted file mode 100644 index ed68f8d95a2a68c00ab53c2cd1037bbff43e0f5b..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/HeatFluxAnalyzer.cu +++ /dev/null @@ -1,147 +0,0 @@ -#include "HeatFluxAnalyzer.h" - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include <cmath> -#include <sstream> - -#include <thrust/device_vector.h> -#include <thrust/reduce.h> -#include <thrust/device_ptr.h> - -#include <iomanip> - -#include "Core/Logger/Logger.h" - -#include "DataBase/DataBase.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" - -#include "FlowStateData/AccessDeviceData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" - -#include "FluxComputation/SutherlandsLaw.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu { - -__global__ void heatFluxKernel ( DataBaseStruct dataBase, GksGpu::BoundaryConditionStruct boundaryCondition, Parameters parameters, real* heatFlux, uint startIndex, uint numberOfEntities ); -__host__ __device__ inline void heatFluxFunction( DataBaseStruct& dataBase, GksGpu::BoundaryConditionStruct& boundaryCondition, Parameters& parameters, real* heatFlux, uint startIndex, uint index ); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -bool HeatFluxAnalyzer::run(uint iter, Parameters parameters) -{ - if( iter % this->analyzeIter != 0 ) return false; - - uint numberOfCells = this->boundaryCondition->numberOfCellsPerLevel[ dataBase->numberOfLevels - 1 ]; - - thrust::device_vector<real> heatFlux( numberOfCells ); - - CudaUtility::CudaGrid grid( numberOfCells, 32 ); - - for( uint level = 0; level < dataBase->numberOfLevels - 1; level++ ) parameters.dx *= c1o2; - - runKernel( heatFluxKernel, - heatFluxFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - boundaryCondition->toStruct(), - parameters, - heatFlux.data().get(), - boundaryCondition->startOfCellsPerLevel[ dataBase->numberOfLevels - 1 ] ); - - getLastCudaError("HeatFluxAnalyzer::run(uint iter)"); - - real q = thrust::reduce( heatFlux.begin(), heatFlux.end(), c0o1, thrust::plus<real>() ) * parameters.dx * parameters.dx; - - real qIdeal = c1o4 * (parameters.K + c5o1) * ( parameters.mu / parameters.Pr ) * ( c1o1 / lambdaHot - c1o1 / lambdaCold ); - - this->heatFluxTimeSeries.push_back( q / qIdeal ); - - if( iter % this->outputIter == 0 ) *logging::out << logging::Logger::INFO_HIGH << "q = " << q / qIdeal << "\n"; - - return true; -} - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__global__ void heatFluxKernel(DataBaseStruct dataBase, GksGpu::BoundaryConditionStruct boundaryCondition, Parameters parameters, real* heatFlux, uint startIndex, uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - heatFluxFunction( dataBase, boundaryCondition, parameters, heatFlux, startIndex, index ); -} - -__host__ __device__ void heatFluxFunction(DataBaseStruct& dataBase, GksGpu::BoundaryConditionStruct& boundaryCondition, Parameters& parameters, real* heatFlux, uint startIndex, uint index) -{ - uint ghostCellIndex = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIndex = boundaryCondition.domainCells[ startIndex + index ]; - - if( isCellProperties( dataBase.cellProperties[ domainCellIndex ], CELL_PROPERTIES_GHOST ) ) - { - heatFlux[ startIndex + index ] = c0o1; - return; - } - - ////////////////////////////////////////////////////////////////////////// - - ConservedVariables ghostCons; - - readCellData(ghostCellIndex, dataBase, ghostCons); - - ConservedVariables domainCons; - - readCellData(domainCellIndex, dataBase, domainCons); - - PrimitiveVariables ghostPrim = toPrimitiveVariables(ghostCons, parameters.K); - PrimitiveVariables domainPrim = toPrimitiveVariables(domainCons, parameters.K); - - ////////////////////////////////////////////////////////////////////////// - - real lambda = c1o2 * (ghostPrim.lambda + domainPrim.lambda); - - real r = parameters.lambdaRef / lambda; - - real mu = getViscosity(parameters, r); - - heatFlux[ startIndex + index ] = c1o4 * (parameters.K + c5o1) * ( mu / parameters.Pr ) / parameters.dx * ( c1o1 / domainPrim.lambda - c1o1 / ghostPrim.lambda ); -} - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -HeatFluxAnalyzer::HeatFluxAnalyzer( SPtr<DataBase> dataBase, SPtr<GksGpu::BoundaryCondition> boundaryCondition, uint analyzeIter, uint outputIter, real lambdaHot, real lambdaCold, real L ) - : dataBase(dataBase), - boundaryCondition(boundaryCondition), - analyzeIter(analyzeIter), - outputIter(outputIter), - lambdaHot(lambdaHot), - lambdaCold(lambdaCold), - L(L) -{ -} - -void HeatFluxAnalyzer::writeToFile(std::string filename) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "HeatFluxAnalyzer::writeToFile( " << filename << " )" << "\n"; - - std::ofstream file; - - file.open(filename + ".dat" ); - - for( auto& EKin : this->heatFluxTimeSeries ) - file << std::setprecision(15) << EKin << std::endl; - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -} // namespace GksGpu - - diff --git a/src/gpu/GksGpu/Analyzer/HeatFluxAnalyzer.h b/src/gpu/GksGpu/Analyzer/HeatFluxAnalyzer.h deleted file mode 100644 index e64c24310411095fe09960b9d2ca0550fc7d6cbf..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/HeatFluxAnalyzer.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef HeatFluxAnalyzer_H -#define HeatFluxAnalyzer_H - -#include <vector> -#include <string> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" - -#include "GksGpu/BoundaryConditions/BoundaryCondition.h" - -#include "FlowStateData/FlowStateData.cuh" - -#include "Parameters/Parameters.h" - -namespace GksGpu { - -struct DataBase; - -class GKSGPU_EXPORT HeatFluxAnalyzer -{ -private: - - SPtr<DataBase> dataBase; - SPtr<GksGpu::BoundaryCondition> boundaryCondition; - - uint outputIter; - - uint analyzeIter; - - std::vector<real> heatFluxTimeSeries; - - real lambdaHot; - real lambdaCold; - - real L; - -public: - - HeatFluxAnalyzer( SPtr<DataBase> dataBase, SPtr<GksGpu::BoundaryCondition> boundaryCondition, uint analyzeIter, uint outputIter, real lambdaHot, real lambdaCold, real L ); - - bool run( uint iter, Parameters parameters ); - - void writeToFile( std::string filename ); - -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Analyzer/KineticEnergyAnalyzer.cu b/src/gpu/GksGpu/Analyzer/KineticEnergyAnalyzer.cu deleted file mode 100644 index 70b130e6a3e22c8064f6e82e281ec51855b284ec..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/KineticEnergyAnalyzer.cu +++ /dev/null @@ -1,116 +0,0 @@ -#include "KineticEnergyAnalyzer.h" - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include <cmath> -#include <sstream> - -#include <thrust/device_vector.h> -#include <thrust/reduce.h> -#include <thrust/device_ptr.h> - -#include <iomanip> - -#include "Core/Logger/Logger.h" - -#include "DataBase/DataBase.h" - -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu { - -__global__ void kineticEnergyKernel ( DataBaseStruct dataBase, real* kineticEnergy, uint startIndex, uint numberOfEntities ); - -__host__ __device__ inline void kineticEnergyFunction( DataBaseStruct dataBase, real* kineticEnergy, uint startIndex, uint index ); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -bool KineticEnergyAnalyzer::run(uint iter) -{ - if( iter % this->analyzeIter != 0 ) return false; - - thrust::device_vector<real> kineticEnergy( this->dataBase->perLevelCount[ 0 ].numberOfBulkCells ); - - CudaUtility::CudaGrid grid( dataBase->perLevelCount[ 0 ].numberOfBulkCells, 32 ); - - runKernel( kineticEnergyKernel, - kineticEnergyFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - kineticEnergy.data().get(), - dataBase->perLevelCount[ 0 ].startOfCells ); - - getLastCudaError("KineticEnergyAnalyzer::run(uint iter)"); - - real EKin = thrust::reduce( kineticEnergy.begin(), kineticEnergy.end(), c0o1, thrust::plus<real>() ) - / real(dataBase->perLevelCount[ 0 ].numberOfBulkCells); - - this->kineticEnergyTimeSeries.push_back( EKin ); - - //*logging::out << logging::Logger::INFO_HIGH << "EKin = " << EKin << "\n"; - - return true; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__global__ void kineticEnergyKernel(DataBaseStruct dataBase, real* kineticEnergy, uint startIndex, uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - kineticEnergyFunction( dataBase, kineticEnergy, startIndex, index ); -} - -__host__ __device__ void kineticEnergyFunction(DataBaseStruct dataBase, real* kineticEnergy, uint startIndex, uint index) -{ - uint cellIndex = startIndex + index; - - ////////////////////////////////////////////////////////////////////////// - - ConservedVariables cons; - - cons.rho = dataBase.data[ RHO__(cellIndex, dataBase.numberOfCells) ]; - cons.rhoU = dataBase.data[ RHO_U(cellIndex, dataBase.numberOfCells) ]; - cons.rhoV = dataBase.data[ RHO_V(cellIndex, dataBase.numberOfCells) ]; - cons.rhoW = dataBase.data[ RHO_W(cellIndex, dataBase.numberOfCells) ]; - - ////////////////////////////////////////////////////////////////////////// - - kineticEnergy[ cellIndex ] = c1o2 * ( cons.rhoU * cons.rhoU + cons.rhoV * cons.rhoV + cons.rhoW * cons.rhoW ) / cons.rho; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -KineticEnergyAnalyzer::KineticEnergyAnalyzer(SPtr<DataBase> dataBase, uint analyzeIter, uint outputIter) -{ - this->dataBase = dataBase; - - this->analyzeIter = analyzeIter; - this->outputIter = outputIter; -} - -void KineticEnergyAnalyzer::writeToFile(std::string filename) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "KineticEnergyAnalyzer::writeToFile( " << filename << " )" << "\n"; - - std::ofstream file; - - file.open(filename + ".dat" ); - - for( auto& EKin : this->kineticEnergyTimeSeries ) - file << std::setprecision(15) << EKin << std::endl; - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -} // namespace GksGpu - - diff --git a/src/gpu/GksGpu/Analyzer/KineticEnergyAnalyzer.h b/src/gpu/GksGpu/Analyzer/KineticEnergyAnalyzer.h deleted file mode 100644 index ee69b40988f8105535e5ec77d6c2d1fadb9172e1..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/KineticEnergyAnalyzer.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef KineticEngergyAnalyzer_H -#define KineticEngergyAnalyzer_H - -#include <vector> -#include <string> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" - -#include "FlowStateData/FlowStateData.cuh" - -namespace GksGpu { - -struct DataBase; - -class GKSGPU_EXPORT KineticEnergyAnalyzer -{ -private: - - SPtr<DataBase> dataBase; - - uint outputIter; - - uint analyzeIter; - - std::vector<real> kineticEnergyTimeSeries; - -public: - - KineticEnergyAnalyzer( SPtr<DataBase> dataBase, uint analyzeIter, uint outputIter ); - - bool run( uint iter ); - - void writeToFile( std::string filename ); - -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Analyzer/PointTimeSeriesAnalyzer.cu b/src/gpu/GksGpu/Analyzer/PointTimeSeriesAnalyzer.cu deleted file mode 100644 index bba7a1e88cfc0f227e298258e76097169faae7d9..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/PointTimeSeriesAnalyzer.cu +++ /dev/null @@ -1,196 +0,0 @@ -#include "PointTimeSeriesAnalyzer.h" - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include <cmath> -#include <sstream> - -#include <thrust/device_vector.h> -#include <thrust/host_vector.h> -#include <thrust/reduce.h> -#include <thrust/device_ptr.h> - -#include <iomanip> - -#include "Core/Logger/Logger.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "DataBase/DataBase.h" - -#include "Parameters/Parameters.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu { - -__global__ void pointTimeSeriesKernel ( DataBaseStruct dataBase, PointTimeSeriesAnalyzerStruct pointTimeSeriesAnalyzer, Parameters parameters, uint startIndex, uint numberOfEntities ); - -__host__ __device__ inline void pointTimeSeriesFunction( DataBaseStruct dataBase, PointTimeSeriesAnalyzerStruct pointTimeSeriesAnalyzer, Parameters parameters, uint startIndex, uint index ); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void PointTimeSeriesAnalyzer::run(uint iter, Parameters parameters) -{ - - CudaUtility::CudaGrid grid( 1, 1 ); - - runKernel( pointTimeSeriesKernel, - pointTimeSeriesFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - 0 ); - - getLastCudaError("PointTimeSeriesAnalyzer::run(uint iter, Parameters parameters)"); - - this->counter++; - - if( this->counter == this->outputIter ) - { - this->download(); - this->counter = 0; - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__global__ void pointTimeSeriesKernel(DataBaseStruct dataBase, PointTimeSeriesAnalyzerStruct pointTimeSeriesAnalyzer, Parameters parameters, uint startIndex, uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - pointTimeSeriesFunction( dataBase, pointTimeSeriesAnalyzer, parameters, startIndex, index ); -} - -__host__ __device__ void pointTimeSeriesFunction(DataBaseStruct dataBase, PointTimeSeriesAnalyzerStruct pointTimeSeriesAnalyzer, Parameters parameters, uint startIndex, uint index) -{ - ////////////////////////////////////////////////////////////////////////// - - ConservedVariables cons; - - readCellData(pointTimeSeriesAnalyzer.cellIndex, dataBase, cons); - - PrimitiveVariables prim = toPrimitiveVariables(cons, parameters.K); - - ////////////////////////////////////////////////////////////////////////// - - if( pointTimeSeriesAnalyzer.quantity == 'U' ) pointTimeSeriesAnalyzer.deviceSeries [ pointTimeSeriesAnalyzer.counter ] = prim.U; - if( pointTimeSeriesAnalyzer.quantity == 'V' ) pointTimeSeriesAnalyzer.deviceSeries [ pointTimeSeriesAnalyzer.counter ] = prim.V; - if( pointTimeSeriesAnalyzer.quantity == 'W' ) pointTimeSeriesAnalyzer.deviceSeries [ pointTimeSeriesAnalyzer.counter ] = prim.W; - -#ifdef USE_PASSIVE_SCALAR - if( pointTimeSeriesAnalyzer.quantity == 'T' ) pointTimeSeriesAnalyzer.deviceSeries [ pointTimeSeriesAnalyzer.counter ] = getT(prim); -#else - if( pointTimeSeriesAnalyzer.quantity == 'T' ) pointTimeSeriesAnalyzer.deviceSeries [ pointTimeSeriesAnalyzer.counter ] = c1o1 / prim.lambda; -#endif - - ////////////////////////////////////////////////////////////////////////// -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -PointTimeSeriesAnalyzer::~PointTimeSeriesAnalyzer() -{ - this->free(); -} - -PointTimeSeriesAnalyzer::PointTimeSeriesAnalyzer(SPtr<DataBase> dataBase, GksMeshAdapter & adapter, Vec3 coordinates, char quantity, uint outputIter) - : dataBase(dataBase), - deviceSeries(nullptr), - counter(0), - outputIter(outputIter), - quantity(quantity) -{ - this->allocate(); - - this->findCellIndex( adapter, coordinates ); -} - -void PointTimeSeriesAnalyzer::free() -{ - checkCudaErrors( cudaFree ( this->deviceSeries ) ); -} - -void PointTimeSeriesAnalyzer::allocate() -{ - this->free(); - - checkCudaErrors( cudaMalloc ( &this->deviceSeries , sizeof(real) * this->outputIter ) ); -} - -void PointTimeSeriesAnalyzer::findCellIndex(GksMeshAdapter & adapter, Vec3 coordinates) -{ - real minDistance = 1.0e99; - - for( uint cellIdx = 0 ; cellIdx < adapter.cells.size(); cellIdx++ ) - { - MeshCell& cell = adapter.cells[ cellIdx ]; - - Vec3 vec = cell.cellCenter - coordinates; - - real distance = sqrt( vec.x*vec.x + vec.y*vec.y + vec.z*vec.z ); - - if( distance < minDistance ) - { - this->cellIndex = cellIdx; - minDistance = distance; - } - } - - this->coordinates = adapter.cells[ this->cellIndex ].cellCenter; - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "PointTimeSeriesAnalyzer::cellIndex = " << this->cellIndex << "\n"; -} - -void PointTimeSeriesAnalyzer::writeToFile(std::string filename) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "PointTimeSeriesAnalyzer::writeToFile( " << filename << " )" << "\n"; - - std::ofstream file; - - file.open(filename + ".dat" ); - - for( auto& value : this->hostSeries ) - file << std::setprecision(15) << value << std::endl; - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -PointTimeSeriesAnalyzerStruct PointTimeSeriesAnalyzer::toStruct() -{ - PointTimeSeriesAnalyzerStruct pointTimeSeriesAnalyzer; - - pointTimeSeriesAnalyzer.deviceSeries = this->deviceSeries; - - pointTimeSeriesAnalyzer.quantity = this->quantity; - - pointTimeSeriesAnalyzer.counter = this->counter; - - pointTimeSeriesAnalyzer.cellIndex = this->cellIndex; - - return pointTimeSeriesAnalyzer; -} - -void PointTimeSeriesAnalyzer::download() -{ - uint oldSize = hostSeries.size(); - - this->hostSeries.resize( oldSize + this->outputIter, c0o1 ); - - checkCudaErrors( cudaMemcpy( this->hostSeries.data() + oldSize, this->deviceSeries , sizeof(real) * outputIter, cudaMemcpyDeviceToHost ) ); -} - -} // namespace GksGpu - - diff --git a/src/gpu/GksGpu/Analyzer/PointTimeSeriesAnalyzer.h b/src/gpu/GksGpu/Analyzer/PointTimeSeriesAnalyzer.h deleted file mode 100644 index 658c7a9d0f0b7932c57f5387646d6177d905f497..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/PointTimeSeriesAnalyzer.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef PointTimeSeriesAnalyzer_H -#define PointTimeSeriesAnalyzer_H - -#include <vector> -#include <string> -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -class GksMeshAdapter; - -namespace GksGpu { - -struct DataBase; -struct Parameters; - -struct PointTimeSeriesAnalyzerStruct -{ - real* deviceSeries; - - char quantity; - - uint counter; - - uint cellIndex; -}; - -class GKSGPU_EXPORT PointTimeSeriesAnalyzer -{ -public: - - SPtr<DataBase> dataBase; - - uint outputIter; - - real* deviceSeries; - - char quantity; - - uint counter; - - uint cellIndex; - - std::vector<real> hostSeries; - - Vec3 coordinates; - -public: - - ~PointTimeSeriesAnalyzer(); - - PointTimeSeriesAnalyzer( SPtr<DataBase> dataBase, GksMeshAdapter & adapter, Vec3 coordinates, char quantity, uint outputIter = 10000 ); - - void free(); - - void allocate(); - - void findCellIndex( GksMeshAdapter & adapter, Vec3 coordinates ); - - void run( uint iter, Parameters parameters ); - - void writeToFile( std::string filename ); - - PointTimeSeriesAnalyzerStruct toStruct(); - - void download(); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Analyzer/PointTimeSeriesCollector.cpp b/src/gpu/GksGpu/Analyzer/PointTimeSeriesCollector.cpp deleted file mode 100644 index 81918b256ab84e5ea9c3d9db97dd8962a0bc1b7d..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/PointTimeSeriesCollector.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "PointTimeSeriesCollector.h" - -#include <iomanip> -#include <fstream> - -#include "Core/Logger/Logger.h" - -#include "Analyzer/PointTimeSeriesAnalyzer.h" - -#include "Parameters/Parameters.h" - -namespace GksGpu { - -PointTimeSeriesCollector::~PointTimeSeriesCollector() -{ -} - -PointTimeSeriesCollector::PointTimeSeriesCollector() -{ -} - -void PointTimeSeriesCollector::addAnalyzer(SPtr<DataBase> dataBase, GksMeshAdapter & adapter, Vec3 coordinate, char quantity, uint outputIter) -{ - auto pointTimeSeriesAnalyzer = std::make_shared<PointTimeSeriesAnalyzer>( dataBase, adapter, coordinate, quantity, outputIter ); - - this->analyzerList.push_back( pointTimeSeriesAnalyzer ); -} - -void PointTimeSeriesCollector::run(uint iter, Parameters parameters) -{ - for( auto analyzer : this->analyzerList ) - analyzer->run(iter, parameters); -} - -void PointTimeSeriesCollector::writeToFile(std::string filename) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "PointTimeSeriesCollector::writeToFile( " << filename << " )" << "\n"; - - if( this->analyzerList.size() == 0 ) - { - *logging::out << logging::Logger::WARNING << "empty!\n"; - return; - } - - std::ofstream file; - - file.open(filename + ".dat" ); - - ////////////////////////////////////////////////////////////////////////// - - file << "Number of Points = " << this->analyzerList.size() << "\n"; - - for( uint j = 0; j < this->analyzerList.size(); j++ ) - { - file << "Point " << j << ", "; - file << "Quantity = " << this->analyzerList[j]->quantity << ", "; - file << "Coordinates = ( " << this->analyzerList[j]->coordinates.x << ", " - << this->analyzerList[j]->coordinates.y << ", " - << this->analyzerList[j]->coordinates.z << " )"; - file << "\n"; - } - - ////////////////////////////////////////////////////////////////////////// - - uint numberOfTimeSteps = this->analyzerList[0]->hostSeries.size(); - - for( uint i = 0; i < numberOfTimeSteps; i++ ) - { - for( uint j = 0; j < this->analyzerList.size(); j++ ) - { - file << std::setprecision(15) << this->analyzerList[j]->hostSeries[i] << ", "; - } - - file << "\n"; - } - - ////////////////////////////////////////////////////////////////////////// - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/Analyzer/PointTimeSeriesCollector.h b/src/gpu/GksGpu/Analyzer/PointTimeSeriesCollector.h deleted file mode 100644 index 6725e7658b59cfe61aa28fbec1e54fe154f2318e..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/PointTimeSeriesCollector.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef PointTimeSeriesCelloctor_H -#define PointTimeSeriesCelloctor_H - - -#include <vector> -#include <string> -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -class GksMeshAdapter; - -namespace GksGpu { - -class PointTimeSeriesAnalyzer; -struct DataBase; -struct Parameters; - -class GKSGPU_EXPORT PointTimeSeriesCollector -{ -public: - - std::vector< SPtr<PointTimeSeriesAnalyzer> > analyzerList; - -public: - - ~PointTimeSeriesCollector(); - - PointTimeSeriesCollector( ); - - void addAnalyzer( SPtr<DataBase> dataBase, GksMeshAdapter & adapter, Vec3 coordinate, char quantity, uint outputIter = 10000 ); - - void run( uint iter, Parameters parameters ); - - void writeToFile( std::string filename ); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Analyzer/TurbulenceAnalyzer.cu b/src/gpu/GksGpu/Analyzer/TurbulenceAnalyzer.cu deleted file mode 100644 index 5e896e03e7f02b63759f4ff6d42ca7f7f5e7bfa5..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/TurbulenceAnalyzer.cu +++ /dev/null @@ -1,433 +0,0 @@ -#include "TurbulenceAnalyzer.h" - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include <cmath> -#include <sstream> - -#include <thrust/device_vector.h> -#include <thrust/host_vector.h> -#include <thrust/reduce.h> -#include <thrust/device_ptr.h> - -#include <iomanip> - -#include "Core/Logger/Logger.h" - -#include "DataBase/DataBase.h" - -#include "Parameters/Parameters.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu { - -__global__ void turbulenceKernel ( DataBaseStruct dataBase, TurbulenceAnalyzerStruct turbulenceAnalyzer, Parameters parameters, uint startIndex, uint numberOfEntities ); - -__host__ __device__ inline void turbulenceFunction( DataBaseStruct dataBase, TurbulenceAnalyzerStruct turbulenceAnalyzer, Parameters parameters, uint startIndex, uint index ); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -bool TurbulenceAnalyzer::run(uint iter, Parameters parameters) -{ - if( iter < this->analyzeStartIter ) return false; - - CudaUtility::CudaGrid grid( dataBase->numberOfCells, 32 ); - - runKernel( turbulenceKernel, - turbulenceFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - 0 ); - - getLastCudaError("TurbulenceAnalyzer::run(uint iter, Parameters parameters)"); - - this->counter++; - - return true; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__global__ void turbulenceKernel(DataBaseStruct dataBase, TurbulenceAnalyzerStruct turbulenceAnalyzer, Parameters parameters, uint startIndex, uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - turbulenceFunction( dataBase, turbulenceAnalyzer, parameters, startIndex, index ); -} - -__host__ __device__ void turbulenceFunction(DataBaseStruct dataBase, TurbulenceAnalyzerStruct turbulenceAnalyzer, Parameters parameters, uint startIndex, uint index) -{ - uint cellIndex = startIndex + index; - - ////////////////////////////////////////////////////////////////////////// - - ConservedVariables cons; - - readCellData(cellIndex, dataBase, cons); - - PrimitiveVariables prim = toPrimitiveVariables(cons, parameters.K); - - ////////////////////////////////////////////////////////////////////////// - - if( turbulenceAnalyzer.U ) turbulenceAnalyzer.U [ cellIndex ] += prim.U; - if( turbulenceAnalyzer.V ) turbulenceAnalyzer.V [ cellIndex ] += prim.V; - if( turbulenceAnalyzer.W ) turbulenceAnalyzer.W [ cellIndex ] += prim.W; - - if( turbulenceAnalyzer.UU ) turbulenceAnalyzer.UU[ cellIndex ] += prim.U * prim.U; - if( turbulenceAnalyzer.VV ) turbulenceAnalyzer.VV[ cellIndex ] += prim.V * prim.V; - if( turbulenceAnalyzer.WW ) turbulenceAnalyzer.WW[ cellIndex ] += prim.W * prim.W; - - if( turbulenceAnalyzer.UV ) turbulenceAnalyzer.UV[ cellIndex ] += prim.U * prim.V; - if( turbulenceAnalyzer.UW ) turbulenceAnalyzer.UW[ cellIndex ] += prim.U * prim.W; - if( turbulenceAnalyzer.VW ) turbulenceAnalyzer.VW[ cellIndex ] += prim.V * prim.W; - -#ifdef USE_PASSIVE_SCALAR - if( turbulenceAnalyzer.T ) turbulenceAnalyzer.T [ cellIndex ] += getT(prim); -#else - if( turbulenceAnalyzer.T ) turbulenceAnalyzer.T [ cellIndex ] += c1o1 / prim.lambda; -#endif - - if( turbulenceAnalyzer.TT ) turbulenceAnalyzer.TT[ cellIndex ] += ( c1o1 / prim.lambda ) * ( c1o1 / prim.lambda ); - if( turbulenceAnalyzer.p ) turbulenceAnalyzer.p [ cellIndex ] += c1o2 * prim.rho / prim.lambda; - - ////////////////////////////////////////////////////////////////////////// -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -TurbulenceAnalyzer::~TurbulenceAnalyzer() -{ - this->free(); -} - -TurbulenceAnalyzer::TurbulenceAnalyzer(SPtr<DataBase> dataBase, uint analyzeStartIter) - : U ( nullptr ), - V ( nullptr ), - W ( nullptr ), - UU( nullptr ), - VV( nullptr ), - WW( nullptr ), - UV( nullptr ), - UW( nullptr ), - VW( nullptr ), - T ( nullptr ), - TT( nullptr ), - p ( nullptr ), - collect_U ( true ), - collect_V ( true ), - collect_W ( true ), - collect_UU( false ), - collect_VV( false ), - collect_WW( false ), - collect_UV( false ), - collect_UW( false ), - collect_VW( false ), - collect_T ( true ), - collect_TT( false ), - collect_p ( false ) -{ - this->dataBase = dataBase; - - this->analyzeStartIter = analyzeStartIter; - - this->counter = 0; - - this->allocate(); -} - -void TurbulenceAnalyzer::free() -{ - if( this->U ) checkCudaErrors( cudaFree ( this->U ) ); - if( this->V ) checkCudaErrors( cudaFree ( this->V ) ); - if( this->W ) checkCudaErrors( cudaFree ( this->W ) ); - if( this->UU ) checkCudaErrors( cudaFree ( this->UU ) ); - if( this->VV ) checkCudaErrors( cudaFree ( this->VV ) ); - if( this->WW ) checkCudaErrors( cudaFree ( this->WW ) ); - if( this->UV ) checkCudaErrors( cudaFree ( this->UV ) ); - if( this->UW ) checkCudaErrors( cudaFree ( this->UW ) ); - if( this->VW ) checkCudaErrors( cudaFree ( this->VW ) ); - if( this->T ) checkCudaErrors( cudaFree ( this->T ) ); - if( this->TT ) checkCudaErrors( cudaFree ( this->TT ) ); - if( this->p ) checkCudaErrors( cudaFree ( this->p ) ); - - h_U.clear ( ); - h_V.clear ( ); - h_W.clear ( ); - h_UU.clear( ); - h_VV.clear( ); - h_WW.clear( ); - h_UV.clear( ); - h_UW.clear( ); - h_VW.clear( ); - h_T.clear ( ); - h_TT.clear( ); - h_p.clear ( ); -} - -void TurbulenceAnalyzer::allocate() -{ - this->free(); - - if( collect_U ) checkCudaErrors( cudaMalloc ( &this->U , sizeof(real) * dataBase->numberOfCells ) ); - if( collect_V ) checkCudaErrors( cudaMalloc ( &this->V , sizeof(real) * dataBase->numberOfCells ) ); - if( collect_W ) checkCudaErrors( cudaMalloc ( &this->W , sizeof(real) * dataBase->numberOfCells ) ); - if( collect_UU ) checkCudaErrors( cudaMalloc ( &this->UU, sizeof(real) * dataBase->numberOfCells ) ); - if( collect_VV ) checkCudaErrors( cudaMalloc ( &this->VV, sizeof(real) * dataBase->numberOfCells ) ); - if( collect_WW ) checkCudaErrors( cudaMalloc ( &this->WW, sizeof(real) * dataBase->numberOfCells ) ); - if( collect_UV ) checkCudaErrors( cudaMalloc ( &this->UV, sizeof(real) * dataBase->numberOfCells ) ); - if( collect_UW ) checkCudaErrors( cudaMalloc ( &this->UW, sizeof(real) * dataBase->numberOfCells ) ); - if( collect_VW ) checkCudaErrors( cudaMalloc ( &this->VW, sizeof(real) * dataBase->numberOfCells ) ); - if( collect_T ) checkCudaErrors( cudaMalloc ( &this->T , sizeof(real) * dataBase->numberOfCells ) ); - if( collect_TT ) checkCudaErrors( cudaMalloc ( &this->TT, sizeof(real) * dataBase->numberOfCells ) ); - if( collect_p ) checkCudaErrors( cudaMalloc ( &this->p , sizeof(real) * dataBase->numberOfCells ) ); - - if( collect_U ) h_U.resize ( dataBase->numberOfCells ); - if( collect_V ) h_V.resize ( dataBase->numberOfCells ); - if( collect_W ) h_W.resize ( dataBase->numberOfCells ); - if( collect_UU ) h_UU.resize( dataBase->numberOfCells ); - if( collect_VV ) h_VV.resize( dataBase->numberOfCells ); - if( collect_WW ) h_WW.resize( dataBase->numberOfCells ); - if( collect_UV ) h_UV.resize( dataBase->numberOfCells ); - if( collect_UW ) h_UW.resize( dataBase->numberOfCells ); - if( collect_VW ) h_VW.resize( dataBase->numberOfCells ); - if( collect_T ) h_T.resize ( dataBase->numberOfCells ); - if( collect_TT ) h_TT.resize( dataBase->numberOfCells ); - if( collect_p ) h_p.resize ( dataBase->numberOfCells ); -} - -void TurbulenceAnalyzer::writeRestartFile(std::string filename) -{ - this->download(false); - - ////////////////////////////////////////////////////////////////////////// - - filename += ".rst"; - - *logging::out << logging::Logger::INFO_HIGH << "Writing restart file " << filename << " ... "; - - std::ofstream file; - - file.open( filename.c_str(), std::ios::binary ); - - if (!file.is_open()) { - throw std::runtime_error("\nFile cannot be opened.\n\nERROR!\n\n\n"); - return; - } - - ////////////////////////////////////////////////////////////////////////// - - file.write( (char*) &this->counter, sizeof( uint ) ); - - file.write( (char*) &dataBase->numberOfLevels, sizeof( uint ) ); - file.write( (char*) &dataBase->numberOfCells, sizeof( uint ) ); - file.write( (char*) &dataBase->numberOfFaces, sizeof( uint ) ); - - file.write( (char*) &this->collect_U , sizeof( bool ) ); - file.write( (char*) &this->collect_V , sizeof( bool ) ); - file.write( (char*) &this->collect_W , sizeof( bool ) ); - file.write( (char*) &this->collect_UU, sizeof( bool ) ); - file.write( (char*) &this->collect_VV, sizeof( bool ) ); - file.write( (char*) &this->collect_WW, sizeof( bool ) ); - file.write( (char*) &this->collect_UV, sizeof( bool ) ); - file.write( (char*) &this->collect_UW, sizeof( bool ) ); - file.write( (char*) &this->collect_VW, sizeof( bool ) ); - file.write( (char*) &this->collect_T , sizeof( bool ) ); - file.write( (char*) &this->collect_TT, sizeof( bool ) ); - file.write( (char*) &this->collect_p , sizeof( bool ) ); - - if( collect_U ) file.write( (char*) this->h_U.data() , dataBase->numberOfCells * sizeof( real ) ); - if( collect_V ) file.write( (char*) this->h_V.data() , dataBase->numberOfCells * sizeof( real ) ); - if( collect_W ) file.write( (char*) this->h_W.data() , dataBase->numberOfCells * sizeof( real ) ); - if( collect_UU ) file.write( (char*) this->h_UU.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_VV ) file.write( (char*) this->h_VV.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_WW ) file.write( (char*) this->h_WW.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_UV ) file.write( (char*) this->h_UV.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_UW ) file.write( (char*) this->h_UW.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_VW ) file.write( (char*) this->h_VW.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_T ) file.write( (char*) this->h_T.data() , dataBase->numberOfCells * sizeof( real ) ); - if( collect_TT ) file.write( (char*) this->h_TT.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_p ) file.write( (char*) this->h_p.data() , dataBase->numberOfCells * sizeof( real ) ); - - ////////////////////////////////////////////////////////////////////////// - - file.close(); - - *logging::out << logging::Logger::INFO_HIGH << "done!\n"; -} - -void TurbulenceAnalyzer::readRestartFile(std::string filename) -{ - filename += ".rst"; - - *logging::out << logging::Logger::INFO_HIGH << "Reading restart file " << filename << " ... "; - - std::ifstream file; - - file.open( filename.c_str(), std::ios::binary ); - - if (!file.is_open()) { - throw std::runtime_error("\nFile cannot be opened.\n\nERROR!\n\n\n"); - return; - } - - ////////////////////////////////////////////////////////////////////////// - - file.read( (char*) &this->counter, sizeof( uint ) ); - - uint numberOfLevelsRead; - uint numberOfCellsRead; - uint numberOfFacesRead; - - file.read( (char*) &numberOfLevelsRead, sizeof( uint ) ); - file.read( (char*) &numberOfCellsRead, sizeof( uint ) ); - file.read( (char*) &numberOfFacesRead, sizeof( uint ) ); - - if( numberOfLevelsRead != dataBase->numberOfLevels || - numberOfCellsRead != dataBase->numberOfCells || - numberOfFacesRead != dataBase->numberOfFaces ){ - - *logging::out << logging::Logger::INFO_HIGH << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "Levels: " << numberOfLevelsRead << " vs. " << dataBase->numberOfLevels << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "Cells: " << numberOfCellsRead << " vs. " << dataBase->numberOfCells << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "Faces: " << numberOfFacesRead << " vs. " << dataBase->numberOfFaces << "\n"; - - file.close(); - - throw std::runtime_error("\nERROR: Restart file does not match current setup"); - } - - ////////////////////////////////////////////////////////////////////////// - - file.read( (char*) &this->collect_U , sizeof( bool ) ); - file.read( (char*) &this->collect_V , sizeof( bool ) ); - file.read( (char*) &this->collect_W , sizeof( bool ) ); - file.read( (char*) &this->collect_UU, sizeof( bool ) ); - file.read( (char*) &this->collect_VV, sizeof( bool ) ); - file.read( (char*) &this->collect_WW, sizeof( bool ) ); - file.read( (char*) &this->collect_UV, sizeof( bool ) ); - file.read( (char*) &this->collect_UW, sizeof( bool ) ); - file.read( (char*) &this->collect_VW, sizeof( bool ) ); - file.read( (char*) &this->collect_T , sizeof( bool ) ); - file.read( (char*) &this->collect_TT, sizeof( bool ) ); - file.read( (char*) &this->collect_p , sizeof( bool ) ); - - if( collect_U ) file.read( (char*) this->h_U.data() , dataBase->numberOfCells * sizeof( real ) ); - if( collect_V ) file.read( (char*) this->h_V.data() , dataBase->numberOfCells * sizeof( real ) ); - if( collect_W ) file.read( (char*) this->h_W.data() , dataBase->numberOfCells * sizeof( real ) ); - if( collect_UU ) file.read( (char*) this->h_UU.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_VV ) file.read( (char*) this->h_VV.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_WW ) file.read( (char*) this->h_WW.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_UV ) file.read( (char*) this->h_UV.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_UW ) file.read( (char*) this->h_UW.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_VW ) file.read( (char*) this->h_VW.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_T ) file.read( (char*) this->h_T.data() , dataBase->numberOfCells * sizeof( real ) ); - if( collect_TT ) file.read( (char*) this->h_TT.data(), dataBase->numberOfCells * sizeof( real ) ); - if( collect_p ) file.read( (char*) this->h_p.data() , dataBase->numberOfCells * sizeof( real ) ); - - ////////////////////////////////////////////////////////////////////////// - - file.close(); - - this->upload(); - - *logging::out << logging::Logger::INFO_HIGH << "done!\n"; -} - -TurbulenceAnalyzerStruct TurbulenceAnalyzer::toStruct() -{ - TurbulenceAnalyzerStruct turbulenceAnalyzer; - - turbulenceAnalyzer.U = this->U; - turbulenceAnalyzer.V = this->V; - turbulenceAnalyzer.W = this->W; - - turbulenceAnalyzer.UU = this->UU; - turbulenceAnalyzer.VV = this->VV; - turbulenceAnalyzer.WW = this->WW; - - turbulenceAnalyzer.UV = this->UV; - turbulenceAnalyzer.UW = this->UW; - turbulenceAnalyzer.VW = this->VW; - - turbulenceAnalyzer.T = this->T; - turbulenceAnalyzer.TT = this->TT; - turbulenceAnalyzer.p = this->p; - - return turbulenceAnalyzer; -} - -void TurbulenceAnalyzer::download(bool normalize) -{ - if( collect_U ) checkCudaErrors( cudaMemcpy( this->h_U.data() , this->U , sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - if( collect_V ) checkCudaErrors( cudaMemcpy( this->h_V.data() , this->V , sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - if( collect_W ) checkCudaErrors( cudaMemcpy( this->h_W.data() , this->W , sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - if( collect_UU ) checkCudaErrors( cudaMemcpy( this->h_UU.data(), this->UU, sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - if( collect_VV ) checkCudaErrors( cudaMemcpy( this->h_VV.data(), this->VV, sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - if( collect_WW ) checkCudaErrors( cudaMemcpy( this->h_WW.data(), this->WW, sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - if( collect_UV ) checkCudaErrors( cudaMemcpy( this->h_UV.data(), this->UV, sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - if( collect_UW ) checkCudaErrors( cudaMemcpy( this->h_UW.data(), this->UW, sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - if( collect_VW ) checkCudaErrors( cudaMemcpy( this->h_VW.data(), this->VW, sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - if( collect_T ) checkCudaErrors( cudaMemcpy( this->h_T.data() , this->T , sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - if( collect_TT ) checkCudaErrors( cudaMemcpy( this->h_TT.data(), this->TT, sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - if( collect_p ) checkCudaErrors( cudaMemcpy( this->h_p.data() , this->p , sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - - if(normalize) - { - for( uint cellIndex = 0; cellIndex < dataBase->numberOfCells; cellIndex++ ) - { - if( collect_U ) this->h_U [ cellIndex ] /= real(this->counter); - if( collect_V ) this->h_V [ cellIndex ] /= real(this->counter); - if( collect_W ) this->h_W [ cellIndex ] /= real(this->counter); - if( collect_UU ) this->h_UU[ cellIndex ] /= real(this->counter); - if( collect_VV ) this->h_VV[ cellIndex ] /= real(this->counter); - if( collect_WW ) this->h_WW[ cellIndex ] /= real(this->counter); - if( collect_UV ) this->h_UV[ cellIndex ] /= real(this->counter); - if( collect_UW ) this->h_UW[ cellIndex ] /= real(this->counter); - if( collect_VW ) this->h_VW[ cellIndex ] /= real(this->counter); - if( collect_T ) this->h_T [ cellIndex ] /= real(this->counter); - if( collect_TT ) this->h_TT[ cellIndex ] /= real(this->counter); - if( collect_p ) this->h_p [ cellIndex ] /= real(this->counter); - - if( collect_UU ) this->h_UU[ cellIndex ] -= this->h_U[ cellIndex ] * this->h_U[ cellIndex ]; - if( collect_VV ) this->h_VV[ cellIndex ] -= this->h_V[ cellIndex ] * this->h_V[ cellIndex ]; - if( collect_WW ) this->h_WW[ cellIndex ] -= this->h_W[ cellIndex ] * this->h_W[ cellIndex ]; - - if( collect_UV ) this->h_UV[ cellIndex ] -= this->h_U[ cellIndex ] * this->h_V[ cellIndex ]; - if( collect_UW ) this->h_UW[ cellIndex ] -= this->h_U[ cellIndex ] * this->h_W[ cellIndex ]; - if( collect_VW ) this->h_VW[ cellIndex ] -= this->h_V[ cellIndex ] * this->h_W[ cellIndex ]; - - if( collect_TT ) this->h_TT[ cellIndex ] -= this->h_T[ cellIndex ] * this->h_T[ cellIndex ]; - } - } -} - -void TurbulenceAnalyzer::upload() -{ - if( collect_U ) checkCudaErrors( cudaMemcpy( this->U , this->h_U.data() , sizeof(real) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - if( collect_V ) checkCudaErrors( cudaMemcpy( this->V , this->h_V.data() , sizeof(real) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - if( collect_W ) checkCudaErrors( cudaMemcpy( this->W , this->h_W.data() , sizeof(real) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - if( collect_UU ) checkCudaErrors( cudaMemcpy( this->UU, this->h_UU.data(), sizeof(real) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - if( collect_VV ) checkCudaErrors( cudaMemcpy( this->VV, this->h_VV.data(), sizeof(real) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - if( collect_WW ) checkCudaErrors( cudaMemcpy( this->WW, this->h_WW.data(), sizeof(real) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - if( collect_UV ) checkCudaErrors( cudaMemcpy( this->UV, this->h_UV.data(), sizeof(real) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - if( collect_UW ) checkCudaErrors( cudaMemcpy( this->UW, this->h_UW.data(), sizeof(real) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - if( collect_VW ) checkCudaErrors( cudaMemcpy( this->VW, this->h_VW.data(), sizeof(real) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - if( collect_T ) checkCudaErrors( cudaMemcpy( this->T , this->h_T.data() , sizeof(real) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - if( collect_TT ) checkCudaErrors( cudaMemcpy( this->TT, this->h_TT.data(), sizeof(real) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - if( collect_p ) checkCudaErrors( cudaMemcpy( this->p , this->h_p.data() , sizeof(real) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); -} - -} // namespace GksGpu - - diff --git a/src/gpu/GksGpu/Analyzer/TurbulenceAnalyzer.h b/src/gpu/GksGpu/Analyzer/TurbulenceAnalyzer.h deleted file mode 100644 index 1f9f3d7338733d48ca4ffb237f09f864566896a4..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Analyzer/TurbulenceAnalyzer.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef TurbulenceAnalyzer_H -#define TurbulenceAnalyzer_H - -#include <vector> -#include <string> -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" - -#include "FlowStateData/FlowStateData.cuh" - -namespace GksGpu { - -struct DataBase; -struct Parameters; - -struct TurbulenceAnalyzerStruct -{ - uint counter; - - real* U ; - real* V ; - real* W ; - - real* UU; - real* VV; - real* WW; - - real* UV; - real* UW; - real* VW; - - real* T ; - real* TT; - - real* p ; -}; - -class GKSGPU_EXPORT TurbulenceAnalyzer -{ -private: - - SPtr<DataBase> dataBase; - - uint analyzeStartIter; - - real* U ; - real* V ; - real* W ; - - real* UU; - real* VV; - real* WW; - - real* UV; - real* UW; - real* VW; - - real* T ; - real* TT; - real* p ; - -public: - - uint counter; - - std::vector<real> h_U ; - std::vector<real> h_V ; - std::vector<real> h_W ; - - std::vector<real> h_UU; - std::vector<real> h_VV; - std::vector<real> h_WW; - - std::vector<real> h_UV; - std::vector<real> h_UW; - std::vector<real> h_VW; - - std::vector<real> h_T ; - std::vector<real> h_TT; - std::vector<real> h_p ; - - bool collect_U ; - bool collect_V ; - bool collect_W ; - - bool collect_UU; - bool collect_VV; - bool collect_WW; - - bool collect_UV; - bool collect_UW; - bool collect_VW; - - bool collect_T ; - bool collect_TT; - bool collect_p ; - -public: - - ~TurbulenceAnalyzer(); - - TurbulenceAnalyzer( SPtr<DataBase> dataBase, uint analyzeStartIter ); - - void free(); - - void allocate(); - - bool run( uint iter, Parameters parameters ); - - void writeRestartFile( std::string filename ); - - void readRestartFile( std::string filename ); - - TurbulenceAnalyzerStruct toStruct(); - - void download(bool normalize = true); - - void upload(); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/AdiabaticWall.cu b/src/gpu/GksGpu/BoundaryConditions/AdiabaticWall.cu deleted file mode 100644 index a5b6a8812283528975461f50fc0d10ee5a0aeb6b..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/AdiabaticWall.cu +++ /dev/null @@ -1,162 +0,0 @@ -#include "AdiabaticWall.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const AdiabaticWallStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const AdiabaticWallStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void AdiabaticWall::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - //cudaDeviceSynchronize(); - - getLastCudaError("AdiabaticWall::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const AdiabaticWallStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const AdiabaticWallStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - uint secondCellIdx = boundaryCondition.secondCells[ startIndex + index ]; - - PrimitiveVariables ghostCellPrim; - { - PrimitiveVariables domainCellPrim; - PrimitiveVariables secondCellPrim; - - { - ConservedVariables domainCellData; - readCellData( domainCellIdx, dataBase, domainCellData ); - domainCellPrim = toPrimitiveVariables( domainCellData, parameters.K ); - - ConservedVariables secondCellData; - if( secondCellIdx != INVALID_INDEX ){ - readCellData( secondCellIdx, dataBase, secondCellData ); - secondCellPrim = toPrimitiveVariables( secondCellData, parameters.K ); - } - } - - ghostCellPrim.U = c2o1 * boundaryCondition.velocity.x - domainCellPrim.U; - ghostCellPrim.V = c2o1 * boundaryCondition.velocity.y - domainCellPrim.V; - ghostCellPrim.W = c2o1 * boundaryCondition.velocity.z - domainCellPrim.W; - - ghostCellPrim.lambda = domainCellPrim.lambda; - #ifdef USE_PASSIVE_SCALAR - ghostCellPrim.S_1 = domainCellPrim.S_1; - ghostCellPrim.S_2 = domainCellPrim.S_2; - #endif // USE_PASSIVE_SCALAR - - - if( boundaryCondition.useSecondCells && secondCellIdx != INVALID_INDEX ){ - real p1 = c1o2 * domainCellPrim.rho / domainCellPrim.lambda; - real p2 = c1o2 * secondCellPrim.rho / secondCellPrim.lambda; - - ghostCellPrim.rho = c2o1 * ( c2o1 * p1 - p2 ) * ghostCellPrim.lambda; - } - else{ - real p = c1o2 * domainCellPrim.rho / domainCellPrim.lambda; - - ghostCellPrim.rho = c2o1 * p * ghostCellPrim.lambda; - } - } - - { - ConservedVariables ghostCons = toConservedVariables( ghostCellPrim, parameters.K ); - - writeCellData( ghostCellIdx, dataBase, ghostCons ); - } -} - -AdiabaticWall::AdiabaticWall(SPtr<DataBase> dataBase, Vec3 velocity, bool useSecondCells) - : BoundaryCondition( dataBase ) -{ - this->velocity = velocity; - this->useSecondCells = useSecondCells; -} - -bool AdiabaticWall::isWall() -{ - return true; -} - -bool AdiabaticWall::isInsulated() -{ - return true; -} - -bool AdiabaticWall::secondCellsNeeded() -{ - return true; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/AdiabaticWall.h b/src/gpu/GksGpu/BoundaryConditions/AdiabaticWall.h deleted file mode 100644 index 88519dc3d145f6c09e8b9cc5135803c53245a378..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/AdiabaticWall.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef AdiabaticWall_CUH -#define AdiabaticWall_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct AdiabaticWallStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - Vec3 velocity; - - bool useSecondCells; -}; - -struct GKSGPU_EXPORT AdiabaticWall : public BoundaryCondition //, public IsothermalWallStruct -{ - Vec3 velocity; - - bool useSecondCells; - - AdiabaticWall( SPtr<DataBase> dataBase, Vec3 velocity, bool useSecondCells ); - - virtual bool isWall() override; - - virtual bool isInsulated() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - AdiabaticWallStruct toStruct() - { - AdiabaticWallStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.velocity = this->velocity; - - boundaryCondition.useSecondCells = this->useSecondCells; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/BoundaryCondition.cpp b/src/gpu/GksGpu/BoundaryConditions/BoundaryCondition.cpp deleted file mode 100644 index fb1ddb1ff7db9d1b6da0115a25aab87f029537fc..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/BoundaryCondition.cpp +++ /dev/null @@ -1,133 +0,0 @@ -#include "BoundaryCondition.h" - -#include <memory> -#include <vector> - -#include "GridGenerator/grid/NodeValues.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseAllocator.h" -#include "DataBase/DataBaseStruct.h" - -using namespace vf::gpu; - -namespace GksGpu{ - -BoundaryCondition::BoundaryCondition( SPtr<DataBase> dataBase ) - : myAllocator ( dataBase->myAllocator ) -{ - numberOfCells = INVALID_INDEX; - ghostCells = nullptr; - domainCells = nullptr; - secondCells = nullptr; -} - -BoundaryCondition::~BoundaryCondition() -{ - this->myAllocator->freeMemory( *this ); -} - -void BoundaryCondition::findBoundaryCells(GksMeshAdapter & adapter, bool allowGhostCells, std::function<bool(Vec3)> boundaryFinder) -{ - this->myAllocator->freeMemory( *this ); - - std::vector<uint> ghostCells; - std::vector<uint> domainCells; - std::vector<uint> secondCells; - - numberOfCellsPerLevel.resize( adapter.numberOfLevels ); - startOfCellsPerLevel.resize ( adapter.numberOfLevels ); - - for( auto& n : numberOfCellsPerLevel ) n = 0; - - for( uint level = 0; level < adapter.numberOfLevels; level++ ) - { - uint startIdx = adapter.startOfCellsPerLevel[level] - + adapter.numberOfBulkCellsPerLevel[level]; - - uint endIdx = adapter.startOfCellsPerLevel[level] - + adapter.numberOfCellsPerLevel[level]; - - for( uint cellIdx = startIdx ; cellIdx < endIdx; cellIdx++ ) - { - MeshCell& cell = adapter.cells[ cellIdx ]; - - if( !boundaryFinder( cell.cellCenter ) ) continue; - - if( cell.type != STOPPER_OUT_OF_GRID && cell.type != STOPPER_OUT_OF_GRID_BOUNDARY && cell.type != STOPPER_SOLID ) continue; - - if( cell.isRecvCell ) continue; - - // look in all directions - uint maximalSearchDirection = 27; - - // in case of Flux BC look only at face neighbors - if( this->isFluxBC() ) maximalSearchDirection = 6; - - for( uint idx = 0; idx < maximalSearchDirection; idx++ ) - { - uint neighborCellIdx = cell.cellToCell[ idx ]; - - if( neighborCellIdx == INVALID_INDEX ) continue; - - MeshCell& neighborCell = adapter.cells[ neighborCellIdx ]; - - bool neighborCellIsFluid = neighborCell.type != STOPPER_OUT_OF_GRID && - neighborCell.type != STOPPER_OUT_OF_GRID_BOUNDARY && - neighborCell.type != STOPPER_SOLID; - - bool neighborCellIsValidGhostCell = !this->isFluxBC() && allowGhostCells && !boundaryFinder( neighborCell.cellCenter ); - - if( neighborCellIsFluid || neighborCellIsValidGhostCell ) - { - ghostCells.push_back ( cellIdx ); - domainCells.push_back( neighborCellIdx ); - - this->numberOfCellsPerLevel[ level ]++; - - if( this->secondCellsNeeded() ) - { - secondCells.push_back( neighborCell.cellToCell[ idx ] ); - } - - if( this->isWall() ) cell.isWall = this->isWall(); - if( this->isFluxBC() ) cell.isFluxBC = this->isFluxBC(); - if( this->isInsulated() ) cell.isInsulated = this->isInsulated(); - - break; - } - } - } - } - - startOfCellsPerLevel[ 0 ] = 0; - - for( uint level = 1; level < adapter.numberOfLevels; level++ ) - { - startOfCellsPerLevel[ level ] = startOfCellsPerLevel [ level - 1 ] - + numberOfCellsPerLevel[ level - 1 ]; - } - - this->numberOfCells = ghostCells.size(); - - this->myAllocator->allocateMemory( shared_from_this(), ghostCells, domainCells, secondCells ); -} - -bool BoundaryCondition::isFluxBC() -{ - return false; -} - -bool BoundaryCondition::isInsulated() -{ - return false; -} - -bool BoundaryCondition::secondCellsNeeded() -{ - return false; -} - -} // namespace GksGpu \ No newline at end of file diff --git a/src/gpu/GksGpu/BoundaryConditions/BoundaryCondition.h b/src/gpu/GksGpu/BoundaryConditions/BoundaryCondition.h deleted file mode 100644 index 9c3bac9c3e2795fa99f339461c6a7f2d16448696..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/BoundaryCondition.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef BoundaryCondition_H -#define BoundaryCondition_H - -#include <functional> - -#include <memory> -#include <vector> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "Parameters/Parameters.h" - -class GksMeshAdapter; - -namespace GksGpu{ - -class DataBaseAllocator; -struct DataBase; - -struct BoundaryConditionStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; -}; - -struct GKSGPU_EXPORT BoundaryCondition : virtual public BoundaryConditionStruct, public std::enable_shared_from_this<BoundaryCondition> -{ - SPtr<DataBaseAllocator> myAllocator; - - std::vector<uint> numberOfCellsPerLevel; - std::vector<uint> startOfCellsPerLevel; - - BoundaryCondition( SPtr<DataBase> dataBase ); - - ~BoundaryCondition(); - - virtual void findBoundaryCells( GksMeshAdapter& adapter, bool allowGhostCells, std::function<bool(Vec3)> boundaryFinder); - - virtual bool isWall() = 0; - - virtual bool isFluxBC(); - - virtual bool isInsulated(); - - virtual bool secondCellsNeeded(); - - virtual void runBoundaryConditionKernel( const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level ) = 0; - - BoundaryConditionStruct toStruct() - { - BoundaryConditionStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - return boundaryCondition; - } - -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/ConcreteHeatFlux.cu b/src/gpu/GksGpu/BoundaryConditions/ConcreteHeatFlux.cu deleted file mode 100644 index 61f001d7b082be04b07dde525d9b0a961e6f89e4..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/ConcreteHeatFlux.cu +++ /dev/null @@ -1,231 +0,0 @@ -#include "ConcreteHeatFlux.h" - -#define _USE_MATH_DEFINES -#include <math.h> -#include <iostream> - -#include <thrust/host_vector.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" -#include "Core/Logger/Logger.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" -#include "FlowStateData/ThermalDependencies.cuh" - -#include "FluxComputation/Moments.cuh" -#include "FluxComputation/ApplyFlux.cuh" -#include "FluxComputation/Transformation.cuh" -#include "FluxComputation/AssembleFlux.cuh" -#include "FluxComputation/ExpansionCoefficients.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const ConcreteHeatFluxStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const ConcreteHeatFluxStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void ConcreteHeatFlux::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - cudaDeviceSynchronize(); - - getLastCudaError("HeatFlux::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const ConcreteHeatFluxStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const ConcreteHeatFluxStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ -#ifdef USE_PASSIVE_SCALAR - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - uint secondCellIdx = boundaryCondition.secondCells[ startIndex + index ]; - - real dx = boundaryCondition.L / real(boundaryCondition.numberOfPoints + 1); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - PrimitiveVariables domainCellPrim; - { - ConservedVariables domainCellData; - readCellData(domainCellIdx, dataBase, domainCellData); - domainCellPrim = toPrimitiveVariables(domainCellData, parameters.K); - } - PrimitiveVariables secondCellPrim; - { - ConservedVariables secondCellData; - readCellData(secondCellIdx, dataBase, secondCellData); - secondCellPrim = toPrimitiveVariables(secondCellData, parameters.K); - } - - real TF = c3o2 * getT(domainCellPrim) - c1o2 * getT(secondCellPrim); - //real TF = getT(domainCellPrim); - - for( uint i = 0; i < boundaryCondition.numberOfPoints; i++ ) - { - uint finiteDifferenceIndex = ( startIndex + index ) * boundaryCondition.numberOfPoints + i; - - real T0 = boundaryCondition.temperatures[ finiteDifferenceIndex ]; - - real Tn; - if( i == 0 ) - Tn = TF; - else - Tn = boundaryCondition.temperatures[ finiteDifferenceIndex - 1 ]; - - real Tp; - if( i == boundaryCondition.numberOfPoints - 1 ) - Tp = boundaryCondition.ambientTemperature; - else - Tp = boundaryCondition.temperatures[ finiteDifferenceIndex + 1 ]; - - real dTdxx = ( Tp + Tn - c2o1 * T0 ) / ( dx * dx ); - - boundaryCondition.temperatures[ finiteDifferenceIndex ] += parameters.dt * boundaryCondition.temperatureConductivity * dTdxx; - } - - ConservedVariables flux; - - { - real T0 = TF; - real T1 = boundaryCondition.temperatures[ ( startIndex + index ) * boundaryCondition.numberOfPoints ]; - real T2 = boundaryCondition.temperatures[ ( startIndex + index ) * boundaryCondition.numberOfPoints + 1 ]; - - - real k = boundaryCondition.temperatureConductivity * boundaryCondition.density * boundaryCondition.specificHeatCapacity; - - flux.rhoE = - k * ( - c3o2 * T0 + c2o1 * T1 - c1o2 * T2 ) / dx; - } - - flux = (parameters.dt * parameters.dx * parameters.dx) * flux; - - applyFluxToNegCell(dataBase, domainCellIdx, flux, 'a', parameters); - -#endif -} - -ConcreteHeatFlux::~ConcreteHeatFlux() -{ - checkCudaErrors( cudaFree( this->temperatures ) ); -} - -ConcreteHeatFlux::ConcreteHeatFlux(SPtr<DataBase> dataBase, uint numberOfPoints, real temperatureConductivity, real density, real specificHeatCapacity, real L, real ambientTemperature) - : BoundaryCondition( dataBase ) -{ - this->numberOfPoints = numberOfPoints; - - this->temperatureConductivity = temperatureConductivity; - this->density = density; - this->specificHeatCapacity = specificHeatCapacity; - - this->L = L; - this->ambientTemperature = ambientTemperature; - - this->temperatures = nullptr; -} - -void ConcreteHeatFlux::init() -{ - checkCudaErrors( cudaMalloc( &this->temperatures, sizeof(real) * numberOfPoints * this->numberOfCells ) ); - - // initialize values - thrust::device_ptr<real> dev_ptr(this->temperatures); - thrust::fill(dev_ptr, dev_ptr + numberOfPoints * this->numberOfCells, this->ambientTemperature); - - this->ghostCellsHost.resize(this->numberOfCells); - this->domainCellsHost.resize(this->numberOfCells); - this->secondCellsHost.resize(this->numberOfCells); - - this->temperaturesHost.resize(this->numberOfPoints * this->numberOfCells); -} - -void ConcreteHeatFlux::download() -{ - checkCudaErrors( cudaMemcpy(this->ghostCellsHost.data() , this->ghostCells , sizeof(uint) * this->numberOfCells, cudaMemcpyDeviceToHost ) ); - checkCudaErrors( cudaMemcpy(this->domainCellsHost.data(), this->domainCells, sizeof(uint) * this->numberOfCells, cudaMemcpyDeviceToHost ) ); - checkCudaErrors( cudaMemcpy(this->secondCellsHost.data(), this->secondCells, sizeof(uint) * this->numberOfCells, cudaMemcpyDeviceToHost ) ); - - checkCudaErrors( cudaMemcpy(this->temperaturesHost.data(), this->temperatures, sizeof(real) * this->numberOfCells * this->numberOfPoints, cudaMemcpyDeviceToHost ) ); -} - -bool ConcreteHeatFlux::isWall() -{ - return true; -} - -bool ConcreteHeatFlux::isInsulated() -{ - return true; -} - -bool ConcreteHeatFlux::isFluxBC() -{ - return true; -} - -bool ConcreteHeatFlux::secondCellsNeeded() -{ - return true; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/ConcreteHeatFlux.h b/src/gpu/GksGpu/BoundaryConditions/ConcreteHeatFlux.h deleted file mode 100644 index b8ff0d316a0dc5d126afc277cde662d8c89eab8d..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/ConcreteHeatFlux.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef ConcreteHeatFlux_CUH -#define ConcreteHeatFlux_CUH - -#include <memory> - -#include <thrust/device_vector.h> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "FlowStateData/FlowStateData.cuh" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct ConcreteHeatFluxStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - uint numberOfPoints; - - real* temperatures; - - real* heatConductivity; - - real temperatureConductivity; - real density; - real specificHeatCapacity; - - real L; - real ambientTemperature; -}; - -struct GKSGPU_EXPORT ConcreteHeatFlux : public BoundaryCondition //, public IsothermalWallStruct -{ - real* temperatures; - - uint numberOfPoints; - - real temperatureConductivity; - real density; - real specificHeatCapacity; - - real L; - real ambientTemperature; - - std::vector<uint> ghostCellsHost ; - std::vector<uint> domainCellsHost; - std::vector<uint> secondCellsHost; - - std::vector<real> temperaturesHost; - - ~ConcreteHeatFlux(); - - ConcreteHeatFlux( SPtr<DataBase> dataBase, uint numberOfPoints, real temperatureConductivity, real density, real specificHeatCapacity, real L, real ambientTemperature ); - - void init(); - - void download(); - - virtual bool isWall() override; - - virtual bool isInsulated() override; - - virtual bool isFluxBC() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - ConcreteHeatFluxStruct toStruct() - { - ConcreteHeatFluxStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.temperatures = this->temperatures; - boundaryCondition.numberOfPoints = this->numberOfPoints; - - boundaryCondition.temperatureConductivity = this->temperatureConductivity; - boundaryCondition.density = this->density; - boundaryCondition.specificHeatCapacity = this->specificHeatCapacity; - - boundaryCondition.L = this->L; - boundaryCondition.ambientTemperature = this->ambientTemperature; - - return boundaryCondition; - } - - void writeVTKFile( SPtr<DataBase> dataBase, Parameters& parameters, std::string filename ); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/CreepingMassFlux.cu b/src/gpu/GksGpu/BoundaryConditions/CreepingMassFlux.cu deleted file mode 100644 index fd55918246bd4aebb38f1ed8982d86e776eb7fbb..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/CreepingMassFlux.cu +++ /dev/null @@ -1,150 +0,0 @@ -#include "CreepingMassFlux.h" - -#define _USE_MATH_DEFINES -#include <math.h> -#include <iostream> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "FluxComputation/Moments.cuh" -#include "FluxComputation/ApplyFlux.cuh" -#include "FluxComputation/Transformation.cuh" -#include "FluxComputation/AssembleFlux.cuh" -#include "FluxComputation/ExpansionCoefficients.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const CreepingMassFluxStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const CreepingMassFluxStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void CreepingMassFlux::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - cudaDeviceSynchronize(); - - getLastCudaError("HeatFlux::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const CreepingMassFluxStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const CreepingMassFluxStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - // uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - PrimitiveVariables domainCellPrim; - { - ConservedVariables domainCellData; - readCellData(domainCellIdx, dataBase, domainCellData); - domainCellPrim = toPrimitiveVariables(domainCellData, parameters.K); - } - - ConservedVariables flux; - - if( boundaryCondition.velocity > 0.0 ) - { - flux.rho = boundaryCondition.velocity * boundaryCondition.rho; - - flux.rhoE = ( parameters.K + c3o1 ) / ( c4o1 * boundaryCondition.lambda ) * flux.rho; - //flux.rhoE = (parameters.K + three) / (four * domainCellPrim.lambda) * flux.rho; - - #ifdef USE_PASSIVE_SCALAR - flux.rhoS_1 = flux.rho; - #endif // USE_PASSIVE_SCALAR - flux = (parameters.dt * parameters.dx * parameters.dx) * flux; - - applyFluxToPosCell(dataBase, domainCellIdx, flux, 'z', parameters); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -} - -CreepingMassFlux::CreepingMassFlux(SPtr<DataBase> dataBase, real rho, real velocity, real lambda) - : BoundaryCondition( dataBase ) -{ - this->rho = rho; - this->velocity = velocity; - this->lambda = lambda; -} - -bool CreepingMassFlux::isWall() -{ - return true; -} - -bool CreepingMassFlux::isFluxBC() -{ - return true; -} - -bool CreepingMassFlux::secondCellsNeeded() -{ - return false; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/CreepingMassFlux.h b/src/gpu/GksGpu/BoundaryConditions/CreepingMassFlux.h deleted file mode 100644 index 70d5f11f2fb6b5ce03195c416dca4035b9e89055..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/CreepingMassFlux.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef CreepingMassFlux_CUH -#define CreepingMassFlux_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "FlowStateData/FlowStateData.cuh" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct CreepingMassFluxStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - real rho; - real velocity; - real lambda; -}; - -struct GKSGPU_EXPORT CreepingMassFlux : public BoundaryCondition //, public IsothermalWallStruct -{ - real rho; - real velocity; - real lambda; - - CreepingMassFlux( SPtr<DataBase> dataBase, real rho, real velocity, real lambda ); - - virtual bool isWall() override; - - virtual bool isFluxBC() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - CreepingMassFluxStruct toStruct() - { - CreepingMassFluxStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.rho = this->rho; - boundaryCondition.velocity = this->velocity; - boundaryCondition.lambda = this->lambda; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/Extrapolation.cu b/src/gpu/GksGpu/BoundaryConditions/Extrapolation.cu deleted file mode 100644 index 34fa30611b33f7c6226a81955e7d637bd4010f17..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Extrapolation.cu +++ /dev/null @@ -1,108 +0,0 @@ -#include "Extrapolation.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const ExtrapolationStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const ExtrapolationStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void Extrapolation::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - getLastCudaError("IsothermalWall::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const ExtrapolationStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const ExtrapolationStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - - ConservedVariables domainCellData; - readCellData ( domainCellIdx, dataBase, domainCellData ); - writeCellData( ghostCellIdx , dataBase, domainCellData ); -} - -Extrapolation::Extrapolation(SPtr<DataBase> dataBase) - : BoundaryCondition( dataBase ) -{ -} - -bool Extrapolation::isWall() -{ - return false; -} - -bool Extrapolation::secondCellsNeeded() -{ - return false; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/Extrapolation.h b/src/gpu/GksGpu/BoundaryConditions/Extrapolation.h deleted file mode 100644 index 4353a5e58e947d248c9b87f7838dab45f986e5f5..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Extrapolation.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef Extrapolation_CUH -#define Extrapolation_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct ExtrapolationStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; -}; - -struct GKSGPU_EXPORT Extrapolation : public BoundaryCondition //, public IsothermalWallStruct -{ - Extrapolation( SPtr<DataBase> dataBase ); - - virtual bool isWall() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - ExtrapolationStruct toStruct() - { - ExtrapolationStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/HeatFlux.cu b/src/gpu/GksGpu/BoundaryConditions/HeatFlux.cu deleted file mode 100644 index 87f880bcf1001a012487f5df327566dfe1ded350..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/HeatFlux.cu +++ /dev/null @@ -1,137 +0,0 @@ -#include "HeatFlux.h" - -#define _USE_MATH_DEFINES -#include <math.h> -#include <iostream> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "FluxComputation/Moments.cuh" -#include "FluxComputation/ApplyFlux.cuh" -#include "FluxComputation/Transformation.cuh" -#include "FluxComputation/AssembleFlux.cuh" -#include "FluxComputation/ExpansionCoefficients.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const HeatFluxStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const HeatFluxStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void HeatFlux::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - cudaDeviceSynchronize(); - - getLastCudaError("HeatFlux::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const HeatFluxStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const HeatFluxStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - // uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - PrimitiveVariables domainCellPrim; - { - ConservedVariables domainCellData; - readCellData(domainCellIdx, dataBase, domainCellData); - domainCellPrim = toPrimitiveVariables(domainCellData, parameters.K); - } - - ConservedVariables flux; - - flux.rhoE = boundaryCondition.HRRPUA * parameters.dt * parameters.dx * parameters.dx; - - applyFluxToPosCell(dataBase, domainCellIdx, flux, 'z', parameters); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -} - -HeatFlux::HeatFlux(SPtr<DataBase> dataBase, real HRRPUA) - : BoundaryCondition( dataBase ) -{ - this->HRRPUA = HRRPUA; -} - -bool HeatFlux::isWall() -{ - return true; -} - -bool HeatFlux::isFluxBC() -{ - return false; -} - -bool HeatFlux::secondCellsNeeded() -{ - return false; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/HeatFlux.h b/src/gpu/GksGpu/BoundaryConditions/HeatFlux.h deleted file mode 100644 index 701f9f4db8593d9f27771d12ac451db13a42f625..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/HeatFlux.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef HeatFlux_CUH -#define HeatFlux_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "FlowStateData/FlowStateData.cuh" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct HeatFluxStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - real HRRPUA; -}; - -struct GKSGPU_EXPORT HeatFlux : public BoundaryCondition //, public IsothermalWallStruct -{ - real HRRPUA; - - HeatFlux( SPtr<DataBase> dataBase, real HRRPUA ); - - virtual bool isWall() override; - - virtual bool isFluxBC() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - HeatFluxStruct toStruct() - { - HeatFluxStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.HRRPUA = this->HRRPUA; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/Inflow.cu b/src/gpu/GksGpu/BoundaryConditions/Inflow.cu deleted file mode 100644 index 7f9b2777f5e75a5c79a2ee5f280871a021cf6c94..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Inflow.cu +++ /dev/null @@ -1,167 +0,0 @@ -#include "Inflow.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const InflowStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const InflowStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void Inflow::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - cudaDeviceSynchronize(); - - getLastCudaError("Inflow::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const InflowStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const InflowStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - // uint secondCellIdx = boundaryCondition.secondCells[ startIndex + index ]; - - PrimitiveVariables ghostCellPrim; - { - PrimitiveVariables domainCellPrim; - PrimitiveVariables secondCellPrim; - - { - ConservedVariables domainCellData; - readCellData( domainCellIdx, dataBase, domainCellData ); - domainCellPrim = toPrimitiveVariables( domainCellData, parameters.K ); - } - - real factor = c1o1; - //if( fabs(boundaryCondition.a1) > real(1.0e-6) ) - { - real y = dataBase.cellCenter[ VEC_Y(ghostCellIdx, dataBase.numberOfCells) ]; - real z = dataBase.cellCenter[ VEC_Z(ghostCellIdx, dataBase.numberOfCells) ]; - - real r = sqrt( y*y + z*z ); - - //factor = ( boundaryCondition.a0 - // + boundaryCondition.a1*y - // + boundaryCondition.a2*y*y ) * ( four / boundaryCondition.a1 / boundaryCondition.a1 ); - - factor = ( boundaryCondition.a0 - + boundaryCondition.a1*r - + boundaryCondition.a2*r*r ); - - //factor = one; - } - - //ghostCellPrim.rho = two * boundaryCondition.rho - domainCellPrim.rho; - ghostCellPrim.U = c2o1 * factor * boundaryCondition.velocity.x - domainCellPrim.U; - ghostCellPrim.V = c2o1 * factor * boundaryCondition.velocity.y - domainCellPrim.V; - ghostCellPrim.W = c2o1 * factor * boundaryCondition.velocity.z - domainCellPrim.W; - ghostCellPrim.lambda = c2o1 * boundaryCondition.lambda - domainCellPrim.lambda; - #ifdef USE_PASSIVE_SCALAR - ghostCellPrim.S_1 = c2o1 * boundaryCondition.S_1 - domainCellPrim.S_1; - ghostCellPrim.S_2 = c2o1 * boundaryCondition.S_2 - domainCellPrim.S_2; - #endif // USE_PASSIVE_SCALAR - - real p = c1o2 * domainCellPrim.rho / domainCellPrim.lambda; - ghostCellPrim.rho = c2o1 * p * ghostCellPrim.lambda; - } - - { - ConservedVariables ghostCons = toConservedVariables( ghostCellPrim, parameters.K ); - - writeCellData( ghostCellIdx, dataBase, ghostCons ); - } -} - -Inflow::Inflow(SPtr<DataBase> dataBase, Vec3 velocity, real lambda, real rho, real a0, real a1, real a2, real S_1, real S_2) - : BoundaryCondition( dataBase ) -{ - this->velocity = velocity; - this->lambda = lambda; - this->rho = rho; - this->S_1 = S_1; - this->S_2 = S_2; - - this->a0 = a0; - this->a1 = a1; - this->a2 = a2; -} - -bool Inflow::isWall() -{ - return false; -} - -bool Inflow::secondCellsNeeded() -{ - return false; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/Inflow.h b/src/gpu/GksGpu/BoundaryConditions/Inflow.h deleted file mode 100644 index b1036c4187ce3d040f8ebf2f51a5fbed1ecb76cc..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Inflow.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef Inflow_CUH -#define Inflow_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct InflowStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - Vec3 velocity; - real lambda; - real rho; - real S_1; - real S_2; - - real a0, a1, a2; -}; - -struct GKSGPU_EXPORT Inflow : public BoundaryCondition //, public IsothermalWallStruct -{ - Vec3 velocity; - real lambda; - real rho; - real S_1; - real S_2; - - real a0, a1, a2; - - Inflow( SPtr<DataBase> dataBase, Vec3 velocity, real lambda, real rho, real a0, real a1, real a2, real S_1 = 0.0, real S_2 = 0.0 ); - - virtual bool isWall() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - InflowStruct toStruct() - { - InflowStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.velocity = this->velocity; - boundaryCondition.lambda = this->lambda; - boundaryCondition.rho = this->rho; - boundaryCondition.S_1 = this->S_1; - boundaryCondition.S_2 = this->S_2; - - boundaryCondition.a0 = this->a0; - boundaryCondition.a1 = this->a1; - boundaryCondition.a2 = this->a2; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/InflowComplete.cu b/src/gpu/GksGpu/BoundaryConditions/InflowComplete.cu deleted file mode 100644 index 6cda5a57f8327c5782725c0b720c4b6ba8a11271..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/InflowComplete.cu +++ /dev/null @@ -1,322 +0,0 @@ -#include "InflowComplete.h" - -#define _USE_MATH_DEFINES -#include <math.h> -#include <iostream> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "FluxComputation/Moments.cuh" -#include "FluxComputation/ApplyFlux.cuh" -#include "FluxComputation/Transformation.cuh" -#include "FluxComputation/AssembleFlux.cuh" -#include "FluxComputation/ExpansionCoefficients.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const InflowCompleteStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const InflowCompleteStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void InflowComplete::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - cudaDeviceSynchronize(); - - getLastCudaError("Inflow::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const InflowCompleteStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const InflowCompleteStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if( true ) - { - PrimitiveVariables ghostCellPrim; - { - PrimitiveVariables domainCellPrim; - - { - ConservedVariables domainCellData; - readCellData(domainCellIdx, dataBase, domainCellData); - domainCellPrim = toPrimitiveVariables(domainCellData, parameters.K); - } - - // ghostCellPrim.rho = two * boundaryCondition.prim.rho - domainCellPrim.rho; - // ghostCellPrim.U = two * boundaryCondition.prim.U - domainCellPrim.U; - // ghostCellPrim.V = two * boundaryCondition.prim.V - domainCellPrim.V; - // ghostCellPrim.W = two * boundaryCondition.prim.W - domainCellPrim.W; - ghostCellPrim.lambda = /*two * boundaryCondition.prim.lambda -*/ domainCellPrim.lambda; - //#ifdef USE_PASSIVE_SCALAR - // ghostCellPrim.S_1 = two * boundaryCondition.prim.S_1 - domainCellPrim.S_1; - // ghostCellPrim.S_2 = two * boundaryCondition.prim.S_2 - domainCellPrim.S_2; - //#endif // USE_PASSIVE_SCALAR - - ghostCellPrim.rho = boundaryCondition.prim.rho; - ghostCellPrim.U = c2o1 * boundaryCondition.prim.U - domainCellPrim.U; - ghostCellPrim.V = c2o1 * boundaryCondition.prim.V - domainCellPrim.V; - //ghostCellPrim.W = two * boundaryCondition.prim.W - domainCellPrim.W; - ghostCellPrim.W = boundaryCondition.prim.W; - //ghostCellPrim.lambda = boundaryCondition.prim.lambda; -#ifdef USE_PASSIVE_SCALAR - ghostCellPrim.S_1 = boundaryCondition.prim.S_1; - ghostCellPrim.S_2 = boundaryCondition.prim.S_2; -#endif // USE_PASSIVE_SCALAR - - real y = dataBase.cellCenter[VEC_Y(ghostCellIdx, dataBase.numberOfCells)]; - real x = dataBase.cellCenter[VEC_X(ghostCellIdx, dataBase.numberOfCells)]; - - real r = sqrt(y*y + x*x); - - ghostCellPrim.W *= (c1o1 - c4o1*r*r); -#ifdef USE_PASSIVE_SCALAR - ghostCellPrim.S_1 *= (c1o1 - c4o1*r*r); - ghostCellPrim.S_2 = boundaryCondition.prim.S_2 - ghostCellPrim.S_1; -#endif // USE_PASSIVE_SCALAR - } - - { - ConservedVariables ghostCons = toConservedVariables(ghostCellPrim, parameters.K); - - writeCellData(ghostCellIdx, dataBase, ghostCons); - } - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if( false ) - { - PrimitiveVariables domainCellPrim; - { - ConservedVariables domainCellData; - readCellData(domainCellIdx, dataBase, domainCellData); - domainCellPrim = toPrimitiveVariables(domainCellData, parameters.K); - } - - real momentU [NUMBER_OF_MOMENTS]; - real momentV [NUMBER_OF_MOMENTS]; - real momentW [NUMBER_OF_MOMENTS]; - real momentXi[NUMBER_OF_MOMENTS]; - - PrimitiveVariables facePrim = boundaryCondition.prim; - - //facePrim.lambda = domainCellPrim.lambda; - - transformGlobalToLocal( facePrim, 'z' ); - - computeMoments(facePrim, parameters.K, momentU, momentV, momentW, momentXi); - - ConservedVariables flux; - - flux.rho = momentU[0 + 1]; - //flux.rhoU = momentU[1 + 1]; - - //flux.rhoE = c1o2 * ( momentU[2 + 1] - // + momentU[0 + 1] * momentV [2] - // + momentU[0 + 1] * momentW [2] - // + momentU[0 + 1] * momentXi[2] ); - - flux.rhoE = momentU[0 + 1] * c1o4 * ( parameters.K + c5o1 ) / boundaryCondition.prim.lambda; - - ////////////////////////////////////////////////////////////////////////// - -#ifdef USE_PASSIVE_SCALAR - flux.rhoS_1 = flux.rho * boundaryCondition.prim.S_1; - flux.rhoS_2 = flux.rho * boundaryCondition.prim.S_2; -#endif // USE_PASSIVE_SCALAR - - flux = ( parameters.dt * parameters.dx * parameters.dx * facePrim.rho ) * flux; - - transformLocalToGlobal( flux, 'z' ); - - applyFluxToPosCell(dataBase, domainCellIdx, flux, 'z', parameters); - - return; - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //if( false ) - //{ - // PrimitiveVariables domainCellPrim; - // { - // ConservedVariables domainCellData; - // readCellData(domainCellIdx, dataBase, domainCellData); - // domainCellPrim = toPrimitiveVariables(domainCellData, parameters.K); - // } - - // PrimitiveVariables facePrim = boundaryCondition.prim; - - // ////////////////////////////////////////////////////////////////////////// - - // real ax[LENGTH_CELL_DATA]; - // real ay[LENGTH_CELL_DATA]; - // real az[LENGTH_CELL_DATA]; - // real at[LENGTH_CELL_DATA]; - - //#pragma unroll - // for( uint i = 0; i < LENGTH_CELL_DATA; i++ ) - // { - // ax[i] = c0o1; - // ay[i] = c0o1; - // az[i] = c0o1; - // at[i] = c0o1; - // } - // - // { - // ConservedVariables gradN, gradT1, gradT2; - - // transformGlobalToLocal( gradN , 'z' ); - // transformGlobalToLocal( gradT1, 'z' ); - // transformGlobalToLocal( gradT2, 'z' ); - - // transformGlobalToLocal( facePrim, 'z' ); - - // computeExpansionCoefficients(facePrim, gradN , parameters.K, ax); - // computeExpansionCoefficients(facePrim, gradT1, parameters.K, ay); - // computeExpansionCoefficients(facePrim, gradT2, parameters.K, az); - // } - - // ////////////////////////////////////////////////////////////////////////// - - // { - // ConservedVariables flux; - // { - // real momentU [ NUMBER_OF_MOMENTS ]; - // real momentV [ NUMBER_OF_MOMENTS ]; - // real momentW [ NUMBER_OF_MOMENTS ]; - // real momentXi[ NUMBER_OF_MOMENTS ]; - - // computeMoments( facePrim, parameters.K, momentU, momentV, momentW, momentXi ); - - // Vec3 force = parameters.force; - - // transformGlobalToLocal(force, 'z'); - - // { - // ConservedVariables timeGrad; - // computeTimeDerivative( facePrim, - // momentU, - // momentV, - // momentW, - // momentXi, - // ax, ay, az, - // force, - // timeGrad ); - - // computeExpansionCoefficients( facePrim, timeGrad, parameters.K, at ); - // } - // { - // real timeCoefficients[4]; - // computeTimeCoefficients( facePrim, parameters, timeCoefficients ); - - // real heatFlux; - // assembleFlux( facePrim, - // momentU, momentV, momentW, momentXi, - // ax, ay, az, at, - // timeCoefficients, - // parameters, - // force, - // flux, - // heatFlux ); - - // transformLocalToGlobal( flux, 'z' ); - // } - // } - - // applyFluxToPosCell(dataBase, domainCellIdx, flux, 'z', parameters); - // applyFluxToNegCell(dataBase, ghostCellIdx , flux, 'z', parameters); - // } - //} - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -} - -InflowComplete::InflowComplete(SPtr<DataBase> dataBase, PrimitiveVariables prim) - : BoundaryCondition( dataBase ) -{ - this->prim = prim; -} - -bool InflowComplete::isWall() -{ - return false; -} - -bool InflowComplete::isFluxBC() -{ - return false; -} - -bool InflowComplete::secondCellsNeeded() -{ - return false; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/InflowComplete.h b/src/gpu/GksGpu/BoundaryConditions/InflowComplete.h deleted file mode 100644 index 6d402d150a10a05666f44ab5c73c068fab507736..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/InflowComplete.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef InflowComplete_CUH -#define InflowComplete_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "FlowStateData/FlowStateData.cuh" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct InflowCompleteStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - PrimitiveVariables prim; -}; - -struct GKSGPU_EXPORT InflowComplete : public BoundaryCondition //, public IsothermalWallStruct -{ - PrimitiveVariables prim; - - InflowComplete( SPtr<DataBase> dataBase, PrimitiveVariables prim ); - - virtual bool isWall() override; - - virtual bool isFluxBC() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - InflowCompleteStruct toStruct() - { - InflowCompleteStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.prim = prim; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/IsothermalWall.cu b/src/gpu/GksGpu/BoundaryConditions/IsothermalWall.cu deleted file mode 100644 index 5dee058d719527ad554ed866b53d7efab536e697..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/IsothermalWall.cu +++ /dev/null @@ -1,159 +0,0 @@ -#include "IsothermalWall.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const IsothermalWallStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const IsothermalWallStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void IsothermalWall::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - cudaDeviceSynchronize(); - - getLastCudaError("IsothermalWall::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const IsothermalWallStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const IsothermalWallStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - uint secondCellIdx = boundaryCondition.secondCells[ startIndex + index ]; - - PrimitiveVariables ghostCellPrim; - { - PrimitiveVariables domainCellPrim; - PrimitiveVariables secondCellPrim; - - { - ConservedVariables domainCellData; - readCellData( domainCellIdx, dataBase, domainCellData ); - domainCellPrim = toPrimitiveVariables( domainCellData, parameters.K ); - - ConservedVariables secondCellData; - if( secondCellIdx != INVALID_INDEX ){ - readCellData( secondCellIdx, dataBase, secondCellData ); - secondCellPrim = toPrimitiveVariables( secondCellData, parameters.K ); - } - } - - ghostCellPrim.U = c2o1 * boundaryCondition.velocity.x - domainCellPrim.U; - ghostCellPrim.V = c2o1 * boundaryCondition.velocity.y - domainCellPrim.V; - ghostCellPrim.W = c2o1 * boundaryCondition.velocity.z - domainCellPrim.W; - ghostCellPrim.lambda = c2o1 * boundaryCondition.lambda - domainCellPrim.lambda; - #ifdef USE_PASSIVE_SCALAR - ghostCellPrim.S_1 = /*two * boundaryCondition.S_1 -*/ domainCellPrim.S_1; - ghostCellPrim.S_2 = /*two * boundaryCondition.S_2 -*/ domainCellPrim.S_2; - #endif // USE_PASSIVE_SCALAR - - - if( boundaryCondition.useSecondCells && secondCellIdx != INVALID_INDEX ){ - real p1 = c1o2 * domainCellPrim.rho / domainCellPrim.lambda; - real p2 = c1o2 * secondCellPrim.rho / secondCellPrim.lambda; - - ghostCellPrim.rho = c2o1 * ( c2o1 * p1 - p2 ) * ghostCellPrim.lambda; - } - else{ - real p = c1o2 * domainCellPrim.rho / domainCellPrim.lambda; - - ghostCellPrim.rho = c2o1 * p * ghostCellPrim.lambda; - } - } - - { - ConservedVariables ghostCons = toConservedVariables( ghostCellPrim, parameters.K ); - - writeCellData( ghostCellIdx, dataBase, ghostCons ); - } -} - -IsothermalWall::IsothermalWall(SPtr<DataBase> dataBase, Vec3 velocity, real lambda, bool useSecondCells, real S_1, real S_2) - : BoundaryCondition( dataBase ) -{ - this->velocity = velocity; - this->lambda = lambda; - this->S_1 = S_1; - this->S_2 = S_2; - this->useSecondCells = useSecondCells; -} - -bool IsothermalWall::isWall() -{ - return true; -} - -bool IsothermalWall::secondCellsNeeded() -{ - return true; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/IsothermalWall.h b/src/gpu/GksGpu/BoundaryConditions/IsothermalWall.h deleted file mode 100644 index 57bafca6bf7190553aa80dacfc41b8207eeef099..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/IsothermalWall.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef IsothermalWall_CUH -#define IsothermalWall_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct IsothermalWallStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - Vec3 velocity; - real lambda; - real S_1; - real S_2; - - bool useSecondCells; -}; - -struct GKSGPU_EXPORT IsothermalWall : public BoundaryCondition //, public IsothermalWallStruct -{ - Vec3 velocity; - real lambda; - real S_1; - real S_2; - - bool useSecondCells; - - IsothermalWall( SPtr<DataBase> dataBase, Vec3 velocity, real lambda, bool useSecondCells, real S_1 = 0.0, real S_2 = 0.0 ); - - virtual bool isWall() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - IsothermalWallStruct toStruct() - { - IsothermalWallStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.velocity = this->velocity; - boundaryCondition.lambda = this->lambda; - boundaryCondition.S_1 = this->S_1; - boundaryCondition.S_2 = this->S_2; - - boundaryCondition.useSecondCells = this->useSecondCells; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/MassCompensation.cu b/src/gpu/GksGpu/BoundaryConditions/MassCompensation.cu deleted file mode 100644 index f6e69742635d594b2f0f1319642c51a5dde78a9e..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/MassCompensation.cu +++ /dev/null @@ -1,154 +0,0 @@ -#include "MassCompensation.h" - -#define _USE_MATH_DEFINES -#include <math.h> -#include <iostream> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "FluxComputation/Moments.cuh" -#include "FluxComputation/ApplyFlux.cuh" -#include "FluxComputation/Transformation.cuh" -#include "FluxComputation/AssembleFlux.cuh" -#include "FluxComputation/ExpansionCoefficients.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const MassCompensationStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const MassCompensationStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void MassCompensation::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - cudaDeviceSynchronize(); - - getLastCudaError("HeatFlux::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const MassCompensationStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const MassCompensationStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - // uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - PrimitiveVariables domainCellPrim; - { - ConservedVariables domainCellData; - readCellData(domainCellIdx, dataBase, domainCellData); - domainCellPrim = toPrimitiveVariables(domainCellData, parameters.K); - } - - ////////////////////////////////////////////////////////////////////////// - - real p0 = c1o2 * boundaryCondition.rho / boundaryCondition.lambda; - real p1 = c1o2 * domainCellPrim.rho / domainCellPrim.lambda; - - ////////////////////////////////////////////////////////////////////////// - - if( p1 > p0 ) - { - ConservedVariables flux; - - flux.rho = c2o1 * p0 * domainCellPrim.lambda - domainCellPrim.rho; - - //flux.rhoE = ( parameters.K + three ) / ( four * boundaryCondition.lambda ) * flux.rho; - flux.rhoE = (parameters.K + c3o1) / (c4o1 * domainCellPrim.lambda) * flux.rho; - - flux = (parameters.dt * parameters.dx * parameters.dx) * flux; - - applyFluxToPosCell(dataBase, domainCellIdx, flux, 'z', parameters); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -} - -MassCompensation::MassCompensation(SPtr<DataBase> dataBase, real rho, real velocity, real lambda) - : BoundaryCondition( dataBase ) -{ - this->rho = rho; - this->velocity = velocity; - this->lambda = lambda; -} - -bool MassCompensation::isWall() -{ - return false; -} - -bool MassCompensation::isFluxBC() -{ - return false; -} - -bool MassCompensation::secondCellsNeeded() -{ - return false; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/MassCompensation.h b/src/gpu/GksGpu/BoundaryConditions/MassCompensation.h deleted file mode 100644 index 6b2c47206718e10f5664f1b7275ce4393d0e3774..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/MassCompensation.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef MassCompensation_CUH -#define MassCompensation_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "FlowStateData/FlowStateData.cuh" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct MassCompensationStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - real rho; - real velocity; - real lambda; -}; - -struct GKSGPU_EXPORT MassCompensation : public BoundaryCondition //, public IsothermalWallStruct -{ - real rho; - real velocity; - real lambda; - - MassCompensation( SPtr<DataBase> dataBase, real rho, real velocity, real lambda ); - - virtual bool isWall() override; - - virtual bool isFluxBC() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - MassCompensationStruct toStruct() - { - MassCompensationStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.rho = this->rho; - boundaryCondition.velocity = this->velocity; - boundaryCondition.lambda = this->lambda; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/Open.cu b/src/gpu/GksGpu/BoundaryConditions/Open.cu deleted file mode 100644 index 9413d7015ac46b18395e8544df162a3868dd0204..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Open.cu +++ /dev/null @@ -1,193 +0,0 @@ -#include "Open.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const OpenStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const OpenStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void Open::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - getLastCudaError("IsothermalWall::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const OpenStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const OpenStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - uint secondCellIdx = boundaryCondition.secondCells[ startIndex + index ]; - - ConservedVariables domainCellData, secondCellData, ghostCellData; - readCellData ( domainCellIdx, dataBase, domainCellData ); - readCellData ( secondCellIdx, dataBase, secondCellData ); - - PrimitiveVariables domainCellPrim = toPrimitiveVariables( domainCellData, parameters.K ); - PrimitiveVariables secondCellPrim = toPrimitiveVariables( secondCellData, parameters.K ); - - ////////////////////////////////////////////////////////////////////////// - - real xGhostCell = dataBase.cellCenter[ VEC_X(ghostCellIdx, dataBase.numberOfCells) ]; - real yGhostCell = dataBase.cellCenter[ VEC_Y(ghostCellIdx, dataBase.numberOfCells) ]; - real zGhostCell = dataBase.cellCenter[ VEC_Z(ghostCellIdx, dataBase.numberOfCells) ]; - - real xDomainCell = dataBase.cellCenter[ VEC_X(domainCellIdx, dataBase.numberOfCells) ]; - real yDomainCell = dataBase.cellCenter[ VEC_Y(domainCellIdx, dataBase.numberOfCells) ]; - real zDomainCell = dataBase.cellCenter[ VEC_Z(domainCellIdx, dataBase.numberOfCells) ]; - - real dx = xGhostCell - xDomainCell; - real dy = yGhostCell - yDomainCell; - real dz = zGhostCell - zDomainCell; - - real sign = domainCellPrim.U * dx - + domainCellPrim.V * dy - + domainCellPrim.W * dz; - - ////////////////////////////////////////////////////////////////////////// - - real p1 = c1o2 * domainCellPrim.rho / domainCellPrim.lambda; - real p2 = c1o2 * secondCellPrim.rho / secondCellPrim.lambda; - - real p0 = c1o2 * boundaryCondition.prim.rho / boundaryCondition.prim.lambda; - - ////////////////////////////////////////////////////////////////////////// - - //if( sign > zero ) - //if( p2 > p1 ) - if( p1 > p0 ) - { - ghostCellData = domainCellData; - //ghostCellData = two * domainCellData + ( - one ) * secondCellData; - - - ghostCellData.rhoU = c0o1; - ghostCellData.rhoV = c0o1; - ghostCellData.rhoW = c0o1; - } - else - { - PrimitiveVariables ghostCellPrim = boundaryCondition.prim; - - ghostCellPrim.U = domainCellPrim.U; - ghostCellPrim.V = domainCellPrim.V; - ghostCellPrim.W = domainCellPrim.W; - - //ghostCellPrim.U = p0/p1; - //ghostCellPrim.V = p0/p1; - //ghostCellPrim.W = p0/p1; - - //ghostCellPrim.U = two * domainCellPrim.U - secondCellPrim.U; - //ghostCellPrim.V = two * domainCellPrim.V - secondCellPrim.V; - //ghostCellPrim.W = two * domainCellPrim.W - secondCellPrim.W; - - real velocity = sqrt( ghostCellPrim.U * ghostCellPrim.U + ghostCellPrim.V * ghostCellPrim.V + ghostCellPrim.W * ghostCellPrim.W ); - - if( velocity > boundaryCondition.velocityLimiter ) - { - ghostCellPrim.U *= boundaryCondition.velocityLimiter / velocity; - ghostCellPrim.V *= boundaryCondition.velocityLimiter / velocity; - ghostCellPrim.W *= boundaryCondition.velocityLimiter / velocity; - } - - ghostCellData = toConservedVariables(ghostCellPrim, parameters.K); - } - - ////////////////////////////////////////////////////////////////////////// - - //ghostCellData = two * domainCellData + ( - one ) * secondCellData; - - //ghostCellData = domainCellData; - - ////////////////////////////////////////////////////////////////////////// - - writeCellData(ghostCellIdx, dataBase, ghostCellData); -} - -Open::Open(SPtr<DataBase> dataBase, PrimitiveVariables prim, real velocityLimiter) - : BoundaryCondition( dataBase ) -{ - this->prim = prim; - - this->velocityLimiter = velocityLimiter; -} - -bool Open::isWall() -{ - return false; -} - -bool Open::secondCellsNeeded() -{ - return true; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/Open.h b/src/gpu/GksGpu/BoundaryConditions/Open.h deleted file mode 100644 index 16cf9736b9ee4b2851d56547a523cc948ec7c64b..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Open.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef Open_CUH -#define Open_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "FlowStateData/FlowStateData.cuh" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct OpenStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - PrimitiveVariables prim; - - real velocityLimiter; -}; - -struct GKSGPU_EXPORT Open : public BoundaryCondition //, public IsothermalWallStruct -{ - PrimitiveVariables prim; - - real velocityLimiter; - - Open( SPtr<DataBase> dataBase, PrimitiveVariables prim, real velocityLimiter ); - - virtual bool isWall() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - OpenStruct toStruct() - { - OpenStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.prim = this->prim; - - boundaryCondition.velocityLimiter = this->velocityLimiter; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/PassiveScalarDiriclet.cu b/src/gpu/GksGpu/BoundaryConditions/PassiveScalarDiriclet.cu deleted file mode 100644 index e8e29790157874ee9775eba84a48a62ca71bb18b..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/PassiveScalarDiriclet.cu +++ /dev/null @@ -1,203 +0,0 @@ -#include "PassiveScalarDiriclet.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const PassiveScalarDiricletStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const PassiveScalarDiricletStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void PassiveScalarDiriclet::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - cudaDeviceSynchronize(); - - getLastCudaError("Pressure::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const PassiveScalarDiricletStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const PassiveScalarDiricletStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ -#ifdef USE_PASSIVE_SCALAR - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if(false){ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - - PrimitiveVariables domainCellPrim; - - ConservedVariables domainCellData; - readCellData( domainCellIdx, dataBase, domainCellData ); - domainCellPrim = toPrimitiveVariables( domainCellData, parameters.K ); - - ////////////////////////////////////////////////////////////////////////// - - real dS_1 = ( boundaryCondition.S_1 * ( 1.0 - domainCellPrim.S_1 ) ) * parameters.dt; - - //real x = dataBase.cellCenter[VEC_X(ghostCellIdx, dataBase.numberOfCells)]; - //real y = dataBase.cellCenter[VEC_Y(ghostCellIdx, dataBase.numberOfCells)]; - - //real r = sqrt( x * x + y * y ); - - //if( r > 0.25 ) dS_1 *= four * (c1o2 - r); - - domainCellPrim.S_1 += dS_1; - - domainCellPrim.S_2 = 1.0 - domainCellPrim.S_1; - - ////////////////////////////////////////////////////////////////////////// - - domainCellData = toConservedVariables( domainCellPrim, parameters.K ); - writeCellData(domainCellIdx, dataBase, domainCellData); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if(true){ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - uint secondCellIdx = boundaryCondition.secondCells[ startIndex + index ]; - - PrimitiveVariables ghostCellPrim; - PrimitiveVariables domainCellPrim; - PrimitiveVariables secondCellPrim; - - { - ConservedVariables domainCellData; - readCellData( domainCellIdx, dataBase, domainCellData ); - domainCellPrim = toPrimitiveVariables( domainCellData, parameters.K ); - - ConservedVariables secondCellData; - if( secondCellIdx != INVALID_INDEX ){ - readCellData( secondCellIdx, dataBase, secondCellData ); - secondCellPrim = toPrimitiveVariables( secondCellData, parameters.K ); - } - } - - ghostCellPrim.U = - domainCellPrim.U; - ghostCellPrim.V = - domainCellPrim.V; - ghostCellPrim.W = - domainCellPrim.W; - #ifdef USE_PASSIVE_SCALAR - ghostCellPrim.S_1 = c2o1 * boundaryCondition.S_1 - domainCellPrim.S_1; - ghostCellPrim.S_2 = c2o1 * boundaryCondition.S_2 - domainCellPrim.S_2; - #endif // USE_PASSIVE_SCALAR - - ////////////////////////////////////////////////////////////////////////// - - real T = getT(domainCellPrim); - setLambdaFromT(ghostCellPrim, T); - - ////////////////////////////////////////////////////////////////////////// - - if( secondCellIdx != INVALID_INDEX ){ - real p1 = c1o2 * domainCellPrim.rho / domainCellPrim.lambda; - real p2 = c1o2 * secondCellPrim.rho / secondCellPrim.lambda; - - ghostCellPrim.rho = c2o1 * ( c2o1 * p1 - p2 ) * ghostCellPrim.lambda; - } - else{ - real p = c1o2 * domainCellPrim.rho / domainCellPrim.lambda; - - ghostCellPrim.rho = c2o1 * p * ghostCellPrim.lambda; - } - - ConservedVariables ghostCons = toConservedVariables( ghostCellPrim, parameters.K ); - - writeCellData( ghostCellIdx, dataBase, ghostCons ); - } - - -#endif // USE_PASSIVE_SCALAR -} - -PassiveScalarDiriclet::PassiveScalarDiriclet(SPtr<DataBase> dataBase, real S_1, real S_2) - : BoundaryCondition( dataBase ) -{ - this->S_1 = S_1; - this->S_2 = S_2; -} - -bool PassiveScalarDiriclet::isWall() -{ - return true; -} - -bool PassiveScalarDiriclet::secondCellsNeeded() -{ - return true; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/PassiveScalarDiriclet.h b/src/gpu/GksGpu/BoundaryConditions/PassiveScalarDiriclet.h deleted file mode 100644 index 0c46b12a085c9e8f755e2170274466e907710d86..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/PassiveScalarDiriclet.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef PassiveScalarDiriclet_CUH -#define PassiveScalarDiriclet_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -//struct IsothermalWallStruct : virtual public BoundaryConditionStruct -//{ -// Vec3 velocity; -// real lambda; -// real S; -//}; - -struct PassiveScalarDiricletStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - real S_1; - real S_2; -}; - -struct GKSGPU_EXPORT PassiveScalarDiriclet : public BoundaryCondition -{ - real S_1; - real S_2; - - PassiveScalarDiriclet( SPtr<DataBase> dataBase, real S_1, real S_2 ); - - virtual bool isWall() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - PassiveScalarDiricletStruct toStruct() - { - PassiveScalarDiricletStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.S_1 = this->S_1; - boundaryCondition.S_2 = this->S_2; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/Periodic.cu b/src/gpu/GksGpu/BoundaryConditions/Periodic.cu deleted file mode 100644 index 559e4c6dac326b417cc98adb10db1dcab154a987..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Periodic.cu +++ /dev/null @@ -1,154 +0,0 @@ -#include "Periodic.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" -#include "DataBase/DataBaseAllocator.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const BoundaryConditionStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const BoundaryConditionStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void Periodic::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - getLastCudaError("Periodic::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const BoundaryConditionStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const BoundaryConditionStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - - ConservedVariables domainCellData; - readCellData ( domainCellIdx, dataBase, domainCellData ); - writeCellData( ghostCellIdx , dataBase, domainCellData ); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void Periodic::findBoundaryCells(GksMeshAdapter & adapter, bool allowGhostCells, std::function<bool(Vec3)> boundaryFinder) -{ - this->myAllocator->freeMemory( *this ); - - std::vector<uint> ghostCells; - std::vector<uint> domainCells; - std::vector<uint> secondCells; - - numberOfCellsPerLevel.resize( adapter.numberOfLevels ); - startOfCellsPerLevel.resize ( adapter.numberOfLevels ); - - for( auto& n : numberOfCellsPerLevel ) n = 0; - - for( uint level = 0; level < adapter.numberOfLevels; level++ ) - { - uint startIdx = adapter.startOfCellsPerLevel[level] - + adapter.numberOfBulkCellsPerLevel[level]; - - uint endIdx = adapter.startOfCellsPerLevel[level] - + adapter.numberOfCellsPerLevel[level]; - - for( uint_2 candidate : adapter.periodicBoundaryNeighbors ) - { - MeshCell& cell = adapter.cells[ candidate[0] ]; - - if( !boundaryFinder( cell.cellCenter ) ) continue; - - if( candidate[1] == INVALID_INDEX ) continue; - - ghostCells.push_back ( candidate[0] ); - domainCells.push_back( candidate[1] ); - - this->numberOfCellsPerLevel[ level ]++; - } - } - - startOfCellsPerLevel[ 0 ] = 0; - - for( uint level = 1; level < adapter.numberOfLevels; level++ ) - { - startOfCellsPerLevel[ level ] = startOfCellsPerLevel [ level - 1 ] - + numberOfCellsPerLevel[ level - 1 ]; - } - - this->numberOfCells = ghostCells.size(); - - this->myAllocator->allocateMemory( shared_from_this(), ghostCells, domainCells, secondCells ); - -} - -bool Periodic::isWall() -{ - return false; -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/BoundaryConditions/Periodic.h b/src/gpu/GksGpu/BoundaryConditions/Periodic.h deleted file mode 100644 index 3d6755f9dd9f3578a717e794f39bc105f8c0a345..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Periodic.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef Periodic_CUH -#define Periodic_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct GKSGPU_EXPORT Periodic : public BoundaryCondition -{ - Periodic( SPtr<DataBase> dataBase ) : BoundaryCondition( dataBase ){} - - virtual bool isWall(); - - virtual void findBoundaryCells( GksMeshAdapter& adapter, bool allowGhostCells, std::function<bool(Vec3)> boundaryFinder) override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - BoundaryConditionStruct toStruct() - { - BoundaryConditionStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/Pressure.cu b/src/gpu/GksGpu/BoundaryConditions/Pressure.cu deleted file mode 100644 index 8523eb18e7db60b79170eee5884d22a3a25abac5..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Pressure.cu +++ /dev/null @@ -1,150 +0,0 @@ -#include "Pressure.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const PressureStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const PressureStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void Pressure::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - cudaDeviceSynchronize(); - - getLastCudaError("Pressure::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const PressureStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const PressureStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - uint secondCellIdx = boundaryCondition.secondCells[ startIndex + index ]; - - PrimitiveVariables ghostCellPrim; - { - PrimitiveVariables domainCellPrim; - PrimitiveVariables secondCellPrim; - - { - ConservedVariables domainCellData; - readCellData( domainCellIdx, dataBase, domainCellData ); - domainCellPrim = toPrimitiveVariables( domainCellData, parameters.K ); - - ConservedVariables secondCellData; - if( secondCellIdx != INVALID_INDEX ){ - readCellData( secondCellIdx, dataBase, secondCellData ); - secondCellPrim = toPrimitiveVariables( secondCellData, parameters.K ); - } - } - - //ghostCellPrim.rho = two * domainCellPrim.rho - secondCellPrim.rho; - ghostCellPrim.U = c2o1 * domainCellPrim.U - secondCellPrim.U; - ghostCellPrim.V = c2o1 * domainCellPrim.V - secondCellPrim.V; - ghostCellPrim.W = c2o1 * domainCellPrim.W - secondCellPrim.W; - ghostCellPrim.lambda = c2o1 * domainCellPrim.lambda - secondCellPrim.lambda; - #ifdef USE_PASSIVE_SCALAR - ghostCellPrim.S_1 = c2o1 * domainCellPrim.S_1 - secondCellPrim.S_1; - ghostCellPrim.S_2 = c2o1 * domainCellPrim.S_2 - secondCellPrim.S_2; - #endif // USE_PASSIVE_SCALAR - - - real rho0 = ( c2o1 * boundaryCondition.p0 * c1o2 * ( domainCellPrim.lambda + ghostCellPrim.lambda ) ); - ghostCellPrim.rho = c2o1 * rho0 - domainCellPrim.rho; - - //real lambda0 = ( c1o2 * ( domainCellPrim.rho + ghostCellPrim.rho ) * c1o2 / boundaryCondition.p0 ); - //ghostCellPrim.lambda = two * lambda0 - domainCellPrim.lambda; - } - - { - ConservedVariables ghostCons = toConservedVariables( ghostCellPrim, parameters.K ); - - writeCellData( ghostCellIdx, dataBase, ghostCons ); - } -} - -Pressure::Pressure(SPtr<DataBase> dataBase, real p0) - : BoundaryCondition( dataBase ) -{ - this->p0 = p0; -} - -bool Pressure::isWall() -{ - return false; -} - -bool Pressure::secondCellsNeeded() -{ - return true; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/Pressure.h b/src/gpu/GksGpu/BoundaryConditions/Pressure.h deleted file mode 100644 index 4413a2d0c1a241ce900d9a1166382c586baad89f..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Pressure.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef Pressure_CUH -#define Pressure_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -//struct IsothermalWallStruct : virtual public BoundaryConditionStruct -//{ -// Vec3 velocity; -// real lambda; -// real S; -//}; - -struct PressureStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - real p0; -}; - -struct GKSGPU_EXPORT Pressure : public BoundaryCondition -{ - real p0; - - Pressure( SPtr<DataBase> dataBase, real p0 ); - - virtual bool isWall() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - PressureStruct toStruct() - { - PressureStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.p0 = this->p0; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/Pressure2.cu b/src/gpu/GksGpu/BoundaryConditions/Pressure2.cu deleted file mode 100644 index c6b00d1ad5689efa1179415b3a6a3ff555700409..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Pressure2.cu +++ /dev/null @@ -1,188 +0,0 @@ -#include "Pressure2.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const Pressure2Struct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const Pressure2Struct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void Pressure2::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - cudaDeviceSynchronize(); - - getLastCudaError("Pressure::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const Pressure2Struct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const Pressure2Struct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - uint secondCellIdx = boundaryCondition.secondCells[ startIndex + index ]; - - PrimitiveVariables ghostCellPrim; - { - PrimitiveVariables domainCellPrim; - PrimitiveVariables secondCellPrim; - - { - ConservedVariables domainCellData; - readCellData( domainCellIdx, dataBase, domainCellData ); - domainCellPrim = toPrimitiveVariables( domainCellData, parameters.K ); - - ConservedVariables secondCellData; - if( secondCellIdx != INVALID_INDEX ){ - readCellData( secondCellIdx, dataBase, secondCellData ); - secondCellPrim = toPrimitiveVariables( secondCellData, parameters.K ); - } - } - - //ghostCellPrim.rho = two * domainCellPrim.rho - secondCellPrim.rho; - ghostCellPrim.U = c2o1 * domainCellPrim.U - secondCellPrim.U; - ghostCellPrim.V = c2o1 * domainCellPrim.V - secondCellPrim.V; - ghostCellPrim.W = c2o1 * domainCellPrim.W - secondCellPrim.W; - //ghostCellPrim.lambda = two * domainCellPrim.lambda - secondCellPrim.lambda; - ghostCellPrim.lambda = domainCellPrim.lambda; - #ifdef USE_PASSIVE_SCALAR - //ghostCellPrim.S_1 = two * domainCellPrim.S_1 - secondCellPrim.S_1; - //ghostCellPrim.S_2 = two * domainCellPrim.S_2 - secondCellPrim.S_2; - ghostCellPrim.S_1 = domainCellPrim.S_1; - ghostCellPrim.S_2 = domainCellPrim.S_2; - //ghostCellPrim.S_1 = zero; - //ghostCellPrim.S_2 = zero; - #endif // USE_PASSIVE_SCALAR - - - real rho0 = ( c2o1 * boundaryCondition.p0 * c1o2 * ( domainCellPrim.lambda + ghostCellPrim.lambda ) ); - ghostCellPrim.rho = c2o1 * rho0 - domainCellPrim.rho; - - //real lambda0 = ( c1o2 * ( domainCellPrim.rho + ghostCellPrim.rho ) * c1o2 / boundaryCondition.p0 ); - //ghostCellPrim.lambda = two * lambda0 - domainCellPrim.lambda; - - ////////////////////////////////////////////////////////////////////////// - - real xGhostCell = dataBase.cellCenter[VEC_X(ghostCellIdx, dataBase.numberOfCells)]; - real yGhostCell = dataBase.cellCenter[VEC_Y(ghostCellIdx, dataBase.numberOfCells)]; - real zGhostCell = dataBase.cellCenter[VEC_Z(ghostCellIdx, dataBase.numberOfCells)]; - - real xDomainCell = dataBase.cellCenter[VEC_X(domainCellIdx, dataBase.numberOfCells)]; - real yDomainCell = dataBase.cellCenter[VEC_Y(domainCellIdx, dataBase.numberOfCells)]; - real zDomainCell = dataBase.cellCenter[VEC_Z(domainCellIdx, dataBase.numberOfCells)]; - - real dx = xGhostCell - xDomainCell; - real dy = yGhostCell - yDomainCell; - real dz = zGhostCell - zDomainCell; - - real sign = domainCellPrim.U * dx - + domainCellPrim.V * dy - + domainCellPrim.W * dz; - - ////////////////////////////////////////////////////////////////////////// - - if( sign < c0o1 ) - { - //ghostCellPrim.U = - domainCellPrim.U; - //ghostCellPrim.V = - domainCellPrim.V; - //ghostCellPrim.W = - domainCellPrim.W; - ghostCellPrim.U = c0o1; - ghostCellPrim.V = c0o1; - ghostCellPrim.W = c0o1; - } - } - - ////////////////////////////////////////////////////////////////////////// - - - { - ConservedVariables ghostCons = toConservedVariables( ghostCellPrim, parameters.K ); - - writeCellData( ghostCellIdx, dataBase, ghostCons ); - } -} - -Pressure2::Pressure2(SPtr<DataBase> dataBase, real p0) - : BoundaryCondition( dataBase ) -{ - this->p0 = p0; -} - -bool Pressure2::isWall() -{ - return false; -} - -bool Pressure2::secondCellsNeeded() -{ - return true; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/Pressure2.h b/src/gpu/GksGpu/BoundaryConditions/Pressure2.h deleted file mode 100644 index 18dc531a5240af42b84ef484980f54b5b47a9d82..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Pressure2.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef Pressure2_CUH -#define Pressure2_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -//struct IsothermalWallStruct : virtual public BoundaryConditionStruct -//{ -// Vec3 velocity; -// real lambda; -// real S; -//}; - -struct Pressure2Struct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - real p0; -}; - -struct GKSGPU_EXPORT Pressure2 : public BoundaryCondition -{ - real p0; - - Pressure2( SPtr<DataBase> dataBase, real p0 ); - - virtual bool isWall() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - Pressure2Struct toStruct() - { - Pressure2Struct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.p0 = this->p0; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/SalinasVazquez.cu b/src/gpu/GksGpu/BoundaryConditions/SalinasVazquez.cu deleted file mode 100644 index afb2065b4cbef2b60db5010d8eb0d750b0320dbd..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/SalinasVazquez.cu +++ /dev/null @@ -1,176 +0,0 @@ -#include "SalinasVazquez.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const SalinasVazquezStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const SalinasVazquezStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void SalinasVazquez::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - getLastCudaError("IsothermalWall::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const SalinasVazquezStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const SalinasVazquezStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - uint secondCellIdx = boundaryCondition.secondCells[ startIndex + index ]; - - real lambda; - { - real x = dataBase.cellCenter[ VEC_X(ghostCellIdx, dataBase.numberOfCells) ]; - - real TMX = c1o1 / boundaryCondition.lambdaMX; - real TPX = c1o1 / boundaryCondition.lambdaPX; - - real T = TPX + ( TMX - TPX ) * ( boundaryCondition.a0 - + boundaryCondition.a1*x - + boundaryCondition.a2*x*x - + boundaryCondition.a3*x*x*x ); - - lambda = c1o1 / T; - } - - PrimitiveVariables ghostCellPrim; - { - PrimitiveVariables domainCellPrim; - PrimitiveVariables secondCellPrim; - - { - ConservedVariables domainCellData; - readCellData( domainCellIdx, dataBase, domainCellData ); - domainCellPrim = toPrimitiveVariables( domainCellData, parameters.K ); - - ConservedVariables secondCellData; - if( secondCellIdx != INVALID_INDEX ){ - readCellData( secondCellIdx, dataBase, secondCellData ); - secondCellPrim = toPrimitiveVariables( secondCellData, parameters.K ); - } - } - - ghostCellPrim.U = - domainCellPrim.U; - ghostCellPrim.V = - domainCellPrim.V; - ghostCellPrim.W = - domainCellPrim.W; - ghostCellPrim.lambda = c2o1 * lambda - domainCellPrim.lambda; - #ifdef USE_PASSIVE_SCALAR - ghostCellPrim.S_1 = domainCellPrim.S_1; - ghostCellPrim.S_2 = domainCellPrim.S_2; - #endif // USE_PASSIVE_SCALAR - - - if( boundaryCondition.useSecondCells && secondCellIdx != INVALID_INDEX ){ - real p1 = c1o2 * domainCellPrim.rho / domainCellPrim.lambda; - real p2 = c1o2 * secondCellPrim.rho / secondCellPrim.lambda; - - ghostCellPrim.rho = c2o1 * ( c2o1 * p1 - p2 ) * ghostCellPrim.lambda; - } - else{ - real p = c1o2 * domainCellPrim.rho / domainCellPrim.lambda; - - ghostCellPrim.rho = c2o1 * p * ghostCellPrim.lambda; - } - } - - { - ConservedVariables ghostCons = toConservedVariables( ghostCellPrim, parameters.K ); - - writeCellData( ghostCellIdx, dataBase, ghostCons ); - } -} - -SalinasVazquez::SalinasVazquez(SPtr<DataBase> dataBase, real lambdaMX, real lambdaPX, real a0, real a1, real a2, real a3, bool useSecondCells) - : BoundaryCondition( dataBase ) -{ - this->lambdaMX = lambdaMX; - this->lambdaPX = lambdaPX; - - this->a0 = a0; - this->a1 = a1; - this->a2 = a2; - this->a3 = a3; - - this->useSecondCells = useSecondCells; -} - -bool SalinasVazquez::isWall() -{ - return true; -} - -bool SalinasVazquez::secondCellsNeeded() -{ - return true; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/SalinasVazquez.h b/src/gpu/GksGpu/BoundaryConditions/SalinasVazquez.h deleted file mode 100644 index 5769b157e987ffe280da40919ce80e0f6e5de9ed..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/SalinasVazquez.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef SalinasVazquez_CUH -#define SalinasVazquez_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct SalinasVazquezStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - real lambdaMX; - real lambdaPX; - - real a0, a1, a2, a3; - - bool useSecondCells; -}; - -struct GKSGPU_EXPORT SalinasVazquez : public BoundaryCondition //, public IsothermalWallStruct -{ - real lambdaMX; - real lambdaPX; - - real a0, a1, a2, a3; - - bool useSecondCells; - - SalinasVazquez( SPtr<DataBase> dataBase, real lambdaMX, real lambdaPX, real a0, real a1, real a2, real a3, bool useSecondCells ); - - virtual bool isWall() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - SalinasVazquezStruct toStruct() - { - SalinasVazquezStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.lambdaMX = this->lambdaMX; - boundaryCondition.lambdaPX = this->lambdaPX; - - boundaryCondition.a0 = this->a0; - boundaryCondition.a1 = this->a1; - boundaryCondition.a2 = this->a2; - boundaryCondition.a3 = this->a3; - - boundaryCondition.useSecondCells = this->useSecondCells; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/BoundaryConditions/Symmetry.cu b/src/gpu/GksGpu/BoundaryConditions/Symmetry.cu deleted file mode 100644 index c4e104cf095125fd40bb0d06ab707697d84826ee..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Symmetry.cu +++ /dev/null @@ -1,128 +0,0 @@ -#include "Symmetry.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu{ - -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel ( const DataBaseStruct dataBase, - const SymmetryStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void boundaryConditionFunction( const DataBaseStruct& dataBase, - const SymmetryStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void Symmetry::runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) -{ - CudaUtility::CudaGrid grid( this->numberOfCellsPerLevel[ level ], 32 ); - - runKernel( boundaryConditionKernel, - boundaryConditionFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->toStruct(), - parameters, - this->startOfCellsPerLevel[ level ] ); - - getLastCudaError("IsothermalWall::runBoundaryConditionKernel( const SPtr<DataBase> dataBase, const Parameters parameters, const uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void boundaryConditionKernel(const DataBaseStruct dataBase, - const SymmetryStruct boundaryCondition, - const Parameters parameters, - const uint startIndex, - const uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - boundaryConditionFunction( dataBase, boundaryCondition, parameters, startIndex, index ); -} - -__host__ __device__ inline void boundaryConditionFunction(const DataBaseStruct& dataBase, - const SymmetryStruct& boundaryCondition, - const Parameters& parameters, - const uint startIndex, - const uint index) -{ - uint ghostCellIdx = boundaryCondition.ghostCells [ startIndex + index ]; - uint domainCellIdx = boundaryCondition.domainCells[ startIndex + index ]; - - ////////////////////////////////////////////////////////////////////////// - - ConservedVariables domainCellData; - readCellData ( domainCellIdx, dataBase, domainCellData ); - - ////////////////////////////////////////////////////////////////////////// - - PrimitiveVariables domainCellPrim = toPrimitiveVariables( domainCellData, parameters.K ); - PrimitiveVariables ghostCellPrim = toPrimitiveVariables( domainCellData, parameters.K ); - - ////////////////////////////////////////////////////////////////////////// - - if( boundaryCondition.direction == 'x' ) ghostCellPrim.U = - domainCellPrim.U; - if( boundaryCondition.direction == 'y' ) ghostCellPrim.V = - domainCellPrim.V; - if( boundaryCondition.direction == 'z' ) ghostCellPrim.W = - domainCellPrim.W; - - ////////////////////////////////////////////////////////////////////////// - - ConservedVariables ghostCellData = toConservedVariables(ghostCellPrim, parameters.K); - - writeCellData( ghostCellIdx , dataBase, ghostCellData ); -} - -Symmetry::Symmetry(SPtr<DataBase> dataBase, char direction) - : BoundaryCondition( dataBase ) -{ - this->direction = direction; -} - -bool Symmetry::isWall() -{ - return true; -} - -bool Symmetry::secondCellsNeeded() -{ - return false; -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/BoundaryConditions/Symmetry.h b/src/gpu/GksGpu/BoundaryConditions/Symmetry.h deleted file mode 100644 index 6fd73fa3894fa500d21b4b5cb7e2f19a8b6fb61b..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/BoundaryConditions/Symmetry.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef Symmetry_CUH -#define Symmetry_CUH - -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "BoundaryConditions/BoundaryCondition.h" - -namespace GksGpu{ - -struct SymmetryStruct -{ - uint numberOfCells; - - uint* ghostCells; - uint* domainCells; - uint* secondCells; - - char direction; -}; - -struct GKSGPU_EXPORT Symmetry : public BoundaryCondition //, public IsothermalWallStruct -{ - char direction; - - Symmetry( SPtr<DataBase> dataBase, char direction ); - - virtual bool isWall() override; - - virtual bool secondCellsNeeded() override; - - virtual void runBoundaryConditionKernel(const SPtr<DataBase> dataBase, - const Parameters parameters, - const uint level) override; - - SymmetryStruct toStruct() - { - SymmetryStruct boundaryCondition; - - boundaryCondition.numberOfCells = this->numberOfCells; - - boundaryCondition.ghostCells = this->ghostCells; - boundaryCondition.domainCells = this->domainCells; - boundaryCondition.secondCells = this->secondCells; - - boundaryCondition.direction = this->direction; - - return boundaryCondition; - } -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/CMakeLists.txt b/src/gpu/GksGpu/CMakeLists.txt deleted file mode 100644 index 6db6cbac1ff60c76986c3c22cc8017300d4f71ea..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -project(GksGpu LANGUAGES CUDA CXX) - -vf_add_library(PRIVATE_LINK basics lbm GksMeshAdapter OpenMP::OpenMP_CXX MPI::MPI_CXX) - -target_include_directories(GksGpu PRIVATE "${VF_THIRD_DIR}/cuda_samples/") - -if (NOT MSVC) - target_compile_options(GksGpu PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-fPIC>") -endif() - diff --git a/src/gpu/GksGpu/CellProperties/CellProperties.cuh b/src/gpu/GksGpu/CellProperties/CellProperties.cuh deleted file mode 100644 index 08731b9f52cdc54cc41d5e239ac05ee6e88fecd7..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/CellProperties/CellProperties.cuh +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef CellProperties_H -#define CellProperties_H - -#ifdef __CUDACC__ -#include <cuda_runtime.h> -#else -#ifndef __host__ -#define __host__ -#endif -#ifndef __device__ -#define __device__ -#endif -#endif - -////////////////////////////////////////////////////////////////////////// - -#define CELL_PROPERTIES_DEFAULT (0u) -#define CELL_PROPERTIES_GHOST (1u) -#define CELL_PROPERTIES_WALL (2u) -#define CELL_PROPERTIES_FINE_GHOST (4u) -#define CELL_PROPERTIES_IS_FLUX_BC (8u) -#define CELL_PROPERTIES_IS_INSULATED (16u) -#define CELL_PROPERTIES_5 (32u) -#define CELL_PROPERTIES_6 (64u) -#define CELL_PROPERTIES_7 (128u) - -////////////////////////////////////////////////////////////////////////// - -namespace GksGpu { - -typedef unsigned char CellProperties; - -////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void setCellProperties( CellProperties& left, const CellProperties& right ) -{ - left |= right; -} - -__host__ __device__ inline void unsetCellProperties( CellProperties& left, const CellProperties& right ) -{ - left &= ~right; -} - -__host__ __device__ inline bool isCellProperties( const CellProperties& left, const CellProperties& right ) -{ - return (left & right) == right; -} - -////////////////////////////////////////////////////////////////////////// - -} // namespace GksGpu - -#endif - diff --git a/src/gpu/GksGpu/CellUpdate/CellUpdate.cu b/src/gpu/GksGpu/CellUpdate/CellUpdate.cu deleted file mode 100644 index ccc7ab12c8ffb9fa183873b36b5faef16a50d793..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/CellUpdate/CellUpdate.cu +++ /dev/null @@ -1,220 +0,0 @@ -#include "CellUpdate.h" - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> -#include <math.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/ThermalDependencies.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CellUpdate/Reaction.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu { - -__global__ void cellUpdateKernel ( DataBaseStruct dataBase, Parameters parameters, uint startIndex, uint numberOfEntities ); - -__host__ __device__ inline void cellUpdateFunction( DataBaseStruct dataBase, Parameters parameters, uint startIndex, uint index ); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CellUpdate::run( SPtr<DataBase> dataBase, Parameters parameters, uint level ) -{ - CudaUtility::CudaGrid grid( dataBase->perLevelCount[ level ].numberOfBulkCells, 32 ); - - runKernel( cellUpdateKernel, - cellUpdateFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - parameters, - dataBase->perLevelCount[ level ].startOfCells ); - - cudaDeviceSynchronize(); - - getLastCudaError("CellUpdate::run( SPtr<DataBase> dataBase, Parameters parameters, uint level )"); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__global__ void cellUpdateKernel(DataBaseStruct dataBase, Parameters parameters, uint startIndex, uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - cellUpdateFunction( dataBase, parameters, startIndex, index ); -} - -__host__ __device__ inline void cellUpdateFunction(DataBaseStruct dataBase, Parameters parameters, uint startIndex, uint index) -{ - uint cellIndex = startIndex + index; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //CellProperties cellProperties = dataBase.cellProperties[ cellIndex ]; - - //if( isCellProperties( cellProperties, CELL_PROPERTIES_FINE_GHOST ) ); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real cellVolume = parameters.dx * parameters.dx * parameters.dx; - - ConservedVariables cons; - - readCellData (cellIndex, dataBase, cons); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - { - ConservedVariables update, zeroCons; - readCellDataUpdate(cellIndex, dataBase, update); - writeCellDataUpdate(cellIndex, dataBase, zeroCons); - - ////////////////////////////////////////////////////////////////////////// - // dirty fix to exclude viscous heating: Part 1 - //ConservedVariables testCons = cons; - //testCons.rho += update.rho / cellVolume; - //testCons.rhoE += update.rhoE/ cellVolume; - //PrimitiveVariables testPrim = toPrimitiveVariables(testCons, parameters.K); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - //if( cellIndex == 415179 ) - //{ - // //printf( "rho = %14.4e | dRho = %14.4e \n", cons.rho , (one / cellVolume) * update.rho ); - // //printf( "rhoU = %14.4e | dRhoU = %14.4e \n", cons.rhoU , (one / cellVolume) * update.rhoU ); - // //printf( "rhoV = %14.4e | dRhoV = %14.4e \n", cons.rhoV , (one / cellVolume) * update.rhoV ); - // //printf( "rhoW = %14.4e | dRhoW = %14.4e \n", cons.rhoW , (one / cellVolume) * update.rhoW ); - // printf( "rhoE = %14.4e | dRhoE = %14.4e \n", cons.rhoE , (one / cellVolume) * update.rhoE ); - // //printf( "rhoS1 = %14.4e | dRhoS1 = %14.4e \n", cons.rhoS_1, (one / cellVolume) * update.rhoS_1 ); - // //printf( "rhoS2 = %14.4e | dRhoS2 = %14.4e \n", cons.rhoS_2, (one / cellVolume) * update.rhoS_2 ); - // printf( "=================================================================\n" ); - //} - ////////////////////////////////////////////////////////////////////////// - - cons = cons + (c1o1 / cellVolume) * update; - - ////////////////////////////////////////////////////////////////////////// - // dirty fix to exclude viscous heating: Part 2 - //PrimitiveVariables prim = toPrimitiveVariables(cons, parameters.K); - //prim.lambda = testPrim.lambda; - //cons = toConservedVariables( prim, parameters.K ); - ////////////////////////////////////////////////////////////////////////// - - if( isnan(cons.rho ) || - isnan(cons.rhoU) || - isnan(cons.rhoV) || - isnan(cons.rhoW) || - isnan(cons.rhoE) ) - { - *dataBase.crashCellIndex = cellIndex; - } - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - if(parameters.forcingSchemeIdx == 0) - { - // consistent source term treatment of Tian et al. (2007) - cons.rhoU += parameters.force.x * parameters.dt * cons.rho; - cons.rhoV += parameters.force.y * parameters.dt * cons.rho; - cons.rhoW += parameters.force.z * parameters.dt * cons.rho; - cons.rhoE += parameters.force.x * dataBase.massFlux[VEC_X(cellIndex, dataBase.numberOfCells)] / (c6o1 * parameters.dx * parameters.dx) - + parameters.force.y * dataBase.massFlux[VEC_Y(cellIndex, dataBase.numberOfCells)] / (c6o1 * parameters.dx * parameters.dx) - + parameters.force.z * dataBase.massFlux[VEC_Z(cellIndex, dataBase.numberOfCells)] / (c6o1 * parameters.dx * parameters.dx); - - dataBase.massFlux[VEC_X(cellIndex, dataBase.numberOfCells)] = c0o1; - dataBase.massFlux[VEC_Y(cellIndex, dataBase.numberOfCells)] = c0o1; - dataBase.massFlux[VEC_Z(cellIndex, dataBase.numberOfCells)] = c0o1; - } - - if(parameters.forcingSchemeIdx == 1) - { - // forcing only on density variation - cons.rhoU += parameters.force.x * parameters.dt * ( cons.rho - parameters.rhoRef ); - cons.rhoV += parameters.force.y * parameters.dt * ( cons.rho - parameters.rhoRef ); - cons.rhoW += parameters.force.z * parameters.dt * ( cons.rho - parameters.rhoRef ); - cons.rhoE += parameters.force.x * dataBase.massFlux[VEC_X(cellIndex, dataBase.numberOfCells)] / (c6o1 * parameters.dx * parameters.dx) - + parameters.force.y * dataBase.massFlux[VEC_Y(cellIndex, dataBase.numberOfCells)] / (c6o1 * parameters.dx * parameters.dx) - + parameters.force.z * dataBase.massFlux[VEC_Z(cellIndex, dataBase.numberOfCells)] / (c6o1 * parameters.dx * parameters.dx); - - dataBase.massFlux[VEC_X(cellIndex, dataBase.numberOfCells)] = c0o1; - dataBase.massFlux[VEC_Y(cellIndex, dataBase.numberOfCells)] = c0o1; - dataBase.massFlux[VEC_Z(cellIndex, dataBase.numberOfCells)] = c0o1; - } - - if(parameters.forcingSchemeIdx == 2) - { - PrimitiveVariables prim = toPrimitiveVariables(cons, parameters.K); - real lambda = prim.lambda; - - // forcing only on density variation - cons.rhoU += parameters.force.x * parameters.dt * ( cons.rho - parameters.rhoRef ); - cons.rhoV += parameters.force.y * parameters.dt * ( cons.rho - parameters.rhoRef ); - cons.rhoW += parameters.force.z * parameters.dt * ( cons.rho - parameters.rhoRef ); - //cons.rhoE += parameters.force.x * dataBase.massFlux[VEC_X(cellIndex, dataBase.numberOfCells)] / (six * parameters.dx * parameters.dx) - // + parameters.force.y * dataBase.massFlux[VEC_Y(cellIndex, dataBase.numberOfCells)] / (six * parameters.dx * parameters.dx) - // + parameters.force.z * dataBase.massFlux[VEC_Z(cellIndex, dataBase.numberOfCells)] / (six * parameters.dx * parameters.dx); - - prim = toPrimitiveVariables(cons, parameters.K); - prim.lambda = lambda; - cons = toConservedVariables(prim, parameters.K); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // mass conserving fix for out of bounds scalars - - //if( cons.rhoS_1 < zero ) { cons.rhoS_2 -= cons.rhoS_1; cons.rhoS_1 = zero; } - //if( cons.rhoS_2 < zero ) { cons.rhoS_1 -= cons.rhoS_2; cons.rhoS_2 = zero; } - - //if( cons.rhoS_1 > cons.rho ) { cons.rhoS_2 += cons.rhoS_1 - cons.rho; cons.rhoS_1 = cons.rho; } - //if( cons.rhoS_2 > cons.rho ) { cons.rhoS_1 += cons.rhoS_2 - cons.rho; cons.rhoS_2 = cons.rho; } - - //if( cons.rhoS_1 + cons.rhoS_2 > cons.rho ) - //{ - // real faktor = (Z1 + Z2); - - // Z1 /= faktor; - // Z2 /= faktor; - //} - - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - chemicalReaction(dataBase, parameters, cellIndex, cons); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Dirty fix that limits the velocity - - //PrimitiveVariables prim = toPrimitiveVariables(cons, parameters.K); - - //real velocity = sqrt( prim.U * prim.U + prim.V * prim.V + prim.W * prim.W ); - - //if( velocity > five ) - //{ - // prim.U *= five / velocity; - // prim.V *= five / velocity; - // prim.W *= five / velocity; - //} - - //cons = toConservedVariables(prim, parameters.K); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - writeCellData(cellIndex, dataBase, cons); -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/CellUpdate/CellUpdate.h b/src/gpu/GksGpu/CellUpdate/CellUpdate.h deleted file mode 100644 index de8a0b86ca5de9501046ffaa1235c70122bf91e8..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/CellUpdate/CellUpdate.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef CellUpdate_H -#define CellUpdate_H - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" - -#include "DataBase/DataBase.h" -#include "Parameters/Parameters.h" - -namespace GksGpu { - -class GKSGPU_EXPORT CellUpdate -{ -public: - - static void run( SPtr<DataBase> dataBase, - Parameters parameters, - uint level ); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/CellUpdate/Reaction.cuh b/src/gpu/GksGpu/CellUpdate/Reaction.cuh deleted file mode 100644 index 21ba61220fd7b81fbb53002ea090d278d228bb66..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/CellUpdate/Reaction.cuh +++ /dev/null @@ -1,191 +0,0 @@ -#include "CellUpdate.h" - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> -#include <math.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/ThermalDependencies.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu { - -inline __host__ __device__ real getTurbulentViscosityDeardorff(const DataBaseStruct& dataBase, const Parameters& parameters, const uint cellIndex, const ConservedVariables& cons ) -{ - // See FDS 6 Technical Reference Guide, Section 4.2.3 - - PrimitiveVariables prim = toPrimitiveVariables(cons, parameters.K); - - ConservedVariables neighborCons; - PrimitiveVariables neighborPrim; - - real kSGS = c0o1; - - { - real uHead = c1o2 * prim.U; - - { - // uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 0, dataBase.numberOfCells)]; - readCellData(cellIndex, dataBase, neighborCons); - neighborPrim = toPrimitiveVariables(neighborCons, parameters.K); - - uHead += c1o4 * neighborPrim.U; - } - { - // uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 1, dataBase.numberOfCells)]; - readCellData(cellIndex, dataBase, neighborCons); - neighborPrim = toPrimitiveVariables(neighborCons, parameters.K); - - uHead += c1o4 * neighborPrim.U; - } - - kSGS += c1o2 * ( prim.U - uHead ) * ( prim.U - uHead ); - } - - { - real vHead = c1o2 * prim.V; - - { - // uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 2, dataBase.numberOfCells)]; - readCellData(cellIndex, dataBase, neighborCons); - neighborPrim = toPrimitiveVariables(neighborCons, parameters.K); - - vHead += c1o4 * neighborPrim.V; - } - { - // uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 3, dataBase.numberOfCells)]; - readCellData(cellIndex, dataBase, neighborCons); - neighborPrim = toPrimitiveVariables(neighborCons, parameters.K); - - vHead += c1o4 * neighborPrim.V; - } - - kSGS += c1o2 * ( prim.V - vHead ) * ( prim.V - vHead ); - } - - { - real wHead = c1o2 * prim.W; - - { - // uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 4, dataBase.numberOfCells)]; - readCellData(cellIndex, dataBase, neighborCons); - neighborPrim = toPrimitiveVariables(neighborCons, parameters.K); - - wHead += c1o4 * neighborPrim.W; - } - { - // uint neighborCellIndex = dataBase.cellToCell[CELL_TO_CELL(cellIndex, 5, dataBase.numberOfCells)]; - readCellData(cellIndex, dataBase, neighborCons); - neighborPrim = toPrimitiveVariables(neighborCons, parameters.K); - - wHead += c1o4 * neighborPrim.W; - } - - kSGS += c1o2 * ( prim.W - wHead ) * ( prim.W - wHead ); - } - - //real turbulentViscosity = prim.rho * parameters.dx * c1o10 * sqrt(kSGS) / 0.3; - - dataBase.diffusivity[cellIndex] = (realAccumulator) kSGS; - - //printf("%f", kSGS); - - return kSGS; -} - - - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void chemicalReaction(DataBaseStruct dataBase, Parameters parameters, uint cellIndex, ConservedVariables& cons) -{ - // see FDS 5 Technical reference guide, section 6.1.4 for combustion model -#ifdef USE_PASSIVE_SCALAR - if (parameters.enableReaction) - { - CellProperties cellProperties = dataBase.cellProperties[ cellIndex ]; - - if( isCellProperties( cellProperties, CELL_PROPERTIES_FINE_GHOST ) ) return; - - PrimitiveVariables prim = toPrimitiveVariables(cons, parameters.K); - - ////////////////////////////////////////////////////////////////////////// - - //real diffusivity = getTurbulentViscosityDeardorff(dataBase, parameters, cellIndex, cons); - //real diffusivity = dataBase.diffusivity[ cellIndex ]; - real diffusivity = dataBase.diffusivity[ cellIndex ] / ( c6o1 * parameters.dx * parameters.dx * parameters.dt ); - dataBase.diffusivity[ cellIndex ] = c0o1; - - ////////////////////////////////////////////////////////////////////////// - - real mixingTimeScale = real(0.1) * parameters.dx * parameters.dx / diffusivity; - - //real kSGS = getTurbulentViscosityDeardorff(dataBase, parameters, cellIndex, cons); - - //real mixingTimeScale_d = parameters.dx * parameters.dx / parameters.D; - - //real mixingTimeScale_u = real(0.4) * parameters.dx / sqrt( c2o3 * kSGS ); - - //real mixingTimeScale_g = sqrt( c2o1 * parameters.dx / fabs( parameters.force.z ) ); - - //real mixingTimeScale = fminf( mixingTimeScale_d, mixingTimeScale_u ); - //mixingTimeScale = fminf( mixingTimeScale_g, mixingTimeScale ); - - ////////////////////////////////////////////////////////////////////////// - - real Y_F = prim.S_1; - real Y_P = prim.S_2; - - real Y_A = c1o1 - Y_F - Y_P; - - /////////////////////////////////////////////////////////////////////////////// - - real Y_O2 = rX * ( M_O2 / M_A ) * Y_A; - - /////////////////////////////////////////////////////////////////////////////// - - real s = M_F / ( c2o1 * M_O2 ); - - real heatReleaseRate = cons.rho * fminf(Y_F, s * Y_O2) / mixingTimeScale * ( parameters.heatOfReaction / M_F ); - - ////////////////////////////////////////////////////////////////////////// - - if( heatReleaseRate < c0o1 ) - heatReleaseRate = c0o1; - - ////////////////////////////////////////////////////////////////////////// - - if( parameters.useHeatReleaseRateLimiter ) - if( heatReleaseRate > parameters.heatReleaseRateLimiter ) - heatReleaseRate = parameters.heatReleaseRateLimiter; - - ////////////////////////////////////////////////////////////////////////// - - real drhoY_F = heatReleaseRate * parameters.dt / ( parameters.heatOfReaction / M_F ); - - //real r = c1o1 + ( c1o2 / rX ) * ( M_A / M_F ); - real r = c1o1 + ( c2o1 / rX ) * ( M_A / M_F ); - - cons.rhoS_1 -= drhoY_F; - cons.rhoS_2 += r * drhoY_F; - cons.rhoE += heatReleaseRate * parameters.dt; - - ////////////////////////////////////////////////////////////////////////// - } - -#endif // USE_PASSIVE_SCALAR -} - -} // namespace GksGpu \ No newline at end of file diff --git a/src/gpu/GksGpu/Communication/Communicator.cpp b/src/gpu/GksGpu/Communication/Communicator.cpp deleted file mode 100644 index 6f4fc0fa575e5c6908ca8a55000b40f78733a781..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Communication/Communicator.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "Communicator.h" - -#ifdef VF_DOUBLE_ACCURACY -#define MPI_TYPE_GPU MPI_DOUBLE -#else -#define MPI_TYPE_GPU MPI_FLOAT -#endif - -#define _USE_MATH_DEFINES -#include <math.h> -#include <iostream> - -#include "PointerDefinitions.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseAllocator.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/CudaAwareMpi.h" - -#include "CudaUtility/CudaUtility.h" - -namespace GksGpu { - -int Communicator::tagSendPositive = 0; -int Communicator::tagSendNegative = 1; - -Communicator::Communicator( SPtr<DataBase> dataBase ) - : myAllocator ( dataBase->myAllocator ) -{ - this->numberOfSendNodes = INVALID_INDEX; - this->numberOfRecvNodes = INVALID_INDEX; - - this->sendIndices = nullptr; - this->recvIndices = nullptr; - this->sendBuffer = nullptr; - this->recvBuffer = nullptr; - this->sendBufferHost = nullptr; - this->recvBufferHost = nullptr; - - this->sendBufferIsReady = MPI_REQUEST_NULL; -} - -void Communicator::initialize(GksMeshAdapter & adapter, uint level, uint direction) -{ - this->myAllocator->freeMemory( *this ); - - this->numberOfSendNodes = adapter.communicationIndices[level].sendIndices[direction].size(); - this->numberOfRecvNodes = adapter.communicationIndices[level].recvIndices[direction].size(); - - this->myAllocator->allocateMemory( *this, adapter.communicationIndices[level].sendIndices[direction], - adapter.communicationIndices[level].recvIndices[direction] ); - - this->opposingRank = adapter.communicationProcesses[direction]; -} - -void Communicator::sendData( SPtr<DataBase> dataBase, int tag ) -{ -#ifdef USE_CUDA_AWARE_MPI - - this->copyFromMeshToSendBuffer( dataBase ); - - MPI_Isend( this->sendBuffer, this->numberOfSendNodes * LENGTH_CELL_DATA, MPI_TYPE_GPU, this->opposingRank, tag, MPI_COMM_WORLD, &this->sendBufferIsReady ); - -#else // USE_CUDA_AWARE_MPI - - this->copyFromMeshToSendBuffer( dataBase ); - - MPI_Wait(&this->sendBufferIsReady, MPI_STATUSES_IGNORE); - - this->myAllocator->copyBuffersDeviceToHost( shared_from_this() ); - - CudaUtility::synchronizeCudaStream( CudaUtility::communicationStream ); - - MPI_Isend( this->sendBufferHost, this->numberOfSendNodes * LENGTH_CELL_DATA, MPI_TYPE_GPU, this->opposingRank, tag, MPI_COMM_WORLD, &this->sendBufferIsReady ); - -#endif // USE_CUDA_AWARE_MPI -} - -void Communicator::recvData( SPtr<DataBase> dataBase, int tag ) -{ -#ifdef USE_CUDA_AWARE_MPI - - MPI_Recv ( this->recvBuffer, this->numberOfRecvNodes * LENGTH_CELL_DATA, MPI_TYPE_GPU, this->opposingRank, tag, MPI_COMM_WORLD, MPI_STATUSES_IGNORE ); - - this->copyFromRecvBufferToMesh( dataBase ); - -#else // USE_CUDA_AWARE_MPI - - MPI_Recv ( this->recvBufferHost, this->numberOfRecvNodes * LENGTH_CELL_DATA, MPI_TYPE_GPU, this->opposingRank, tag, MPI_COMM_WORLD, MPI_STATUSES_IGNORE ); - - this->myAllocator->copyBuffersHostToDevice( shared_from_this() ); - - this->copyFromRecvBufferToMesh( dataBase ); - -#endif // USE_CUDA_AWARE_MPI -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/Communication/Communicator.cu b/src/gpu/GksGpu/Communication/Communicator.cu deleted file mode 100644 index 58951afdef57d6eb53fd7b6ab278d0df63cf00d2..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Communication/Communicator.cu +++ /dev/null @@ -1,165 +0,0 @@ -#include "Communicator.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "DataBase/DataBase.h" -#include "DataBase/DataBaseAllocator.h" -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu { - -////////////////////////////////////////////////////////////////////////// - -__global__ void sendBufferKernel ( const DataBaseStruct dataBase, - const uint numberOfSendNodes, - const uint* sendIndices, - real* sendBuffer, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void sendBufferFunction( const DataBaseStruct dataBase, - const uint numberOfSendNodes, - const uint* sendIndices, - real* sendBuffer, - const uint startIndex, - const uint index ); - -__global__ void recvBufferKernel ( const DataBaseStruct dataBase, - const uint numberOfRecvNodes, - const uint* recvIndices, - real* recvBuffer, - const uint startIndex, - const uint numberOfEntities ); - -__host__ __device__ inline void recvBufferFunction( const DataBaseStruct dataBase, - const uint numberOfRecvNodes, - const uint* recvIndices, - real* recvBuffer, - const uint startIndex, - const uint index ); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void Communicator::copyFromMeshToSendBuffer(const SPtr<DataBase> dataBase) -{ - CudaUtility::CudaGrid grid( this->numberOfSendNodes, 32, CudaUtility::communicationStream ); - - runKernel( sendBufferKernel, - sendBufferFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->numberOfSendNodes, - this->sendIndices, - this->sendBuffer, - 0 ); -} - -void Communicator::copyFromRecvBufferToMesh(const SPtr<DataBase> dataBase) -{ - CudaUtility::CudaGrid grid( this->numberOfRecvNodes, 32, CudaUtility::communicationStream ); - - runKernel( recvBufferKernel, - recvBufferFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - this->numberOfRecvNodes, - this->recvIndices, - this->recvBuffer, - 0 ); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__global__ void sendBufferKernel( const DataBaseStruct dataBase, - const uint numberOfSendNodes, - const uint* sendIndices, - real* sendBuffer, - const uint startIndex, - const uint numberOfEntities ) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - sendBufferFunction( dataBase, numberOfSendNodes, sendIndices, sendBuffer, startIndex, index ); -} - -__host__ __device__ inline void sendBufferFunction( const DataBaseStruct dataBase, - const uint numberOfSendNodes, - const uint* sendIndices, - real* sendBuffer, - const uint startIndex, - const uint index ) -{ - uint cellIdx = sendIndices [ index ]; - - sendBuffer[ RHO__(index, numberOfSendNodes) ] = dataBase.data[ RHO__(cellIdx, dataBase.numberOfCells) ]; - sendBuffer[ RHO_U(index, numberOfSendNodes) ] = dataBase.data[ RHO_U(cellIdx, dataBase.numberOfCells) ]; - sendBuffer[ RHO_V(index, numberOfSendNodes) ] = dataBase.data[ RHO_V(cellIdx, dataBase.numberOfCells) ]; - sendBuffer[ RHO_W(index, numberOfSendNodes) ] = dataBase.data[ RHO_W(cellIdx, dataBase.numberOfCells) ]; - sendBuffer[ RHO_E(index, numberOfSendNodes) ] = dataBase.data[ RHO_E(cellIdx, dataBase.numberOfCells) ]; -#ifdef USE_PASSIVE_SCALAR - sendBuffer[ RHO_S_1(index, numberOfSendNodes) ] = dataBase.data[ RHO_S_1(cellIdx, dataBase.numberOfCells) ]; - sendBuffer[ RHO_S_2(index, numberOfSendNodes) ] = dataBase.data[ RHO_S_2(cellIdx, dataBase.numberOfCells) ]; -#endif // USE_PASSIVE_SCALAR -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__global__ void recvBufferKernel( const DataBaseStruct dataBase, - const uint numberOfRecvNodes, - const uint* recvIndices, - real* recvBuffer, - const uint startIndex, - const uint numberOfEntities ) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - recvBufferFunction( dataBase, numberOfRecvNodes, recvIndices, recvBuffer, startIndex, index ); -} - -__host__ __device__ inline void recvBufferFunction( const DataBaseStruct dataBase, - const uint numberOfRecvNodes, - const uint* recvIndices, - real* recvBuffer, - const uint startIndex, - const uint index ) -{ - uint cellIdx = recvIndices [ index ]; - - dataBase.data[ RHO__(cellIdx, dataBase.numberOfCells) ] = recvBuffer[ RHO__(index, numberOfRecvNodes) ] ; - dataBase.data[ RHO_U(cellIdx, dataBase.numberOfCells) ] = recvBuffer[ RHO_U(index, numberOfRecvNodes) ] ; - dataBase.data[ RHO_V(cellIdx, dataBase.numberOfCells) ] = recvBuffer[ RHO_V(index, numberOfRecvNodes) ] ; - dataBase.data[ RHO_W(cellIdx, dataBase.numberOfCells) ] = recvBuffer[ RHO_W(index, numberOfRecvNodes) ] ; - dataBase.data[ RHO_E(cellIdx, dataBase.numberOfCells) ] = recvBuffer[ RHO_E(index, numberOfRecvNodes) ] ; -#ifdef USE_PASSIVE_SCALAR - dataBase.data[ RHO_S_1(cellIdx, dataBase.numberOfCells) ] = recvBuffer[ RHO_S_1(index, numberOfRecvNodes) ] ; - dataBase.data[ RHO_S_2(cellIdx, dataBase.numberOfCells) ] = recvBuffer[ RHO_S_2(index, numberOfRecvNodes) ] ; -#endif // USE_PASSIVE_SCALAR -} - -} // namespace GksGpu \ No newline at end of file diff --git a/src/gpu/GksGpu/Communication/Communicator.h b/src/gpu/GksGpu/Communication/Communicator.h deleted file mode 100644 index 4b883563705324c862cc6778480b6b09ba285587..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Communication/Communicator.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef Communicator_H -#define Communicator_H - -#include <memory> -#include <vector> -#include <mpi.h> -//#include <mutex> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -class GksMeshAdapter; - -namespace GksGpu { - -class DataBaseAllocator; -struct DataBase; - -struct GKSGPU_EXPORT Communicator : public std::enable_shared_from_this<Communicator> -{ - SPtr<DataBaseAllocator> myAllocator; - - uint numberOfSendNodes; - uint numberOfRecvNodes; - - uint* sendIndices; // device - uint* recvIndices; // device - - real* sendBuffer; // device - real* recvBuffer; // device - - real* sendBufferHost; // pinned memory - real* recvBufferHost; // pinned memory - - uint rank; - uint opposingRank; - - MPI_Request sendBufferIsReady; - - static int tagSendPositive; - static int tagSendNegative; - - ////////////////////////////////////////////////////////////////////////// - - Communicator( SPtr<DataBase> dataBase ); - - void initialize( GksMeshAdapter& adapter, uint level, uint direction ); - - void copyFromMeshToSendBuffer( SPtr<DataBase> dataBase ); - - void copyFromRecvBufferToMesh( SPtr<DataBase> dataBase ); - - void sendData( SPtr<DataBase> dataBase, int tag ); - void recvData( SPtr<DataBase> dataBase, int tag ); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Communication/MpiUtility.cpp b/src/gpu/GksGpu/Communication/MpiUtility.cpp deleted file mode 100644 index 1dbfcaf15a3023ea03f829f9d74aa84548523a04..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Communication/MpiUtility.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "MpiUtility.h" - -#include <exception> - -#define ENV_LOCAL_RANK "OMPI_COMM_WORLD_RANK" -#define ENV_COMM_WORLD_SIZE "OMPI_COMM_WORLD_SIZE" - -namespace GksGpu { - -int MpiUtility::getMpiRankBeforeInit() -{ - char * localRankStr = NULL; - - // We extract the local rank initialization using an environment variable - if ((localRankStr = getenv(ENV_LOCAL_RANK)) != NULL) - { - return atoi(localRankStr); - } - else - { - return 0; - } -} - -int MpiUtility::getMpiWorldSizeBeforeInit() -{ - char * mpiWorldSizeStr = NULL; - - // We extract the local rank initialization using an environment variable - if ((mpiWorldSizeStr = getenv(ENV_COMM_WORLD_SIZE)) != NULL) - { - return atoi(mpiWorldSizeStr); - } - else - { - return 1; - } -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/Communication/MpiUtility.h b/src/gpu/GksGpu/Communication/MpiUtility.h deleted file mode 100644 index f2aa1a8be1d18f99cfd29d91b2bcb31edc0a661f..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Communication/MpiUtility.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef MpiUtility_H -#define MpiUtility_H - -#include <mpi.h> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -class GksMeshAdapter; - -namespace GksGpu { - -class DataBaseAllocator; -struct DataBase; - -struct GKSGPU_EXPORT MpiUtility -{ - static int getMpiRankBeforeInit(); - - static int getMpiWorldSizeBeforeInit(); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/CudaUtility/CudaRunKernel.hpp b/src/gpu/GksGpu/CudaUtility/CudaRunKernel.hpp deleted file mode 100644 index 91de639cc712745cadd5f8a21e3c330dde989121..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/CudaUtility/CudaRunKernel.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef CudaRunKernel_HPP -#define CudaRunKernel_HPP - -#include <string> -#include <device_launch_parameters.h> -#include <omp.h> -#include <iostream> - -#include "CudaUtility/CudaUtility.h" - -namespace GksGpu { - -template<typename KernelFunctor, typename FunctionFunctor, typename... TArgs> -void runKernel(KernelFunctor kernel, FunctionFunctor function, std::string deviceType, const CudaUtility::CudaGrid& grid, TArgs... args) -{ - if( grid.numberOfEntities == 0 ) return; - - if( deviceType == "GPU" ) - { - kernel<<< grid.blocks, grid.threads, 0, grid.stream >>>( args..., grid.numberOfEntities ); - } - else - { -//#pragma omp parallel for - for( int index = 0; index < grid.numberOfEntities; index++ ) - { - function( args..., index ); - } - } -} - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/CudaUtility/CudaUtility.cpp b/src/gpu/GksGpu/CudaUtility/CudaUtility.cpp deleted file mode 100644 index 0cd9e948dca8522284efe3febce95320dd5f4243..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/CudaUtility/CudaUtility.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "CudaUtility.h" - -#include <iostream> -#include <cuda_runtime.h> -#include <cuda.h> -#include <helper_cuda.h> - -#include "Core/DataTypes.h" -#include "Core/Logger/Logger.h" - -namespace GksGpu { - -cudaStream_t CudaUtility::computeStream = nullptr; -cudaStream_t CudaUtility::communicationStream = nullptr; - -CudaUtility::CudaGrid::CudaGrid( uint numberOfEntities, uint threadsPerBlock, cudaStream_t stream ) -{ - this->numberOfEntities = numberOfEntities; - this->threads.x = threadsPerBlock; - this->blocks.x = ( numberOfEntities + threadsPerBlock - 1 ) / threadsPerBlock; - - this->stream = stream; -} - -void CudaUtility::printCudaMemoryUsage() -{ - size_t free_byte ; - size_t total_byte ; - - checkCudaErrors( cudaMemGetInfo( &free_byte, &total_byte ) ); - - double free_db = (double)free_byte ; - double total_db = (double)total_byte ; - double used_db = total_db - free_db ; - - *logging::out << logging::Logger::INFO_HIGH << "GPU memory usage:" << "\n"; - *logging::out << logging::Logger::INFO_HIGH << " used = " << used_db /1024.0/1024.0/1024.0 << " GB\n"; - *logging::out << logging::Logger::INFO_HIGH << " free = " << free_db /1024.0/1024.0/1024.0 << " GB\n"; - *logging::out << logging::Logger::INFO_HIGH << " total = " << total_db/1024.0/1024.0/1024.0 << " GB\n"; -} - -int CudaUtility::getCudaDeviceCount() -{ - int deviceCount = 0; - checkCudaErrors( cudaGetDeviceCount(&deviceCount) ); - return deviceCount; -} - -void CudaUtility::setCudaDevice(int device) -{ - checkCudaErrors( cudaSetDevice( device ) ); - checkCudaErrors( cudaGetDevice( &device ) ); - - cudaDeviceProp prop; - cudaGetDeviceProperties(&prop, device); - - *logging::out << logging::Logger::INFO_HIGH << "Set device " << device << ": " << prop.name << "\n"; - - // set communication stream on high priority, such that it can interleave the compute stream - // the non blocking flag disable implicit synchronization with the default thread '0' - // based on https://fenix.tecnico.ulisboa.pt/downloadFile/563568428758047/CUDA_StreamsEvents.pdf - // slide 5 - int priority_high, priority_low; - cudaDeviceGetStreamPriorityRange(&priority_low , &priority_high ) ; - - // the flag needs to be cudaStreamDefault to ensure synchronization with default stream - //cudaStreamCreateWithPriority (&communicationStream, cudaStreamDefault, priority_high ); - //cudaStreamCreateWithPriority (&computeStream , cudaStreamDefault, priority_low ); - cudaStreamCreateWithPriority (&communicationStream, cudaStreamNonBlocking, priority_high ); - cudaStreamCreateWithPriority (&computeStream , cudaStreamNonBlocking, priority_low ); -} - -int CudaUtility::getCudaDevice() -{ - int device; - checkCudaErrors( cudaGetDevice( &device ) ); - - cudaDeviceProp prop; - cudaGetDeviceProperties(&prop, device); - - *logging::out << logging::Logger::INFO_HIGH << "The current device " << device << ": " << prop.name << "\n"; - - return device; -} - -void CudaUtility::synchronizeCudaDevice() -{ - checkCudaErrors( cudaDeviceSynchronize() ); -} - -void CudaUtility::synchronizeCudaStream(cudaStream_t stream) -{ - checkCudaErrors( cudaStreamSynchronize(stream) ); -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/CudaUtility/CudaUtility.h b/src/gpu/GksGpu/CudaUtility/CudaUtility.h deleted file mode 100644 index fa312e9d41879703d04a03092e79401abc132c86..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/CudaUtility/CudaUtility.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef CudaUtilExtern_H -#define CudaUtilExtern_H - -#include <cuda.h> -#include <cuda_runtime.h> - - -#include "GksGpu_export.h" - -#include "Core/DataTypes.h" - -namespace GksGpu { - -class GKSGPU_EXPORT CudaUtility -{ -public: - - struct CudaGrid - { - dim3 threads; - dim3 blocks; - - uint numberOfEntities; - - cudaStream_t stream; - - CudaGrid( uint numberOfEntities, uint threadsPerBlock, cudaStream_t stream = 0 ); - }; - - static cudaStream_t computeStream; - static cudaStream_t communicationStream; - - static void printCudaMemoryUsage(); - - static int getCudaDeviceCount(); - - static void setCudaDevice( int device ); - - static int getCudaDevice( ); - - static void synchronizeCudaDevice(); - - static void synchronizeCudaStream( cudaStream_t stream ); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/DataBase/DataBase.cpp b/src/gpu/GksGpu/DataBase/DataBase.cpp deleted file mode 100644 index 46921a683de3dd9c322be2d89b4ca66f6fa07020..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/DataBase/DataBase.cpp +++ /dev/null @@ -1,244 +0,0 @@ -#include "DataBase.h" - -#include <iostream> -#include <string> -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "DataBaseAllocator.h" -#include "DataBaseStruct.h" - -#include "Core/Logger/Logger.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" -#include "Communication/Communicator.h" - -#include <lbm/constants/NumericConstants.h> - -using namespace vf::lbm::constant; - -namespace GksGpu { - -DataBase::DataBase( std::string type ) - : myAllocator ( DataBaseAllocator::create( type ) ), - numberOfNodes (0), - numberOfCells (0), - numberOfFaces (0), - numberOfLevels (0), - numberOfCoarseGhostCells(0), - numberOfFineGhostCells(0), - cellToCell (nullptr), - faceToCell (nullptr), - parentCell (nullptr), - faceCenter (nullptr), - cellCenter (nullptr), - cellProperties (nullptr), - faceOrientation(nullptr), - fineToCoarse (nullptr), - coarseToFine (nullptr), - data (nullptr), - dataUpdate (nullptr), - massFlux (nullptr), - diffusivity (nullptr) -{ -} - -DataBase::~DataBase() -{ - this->myAllocator->freeMemory( *this ); -} - -void DataBase::setMesh(GksMeshAdapter & adapter) -{ - this->numberOfNodes = adapter.nodes.size(); - - this->numberOfCells = adapter.cells.size(); - - this->numberOfFaces = adapter.faces.size(); - - this->numberOfLevels = adapter.numberOfLevels; - - this->perLevelCount.resize( this->numberOfLevels ); - - for( uint level = 0; level < this->numberOfLevels; level++ ) - { - perLevelCount[ level ].numberOfCells = adapter.numberOfCellsPerLevel[ level ]; - perLevelCount[ level ].startOfCells = adapter.startOfCellsPerLevel [ level ]; - - perLevelCount[ level ].numberOfBulkCells = adapter.numberOfBulkCellsPerLevel[ level ]; - - perLevelCount[ level ].numberOfFacesX = adapter.numberOfFacesPerLevelXYZ[ 3 * level ]; - perLevelCount[ level ].startOfFacesX = adapter.startOfFacesPerLevelXYZ [ 3 * level ]; - - perLevelCount[ level ].numberOfFacesY = adapter.numberOfFacesPerLevelXYZ[ 3 * level + 1 ]; - perLevelCount[ level ].startOfFacesY = adapter.startOfFacesPerLevelXYZ [ 3 * level + 1 ]; - - perLevelCount[ level ].numberOfFacesZ = adapter.numberOfFacesPerLevelXYZ[ 3 * level + 2 ]; - perLevelCount[ level ].startOfFacesZ = adapter.startOfFacesPerLevelXYZ [ 3 * level + 2 ]; - - perLevelCount[ level ].numberOfFaces = perLevelCount[ level ].numberOfFacesX - + perLevelCount[ level ].numberOfFacesY - + perLevelCount[ level ].numberOfFacesZ; - - perLevelCount[ level ].numberOfInnerFaces = adapter.numberOfInnerFacesPerLevel[ level ]; - - perLevelCount[ level ].numberOfFineToCoarse = adapter.numberOfFineToCoarsePerLevel[ level ]; - perLevelCount[ level ].numberOfCoarseToFine = adapter.numberOfCoarseToFinePerLevel[ level ]; - - perLevelCount[ level ].startOfFineToCoarse = adapter.startOfFineToCoarsePerLevel[ level ]; - perLevelCount[ level ].startOfCoarseToFine = adapter.startOfCoarseToFinePerLevel[ level ]; - } - - this->numberOfCoarseGhostCells = adapter.fineToCoarse.size(); - - this->numberOfFineGhostCells = adapter.coarseToFine.size(); - - this->myAllocator->allocateMemory( shared_from_this() ); - - this->myAllocator->copyMesh( shared_from_this(), adapter ); -} - -void DataBase::setCommunicators(GksMeshAdapter & adapter) -{ - this->communicators.resize( this->numberOfLevels ); - - for( uint level = 0; level < this->numberOfLevels; level++ ) - { - for( uint direction = 0; direction < 6; direction++ ) - { - if( adapter.communicationProcesses[direction] != INVALID_INDEX && - ( - adapter.communicationIndices[level].sendIndices[direction].size() > 0 || - adapter.communicationIndices[level].recvIndices[direction].size() > 0 - ) - ) - { - this->communicators[level][direction] = std::make_shared<Communicator>( shared_from_this() ); - - this->communicators[level][direction]->initialize( adapter, level, direction ); - - *logging::out << logging::Logger::INFO_LOW << "Generated Communicator " << level << ":" << direction << " \n"; - } - else - { - this->communicators[level][direction] = nullptr; - } - } - - - } -} - -void DataBase::copyDataHostToDevice() -{ - this->myAllocator->copyDataHostToDevice( shared_from_this() ); -} - -void DataBase::copyDataDeviceToHost() -{ - this->myAllocator->copyDataDeviceToHost( shared_from_this(), this->dataHost.data() ); -} - -void DataBase::copyDataDeviceToHost( real* dataHost ) -{ - this->myAllocator->copyDataDeviceToHost( shared_from_this(), dataHost ); -} - -int DataBase::getCrashCellIndex() -{ - return this->myAllocator->getCrashCellIndex(shared_from_this()); -} - -DataBaseStruct DataBase::toStruct() -{ - DataBaseStruct dataBase; - - dataBase.numberOfCells = this->numberOfCells; - dataBase.numberOfFaces = this->numberOfFaces; - - dataBase.numberOfCoarseGhostCells = this->numberOfCoarseGhostCells; - dataBase.numberOfFineGhostCells = this->numberOfFineGhostCells; - - dataBase.cellToCell = this->cellToCell; - dataBase.faceToCell = this->faceToCell; - - dataBase.parentCell = this->parentCell; - - dataBase.fineToCoarse = this->fineToCoarse; - dataBase.coarseToFine = this->coarseToFine; - - dataBase.faceCenter = this->faceCenter; - dataBase.cellCenter = this->cellCenter; - - dataBase.cellProperties = this->cellProperties; - - dataBase.faceOrientation = this->faceOrientation; - - dataBase.fineToCoarse = this->fineToCoarse; - dataBase.coarseToFine = this->coarseToFine; - - dataBase.data = this->data; - dataBase.dataUpdate = this->dataUpdate; - - dataBase.massFlux = this->massFlux; - - dataBase.diffusivity = this->diffusivity; - - dataBase.crashCellIndex = this->crashCellIndex; - - return dataBase; -} - -uint DataBase::getCellLevel(uint cellIdx) -{ - uint level = 0; - - while( cellIdx >= this->perLevelCount[level].startOfCells - + this->perLevelCount[level].numberOfCells ) level++; - - return level; -} - -uint DataBase::getFaceLevel(uint faceIdx) -{ - uint level = 0; - - while( faceIdx >= this->perLevelCount[level].startOfFacesX - + this->perLevelCount[level].numberOfFaces ) level++; - - return level; -} - -Vec3 DataBase::getCellCenter(uint cellIdx) -{ - Vec3 cellCenter; - - for( uint node = 0; node < 8; node++ ) - { - cellCenter = cellCenter + this->nodeCoordinates[ this->cellToNode[ cellIdx ][ node ] ]; - } - - cellCenter.x /= c8o1; - cellCenter.y /= c8o1; - cellCenter.z /= c8o1; - - return cellCenter; -} - -bool DataBase::isGhostCell(uint cellIdx) -{ - uint level = this->getCellLevel( cellIdx ); - - return ( cellIdx >= this->perLevelCount[ level ].startOfCells + this->perLevelCount[ level ].numberOfBulkCells ) - || - ( isCellProperties( this->cellPropertiesHost[cellIdx], CELL_PROPERTIES_FINE_GHOST ) ); - -} - -std::string DataBase::getDeviceType() -{ - return this->myAllocator->getDeviceType(); -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/DataBase/DataBase.h b/src/gpu/GksGpu/DataBase/DataBase.h deleted file mode 100644 index 02475ae98ca5bb5d799098791342802cf6cde7b0..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/DataBase/DataBase.h +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef DataBase_H -#define DataBase_H - -#include <memory> -#include <string> -#include <vector> -#include <array> - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/ArrayTypes.h" - - -#include "GksGpu_export.h" - -#include "Definitions/AccumulatorDataType.h" - -#include "CellProperties/CellProperties.cuh" - -class GksMeshAdapter; - -namespace GksGpu { - -struct BoundaryCondition; -class DataBaseAllocator; -struct DataBase; -struct PerLevelCounts; -struct DataBaseStruct; -struct Communicator; - -struct GKSGPU_EXPORT DataBase : public std::enable_shared_from_this<DataBase> -{ - ////////////////////////////////////////////////////////////////////////// - // Management - ////////////////////////////////////////////////////////////////////////// - - SPtr<DataBaseAllocator> myAllocator; - - std::vector< SPtr<BoundaryCondition> > boundaryConditions; - - std::vector< std::array< SPtr< Communicator >, 6 > > communicators; - - ////////////////////////////////////////////////////////////////////////// - // Sizes - ////////////////////////////////////////////////////////////////////////// - - uint numberOfNodes; - - uint numberOfCells; - - uint numberOfFaces; - - uint numberOfLevels; - - uint numberOfCoarseGhostCells; - - uint numberOfFineGhostCells; - - std::vector<PerLevelCounts> perLevelCount; - - ////////////////////////////////////////////////////////////////////////// - // Host only geometry and connectivity - ////////////////////////////////////////////////////////////////////////// - - std::vector<Vec3> nodeCoordinates; - - std::vector<uint_8> cellToNode; - std::vector<uint_4> faceToNode; - - std::vector<CellProperties> cellPropertiesHost; - - ////////////////////////////////////////////////////////////////////////// - // Host/Device geometry and connectivity - READ ONLY - ////////////////////////////////////////////////////////////////////////// - - uint* cellToCell; // 6 - - uint* faceToCell; // 2 - - uint* parentCell; // 1 - - real* faceCenter; // 3 - real* cellCenter; // 3 - - CellProperties* cellProperties; // 1 x byte - - char* faceOrientation; - - uint* fineToCoarse; // 9 - uint* coarseToFine; // 9 - - ////////////////////////////////////////////////////////////////////////// - // Host/Device data - READ MODIFY - ////////////////////////////////////////////////////////////////////////// - - real* data; - realAccumulator* dataUpdate; - - real* massFlux; - - realAccumulator* diffusivity; - - int* crashCellIndex; - - ////////////////////////////////////////////////////////////////////////// - // Host only data - ////////////////////////////////////////////////////////////////////////// - - std::vector<real> dataHost; - - std::vector<real> diffusivityHost; - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // Methods - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - DataBase( std::string type ); - ~DataBase(); - - //void setMesh( std::shared_ptr<MeshGeneratorQuadTree> mesh ); - - void setMesh( GksMeshAdapter& adapter ); - - void setCommunicators( GksMeshAdapter& adapter ); - - void copyDataHostToDevice(); - - void copyDataDeviceToHost(); - - void copyDataDeviceToHost( real* dataHost ); - - int getCrashCellIndex(); - - DataBaseStruct toStruct(); - - ////////////////////////////////////////////////////////////////////////// - - uint getCellLevel( uint cellIdx ); - uint getFaceLevel( uint faceIdx ); - - Vec3 getCellCenter( uint cellIdx ); - - bool isGhostCell( uint cellIdx ); - - std::string getDeviceType(); -}; - -struct GKSGPU_EXPORT PerLevelCounts -{ - uint numberOfCells; - uint startOfCells; - - uint numberOfBulkCells; - - uint numberOfFaces; - - uint numberOfInnerFaces; - - uint numberOfFacesX; - uint startOfFacesX; - - uint numberOfFacesY; - uint startOfFacesY; - - uint numberOfFacesZ; - uint startOfFacesZ; - - uint numberOfCoarseToFine; - uint startOfCoarseToFine; - - uint numberOfFineToCoarse; - uint startOfFineToCoarse; -}; - -} // namespace GksGpu - -#endif \ No newline at end of file diff --git a/src/gpu/GksGpu/DataBase/DataBaseAllocator.cpp b/src/gpu/GksGpu/DataBase/DataBaseAllocator.cpp deleted file mode 100644 index fc5a8ddf3ee1f4ea1816a01ad315afd4df85ccf3..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/DataBase/DataBaseAllocator.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "DataBaseAllocator.h" - -//#include "../../DataBase/DataBaseAllocator/DataBaseAllocatorCPU/DataBaseAllocatorCPU.h" -//#include "../../DataBase/DataBaseAllocator/DataBaseAllocatorGPU/DataBaseAllocatorGPU.h" - -#include "DataBaseAllocatorCPU.h" -#include "DataBaseAllocatorGPU.h" - -#include <string> - -namespace GksGpu { - -std::shared_ptr<DataBaseAllocator> DataBaseAllocator::create(std::string type) -{ - if ( type == "GPU" ) - return std::shared_ptr<DataBaseAllocator>( new DataBaseAllocatorGPU() ); - else - return std::shared_ptr<DataBaseAllocator>( new DataBaseAllocatorCPU() ); -} - -DataBaseAllocator::~DataBaseAllocator() -{ -} - -DataBaseAllocator::DataBaseAllocator() -{ -} - -DataBaseAllocator::DataBaseAllocator(const DataBaseAllocator & orig) -{ -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/DataBase/DataBaseAllocator.h b/src/gpu/GksGpu/DataBase/DataBaseAllocator.h deleted file mode 100644 index e50c58f13a8c2134311f28a904e14ac64ca473d5..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/DataBase/DataBaseAllocator.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef DataBaseAllocator_H -#define DataBaseAllocator_H - -#include <string> -#include <vector> - -#include "Core/DataTypes.h" -#include "PointerDefinitions.h" - - -#include "GksGpu_export.h" - -class GksMeshAdapter; - -namespace GksGpu { - -struct DataBase; -struct BoundaryCondition; -struct Communicator; - -class GKSGPU_EXPORT DataBaseAllocator { - -public: - - static std::shared_ptr<DataBaseAllocator> create( std::string type ); - - ////////////////////////////////////////////////////////////////////////// - - virtual void freeMemory( DataBase& dataBase ) = 0; - - virtual void allocateMemory( SPtr<DataBase> dataBase) = 0; - - virtual void copyMesh( SPtr<DataBase> dataBase, GksMeshAdapter& adapter ) = 0; - - virtual void copyDataHostToDevice( SPtr<DataBase> dataBase ) = 0; - - virtual void copyDataDeviceToHost( SPtr<DataBase> dataBase, real* hostData ) = 0; - - virtual int getCrashCellIndex( SPtr<DataBase> dataBase ) = 0; - - ////////////////////////////////////////////////////////////////////////// - - virtual void freeMemory( BoundaryCondition& boundaryCondition ) = 0; - - virtual void allocateMemory( SPtr<BoundaryCondition> boundaryCondition, std::vector<uint> ghostCells, std::vector<uint> domainCells, std::vector<uint> secondCells ) = 0; - - ////////////////////////////////////////////////////////////////////////// - - virtual void freeMemory( Communicator& communicator ) = 0; - - virtual void allocateMemory( Communicator& communicator, std::vector<uint>& sendIndices, std::vector<uint>& recvIndices ) = 0; - - virtual void copyDataDeviceToDevice( SPtr<Communicator> dst, SPtr<Communicator> src ) = 0; - - virtual void copyBuffersDeviceToHost( SPtr<Communicator> communicator ) = 0; - virtual void copyBuffersHostToDevice( SPtr<Communicator> communicator ) = 0; - - ////////////////////////////////////////////////////////////////////////// - - ~DataBaseAllocator(); - - virtual std::string getDeviceType() = 0; - -protected: - - DataBaseAllocator(); - DataBaseAllocator( const DataBaseAllocator& orig ); - -}; - -} // namespace GksGpu - - -#endif \ No newline at end of file diff --git a/src/gpu/GksGpu/DataBase/DataBaseAllocatorCPU.cpp b/src/gpu/GksGpu/DataBase/DataBaseAllocatorCPU.cpp deleted file mode 100644 index 39d5f788c6a3b5332ded60378fdae8cd137d0b80..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/DataBase/DataBaseAllocatorCPU.cpp +++ /dev/null @@ -1,262 +0,0 @@ -#include "DataBaseAllocatorCPU.h" - -#include <cstring> - -#include "Core/DataTypes.h" -#include "PointerDefinitions.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "DataBase/DataBase.h" - -#include "CellProperties/CellProperties.cuh" - -#include "BoundaryConditions/BoundaryCondition.h" - -#include "Communication/Communicator.h" - -#include "Definitions/MemoryAccessPattern.h" - -namespace GksGpu { - -void DataBaseAllocatorCPU::freeMemory( DataBase& dataBase) -{ - dataBase.cellToNode.clear(); - dataBase.faceToNode.clear(); - - dataBase.cellPropertiesHost.clear(); - - delete [] dataBase.cellToCell; - - delete [] dataBase.faceToCell; - - delete [] dataBase.parentCell; - - delete [] dataBase.faceCenter; - delete [] dataBase.cellCenter; - - delete [] dataBase.cellProperties; - - delete [] dataBase.faceOrientation; - - delete [] dataBase.fineToCoarse; - delete [] dataBase.coarseToFine; - - delete [] dataBase.data; - delete [] dataBase.dataUpdate; - - delete [] dataBase.massFlux; - - delete [] dataBase.diffusivity; - - delete [] dataBase.crashCellIndex; - - dataBase.dataHost.clear(); -} - -void DataBaseAllocatorCPU::allocateMemory(SPtr<DataBase> dataBase) -{ - dataBase->cellToNode.resize( dataBase->numberOfCells ); - dataBase->faceToNode.resize( dataBase->numberOfFaces ); - - dataBase->cellPropertiesHost.resize( dataBase->numberOfCells ); - - dataBase->cellToCell = new uint [ LENGTH_CELL_TO_CELL * dataBase->numberOfCells ]; - - dataBase->faceToCell = new uint [ LENGTH_FACE_TO_CELL * dataBase->numberOfFaces ]; - - dataBase->parentCell = new uint [ dataBase->numberOfCells ]; - - dataBase->faceCenter = new real [ LENGTH_VECTOR * dataBase->numberOfFaces ]; - dataBase->cellCenter = new real [ LENGTH_VECTOR * dataBase->numberOfCells ]; - - dataBase->cellProperties = new CellProperties [ dataBase->numberOfCells ]; - - dataBase->faceOrientation = new char [ dataBase->numberOfFaces ]; - - dataBase->fineToCoarse = new uint [ LENGTH_FINE_TO_COARSE * dataBase->numberOfCoarseGhostCells ]; - dataBase->coarseToFine = new uint [ LENGTH_COARSE_TO_FINE * dataBase->numberOfFineGhostCells ]; - - dataBase->data = new real [ LENGTH_CELL_DATA * dataBase->numberOfCells ]; - dataBase->dataUpdate = new realAccumulator [ LENGTH_CELL_DATA * dataBase->numberOfCells ]; - - dataBase->massFlux = new real [ LENGTH_VECTOR * dataBase->numberOfCells ]; - - dataBase->diffusivity = new realAccumulator [ dataBase->numberOfCells ]; - - dataBase->crashCellIndex = new int; - - dataBase->dataHost.resize( LENGTH_CELL_DATA * dataBase->numberOfCells ); - - dataBase->diffusivityHost.resize( dataBase->numberOfCells ); -} - -void DataBaseAllocatorCPU::copyMesh(SPtr<DataBase> dataBase, GksMeshAdapter & adapter) -{ - dataBase->nodeCoordinates = adapter.nodes; - - ////////////////////////////////////////////////////////////////////////// - - for( uint cellIdx = 0; cellIdx < dataBase->numberOfCells; cellIdx++ ) - { - dataBase->cellToNode[ cellIdx ][ 0 ] = adapter.cells[ cellIdx ].cellToNode[ 7 ]; - dataBase->cellToNode[ cellIdx ][ 1 ] = adapter.cells[ cellIdx ].cellToNode[ 3 ]; - dataBase->cellToNode[ cellIdx ][ 2 ] = adapter.cells[ cellIdx ].cellToNode[ 1 ]; - dataBase->cellToNode[ cellIdx ][ 3 ] = adapter.cells[ cellIdx ].cellToNode[ 5 ]; - dataBase->cellToNode[ cellIdx ][ 4 ] = adapter.cells[ cellIdx ].cellToNode[ 6 ]; - dataBase->cellToNode[ cellIdx ][ 5 ] = adapter.cells[ cellIdx ].cellToNode[ 2 ]; - dataBase->cellToNode[ cellIdx ][ 6 ] = adapter.cells[ cellIdx ].cellToNode[ 0 ]; - dataBase->cellToNode[ cellIdx ][ 7 ] = adapter.cells[ cellIdx ].cellToNode[ 4 ]; - - for( uint neighbordx = 0; neighbordx < LENGTH_CELL_TO_CELL; neighbordx++ ) - dataBase->cellToCell[ CELL_TO_CELL( cellIdx, neighbordx, dataBase->numberOfCells ) ] - = adapter.cells[ cellIdx ].cellToCell[ neighbordx ]; - - dataBase->parentCell[ cellIdx ] = adapter.cells[ cellIdx ].parent; - - dataBase->cellCenter[ VEC_X( cellIdx, dataBase->numberOfCells ) ] = adapter.cells[ cellIdx ].cellCenter.x; - dataBase->cellCenter[ VEC_Y( cellIdx, dataBase->numberOfCells ) ] = adapter.cells[ cellIdx ].cellCenter.y; - dataBase->cellCenter[ VEC_Z( cellIdx, dataBase->numberOfCells ) ] = adapter.cells[ cellIdx ].cellCenter.z; - - dataBase->cellPropertiesHost[ cellIdx ] = CELL_PROPERTIES_DEFAULT; - - if( adapter.cells[ cellIdx ].isWall ) - setCellProperties( dataBase->cellPropertiesHost[ cellIdx ], CELL_PROPERTIES_WALL ); - - if( adapter.cells[ cellIdx ].isFluxBC ) - setCellProperties( dataBase->cellPropertiesHost[ cellIdx ], CELL_PROPERTIES_IS_FLUX_BC ); - - if( adapter.cells[ cellIdx ].isInsulated ) - setCellProperties( dataBase->cellPropertiesHost[ cellIdx ], CELL_PROPERTIES_IS_INSULATED ); - - if( adapter.cells[ cellIdx ].isGhostCell ) - setCellProperties( dataBase->cellPropertiesHost[ cellIdx ], CELL_PROPERTIES_GHOST ); - - if( adapter.cells[ cellIdx ].isFineGhostCell() ) - setCellProperties( dataBase->cellPropertiesHost[ cellIdx ], CELL_PROPERTIES_FINE_GHOST ); - } - - for( uint faceIdx = 0; faceIdx < dataBase->numberOfFaces; faceIdx++ ) - { - for( uint nodeIdx = 0; nodeIdx < 4; nodeIdx++ ) - dataBase->faceToNode[ faceIdx ][ nodeIdx ] - = adapter.faces[ faceIdx ].faceToNode[ nodeIdx ]; - - dataBase->faceToCell[ NEG_CELL( faceIdx, dataBase->numberOfFaces ) ] = adapter.faces[ faceIdx ].negCell; - dataBase->faceToCell[ POS_CELL( faceIdx, dataBase->numberOfFaces ) ] = adapter.faces[ faceIdx ].posCell; - - dataBase->faceCenter[ VEC_X( faceIdx, dataBase->numberOfFaces ) ] = adapter.faces[ faceIdx ].faceCenter.x; - dataBase->faceCenter[ VEC_Y( faceIdx, dataBase->numberOfFaces ) ] = adapter.faces[ faceIdx ].faceCenter.y; - dataBase->faceCenter[ VEC_Z( faceIdx, dataBase->numberOfFaces ) ] = adapter.faces[ faceIdx ].faceCenter.z; - - dataBase->faceOrientation[ faceIdx ] = adapter.faces[ faceIdx ].orientation; - } - - ////////////////////////////////////////////////////////////////////////// - - for( uint idx = 0; idx < dataBase->numberOfCoarseGhostCells; idx++ ){ - for( uint connectivityIdx = 0; connectivityIdx < LENGTH_FINE_TO_COARSE; connectivityIdx++ ){ - dataBase->fineToCoarse[ FINE_TO_COARSE( idx, connectivityIdx, dataBase->numberOfCoarseGhostCells ) ] - = adapter.fineToCoarse[idx][connectivityIdx]; - } - } - - for( uint idx = 0; idx < dataBase->numberOfFineGhostCells; idx++ ){ - for( uint connectivityIdx = 0; connectivityIdx < LENGTH_COARSE_TO_FINE; connectivityIdx++ ){ - dataBase->coarseToFine[ COARSE_TO_FINE( idx, connectivityIdx, dataBase->numberOfFineGhostCells ) ] - = adapter.coarseToFine[idx][connectivityIdx]; - } - } - - ////////////////////////////////////////////////////////////////////////// - - memcpy ( dataBase->cellProperties, dataBase->cellPropertiesHost.data(), sizeof(CellProperties) * dataBase->numberOfCells ); - - ////////////////////////////////////////////////////////////////////////// - - *dataBase->crashCellIndex = -1; -} - -void DataBaseAllocatorCPU::copyDataHostToDevice(SPtr<DataBase> dataBase) -{ - memcpy( dataBase->data, dataBase->dataHost.data(), sizeof(real) * LENGTH_CELL_DATA * dataBase->numberOfCells ); -} - -void DataBaseAllocatorCPU::copyDataDeviceToHost(SPtr<DataBase> dataBase, real* hostData) -{ - memcpy( hostData, dataBase->data, sizeof(real) * LENGTH_CELL_DATA * dataBase->numberOfCells ); - - memcpy( dataBase->diffusivityHost.data(), dataBase->diffusivity, sizeof(real) * dataBase->numberOfCells ); -} - -int DataBaseAllocatorCPU::getCrashCellIndex(SPtr<DataBase> dataBase) -{ - return *dataBase->crashCellIndex; -} - -void DataBaseAllocatorCPU::freeMemory(GksGpu::BoundaryCondition& boundaryCondition) -{ - delete [] boundaryCondition.ghostCells ; - delete [] boundaryCondition.domainCells; - delete [] boundaryCondition.secondCells; -} - -void DataBaseAllocatorCPU::allocateMemory(SPtr<GksGpu::BoundaryCondition> boundaryCondition, std::vector<uint> ghostCells, std::vector<uint> domainCells, std::vector<uint> secondCells) -{ - boundaryCondition->ghostCells = new uint[ ghostCells.size() ]; - boundaryCondition->domainCells = new uint[ domainCells.size() ]; - boundaryCondition->secondCells = new uint[ secondCells.size() ]; - - memcpy ( boundaryCondition->ghostCells , ghostCells.data() , sizeof(uint) * ghostCells.size() ); - memcpy ( boundaryCondition->domainCells, domainCells.data(), sizeof(uint) * domainCells.size() ); - memcpy ( boundaryCondition->secondCells, secondCells.data(), sizeof(uint) * secondCells.size() ); -} - -void DataBaseAllocatorCPU::freeMemory(Communicator & communicator) -{ - delete [] communicator.sendIndices; - delete [] communicator.recvIndices; - - delete [] communicator.sendBuffer; - delete [] communicator.recvBuffer; - - delete [] communicator.sendBufferHost; - delete [] communicator.recvBufferHost; -} - -void DataBaseAllocatorCPU::allocateMemory(Communicator & communicator, std::vector<uint>& sendIndices, std::vector<uint>& recvIndices) -{ - communicator.sendIndices = new uint[communicator.numberOfSendNodes]; - communicator.recvIndices = new uint[communicator.numberOfRecvNodes]; - - communicator.sendBuffer = new real[LENGTH_CELL_DATA * communicator.numberOfSendNodes]; - communicator.recvBuffer = new real[LENGTH_CELL_DATA * communicator.numberOfRecvNodes]; - - communicator.sendBufferHost = new real[LENGTH_CELL_DATA * communicator.numberOfSendNodes]; - communicator.recvBufferHost = new real[LENGTH_CELL_DATA * communicator.numberOfRecvNodes]; - - memcpy ( communicator.sendIndices , sendIndices.data() , sizeof(uint) * communicator.numberOfSendNodes ); - memcpy ( communicator.recvIndices , recvIndices.data() , sizeof(uint) * communicator.numberOfRecvNodes ); -} - -void DataBaseAllocatorCPU::copyDataDeviceToDevice(SPtr<Communicator> dst, SPtr<Communicator> src) -{ - memcpy( dst->recvBuffer, src->sendBuffer, LENGTH_CELL_DATA * sizeof(real) * src->numberOfSendNodes ); -} - -void DataBaseAllocatorCPU::copyBuffersDeviceToHost(SPtr<Communicator> communicator) -{ - memcpy( communicator->sendBufferHost, communicator->sendBuffer, LENGTH_CELL_DATA * sizeof(real) * communicator->numberOfSendNodes ); -} - -void DataBaseAllocatorCPU::copyBuffersHostToDevice(SPtr<Communicator> communicator) -{ - memcpy( communicator->recvBuffer, communicator->recvBufferHost, LENGTH_CELL_DATA * sizeof(real) * communicator->numberOfRecvNodes ); -} - -std::string DataBaseAllocatorCPU::getDeviceType() -{ - return std::string("CPU"); -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/DataBase/DataBaseAllocatorCPU.h b/src/gpu/GksGpu/DataBase/DataBaseAllocatorCPU.h deleted file mode 100644 index 420223338912f152a44ed92c7140afb587f4ec95..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/DataBase/DataBaseAllocatorCPU.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef DataBaseAllocatorCPU_H -#define DatabaseAllocatorCPU_H - -#include "Core/DataTypes.h" -#include "PointerDefinitions.h" - -#include "DataBaseAllocator.h" - - -#include "GksGpu_export.h" - -namespace GksGpu { - -class GKSGPU_EXPORT DataBaseAllocatorCPU : public DataBaseAllocator { - -public: - - virtual void freeMemory( DataBase& dataBase ) override; - - virtual void allocateMemory( SPtr<DataBase> dataBase ) override; - - virtual void copyMesh( SPtr<DataBase> dataBase, GksMeshAdapter& adapter ) override; - - virtual void copyDataHostToDevice( SPtr<DataBase> dataBase ) override; - - virtual void copyDataDeviceToHost( SPtr<DataBase> dataBase, real* dataHost ) override; - - virtual int getCrashCellIndex( SPtr<DataBase> dataBase ) override; - - ////////////////////////////////////////////////////////////////////////// - - virtual void freeMemory( BoundaryCondition& boundaryCondition ) override; - - virtual void allocateMemory( SPtr<BoundaryCondition> boundaryCondition, std::vector<uint> ghostCells, std::vector<uint> domainCells, std::vector<uint> secondCells ) override; - - ////////////////////////////////////////////////////////////////////////// - - virtual void freeMemory( Communicator& communicator ) override; - - virtual void allocateMemory( Communicator& communicator, std::vector<uint>& sendIndices, std::vector<uint>& recvIndices ) override; - - virtual void copyDataDeviceToDevice( SPtr<Communicator> dst, SPtr<Communicator> src ) override; - - virtual void copyBuffersDeviceToHost( SPtr<Communicator> communicator ) override; - virtual void copyBuffersHostToDevice( SPtr<Communicator> communicator ) override; - - ////////////////////////////////////////////////////////////////////////// - - virtual std::string getDeviceType() override; -}; - -} // namespace GksGpu - - -#endif \ No newline at end of file diff --git a/src/gpu/GksGpu/DataBase/DataBaseAllocatorGPU.cpp b/src/gpu/GksGpu/DataBase/DataBaseAllocatorGPU.cpp deleted file mode 100644 index b2eb7d6f124bcb004ee900228a1631a452b6ff3a..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/DataBase/DataBaseAllocatorGPU.cpp +++ /dev/null @@ -1,305 +0,0 @@ -#include "DataBaseAllocatorGPU.h" - -#include <cstring> -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "Core/DataTypes.h" -#include "PointerDefinitions.h" - -#include "GksMeshAdapter/GksMeshAdapter.h" - -#include "DataBase/DataBase.h" - -#include "CellProperties/CellProperties.cuh" - -#include "BoundaryConditions/BoundaryCondition.h" - -#include "Communication/Communicator.h" - -#include "Definitions/MemoryAccessPattern.h" - -#include "CudaUtility/CudaUtility.h" - -namespace GksGpu { - -void DataBaseAllocatorGPU::freeMemory( DataBase& dataBase ) -{ - dataBase.cellToNode.clear(); - dataBase.faceToNode.clear(); - - dataBase.cellPropertiesHost.clear(); - - checkCudaErrors( cudaFree ( dataBase.cellToCell ) ); - - checkCudaErrors( cudaFree ( dataBase.faceToCell ) ); - - checkCudaErrors( cudaFree ( dataBase.parentCell ) ); - - checkCudaErrors( cudaFree ( dataBase.faceCenter ) ); - checkCudaErrors( cudaFree ( dataBase.cellCenter ) ); - - checkCudaErrors( cudaFree ( dataBase.cellProperties ) ); - - checkCudaErrors( cudaFree ( dataBase.faceOrientation ) ); - - checkCudaErrors( cudaFree ( dataBase.fineToCoarse ) ); - checkCudaErrors( cudaFree ( dataBase.coarseToFine ) ); - - checkCudaErrors( cudaFree ( dataBase.data ) ); - checkCudaErrors( cudaFree ( dataBase.dataUpdate ) ); - - checkCudaErrors( cudaFree ( dataBase.massFlux ) ); - - checkCudaErrors( cudaFree ( dataBase.diffusivity ) ); - - checkCudaErrors( cudaFree ( dataBase.crashCellIndex ) ); - - dataBase.dataHost.clear(); -} - -void DataBaseAllocatorGPU::allocateMemory(SPtr<DataBase> dataBase) -{ - dataBase->cellToNode.resize( dataBase->numberOfCells ); - dataBase->faceToNode.resize( dataBase->numberOfFaces ); - - dataBase->cellPropertiesHost.resize( dataBase->numberOfCells ); - - checkCudaErrors( cudaMalloc ( &dataBase->cellToCell, sizeof(uint) * LENGTH_CELL_TO_CELL * dataBase->numberOfCells ) ); - - checkCudaErrors( cudaMalloc ( &dataBase->faceToCell, sizeof(uint) * LENGTH_FACE_TO_CELL * dataBase->numberOfFaces ) ); - - checkCudaErrors( cudaMalloc ( &dataBase->parentCell, sizeof(uint) * dataBase->numberOfCells ) ); - - checkCudaErrors( cudaMalloc ( &dataBase->faceCenter, sizeof(real) * LENGTH_VECTOR * dataBase->numberOfFaces ) ); - checkCudaErrors( cudaMalloc ( &dataBase->cellCenter, sizeof(real) * LENGTH_VECTOR * dataBase->numberOfCells ) ); - - checkCudaErrors( cudaMalloc ( &dataBase->cellProperties, sizeof(CellProperties) * dataBase->numberOfCells ) ); - - checkCudaErrors( cudaMalloc ( &dataBase->faceOrientation, sizeof(char) * dataBase->numberOfFaces ) ); - - checkCudaErrors( cudaMalloc ( &dataBase->fineToCoarse, sizeof(uint) * LENGTH_FINE_TO_COARSE * dataBase->numberOfCoarseGhostCells ) ); - checkCudaErrors( cudaMalloc ( &dataBase->coarseToFine, sizeof(uint) * LENGTH_COARSE_TO_FINE * dataBase->numberOfFineGhostCells ) ); - - checkCudaErrors( cudaMalloc ( &dataBase->data, sizeof(real) * LENGTH_CELL_DATA * dataBase->numberOfCells ) ); - checkCudaErrors( cudaMalloc ( &dataBase->dataUpdate, sizeof(realAccumulator) * LENGTH_CELL_DATA * dataBase->numberOfCells ) ); - - checkCudaErrors( cudaMalloc ( &dataBase->massFlux , sizeof(real) * LENGTH_VECTOR * dataBase->numberOfCells ) ); - - checkCudaErrors( cudaMalloc ( &dataBase->diffusivity, sizeof(realAccumulator) * dataBase->numberOfCells ) ); - - checkCudaErrors( cudaMalloc ( &dataBase->crashCellIndex, sizeof(int) ) ); - - dataBase->dataHost.resize( LENGTH_CELL_DATA * dataBase->numberOfCells ); - - dataBase->diffusivityHost.resize( dataBase->numberOfCells ); -} - -void DataBaseAllocatorGPU::copyMesh(SPtr<DataBase> dataBase, GksMeshAdapter & adapter) -{ - dataBase->nodeCoordinates = adapter.nodes; - - ////////////////////////////////////////////////////////////////////////// - - std::vector<uint> cellToCellBuffer ( LENGTH_CELL_TO_CELL * dataBase->numberOfCells ); - - std::vector<uint> faceToCellBuffer ( LENGTH_FACE_TO_CELL * dataBase->numberOfFaces ); - - std::vector<uint> parentCellBuffer ( dataBase->numberOfCells ); - - std::vector<real> faceCenterBuffer ( LENGTH_VECTOR * dataBase->numberOfFaces ); - std::vector<real> cellCenterBuffer ( LENGTH_VECTOR * dataBase->numberOfCells ); - - std::vector<char> faceOrientationBuffer( dataBase->numberOfFaces ); - - std::vector<uint> fineToCoarseBuffer ( LENGTH_FINE_TO_COARSE * dataBase->numberOfCoarseGhostCells ); - std::vector<uint> coarseToFineBuffer ( LENGTH_COARSE_TO_FINE * dataBase->numberOfFineGhostCells ); - - ////////////////////////////////////////////////////////////////////////// - - for( uint cellIdx = 0; cellIdx < dataBase->numberOfCells; cellIdx++ ) - { - dataBase->cellToNode[ cellIdx ][ 0 ] = adapter.cells[ cellIdx ].cellToNode[ 7 ]; - dataBase->cellToNode[ cellIdx ][ 1 ] = adapter.cells[ cellIdx ].cellToNode[ 3 ]; - dataBase->cellToNode[ cellIdx ][ 2 ] = adapter.cells[ cellIdx ].cellToNode[ 1 ]; - dataBase->cellToNode[ cellIdx ][ 3 ] = adapter.cells[ cellIdx ].cellToNode[ 5 ]; - dataBase->cellToNode[ cellIdx ][ 4 ] = adapter.cells[ cellIdx ].cellToNode[ 6 ]; - dataBase->cellToNode[ cellIdx ][ 5 ] = adapter.cells[ cellIdx ].cellToNode[ 2 ]; - dataBase->cellToNode[ cellIdx ][ 6 ] = adapter.cells[ cellIdx ].cellToNode[ 0 ]; - dataBase->cellToNode[ cellIdx ][ 7 ] = adapter.cells[ cellIdx ].cellToNode[ 4 ]; - - for( uint neighbordx = 0; neighbordx < LENGTH_CELL_TO_CELL; neighbordx++ ) - cellToCellBuffer[ CELL_TO_CELL( cellIdx, neighbordx, dataBase->numberOfCells ) ] - = adapter.cells[ cellIdx ].cellToCell[ neighbordx ]; - - parentCellBuffer[ cellIdx ] = adapter.cells[ cellIdx ].parent; - - cellCenterBuffer[ VEC_X( cellIdx, dataBase->numberOfCells ) ] = adapter.cells[ cellIdx ].cellCenter.x; - cellCenterBuffer[ VEC_Y( cellIdx, dataBase->numberOfCells ) ] = adapter.cells[ cellIdx ].cellCenter.y; - cellCenterBuffer[ VEC_Z( cellIdx, dataBase->numberOfCells ) ] = adapter.cells[ cellIdx ].cellCenter.z; - - dataBase->cellPropertiesHost[ cellIdx ] = CELL_PROPERTIES_DEFAULT; - - if( adapter.cells[ cellIdx ].isWall ) - setCellProperties( dataBase->cellPropertiesHost[ cellIdx ], CELL_PROPERTIES_WALL ); - - if( adapter.cells[ cellIdx ].isFluxBC ) - setCellProperties( dataBase->cellPropertiesHost[ cellIdx ], CELL_PROPERTIES_IS_FLUX_BC ); - - if( adapter.cells[ cellIdx ].isInsulated ) - setCellProperties( dataBase->cellPropertiesHost[ cellIdx ], CELL_PROPERTIES_IS_INSULATED ); - - if( adapter.cells[ cellIdx ].isGhostCell ) - setCellProperties( dataBase->cellPropertiesHost[ cellIdx ], CELL_PROPERTIES_GHOST ); - - if( adapter.cells[ cellIdx ].isFineGhostCell() ) - setCellProperties( dataBase->cellPropertiesHost[ cellIdx ], CELL_PROPERTIES_FINE_GHOST ); - } - - for( uint faceIdx = 0; faceIdx < dataBase->numberOfFaces; faceIdx++ ) - { - for( uint nodeIdx = 0; nodeIdx < 4; nodeIdx++ ) - dataBase->faceToNode[ faceIdx ][ nodeIdx ] - = adapter.faces[ faceIdx ].faceToNode[ nodeIdx ]; - - faceToCellBuffer[ NEG_CELL( faceIdx, dataBase->numberOfFaces ) ] = adapter.faces[ faceIdx ].negCell; - faceToCellBuffer[ POS_CELL( faceIdx, dataBase->numberOfFaces ) ] = adapter.faces[ faceIdx ].posCell; - - faceCenterBuffer[ VEC_X( faceIdx, dataBase->numberOfFaces ) ] = adapter.faces[ faceIdx ].faceCenter.x; - faceCenterBuffer[ VEC_Y( faceIdx, dataBase->numberOfFaces ) ] = adapter.faces[ faceIdx ].faceCenter.y; - faceCenterBuffer[ VEC_Z( faceIdx, dataBase->numberOfFaces ) ] = adapter.faces[ faceIdx ].faceCenter.z; - - faceOrientationBuffer[ faceIdx ] = adapter.faces[ faceIdx ].orientation; - } - - ////////////////////////////////////////////////////////////////////////// - - for( uint cellIdx = 0; cellIdx < dataBase->numberOfCoarseGhostCells; cellIdx++ ){ - for( uint connectivityIdx = 0; connectivityIdx < LENGTH_FINE_TO_COARSE; connectivityIdx++ ){ - fineToCoarseBuffer[ FINE_TO_COARSE( cellIdx, connectivityIdx, dataBase->numberOfCoarseGhostCells ) ] - = adapter.fineToCoarse[cellIdx][connectivityIdx]; - } - } - - for( uint cellIdx = 0; cellIdx < dataBase->numberOfFineGhostCells; cellIdx++ ){ - for( uint connectivityIdx = 0; connectivityIdx < LENGTH_COARSE_TO_FINE; connectivityIdx++ ){ - coarseToFineBuffer[ COARSE_TO_FINE( cellIdx, connectivityIdx, dataBase->numberOfFineGhostCells ) ] - = adapter.coarseToFine[cellIdx][connectivityIdx]; - } - } - - ////////////////////////////////////////////////////////////////////////// - - checkCudaErrors( cudaMemcpy ( dataBase->cellToCell, cellToCellBuffer.data(), sizeof(uint) * LENGTH_CELL_TO_CELL * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - - checkCudaErrors( cudaMemcpy ( dataBase->faceToCell, faceToCellBuffer.data(), sizeof(uint) * LENGTH_FACE_TO_CELL * dataBase->numberOfFaces, cudaMemcpyHostToDevice ) ); - - checkCudaErrors( cudaMemcpy ( dataBase->parentCell, parentCellBuffer.data(), sizeof(uint) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - - checkCudaErrors( cudaMemcpy ( dataBase->faceCenter, faceCenterBuffer.data(), sizeof(real) * LENGTH_VECTOR * dataBase->numberOfFaces, cudaMemcpyHostToDevice ) ); - checkCudaErrors( cudaMemcpy ( dataBase->cellCenter, cellCenterBuffer.data(), sizeof(real) * LENGTH_VECTOR * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - - checkCudaErrors( cudaMemcpy ( dataBase->cellProperties, dataBase->cellPropertiesHost.data(), sizeof(CellProperties) * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); - - checkCudaErrors( cudaMemcpy ( dataBase->faceOrientation, faceOrientationBuffer.data(), sizeof(char) * dataBase->numberOfFaces, cudaMemcpyHostToDevice ) ); - - checkCudaErrors( cudaMemcpy ( dataBase->fineToCoarse, fineToCoarseBuffer.data(), sizeof(uint) * LENGTH_FINE_TO_COARSE * dataBase->numberOfCoarseGhostCells, cudaMemcpyHostToDevice ) ); - checkCudaErrors( cudaMemcpy ( dataBase->coarseToFine, coarseToFineBuffer.data(), sizeof(uint) * LENGTH_COARSE_TO_FINE * dataBase->numberOfFineGhostCells , cudaMemcpyHostToDevice ) ); - - ////////////////////////////////////////////////////////////////////////// - - checkCudaErrors( cudaMemset( dataBase->crashCellIndex, -1, sizeof(int) ) ); - - ////////////////////////////////////////////////////////////////////////// -} - -void DataBaseAllocatorGPU::copyDataHostToDevice(SPtr<DataBase> dataBase) -{ - checkCudaErrors( cudaMemcpy( dataBase->data, dataBase->dataHost.data(), sizeof(real) * LENGTH_CELL_DATA * dataBase->numberOfCells, cudaMemcpyHostToDevice ) ); -} - -void DataBaseAllocatorGPU::copyDataDeviceToHost(SPtr<DataBase> dataBase, real* hostData ) -{ - checkCudaErrors( cudaMemcpy( hostData, dataBase->data, sizeof(real) * LENGTH_CELL_DATA * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); - - checkCudaErrors( cudaMemcpy( dataBase->diffusivityHost.data(), dataBase->diffusivity, sizeof(real) * dataBase->numberOfCells, cudaMemcpyDeviceToHost ) ); -} - -int DataBaseAllocatorGPU::getCrashCellIndex(SPtr<DataBase> dataBase) -{ - int crashCellIndex; - - checkCudaErrors( cudaMemcpy( &crashCellIndex, dataBase->crashCellIndex, sizeof(int), cudaMemcpyDeviceToHost ) ); - - return crashCellIndex; -} - -void DataBaseAllocatorGPU::freeMemory(GksGpu::BoundaryCondition& boundaryCondition) -{ - checkCudaErrors( cudaFree ( boundaryCondition.ghostCells ) ); - checkCudaErrors( cudaFree ( boundaryCondition.domainCells ) ); - checkCudaErrors( cudaFree ( boundaryCondition.secondCells ) ); -} - -void DataBaseAllocatorGPU::allocateMemory(SPtr<GksGpu::BoundaryCondition> boundaryCondition, std::vector<uint> ghostCells, std::vector<uint> domainCells, std::vector<uint> secondCells) -{ - checkCudaErrors( cudaMalloc ( &boundaryCondition->ghostCells , sizeof(uint) * ghostCells.size() ) ); - checkCudaErrors( cudaMalloc ( &boundaryCondition->domainCells, sizeof(uint) * domainCells.size() ) ); - checkCudaErrors( cudaMalloc ( &boundaryCondition->secondCells, sizeof(uint) * secondCells.size() ) ); - - checkCudaErrors( cudaMemcpy ( boundaryCondition->ghostCells , ghostCells.data() , sizeof(uint) * ghostCells.size() , cudaMemcpyHostToDevice ) ); - checkCudaErrors( cudaMemcpy ( boundaryCondition->domainCells, domainCells.data(), sizeof(uint) * domainCells.size(), cudaMemcpyHostToDevice ) ); - checkCudaErrors( cudaMemcpy ( boundaryCondition->secondCells, secondCells.data(), sizeof(uint) * secondCells.size(), cudaMemcpyHostToDevice ) ); -} - -void DataBaseAllocatorGPU::freeMemory(Communicator & communicator) -{ - checkCudaErrors( cudaFree ( communicator.sendIndices ) ); - checkCudaErrors( cudaFree ( communicator.recvIndices ) ); - - checkCudaErrors( cudaFree ( communicator.sendBuffer ) ); - checkCudaErrors( cudaFree ( communicator.recvBuffer ) ); - - checkCudaErrors( cudaFreeHost ( communicator.sendBufferHost ) ); - checkCudaErrors( cudaFreeHost ( communicator.recvBufferHost ) ); -} - -void DataBaseAllocatorGPU::allocateMemory(Communicator & communicator, std::vector<uint>& sendIndices, std::vector<uint>& recvIndices) -{ - checkCudaErrors( cudaMalloc ( &communicator.sendIndices , sizeof(uint) * communicator.numberOfSendNodes ) ); - checkCudaErrors( cudaMalloc ( &communicator.recvIndices , sizeof(uint) * communicator.numberOfRecvNodes ) ); - - checkCudaErrors( cudaMalloc ( &communicator.sendBuffer , LENGTH_CELL_DATA * sizeof(real) * communicator.numberOfSendNodes ) ); - checkCudaErrors( cudaMalloc ( &communicator.recvBuffer , LENGTH_CELL_DATA * sizeof(real) * communicator.numberOfRecvNodes ) ); - - checkCudaErrors( cudaMallocHost ( &communicator.sendBufferHost , LENGTH_CELL_DATA * sizeof(real) * communicator.numberOfSendNodes ) ); - checkCudaErrors( cudaMallocHost ( &communicator.recvBufferHost , LENGTH_CELL_DATA * sizeof(real) * communicator.numberOfRecvNodes ) ); - - checkCudaErrors( cudaMemcpy ( communicator.sendIndices , sendIndices.data() , sizeof(uint) * communicator.numberOfSendNodes, cudaMemcpyHostToDevice ) ); - checkCudaErrors( cudaMemcpy ( communicator.recvIndices , recvIndices.data() , sizeof(uint) * communicator.numberOfRecvNodes, cudaMemcpyHostToDevice ) ); -} - -void DataBaseAllocatorGPU::copyDataDeviceToDevice(SPtr<Communicator> dst, SPtr<Communicator> src) -{ - checkCudaErrors( cudaMemcpy ( dst->recvBuffer, src->sendBuffer, LENGTH_CELL_DATA * sizeof(real) * src->numberOfSendNodes, cudaMemcpyDefault ) ); -} - -void DataBaseAllocatorGPU::copyBuffersDeviceToHost(SPtr<Communicator> communicator) -{ - size_t size = LENGTH_CELL_DATA * sizeof(real) * communicator->numberOfSendNodes; - cudaMemcpyAsync ( communicator->sendBufferHost, communicator->sendBuffer, size, cudaMemcpyDeviceToHost, CudaUtility::communicationStream ); -} - -void DataBaseAllocatorGPU::copyBuffersHostToDevice(SPtr<Communicator> communicator) -{ - size_t size = LENGTH_CELL_DATA * sizeof(real) * communicator->numberOfRecvNodes; - cudaMemcpyAsync ( communicator->recvBuffer, communicator->recvBufferHost, size, cudaMemcpyHostToDevice, CudaUtility::communicationStream ); -} - -std::string DataBaseAllocatorGPU::getDeviceType() -{ - return std::string("GPU"); -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/DataBase/DataBaseAllocatorGPU.h b/src/gpu/GksGpu/DataBase/DataBaseAllocatorGPU.h deleted file mode 100644 index 4ed547e223c36248cd323ced4ecca637fcdce9a8..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/DataBase/DataBaseAllocatorGPU.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef DataBaseAllocatorGPU_H -#define DatabaseAllocatorGPU_H - -#include "Core/DataTypes.h" -#include "PointerDefinitions.h" - -#include "DataBaseAllocator.h" - - -#include "GksGpu_export.h" - -namespace GksGpu { - -class GKSGPU_EXPORT DataBaseAllocatorGPU : public DataBaseAllocator { - -public: - - virtual void freeMemory( DataBase& dataBase ) override; - - virtual void allocateMemory( SPtr<DataBase> dataBase ) override; - - virtual void copyMesh( SPtr<DataBase> dataBase, GksMeshAdapter& adapter ) override; - - virtual void copyDataHostToDevice( SPtr<DataBase> dataBase ) override; - - virtual void copyDataDeviceToHost( SPtr<DataBase> dataBase, real* dataHost ) override; - - virtual int getCrashCellIndex( SPtr<DataBase> dataBase ) override; - - ////////////////////////////////////////////////////////////////////////// - - virtual void freeMemory( BoundaryCondition& boundaryCondition ) override; - - virtual void allocateMemory( SPtr<BoundaryCondition> boundaryCondition, std::vector<uint> ghostCells, std::vector<uint> domainCells, std::vector<uint> secondCells ) override; - - ////////////////////////////////////////////////////////////////////////// - - virtual void freeMemory( Communicator& communicator ) override; - - virtual void allocateMemory( Communicator& communicator, std::vector<uint>& sendIndices, std::vector<uint>& recvIndices ) override; - - virtual void copyDataDeviceToDevice( SPtr<Communicator> dst, SPtr<Communicator> src ) override; - - virtual void copyBuffersDeviceToHost( SPtr<Communicator> communicator ) override; - virtual void copyBuffersHostToDevice( SPtr<Communicator> communicator ) override; - - ////////////////////////////////////////////////////////////////////////// - - virtual std::string getDeviceType() override; -}; - -} // namespace GksGpu - - -#endif \ No newline at end of file diff --git a/src/gpu/GksGpu/DataBase/DataBaseStruct.h b/src/gpu/GksGpu/DataBase/DataBaseStruct.h deleted file mode 100644 index 3fb5a50a0c396f92d49ebf29fd197067ccda6500..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/DataBase/DataBaseStruct.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef DataBaseStruct_H -#define DataBaseStruct_H - -#include "Core/DataTypes.h" - - - -namespace GksGpu{ - -struct GKSGPU_EXPORT DataBaseStruct -{ - uint numberOfCells; - uint numberOfFaces; - - uint numberOfCoarseGhostCells; - uint numberOfFineGhostCells; - - uint* cellToCell; - uint* faceToCell; - - uint* parentCell; - - uint* fineToCoarse; - uint* coarseToFine; - - real* faceCenter; - real* cellCenter; - - CellProperties* cellProperties; - - char* faceOrientation; - - real* data; - realAccumulator* dataUpdate; - - real* massFlux; - - realAccumulator* diffusivity; - - int* crashCellIndex; -}; - -} // namespace GksGpu - - -#endif \ No newline at end of file diff --git a/src/gpu/GksGpu/Definitions/AccumulatorDataType.h b/src/gpu/GksGpu/Definitions/AccumulatorDataType.h deleted file mode 100644 index 20807f33a2ad3f892266975395ab980814c8362f..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Definitions/AccumulatorDataType.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef AccumulatorDataType_H -#define AccumulatorDataType_H - -namespace GksGpu { - -// This file is used to control the data type of accumulator variables. -// Accumulator variables are variables, where cell values are written -// during the flux computation, which is per face. Since the face evaluation -// order on GPUs is arbitrary, the cutoff errors for these accumulators are non -// deterministic. This deficiency can be solved for single precision calculations -// by setting the accumulator data type to double. The deviations are then -// so small, that they are cut off during the downcast to single. -// using double precision accumulators has some performance implications, -// especially on consumer hardware. - -//typedef float realAccumulator; -typedef double realAccumulator; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Definitions/CudaAwareMpi.h b/src/gpu/GksGpu/Definitions/CudaAwareMpi.h deleted file mode 100644 index b12e5eca17bcf02a1e7a1446cf878484833423fb..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Definitions/CudaAwareMpi.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef CudaAwareMpi_H -#define CudaAwareMpi_H - -//#define USE_CUDA_AWARE_MPI - -#endif diff --git a/src/gpu/GksGpu/Definitions/MemoryAccessPattern.h b/src/gpu/GksGpu/Definitions/MemoryAccessPattern.h deleted file mode 100644 index 0b1c33861b06986f318860201db0fdec69d1a11d..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Definitions/MemoryAccessPattern.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef DataDefinitions_H -#define DataDefinitions_H - -#include "PassiveScalar.h" - -#define SOA - -////////////////////////////////////////////////////////////////////////// - -#define LENGTH_VECTOR 3 - -#ifdef USE_PASSIVE_SCALAR - #define LENGTH_CELL_DATA 7 -#else - #define LENGTH_CELL_DATA 5 -#endif - -#define LENGTH_CELL_TO_CELL 6 - -#define LENGTH_FACE_TO_CELL 2 - -#define LENGTH_FINE_TO_COARSE 9 - -#define LENGTH_COARSE_TO_FINE 9 - -////////////////////////////////////////////////////////////////////////// - -#ifdef SOA - -#define VEC_X(vecIdx, numberOfVectors) ( 0 * numberOfVectors + vecIdx ) -#define VEC_Y(vecIdx, numberOfVectors) ( 1 * numberOfVectors + vecIdx ) -#define VEC_Z(vecIdx, numberOfVectors) ( 2 * numberOfVectors + vecIdx ) - -#define RHO__( cellIdx, numberOfCells ) ( 0 * numberOfCells + cellIdx ) -#define RHO_U( cellIdx, numberOfCells ) ( 1 * numberOfCells + cellIdx ) -#define RHO_V( cellIdx, numberOfCells ) ( 2 * numberOfCells + cellIdx ) -#define RHO_W( cellIdx, numberOfCells ) ( 3 * numberOfCells + cellIdx ) -#define RHO_E( cellIdx, numberOfCells ) ( 4 * numberOfCells + cellIdx ) - -#ifdef USE_PASSIVE_SCALAR - #define RHO_S_1( cellIdx, numberOfCells ) ( 5 * numberOfCells + cellIdx ) - #define RHO_S_2( cellIdx, numberOfCells ) ( 6 * numberOfCells + cellIdx ) -#endif // USE_PASSIVE_SCALAR - -#define CELL_TO_CELL( cellIdx, neighborIdx, numberOfCells ) ( neighborIdx * numberOfCells + cellIdx ) - -#define NEG_CELL( faceIdx, numberOfFaces ) ( faceIdx ) -#define POS_CELL( faceIdx, numberOfFaces ) ( numberOfFaces + faceIdx ) - -#define FINE_TO_COARSE( idx, cellIdx, number ) ( cellIdx * number + idx ) -#define COARSE_TO_FINE( idx, cellIdx, number ) ( cellIdx * number + idx ) - -#endif - -////////////////////////////////////////////////////////////////////////// - -#ifdef AOS - -#define VEC_X(vecIdx, numberOfVectors) ( vecIdx * LENGTH_VECTOR ) -#define VEC_Y(vecIdx, numberOfVectors) ( vecIdx * LENGTH_VECTOR + 1 ) -#define VEC_Z(vecIdx, numberOfVectors) ( vecIdx * LENGTH_VECTOR + 2 ) - -#define RHO__( cellIdx, numberOfCells ) ( cellIdx * LENGTH_CELL_DATA ) -#define RHO_U( cellIdx, numberOfCells ) ( cellIdx * LENGTH_CELL_DATA + 1 ) -#define RHO_V( cellIdx, numberOfCells ) ( cellIdx * LENGTH_CELL_DATA + 2 ) -#define RHO_W( cellIdx, numberOfCells ) ( cellIdx * LENGTH_CELL_DATA + 3 ) -#define RHO_E( cellIdx, numberOfCells ) ( cellIdx * LENGTH_CELL_DATA + 4 ) - -#ifdef USE_PASSIVE_SCALAR - #define RHO_S_1( cellIdx, numberOfCells ) ( cellIdx * LENGTH_CELL_DATA + 5 ) - #define RHO_S_2( cellIdx, numberOfCells ) ( cellIdx * LENGTH_CELL_DATA + 6 ) -#endif // USE_PASSIVE_SCALAR - -#define CELL_TO_CELL( cellIdx, neighborIdx, numberOfCells ) ( cellIdx * LENGTH_CELL_TO_CELL + neighborIdx ) - -#define NEG_CELL( faceIdx, numberOfFaces ) ( faceIdx * LENGTH_FACE_TO_CELL ) -#define POS_CELL( faceIdx, numberOfFaces ) ( faceIdx * LENGTH_FACE_TO_CELL + 1 ) - -#define FINE_TO_COARSE( idx, cellIdx, number ) ( cellIdx * LENGTH_FINE_TO_COARSE + idx ) -#define COARSE_TO_FINE( idx, cellIdx, number ) ( cellIdx * LENGTH_COARSE_TO_FINE + idx ) - -#endif - -////////////////////////////////////////////////////////////////////////// - -#endif diff --git a/src/gpu/GksGpu/Definitions/PassiveScalar.h b/src/gpu/GksGpu/Definitions/PassiveScalar.h deleted file mode 100644 index b71ada48a0c05eaa726abae31bf76f7b56a2c0fd..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Definitions/PassiveScalar.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef PassiveScalar_H -#define PassiveScalar_H - -//#define USE_PASSIVE_SCALAR - -#endif diff --git a/src/gpu/GksGpu/FlowStateData/AccessDeviceData.cuh b/src/gpu/GksGpu/FlowStateData/AccessDeviceData.cuh deleted file mode 100644 index 2ad158173970c5bb36637643f621c729a8fcc37a..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FlowStateData/AccessDeviceData.cuh +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef AccessDeviceData_CUH -#define AccessDeviceData_CUH - -#ifdef __CUDACC__ -#include <cuda_runtime.h> -#else -#ifndef __host__ -#define __host__ -#endif -#ifndef __device__ -#define __device__ -#endif -#endif - -#include "Core/DataTypes.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" - -namespace GksGpu { - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void readCellData(const uint cellIdx, const DataBaseStruct& dataBase, ConservedVariables& cellCons) -{ - cellCons.rho = dataBase.data[ RHO__( cellIdx, dataBase.numberOfCells ) ]; - cellCons.rhoU = dataBase.data[ RHO_U( cellIdx, dataBase.numberOfCells ) ]; - cellCons.rhoV = dataBase.data[ RHO_V( cellIdx, dataBase.numberOfCells ) ]; - cellCons.rhoW = dataBase.data[ RHO_W( cellIdx, dataBase.numberOfCells ) ]; - cellCons.rhoE = dataBase.data[ RHO_E( cellIdx, dataBase.numberOfCells ) ]; -#ifdef USE_PASSIVE_SCALAR - cellCons.rhoS_1 = dataBase.data[ RHO_S_1( cellIdx, dataBase.numberOfCells ) ]; - cellCons.rhoS_2 = dataBase.data[ RHO_S_2( cellIdx, dataBase.numberOfCells ) ]; -#endif // USE_PASSIVE_SCALAR -} - -__host__ __device__ inline void writeCellData(const uint cellIdx, const DataBaseStruct& dataBase, ConservedVariables& cellCons) -{ - dataBase.data[ RHO__( cellIdx, dataBase.numberOfCells ) ] = cellCons.rho ; - dataBase.data[ RHO_U( cellIdx, dataBase.numberOfCells ) ] = cellCons.rhoU; - dataBase.data[ RHO_V( cellIdx, dataBase.numberOfCells ) ] = cellCons.rhoV; - dataBase.data[ RHO_W( cellIdx, dataBase.numberOfCells ) ] = cellCons.rhoW; - dataBase.data[ RHO_E( cellIdx, dataBase.numberOfCells ) ] = cellCons.rhoE; -#ifdef USE_PASSIVE_SCALAR - dataBase.data[ RHO_S_1( cellIdx, dataBase.numberOfCells ) ] = cellCons.rhoS_1; - dataBase.data[ RHO_S_2( cellIdx, dataBase.numberOfCells ) ] = cellCons.rhoS_2; -#endif // USE_PASSIVE_SCALAR -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void readCellDataUpdate(const uint cellIdx, const DataBaseStruct& dataBase, ConservedVariables& cellCons) -{ - cellCons.rho = dataBase.dataUpdate[ RHO__( cellIdx, dataBase.numberOfCells ) ]; - cellCons.rhoU = dataBase.dataUpdate[ RHO_U( cellIdx, dataBase.numberOfCells ) ]; - cellCons.rhoV = dataBase.dataUpdate[ RHO_V( cellIdx, dataBase.numberOfCells ) ]; - cellCons.rhoW = dataBase.dataUpdate[ RHO_W( cellIdx, dataBase.numberOfCells ) ]; - cellCons.rhoE = dataBase.dataUpdate[ RHO_E( cellIdx, dataBase.numberOfCells ) ]; -#ifdef USE_PASSIVE_SCALAR - cellCons.rhoS_1 = dataBase.dataUpdate[ RHO_S_1( cellIdx, dataBase.numberOfCells ) ]; - cellCons.rhoS_2 = dataBase.dataUpdate[ RHO_S_2( cellIdx, dataBase.numberOfCells ) ]; -#endif // USE_PASSIVE_SCALAR -} - -__host__ __device__ inline void writeCellDataUpdate(const uint cellIdx, const DataBaseStruct& dataBase, ConservedVariables& cellCons) -{ - dataBase.dataUpdate[ RHO__( cellIdx, dataBase.numberOfCells ) ] = cellCons.rho ; - dataBase.dataUpdate[ RHO_U( cellIdx, dataBase.numberOfCells ) ] = cellCons.rhoU; - dataBase.dataUpdate[ RHO_V( cellIdx, dataBase.numberOfCells ) ] = cellCons.rhoV; - dataBase.dataUpdate[ RHO_W( cellIdx, dataBase.numberOfCells ) ] = cellCons.rhoW; - dataBase.dataUpdate[ RHO_E( cellIdx, dataBase.numberOfCells ) ] = cellCons.rhoE; -#ifdef USE_PASSIVE_SCALAR - dataBase.dataUpdate[ RHO_S_1( cellIdx, dataBase.numberOfCells ) ] = cellCons.rhoS_1; - dataBase.dataUpdate[ RHO_S_2( cellIdx, dataBase.numberOfCells ) ] = cellCons.rhoS_2; -#endif // USE_PASSIVE_SCALAR -} - -} // namespace GksGpu - -#endif \ No newline at end of file diff --git a/src/gpu/GksGpu/FlowStateData/FlowStateData.cuh b/src/gpu/GksGpu/FlowStateData/FlowStateData.cuh deleted file mode 100644 index 3b7929b39b47761624fec7052becc55921990276..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FlowStateData/FlowStateData.cuh +++ /dev/null @@ -1,264 +0,0 @@ -#ifndef FlowStateData_H -#define FlowStateData_H - -#ifdef __CUDACC__ -#include <cuda_runtime.h> -#else -#ifndef __host__ -#define __host__ -#endif -#ifndef __device__ -#define __device__ -#endif -#endif - -#include "Core/DataTypes.h" - -#include "Definitions/PassiveScalar.h" - -#include <lbm/constants/NumericConstants.h> - -using namespace vf::lbm::constant; - -namespace GksGpu { - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -struct PrimitiveVariables -{ - real rho; - real U; - real V; - real W; - real lambda; - #ifdef USE_PASSIVE_SCALAR - real S_1; - real S_2; - #endif - - ////////////////////////////////////////////////////////////////////////// - - __host__ __device__ PrimitiveVariables() - : rho (c0o1) - ,U (c0o1) - ,V (c0o1) - ,W (c0o1) - ,lambda(c0o1) - #ifdef USE_PASSIVE_SCALAR - ,S_1 (c0o1) - ,S_2 (c0o1) - #endif - {} - - ////////////////////////////////////////////////////////////////////////// - - __host__ __device__ PrimitiveVariables(real rho - ,real U - ,real V - ,real W - ,real lambda - #ifdef USE_PASSIVE_SCALAR - ,real S_1 = c0o1 - ,real S_2 = c0o1 - #endif - ) - : rho (rho ) - ,U (U ) - ,V (V ) - ,W (W ) - ,lambda(lambda) - #ifdef USE_PASSIVE_SCALAR - ,S_1 (S_1 ) - ,S_2 (S_2 ) - #endif - {} - - ////////////////////////////////////////////////////////////////////////// -}; - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -struct ConservedVariables -{ - real rho; - real rhoU; - real rhoV; - real rhoW; - real rhoE; - #ifdef USE_PASSIVE_SCALAR - real rhoS_1; - real rhoS_2; - #endif - - ////////////////////////////////////////////////////////////////////////// - - __host__ __device__ ConservedVariables() - : rho (c0o1) - ,rhoU(c0o1) - ,rhoV(c0o1) - ,rhoW(c0o1) - ,rhoE(c0o1) - #ifdef USE_PASSIVE_SCALAR - ,rhoS_1(c0o1) - ,rhoS_2(c0o1) - #endif - {} - - ////////////////////////////////////////////////////////////////////////// - - __host__ __device__ ConservedVariables(real rho - ,real rhoU - ,real rhoV - ,real rhoW - ,real rhoE - #ifdef USE_PASSIVE_SCALAR - ,real rhoS_1 = c0o1 - ,real rhoS_2 = c0o1 - #endif - ) - : rho (rho ) - ,rhoU(rhoU) - ,rhoV(rhoV) - ,rhoW(rhoW) - ,rhoE(rhoE) - #ifdef USE_PASSIVE_SCALAR - ,rhoS_1(rhoS_1) - ,rhoS_2(rhoS_2) - #endif - {} - - ////////////////////////////////////////////////////////////////////////// -}; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline PrimitiveVariables operator+ ( const PrimitiveVariables& left, const PrimitiveVariables& right ) -{ - PrimitiveVariables result; - - result.rho = left.rho + right.rho ; - result.U = left.U + right.U ; - result.V = left.V + right.V ; - result.W = left.W + right.W ; - result.lambda = left.lambda + right.lambda; - -#ifdef USE_PASSIVE_SCALAR - result.S_1 = left.S_1 + right.S_1 ; - result.S_2 = left.S_2 + right.S_2 ; -#endif - - return result; -} - -__host__ __device__ inline ConservedVariables operator+ ( const ConservedVariables& left, const ConservedVariables& right ) -{ - ConservedVariables result; - - result.rho = left.rho + right.rho ; - result.rhoU = left.rhoU + right.rhoU ; - result.rhoV = left.rhoV + right.rhoV ; - result.rhoW = left.rhoW + right.rhoW ; - result.rhoE = left.rhoE + right.rhoE ; - -#ifdef USE_PASSIVE_SCALAR - result.rhoS_1 = left.rhoS_1 + right.rhoS_1; - result.rhoS_2 = left.rhoS_2 + right.rhoS_2; -#endif - - return result; -} - -////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline PrimitiveVariables operator- ( const PrimitiveVariables& left, const PrimitiveVariables& right ) -{ - PrimitiveVariables result; - - result.rho = left.rho - right.rho ; - result.U = left.U - right.U ; - result.V = left.V - right.V ; - result.W = left.W - right.W ; - result.lambda = left.lambda - right.lambda; - -#ifdef USE_PASSIVE_SCALAR - result.S_1 = left.S_1 - right.S_1 ; - result.S_2 = left.S_2 - right.S_2 ; -#endif - - return result; -} - -__host__ __device__ inline ConservedVariables operator- ( const ConservedVariables& left, const ConservedVariables& right ) -{ - ConservedVariables result; - - result.rho = left.rho - right.rho ; - result.rhoU = left.rhoU - right.rhoU ; - result.rhoV = left.rhoV - right.rhoV ; - result.rhoW = left.rhoW - right.rhoW ; - result.rhoE = left.rhoE - right.rhoE ; - -#ifdef USE_PASSIVE_SCALAR - result.rhoS_1 = left.rhoS_1 - right.rhoS_1; - result.rhoS_2 = left.rhoS_2 - right.rhoS_2; -#endif - - return result; -} - -////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline PrimitiveVariables operator* ( const real left, const PrimitiveVariables& right ) -{ - PrimitiveVariables result; - - result.rho = left * right.rho ; - result.U = left * right.U ; - result.V = left * right.V ; - result.W = left * right.W ; - result.lambda = left * right.lambda; - -#ifdef USE_PASSIVE_SCALAR - result.S_1 = left * right.S_1 ; - result.S_2 = left * right.S_2 ; -#endif - - return result; -} - -__host__ __device__ inline ConservedVariables operator* ( const real left, const ConservedVariables& right ) -{ - ConservedVariables result; - - result.rho = left * right.rho ; - result.rhoU = left * right.rhoU ; - result.rhoV = left * right.rhoV ; - result.rhoW = left * right.rhoW ; - result.rhoE = left * right.rhoE ; - -#ifdef USE_PASSIVE_SCALAR - result.rhoS_1 = left * right.rhoS_1; - result.rhoS_2 = left * right.rhoS_2; -#endif - - return result; -} - -} // namespace GksGpu - -#endif - diff --git a/src/gpu/GksGpu/FlowStateData/FlowStateDataConversion.cuh b/src/gpu/GksGpu/FlowStateData/FlowStateDataConversion.cuh deleted file mode 100644 index b7b759c99ffec6118a4173af098e0b372caf6ef7..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FlowStateData/FlowStateDataConversion.cuh +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef FlowStateDataConversion_H -#define FlowStateDataConversion_H - -#ifdef __CUDACC__ -#include <cuda_runtime.h> -#else -#ifndef __host__ -#define __host__ -#endif -#ifndef __device__ -#define __device__ -#endif -#endif - -#include "Core/DataTypes.h" -#include "Core/RealConstants.h" - -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/ThermalDependencies.cuh" - -namespace GksGpu { - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline ConservedVariables toConservedVariables( const PrimitiveVariables& prim, real K, bool overrideK = true ) -{ - //#ifdef USE_PASSIVE_SCALAR - //if( overrideK ) K = getK(prim); - //#endif - -#ifdef USE_PASSIVE_SCALAR - return ConservedVariables(prim.rho - ,prim.U * prim.rho - ,prim.V * prim.rho - ,prim.W * prim.rho - //,getEint(prim) * prim.rho + c1o2 * prim.rho * ( prim.U * prim.U + prim.V * prim.V + prim.W * prim.W ) - ,( K + c3o1 ) / ( c4o1 * prim.lambda ) * prim.rho + c1o2 * prim.rho * ( prim.U * prim.U + prim.V * prim.V + prim.W * prim.W ) - ,prim.S_1 * prim.rho - ,prim.S_2 * prim.rho - ); -#else - return ConservedVariables(prim.rho - ,prim.U * prim.rho - ,prim.V * prim.rho - ,prim.W * prim.rho - ,( K + c3o1 ) / ( c4o1 * prim.lambda ) * prim.rho + c1o2 * prim.rho * ( prim.U * prim.U + prim.V * prim.V + prim.W * prim.W ) - ); -#endif -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline PrimitiveVariables toPrimitiveVariables( const ConservedVariables& cons, real K, bool overrideK = true ) -{ - //#ifdef USE_PASSIVE_SCALAR - //if( overrideK ) K = getK(cons); - //#endif - -#ifdef USE_PASSIVE_SCALAR - return PrimitiveVariables(cons.rho - ,cons.rhoU / cons.rho - ,cons.rhoV / cons.rho - ,cons.rhoW / cons.rho - //,getlambda(cons) - ,( K + c3o1 ) * cons.rho / ( c4o1 * ( cons.rhoE - c1o2 * ( cons.rhoU * cons.rhoU + cons.rhoV * cons.rhoV + cons.rhoW * cons.rhoW ) / cons.rho ) ) - ,cons.rhoS_1 / cons.rho - ,cons.rhoS_2 / cons.rho - ); -#else - return PrimitiveVariables(cons.rho - ,cons.rhoU / cons.rho - ,cons.rhoV / cons.rho - ,cons.rhoW / cons.rho - ,( K + c3o1 ) * cons.rho / ( c4o1 * ( cons.rhoE - c1o2 * ( cons.rhoU * cons.rhoU + cons.rhoV * cons.rhoV + cons.rhoW * cons.rhoW ) / cons.rho ) ) - ); -#endif -} - -} // namespace GksGpu - -#endif - diff --git a/src/gpu/GksGpu/FlowStateData/HeatCapacities.cuh b/src/gpu/GksGpu/FlowStateData/HeatCapacities.cuh deleted file mode 100644 index 04a164aa327bed36cca2b8756c87dd1c7d9f0a64..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FlowStateData/HeatCapacities.cuh +++ /dev/null @@ -1,407 +0,0 @@ -//#ifndef HeatCapacities_H -//#define HeatCapacities_H -// -// #ifdef __CUDACC__ -// #include <cuda_runtime.h> -// #else -// #ifndef __host__ -// #define __host__ -// #endif -// #ifndef __device__ -// #define __device__ -// #endif -// #endif -// -//#include "Core/DataTypes.h" -//#include "Core/RealConstants.h" -// -//#include "Definitions/PassiveScalar.h" -// -//#include "FlowStateData/FlowStateData.cuh" -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -//#ifdef USE_PASSIVE_SCALAR -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -//__host__ __device__ inline real getCp( real T, real* CpData ) -//{ -// real T0 = 100.0; -// real dT = 200.0; -// -// int i = int( ( T - T0 ) / dT ); -// -// real CpLow = CpData[i]; -// real CpHigh = CpData[i+1]; -// -// real x = (T - T0 - i * dT) / dT; -// -// return CpLow + x * ( CpHigh - CpLow ); -//} -// -////__host__ __device__ inline real getIntegratedCp( real T, real* CpData ) -////{ -//// real T0 = 100.0; -//// real dT = 200.0; -//// -//// int i = int( ( T - T0 ) / dT ); -//// -//// real CpLow = CpData[i]; -//// real CpHigh = CpData[i+1]; -//// -//// real x = (T - T0 - i * dT) / dT; -//// -//// real CpAtT = CpLow + x * ( CpHigh - CpLow ); -//// -//// real sum = dT * c1o2 * CpLow; -//// -//// for( int j = 0; j < i; j++ ) -//// { -//// sum += dT * CpData[i]; -//// } -//// -//// sum += (T - T0 - i * dT) * c1o2 * ( CpLow + CpAtT ); -//// -//// return sum; -////} -// -//__host__ __device__ inline real getIntegratedCv( real T, real* CpData ) -//{ -// real T0 = 100.0; -// real dT = 200.0; -// -// int i = int( ( T - T0 ) / dT ); -// -// real Cv0 = CpData[0] - real(8.31445984848); -// real CvLow = CpData[i] - real(8.31445984848); -// real CvHigh = CpData[i+1] - real(8.31445984848); -// -// real deltaT = T - T0 - i * dT; -// -// real x = deltaT / dT; -// -// real CvAtT = CvLow + x * ( CvHigh - CvLow ); -// -// ////////////////////////////////////////////////////////////////////////// -// -// real sum = c1o2 * deltaT * ( CvLow + CvAtT ); -// -// if( i > 0 ) -// { -// sum += dT * c1o2 * ( Cv0 + CvLow ); -// -// for (int j = 1; j < i; j++) -// { -// sum += dT * ( CpData[j] - real(8.31445984848) ); -// } -// } -// -// return sum; -//} -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -//__host__ __device__ inline real getCpO2( real T ) -//{ -// real CpData [] = { -// 29.106, -// 29.385, -// 31.091, -// 32.981, -// 34.355, -// 35.300, -// 35.988, -// 36.544, -// 37.040, -// 37.510, -// 37.969, -// 38.419, -// 38.856, -// 39.276, -// 39.674, -// 40.048, -// 40.395, -// 40.716, -// 41.013, -// 41.289 -// }; -// -// return getCp( T, CpData); -//} -// -//__host__ __device__ inline real getCpN2( real T ) -//{ -// real CpData [] = { -// 29.104, -// 29.125, -// 29.580, -// 30.754, -// 32.090, -// 33.241, -// 34.147, -// 34.843, -// 35.378, -// 35.796, -// 36.126, -// 36.395, -// 36.616, -// 36.801, -// 36.959, -// 37.096, -// 37.216, -// 37.323, -// 37.420, -// 37.508 -// }; -// -// return getCp( T, CpData); -//} -// -//__host__ __device__ inline real getCpCH4( real T ) -//{ -// -// real CpData [] = { -// 33.258, -// 35.708, -// 46.342, -// 57.794, -// 67.601, -// 75.529, -// 81.744, -// 86.556, -// 90.283, -// 93.188, -// 95.477, -// 97.301, -// 98.772, -// 99.971, -// 100.960, -// 101.782, -// 102.474, -// 103.060, -// 103.560, -// 103.990 -// }; -// -// return getCp( T, CpData); -//} -// -//__host__ __device__ inline real getCpH2O( real T ) -//{ -// -// real CpData [] = { -// 33.299, -// 33.596, -// 35.226, -// 37.495, -// 39.987, -// 42.536, -// 44.945, -// 47.090, -// 48.935, -// 50.496, -// 51.823, -// 52.947, -// 53.904, -// 54.723, -// 55.430, -// 56.044, -// 56.583, -// 57.058, -// 57.480, -// 57.859 -// }; -// -// return getCp( T, CpData); -//} -// -//__host__ __device__ inline real getCpCO2( real T ) -//{ -// -// real CpData [] = { -// 29.208, -// 37.221, -// 44.627, -// 49.564, -// 52.999, -// 55.409, -// 57.137, -// 58.379, -// 59.317, -// 60.049, -// 60.622, -// 61.086, -// 61.471, -// 61.802, -// 62.095, -// 62.347, -// 62.573, -// 62.785, -// 62.980, -// 63.166 -// }; -// -// return getCp( T, CpData); -//} -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -//__host__ __device__ inline real getIntegratedCvO2( real T ) -//{ -// real CpData [] = { -// 29.106, -// 29.385, -// 31.091, -// 32.981, -// 34.355, -// 35.300, -// 35.988, -// 36.544, -// 37.040, -// 37.510, -// 37.969, -// 38.419, -// 38.856, -// 39.276, -// 39.674, -// 40.048, -// 40.395, -// 40.716, -// 41.013, -// 41.289 -// }; -// -// return getIntegratedCv( T, CpData); -//} -// -//__host__ __device__ inline real getIntegratedCvN2( real T ) -//{ -// real CpData [] = { -// 29.104, -// 29.125, -// 29.580, -// 30.754, -// 32.090, -// 33.241, -// 34.147, -// 34.843, -// 35.378, -// 35.796, -// 36.126, -// 36.395, -// 36.616, -// 36.801, -// 36.959, -// 37.096, -// 37.216, -// 37.323, -// 37.420, -// 37.508 -// }; -// -// return getIntegratedCv( T, CpData); -//} -// -//__host__ __device__ inline real getIntegratedCvCH4( real T ) -//{ -// -// real CpData [] = { -// 33.258, -// 35.708, -// 46.342, -// 57.794, -// 67.601, -// 75.529, -// 81.744, -// 86.556, -// 90.283, -// 93.188, -// 95.477, -// 97.301, -// 98.772, -// 99.971, -// 100.960, -// 101.782, -// 102.474, -// 103.060, -// 103.560, -// 103.990 -// }; -// -// return getIntegratedCv( T, CpData); -//} -// -//__host__ __device__ inline real getIntegratedCvH2O( real T ) -//{ -// -// real CpData [] = { -// 33.299, -// 33.596, -// 35.226, -// 37.495, -// 39.987, -// 42.536, -// 44.945, -// 47.090, -// 48.935, -// 50.496, -// 51.823, -// 52.947, -// 53.904, -// 54.723, -// 55.430, -// 56.044, -// 56.583, -// 57.058, -// 57.480, -// 57.859 -// }; -// -// return getIntegratedCv( T, CpData); -//} -// -//__host__ __device__ inline real getIntegratedCvCO2( real T ) -//{ -// -// real CpData [] = { -// 29.208, -// 37.221, -// 44.627, -// 49.564, -// 52.999, -// 55.409, -// 57.137, -// 58.379, -// 59.317, -// 60.049, -// 60.622, -// 61.086, -// 61.471, -// 61.802, -// 62.095, -// 62.347, -// 62.573, -// 62.785, -// 62.980, -// 63.166 -// }; -// -// return getIntegratedCv( T, CpData); -//} -// -// -//#endif -// -// -// -//#endif -// diff --git a/src/gpu/GksGpu/FlowStateData/ThermalDependencies.cuh b/src/gpu/GksGpu/FlowStateData/ThermalDependencies.cuh deleted file mode 100644 index 47eb261a089b9a1c8d7bb14bca864c334887d447..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FlowStateData/ThermalDependencies.cuh +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef ThermalDependencies_H -#define ThermalDependencies_H - -#ifdef __CUDACC__ -#include <cuda_runtime.h> -#else -#ifndef __host__ -#define __host__ -#endif -#ifndef __device__ -#define __device__ -#endif -#endif - -#include <math.h> - -#include "Core/DataTypes.h" -#include "Core/RealConstants.h" - -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/HeatCapacities.cuh" - -namespace GksGpu { - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#define R_U real( 8.31445984848 ) - -#define M_A real( 0.02884 ) -#define M_P real( 0.0276199095022624 ) -#define M_F real( 0.016 ) - -#define M_O2 real( 0.032 ) - -#define rX real( 0.21 ) - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline real getT( const PrimitiveVariables& prim ) -{ - real T = M_A / ( c2o1 * prim.lambda * R_U ); - - return T; -} - -__host__ __device__ inline void setLambdaFromT( PrimitiveVariables& prim, real T ) -{ - prim.lambda = M_A / ( c2o1 * T * R_U ); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -} // namespace GksGpu - - - - -#endif - diff --git a/src/gpu/GksGpu/FluxComputation/ApplyFlux.cuh b/src/gpu/GksGpu/FluxComputation/ApplyFlux.cuh deleted file mode 100644 index 0a938799d240d42615f8c478a0c949526adf9463..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FluxComputation/ApplyFlux.cuh +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef ApplyFlux_CUH -#define ApplyFlux_CUH - - -#include "GksGpu_export.h" - -#include "Core/DataTypes.h" - -#include "DataBase/DataBase.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -namespace GksGpu { - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void applyFluxToNegCell( const DataBaseStruct& dataBase, - const uint& negCellIdx, - const ConservedVariables& flux, - const char direction, - const Parameters& parameters) -{ - realAccumulator* dataUpdate = dataBase.dataUpdate; - -#if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ > 0)) - atomicAdd( &( dataUpdate[ RHO__(negCellIdx, dataBase.numberOfCells) ] ), - (realAccumulator)flux.rho ); - atomicAdd( &( dataUpdate[ RHO_U(negCellIdx, dataBase.numberOfCells) ] ), - (realAccumulator)flux.rhoU ); - atomicAdd( &( dataUpdate[ RHO_V(negCellIdx, dataBase.numberOfCells) ] ), - (realAccumulator)flux.rhoV ); - atomicAdd( &( dataUpdate[ RHO_W(negCellIdx, dataBase.numberOfCells) ] ), - (realAccumulator)flux.rhoW ); - atomicAdd( &( dataUpdate[ RHO_E(negCellIdx, dataBase.numberOfCells) ] ), - (realAccumulator)flux.rhoE ); -#ifdef USE_PASSIVE_SCALAR - atomicAdd( &( dataUpdate[ RHO_S_1(negCellIdx, dataBase.numberOfCells) ] ), - (realAccumulator)flux.rhoS_1 ); - atomicAdd( &( dataUpdate[ RHO_S_2(negCellIdx, dataBase.numberOfCells) ] ), - (realAccumulator)flux.rhoS_2 ); -#endif // USE_PASSIVE_SCALAR - - if( parameters.forcingSchemeIdx == 0 || parameters.forcingSchemeIdx == 1 ) - { - if (direction == 'x') - atomicAdd(&(dataBase.massFlux[VEC_X(negCellIdx, dataBase.numberOfCells)]), flux.rho); - if (direction == 'y') - atomicAdd(&(dataBase.massFlux[VEC_Y(negCellIdx, dataBase.numberOfCells)]), flux.rho); - if (direction == 'z') - atomicAdd(&(dataBase.massFlux[VEC_Z(negCellIdx, dataBase.numberOfCells)]), flux.rho); - } -#else -#pragma omp atomic - dataUpdate[ RHO__(negCellIdx, dataBase.numberOfCells) ] -= flux.rho ; -#pragma omp atomic - dataUpdate[ RHO_U(negCellIdx, dataBase.numberOfCells) ] -= flux.rhoU; -#pragma omp atomic - dataUpdate[ RHO_V(negCellIdx, dataBase.numberOfCells) ] -= flux.rhoV; -#pragma omp atomic - dataUpdate[ RHO_W(negCellIdx, dataBase.numberOfCells) ] -= flux.rhoW; -#pragma omp atomic - dataUpdate[ RHO_E(negCellIdx, dataBase.numberOfCells) ] -= flux.rhoE; -#ifdef USE_PASSIVE_SCALAR -#pragma omp atomic - dataUpdate[ RHO_S_1(negCellIdx, dataBase.numberOfCells) ] -= flux.rhoS_1; - dataUpdate[ RHO_S_2(negCellIdx, dataBase.numberOfCells) ] -= flux.rhoS_2; -#endif // USE_PASSIVE_SCALAR - - if( parameters.forcingSchemeIdx == 0 || parameters.forcingSchemeIdx == 1 ) - { - if( direction == 'x' ) - #pragma omp atomic - dataBase.massFlux[ VEC_X(negCellIdx, dataBase.numberOfCells) ] += flux.rho; - if( direction == 'y' ) - #pragma omp atomic - dataBase.massFlux[ VEC_Y(negCellIdx, dataBase.numberOfCells) ] += flux.rho; - if( direction == 'z' ) - #pragma omp atomic - dataBase.massFlux[ VEC_Z(negCellIdx, dataBase.numberOfCells) ] += flux.rho; - } -#endif - -} - -__host__ __device__ inline void applyFluxToPosCell( const DataBaseStruct& dataBase, - const uint& posCellIdx, - const ConservedVariables& flux, - const char& direction, - const Parameters& parameters) -{ - realAccumulator* dataUpdate = dataBase.dataUpdate; - -#if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ > 0)) - atomicAdd( &( dataUpdate[ RHO__(posCellIdx, dataBase.numberOfCells) ] ), (realAccumulator)flux.rho ); - atomicAdd( &( dataUpdate[ RHO_U(posCellIdx, dataBase.numberOfCells) ] ), (realAccumulator)flux.rhoU ); - atomicAdd( &( dataUpdate[ RHO_V(posCellIdx, dataBase.numberOfCells) ] ), (realAccumulator)flux.rhoV ); - atomicAdd( &( dataUpdate[ RHO_W(posCellIdx, dataBase.numberOfCells) ] ), (realAccumulator)flux.rhoW ); - atomicAdd( &( dataUpdate[ RHO_E(posCellIdx, dataBase.numberOfCells) ] ), (realAccumulator)flux.rhoE ); -#ifdef USE_PASSIVE_SCALAR - atomicAdd( &( dataUpdate[ RHO_S_1(posCellIdx, dataBase.numberOfCells) ] ), (realAccumulator)flux.rhoS_1 ); - atomicAdd( &( dataUpdate[ RHO_S_2(posCellIdx, dataBase.numberOfCells) ] ), (realAccumulator)flux.rhoS_2 ); -#endif // USE_PASSIVE_SCALAR - - if( parameters.forcingSchemeIdx == 0 || parameters.forcingSchemeIdx == 1 ) - { - if (direction == 'x') - atomicAdd(&(dataBase.massFlux[VEC_X(posCellIdx, dataBase.numberOfCells)]), flux.rho); - if (direction == 'y') - atomicAdd(&(dataBase.massFlux[VEC_Y(posCellIdx, dataBase.numberOfCells)]), flux.rho); - if (direction == 'z') - atomicAdd(&(dataBase.massFlux[VEC_Z(posCellIdx, dataBase.numberOfCells)]), flux.rho); - } -#else -#pragma omp atomic - dataUpdate[ RHO__(posCellIdx, dataBase.numberOfCells) ] += flux.rho ; -#pragma omp atomic - dataUpdate[ RHO_U(posCellIdx, dataBase.numberOfCells) ] += flux.rhoU; -#pragma omp atomic - dataUpdate[ RHO_V(posCellIdx, dataBase.numberOfCells) ] += flux.rhoV; -#pragma omp atomic - dataUpdate[ RHO_W(posCellIdx, dataBase.numberOfCells) ] += flux.rhoW; -#pragma omp atomic - dataUpdate[ RHO_E(posCellIdx, dataBase.numberOfCells) ] += flux.rhoE; -#ifdef USE_PASSIVE_SCALAR -#pragma omp atomic - dataUpdate[ RHO_S_1(posCellIdx, dataBase.numberOfCells) ] += flux.rhoS_1; - dataUpdate[ RHO_S_2(posCellIdx, dataBase.numberOfCells) ] += flux.rhoS_2; -#endif // USE_PASSIVE_SCALAR - - if( parameters.forcingSchemeIdx == 0 || parameters.forcingSchemeIdx == 1 ) - { - if (direction == 'x') - #pragma omp atomic - dataBase.massFlux[VEC_X(posCellIdx, dataBase.numberOfCells)] += flux.rho; - if (direction == 'y') - #pragma omp atomic - dataBase.massFlux[VEC_Y(posCellIdx, dataBase.numberOfCells)] += flux.rho; - if (direction == 'z') - #pragma omp atomic - dataBase.massFlux[VEC_Z(posCellIdx, dataBase.numberOfCells)] += flux.rho; - } -#endif -} - -} // namespace GksGpu - -#endif \ No newline at end of file diff --git a/src/gpu/GksGpu/FluxComputation/AssembleFlux.cuh b/src/gpu/GksGpu/FluxComputation/AssembleFlux.cuh deleted file mode 100644 index 3e00c3ae33d6083d37d4cf334dd51d575f4fc0db..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FluxComputation/AssembleFlux.cuh +++ /dev/null @@ -1,569 +0,0 @@ -#ifndef AssembleFlux_CUH -#define AssembleFlux_CUH - - -#include "GksGpu_export.h" - -#include "Core/DataTypes.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBase.h" -#include "Parameters/Parameters.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#include "FluxComputation/SutherlandsLaw.cuh" -#include "FluxComputation/Moments.cuh" - -extern __device__ real atomicAdd(real* address, real val); - -#define NUMBER_OF_MOMENTS 7 - -namespace GksGpu { - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void computeTimeDerivative( const PrimitiveVariables& facePrim, - const real momentU [ NUMBER_OF_MOMENTS ], - const real momentV [ NUMBER_OF_MOMENTS ], - const real momentW [ NUMBER_OF_MOMENTS ], - const real momentXi[ NUMBER_OF_MOMENTS ], - const real ax[LENGTH_CELL_DATA], - const real ay[LENGTH_CELL_DATA], - const real az[LENGTH_CELL_DATA], - const Vec3& force, - ConservedVariables& timeGrad ) -{ - timeGrad.rho = ax[0]*momentU[1] + ax[1]*momentU[2] + c1o2*ax[4]*momentU[3] + ay[0]*momentV[1] + - ax[2]*momentU[1]*momentV[1] + ay[1]*momentU[1]*momentV[1] + - c1o2*ay[4]*momentU[2]*momentV[1] + ay[2]*momentV[2] + c1o2*ax[4]*momentU[1]*momentV[2] + - c1o2*ay[4]*momentV[3] + az[0]*momentW[1] + ax[3]*momentU[1]*momentW[1] + - az[1]*momentU[1]*momentW[1] + c1o2*az[4]*momentU[2]*momentW[1] + - ay[3]*momentV[1]*momentW[1] + az[2]*momentV[1]*momentW[1] + - c1o2*az[4]*momentV[2]*momentW[1] + az[3]*momentW[2] + c1o2*ax[4]*momentU[1]*momentW[2] + - c1o2*ay[4]*momentV[1]*momentW[2] + c1o2*az[4]*momentW[3] + - c1o2*ax[4]*momentU[1]*momentXi[2] + c1o2*ay[4]*momentV[1]*momentXi[2] + - c1o2*az[4]*momentW[1]*momentXi[2]; - - timeGrad.rhoU = ax[0]*momentU[2] + ax[1]*momentU[3] + c1o2*ax[4]*momentU[4] + - ay[0]*momentU[1]*momentV[1] + ax[2]*momentU[2]*momentV[1] + - ay[1]*momentU[2]*momentV[1] + c1o2*ay[4]*momentU[3]*momentV[1] + - ay[2]*momentU[1]*momentV[2] + c1o2*ax[4]*momentU[2]*momentV[2] + - c1o2*ay[4]*momentU[1]*momentV[3] + az[0]*momentU[1]*momentW[1] + - ax[3]*momentU[2]*momentW[1] + az[1]*momentU[2]*momentW[1] + - c1o2*az[4]*momentU[3]*momentW[1] + ay[3]*momentU[1]*momentV[1]*momentW[1] + - az[2]*momentU[1]*momentV[1]*momentW[1] + c1o2*az[4]*momentU[1]*momentV[2]*momentW[1] + - az[3]*momentU[1]*momentW[2] + c1o2*ax[4]*momentU[2]*momentW[2] + - c1o2*ay[4]*momentU[1]*momentV[1]*momentW[2] + c1o2*az[4]*momentU[1]*momentW[3] + - c1o2*ax[4]*momentU[2]*momentXi[2] + c1o2*ay[4]*momentU[1]*momentV[1]*momentXi[2] + - c1o2*az[4]*momentU[1]*momentW[1]*momentXi[2]; - - timeGrad.rhoV = ax[0]*momentU[1]*momentV[1] + ax[1]*momentU[2]*momentV[1] + - c1o2*ax[4]*momentU[3]*momentV[1] + ay[0]*momentV[2] + ax[2]*momentU[1]*momentV[2] + - ay[1]*momentU[1]*momentV[2] + c1o2*ay[4]*momentU[2]*momentV[2] + ay[2]*momentV[3] + - c1o2*ax[4]*momentU[1]*momentV[3] + c1o2*ay[4]*momentV[4] + az[0]*momentV[1]*momentW[1] + - ax[3]*momentU[1]*momentV[1]*momentW[1] + az[1]*momentU[1]*momentV[1]*momentW[1] + - c1o2*az[4]*momentU[2]*momentV[1]*momentW[1] + ay[3]*momentV[2]*momentW[1] + - az[2]*momentV[2]*momentW[1] + c1o2*az[4]*momentV[3]*momentW[1] + - az[3]*momentV[1]*momentW[2] + c1o2*ax[4]*momentU[1]*momentV[1]*momentW[2] + - c1o2*ay[4]*momentV[2]*momentW[2] + c1o2*az[4]*momentV[1]*momentW[3] + - c1o2*ax[4]*momentU[1]*momentV[1]*momentXi[2] + c1o2*ay[4]*momentV[2]*momentXi[2] + - c1o2*az[4]*momentV[1]*momentW[1]*momentXi[2]; - - timeGrad.rhoW = ax[0]*momentU[1]*momentW[1] + ax[1]*momentU[2]*momentW[1] + - c1o2*ax[4]*momentU[3]*momentW[1] + ay[0]*momentV[1]*momentW[1] + - ax[2]*momentU[1]*momentV[1]*momentW[1] + ay[1]*momentU[1]*momentV[1]*momentW[1] + - c1o2*ay[4]*momentU[2]*momentV[1]*momentW[1] + ay[2]*momentV[2]*momentW[1] + - c1o2*ax[4]*momentU[1]*momentV[2]*momentW[1] + c1o2*ay[4]*momentV[3]*momentW[1] + - az[0]*momentW[2] + ax[3]*momentU[1]*momentW[2] + az[1]*momentU[1]*momentW[2] + - c1o2*az[4]*momentU[2]*momentW[2] + ay[3]*momentV[1]*momentW[2] + - az[2]*momentV[1]*momentW[2] + c1o2*az[4]*momentV[2]*momentW[2] + az[3]*momentW[3] + - c1o2*ax[4]*momentU[1]*momentW[3] + c1o2*ay[4]*momentV[1]*momentW[3] + - c1o2*az[4]*momentW[4] + c1o2*ax[4]*momentU[1]*momentW[1]*momentXi[2] + - c1o2*ay[4]*momentV[1]*momentW[1]*momentXi[2] + c1o2*az[4]*momentW[2]*momentXi[2]; - - timeGrad.rhoE = c1o2*ax[0]*momentU[3] + c1o2*ax[1]*momentU[4] + c1o4*ax[4]*momentU[5] + - c1o2*ay[0]*momentU[2]*momentV[1] + c1o2*ax[2]*momentU[3]*momentV[1] + - c1o2*ay[1]*momentU[3]*momentV[1] + c1o4*ay[4]*momentU[4]*momentV[1] + - c1o2*ax[0]*momentU[1]*momentV[2] + c1o2*ax[1]*momentU[2]*momentV[2] + - c1o2*ay[2]*momentU[2]*momentV[2] + c1o2*ax[4]*momentU[3]*momentV[2] + - c1o2*ay[0]*momentV[3] + c1o2*ax[2]*momentU[1]*momentV[3] + - c1o2*ay[1]*momentU[1]*momentV[3] + c1o2*ay[4]*momentU[2]*momentV[3] + - c1o2*ay[2]*momentV[4] + c1o4*ax[4]*momentU[1]*momentV[4] + c1o4*ay[4]*momentV[5] + - c1o2*az[0]*momentU[2]*momentW[1] + c1o2*ax[3]*momentU[3]*momentW[1] + - c1o2*az[1]*momentU[3]*momentW[1] + c1o4*az[4]*momentU[4]*momentW[1] + - c1o2*ay[3]*momentU[2]*momentV[1]*momentW[1] + c1o2*az[2]*momentU[2]*momentV[1]*momentW[1] + - c1o2*az[0]*momentV[2]*momentW[1] + c1o2*ax[3]*momentU[1]*momentV[2]*momentW[1] + - c1o2*az[1]*momentU[1]*momentV[2]*momentW[1] + c1o2*az[4]*momentU[2]*momentV[2]*momentW[1] + - c1o2*ay[3]*momentV[3]*momentW[1] + c1o2*az[2]*momentV[3]*momentW[1] + - c1o4*az[4]*momentV[4]*momentW[1] + c1o2*ax[0]*momentU[1]*momentW[2] + - c1o2*ax[1]*momentU[2]*momentW[2] + c1o2*az[3]*momentU[2]*momentW[2] + - c1o2*ax[4]*momentU[3]*momentW[2] + c1o2*ay[0]*momentV[1]*momentW[2] + - c1o2*ax[2]*momentU[1]*momentV[1]*momentW[2] + c1o2*ay[1]*momentU[1]*momentV[1]*momentW[2] + - c1o2*ay[4]*momentU[2]*momentV[1]*momentW[2] + c1o2*ay[2]*momentV[2]*momentW[2] + - c1o2*az[3]*momentV[2]*momentW[2] + c1o2*ax[4]*momentU[1]*momentV[2]*momentW[2] + - c1o2*ay[4]*momentV[3]*momentW[2] + c1o2*az[0]*momentW[3] + - c1o2*ax[3]*momentU[1]*momentW[3] + c1o2*az[1]*momentU[1]*momentW[3] + - c1o2*az[4]*momentU[2]*momentW[3] + c1o2*ay[3]*momentV[1]*momentW[3] + - c1o2*az[2]*momentV[1]*momentW[3] + c1o2*az[4]*momentV[2]*momentW[3] + - c1o2*az[3]*momentW[4] + c1o4*ax[4]*momentU[1]*momentW[4] + - c1o4*ay[4]*momentV[1]*momentW[4] + c1o4*az[4]*momentW[5] + - c1o2*ax[0]*momentU[1]*momentXi[2] + c1o2*ax[1]*momentU[2]*momentXi[2] + - c1o2*ax[4]*momentU[3]*momentXi[2] + c1o2*ay[0]*momentV[1]*momentXi[2] + - c1o2*ax[2]*momentU[1]*momentV[1]*momentXi[2] + - c1o2*ay[1]*momentU[1]*momentV[1]*momentXi[2] + - c1o2*ay[4]*momentU[2]*momentV[1]*momentXi[2] + c1o2*ay[2]*momentV[2]*momentXi[2] + - c1o2*ax[4]*momentU[1]*momentV[2]*momentXi[2] + c1o2*ay[4]*momentV[3]*momentXi[2] + - c1o2*az[0]*momentW[1]*momentXi[2] + c1o2*ax[3]*momentU[1]*momentW[1]*momentXi[2] + - c1o2*az[1]*momentU[1]*momentW[1]*momentXi[2] + - c1o2*az[4]*momentU[2]*momentW[1]*momentXi[2] + - c1o2*ay[3]*momentV[1]*momentW[1]*momentXi[2] + - c1o2*az[2]*momentV[1]*momentW[1]*momentXi[2] + - c1o2*az[4]*momentV[2]*momentW[1]*momentXi[2] + c1o2*az[3]*momentW[2]*momentXi[2] + - c1o2*ax[4]*momentU[1]*momentW[2]*momentXi[2] + - c1o2*ay[4]*momentV[1]*momentW[2]*momentXi[2] + c1o2*az[4]*momentW[3]*momentXi[2] + - c1o4*ax[4]*momentU[1]*momentXi[4] + c1o4*ay[4]*momentV[1]*momentXi[4] + - c1o4*az[4]*momentW[1]*momentXi[4]; - - ////////////////////////////////////////////////////////////////////////// - - timeGrad.rho += c2o1 * facePrim.lambda * ( facePrim.U - momentU[1] ) * force.x - + c2o1 * facePrim.lambda * ( facePrim.V - momentV[1] ) * force.y - + c2o1 * facePrim.lambda * ( facePrim.W - momentW[1] ) * force.z ; - - timeGrad.rhoU += c2o1 * facePrim.lambda * ( momentU[1] * facePrim.U - momentU[2] ) * force.x - + c2o1 * facePrim.lambda * ( momentU[1] * facePrim.V - momentU[1] * momentV[1] ) * force.y - + c2o1 * facePrim.lambda * ( momentU[1] * facePrim.W - momentU[1] * momentW[1] ) * force.z ; - - timeGrad.rhoV += c2o1 * facePrim.lambda * ( momentV[1] * facePrim.U - momentU[1] * momentV[1] ) * force.x - + c2o1 * facePrim.lambda * ( momentV[1] * facePrim.V - momentV[2] ) * force.y - + c2o1 * facePrim.lambda * ( momentV[1] * facePrim.W - momentV[1] * momentW[1] ) * force.z ; - - timeGrad.rhoW += c2o1 * facePrim.lambda * ( momentW[1] * facePrim.U - momentU[1] * momentW[1] ) * force.x - + c2o1 * facePrim.lambda * ( momentW[1] * facePrim.V - momentV[1] * momentW[1] ) * force.y - + c2o1 * facePrim.lambda * ( momentW[1] * facePrim.W - momentW[2] ) * force.z ; - - timeGrad.rhoE += facePrim.lambda * ( ( momentU[2] + momentV[2] + momentW[2] + momentXi[2] ) * facePrim.U - - - ( momentU[3] - + momentU[1] * momentV[2] - + momentU[1] * momentW[2] - + momentU[1] * momentXi[2] ) - ) * force.x - - + facePrim.lambda * ( ( momentU[2] + momentV[2] + momentW[2] + momentXi[2] ) * facePrim.V - - - ( momentU[2] * momentV[1] - + momentV[3] - + momentV[1] * momentW[2] - + momentV[1] * momentXi[2] ) - ) * force.y - - + facePrim.lambda * ( ( momentU[2] + momentV[2] + momentW[2] + momentXi[2] ) * facePrim.W - - - ( momentU[2] * momentW[1] - + momentV[2] * momentW[1] - + momentW[3] - + momentW[1] * momentXi[2] ) - ) * force.z ; - - ////////////////////////////////////////////////////////////////////////// - - timeGrad.rho *= - c1o1; - timeGrad.rhoU *= - c1o1; - timeGrad.rhoV *= - c1o1; - timeGrad.rhoW *= - c1o1; - timeGrad.rhoE *= - c1o1; - - ////////////////////////////////////////////////////////////////////////// - -#ifdef USE_PASSIVE_SCALAR - timeGrad.rhoS_1 = timeGrad.rho * facePrim.S_1 - + ( ax[5] * momentU[1] - + ay[5] * momentV[1] - + az[5] * momentW[1] ) - / (c1o2 * facePrim.lambda); - - timeGrad.rhoS_2 = timeGrad.rho * facePrim.S_2 - + ( ax[6] * momentU[1] - + ay[6] * momentV[1] - + az[6] * momentW[1] ) - / (c1o2 * facePrim.lambda); - - timeGrad.rhoS_1 *= - c1o1; - timeGrad.rhoS_2 *= - c1o1; -#endif // USE_PASSIVE_SCALAR - - ////////////////////////////////////////////////////////////////////////// -} - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void computeTimeCoefficients(const PrimitiveVariables & facePrim, Parameters& parameters, real timeCoefficients[4]) -{ - real r = parameters.lambdaRef / facePrim.lambda; - - //if( r < zero ) printf( "ERROR: %f/%f\n", parameters.lambdaRef, facePrim.lambda ); - - real mu = getViscosity(parameters, r); - - real tau = c2o1 * facePrim.lambda * mu / facePrim.rho; - - real dt = parameters.dt; - - timeCoefficients[0] = dt; - timeCoefficients[1] = - tau * dt; - timeCoefficients[2] = c1o2 * dt * dt - tau * dt; - - timeCoefficients[3] = tau ; -} - -__host__ __device__ inline void getTau(const PrimitiveVariables & facePrim, Parameters& parameters, real& tau) -{ - real r = parameters.lambdaRef / facePrim.lambda; - - real mu = getViscosity(parameters, r); mu = sutherlandsLaw2( parameters, r ); - - tau = c2o1 * facePrim.lambda * mu / facePrim.rho; -} - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void assembleFlux( const PrimitiveVariables& facePrim, - const real momentU [ NUMBER_OF_MOMENTS ], - const real momentV [ NUMBER_OF_MOMENTS ], - const real momentW [ NUMBER_OF_MOMENTS ], - const real momentXi[ NUMBER_OF_MOMENTS ], - const real ax[LENGTH_CELL_DATA], - const real ay[LENGTH_CELL_DATA], - const real az[LENGTH_CELL_DATA], - const real at[LENGTH_CELL_DATA], - const real timeCoefficients[4], - const Parameters& parameters, - const Vec3 force, - ConservedVariables& flux, - real& heatFlux ) -{ - ConservedVariables flux_1, flux_2, flux_3; - - flux_1.rho = momentU[0+1] ; - flux_1.rhoU = momentU[1+1] ; - flux_1.rhoV = momentU[0+1] * momentV[1] ; - flux_1.rhoW = momentU[0+1] * momentW[1]; - - flux_1.rhoE = c1o2 * ( momentU[2+1] - + momentU[0+1] * momentV[2] - + momentU[0+1] * momentW[2] - + momentU[0+1] * momentXi[2] ); - - ////////////////////////////////////////////////////////////////////////// - - flux_2.rho = ax[0]*momentU[2] + ax[1]*momentU[3] + c1o2*ax[4]*momentU[4] + - ay[0]*momentU[1]*momentV[1] + ax[2]*momentU[2]*momentV[1] + - ay[1]*momentU[2]*momentV[1] + c1o2*ay[4]*momentU[3]*momentV[1] + - ay[2]*momentU[1]*momentV[2] + c1o2*ax[4]*momentU[2]*momentV[2] + - c1o2*ay[4]*momentU[1]*momentV[3] + az[0]*momentU[1]*momentW[1] + - ax[3]*momentU[2]*momentW[1] + az[1]*momentU[2]*momentW[1] + - c1o2*az[4]*momentU[3]*momentW[1] + ay[3]*momentU[1]*momentV[1]*momentW[1] + - az[2]*momentU[1]*momentV[1]*momentW[1] + c1o2*az[4]*momentU[1]*momentV[2]*momentW[1] + - az[3]*momentU[1]*momentW[2] + c1o2*ax[4]*momentU[2]*momentW[2] + - c1o2*ay[4]*momentU[1]*momentV[1]*momentW[2] + c1o2*az[4]*momentU[1]*momentW[3] + - c1o2*ax[4]*momentU[2]*momentXi[2] + c1o2*ay[4]*momentU[1]*momentV[1]*momentXi[2] + - c1o2*az[4]*momentU[1]*momentW[1]*momentXi[2]; - - flux_2.rhoU = ax[0]*momentU[3] + ax[1]*momentU[4] + c1o2*ax[4]*momentU[5] + - ay[0]*momentU[2]*momentV[1] + ax[2]*momentU[3]*momentV[1] + - ay[1]*momentU[3]*momentV[1] + c1o2*ay[4]*momentU[4]*momentV[1] + - ay[2]*momentU[2]*momentV[2] + c1o2*ax[4]*momentU[3]*momentV[2] + - c1o2*ay[4]*momentU[2]*momentV[3] + az[0]*momentU[2]*momentW[1] + - ax[3]*momentU[3]*momentW[1] + az[1]*momentU[3]*momentW[1] + - c1o2*az[4]*momentU[4]*momentW[1] + ay[3]*momentU[2]*momentV[1]*momentW[1] + - az[2]*momentU[2]*momentV[1]*momentW[1] + c1o2*az[4]*momentU[2]*momentV[2]*momentW[1] + - az[3]*momentU[2]*momentW[2] + c1o2*ax[4]*momentU[3]*momentW[2] + - c1o2*ay[4]*momentU[2]*momentV[1]*momentW[2] + c1o2*az[4]*momentU[2]*momentW[3] + - c1o2*ax[4]*momentU[3]*momentXi[2] + c1o2*ay[4]*momentU[2]*momentV[1]*momentXi[2] + - c1o2*az[4]*momentU[2]*momentW[1]*momentXi[2]; - - flux_2.rhoV = ax[0]*momentU[2]*momentV[1] + ax[1]*momentU[3]*momentV[1] + - c1o2*ax[4]*momentU[4]*momentV[1] + ay[0]*momentU[1]*momentV[2] + - ax[2]*momentU[2]*momentV[2] + ay[1]*momentU[2]*momentV[2] + - c1o2*ay[4]*momentU[3]*momentV[2] + ay[2]*momentU[1]*momentV[3] + - c1o2*ax[4]*momentU[2]*momentV[3] + c1o2*ay[4]*momentU[1]*momentV[4] + - az[0]*momentU[1]*momentV[1]*momentW[1] + ax[3]*momentU[2]*momentV[1]*momentW[1] + - az[1]*momentU[2]*momentV[1]*momentW[1] + c1o2*az[4]*momentU[3]*momentV[1]*momentW[1] + - ay[3]*momentU[1]*momentV[2]*momentW[1] + az[2]*momentU[1]*momentV[2]*momentW[1] + - c1o2*az[4]*momentU[1]*momentV[3]*momentW[1] + az[3]*momentU[1]*momentV[1]*momentW[2] + - c1o2*ax[4]*momentU[2]*momentV[1]*momentW[2] + c1o2*ay[4]*momentU[1]*momentV[2]*momentW[2] + - c1o2*az[4]*momentU[1]*momentV[1]*momentW[3] + - c1o2*ax[4]*momentU[2]*momentV[1]*momentXi[2] + - c1o2*ay[4]*momentU[1]*momentV[2]*momentXi[2] + - c1o2*az[4]*momentU[1]*momentV[1]*momentW[1]*momentXi[2]; - - flux_2.rhoW = ax[0]*momentU[2]*momentW[1] + ax[1]*momentU[3]*momentW[1] + - c1o2*ax[4]*momentU[4]*momentW[1] + ay[0]*momentU[1]*momentV[1]*momentW[1] + - ax[2]*momentU[2]*momentV[1]*momentW[1] + ay[1]*momentU[2]*momentV[1]*momentW[1] + - c1o2*ay[4]*momentU[3]*momentV[1]*momentW[1] + ay[2]*momentU[1]*momentV[2]*momentW[1] + - c1o2*ax[4]*momentU[2]*momentV[2]*momentW[1] + c1o2*ay[4]*momentU[1]*momentV[3]*momentW[1] + - az[0]*momentU[1]*momentW[2] + ax[3]*momentU[2]*momentW[2] + - az[1]*momentU[2]*momentW[2] + c1o2*az[4]*momentU[3]*momentW[2] + - ay[3]*momentU[1]*momentV[1]*momentW[2] + az[2]*momentU[1]*momentV[1]*momentW[2] + - c1o2*az[4]*momentU[1]*momentV[2]*momentW[2] + az[3]*momentU[1]*momentW[3] + - c1o2*ax[4]*momentU[2]*momentW[3] + c1o2*ay[4]*momentU[1]*momentV[1]*momentW[3] + - c1o2*az[4]*momentU[1]*momentW[4] + c1o2*ax[4]*momentU[2]*momentW[1]*momentXi[2] + - c1o2*ay[4]*momentU[1]*momentV[1]*momentW[1]*momentXi[2] + - c1o2*az[4]*momentU[1]*momentW[2]*momentXi[2]; - - flux_2.rhoE = c1o2*ax[0]*momentU[4] + c1o2*ax[1]*momentU[5] + c1o4*ax[4]*momentU[6] + - c1o2*ay[0]*momentU[3]*momentV[1] + c1o2*ax[2]*momentU[4]*momentV[1] + - c1o2*ay[1]*momentU[4]*momentV[1] + c1o4*ay[4]*momentU[5]*momentV[1] + - c1o2*ax[0]*momentU[2]*momentV[2] + c1o2*ax[1]*momentU[3]*momentV[2] + - c1o2*ay[2]*momentU[3]*momentV[2] + c1o2*ax[4]*momentU[4]*momentV[2] + - c1o2*ay[0]*momentU[1]*momentV[3] + c1o2*ax[2]*momentU[2]*momentV[3] + - c1o2*ay[1]*momentU[2]*momentV[3] + c1o2*ay[4]*momentU[3]*momentV[3] + - c1o2*ay[2]*momentU[1]*momentV[4] + c1o4*ax[4]*momentU[2]*momentV[4] + - c1o4*ay[4]*momentU[1]*momentV[5] + c1o2*az[0]*momentU[3]*momentW[1] + - c1o2*ax[3]*momentU[4]*momentW[1] + c1o2*az[1]*momentU[4]*momentW[1] + - c1o4*az[4]*momentU[5]*momentW[1] + c1o2*ay[3]*momentU[3]*momentV[1]*momentW[1] + - c1o2*az[2]*momentU[3]*momentV[1]*momentW[1] + - c1o2*az[0]*momentU[1]*momentV[2]*momentW[1] + - c1o2*ax[3]*momentU[2]*momentV[2]*momentW[1] + c1o2*az[1]*momentU[2]*momentV[2]*momentW[1] + - c1o2*az[4]*momentU[3]*momentV[2]*momentW[1] + c1o2*ay[3]*momentU[1]*momentV[3]*momentW[1] + - c1o2*az[2]*momentU[1]*momentV[3]*momentW[1] + c1o4*az[4]*momentU[1]*momentV[4]*momentW[1] + - c1o2*ax[0]*momentU[2]*momentW[2] + c1o2*ax[1]*momentU[3]*momentW[2] + - c1o2*az[3]*momentU[3]*momentW[2] + c1o2*ax[4]*momentU[4]*momentW[2] + - c1o2*ay[0]*momentU[1]*momentV[1]*momentW[2] + - c1o2*ax[2]*momentU[2]*momentV[1]*momentW[2] + c1o2*ay[1]*momentU[2]*momentV[1]*momentW[2] + - c1o2*ay[4]*momentU[3]*momentV[1]*momentW[2] + c1o2*ay[2]*momentU[1]*momentV[2]*momentW[2] + - c1o2*az[3]*momentU[1]*momentV[2]*momentW[2] + c1o2*ax[4]*momentU[2]*momentV[2]*momentW[2] + - c1o2*ay[4]*momentU[1]*momentV[3]*momentW[2] + c1o2*az[0]*momentU[1]*momentW[3] + - c1o2*ax[3]*momentU[2]*momentW[3] + c1o2*az[1]*momentU[2]*momentW[3] + - c1o2*az[4]*momentU[3]*momentW[3] + c1o2*ay[3]*momentU[1]*momentV[1]*momentW[3] + - c1o2*az[2]*momentU[1]*momentV[1]*momentW[3] + c1o2*az[4]*momentU[1]*momentV[2]*momentW[3] + - c1o2*az[3]*momentU[1]*momentW[4] + c1o4*ax[4]*momentU[2]*momentW[4] + - c1o4*ay[4]*momentU[1]*momentV[1]*momentW[4] + c1o4*az[4]*momentU[1]*momentW[5] + - c1o2*ax[0]*momentU[2]*momentXi[2] + c1o2*ax[1]*momentU[3]*momentXi[2] + - c1o2*ax[4]*momentU[4]*momentXi[2] + c1o2*ay[0]*momentU[1]*momentV[1]*momentXi[2] + - c1o2*ax[2]*momentU[2]*momentV[1]*momentXi[2] + - c1o2*ay[1]*momentU[2]*momentV[1]*momentXi[2] + - c1o2*ay[4]*momentU[3]*momentV[1]*momentXi[2] + - c1o2*ay[2]*momentU[1]*momentV[2]*momentXi[2] + - c1o2*ax[4]*momentU[2]*momentV[2]*momentXi[2] + - c1o2*ay[4]*momentU[1]*momentV[3]*momentXi[2] + - c1o2*az[0]*momentU[1]*momentW[1]*momentXi[2] + - c1o2*ax[3]*momentU[2]*momentW[1]*momentXi[2] + - c1o2*az[1]*momentU[2]*momentW[1]*momentXi[2] + - c1o2*az[4]*momentU[3]*momentW[1]*momentXi[2] + - c1o2*ay[3]*momentU[1]*momentV[1]*momentW[1]*momentXi[2] + - c1o2*az[2]*momentU[1]*momentV[1]*momentW[1]*momentXi[2] + - c1o2*az[4]*momentU[1]*momentV[2]*momentW[1]*momentXi[2] + - c1o2*az[3]*momentU[1]*momentW[2]*momentXi[2] + - c1o2*ax[4]*momentU[2]*momentW[2]*momentXi[2] + - c1o2*ay[4]*momentU[1]*momentV[1]*momentW[2]*momentXi[2] + - c1o2*az[4]*momentU[1]*momentW[3]*momentXi[2] + c1o4*ax[4]*momentU[2]*momentXi[4] + - c1o4*ay[4]*momentU[1]*momentV[1]*momentXi[4] + c1o4*az[4]*momentU[1]*momentW[1]*momentXi[4]; - - ////////////////////////////////////////////////////////////////////////// - - flux_2.rho += c2o1 * facePrim.lambda * ( momentU[0+1] * facePrim.U - momentU[1+1] ) * force.x - + c2o1 * facePrim.lambda * ( momentU[0+1] * facePrim.V - momentU[0+1] * momentV[1] ) * force.y - + c2o1 * facePrim.lambda * ( momentU[0+1] * facePrim.W - momentU[0+1] * momentW[1] ) * force.z ; - - flux_2.rhoU += c2o1 * facePrim.lambda * ( momentU[1+1] * facePrim.U - momentU[2+1] ) * force.x - + c2o1 * facePrim.lambda * ( momentU[1+1] * facePrim.V - momentU[1+1] * momentV[1] ) * force.y - + c2o1 * facePrim.lambda * ( momentU[1+1] * facePrim.W - momentU[1+1] * momentW[1] ) * force.z ; - - flux_2.rhoV += c2o1 * facePrim.lambda * ( momentU[0+1] * momentV[1] * facePrim.U - momentU[1+1] * momentV[1] ) * force.x - + c2o1 * facePrim.lambda * ( momentU[0+1] * momentV[1] * facePrim.V - momentU[0+1] * momentV[2] ) * force.y - + c2o1 * facePrim.lambda * ( momentU[0+1] * momentV[1] * facePrim.W - momentU[0+1] * momentV[1] * momentW[1] ) * force.z ; - - flux_2.rhoW += c2o1 * facePrim.lambda * ( momentU[0+1] * momentW[1] * facePrim.U - momentU[1+1] * momentW[1] ) * force.x - + c2o1 * facePrim.lambda * ( momentU[0+1] * momentW[1] * facePrim.V - momentU[0+1] * momentV[1] * momentW[1] ) * force.y - + c2o1 * facePrim.lambda * ( momentU[0+1] * momentW[1] * facePrim.W - momentU[0+1] * momentW[2] ) * force.z ; - - flux_2.rhoE += facePrim.lambda * ( ( momentU[2+1] + momentV[2] + momentW[2] + momentXi[2] ) * facePrim.U - - - ( momentU[3+1] - + momentU[1+1] * momentV[2] - + momentU[1+1] * momentW[2] - + momentU[1+1] * momentXi[2] ) - ) * force.x - - + facePrim.lambda * ( ( momentU[2+1] + momentV[2] + momentW[2] + momentXi[2] ) * facePrim.V - - - ( momentU[2+1] * momentV[1] - + momentU[0+1] * momentV[3] - + momentU[0+1] * momentV[1] * momentW[2] - + momentU[0+1] * momentV[1] * momentXi[2] ) - ) * force.y - - + facePrim.lambda * ( ( momentU[2+1] + momentV[2] + momentW[2] + momentXi[2] ) * facePrim.W - - - ( momentU[2+1] * momentW[1] - + momentU[0+1] * momentV[2] * momentW[1] - + momentU[0+1] * momentW[3] - + momentU[0+1] * momentW[1] * momentXi[2] ) - ) * force.z ; - - ////////////////////////////////////////////////////////////////////////// - - flux_3.rho = at[0]*momentU[1] + at[1]*momentU[2] + c1o2*at[4]*momentU[3] + at[2]*momentU[1]*momentV[1] + - c1o2*at[4]*momentU[1]*momentV[2] + at[3]*momentU[1]*momentW[1] + - c1o2*at[4]*momentU[1]*momentW[2] + c1o2*at[4]*momentU[1]*momentXi[2]; - - flux_3.rhoU = at[0]*momentU[2] + at[1]*momentU[3] + c1o2*at[4]*momentU[4] + at[2]*momentU[2]*momentV[1] + - c1o2*at[4]*momentU[2]*momentV[2] + at[3]*momentU[2]*momentW[1] + - c1o2*at[4]*momentU[2]*momentW[2] + c1o2*at[4]*momentU[2]*momentXi[2]; - - flux_3.rhoV = at[0]*momentU[1]*momentV[1] + at[1]*momentU[2]*momentV[1] + - c1o2*at[4]*momentU[3]*momentV[1] + at[2]*momentU[1]*momentV[2] + - c1o2*at[4]*momentU[1]*momentV[3] + at[3]*momentU[1]*momentV[1]*momentW[1] + - c1o2*at[4]*momentU[1]*momentV[1]*momentW[2] + c1o2*at[4]*momentU[1]*momentV[1]*momentXi[2]; - - flux_3.rhoW = at[0]*momentU[1]*momentW[1] + at[1]*momentU[2]*momentW[1] + - c1o2*at[4]*momentU[3]*momentW[1] + at[2]*momentU[1]*momentV[1]*momentW[1] + - c1o2*at[4]*momentU[1]*momentV[2]*momentW[1] + at[3]*momentU[1]*momentW[2] + - c1o2*at[4]*momentU[1]*momentW[3] + c1o2*at[4]*momentU[1]*momentW[1]*momentXi[2]; - - flux_3.rhoE = c1o2*at[0]*momentU[3] + c1o2*at[1]*momentU[4] + c1o4*at[4]*momentU[5] + - c1o2*at[2]*momentU[3]*momentV[1] + c1o2*at[0]*momentU[1]*momentV[2] + - c1o2*at[1]*momentU[2]*momentV[2] + c1o2*at[4]*momentU[3]*momentV[2] + - c1o2*at[2]*momentU[1]*momentV[3] + c1o4*at[4]*momentU[1]*momentV[4] + - c1o2*at[3]*momentU[3]*momentW[1] + c1o2*at[3]*momentU[1]*momentV[2]*momentW[1] + - c1o2*at[0]*momentU[1]*momentW[2] + c1o2*at[1]*momentU[2]*momentW[2] + - c1o2*at[4]*momentU[3]*momentW[2] + c1o2*at[2]*momentU[1]*momentV[1]*momentW[2] + - c1o2*at[4]*momentU[1]*momentV[2]*momentW[2] + c1o2*at[3]*momentU[1]*momentW[3] + - c1o4*at[4]*momentU[1]*momentW[4] + c1o2*at[0]*momentU[1]*momentXi[2] + - c1o2*at[1]*momentU[2]*momentXi[2] + c1o2*at[4]*momentU[3]*momentXi[2] + - c1o2*at[2]*momentU[1]*momentV[1]*momentXi[2] + - c1o2*at[4]*momentU[1]*momentV[2]*momentXi[2] + - c1o2*at[3]*momentU[1]*momentW[1]*momentXi[2] + - c1o2*at[4]*momentU[1]*momentW[2]*momentXi[2] + c1o4*at[4]*momentU[1]*momentXi[4]; - - ////////////////////////////////////////////////////////////////////////// - - flux.rho = ( timeCoefficients[0] * flux_1.rho + timeCoefficients[1] * flux_2.rho + timeCoefficients[2] * flux_3.rho ) * parameters.dx * parameters.dx * facePrim.rho; - flux.rhoU = ( timeCoefficients[0] * flux_1.rhoU + timeCoefficients[1] * flux_2.rhoU + timeCoefficients[2] * flux_3.rhoU ) * parameters.dx * parameters.dx * facePrim.rho; - flux.rhoV = ( timeCoefficients[0] * flux_1.rhoV + timeCoefficients[1] * flux_2.rhoV + timeCoefficients[2] * flux_3.rhoV ) * parameters.dx * parameters.dx * facePrim.rho; - flux.rhoW = ( timeCoefficients[0] * flux_1.rhoW + timeCoefficients[1] * flux_2.rhoW + timeCoefficients[2] * flux_3.rhoW ) * parameters.dx * parameters.dx * facePrim.rho; - flux.rhoE = ( timeCoefficients[0] * flux_1.rhoE + timeCoefficients[1] * flux_2.rhoE + timeCoefficients[2] * flux_3.rhoE ) * parameters.dx * parameters.dx * facePrim.rho; - - ////////////////////////////////////////////////////////////////////////// - - real qConstPr = timeCoefficients[1] * ( ( flux_2.rhoE + flux_3.rhoE ) - - facePrim.U * ( flux_2.rhoU + flux_3.rhoU ) - - facePrim.V * ( flux_2.rhoV + flux_3.rhoV ) - - facePrim.W * ( flux_2.rhoW + flux_3.rhoW ) - ) * parameters.dx * parameters.dx * facePrim.rho; - - flux.rhoE += ( c1o1 / parameters.Pr - c1o1 ) * qConstPr; - - heatFlux = qConstPr / parameters.Pr; - - ////////////////////////////////////////////////////////////////////////// - -//#ifdef USE_PASSIVE_SCALAR -// flux_1.rhoS_1 = flux_1.rho * facePrim.S_1; -// flux_1.rhoS_2 = flux_1.rho * facePrim.S_2; -// -// flux_2.rhoS_1 = flux_2.rho * facePrim.S_1 -// + ( ax[5] * momentU[1+1] -// + ay[5] * momentU[0+1] * momentV[1] -// + az[5] * momentU[0+1] * momentW[1] -// ) / (two * facePrim.lambda); -// -// flux_2.rhoS_2 = flux_2.rho * facePrim.S_2 -// + ( ax[6] * momentU[1+1] -// + ay[6] * momentU[0+1] * momentV[1] -// + az[6] * momentU[0+1] * momentW[1] -// ) / (two * facePrim.lambda); -// -// flux_3.rhoS_1 = flux_3.rho * facePrim.S_1 -// + at[5] * momentU[0 + 1] -// / ( two * facePrim.lambda ); -// -// flux_3.rhoS_2 = flux_3.rho * facePrim.S_2 -// + at[6] * momentU[0 + 1] -// / ( two * facePrim.lambda ); -// -// -// real tauS = parameters.D * two * facePrim.lambda; -// -// real dt = parameters.dt; -// -// real timeCoefficientsScalar [3]; -// -// timeCoefficientsScalar[0] = dt; -// timeCoefficientsScalar[1] = -tauS * dt; -// timeCoefficientsScalar[2] = c1o2 * dt * dt - tauS * dt; -// -// flux.rhoS_1 = ( timeCoefficientsScalar[0] * flux_1.rhoS_1 + timeCoefficientsScalar[1] * flux_2.rhoS_1 + timeCoefficientsScalar[2] * flux_3.rhoS_1 ) * parameters.dx * parameters.dx * facePrim.rho; -// flux.rhoS_2 = ( timeCoefficientsScalar[0] * flux_1.rhoS_2 + timeCoefficientsScalar[1] * flux_2.rhoS_2 + timeCoefficientsScalar[2] * flux_3.rhoS_2 ) * parameters.dx * parameters.dx * facePrim.rho; -// -//#endif // USE_PASSIVE_SCALAR - - ////////////////////////////////////////////////////////////////////////// - -#ifdef USE_PASSIVE_SCALAR - - flux_2.rhoS_1 = ( ax[5] * momentU[1+1] - + ay[5] * momentU[0+1] * momentV[1] - + az[5] * momentU[0+1] * momentW[1] - ) / (c2o1 * facePrim.lambda); - - flux_2.rhoS_2 = ( ax[6] * momentU[1+1] - + ay[6] * momentU[0+1] * momentV[1] - + az[6] * momentU[0+1] * momentW[1] - ) / (c2o1 * facePrim.lambda); - - flux_3.rhoS_1 = at[5] * momentU[0 + 1] - / ( c2o1 * facePrim.lambda ); - - flux_3.rhoS_2 = at[6] * momentU[0 + 1] - / ( c2o1 * facePrim.lambda ); - - ////////////////////////////////////////////////////////////////////////// - - real dt = parameters.dt; - real timeCoefficientsScalar [3]; - - { - real tauS = parameters.D1 * c2o1 * facePrim.lambda; - timeCoefficientsScalar[0] = dt; - timeCoefficientsScalar[1] = -tauS * dt; - timeCoefficientsScalar[2] = c1o2 * dt * dt - tauS * dt; - - flux.rhoS_1 = flux.rho * facePrim.S_1 + ( timeCoefficientsScalar[1] * flux_2.rhoS_1 + timeCoefficientsScalar[2] * flux_3.rhoS_1 ) * parameters.dx * parameters.dx * facePrim.rho; - } - - { - real tauS = parameters.D2 * c2o1 * facePrim.lambda; - timeCoefficientsScalar[0] = dt; - timeCoefficientsScalar[1] = -tauS * dt; - timeCoefficientsScalar[2] = c1o2 * dt * dt - tauS * dt; - - flux.rhoS_2 = flux.rho * facePrim.S_2 + ( timeCoefficientsScalar[1] * flux_2.rhoS_2 + timeCoefficientsScalar[2] * flux_3.rhoS_2 ) * parameters.dx * parameters.dx * facePrim.rho; - } - -#endif // USE_PASSIVE_SCALAR -} - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -} // namespace GksGpu - -#endif \ No newline at end of file diff --git a/src/gpu/GksGpu/FluxComputation/ExpansionCoefficients.cuh b/src/gpu/GksGpu/FluxComputation/ExpansionCoefficients.cuh deleted file mode 100644 index 69c00acdda7d0f35ac3433af177471db083853b9..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FluxComputation/ExpansionCoefficients.cuh +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef ExpansionCoefficients_CUH -#define ExpansionCoefficients_CUH - - -#include "GksGpu_export.h" - -#include "Core/DataTypes.h" - -#include "DataBase/DataBase.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -namespace GksGpu { - -__host__ __device__ inline void computeExpansionCoefficients(const PrimitiveVariables & facePrim, - const ConservedVariables & gradient, - const real K, - real expansionCoefficient[LENGTH_CELL_DATA]) -{ - real two_E, - rho_dU_dx, - rho_dV_dx, - rho_dW_dx, - two_rho_dE_dx; - - two_E = facePrim.U * facePrim.U - + facePrim.V * facePrim.V - + facePrim.W * facePrim.W - + c1o2 * ( K + c3o1 ) / facePrim.lambda; - - rho_dU_dx = gradient.rhoU - facePrim.U * gradient.rho; - rho_dV_dx = gradient.rhoV - facePrim.V * gradient.rho; - rho_dW_dx = gradient.rhoW - facePrim.W * gradient.rho; - two_rho_dE_dx = c2o1 * gradient.rhoE - two_E * gradient.rho; - - expansionCoefficient[4] = ( c4o1 * facePrim.lambda * facePrim.lambda ) / ( K + c3o1 ) - * ( two_rho_dE_dx - c2o1 * facePrim.U * rho_dU_dx - - c2o1 * facePrim.V * rho_dV_dx - - c2o1 * facePrim.W * rho_dW_dx ); - - expansionCoefficient[3] = c2o1 * facePrim.lambda * rho_dW_dx - facePrim.W * expansionCoefficient[4]; - - expansionCoefficient[2] = c2o1 * facePrim.lambda * rho_dV_dx - facePrim.V * expansionCoefficient[4]; - - expansionCoefficient[1] = c2o1 * facePrim.lambda * rho_dU_dx - facePrim.U * expansionCoefficient[4]; - - expansionCoefficient[0] = gradient.rho - facePrim.U * expansionCoefficient[1] - - facePrim.V * expansionCoefficient[2] - - facePrim.W * expansionCoefficient[3] - - c1o2 * two_E * expansionCoefficient[4]; - -#ifdef USE_PASSIVE_SCALAR - expansionCoefficient[5] = c2o1 * facePrim.lambda * (gradient.rhoS_1 - facePrim.S_1 * gradient.rho); - expansionCoefficient[6] = c2o1 * facePrim.lambda * (gradient.rhoS_2 - facePrim.S_2 * gradient.rho); -#endif // USE_PASSIVE_SCALAR -} - -} // namespace GksGpu - -#endif \ No newline at end of file diff --git a/src/gpu/GksGpu/FluxComputation/FluxComputation.cu b/src/gpu/GksGpu/FluxComputation/FluxComputation.cu deleted file mode 100644 index 25ba5726bfd505518bf82b88accea1c3549c5b96..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FluxComputation/FluxComputation.cu +++ /dev/null @@ -1,478 +0,0 @@ -#include "FluxComputation.h" - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" - -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/PassiveScalar.h" - -#include "FlowStateData/FlowStateData.cuh" - -#include "CellProperties/CellProperties.cuh" - -#include "FluxComputation/Moments.cuh" -#include "FluxComputation/Reconstruction.cuh" -#include "FluxComputation/Transformation.cuh" -#include "FluxComputation/ExpansionCoefficients.cuh" -#include "FluxComputation/AssembleFlux.cuh" -#include "FluxComputation/ApplyFlux.cuh" -#include "FluxComputation/Smagorinsky.cuh" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu { - -__global__ void fluxKernel ( DataBaseStruct dataBase, Parameters parameters, char direction, uint startIndex, uint numberOfEntities ); - -__host__ __device__ inline void fluxFunction( DataBaseStruct dataBase, Parameters parameters, char direction, uint startIndex, uint index ); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void FluxComputation::run( SPtr<DataBase> dataBase, Parameters parameters, uint level, bool evaluateCommFaces ) -{ - //{ - // CudaUtility::CudaGrid grid(dataBase->perLevelCount[level].numberOfFacesX, 128); - - // runKernel(fluxKernel, - // fluxFunction, - // dataBase->getDeviceType(), grid, - // dataBase->toStruct(), - // parameters, - // 'x', - // dataBase->perLevelCount[level].startOfFacesX); - - // cudaDeviceSynchronize(); - - // getLastCudaError("FluxComputation::run( SPtr<DataBase> dataBase, Parameters parameters, 'x', uint level )"); - //} - //{ - // CudaUtility::CudaGrid grid(dataBase->perLevelCount[level].numberOfFacesY, 128); - - // runKernel(fluxKernel, - // fluxFunction, - // dataBase->getDeviceType(), grid, - // dataBase->toStruct(), - // parameters, - // 'y', - // dataBase->perLevelCount[level].startOfFacesY); - - // cudaDeviceSynchronize(); - - // getLastCudaError("FluxComputation::run( SPtr<DataBase> dataBase, Parameters parameters, 'y', uint level )"); - //} - //{ - // CudaUtility::CudaGrid grid(dataBase->perLevelCount[level].numberOfFacesZ, 128); - - // runKernel(fluxKernel, - // fluxFunction, - // dataBase->getDeviceType(), grid, - // dataBase->toStruct(), - // parameters, - // 'z', - // dataBase->perLevelCount[level].startOfFacesZ); - - // cudaDeviceSynchronize(); - - // getLastCudaError("FluxComputation::run( SPtr<DataBase> dataBase, Parameters parameters, 'z', uint level )"); - //} - ////////////////////////////////////////////////////////////////////////// - //{ - // CudaUtility::CudaGrid grid(dataBase->perLevelCount[level].numberOfFaces, 64); - - // runKernel(fluxKernel, - // fluxFunction, - // dataBase->getDeviceType(), grid, - // dataBase->toStruct(), - // parameters, - // 'x', - // dataBase->perLevelCount[level].startOfFacesX); - - // cudaDeviceSynchronize(); - - // getLastCudaError("FluxComputation::run( SPtr<DataBase> dataBase, Parameters parameters, 'x', uint level )"); - //} - ////////////////////////////////////////////////////////////////////////// - if( evaluateCommFaces ) - { - CudaUtility::CudaGrid grid(dataBase->perLevelCount[level].numberOfFaces - dataBase->perLevelCount[level].numberOfInnerFaces, 64, CudaUtility::communicationStream); - - if( grid.numberOfEntities <= 0 ) return; - - runKernel(fluxKernel, - fluxFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - parameters, - 'x', - dataBase->perLevelCount[level].startOfFacesX + dataBase->perLevelCount[level].numberOfInnerFaces); - } - else - { - CudaUtility::CudaGrid grid(dataBase->perLevelCount[level].numberOfInnerFaces, 64, CudaUtility::computeStream); - - runKernel(fluxKernel, - fluxFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - parameters, - 'x', - dataBase->perLevelCount[level].startOfFacesX); - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__global__ void fluxKernel(DataBaseStruct dataBase, Parameters parameters, char direction, uint startIndex, uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - fluxFunction( dataBase, parameters, direction, startIndex, index ); -} - -__host__ __device__ inline void fluxFunction(DataBaseStruct dataBase, Parameters parameters, char direction, uint startIndex, uint index) -{ - uint faceIndex = startIndex + index; - - real K = parameters.K; - - direction = dataBase.faceOrientation[ faceIndex ]; - - parameters.D1 = parameters.D; - parameters.D2 = parameters.D; - - ////////////////////////////////////////////////////////////////////////// - - if( parameters.useSpongeLayer ) - { - if( parameters.spongeLayerIdx == 0 ) - { - // real x = dataBase.faceCenter[VEC_X(faceIndex, dataBase.numberOfFaces)]; - real z = dataBase.faceCenter[VEC_Z(faceIndex, dataBase.numberOfFaces)]; - - real muNew = parameters.mu; - - real zStart = real(0.35); - - if (fabsf(z) > zStart) - { - muNew += (fabs(z) - zStart) * c10o1 * c10o1 * c10o1 * parameters.mu; - } - - parameters.mu = muNew; - } - if( parameters.spongeLayerIdx == 1 ) - { - // real x = dataBase.faceCenter[VEC_X(faceIndex, dataBase.numberOfFaces)]; - real z = dataBase.faceCenter[VEC_Z(faceIndex, dataBase.numberOfFaces)]; - - real muNew = parameters.mu; - - real zStart = real(3.5); - - if (fabsf(z) > zStart) - { - muNew += (fabs(z) - zStart) * c10o1 * c10o1 * c10o1 * parameters.mu; - } - - parameters.mu = muNew; - } - if( parameters.spongeLayerIdx == 2 ) - { - real y = dataBase.faceCenter[VEC_Y(faceIndex, dataBase.numberOfFaces)]; - - real muNew = parameters.mu; - - real yStart = real(3.0); - - if (fabsf(y) > yStart) - { - muNew += (fabs(y) - yStart) * c10o1 * c10o1 * parameters.mu; - } - - parameters.mu = muNew; - } - } - - ////////////////////////////////////////////////////////////////////////// - - PrimitiveVariables facePrim; - - ////////////////////////////////////////////////////////////////////////// - - real ax[LENGTH_CELL_DATA]; - real ay[LENGTH_CELL_DATA]; - real az[LENGTH_CELL_DATA]; - real at[LENGTH_CELL_DATA]; - -#pragma unroll - for( uint i = 0; i < LENGTH_CELL_DATA; i++ ) - { - ax[i] = c0o1; - ay[i] = c0o1; - az[i] = c0o1; - at[i] = c0o1; - } - - ////////////////////////////////////////////////////////////////////////// - - { - ConservedVariables gradN, gradT1, gradT2; - - reconstructFiniteDifferences(faceIndex, - dataBase, - parameters, - direction, - gradN, - gradT1, - gradT2, - facePrim, - K); - - transformGlobalToLocal( gradN , direction ); - transformGlobalToLocal( gradT1, direction ); - transformGlobalToLocal( gradT2, direction ); - - transformGlobalToLocal( facePrim, direction ); - - computeExpansionCoefficients(facePrim, gradN , K, ax); - computeExpansionCoefficients(facePrim, gradT1, K, ay); - computeExpansionCoefficients(facePrim, gradT2, K, az); - - ////////////////////////////////////////////////////////////////////////// - - if(parameters.useSmagorinsky) - { - real muTurb = getTurbulentViscositySmagorinsky( parameters, facePrim, gradN, gradT1, gradT2 ); - - if( muTurb > parameters.mu ) - { - real turbSc = real(0.3); - real turbPr = real(0.5); - - parameters.mu = muTurb; - - parameters.D = muTurb / turbSc; - parameters.Pr = turbPr; - } - } - - ////////////////////////////////////////////////////////////////////////// - - if(parameters.useTemperatureLimiter){ - real k = parameters.mu / parameters.Pr; - - real dUdx1 = ( gradN.rhoU - facePrim.U * gradN.rho ); - real dUdx2 = ( gradT1.rhoU - facePrim.U * gradT1.rho ); - real dUdx3 = ( gradT2.rhoU - facePrim.U * gradT2.rho ); - - real dVdx1 = ( gradN.rhoV - facePrim.V * gradN.rho ); - real dVdx2 = ( gradT1.rhoV - facePrim.V * gradT1.rho ); - real dVdx3 = ( gradT2.rhoV - facePrim.V * gradT2.rho ); - - real dWdx1 = ( gradN.rhoW - facePrim.W * gradN.rho ); - real dWdx2 = ( gradT1.rhoW - facePrim.W * gradT1.rho ); - real dWdx3 = ( gradT2.rhoW - facePrim.W * gradT2.rho ); - - real dEdx1 = ( gradN.rhoE - facePrim.W * gradN.rho ); - real dEdx2 = ( gradT1.rhoE - facePrim.W * gradT1.rho ); - real dEdx3 = ( gradT2.rhoE - facePrim.W * gradT2.rho ); - - real dTdx1 = dEdx1 - c2o1 * facePrim.U * dUdx1 - c2o1 * facePrim.V * dVdx1 - c2o1 * facePrim.W * dWdx1; - real dTdx2 = dEdx2 - c2o1 * facePrim.U * dUdx2 - c2o1 * facePrim.V * dVdx2 - c2o1 * facePrim.W * dWdx2; - real dTdx3 = dEdx3 - c2o1 * facePrim.U * dUdx3 - c2o1 * facePrim.V * dVdx3 - c2o1 * facePrim.W * dWdx3; - - //real E = c1o2 * ( facePrim.U * facePrim.U - // + facePrim.V * facePrim.V - // + facePrim.W * facePrim.W - // + ( parameters.K + c3o1 ) / ( c4o1 * facePrim.lambda ) ); - - //real dEdx1 = ( gradN.rhoE - E * gradN.rho ); - //real dEdx2 = ( gradT1.rhoE - E * gradT1.rho ); - //real dEdx3 = ( gradT2.rhoE - E * gradT2.rho ); - - //real dTdx1 = dEdx1 - facePrim.U * dUdx1 - facePrim.V * dVdx1 - facePrim.W * dWdx1; - //real dTdx2 = dEdx2 - facePrim.U * dUdx2 - facePrim.V * dVdx2 - facePrim.W * dWdx2; - //real dTdx3 = dEdx3 - facePrim.U * dUdx3 - facePrim.V * dVdx3 - facePrim.W * dWdx3; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // this one works for some time - //real S = parameters.dx * parameters.dx * ( fabsf(dTdx1) + fabsf(dTdx2) + fabsf(dTdx3) ); - //k += real(0.00002) / real(0.015625) * S; - - //real T = getT(facePrim); - //if( T > 20 ) - //k += parameters.temperatureLimiter * S; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //real S = parameters.dx * ( fabsf(dTdx1) + fabsf(dTdx2) + fabsf(dTdx3) ); - //k += real(0.00001) * real(0.0025) * S * S; - - //real kMax = real(0.01) * c1o2 * parameters.dx * parameters.dx / parameters.dt; - //real kMax = real(0.01); - - real S = parameters.dx * parameters.dx * ( dTdx1 * dTdx1 + dTdx2 * dTdx2 + dTdx3 * dTdx3 ); - - k += fminf(parameters.temperatureLimiterUpperLimit, parameters.temperatureLimiter * S); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // this one works for some time - //real S = ( fabsf(dTdx1) + fabsf(dTdx2) + fabsf(dTdx3) ); - //k += real(0.00002) / real(0.015625) * S; - //k += real(1.28e-4) * parameters.dx * parameters.dx * parameters.dx * S * S; - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - parameters.Pr = parameters.mu / k; - } - } - - ////////////////////////////////////////////////////////////////////////// - - parameters.D1 = parameters.D; - parameters.D2 = parameters.D; - - if(parameters.usePassiveScalarLimiter){ - #ifdef USE_PASSIVE_SCALAR - - if( facePrim.S_1 < c0o1 ) parameters.D1 += - parameters.passiveScalarLimiter * facePrim.S_1; - if( facePrim.S_1 > c1o1 ) parameters.D1 += parameters.passiveScalarLimiter * ( facePrim.S_1 - c1o1 ); - - parameters.D2 = parameters.D1; - - if( facePrim.S_2 < c0o1 ) parameters.D2 += - real(0.1)*parameters.passiveScalarLimiter * facePrim.S_2; - if( facePrim.S_2 > c1o1 ) parameters.D2 += real(0.1)*parameters.passiveScalarLimiter * ( facePrim.S_2 - c1o1 ); - #endif // USE_PASSIVE_SCALAR - } - - ////////////////////////////////////////////////////////////////////////// - - //{ - //#ifdef USE_PASSIVE_SCALAR - // if( facePrim.S_1 < zero ) - // { - // parameters.D += - real(0.1) * facePrim.S_1; - // } - // if( facePrim.S_1 > one ) - // { - // parameters.D += real(0.1) * ( facePrim.S_1 - one ); - // } - - //#endif // USE_PASSIVE_SCALAR - //} - - ////////////////////////////////////////////////////////////////////////// - - { - ConservedVariables flux; - - { - real momentU [ NUMBER_OF_MOMENTS ]; - real momentV [ NUMBER_OF_MOMENTS ]; - real momentW [ NUMBER_OF_MOMENTS ]; - real momentXi[ NUMBER_OF_MOMENTS ]; - - computeMoments( facePrim, K, momentU, momentV, momentW, momentXi ); - - Vec3 force = parameters.force; - - transformGlobalToLocal(force, direction); - - { - ConservedVariables timeGrad; - computeTimeDerivative( facePrim, - momentU, - momentV, - momentW, - momentXi, - ax, ay, az, - force, - timeGrad ); - - computeExpansionCoefficients( facePrim, timeGrad, K, at ); - } - { - real timeCoefficients[4]; - computeTimeCoefficients( facePrim, parameters, timeCoefficients ); - - real heatFlux; - assembleFlux( facePrim, - momentU, momentV, momentW, momentXi, - ax, ay, az, at, - timeCoefficients, - parameters, - force, - flux, - heatFlux ); - - transformLocalToGlobal( flux, direction ); - } - } - - ////////////////////////////////////////////////////////////////////////// - - { - uint negCellIdx = dataBase.faceToCell[ NEG_CELL(faceIndex, dataBase.numberOfFaces) ]; - uint posCellIdx = dataBase.faceToCell[ POS_CELL(faceIndex, dataBase.numberOfFaces) ]; - - #if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ > 0)) - atomicAdd( &( dataBase.diffusivity[ negCellIdx ] ), (realAccumulator)( parameters.D * parameters.dx * parameters.dx * parameters.dt ) ); - atomicAdd( &( dataBase.diffusivity[ posCellIdx ] ), (realAccumulator)( parameters.D * parameters.dx * parameters.dx * parameters.dt ) ); - #endif - - CellProperties negCellProperties = dataBase.cellProperties[ negCellIdx ]; - CellProperties posCellProperties = dataBase.cellProperties[ posCellIdx ]; - - //if( isCellProperties( negCellProperties, CELL_PROPERTIES_IS_FLUX_BC ) || - // isCellProperties( posCellProperties, CELL_PROPERTIES_IS_FLUX_BC ) ) - // return; - - if( isCellProperties( negCellProperties, CELL_PROPERTIES_WALL ) || - isCellProperties( posCellProperties, CELL_PROPERTIES_WALL ) ) - { - flux.rho = c0o1; - #ifdef USE_PASSIVE_SCALAR - flux.rhoS_1 = c0o1; - flux.rhoS_2 = c0o1; - #endif //USE_PASSIVE_SCALAR - } - - if( isCellProperties( negCellProperties, CELL_PROPERTIES_IS_INSULATED ) || - isCellProperties( posCellProperties, CELL_PROPERTIES_IS_INSULATED ) ) - { - flux.rhoE = c0o1; - } - - uint negCellParentIdx = dataBase.parentCell[ negCellIdx ]; - uint posCellParentIdx = dataBase.parentCell[ posCellIdx ]; - - //if( !( negCellParentIdx != INVALID_INDEX ) != !( posCellParentIdx != INVALID_INDEX ) ) // XOR - if( ( negCellParentIdx == INVALID_INDEX ) != ( posCellParentIdx == INVALID_INDEX ) ) // XOR - { - if( !isCellProperties( negCellProperties, CELL_PROPERTIES_GHOST ) && - !isCellProperties( posCellProperties, CELL_PROPERTIES_GHOST ) ) - { - if (negCellParentIdx != INVALID_INDEX) - { - applyFluxToNegCell(dataBase, negCellParentIdx, flux, direction, parameters); - } - - if (posCellParentIdx != INVALID_INDEX) - { - applyFluxToPosCell(dataBase, posCellParentIdx, flux, direction, parameters); - } - } - } - - applyFluxToNegCell(dataBase, negCellIdx, flux, direction, parameters); - applyFluxToPosCell(dataBase, posCellIdx, flux, direction, parameters); - } - } -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/FluxComputation/FluxComputation.h b/src/gpu/GksGpu/FluxComputation/FluxComputation.h deleted file mode 100644 index 0fe86577dbe9901ac513cce802667db4b3db2ee7..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FluxComputation/FluxComputation.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef FluxComputation_H -#define FluxComputation_H - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" - -#include "DataBase/DataBase.h" -#include "Parameters/Parameters.h" - -namespace GksGpu { - -class GKSGPU_EXPORT FluxComputation -{ -public: - - static void run( SPtr<DataBase> dataBase, - Parameters parameters, - uint level, - bool evaluateCommFaces = false); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/FluxComputation/Moments.cuh b/src/gpu/GksGpu/FluxComputation/Moments.cuh deleted file mode 100644 index 8ba25dbef215bdff85c8618cff5e9da047b364f2..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FluxComputation/Moments.cuh +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef Moments_CUH -#define Moments_CUH - - -#include "GksGpu_export.h" - -#include "Core/DataTypes.h" - -#include "DataBase/DataBase.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -#define NUMBER_OF_MOMENTS 7 - -namespace GksGpu { - -__host__ __device__ inline void computeMoments( const PrimitiveVariables & facePrim, - const real K, - real momentU [NUMBER_OF_MOMENTS], - real momentV [NUMBER_OF_MOMENTS], - real momentW [NUMBER_OF_MOMENTS], - real momentXi[NUMBER_OF_MOMENTS] ) -{ - momentU[0] = c1o1; - momentU[1] = facePrim.U; -#pragma unroll - for ( uint i = 2; i < NUMBER_OF_MOMENTS; i++ ) - momentU[i] = facePrim.U * momentU[i - 1] + ( real(i - 1) * momentU[i - 2] )/( c2o1 * facePrim.lambda ); - - momentV[0] = c1o1; - momentV[1] = facePrim.V; -#pragma unroll - for ( uint i = 2; i < NUMBER_OF_MOMENTS; i++ ) - momentV[i] = facePrim.V * momentV[i - 1] + ( real(i - 1) * momentV[i - 2] )/( c2o1 * facePrim.lambda ); - - momentW[0] = c1o1; - momentW[1] = facePrim.W; -#pragma unroll - for ( uint i = 2; i < NUMBER_OF_MOMENTS; i++ ) - momentW[i] = facePrim.W * momentW[i - 1] + ( real(i - 1) * momentW[i - 2] )/( c2o1 * facePrim.lambda ); - - momentXi[0] = c1o1; - momentXi[1] = c0o1; - momentXi[2] = K / ( c2o1 * facePrim.lambda ); - momentXi[3] = c0o1; - momentXi[4] = K * ( c2o1 + K ) / ( c4o1 * facePrim.lambda * facePrim.lambda ); - momentXi[5] = c0o1; - momentXi[6] = ( K + c4o1 ) / ( c2o1 * facePrim.lambda ) * momentXi[4]; -} - -} // namespace GksGpu - - - -#endif \ No newline at end of file diff --git a/src/gpu/GksGpu/FluxComputation/Reconstruction.cuh b/src/gpu/GksGpu/FluxComputation/Reconstruction.cuh deleted file mode 100644 index 74134aba8b2f6e453b6e6095d887ec086836c1e3..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FluxComputation/Reconstruction.cuh +++ /dev/null @@ -1,263 +0,0 @@ -#ifndef Reconstruction_CUH -#define Reconstruction_CUH - - -#include "GksGpu_export.h" - -#include "Core/DataTypes.h" - -#include "DataBase/DataBase.h" -#include "Parameters/Parameters.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" -#include "FlowStateData/ThermalDependencies.cuh" - -namespace GksGpu { - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void getCellIndicesN ( const uint faceIndex, - const DataBaseStruct& dataBase, - uint& posCellIndexN, - uint& negCellIndexN ) -{ - posCellIndexN = dataBase.faceToCell[ POS_CELL( faceIndex, dataBase.numberOfFaces ) ]; - negCellIndexN = dataBase.faceToCell[ NEG_CELL( faceIndex, dataBase.numberOfFaces ) ]; -} - -__host__ __device__ inline void getCellIndicesTX( const uint faceIndex, - const DataBaseStruct& dataBase, - const uint posCellIndexN, - const uint negCellIndexN, - uint* posCellIndexTX, - uint* negCellIndexTX ) -{ - posCellIndexTX[0] = dataBase.cellToCell[ CELL_TO_CELL( posCellIndexN, 0, dataBase.numberOfCells ) ]; - posCellIndexTX[1] = dataBase.cellToCell[ CELL_TO_CELL( negCellIndexN, 0, dataBase.numberOfCells ) ]; - - negCellIndexTX[0] = dataBase.cellToCell[ CELL_TO_CELL( posCellIndexN, 1, dataBase.numberOfCells ) ]; - negCellIndexTX[1] = dataBase.cellToCell[ CELL_TO_CELL( negCellIndexN, 1, dataBase.numberOfCells ) ]; -} - -__host__ __device__ inline void getCellIndicesTY( const uint faceIndex, - const DataBaseStruct& dataBase, - const uint posCellIndexN, - const uint negCellIndexN, - uint* posCellIndexTY, - uint* negCellIndexTY ) -{ - posCellIndexTY[0] = dataBase.cellToCell[ CELL_TO_CELL( posCellIndexN, 2, dataBase.numberOfCells ) ]; - posCellIndexTY[1] = dataBase.cellToCell[ CELL_TO_CELL( negCellIndexN, 2, dataBase.numberOfCells ) ]; - - negCellIndexTY[0] = dataBase.cellToCell[ CELL_TO_CELL( posCellIndexN, 3, dataBase.numberOfCells ) ]; - negCellIndexTY[1] = dataBase.cellToCell[ CELL_TO_CELL( negCellIndexN, 3, dataBase.numberOfCells ) ]; -} - -__host__ __device__ inline void getCellIndicesTZ( const uint faceIndex, - const DataBaseStruct& dataBase, - const uint posCellIndexN, - const uint negCellIndexN, - uint* posCellIndexTZ, - uint* negCellIndexTZ ) -{ - posCellIndexTZ[0] = dataBase.cellToCell[ CELL_TO_CELL( posCellIndexN, 4, dataBase.numberOfCells ) ]; - posCellIndexTZ[1] = dataBase.cellToCell[ CELL_TO_CELL( negCellIndexN, 4, dataBase.numberOfCells ) ]; - - negCellIndexTZ[0] = dataBase.cellToCell[ CELL_TO_CELL( posCellIndexN, 5, dataBase.numberOfCells ) ]; - negCellIndexTZ[1] = dataBase.cellToCell[ CELL_TO_CELL( negCellIndexN, 5, dataBase.numberOfCells ) ]; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void computeFaceCons( const ConservedVariables& posCons, - const ConservedVariables& negCons, - ConservedVariables& faceCons ) -{ - faceCons.rho = c1o2 * ( negCons.rho + posCons.rho ); - faceCons.rhoU = c1o2 * ( negCons.rhoU + posCons.rhoU ); - faceCons.rhoV = c1o2 * ( negCons.rhoV + posCons.rhoV ); - faceCons.rhoW = c1o2 * ( negCons.rhoW + posCons.rhoW ); - faceCons.rhoE = c1o2 * ( negCons.rhoE + posCons.rhoE ); -#ifdef USE_PASSIVE_SCALAR - faceCons.rhoS_1 = c1o2 * ( negCons.rhoS_1 + posCons.rhoS_1 ); - faceCons.rhoS_2 = c1o2 * ( negCons.rhoS_2 + posCons.rhoS_2 ); -#endif // USE_PASSIVE_SCALAR -} - -__host__ __device__ inline void computeGradN( const Parameters& parameters, - const ConservedVariables& posCons, - const ConservedVariables& negCons, - const PrimitiveVariables& facePrim, - ConservedVariables& gradN ) -{ - gradN.rho = ( posCons.rho - negCons.rho ) / ( parameters.dx * facePrim.rho ); - gradN.rhoU = ( posCons.rhoU - negCons.rhoU ) / ( parameters.dx * facePrim.rho ); - gradN.rhoV = ( posCons.rhoV - negCons.rhoV ) / ( parameters.dx * facePrim.rho ); - gradN.rhoW = ( posCons.rhoW - negCons.rhoW ) / ( parameters.dx * facePrim.rho ); - gradN.rhoE = ( posCons.rhoE - negCons.rhoE ) / ( parameters.dx * facePrim.rho ); -#ifdef USE_PASSIVE_SCALAR - gradN.rhoS_1 = ( posCons.rhoS_1 - negCons.rhoS_1 ) / ( parameters.dx * facePrim.rho ); - gradN.rhoS_2 = ( posCons.rhoS_2 - negCons.rhoS_2 ) / ( parameters.dx * facePrim.rho ); -#endif // USE_PASSIVE_SCALAR -} - -__host__ __device__ inline void computeGradT( const DataBaseStruct& dataBase, - const Parameters& parameters, - const uint posCellIndexT[2], - const uint negCellIndexT[2], - const PrimitiveVariables& facePrim, - ConservedVariables& gradN ) -{ - ConservedVariables cons; - - ////////////////////////////////////////////////////////////////////////// - { - readCellData(posCellIndexT[0], dataBase, cons); - - gradN.rho += c1o2 * cons.rho; - gradN.rhoU += c1o2 * cons.rhoU; - gradN.rhoV += c1o2 * cons.rhoV; - gradN.rhoW += c1o2 * cons.rhoW; - gradN.rhoE += c1o2 * cons.rhoE; - #ifdef USE_PASSIVE_SCALAR - gradN.rhoS_1 += c1o2 * cons.rhoS_1; - gradN.rhoS_2 += c1o2 * cons.rhoS_2; - #endif // USE_PASSIVE_SCALAR - } - { - readCellData(posCellIndexT[1], dataBase, cons); - - gradN.rho += c1o2 * cons.rho; - gradN.rhoU += c1o2 * cons.rhoU; - gradN.rhoV += c1o2 * cons.rhoV; - gradN.rhoW += c1o2 * cons.rhoW; - gradN.rhoE += c1o2 * cons.rhoE; - #ifdef USE_PASSIVE_SCALAR - gradN.rhoS_1 += c1o2 * cons.rhoS_1; - gradN.rhoS_2 += c1o2 * cons.rhoS_2; - #endif // USE_PASSIVE_SCALAR - } - ////////////////////////////////////////////////////////////////////////// - { - readCellData(negCellIndexT[0], dataBase, cons); - - gradN.rho -= c1o2 * cons.rho; - gradN.rhoU -= c1o2 * cons.rhoU; - gradN.rhoV -= c1o2 * cons.rhoV; - gradN.rhoW -= c1o2 * cons.rhoW; - gradN.rhoE -= c1o2 * cons.rhoE; - #ifdef USE_PASSIVE_SCALAR - gradN.rhoS_1 -= c1o2 * cons.rhoS_1; - gradN.rhoS_2 -= c1o2 * cons.rhoS_2; - #endif // USE_PASSIVE_SCALAR - } - { - readCellData(negCellIndexT[1], dataBase, cons); - - gradN.rho -= c1o2 * cons.rho; - gradN.rhoU -= c1o2 * cons.rhoU; - gradN.rhoV -= c1o2 * cons.rhoV; - gradN.rhoW -= c1o2 * cons.rhoW; - gradN.rhoE -= c1o2 * cons.rhoE; - #ifdef USE_PASSIVE_SCALAR - gradN.rhoS_1 -= c1o2 * cons.rhoS_1; - gradN.rhoS_2 -= c1o2 * cons.rhoS_2; - #endif // USE_PASSIVE_SCALAR - } - ////////////////////////////////////////////////////////////////////////// - { - gradN.rho /= c2o1 * parameters.dx * facePrim.rho; - gradN.rhoU /= c2o1 * parameters.dx * facePrim.rho; - gradN.rhoV /= c2o1 * parameters.dx * facePrim.rho; - gradN.rhoW /= c2o1 * parameters.dx * facePrim.rho; - gradN.rhoE /= c2o1 * parameters.dx * facePrim.rho; - #ifdef USE_PASSIVE_SCALAR - gradN.rhoS_1 /= c2o1 * parameters.dx * facePrim.rho; - gradN.rhoS_2 /= c2o1 * parameters.dx * facePrim.rho; - #endif // USE_PASSIVE_SCALAR - } - ////////////////////////////////////////////////////////////////////////// -} - - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void reconstructFiniteDifferences( const uint faceIndex, - const DataBaseStruct& dataBase, - const Parameters& parameters, - const char direction, - ConservedVariables& gradN, - ConservedVariables& gradT1, - ConservedVariables& gradT2, - PrimitiveVariables& facePrim, - real& K ) -{ - uint posCellIndexN, negCellIndexN; - - getCellIndicesN( faceIndex, dataBase, posCellIndexN, negCellIndexN ); - - { - ConservedVariables posCons, negCons, faceCons; - - readCellData(posCellIndexN, dataBase, posCons); - readCellData(negCellIndexN, dataBase, negCons); - - computeFaceCons(posCons, negCons, faceCons); - - #ifdef USE_PASSIVE_SCALAR - { - //K = getK(faceCons); - } - #endif - - facePrim = toPrimitiveVariables( faceCons, K, false ); - - computeGradN( parameters, posCons, negCons, facePrim, gradN ); - } - - { - uint posCellIndexT1[2]; - uint negCellIndexT1[2]; - - if( direction == 'x' ) getCellIndicesTY(faceIndex, dataBase, posCellIndexN, negCellIndexN, posCellIndexT1, negCellIndexT1); - if( direction == 'y' ) getCellIndicesTZ(faceIndex, dataBase, posCellIndexN, negCellIndexN, posCellIndexT1, negCellIndexT1); - if( direction == 'z' ) getCellIndicesTX(faceIndex, dataBase, posCellIndexN, negCellIndexN, posCellIndexT1, negCellIndexT1); - - computeGradT( dataBase, parameters, posCellIndexT1, negCellIndexT1, facePrim, gradT1 ); - } - - { - uint posCellIndexT2[2]; - uint negCellIndexT2[2]; - - if( direction == 'x' ) getCellIndicesTZ(faceIndex, dataBase, posCellIndexN, negCellIndexN, posCellIndexT2, negCellIndexT2); - if( direction == 'y' ) getCellIndicesTX(faceIndex, dataBase, posCellIndexN, negCellIndexN, posCellIndexT2, negCellIndexT2); - if( direction == 'z' ) getCellIndicesTY(faceIndex, dataBase, posCellIndexN, negCellIndexN, posCellIndexT2, negCellIndexT2); - - computeGradT( dataBase, parameters, posCellIndexT2, negCellIndexT2, facePrim, gradT2 ); - } -} - -} // namespace GksGpu - - - - - - -#endif \ No newline at end of file diff --git a/src/gpu/GksGpu/FluxComputation/Smagorinsky.cuh b/src/gpu/GksGpu/FluxComputation/Smagorinsky.cuh deleted file mode 100644 index 8a03ae722e62f338eed7672d362cf0aaa28d6d7a..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FluxComputation/Smagorinsky.cuh +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef Smagorinsky_CUH -#define Smagorinsky_CUH - -#include <cmath> - - -#include "GksGpu_export.h" - -#include "Core/DataTypes.h" -#include "Core/RealConstants.h" - -#include "Parameters/Parameters.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -namespace GksGpu { - -inline __host__ __device__ real getTurbulentViscositySmagorinsky(const Parameters & parameters, - const PrimitiveVariables& facePrim, - const ConservedVariables gradX1, - const ConservedVariables gradX2, - const ConservedVariables gradX3 ) -{ - // See FDS 6 Technical Reference Guide, Section 4.2.8 - - real dUdx1 = ( gradX1.rhoU - facePrim.U * gradX1.rho )/* / facePrim.rho*/; - real dUdx2 = ( gradX2.rhoU - facePrim.U * gradX2.rho )/* / facePrim.rho*/; - real dUdx3 = ( gradX3.rhoU - facePrim.U * gradX3.rho )/* / facePrim.rho*/; - real dVdx1 = ( gradX1.rhoV - facePrim.V * gradX1.rho )/* / facePrim.rho*/; - real dVdx2 = ( gradX2.rhoV - facePrim.V * gradX2.rho )/* / facePrim.rho*/; - real dVdx3 = ( gradX3.rhoV - facePrim.V * gradX3.rho )/* / facePrim.rho*/; - real dWdx1 = ( gradX1.rhoW - facePrim.W * gradX1.rho )/* / facePrim.rho*/; - real dWdx2 = ( gradX2.rhoW - facePrim.W * gradX2.rho )/* / facePrim.rho*/; - real dWdx3 = ( gradX3.rhoW - facePrim.W * gradX3.rho )/* / facePrim.rho*/; - - real S11sq = dUdx1*dUdx1; - real S22sq = dVdx2*dVdx2; - real S33sq = dWdx3*dWdx3; - - real S12sq = c1o4 * ( dUdx2 + dVdx1 ) * ( dUdx2 + dVdx1 ); - real S13sq = c1o4 * ( dUdx3 + dWdx1 ) * ( dUdx3 + dWdx1 ); - real S23sq = c1o4 * ( dVdx3 + dWdx2 ) * ( dVdx3 + dWdx2 ); - - real divergence = dUdx1 + dVdx2 + dWdx3; - - real S = sqrt( c2o1 * ( S11sq + S22sq + S33sq + c2o1 * ( S12sq + S13sq + S23sq ) ) - c2o3 * divergence * divergence ); - - real Cs = parameters.smagorinskyConstant; - - return facePrim.rho * Cs*Cs * parameters.dx*parameters.dx * S; -} - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/FluxComputation/SutherlandsLaw.cuh b/src/gpu/GksGpu/FluxComputation/SutherlandsLaw.cuh deleted file mode 100644 index 5af3ca3889fc73f4230bdcfb18a7cf13a3c0d82b..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FluxComputation/SutherlandsLaw.cuh +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef SutherlandsLaw_CUH -#define SutherlandsLaw_CUH - -#include <cmath> - - -#include "GksGpu_export.h" - -#include "Core/DataTypes.h" -#include "Core/RealConstants.h" - -#include "Parameters/Parameters.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -namespace GksGpu { - -inline __host__ __device__ real sutherlandsLaw(Parameters & parameters, const real r) -{ - real S = real( 110.5 ); - - real T0 = real( 600.0 ); - - real C = S / T0; - - return parameters.mu * sqrt( r * r * r ) * ( C + c1o1 ) / ( r + C ); -} - -inline __host__ __device__ real sutherlandsLaw2(Parameters & parameters, const real r) -{ - real Smu = real( 0.648 ); - - real Sk = real( 0.368 ); - - parameters.Pr *= ( ( Smu + c1o1 ) / ( Sk + c1o1 ) ) * ( ( r + Sk ) / ( r + Smu ) ); - - return parameters.mu * sqrt( r * r * r ) * ( Smu + c1o1 ) / ( r + Smu ); -} - -inline __host__ __device__ real getViscosity(Parameters & parameters, const real r) -{ - if ( parameters.viscosityModel == ViscosityModel::sutherlandsLaw ){ - return sutherlandsLaw( parameters, r ); - } - else if ( parameters.viscosityModel == ViscosityModel::sutherlandsLaw2 ){ - return sutherlandsLaw2( parameters, r ); - } - - return parameters.mu; -} - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/FluxComputation/Transformation.cuh b/src/gpu/GksGpu/FluxComputation/Transformation.cuh deleted file mode 100644 index d8ffb91fab35c23b8925fc55f3531c4a83c53dbe..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/FluxComputation/Transformation.cuh +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef Transformation_CUH -#define Transformation_CUH - - -#include "GksGpu_export.h" - -#include "Core/DataTypes.h" - -#include "DataBase/DataBase.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -namespace GksGpu { - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void transformGlobalToLocal(Vec3& vector, const char direction) -{ - if( direction == 'x' ) return; - - if( direction == 'y' ) - { - Vec3 tmp = vector; - - vector.x = tmp.y; - vector.y = tmp.z; - vector.z = tmp.x; - - return; - } - - if( direction == 'z' ) - { - Vec3 tmp = vector; - - vector.x = tmp.z; - vector.y = tmp.x; - vector.z = tmp.y; - - return; - } -} - -__host__ __device__ inline void transformLocalToGlobal(Vec3& vector, const char direction) -{ - if( direction == 'x' ) return; - - if( direction == 'y' ) - { - Vec3 tmp; - - tmp.y = vector.x; - tmp.z = vector.y; - tmp.x = vector.z; - - vector = tmp; - - return; - } - - if( direction == 'z' ) - { - Vec3 tmp; - - tmp.z = vector.x; - tmp.x = vector.y; - tmp.y = vector.z; - - vector = tmp; - - return; - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void transformGlobalToLocal(ConservedVariables& cons, const char direction) -{ - Vec3 vector( cons.rhoU, cons.rhoV, cons.rhoW ); - - transformGlobalToLocal( vector, direction ); - - cons.rhoU = vector.x; - cons.rhoV = vector.y; - cons.rhoW = vector.z; -} - -__host__ __device__ inline void transformGlobalToLocal(PrimitiveVariables& prim, const char direction) -{ - Vec3 vector( prim.U, prim.V, prim.W ); - - transformGlobalToLocal( vector, direction ); - - prim.U = vector.x; - prim.V = vector.y; - prim.W = vector.z; -} - -////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void transformLocalToGlobal(ConservedVariables& cons, const char direction) -{ - Vec3 vector( cons.rhoU, cons.rhoV, cons.rhoW ); - - transformLocalToGlobal( vector, direction ); - - cons.rhoU = vector.x; - cons.rhoV = vector.y; - cons.rhoW = vector.z; -} - -__host__ __device__ inline void transformLocalToGlobal(PrimitiveVariables& prim, const char direction) -{ - Vec3 vector( prim.U, prim.V, prim.W ); - - transformLocalToGlobal( vector, direction ); - - prim.U = vector.x; - prim.V = vector.y; - prim.W = vector.z; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Initializer/Initializer.cpp b/src/gpu/GksGpu/Initializer/Initializer.cpp deleted file mode 100644 index f5c2cf535aefaa4e5662ae8dc588859ccebdc008..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Initializer/Initializer.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "Initializer.h" - -#include <sstream> -#define _USE_MATH_DEFINES -#include <math.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -namespace GksGpu { - -void Initializer::interpret(SPtr<DataBase> dataBase, std::function<ConservedVariables(Vec3)> initialCondition) -{ - for( uint cellIdx = 0; cellIdx < dataBase->numberOfCells; cellIdx++ ){ - - Vec3 cellCenter = dataBase->getCellCenter( cellIdx ); - - ConservedVariables cellCons = initialCondition(cellCenter); - - dataBase->dataHost[ RHO__(cellIdx, dataBase->numberOfCells) ] = cellCons.rho ; - dataBase->dataHost[ RHO_U(cellIdx, dataBase->numberOfCells) ] = cellCons.rhoU; - dataBase->dataHost[ RHO_V(cellIdx, dataBase->numberOfCells) ] = cellCons.rhoV; - dataBase->dataHost[ RHO_W(cellIdx, dataBase->numberOfCells) ] = cellCons.rhoW; - dataBase->dataHost[ RHO_E(cellIdx, dataBase->numberOfCells) ] = cellCons.rhoE; - #ifdef USE_PASSIVE_SCALAR - dataBase->dataHost[ RHO_S_1(cellIdx, dataBase->numberOfCells) ] = cellCons.rhoS_1; - dataBase->dataHost[ RHO_S_2(cellIdx, dataBase->numberOfCells) ] = cellCons.rhoS_2; - #endif // USE_PASSIVE_SCALAR - } - - return; -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/Initializer/Initializer.h b/src/gpu/GksGpu/Initializer/Initializer.h deleted file mode 100644 index badac795fedf7bc6df82c6a34139c7c427c051aa..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Initializer/Initializer.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef Initializer_H -#define Initializer_H - -#include <string> -#include <memory> -#include <functional> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - -#include "DataBase/DataBase.h" -#include "FlowStateData/FlowStateData.cuh" - -namespace GksGpu { - -class GKSGPU_EXPORT Initializer -{ -public: - - static void interpret( SPtr<DataBase> dataBase, std::function<ConservedVariables(Vec3)> initialCondition ); - - static void initializeDataUpdate( SPtr<DataBase> dataBase ); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Initializer/InitializerKernel.cu b/src/gpu/GksGpu/Initializer/InitializerKernel.cu deleted file mode 100644 index 8b456e9be744b0d7999ff0d5e585c55460b7dbcf..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Initializer/InitializerKernel.cu +++ /dev/null @@ -1,69 +0,0 @@ -#include "Initializer.h" - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" - -#include "DataBase/DataBaseStruct.h" - -#include "Definitions/MemoryAccessPattern.h" -#include "Definitions/PassiveScalar.h" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu { - -__global__ void initializeDataUpdateKernel ( DataBaseStruct dataBase, uint numberOfEntities ); - -__host__ __device__ inline void initializeDataUpdateFunction( DataBaseStruct dataBase, uint index ); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void Initializer::initializeDataUpdate( SPtr<DataBase> dataBase ) -{ - CudaUtility::CudaGrid grid( dataBase->numberOfCells, 32 ); - - runKernel( initializeDataUpdateKernel, - initializeDataUpdateFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct() ); - - cudaDeviceSynchronize(); - - getLastCudaError("Initializer::initializeDataUpdate( SPtr<DataBase> dataBase )"); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__global__ void initializeDataUpdateKernel(DataBaseStruct dataBase, uint numberOfEntities) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - initializeDataUpdateFunction( dataBase, index ); -} - -__host__ __device__ inline void initializeDataUpdateFunction(DataBaseStruct dataBase, uint index) -{ - dataBase.dataUpdate[ RHO__(index, dataBase.numberOfCells) ] = c0o1; - dataBase.dataUpdate[ RHO_U(index, dataBase.numberOfCells) ] = c0o1; - dataBase.dataUpdate[ RHO_V(index, dataBase.numberOfCells) ] = c0o1; - dataBase.dataUpdate[ RHO_W(index, dataBase.numberOfCells) ] = c0o1; - dataBase.dataUpdate[ RHO_E(index, dataBase.numberOfCells) ] = c0o1; -#ifdef USE_PASSIVE_SCALAR - dataBase.dataUpdate[ RHO_S_1(index, dataBase.numberOfCells) ] = c0o1; - dataBase.dataUpdate[ RHO_S_2(index, dataBase.numberOfCells) ] = c0o1; -#endif // USE_PASSIVE_SCALAR - - dataBase.massFlux[ VEC_X(index, dataBase.numberOfCells) ] = c0o1; - dataBase.massFlux[ VEC_Y(index, dataBase.numberOfCells) ] = c0o1; - dataBase.massFlux[ VEC_Z(index, dataBase.numberOfCells) ] = c0o1; - - dataBase.diffusivity[ index ] = c1o1; -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/Interface/CoarseToFineKernel.cu b/src/gpu/GksGpu/Interface/CoarseToFineKernel.cu deleted file mode 100644 index d1451db3c2595fc65a9f052033822459bb07000e..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Interface/CoarseToFineKernel.cu +++ /dev/null @@ -1,427 +0,0 @@ -#include "Interface.h" - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" - -#include "DataBase/DataBaseStruct.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" - -#include "FlowStateData/AccessDeviceData.cuh" - -#include "Definitions/PassiveScalar.h" -#include "Definitions/MemoryAccessPattern.h" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu { - -////////////////////////////////////////////////////////////////////////// - -__global__ void coarseToFineKernel ( DataBaseStruct dataBase, uint startIndex, uint numberOfEntities ); - -__host__ __device__ inline void coarseToFineFunction ( DataBaseStruct dataBase, uint startIndex, uint index ); -__host__ __device__ inline void coarseToFineFunctionPrimitiveInterpolation( DataBaseStruct dataBase, uint startIndex, uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void Interface::runCoarseToFine( SPtr<DataBase> dataBase, uint level ) -{ - CudaUtility::CudaGrid grid(dataBase->perLevelCount[level].numberOfCoarseToFine, 128); - - runKernel(coarseToFineKernel, - coarseToFineFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - dataBase->perLevelCount[level].startOfCoarseToFine); - - cudaDeviceSynchronize(); - - getLastCudaError("void Interface::runCoarseToFine( SPtr<DataBase> dataBase, uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void coarseToFineKernel( DataBaseStruct dataBase, uint startIndex, uint numberOfEntities ) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - coarseToFineFunction( dataBase, startIndex, index ); - //coarseToFineFunctionPrimitiveInterpolation( dataBase, startIndex, index ); -} - -//__host__ __device__ inline void coarseToFineFunction( DataBaseStruct dataBase, uint startIndex, uint index ) -//{ -// index += startIndex; -// -// uint cellIndex = dataBase.coarseToFine[ COARSE_TO_FINE( index, 0, dataBase.numberOfFineGhostCells ) ]; -// -// uint cellToCell [6]; -// -// cellToCell[0] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 0, dataBase.numberOfCells ) ]; -// cellToCell[1] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 1, dataBase.numberOfCells ) ]; -// cellToCell[2] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 2, dataBase.numberOfCells ) ]; -// cellToCell[3] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 3, dataBase.numberOfCells ) ]; -// cellToCell[4] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 4, dataBase.numberOfCells ) ]; -// cellToCell[5] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 5, dataBase.numberOfCells ) ]; -// -// ConservedVariables childCons [8]; -// -// { -// real data [7]; -// -// data[0] = dataBase.data[ RHO__(cellToCell[0], dataBase.numberOfCells) ]; -// data[1] = dataBase.data[ RHO__(cellToCell[1], dataBase.numberOfCells) ]; -// data[2] = dataBase.data[ RHO__(cellToCell[2], dataBase.numberOfCells) ]; -// data[3] = dataBase.data[ RHO__(cellToCell[3], dataBase.numberOfCells) ]; -// data[4] = dataBase.data[ RHO__(cellToCell[4], dataBase.numberOfCells) ]; -// data[5] = dataBase.data[ RHO__(cellToCell[5], dataBase.numberOfCells) ]; -// data[6] = dataBase.data[ RHO__(cellIndex , dataBase.numberOfCells) ]; -// -// // PX PY PZ MX MY MZ -// childCons[0].rho = data[6] + c1o8 * ( + data[0] + data[2] + data[4] - data[1] - data[3] - data[5] ); // PX PY PZ -// childCons[1].rho = data[6] + c1o8 * ( + data[0] + data[2] - data[4] - data[1] - data[3] + data[5] ); // PX PY MZ -// childCons[2].rho = data[6] + c1o8 * ( + data[0] - data[2] + data[4] - data[1] + data[3] - data[5] ); // PX MY PZ -// childCons[3].rho = data[6] + c1o8 * ( + data[0] - data[2] - data[4] - data[1] + data[3] + data[5] ); // PX MY MZ -// childCons[4].rho = data[6] + c1o8 * ( - data[0] + data[2] + data[4] + data[1] - data[3] - data[5] ); // MX PY PZ -// childCons[5].rho = data[6] + c1o8 * ( - data[0] + data[2] - data[4] + data[1] - data[3] + data[5] ); // MX PY MZ -// childCons[6].rho = data[6] + c1o8 * ( - data[0] - data[2] + data[4] + data[1] + data[3] - data[5] ); // MX MY PZ -// childCons[7].rho = data[6] + c1o8 * ( - data[0] - data[2] - data[4] + data[1] + data[3] + data[5] ); // MX MY MZ -// } -// -// { -// real data [7]; -// -// data[0] = dataBase.data[ RHO_U(cellToCell[0], dataBase.numberOfCells) ]; -// data[1] = dataBase.data[ RHO_U(cellToCell[1], dataBase.numberOfCells) ]; -// data[2] = dataBase.data[ RHO_U(cellToCell[2], dataBase.numberOfCells) ]; -// data[3] = dataBase.data[ RHO_U(cellToCell[3], dataBase.numberOfCells) ]; -// data[4] = dataBase.data[ RHO_U(cellToCell[4], dataBase.numberOfCells) ]; -// data[5] = dataBase.data[ RHO_U(cellToCell[5], dataBase.numberOfCells) ]; -// data[6] = dataBase.data[ RHO_U(cellIndex , dataBase.numberOfCells) ]; -// -// // PX PY PZ MX MY MZ -// childCons[0].rhoU = data[6] + c1o8 * ( + data[0] + data[2] + data[4] - data[1] - data[3] - data[5] ); // PX PY PZ -// childCons[1].rhoU = data[6] + c1o8 * ( + data[0] + data[2] - data[4] - data[1] - data[3] + data[5] ); // PX PY MZ -// childCons[2].rhoU = data[6] + c1o8 * ( + data[0] - data[2] + data[4] - data[1] + data[3] - data[5] ); // PX MY PZ -// childCons[3].rhoU = data[6] + c1o8 * ( + data[0] - data[2] - data[4] - data[1] + data[3] + data[5] ); // PX MY MZ -// childCons[4].rhoU = data[6] + c1o8 * ( - data[0] + data[2] + data[4] + data[1] - data[3] - data[5] ); // MX PY PZ -// childCons[5].rhoU = data[6] + c1o8 * ( - data[0] + data[2] - data[4] + data[1] - data[3] + data[5] ); // MX PY MZ -// childCons[6].rhoU = data[6] + c1o8 * ( - data[0] - data[2] + data[4] + data[1] + data[3] - data[5] ); // MX MY PZ -// childCons[7].rhoU = data[6] + c1o8 * ( - data[0] - data[2] - data[4] + data[1] + data[3] + data[5] ); // MX MY MZ -// } -// -// { -// real data [7]; -// -// data[0] = dataBase.data[ RHO_V(cellToCell[0], dataBase.numberOfCells) ]; -// data[1] = dataBase.data[ RHO_V(cellToCell[1], dataBase.numberOfCells) ]; -// data[2] = dataBase.data[ RHO_V(cellToCell[2], dataBase.numberOfCells) ]; -// data[3] = dataBase.data[ RHO_V(cellToCell[3], dataBase.numberOfCells) ]; -// data[4] = dataBase.data[ RHO_V(cellToCell[4], dataBase.numberOfCells) ]; -// data[5] = dataBase.data[ RHO_V(cellToCell[5], dataBase.numberOfCells) ]; -// data[6] = dataBase.data[ RHO_V(cellIndex , dataBase.numberOfCells) ]; -// -// // PX PY PZ MX MY MZ -// childCons[0].rhoV = data[6] + c1o8 * ( + data[0] + data[2] + data[4] - data[1] - data[3] - data[5] ); // PX PY PZ -// childCons[1].rhoV = data[6] + c1o8 * ( + data[0] + data[2] - data[4] - data[1] - data[3] + data[5] ); // PX PY MZ -// childCons[2].rhoV = data[6] + c1o8 * ( + data[0] - data[2] + data[4] - data[1] + data[3] - data[5] ); // PX MY PZ -// childCons[3].rhoV = data[6] + c1o8 * ( + data[0] - data[2] - data[4] - data[1] + data[3] + data[5] ); // PX MY MZ -// childCons[4].rhoV = data[6] + c1o8 * ( - data[0] + data[2] + data[4] + data[1] - data[3] - data[5] ); // MX PY PZ -// childCons[5].rhoV = data[6] + c1o8 * ( - data[0] + data[2] - data[4] + data[1] - data[3] + data[5] ); // MX PY MZ -// childCons[6].rhoV = data[6] + c1o8 * ( - data[0] - data[2] + data[4] + data[1] + data[3] - data[5] ); // MX MY PZ -// childCons[7].rhoV = data[6] + c1o8 * ( - data[0] - data[2] - data[4] + data[1] + data[3] + data[5] ); // MX MY MZ -// } -// -// { -// real data [7]; -// -// data[0] = dataBase.data[ RHO_W(cellToCell[0], dataBase.numberOfCells) ]; -// data[1] = dataBase.data[ RHO_W(cellToCell[1], dataBase.numberOfCells) ]; -// data[2] = dataBase.data[ RHO_W(cellToCell[2], dataBase.numberOfCells) ]; -// data[3] = dataBase.data[ RHO_W(cellToCell[3], dataBase.numberOfCells) ]; -// data[4] = dataBase.data[ RHO_W(cellToCell[4], dataBase.numberOfCells) ]; -// data[5] = dataBase.data[ RHO_W(cellToCell[5], dataBase.numberOfCells) ]; -// data[6] = dataBase.data[ RHO_W(cellIndex , dataBase.numberOfCells) ]; -// -// // PX PY PZ MX MY MZ -// childCons[0].rhoW = data[6] + c1o8 * ( + data[0] + data[2] + data[4] - data[1] - data[3] - data[5] ); // PX PY PZ -// childCons[1].rhoW = data[6] + c1o8 * ( + data[0] + data[2] - data[4] - data[1] - data[3] + data[5] ); // PX PY MZ -// childCons[2].rhoW = data[6] + c1o8 * ( + data[0] - data[2] + data[4] - data[1] + data[3] - data[5] ); // PX MY PZ -// childCons[3].rhoW = data[6] + c1o8 * ( + data[0] - data[2] - data[4] - data[1] + data[3] + data[5] ); // PX MY MZ -// childCons[4].rhoW = data[6] + c1o8 * ( - data[0] + data[2] + data[4] + data[1] - data[3] - data[5] ); // MX PY PZ -// childCons[5].rhoW = data[6] + c1o8 * ( - data[0] + data[2] - data[4] + data[1] - data[3] + data[5] ); // MX PY MZ -// childCons[6].rhoW = data[6] + c1o8 * ( - data[0] - data[2] + data[4] + data[1] + data[3] - data[5] ); // MX MY PZ -// childCons[7].rhoW = data[6] + c1o8 * ( - data[0] - data[2] - data[4] + data[1] + data[3] + data[5] ); // MX MY MZ -// } -// -// { -// real data [7]; -// -// data[0] = dataBase.data[ RHO_E(cellToCell[0], dataBase.numberOfCells) ]; -// data[1] = dataBase.data[ RHO_E(cellToCell[1], dataBase.numberOfCells) ]; -// data[2] = dataBase.data[ RHO_E(cellToCell[2], dataBase.numberOfCells) ]; -// data[3] = dataBase.data[ RHO_E(cellToCell[3], dataBase.numberOfCells) ]; -// data[4] = dataBase.data[ RHO_E(cellToCell[4], dataBase.numberOfCells) ]; -// data[5] = dataBase.data[ RHO_E(cellToCell[5], dataBase.numberOfCells) ]; -// data[6] = dataBase.data[ RHO_E(cellIndex , dataBase.numberOfCells) ]; -// -// // PX PY PZ MX MY MZ -// childCons[0].rhoE = data[6] + c1o8 * ( + data[0] + data[2] + data[4] - data[1] - data[3] - data[5] ); // PX PY PZ -// childCons[1].rhoE = data[6] + c1o8 * ( + data[0] + data[2] - data[4] - data[1] - data[3] + data[5] ); // PX PY MZ -// childCons[2].rhoE = data[6] + c1o8 * ( + data[0] - data[2] + data[4] - data[1] + data[3] - data[5] ); // PX MY PZ -// childCons[3].rhoE = data[6] + c1o8 * ( + data[0] - data[2] - data[4] - data[1] + data[3] + data[5] ); // PX MY MZ -// childCons[4].rhoE = data[6] + c1o8 * ( - data[0] + data[2] + data[4] + data[1] - data[3] - data[5] ); // MX PY PZ -// childCons[5].rhoE = data[6] + c1o8 * ( - data[0] + data[2] - data[4] + data[1] - data[3] + data[5] ); // MX PY MZ -// childCons[6].rhoE = data[6] + c1o8 * ( - data[0] - data[2] + data[4] + data[1] + data[3] - data[5] ); // MX MY PZ -// childCons[7].rhoE = data[6] + c1o8 * ( - data[0] - data[2] - data[4] + data[1] + data[3] + data[5] ); // MX MY MZ -// } -// -// #ifdef USE_PASSIVE_SCALAR -// { -// { -// real data[7]; -// -// data[0] = dataBase.data[RHO_S_1(cellToCell[0], dataBase.numberOfCells)]; -// data[1] = dataBase.data[RHO_S_1(cellToCell[1], dataBase.numberOfCells)]; -// data[2] = dataBase.data[RHO_S_1(cellToCell[2], dataBase.numberOfCells)]; -// data[3] = dataBase.data[RHO_S_1(cellToCell[3], dataBase.numberOfCells)]; -// data[4] = dataBase.data[RHO_S_1(cellToCell[4], dataBase.numberOfCells)]; -// data[5] = dataBase.data[RHO_S_1(cellToCell[5], dataBase.numberOfCells)]; -// data[6] = dataBase.data[RHO_S_1(cellIndex, dataBase.numberOfCells)]; -// -// // PX PY PZ MX MY MZ -// childCons[0].rhoS_1 = data[6] + c1o8 * (+data[0] + data[2] + data[4] - data[1] - data[3] - data[5]); // PX PY PZ -// childCons[1].rhoS_1 = data[6] + c1o8 * (+data[0] + data[2] - data[4] - data[1] - data[3] + data[5]); // PX PY MZ -// childCons[2].rhoS_1 = data[6] + c1o8 * (+data[0] - data[2] + data[4] - data[1] + data[3] - data[5]); // PX MY PZ -// childCons[3].rhoS_1 = data[6] + c1o8 * (+data[0] - data[2] - data[4] - data[1] + data[3] + data[5]); // PX MY MZ -// childCons[4].rhoS_1 = data[6] + c1o8 * (-data[0] + data[2] + data[4] + data[1] - data[3] - data[5]); // MX PY PZ -// childCons[5].rhoS_1 = data[6] + c1o8 * (-data[0] + data[2] - data[4] + data[1] - data[3] + data[5]); // MX PY MZ -// childCons[6].rhoS_1 = data[6] + c1o8 * (-data[0] - data[2] + data[4] + data[1] + data[3] - data[5]); // MX MY PZ -// childCons[7].rhoS_1 = data[6] + c1o8 * (-data[0] - data[2] - data[4] + data[1] + data[3] + data[5]); // MX MY MZ -// } -// -// { -// real data[7]; -// -// data[0] = dataBase.data[RHO_S_2(cellToCell[0], dataBase.numberOfCells)]; -// data[1] = dataBase.data[RHO_S_2(cellToCell[1], dataBase.numberOfCells)]; -// data[2] = dataBase.data[RHO_S_2(cellToCell[2], dataBase.numberOfCells)]; -// data[3] = dataBase.data[RHO_S_2(cellToCell[3], dataBase.numberOfCells)]; -// data[4] = dataBase.data[RHO_S_2(cellToCell[4], dataBase.numberOfCells)]; -// data[5] = dataBase.data[RHO_S_2(cellToCell[5], dataBase.numberOfCells)]; -// data[6] = dataBase.data[RHO_S_2(cellIndex, dataBase.numberOfCells)]; -// -// // PX PY PZ MX MY MZ -// childCons[0].rhoS_2 = data[6] + c1o8 * (+data[0] + data[2] + data[4] - data[1] - data[3] - data[5]); // PX PY PZ -// childCons[1].rhoS_2 = data[6] + c1o8 * (+data[0] + data[2] - data[4] - data[1] - data[3] + data[5]); // PX PY MZ -// childCons[2].rhoS_2 = data[6] + c1o8 * (+data[0] - data[2] + data[4] - data[1] + data[3] - data[5]); // PX MY PZ -// childCons[3].rhoS_2 = data[6] + c1o8 * (+data[0] - data[2] - data[4] - data[1] + data[3] + data[5]); // PX MY MZ -// childCons[4].rhoS_2 = data[6] + c1o8 * (-data[0] + data[2] + data[4] + data[1] - data[3] - data[5]); // MX PY PZ -// childCons[5].rhoS_2 = data[6] + c1o8 * (-data[0] + data[2] - data[4] + data[1] - data[3] + data[5]); // MX PY MZ -// childCons[6].rhoS_2 = data[6] + c1o8 * (-data[0] - data[2] + data[4] + data[1] + data[3] - data[5]); // MX MY PZ -// childCons[7].rhoS_2 = data[6] + c1o8 * (-data[0] - data[2] - data[4] + data[1] + data[3] + data[5]); // MX MY MZ -// } -// } -// #endif // USE_PASSIVE_SCALAR -// -//#pragma unroll -// for( uint childIndex = 0; childIndex < 8; childIndex++ ){ -// -// uint childCellIndex = dataBase.coarseToFine[ COARSE_TO_FINE( index, ( 1 + childIndex ), dataBase.numberOfFineGhostCells ) ]; -// -// dataBase.data[ RHO__(childCellIndex, dataBase.numberOfCells) ] = childCons[childIndex].rho ; -// dataBase.data[ RHO_U(childCellIndex, dataBase.numberOfCells) ] = childCons[childIndex].rhoU; -// dataBase.data[ RHO_V(childCellIndex, dataBase.numberOfCells) ] = childCons[childIndex].rhoV; -// dataBase.data[ RHO_W(childCellIndex, dataBase.numberOfCells) ] = childCons[childIndex].rhoW; -// dataBase.data[ RHO_E(childCellIndex, dataBase.numberOfCells) ] = childCons[childIndex].rhoE; -// #ifdef USE_PASSIVE_SCALAR -// dataBase.data[ RHO_S_1(childCellIndex, dataBase.numberOfCells) ] = childCons[childIndex].rhoS_1; -// dataBase.data[ RHO_S_2(childCellIndex, dataBase.numberOfCells) ] = childCons[childIndex].rhoS_2; -// #endif // USE_PASSIVE_SCALAR -// } -//} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -__host__ __device__ inline void coarseToFineFunction( DataBaseStruct dataBase, uint startIndex, uint index ) -{ - index += startIndex; - - uint cellIndex = dataBase.coarseToFine[ COARSE_TO_FINE( index, 0, dataBase.numberOfFineGhostCells ) ]; - - uint cellToCell [6]; - - cellToCell[0] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 0, dataBase.numberOfCells ) ]; - cellToCell[1] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 1, dataBase.numberOfCells ) ]; - cellToCell[2] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 2, dataBase.numberOfCells ) ]; - cellToCell[3] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 3, dataBase.numberOfCells ) ]; - cellToCell[4] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 4, dataBase.numberOfCells ) ]; - cellToCell[5] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 5, dataBase.numberOfCells ) ]; - - ConservedVariables cons[7]; - - readCellData(cellToCell[0], dataBase, cons[0]); - readCellData(cellToCell[1], dataBase, cons[1]); - readCellData(cellToCell[2], dataBase, cons[2]); - readCellData(cellToCell[3], dataBase, cons[3]); - readCellData(cellToCell[4], dataBase, cons[4]); - readCellData(cellToCell[5], dataBase, cons[5]); - readCellData(cellIndex, dataBase, cons[6]); - - ConservedVariables childCons [8]; - ConservedVariables zeroCons; - - // PX PY PZ MX MY MZ - childCons[0] = cons[6] + c1o8 * ( zeroCons + cons[0] + cons[2] + cons[4] - cons[1] - cons[3] - cons[5] ); // PX PY PZ - childCons[1] = cons[6] + c1o8 * ( zeroCons + cons[0] + cons[2] - cons[4] - cons[1] - cons[3] + cons[5] ); // PX PY MZ - childCons[2] = cons[6] + c1o8 * ( zeroCons + cons[0] - cons[2] + cons[4] - cons[1] + cons[3] - cons[5] ); // PX MY PZ - childCons[3] = cons[6] + c1o8 * ( zeroCons + cons[0] - cons[2] - cons[4] - cons[1] + cons[3] + cons[5] ); // PX MY MZ - childCons[4] = cons[6] + c1o8 * ( zeroCons - cons[0] + cons[2] + cons[4] + cons[1] - cons[3] - cons[5] ); // MX PY PZ - childCons[5] = cons[6] + c1o8 * ( zeroCons - cons[0] + cons[2] - cons[4] + cons[1] - cons[3] + cons[5] ); // MX PY MZ - childCons[6] = cons[6] + c1o8 * ( zeroCons - cons[0] - cons[2] + cons[4] + cons[1] + cons[3] - cons[5] ); // MX MY PZ - childCons[7] = cons[6] + c1o8 * ( zeroCons - cons[0] - cons[2] - cons[4] + cons[1] + cons[3] + cons[5] ); // MX MY MZ - -#ifdef USE_PASSIVE_SCALAR - ConservedVariables min( 1.0e99, 1.0e99, 1.0e99, 1.0e99, 1.0e99, 1.0e99, 1.0e99 ); - ConservedVariables max( -1.0e99, -1.0e99, -1.0e99, -1.0e99, -1.0e99, -1.0e99, -1.0e99 ); -#else - ConservedVariables min( 1.0e99, 1.0e99, 1.0e99, 1.0e99, 1.0e99 ); - ConservedVariables max( -1.0e99, -1.0e99, -1.0e99, -1.0e99, -1.0e99 ); -#endif - - for( uint index = 0; index < 7; index++ ) - { - if( cons[ index ].rho < min.rho ) min.rho = cons[ index ].rho ; - if( cons[ index ].rhoU < min.rhoU ) min.rhoU = cons[ index ].rhoU ; - if( cons[ index ].rhoV < min.rhoV ) min.rhoV = cons[ index ].rhoV ; - if( cons[ index ].rhoW < min.rhoW ) min.rhoW = cons[ index ].rhoW ; - if( cons[ index ].rhoE < min.rhoE ) min.rhoE = cons[ index ].rhoE ; - #ifdef USE_PASSIVE_SCALAR - if( cons[ index ].rhoS_1 < min.rhoS_1 ) min.rhoS_1 = cons[ index ].rhoS_1; - if( cons[ index ].rhoS_2 < min.rhoS_2 ) min.rhoS_2 = cons[ index ].rhoS_2; - #endif - - if( cons[ index ].rho > max.rho ) max.rho = cons[ index ].rho ; - if( cons[ index ].rhoU > max.rhoU ) max.rhoU = cons[ index ].rhoU ; - if( cons[ index ].rhoV > max.rhoV ) max.rhoV = cons[ index ].rhoV ; - if( cons[ index ].rhoW > max.rhoW ) max.rhoW = cons[ index ].rhoW ; - if( cons[ index ].rhoE > max.rhoE ) max.rhoE = cons[ index ].rhoE ; - #ifdef USE_PASSIVE_SCALAR - if( cons[ index ].rhoS_1 > max.rhoS_1 ) max.rhoS_1 = cons[ index ].rhoS_1; - if( cons[ index ].rhoS_2 > max.rhoS_2 ) max.rhoS_2 = cons[ index ].rhoS_2; - #endif - } - -#pragma unroll - for( uint index = 0; index < 8; index++ ) - { - if( childCons[ index ].rho < min.rho ) childCons[ index ].rho = min.rho ; - if( childCons[ index ].rhoU < min.rhoU ) childCons[ index ].rhoU = min.rhoU ; - if( childCons[ index ].rhoV < min.rhoV ) childCons[ index ].rhoV = min.rhoV ; - if( childCons[ index ].rhoW < min.rhoW ) childCons[ index ].rhoW = min.rhoW ; - if( childCons[ index ].rhoE < min.rhoE ) childCons[ index ].rhoE = min.rhoE ; - #ifdef USE_PASSIVE_SCALAR - if( childCons[ index ].rhoS_1 < min.rhoS_1 ) childCons[ index ].rhoS_1 = min.rhoS_1 ; - if( childCons[ index ].rhoS_2 < min.rhoS_2 ) childCons[ index ].rhoS_2 = min.rhoS_2 ; - #endif - - if( childCons[ index ].rho > max.rho ) childCons[ index ].rho = max.rho ; - if( childCons[ index ].rhoU > max.rhoU ) childCons[ index ].rhoU = max.rhoU ; - if( childCons[ index ].rhoV > max.rhoV ) childCons[ index ].rhoV = max.rhoV ; - if( childCons[ index ].rhoW > max.rhoW ) childCons[ index ].rhoW = max.rhoW ; - if( childCons[ index ].rhoE > max.rhoE ) childCons[ index ].rhoE = max.rhoE ; - #ifdef USE_PASSIVE_SCALAR - if( childCons[ index ].rhoS_1 > max.rhoS_1 ) childCons[ index ].rhoS_1 = max.rhoS_1 ; - if( childCons[ index ].rhoS_2 > max.rhoS_2 ) childCons[ index ].rhoS_2 = max.rhoS_2 ; - #endif - } - -#pragma unroll - for( uint childIndex = 0; childIndex < 8; childIndex++ ){ - - uint childCellIndex = dataBase.coarseToFine[ COARSE_TO_FINE( index, ( 1 + childIndex ), dataBase.numberOfFineGhostCells ) ]; - - writeCellData(childCellIndex, dataBase, childCons[childIndex]); - } -} - -__host__ __device__ inline void coarseToFineFunctionPrimitiveInterpolation( DataBaseStruct dataBase, uint startIndex, uint index ) -{ - index += startIndex; - - uint cellIndex = dataBase.coarseToFine[ COARSE_TO_FINE( index, 0, dataBase.numberOfFineGhostCells ) ]; - - uint cellToCell [6]; - - cellToCell[0] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 0, dataBase.numberOfCells ) ]; - cellToCell[1] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 1, dataBase.numberOfCells ) ]; - cellToCell[2] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 2, dataBase.numberOfCells ) ]; - cellToCell[3] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 3, dataBase.numberOfCells ) ]; - cellToCell[4] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 4, dataBase.numberOfCells ) ]; - cellToCell[5] = dataBase.cellToCell[ CELL_TO_CELL( cellIndex, 5, dataBase.numberOfCells ) ]; - - PrimitiveVariables prim [7]; - ConservedVariables cons[7]; - - readCellData(cellToCell[0], dataBase, cons[0]); - readCellData(cellToCell[1], dataBase, cons[1]); - readCellData(cellToCell[2], dataBase, cons[2]); - readCellData(cellToCell[3], dataBase, cons[3]); - readCellData(cellToCell[4], dataBase, cons[4]); - readCellData(cellToCell[5], dataBase, cons[5]); - readCellData(cellIndex, dataBase, cons[6]); - - prim[0] = toPrimitiveVariables(cons[0], c2o1); - prim[1] = toPrimitiveVariables(cons[1], c2o1); - prim[2] = toPrimitiveVariables(cons[2], c2o1); - prim[3] = toPrimitiveVariables(cons[3], c2o1); - prim[4] = toPrimitiveVariables(cons[4], c2o1); - prim[5] = toPrimitiveVariables(cons[5], c2o1); - prim[6] = toPrimitiveVariables(cons[6], c2o1); - - PrimitiveVariables childPrim [8]; - PrimitiveVariables zeroPrim; - - // PX PY PZ MX MY MZ - childPrim[0] = prim[6] + c1o8 * ( zeroPrim + prim[0] + prim[2] + prim[4] - prim[1] - prim[3] - prim[5] ); // PX PY PZ - childPrim[1] = prim[6] + c1o8 * ( zeroPrim + prim[0] + prim[2] - prim[4] - prim[1] - prim[3] + prim[5] ); // PX PY MZ - childPrim[2] = prim[6] + c1o8 * ( zeroPrim + prim[0] - prim[2] + prim[4] - prim[1] + prim[3] - prim[5] ); // PX MY PZ - childPrim[3] = prim[6] + c1o8 * ( zeroPrim + prim[0] - prim[2] - prim[4] - prim[1] + prim[3] + prim[5] ); // PX MY MZ - childPrim[4] = prim[6] + c1o8 * ( zeroPrim - prim[0] + prim[2] + prim[4] + prim[1] - prim[3] - prim[5] ); // MX PY PZ - childPrim[5] = prim[6] + c1o8 * ( zeroPrim - prim[0] + prim[2] - prim[4] + prim[1] - prim[3] + prim[5] ); // MX PY MZ - childPrim[6] = prim[6] + c1o8 * ( zeroPrim - prim[0] - prim[2] + prim[4] + prim[1] + prim[3] - prim[5] ); // MX MY PZ - childPrim[7] = prim[6] + c1o8 * ( zeroPrim - prim[0] - prim[2] - prim[4] + prim[1] + prim[3] + prim[5] ); // MX MY MZ - -#pragma unroll - for( uint childIndex = 0; childIndex < 8; childIndex++ ){ - - uint childCellIndex = dataBase.coarseToFine[ COARSE_TO_FINE( index, ( 1 + childIndex ), dataBase.numberOfFineGhostCells ) ]; - - ConservedVariables childCons = toConservedVariables(childPrim[childIndex], c2o1); - - writeCellData(childCellIndex, dataBase, childCons); - } -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/Interface/FineToCoarseKernel.cu b/src/gpu/GksGpu/Interface/FineToCoarseKernel.cu deleted file mode 100644 index e31fdb912d735669297027b4f15808869d17abf2..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Interface/FineToCoarseKernel.cu +++ /dev/null @@ -1,115 +0,0 @@ -#include "Interface.h" - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include "PointerDefinitions.h" - -#include "DataBase/DataBaseStruct.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" - -#include "FlowStateData/AccessDeviceData.cuh" - -#include "Definitions/PassiveScalar.h" -#include "Definitions/MemoryAccessPattern.h" - -#include "CudaUtility/CudaRunKernel.hpp" - -namespace GksGpu { - -////////////////////////////////////////////////////////////////////////// - -__global__ void fineToCoarseKernel ( DataBaseStruct dataBase, uint startIndex, uint numberOfEntities ); - -__host__ __device__ inline void fineToCoarseFunction ( DataBaseStruct dataBase, uint startIndex, uint index ); -__host__ __device__ inline void fineToCoarseFunctionPrimitiveInterpolation( DataBaseStruct dataBase, uint startIndex, uint index ); - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -void Interface::runFineToCoarse( SPtr<DataBase> dataBase, uint level ) -{ - CudaUtility::CudaGrid grid(dataBase->perLevelCount[level].numberOfFineToCoarse, 128); - - runKernel(fineToCoarseKernel, - fineToCoarseFunction, - dataBase->getDeviceType(), grid, - dataBase->toStruct(), - dataBase->perLevelCount[level].startOfFineToCoarse); - - cudaDeviceSynchronize(); - - getLastCudaError("Interface::runFineToCoarse( SPtr<DataBase> dataBase, uint level )"); -} - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// - -__global__ void fineToCoarseKernel( DataBaseStruct dataBase, uint startIndex, uint numberOfEntities ) -{ - uint index = blockIdx.x * blockDim.x + threadIdx.x; - - if( index >= numberOfEntities ) return; - - fineToCoarseFunction( dataBase, startIndex, index ); - //fineToCoarseFunctionPrimitiveInterpolation( dataBase, startIndex, index ); -} - -__host__ __device__ inline void fineToCoarseFunction( DataBaseStruct dataBase, uint startIndex, uint index ) -{ - index += startIndex; - - ConservedVariables parentCons; - -#pragma unroll - for( uint childIdx = 1; childIdx < LENGTH_FINE_TO_COARSE; childIdx++ ){ - - uint cellIdx = dataBase.fineToCoarse[ FINE_TO_COARSE( index, childIdx, dataBase.numberOfCoarseGhostCells ) ]; - - ConservedVariables cons; - - readCellData( cellIdx, dataBase, cons ); - - parentCons = parentCons + c1o8 * cons; - } - - { - uint cellIdx = dataBase.fineToCoarse[FINE_TO_COARSE(index, 0, dataBase.numberOfCoarseGhostCells)]; - - writeCellData(cellIdx, dataBase, parentCons); - } -} - -__host__ __device__ inline void fineToCoarseFunctionPrimitiveInterpolation( DataBaseStruct dataBase, uint startIndex, uint index ) -{ - index += startIndex; - - PrimitiveVariables parentPrim; - -#pragma unroll - for( uint childIdx = 1; childIdx < LENGTH_FINE_TO_COARSE; childIdx++ ){ - - uint cellIdx = dataBase.fineToCoarse[ FINE_TO_COARSE( index, childIdx, dataBase.numberOfCoarseGhostCells ) ]; - - ConservedVariables cons; - - readCellData( cellIdx, dataBase, cons ); - - parentPrim = parentPrim + c1o8 * toPrimitiveVariables(cons, c2o1); - } - - { - uint cellIdx = dataBase.fineToCoarse[FINE_TO_COARSE(index, 0, dataBase.numberOfCoarseGhostCells)]; - - ConservedVariables parentCons = toConservedVariables(parentPrim, c2o1); - - writeCellData(cellIdx, dataBase, parentCons); - } -} - -} // namespace GksGpu diff --git a/src/gpu/GksGpu/Interface/Interface.h b/src/gpu/GksGpu/Interface/Interface.h deleted file mode 100644 index 5aa99bd99db520818a18aa638c8061995b58aa6e..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Interface/Interface.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef FineToCoarse_H -#define FineToCoarse_H - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" - -#include "DataBase/DataBase.h" - -namespace GksGpu { - -class GKSGPU_EXPORT Interface -{ -public: - static void runFineToCoarse( SPtr<DataBase> dataBase, uint level ); - - static void runCoarseToFine( SPtr<DataBase> dataBase, uint level ); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Output/VtkWriter.cpp b/src/gpu/GksGpu/Output/VtkWriter.cpp deleted file mode 100644 index 234151c7df481e81e5dd68c9a4692831f7271f54..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Output/VtkWriter.cpp +++ /dev/null @@ -1,150 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file VtkWriter.cpp -//! \ingroup Output -//! \author Stephan Lenz -//======================================================================================= -#include "VtkWriter.h" - -#include <vector> -#include <memory> - -#include "Core/Logger/Logger.h" - -#include "basics/utilities/UbTuple.h" -#include "basics/writer/WbWriterVtkXmlBinary.h" - -#include "DataBase/DataBase.h" -#include "Parameters/Parameters.h" - -#include "FlowStateData/FlowStateData.cuh" -#include "FlowStateData/FlowStateDataConversion.cuh" -#include "FlowStateData/AccessDeviceData.cuh" - -namespace GksGpu { - -void VtkWriter::write(std::shared_ptr<DataBase> dataBase, Parameters parameters, std::string filename) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Write " << filename << ".vtu" << " ... \n"; - - ////////////////////////////////////////////////////////////////////////// - - std::vector< UbTupleFloat3 > nodes; - std::vector< UbTupleInt8 > cells; - - nodes.resize( dataBase->numberOfNodes ); - cells.resize( dataBase->numberOfCells ); - - for( uint nodeIdx = 0; nodeIdx < dataBase->numberOfNodes; nodeIdx++ ) - { - Vec3& node = dataBase->nodeCoordinates[ nodeIdx ]; - - nodes[nodeIdx] = makeUbTuple( node.x, node.y, node.z ); - } - - for( uint cellIdx = 0; cellIdx < dataBase->numberOfCells; cellIdx++ ) - { - cells[cellIdx] = makeUbTuple( (int)dataBase->cellToNode[ cellIdx ][ 0 ], - (int)dataBase->cellToNode[ cellIdx ][ 1 ], - (int)dataBase->cellToNode[ cellIdx ][ 2 ], - (int)dataBase->cellToNode[ cellIdx ][ 3 ], - (int)dataBase->cellToNode[ cellIdx ][ 4 ], - (int)dataBase->cellToNode[ cellIdx ][ 5 ], - (int)dataBase->cellToNode[ cellIdx ][ 6 ], - (int)dataBase->cellToNode[ cellIdx ][ 7 ] ); - } - - ////////////////////////////////////////////////////////////////////////// - - std::vector< std::string > cellDataNames; - cellDataNames.push_back("Press"); // 0 - cellDataNames.push_back("Rho"); // 1 - cellDataNames.push_back("Vx"); // 2 - cellDataNames.push_back("Vy"); // 3 - cellDataNames.push_back("Vz"); // 4 - cellDataNames.push_back("Temperature"); // 5 - cellDataNames.push_back("Geometry"); // 6 -#ifdef USE_PASSIVE_SCALAR - cellDataNames.push_back("S_1"); // 7 - cellDataNames.push_back("S_2"); // 8 -#endif - - ////////////////////////////////////////////////////////////////////////// - - std::vector< std::vector< double > > cellData(cellDataNames.size()); - - for( auto& i : cellData ) i.resize( dataBase->numberOfCells ); - - for( uint cellIdx = 0; cellIdx < dataBase->numberOfCells; cellIdx++ ) - { - ConservedVariables cons; - - cons.rho = dataBase->dataHost[ RHO__(cellIdx, dataBase->numberOfCells) ]; - cons.rhoU = dataBase->dataHost[ RHO_U(cellIdx, dataBase->numberOfCells) ]; - cons.rhoV = dataBase->dataHost[ RHO_V(cellIdx, dataBase->numberOfCells) ]; - cons.rhoW = dataBase->dataHost[ RHO_W(cellIdx, dataBase->numberOfCells) ]; - cons.rhoE = dataBase->dataHost[ RHO_E(cellIdx, dataBase->numberOfCells) ]; -#ifdef USE_PASSIVE_SCALAR - cons.rhoS_1 = dataBase->dataHost[ RHO_S_1(cellIdx, dataBase->numberOfCells) ]; - cons.rhoS_2 = dataBase->dataHost[ RHO_S_2(cellIdx, dataBase->numberOfCells) ]; -#endif // USE_PASSIVE_SCALAR - - PrimitiveVariables prim = toPrimitiveVariables(cons, parameters.K); - - real p = 0.5 * prim.rho / prim.lambda; - -#ifdef USE_PASSIVE_SCALAR - real T = getT(prim); -#else // USE_PASSIVE_SCALAR - real T = 1.0 / prim.lambda; -#endif // USE_PASSIVE_SCALAR - - cellData[0][cellIdx] = p; - cellData[1][cellIdx] = prim.rho; - cellData[2][cellIdx] = prim.U; - cellData[3][cellIdx] = prim.V; - cellData[4][cellIdx] = prim.W; - cellData[5][cellIdx] = T; - cellData[6][cellIdx] = dataBase->isGhostCell(cellIdx); -#ifdef USE_PASSIVE_SCALAR - cellData[7][cellIdx] = prim.S_1; - cellData[8][cellIdx] = prim.S_2; -#endif - } - - ////////////////////////////////////////////////////////////////////////// - - WbWriterVtkXmlBinary::getInstance()->writeOctsWithCellData(filename, nodes, cells, cellDataNames, cellData); - - ////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -} diff --git a/src/gpu/GksGpu/Output/VtkWriter.h b/src/gpu/GksGpu/Output/VtkWriter.h deleted file mode 100644 index 679fae55b2db5ec418b389ca0840961ab8f80dde..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Output/VtkWriter.h +++ /dev/null @@ -1,57 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file VtkWriter.h -//! \ingroup Output -//! \author Stephan Lenz -//======================================================================================= -#ifndef VTK_WRITER_H -#define VTK_WRITER_H - -#include <memory> -#include <string> - -#include "GksGpu_export.h" - -namespace GksGpu { - -struct DataBase; -struct Parameters; - - -class GKSGPU_EXPORT VtkWriter -{ -public: - static void write( std::shared_ptr<DataBase> dataBase, - Parameters parameters, - std::string filename ); -}; - -} - -#endif \ No newline at end of file diff --git a/src/gpu/GksGpu/Parameters/Parameters.h b/src/gpu/GksGpu/Parameters/Parameters.h deleted file mode 100644 index ab7bdb4c61909f3f08b2857e62b458d14d589280..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Parameters/Parameters.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef Parameters_H -#define Parameters_H - -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" - - -#include "GksGpu_export.h" - -namespace GksGpu { - -enum class GKSGPU_EXPORT ViscosityModel{ - constant, - sutherlandsLaw, - sutherlandsLaw2 -}; - -struct GKSGPU_EXPORT Parameters -{ - - real mu = real(0.01); - real K = real(2.0); - real Pr = real(1.0); - real D = real(0.01); - real D1 = real(0.01); - real D2 = real(0.01); - - real dt = real(0.01); - real dx = real(0.01); - - Vec3 force; - - real lambdaRef = real(1.0); - - real rhoRef = real(1.0); - - ViscosityModel viscosityModel = ViscosityModel::constant; - - real boussinesqT0 = real(1.0); - real boussinesqBeta = real(1.0); - - ////////////////////////////////////////////////////////////////////////// - - bool useSmagorinsky = false; - real smagorinskyConstant = real(0.2); - - ////////////////////////////////////////////////////////////////////////// - - bool useSpongeLayer = false; - uint spongeLayerIdx = 0; - - ////////////////////////////////////////////////////////////////////////// - - uint forcingSchemeIdx = 0; - - ////////////////////////////////////////////////////////////////////////// - - bool enableReaction = false; - - real heatOfReaction = real(8000.0); // kJ / kmol - - bool useHeatReleaseRateLimiter = false; - bool useTemperatureLimiter = false; - bool usePassiveScalarLimiter = false; - - real heatReleaseRateLimiter = real(20000.0); - real temperatureLimiter = real(1.0e-3); - real temperatureLimiterUpperLimit = real(1.0e-3); - real passiveScalarLimiter = real(0.1); - - // deprecated limiters - bool useReactionLimiter = false; - real reactionLimiter = real(1.005); -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksGpu/Restart/Restart.cpp b/src/gpu/GksGpu/Restart/Restart.cpp deleted file mode 100644 index 5f593c22662f2a6c471d59d432b8694d9bdefc6d..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Restart/Restart.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "Restart.h" - -#include <iostream> -#include <fstream> - -#include "PointerDefinitions.h" -#include "Core/RealConstants.h" -#include "Core/Logger/Logger.h" - -#include "DataBase/DataBase.h" - -#include "Definitions/MemoryAccessPattern.h" - -namespace GksGpu { - -void Restart::writeRestart( SPtr<DataBase> dataBase, std::string filename, uint iter ) -{ - filename += ".rst"; - - *logging::out << logging::Logger::INFO_HIGH << "Writing restart file " << filename << " ... "; - - std::ofstream file; - - file.open( filename.c_str(), std::ios::binary ); - - if (!file.is_open()) { - throw std::runtime_error("\nFile cannot be opened.\n\nERROR!\n\n\n"); - return; - } - - ////////////////////////////////////////////////////////////////////////// - - file.write( (char*) &iter, sizeof( uint ) ); - - file.write( (char*) &dataBase->numberOfLevels, sizeof( uint ) ); - file.write( (char*) &dataBase->numberOfCells, sizeof( uint ) ); - file.write( (char*) &dataBase->numberOfFaces, sizeof( uint ) ); - - file.write( (char*) dataBase->dataHost.data(), LENGTH_CELL_DATA * dataBase->numberOfCells * sizeof( real ) ); - - file.close(); - - *logging::out << logging::Logger::INFO_HIGH << "done!\n"; -} - -bool Restart::readRestart( SPtr<DataBase> dataBase, std::string filename, uint& iter ) -{ - filename += ".rst"; - - *logging::out << logging::Logger::INFO_HIGH << "Reading restart file " << filename << " ... "; - - std::ifstream file; - - file.open( filename.c_str(), std::ios::binary ); - - if (!file.is_open()) { - throw std::runtime_error("\nFile cannot be opened.\n\nERROR!\n\n\n"); - return false; - } - - ////////////////////////////////////////////////////////////////////////// - - file.read( (char*) &iter, sizeof( uint ) ); - - uint numberOfLevelsRead; - uint numberOfCellsRead; - uint numberOfFacesRead; - - file.read( (char*) &numberOfLevelsRead, sizeof( uint ) ); - file.read( (char*) &numberOfCellsRead, sizeof( uint ) ); - file.read( (char*) &numberOfFacesRead, sizeof( uint ) ); - - if( numberOfLevelsRead != dataBase->numberOfLevels || - numberOfCellsRead != dataBase->numberOfCells || - numberOfFacesRead != dataBase->numberOfFaces ){ - - *logging::out << logging::Logger::INFO_HIGH << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "Levels: " << numberOfLevelsRead << " vs. " << dataBase->numberOfLevels << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "Cells: " << numberOfCellsRead << " vs. " << dataBase->numberOfCells << "\n"; - *logging::out << logging::Logger::INFO_HIGH << "Faces: " << numberOfFacesRead << " vs. " << dataBase->numberOfFaces << "\n"; - - file.close(); - - throw std::runtime_error("\nERROR: Restart file does not match current setup"); - } - - file.read( (char*) dataBase->dataHost.data(), LENGTH_CELL_DATA * dataBase->numberOfCells * sizeof( real ) ); - - file.close(); - - *logging::out << logging::Logger::INFO_HIGH << "done!\n"; - - return true; -} - -} // namespace GksGpu \ No newline at end of file diff --git a/src/gpu/GksGpu/Restart/Restart.h b/src/gpu/GksGpu/Restart/Restart.h deleted file mode 100644 index 235a4334373be3f0b6c788ba5f89d226e5c77f17..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/Restart/Restart.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef Restart_h -#define Restart_h - -#include <string> -#include <memory> - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" - -namespace GksGpu { - -struct DataBase; - -class GKSGPU_EXPORT Restart -{ - -public: - static void writeRestart( SPtr<DataBase> dataBase, std::string filename, uint iter ); - - static bool readRestart ( SPtr<DataBase> dataBase, std::string filename, uint& iter ); - -private: - Restart(){} - ~Restart(){} -}; - -} // namespace GksGpu - - -#endif diff --git a/src/gpu/GksGpu/TimeStepping/NestedTimeStep.cpp b/src/gpu/GksGpu/TimeStepping/NestedTimeStep.cpp deleted file mode 100644 index 516349ff67bc9fa6618ab40aee32a94148633c5d..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/TimeStepping/NestedTimeStep.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "NestedTimeStep.h" - -#include <iostream> - -#include "Core/RealConstants.h" - -#include "BoundaryConditions/BoundaryCondition.h" -#include "Communication/Communicator.h" -#include "CellUpdate/CellUpdate.h" -#include "FluxComputation/FluxComputation.h" -#include "Interface/Interface.h" -#include "Initializer/Initializer.h" -#include "CudaUtility/CudaUtility.h" - -namespace GksGpu { - -void TimeStepping::nestedTimeStep( SPtr<DataBase> dataBase, - Parameters parameters, - uint level ) -{ - ////////////////////////////////////////////////////////////////////////// - - if( level != 0 ) parameters.dt /= c2o1; - if( level != 0 ) parameters.dx /= c2o1; - - ////////////////////////////////////////////////////////////////////////// - - if( level != dataBase->numberOfLevels - 1 ) - { - Interface::runFineToCoarse( dataBase, level ); - } - - ////////////////////////////////////////////////////////////////////////// - - for( SPtr<BoundaryCondition> bc : dataBase->boundaryConditions ) - { - bc->runBoundaryConditionKernel( dataBase, parameters, level ); - } - - ////////////////////////////////////////////////////////////////////////// - - CudaUtility::synchronizeCudaDevice(); - - ////////////////////////////////////////////////////////////////////////// - - FluxComputation::run( dataBase, parameters, level ); // comment out to disable commhiding - - ////////////////////////////////////////////////////////////////////////// - - if( !dataBase->communicators.empty() ) - { - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - if( dataBase->communicators[level][0] != nullptr ) dataBase->communicators[level][0]->sendData(dataBase, Communicator::tagSendNegative); - if( dataBase->communicators[level][1] != nullptr ) dataBase->communicators[level][1]->sendData(dataBase, Communicator::tagSendPositive); - - if( dataBase->communicators[level][0] != nullptr ) dataBase->communicators[level][0]->recvData(dataBase, Communicator::tagSendPositive); - if( dataBase->communicators[level][1] != nullptr ) dataBase->communicators[level][1]->recvData(dataBase, Communicator::tagSendNegative); - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - if( dataBase->communicators[level][2] != nullptr ) dataBase->communicators[level][2]->sendData(dataBase, Communicator::tagSendNegative); - if( dataBase->communicators[level][3] != nullptr ) dataBase->communicators[level][3]->sendData(dataBase, Communicator::tagSendPositive); - - if( dataBase->communicators[level][2] != nullptr ) dataBase->communicators[level][2]->recvData(dataBase, Communicator::tagSendPositive); - if( dataBase->communicators[level][3] != nullptr ) dataBase->communicators[level][3]->recvData(dataBase, Communicator::tagSendNegative); - ////////////////////////////////////////////////////////////////////////// - // Z - ////////////////////////////////////////////////////////////////////////// - if( dataBase->communicators[level][4] != nullptr ) dataBase->communicators[level][4]->sendData(dataBase, Communicator::tagSendNegative); - if( dataBase->communicators[level][5] != nullptr ) dataBase->communicators[level][5]->sendData(dataBase, Communicator::tagSendPositive); - - if( dataBase->communicators[level][4] != nullptr ) dataBase->communicators[level][4]->recvData(dataBase, Communicator::tagSendPositive); - if( dataBase->communicators[level][5] != nullptr ) dataBase->communicators[level][5]->recvData(dataBase, Communicator::tagSendNegative); - } - - ////////////////////////////////////////////////////////////////////////// - - FluxComputation::run( dataBase, parameters, level, true ); // comment out to disable commhiding - - //CudaUtility::synchronizeCudaDevice(); // comment in to disable commhiding - //FluxComputation::run( dataBase, parameters, level ); // comment in to disable commhiding - - ////////////////////////////////////////////////////////////////////////// - - CudaUtility::synchronizeCudaDevice(); - - ////////////////////////////////////////////////////////////////////////// - - if( level != dataBase->numberOfLevels - 1 ) - { - Interface::runCoarseToFine( dataBase, level ); - - nestedTimeStep( dataBase, parameters, level + 1 ); - nestedTimeStep( dataBase, parameters, level + 1 ); - } - - ////////////////////////////////////////////////////////////////////////// - - CellUpdate::run( dataBase, parameters, level ); - - ////////////////////////////////////////////////////////////////////////// -} - -} // namespace GksGpu - diff --git a/src/gpu/GksGpu/TimeStepping/NestedTimeStep.h b/src/gpu/GksGpu/TimeStepping/NestedTimeStep.h deleted file mode 100644 index 315db1778b79237cafa9f52ba53b26065d5f97a5..0000000000000000000000000000000000000000 --- a/src/gpu/GksGpu/TimeStepping/NestedTimeStep.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef NestedTimeStep_H -#define NestedTimeStep_H - - -#include "GksGpu_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" - -#include "DataBase/DataBase.h" -#include "Parameters/Parameters.h" -namespace GksGpu{ - -class GKSGPU_EXPORT TimeStepping -{ -public: - - static void nestedTimeStep( SPtr<DataBase> dataBase, - Parameters parameters, - uint level ); - -}; - -} // namespace GksGpu - -#endif diff --git a/src/gpu/GksMeshAdapter/CMakeLists.txt b/src/gpu/GksMeshAdapter/CMakeLists.txt deleted file mode 100644 index 8ac5e69513eca94710797db1f971b2461336b769..0000000000000000000000000000000000000000 --- a/src/gpu/GksMeshAdapter/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -project(GksMeshAdapter LANGUAGES CUDA CXX) - -vf_add_library(PRIVATE_LINK basics GridGenerator lbm) diff --git a/src/gpu/GksMeshAdapter/GksMeshAdapter.cpp b/src/gpu/GksMeshAdapter/GksMeshAdapter.cpp deleted file mode 100644 index ca6b223c90859656231360142b08d543b019b7ad..0000000000000000000000000000000000000000 --- a/src/gpu/GksMeshAdapter/GksMeshAdapter.cpp +++ /dev/null @@ -1,1328 +0,0 @@ -#include "GksMeshAdapter.h" - -#define _USE_MATH_DEFINES -#include <math.h> - -#include <fstream> -#include <algorithm> -#include <numeric> -#include <functional> -#include <iostream> -#include <iomanip> -#include <sstream> -#include <mpi.h> - -#include "Core/Logger/Logger.h" - -#include "GridGenerator/grid/distributions/D3Q27.h" -#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/NodeValues.h" -#include "GridGenerator/utilities/math/Math.h" - -#include "MeshCell.h" -#include "MeshFace.h" - -#include <lbm/constants/NumericConstants.h> - -using namespace vf::lbm::constant; - -using namespace vf::gpu; - -GksMeshAdapter::GksMeshAdapter(SPtr<MultipleGridBuilder> gridBuilder) - : gridBuilder(gridBuilder) -{} - -void GksMeshAdapter::inputGrid() -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "inputGrid()" << "\n"; - - this->numberOfLevels = this->gridBuilder->getNumberOfGridLevels(); - - std::vector< SPtr<Grid> > grids = this->gridBuilder->getGrids(); - - this->dxCoarse = grids[0]->getDelta(); - - ////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Allocate gridToMesh[][]" << "\n"; - - this->gridToMesh.resize( this->gridBuilder->getNumberOfGridLevels() ); - - for( uint level = 0; level < this->gridBuilder->getNumberOfGridLevels(); level++ ){ - this->gridToMesh[level].resize( grids[level]->getSize() ); - - for( auto& cellIdx : this->gridToMesh[level] ) cellIdx = INVALID_INDEX; - } - - ////////////////////////////////////////////////////////////////////////// - // - // I d e n t i f y C e l l s i n L B - G r i d - // - ////////////////////////////////////////////////////////////////////////// - - uint numberOfCells = 0; - - for( uint level = 0; level < this->gridBuilder->getNumberOfGridLevels(); level++ ){ - for( uint gridIdx = 0; gridIdx < grids[level]->getSize(); gridIdx++ ){ - if (grids[level]->getFieldEntry(gridIdx) != STOPPER_COARSE_UNDER_FINE && - //grids[level]->getFieldEntry(gridIdx) != STOPPER_SOLID && - grids[level]->getFieldEntry(gridIdx) != INVALID_COARSE_UNDER_FINE && - grids[level]->getFieldEntry(gridIdx) != INVALID_OUT_OF_GRID && - grids[level]->getFieldEntry(gridIdx) != INVALID_SOLID ) - { - this->gridToMesh[level][gridIdx] = numberOfCells++; - } - } - } - - ////////////////////////////////////////////////////////////////////////// - // - // S e t M e s h t o G r i d i n f o r m a t i o n - // - ////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Allocate " << numberOfCells << " cells" << "\n"; - - this->cells.resize( numberOfCells ); - - for( uint level = 0; level < this->gridBuilder->getNumberOfGridLevels(); level++ ){ - for( uint gridIdx = 0; gridIdx < grids[level]->getSize(); gridIdx++ ){ - if ( this->gridToMesh[level][gridIdx] != INVALID_INDEX ){ - - uint cellIdx = gridToMesh[level][gridIdx]; - - MeshCell& cell = this->cells[ cellIdx ]; - - cell.level = level; - cell.gridIdx = gridIdx; - - cell.type = grids[level]->getFieldEntry(gridIdx); - } - } - } - - ////////////////////////////////////////////////////////////////////////// - - this->findQuadtreeConnectivity(); - this->findCellToCellConnectivity(); - this->countCells(); - this->partitionCells(); - this->generateNodes(); - this->computeCellGeometry(); - - this->getCommunicationIndices(); - - this->generateFaces(); - this->sortFaces(); - this->countFaces(); - this->generateInterfaceConnectivity(); - - ////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "inputGrid() finished!" << "\n"; -} - -void GksMeshAdapter::findQuadtreeConnectivity() -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "findQuadtreeConnectivity()" << "\n"; - - std::vector< SPtr<Grid> > grids = this->gridBuilder->getGrids(); - - Distribution dirs = DistributionHelper::getDistribution27(); - - for( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - MeshCell& cell = this->cells[ cellIdx ]; - - if( cell.type == FLUID_FCC || cell.type == FLUID_CFC ){ - - real x, y, z; - grids[cell.level]->transIndexToCoords(cell.gridIdx, x, y, z); - - real d = 0.25 * grids[cell.level]->getDelta(); - - for( uint idx = 0; idx < 8; idx++ ) - { - - real xSign = dirs.directions[idx + 19][0]; - real ySign = dirs.directions[idx + 19][1]; - real zSign = dirs.directions[idx + 19][2]; - - cell.children[ idx ] = this->gridToMesh[cell.level+1][ grids[cell.level+1]->transCoordToIndex( x + xSign * d, - y + ySign * d, - z + zSign * d ) ]; - } - - // register parent - if( cell.type == FLUID_CFC ) - for (uint child = 0; child < 8; child++) - this->cells[cell.children[child]].parent = cellIdx; - - // set correct type for CFF cells - if( cell.type == FLUID_CFC ) - for( uint child = 0; child < 8; child++ ) - this->cells[ cell.children[child] ].type = FLUID_CFF; - - } - } -} - -void GksMeshAdapter::findCellToCellConnectivity() -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "findCellToCellConnectivity()" << "\n"; - - std::vector< SPtr<Grid> > grids = this->gridBuilder->getGrids(); - - Distribution dirs = DistributionHelper::getDistribution27(); - - for( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - MeshCell& cell = this->cells[ cellIdx ]; - - real x, y, z; - grids[cell.level]->transIndexToCoords(cell.gridIdx, x, y, z); - - real d = grids[cell.level]->getDelta(); - - for( uint idx = 0; idx < 27; idx++ ) - { - if( idx == DIR_27_REST ) continue; - - int xSign = dirs.directions[idx][0]; - int ySign = dirs.directions[idx][1]; - int zSign = dirs.directions[idx][2]; - - uint neighborGridIdx = grids[cell.level]->transCoordToIndex( x + xSign * d, - y + ySign * d, - z + zSign * d ); - - if( neighborGridIdx == INVALID_INDEX || this->gridToMesh[cell.level][neighborGridIdx] == INVALID_INDEX ){ - if( !cell.isCoarseGhostCell() && cell.type != BC_SOLID ) - cell.isGhostCell = true; - - continue; - } - - cell.cellToCell[ idx ] = this->gridToMesh[cell.level][neighborGridIdx]; - } - } -} - -void GksMeshAdapter::countCells() -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "countCells()" << "\n"; - - this->numberOfCellsPerLevel .resize( this->numberOfLevels ); - this->numberOfBulkCellsPerLevel.resize( this->numberOfLevels ); - this->startOfCellsPerLevel .resize( this->numberOfLevels ); - - for( auto& i : this->numberOfCellsPerLevel ) i = 0; - for( auto& i : this->numberOfBulkCellsPerLevel ) i = 0; - for( auto& i : this->startOfCellsPerLevel ) i = 0; - - uint level = 0; - for( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - MeshCell& cell = this->cells[ cellIdx ]; - - if( cell.level != level ) level++; - - this->numberOfCellsPerLevel[ level ]++; - - if( ! ( cell.isGhostCell || cell.isCoarseGhostCell() ) ) - this->numberOfBulkCellsPerLevel[ level ]++; - } - - for( uint level = 1; level < this->numberOfLevels; level++ ) - this->startOfCellsPerLevel[ level ] = this->startOfCellsPerLevel[ level-1 ] + this->numberOfCellsPerLevel[ level-1 ]; -} - -void GksMeshAdapter::partitionCells() -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "partitionCells()" << "\n"; - - for( uint level = 0; level < this->numberOfLevels; level++ ){ - - std::vector<uint> idxMap( this->cells.size() ); - std::iota( idxMap.begin(), idxMap.end(), 0 ); - - // partition idxMap - std::stable_partition( idxMap.begin() + this->startOfCellsPerLevel[level], - idxMap.begin() + this->startOfCellsPerLevel[level] - + this->numberOfCellsPerLevel[level], - [this](int lhs){ - return ! ( this->cells[ lhs ].isGhostCell || this->cells[ lhs ].isCoarseGhostCell() ); - } - ); - - // invert idxMap - { - std::vector<uint> buffer = idxMap; - for( uint idx = 0; idx < idxMap.size(); idx ++ ) - idxMap[ buffer[idx] ] = idx; - } - - // partition cell list - std::stable_partition( this->cells.begin() + this->startOfCellsPerLevel[level], - this->cells.begin() + this->startOfCellsPerLevel[level] - + this->numberOfCellsPerLevel[level], - [this](MeshCell lhs){ - return ! ( lhs.isGhostCell || lhs.isCoarseGhostCell() ); - } - ); - - this->refreshCellConnectivity( idxMap ); - } -} - -void GksMeshAdapter::refreshCellConnectivity(const std::vector<uint>& idxMap) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "refreshCellConnectivity()" << "\n"; - - for( auto& cell : this->cells ){ - for( uint idx = 0; idx < 27; idx++ ) - if( cell.cellToCell[ idx ] != INVALID_INDEX ) - cell.cellToCell[ idx ] = idxMap[ cell.cellToCell[ idx ] ]; - - if( cell.parent != INVALID_INDEX ) - cell.parent = idxMap[ cell.parent ]; - - for( uint idx = 0; idx < 8; idx++ ) - if( cell.children[ idx ] != INVALID_INDEX ) - cell.children[ idx ] = idxMap[ cell.children[ idx ] ]; - } - - for( auto& grid : this->gridToMesh ){ - for( auto& cellIdx : grid ){ - if( cellIdx != INVALID_INDEX ) - cellIdx = idxMap[ cellIdx ]; - } - } -} - -void GksMeshAdapter::findCornerCells() -{ - //SPtr<Grid> grid = this->gridBuilder->getGrids()[0]; - // - //this->cornerCells[0] = this->gridToMesh[ 0 ][ grid->transCoordToIndex( grid->getStartX(), grid->getStartY(), z0 ) ]; - //this->cornerCells[1] = this->gridToMesh[ 0 ][ grid->transCoordToIndex( grid->getEndX() , grid->getStartY(), z0 ) ]; - //this->cornerCells[2] = this->gridToMesh[ 0 ][ grid->transCoordToIndex( grid->getEndX() , grid->getEndY() , z0 ) ]; - //this->cornerCells[3] = this->gridToMesh[ 0 ][ grid->transCoordToIndex( grid->getStartX(), grid->getEndY() , z0 ) ]; -} - -void GksMeshAdapter::generateNodes() -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "generateNodes()" << "\n"; - - std::vector< SPtr<Grid> > grids = gridBuilder->getGrids(); - - nodes.reserve( 2 * this->cells.size() ); - - Distribution dirs = DistributionHelper::getDistribution27(); - - for( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - MeshCell& cell = this->cells[ cellIdx ]; - - //if( cell.type == STOPPER_SOLID ) continue; - - real x, y, z; - grids[cell.level]->transIndexToCoords(cell.gridIdx, x, y, z); - - real d = 0.5 * grids[cell.level]->getDelta(); - - std::array<Vec3,8> dir; - - for( uint idx = 0; idx < 8; idx++ ) - { - if( cell.cellToNode[idx] == INVALID_INDEX ) - { - - real dx = dirs.directions[idx + 19][0] * d; - real dy = dirs.directions[idx + 19][1] * d; - real dz = dirs.directions[idx + 19][2] * d; - - nodes.push_back( Vec3( x + dx, y + dy, z + dz ) ); - - cell.cellToNode[idx] = nodes.size()-1; - - //// register new node at neighbor cells on same level - for (uint idx = 0; idx < 8; idx++) - { - real dxNeighbor = -dirs.directions[idx + 19][0] * d; - real dyNeighbor = -dirs.directions[idx + 19][1] * d; - real dzNeighbor = -dirs.directions[idx + 19][2] * d; - - real xNeighbor = nodes.back().x + dxNeighbor; - real yNeighbor = nodes.back().y + dyNeighbor; - real zNeighbor = nodes.back().z + dzNeighbor; - - uint neighborGridIdx = grids[cell.level]->transCoordToIndex(xNeighbor, yNeighbor, zNeighbor); - - if ( neighborGridIdx == INVALID_INDEX ) continue; - - uint neighborIdx = gridToMesh[cell.level][neighborGridIdx]; - - if ( neighborIdx != INVALID_INDEX ) - { - this->cells[ neighborIdx ].cellToNode[idx] = nodes.size() - 1; - } - } - } - } - } -} - -void GksMeshAdapter::computeCellGeometry() -{ - for( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - MeshCell& cell = this->cells[ cellIdx ]; - - Vec3 cellCenter; - - for( uint node = 0; node < 8; node++ ){ - cellCenter = cellCenter + this->nodes[ cell.cellToNode[node] ]; - } - - cell.cellCenter.x = cellCenter.x / c8o1; - cell.cellCenter.y = cellCenter.y / c8o1; - cell.cellCenter.z = cellCenter.z / c8o1; - } -} - -void GksMeshAdapter::generateFaces() -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "generateFaces()" << "\n"; - - std::vector< SPtr<Grid> > grids = this->gridBuilder->getGrids(); - - this->faces.reserve( 2 * this->cells.size() ); - - for( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - MeshCell& cell = this->cells[ cellIdx ]; - - //if( cell.type == BC_SOLID || cell.type == STOPPER_SOLID ) continue; - - // generate faces in positive direction - for( uint neighborIdx = 0; neighborIdx < 6; neighborIdx += 2 ){ - - if( cell.faceExists[ neighborIdx ] ) continue; - - if( cell.cellToCell[ neighborIdx ] == INVALID_INDEX ) continue; - - uint neighborCellIdx = cell.cellToCell[ neighborIdx ]; - - MeshCell& neighborCell = this->cells[ neighborCellIdx ]; - - if( cell.isGhostCell && neighborCell.isGhostCell ) continue; - - if( cell.isCoarseGhostCell() || neighborCell.isCoarseGhostCell() ) continue; - - ////////////////////////////////////////////////////////////////////////// - - MeshFace newFace; - - newFace.level = cell.level; - - if( neighborIdx == 0 ) - { - newFace.faceToNode[ 0 ] = cell.cellToNode[ 3 ]; - newFace.faceToNode[ 1 ] = cell.cellToNode[ 1 ]; - newFace.faceToNode[ 2 ] = cell.cellToNode[ 0 ]; - newFace.faceToNode[ 3 ] = cell.cellToNode[ 2 ]; - newFace.orientation = 'x'; - } - if( neighborIdx == 2 ) - { - newFace.faceToNode[ 0 ] = cell.cellToNode[ 5 ]; - newFace.faceToNode[ 1 ] = cell.cellToNode[ 4 ]; - newFace.faceToNode[ 2 ] = cell.cellToNode[ 0 ]; - newFace.faceToNode[ 3 ] = cell.cellToNode[ 1 ]; - newFace.orientation = 'y'; - } - if( neighborIdx == 4 ) - { - newFace.faceToNode[ 0 ] = cell.cellToNode[ 6 ]; - newFace.faceToNode[ 1 ] = cell.cellToNode[ 2 ]; - newFace.faceToNode[ 2 ] = cell.cellToNode[ 0 ]; - newFace.faceToNode[ 3 ] = cell.cellToNode[ 4 ]; - newFace.orientation = 'z'; - } - - ////////////////////////////////////////////////////////////////////////// - - cell.faceExists[ neighborIdx ] = true; - - // register face at neighbor - for( uint idx = 0; idx < 6; idx++ ){ - if( neighborCell.cellToCell[ idx ] == cellIdx ){ - neighborCell.faceExists[ idx ] = true; - break; - } - } - - ////////////////////////////////////////////////////////////////////////// - - newFace.negCell = cellIdx; - newFace.posCell = neighborCellIdx; - - ////////////////////////////////////////////////////////////////////////// - - //if ( cell.type == FLUID_CFF && neighborCell.type == FLUID_FCF ) newFace.negCellCoarse = cell.parent; - //if ( cell.type == FLUID_FCF && neighborCell.type == FLUID_CFF ) newFace.posCellCoarse = neighborCell.parent; - - ////////////////////////////////////////////////////////////////////////// - - Vec3 faceCenter; - - for( uint node = 0; node < 4; node++ ){ - faceCenter = faceCenter + this->nodes[ newFace.faceToNode[node] ]; - } - - newFace.faceCenter.x = faceCenter.x / c4o1; - newFace.faceCenter.y = faceCenter.y / c4o1; - newFace.faceCenter.z = faceCenter.z / c4o1; - - this->faces.push_back( newFace ); - } - } -} - -#define OLD_SORTING -#ifdef OLD_SORTING - -void GksMeshAdapter::sortFaces() -{ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // sort by level and orientation - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "sortFaces()" << "\n"; - - std::stable_sort(this->faces.begin(), this->faces.end(), - [&, this](MeshFace lhs, MeshFace rhs) - { - if( lhs.level != rhs.level ) return lhs.level < rhs.level; - - if (lhs.orientation != rhs.orientation) { - if (lhs.orientation == 'x' && rhs.orientation == 'y') return true; - else if (lhs.orientation == 'y' && rhs.orientation == 'z') return true; - else if (lhs.orientation == 'x' && rhs.orientation == 'z') return true; - else return false; - } - - return false; - } - ); - - this->countFaces(); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // sort into blocks - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // std::array<char, 3> orientations = {'x', 'y', 'z'}; - - for( uint level = 0; level < this->gridBuilder->getNumberOfLevels(); level++ ) - { - for( uint idx = 0; idx < 3; idx++ ) - { - uint start = this->startOfFacesPerLevelXYZ [ 3 * level + idx]; - uint end = start + this->numberOfFacesPerLevelXYZ[ 3 * level + idx]; - - // real xMax = (*std::max_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.x < rhs.faceCenter.x; })).faceCenter.x; - // real yMax = (*std::max_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.y < rhs.faceCenter.y; })).faceCenter.y; - // real zMax = (*std::max_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.z < rhs.faceCenter.z; })).faceCenter.z; - - real xMin = (*std::min_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.x < rhs.faceCenter.x; })).faceCenter.x; - real yMin = (*std::min_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.y < rhs.faceCenter.y; })).faceCenter.y; - real zMin = (*std::min_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.z < rhs.faceCenter.z; })).faceCenter.z; - - // real xRange = xMax - xMin; - // real yRange = yMax - yMin; - // real zRange = zMax - zMin; - - uint blockDim = 8; - - real dx = this->gridBuilder->getGrid(level)->getDelta(); - - std::sort(this->faces.begin() + start, this->faces.begin() + end, - [&, this](MeshFace lhs, MeshFace rhs) - { - uint xIdxLhs = lround((lhs.faceCenter.x - xMin) / dx); - uint yIdxLhs = lround((lhs.faceCenter.y - yMin) / dx); - uint zIdxLhs = lround((lhs.faceCenter.z - zMin) / dx); - - uint xIdxRhs = lround((rhs.faceCenter.x - xMin) / dx); - uint yIdxRhs = lround((rhs.faceCenter.y - yMin) / dx); - uint zIdxRhs = lround((rhs.faceCenter.z - zMin) / dx); - - real xBlockLhs = xIdxLhs / blockDim; - real yBlockLhs = yIdxLhs / blockDim; - real zBlockLhs = zIdxLhs / blockDim; - - real xBlockRhs = xIdxRhs / blockDim; - real yBlockRhs = yIdxRhs / blockDim; - real zBlockRhs = zIdxRhs / blockDim; - - if (zBlockLhs < zBlockRhs) return true; - if (zBlockLhs > zBlockRhs) return false; - if (yBlockLhs < yBlockRhs) return true; - if (yBlockLhs > yBlockRhs) return false; - if (xBlockLhs < xBlockRhs) return true; - if (xBlockLhs > xBlockRhs) return false; - - if (zIdxLhs < zIdxRhs) return true; - if (zIdxLhs > zIdxRhs) return false; - if (yIdxLhs < yIdxRhs) return true; - if (yIdxLhs > yIdxRhs) return false; - if (xIdxLhs < xIdxRhs) return true; - if (xIdxLhs > xIdxRhs) return false; - - return true; - } - ); - } - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // partition by inner and out for communication hiding - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - this->numberOfInnerFacesPerLevel.resize( this->numberOfLevels ); - - for( uint level = 0; level < this->gridBuilder->getNumberOfLevels(); level++ ) - { - auto bound = - std::stable_partition( this->faces.begin() + this->startOfFacesPerLevelXYZ [3 * level], - this->faces.begin() + this->startOfFacesPerLevelXYZ [3 * level] - + this->numberOfFacesPerLevelXYZ[3 * level + 0] - + this->numberOfFacesPerLevelXYZ[3 * level + 1] - + this->numberOfFacesPerLevelXYZ[3 * level + 2], - [this](MeshFace& lhs) - { - //return true; // comment this in to disable sorting for Comm hiding - - for( uint neighborIndex = 0; neighborIndex < 6; neighborIndex++ ) - { - uint neighborCellIndex = this->cells[ lhs.posCell ].cellToCell[ neighborIndex ]; - if( neighborCellIndex != INVALID_INDEX && this->cells[ neighborCellIndex ].isRecvCell ) - { - return false; - } - } - for( uint neighborIndex = 0; neighborIndex < 6; neighborIndex++ ) - { - uint neighborCellIndex = this->cells[ lhs.negCell ].cellToCell[ neighborIndex ]; - if( neighborCellIndex != INVALID_INDEX && this->cells[ neighborCellIndex ].isRecvCell ) - { - return false; - } - } - - return true; - } - ); - - this->numberOfInnerFacesPerLevel[ level ] = 0; - for( auto it = this->faces.begin() + this->startOfFacesPerLevelXYZ [3 * level]; it != bound; it++ ) - { - this->numberOfInnerFacesPerLevel[ level ]++; - } - - *logging::out << logging::Logger::INFO_LOW << " Level " << level << ": " << this->numberOfFacesPerLevelXYZ[ 3 * level + 0 ] - + this->numberOfFacesPerLevelXYZ[ 3 * level + 1 ] - + this->numberOfFacesPerLevelXYZ[ 3 * level + 2 ] - << " faces" << "\n"; - *logging::out << logging::Logger::INFO_LOW << " Level " << level << ": " << this->numberOfInnerFacesPerLevel[ level ] << " inner faces" << "\n"; - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -} - -#else - -void GksMeshAdapter::sortFaces() -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "sortFaces()" << "\n"; - - std::stable_sort(this->faces.begin(), this->faces.end(), - [&, this](MeshFace lhs, MeshFace rhs) - { - if( lhs.level != rhs.level ) return lhs.level < rhs.level; - - return false; - } - ); - - countFaces(); - - std::array<char, 3> orientations = {'x', 'y', 'z'}; - - for( uint level = 0; level < this->gridBuilder->getNumberOfLevels(); level++ ) - { - uint start = this->startOfFacesPerLevelXYZ [ 3 * level ]; - uint end = start + this->numberOfFacesPerLevelXYZ[ 3 * level + 0] - + this->numberOfFacesPerLevelXYZ[ 3 * level + 1] - + this->numberOfFacesPerLevelXYZ[ 3 * level + 2]; - - uint blockDim = 16; - - real dx = this->gridBuilder->getGrid(level)->getDelta(); - - real xMax = (*std::max_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.x < rhs.faceCenter.x; })).faceCenter.x + 0.5 * dx; - real yMax = (*std::max_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.y < rhs.faceCenter.y; })).faceCenter.y + 0.5 * dx; - real zMax = (*std::max_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.z < rhs.faceCenter.z; })).faceCenter.z + 0.5 * dx; - - real xMin = (*std::min_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.x < rhs.faceCenter.x; })).faceCenter.x + 0.5 * dx; - real yMin = (*std::min_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.y < rhs.faceCenter.y; })).faceCenter.y + 0.5 * dx; - real zMin = (*std::min_element(this->faces.begin() + start, this->faces.begin() + end, [this](MeshFace lhs, MeshFace rhs) { return lhs.faceCenter.z < rhs.faceCenter.z; })).faceCenter.z + 0.5 * dx; - - std::stable_sort(this->faces.begin() + start, this->faces.begin() + end, - [&, this](MeshFace lhs, MeshFace rhs) - { - Vec3 lhsCenter = lhs.faceCenter; - Vec3 rhsCenter = rhs.faceCenter; - - if( lhs.orientation == 'x' ) lhsCenter.x += 0.5 * dx; - if( lhs.orientation == 'y' ) lhsCenter.y += 0.5 * dx; - if( lhs.orientation == 'z' ) lhsCenter.z += 0.5 * dx; - - if( rhs.orientation == 'x' ) rhsCenter.x += 0.5 * dx; - if( rhs.orientation == 'y' ) rhsCenter.y += 0.5 * dx; - if( rhs.orientation == 'z' ) rhsCenter.z += 0.5 * dx; - - uint xIdxLhs = lround((lhsCenter.x - xMin) / dx); - uint yIdxLhs = lround((lhsCenter.y - yMin) / dx); - uint zIdxLhs = lround((lhsCenter.z - zMin) / dx); - - uint xIdxRhs = lround((rhsCenter.x - xMin) / dx); - uint yIdxRhs = lround((rhsCenter.y - yMin) / dx); - uint zIdxRhs = lround((rhsCenter.z - zMin) / dx); - - uint xBlockLhs = xIdxLhs / blockDim; - uint yBlockLhs = yIdxLhs / blockDim; - uint zBlockLhs = zIdxLhs / blockDim; - - uint xBlockRhs = xIdxRhs / blockDim; - uint yBlockRhs = yIdxRhs / blockDim; - uint zBlockRhs = zIdxRhs / blockDim; - - if (zBlockLhs < zBlockRhs) return true; - if (zBlockLhs > zBlockRhs) return false; - if (yBlockLhs < yBlockRhs) return true; - if (yBlockLhs > yBlockRhs) return false; - if (xBlockLhs < xBlockRhs) return true; - if (xBlockLhs > xBlockRhs) return false; - - if (lhs.orientation != rhs.orientation) { - if (lhs.orientation == 'x' && rhs.orientation == 'y') return true; - else if (lhs.orientation == 'y' && rhs.orientation == 'z') return true; - else if (lhs.orientation == 'x' && rhs.orientation == 'z') return true; - else return false; - } - - if (zIdxLhs < zIdxRhs) return true; - if (zIdxLhs > zIdxRhs) return false; - if (yIdxLhs < yIdxRhs) return true; - if (yIdxLhs > yIdxRhs) return false; - if (xIdxLhs < xIdxRhs) return true; - if (xIdxLhs > xIdxRhs) return false; - - return false; - }); - } -} - -#endif - -void GksMeshAdapter::countFaces() -{ - this->numberOfFacesPerLevelXYZ.resize( 3 * this->numberOfLevels ); - this->startOfFacesPerLevelXYZ.resize ( 3 * this->numberOfLevels ); - - for( auto& i : this->numberOfFacesPerLevelXYZ ) i = 0; - for( auto& i : this->startOfFacesPerLevelXYZ ) i = 0; - - for( auto& face : this->faces ){ - if ( face.orientation == 'x' ) this->numberOfFacesPerLevelXYZ[ 3 * face.level ]++; - else if ( face.orientation == 'y' ) this->numberOfFacesPerLevelXYZ[ 3 * face.level + 1 ]++; - else if ( face.orientation == 'z' ) this->numberOfFacesPerLevelXYZ[ 3 * face.level + 2 ]++; - } - - this->startOfFacesPerLevelXYZ[0] = 0; - - for( uint level = 1; level < 3 * this->numberOfLevels; level++ ){ - - this->startOfFacesPerLevelXYZ[level] = this->startOfFacesPerLevelXYZ [level - 1] - + this->numberOfFacesPerLevelXYZ[level - 1]; - } -} - -void GksMeshAdapter::generateInterfaceConnectivity() -{ - this->numberOfFineToCoarsePerLevel.resize( this->numberOfLevels ); - this->startOfFineToCoarsePerLevel.resize ( this->numberOfLevels ); - this->numberOfCoarseToFinePerLevel.resize( this->numberOfLevels ); - this->startOfCoarseToFinePerLevel.resize ( this->numberOfLevels ); - - for( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - MeshCell& cell = this->cells[ cellIdx ]; - - if( cell.type == FLUID_FCC ){ - - uint_9 connectivity; - - connectivity[ 0 ] = cellIdx; - connectivity[ 1 ] = cell.children[ 0 ]; - connectivity[ 2 ] = cell.children[ 1 ]; - connectivity[ 3 ] = cell.children[ 2 ]; - connectivity[ 4 ] = cell.children[ 3 ]; - connectivity[ 5 ] = cell.children[ 4 ]; - connectivity[ 6 ] = cell.children[ 5 ]; - connectivity[ 7 ] = cell.children[ 6 ]; - connectivity[ 8 ] = cell.children[ 7 ]; - - this->fineToCoarse.push_back( connectivity ); - - this->numberOfFineToCoarsePerLevel[ cell.level ]++; - } - - if( cell.type == FLUID_CFC ){ - - uint_15 connectivity; - - connectivity[ 0 ] = cellIdx; - - //connectivity[ 1 ] = cell.cellToCell[ 0 ]; - //connectivity[ 2 ] = cell.cellToCell[ 1 ]; - //connectivity[ 3 ] = cell.cellToCell[ 2 ]; - //connectivity[ 4 ] = cell.cellToCell[ 3 ]; - //connectivity[ 5 ] = cell.cellToCell[ 4 ]; - //connectivity[ 6 ] = cell.cellToCell[ 5 ]; - - //connectivity[ 7 ] = cell.children[ 0 ]; - //connectivity[ 8 ] = cell.children[ 1 ]; - //connectivity[ 9 ] = cell.children[ 2 ]; - //connectivity[ 10 ] = cell.children[ 3 ]; - //connectivity[ 11 ] = cell.children[ 4 ]; - //connectivity[ 12 ] = cell.children[ 5 ]; - //connectivity[ 13 ] = cell.children[ 6 ]; - //connectivity[ 14 ] = cell.children[ 7 ]; - - connectivity[ 1 ] = cell.children[ 0 ]; - connectivity[ 2 ] = cell.children[ 1 ]; - connectivity[ 3 ] = cell.children[ 2 ]; - connectivity[ 4 ] = cell.children[ 3 ]; - connectivity[ 5 ] = cell.children[ 4 ]; - connectivity[ 6 ] = cell.children[ 5 ]; - connectivity[ 7 ] = cell.children[ 6 ]; - connectivity[ 8 ] = cell.children[ 7 ]; - - this->coarseToFine.push_back( connectivity ); - - numberOfCoarseToFinePerLevel[ cell.level ]++; - } - } - - this->startOfFineToCoarsePerLevel[0] = 0; - this->startOfCoarseToFinePerLevel[0] = 0; - - for( uint level = 1; level < this->numberOfLevels; level++ ) - { - this->startOfFineToCoarsePerLevel[level] = this->startOfFineToCoarsePerLevel [level - 1] - + this->numberOfFineToCoarsePerLevel[level - 1]; - - this->startOfCoarseToFinePerLevel[level] = this->startOfCoarseToFinePerLevel [level - 1] - + this->numberOfCoarseToFinePerLevel[level - 1]; - } -} - -void GksMeshAdapter::findPeriodicBoundaryNeighbors() -{ - for( uint level = 0; level < this->numberOfLevels; level++ ) - { - SPtr<Grid> grid = this->gridBuilder->getGrid(level); - - if( !grid->getPeriodicityX() && !grid->getPeriodicityY() && !grid->getPeriodicityZ() ) - throw std::runtime_error( "GksMeshAdapter::findPeriodicBoundaryNeighbors() failed, because no periodic direction is set!" ); - - uint startIdx = startOfCellsPerLevel[ level ] + numberOfBulkCellsPerLevel[ level ]; - - uint endIdx = startOfCellsPerLevel[ level ] + numberOfCellsPerLevel[ level ]; - - for( uint cellIdx = startIdx; cellIdx < endIdx; cellIdx++ ) - { - MeshCell cell = this->cells[ cellIdx ]; - - if( cell.type != STOPPER_OUT_OF_GRID && cell.type != STOPPER_OUT_OF_GRID_BOUNDARY && cell.type != STOPPER_SOLID ) continue; - - Vec3 gridStart ( grid->getStartX() + c1o2 * grid->getDelta(), - grid->getStartY() + c1o2 * grid->getDelta(), - grid->getStartZ() + c1o2 * grid->getDelta() ); - - Vec3 gridEnd ( grid->getEndX() - c1o2 * grid->getDelta(), - grid->getEndY() - c1o2 * grid->getDelta(), - grid->getEndZ() - c1o2 * grid->getDelta() ); - - Vec3 size = gridEnd - gridStart; - - Vec3 delta; - - if( grid->getPeriodicityX() && cell.cellCenter.x < gridStart.x ) delta.x = size.x; - if( grid->getPeriodicityX() && cell.cellCenter.x > gridEnd.x ) delta.x = - size.x; - - if( grid->getPeriodicityY() && cell.cellCenter.y < gridStart.y ) delta.y = size.y; - if( grid->getPeriodicityY() && cell.cellCenter.y > gridEnd.y ) delta.y = - size.y; - - if( grid->getPeriodicityZ() && cell.cellCenter.z < gridStart.z ) delta.z = size.z; - if( grid->getPeriodicityZ() && cell.cellCenter.z > gridEnd.z ) delta.z = - size.z; - - uint neighborGridIdx = grid->transCoordToIndex( cell.cellCenter.x + delta.x, - cell.cellCenter.y + delta.y, - cell.cellCenter.z + delta.z ); - - if( neighborGridIdx == INVALID_INDEX ) throw std::runtime_error( std::string("No periodic cell found!") ); - - uint neighborIdx = this->gridToMesh[ level ][ neighborGridIdx ]; - - //if( neighborIdx == cellIdx ) neighborIdx == INVALID_INDEX; - - if( neighborIdx == INVALID_INDEX ) - { - std::stringstream s; - - s << "No periodic cell found: "; - s << "( " << cell.cellCenter.x << ", " << cell.cellCenter.y << ", " << cell.cellCenter.z << " )"; - s << "( " << cell.cellCenter.x + delta.x << ", " << cell.cellCenter.y + delta.y << ", " << cell.cellCenter.z + delta.z << " )"; - - s << "( " << gridStart.x << ", " << gridStart.y << ", " << gridStart.z << " )"; - s << "( " << gridEnd.x << ", " << gridEnd.y << ", " << gridEnd.z << " )"; - - throw std::runtime_error( s.str() ); - } - - this->periodicBoundaryNeighbors.push_back( {cellIdx, neighborIdx} ); - } - } -} - -void GksMeshAdapter::getCommunicationIndices() -{ - this->communicationProcesses[0] = this->gridBuilder->getCommunicationProcess(0); - this->communicationProcesses[1] = this->gridBuilder->getCommunicationProcess(1); - this->communicationProcesses[2] = this->gridBuilder->getCommunicationProcess(2); - this->communicationProcesses[3] = this->gridBuilder->getCommunicationProcess(3); - this->communicationProcesses[4] = this->gridBuilder->getCommunicationProcess(4); - this->communicationProcesses[5] = this->gridBuilder->getCommunicationProcess(5); - - this->communicationIndices.resize( this->gridBuilder->getNumberOfLevels() ); - - //int rank = 0; - //MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - //int mpiWorldSize = 1; - //MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize); - - //MPI_Barrier(MPI_COMM_WORLD); - - //for( int i = 0; i < rank; i++ ) MPI_Barrier(MPI_COMM_WORLD); - - for( uint level = 0; level < this->gridBuilder->getNumberOfLevels(); level++ ) - { - ////////////////////////////////////////////////////////////////////////// - - SPtr<Grid> grid = this->gridBuilder->getGrid(level); - - for (uint direction = 0; direction < 6; direction++) - { - for (uint index = 0; index < grid->getNumberOfSendNodes(direction); index++) - { - uint cellIndex = this->gridToMesh[level][grid->getSendIndex(direction, index)]; - this->communicationIndices[level].sendIndices[direction].push_back(cellIndex); - } - - for (uint index = 0; index < grid->getNumberOfReceiveNodes(direction); index++) - { - uint cellIndex = this->gridToMesh[level][grid->getReceiveIndex(direction, index)]; - this->communicationIndices[level].recvIndices[direction].push_back(cellIndex); - this->cells[ cellIndex ].isRecvCell = true; - } - - std::stringstream msg; - - msg << "Rank " << /*rank <<*/ " | Level " << level << " | dir " << direction << " | "; - msg << "Send " << this->communicationIndices[level].sendIndices[direction].size() << " | "; - msg << "Recv " << this->communicationIndices[level].recvIndices[direction].size() << std::endl; - - *logging::out << logging::Logger::INFO_INTERMEDIATE << msg.str(); - } - - ////////////////////////////////////////////////////////////////////////// - } - - //for( int i = rank; i < mpiWorldSize; i++ ) MPI_Barrier(MPI_COMM_WORLD); -} - -void GksMeshAdapter::writeMeshVTK(std::string filename) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "writeMeshVTK( " << filename << " )" << "\n"; - - std::ofstream file; - - file.open(filename); - - file << "# vtk DataFile Version 3.0\n"; - file << "by MeshGenerator\n"; - file << "ASCII\n"; - file << "DATASET UNSTRUCTURED_GRID\n"; - - file << "POINTS " << nodes.size() << " float" << std::endl; - - for (auto node : nodes){ - file << node.x << " " << node.y << " " << node.z << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file << "CELLS " << this->cells.size() << " " << this->cells.size() * 9 << std::endl; - - for ( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - MeshCell& cell = this->cells[ cellIdx ]; - - uint_8 nodes; - for( auto& i : nodes ) i = INVALID_INDEX; - - nodes[0] = cell.cellToNode[7];//[ 6 ]; - nodes[1] = cell.cellToNode[3];//[ 5 ]; - nodes[2] = cell.cellToNode[1];//[ 2 ]; - nodes[3] = cell.cellToNode[5];//[ 1 ]; - nodes[4] = cell.cellToNode[6];//[ 4 ]; - nodes[5] = cell.cellToNode[2];//[ 7 ]; - nodes[6] = cell.cellToNode[0];//[ 0 ]; - nodes[7] = cell.cellToNode[4];//[ 3 ]; - - file << 8 << " "; - - for( uint i = 0; i < 8; i++ ) file << nodes[i] << " "; - - file << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file << "CELL_TYPES " << this->cells.size() << std::endl; - - for ( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - file << 12 << std::endl; - } - ////////////////////////////////////////////////////////////////////////// - - file << "\nCELL_DATA " << this->cells.size() << std::endl; - - file << "FIELD Label " << 4 << std::endl; - - ////////////////////////////////////////////////////////////////////////// - - file << "CellIdx 1 " << this->cells.size() << " int" << std::endl; - - for ( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - file << cellIdx << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file << "level 1 " << this->cells.size() << " int" << std::endl; - - for ( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - MeshCell& cell = this->cells[ cellIdx ]; - - file << cell.level << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file << "type 1 " << this->cells.size() << " int" << std::endl; - - for ( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - MeshCell& cell = this->cells[ cellIdx ]; - - file << (uint) cell.type << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file << "isGhostCell 1 " << this->cells.size() << " int" << std::endl; - - for ( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - MeshCell& cell = this->cells[ cellIdx ]; - - file << (uint) cell.isGhostCell << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file.close(); -} - -void GksMeshAdapter::writeMeshFaceVTK(std::string filename) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "writeMeshFaceVTK( " << filename << " )" << "\n"; - - std::ofstream file; - - file.open(filename); - - file << "# vtk DataFile Version 3.0\n"; - file << "by MeshGenerator\n"; - file << "ASCII\n"; - file << "DATASET UNSTRUCTURED_GRID\n"; - - file << "POINTS " << nodes.size() << " float" << std::endl; - - for (auto node : nodes){ - file << node.x << " " << node.y << " " << node.z << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file << "CELLS " << this->faces.size() << " " << 5 * this->faces.size() << std::endl; - - for ( uint faceIdx = 0; faceIdx < this->faces.size(); faceIdx++ ){ - - file << "4 "; - - file << this->faces[ faceIdx ].faceToNode[0] << " "; - file << this->faces[ faceIdx ].faceToNode[1] << " "; - file << this->faces[ faceIdx ].faceToNode[2] << " "; - file << this->faces[ faceIdx ].faceToNode[3] << " "; - - file << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file << "CELL_TYPES " << this->faces.size() << std::endl; - - for ( uint faceIdx = 0; faceIdx < this->faces.size(); faceIdx++ ){ - file << "9" << std::endl; - } - ////////////////////////////////////////////////////////////////////////// - - file << "\nCELL_DATA " << this->faces.size() << std::endl; - - file << "FIELD Label " << 3 << std::endl; - - ////////////////////////////////////////////////////////////////////////// - - file << "FaceIdx 1 " << this->faces.size() << " int" << std::endl; - - for ( uint faceIdx = 0; faceIdx < this->faces.size(); faceIdx++ ){ - - file << faceIdx << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file << "level 1 " << this->faces.size() << " int" << std::endl; - - for ( uint faceIdx = 0; faceIdx < this->faces.size(); faceIdx++ ){ - - file << this->faces[ faceIdx ].level << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file << "orientation 1 " << this->faces.size() << " int" << std::endl; - - for ( uint faceIdx = 0; faceIdx < this->faces.size(); faceIdx++ ){ - - file << (int)this->faces[ faceIdx ].orientation << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - file << "VECTORS posCell double" << std::endl; - - for ( auto face : this->faces ) - { - MeshCell& cell = this->cells[ face.posCell ]; - - Vec3 vec = cell.cellCenter - face.faceCenter; - - file << vec.x << " "; - file << vec.y << " "; - file << vec.z << std::endl; - } - - file << "VECTORS negCell double" << std::endl; - - for ( auto face : this->faces ) - { - MeshCell& cell = this->cells[ face.negCell ]; - - Vec3 vec = cell.cellCenter - face.faceCenter; - - file << vec.x << " "; - file << vec.y << " "; - file << vec.z << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file.close(); -} - -void GksMeshAdapter::writeMeshCellToCellVTK(std::string filename) -{ - //std::ofstream file; - - //file.open(filename); - - //file << "# vtk DataFile Version 3.0\n"; - //file << "by MeshGenerator\n"; - //file << "ASCII\n"; - //file << "DATASET UNSTRUCTURED_GRID\n"; - - //file << "POINTS " << this->cells.size() << " float" << std::endl; - - //for (auto cell : cells){ - // file << cell.cellCenter.x << " " << cell.cellCenter.y << " 0.0" << std::endl; - //} - - //////////////////////////////////////////////////////////////////////////// - - //file << "CELLS " << 8 * this->cells.size() << " " << 3 * 8 * this->cells.size() << std::endl; - - //for ( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - // for( uint i = 0; i < 8; i++ ) - // if( this->cells[ cellIdx ].cellToCell[ i ] != INVALID_INDEX ) - // file << "2 " << cellIdx << " " << this->cells[ cellIdx ].cellToCell[ i ] << " " << std::endl; - // else - // file << "2 " << cellIdx << " " << cellIdx << " " << std::endl; - //} - - //////////////////////////////////////////////////////////////////////////// - - //file << "CELL_TYPES " << 8 * this->cells.size() << std::endl; - - //for ( uint i = 0; i < 8 * this->cells.size(); i++ ){ - // file << "3" << std::endl; - //} - //////////////////////////////////////////////////////////////////////////// - - //file << "\nCELL_DATA " << 8 * this->cells.size() << std::endl; - - //file << "FIELD Label " << 2 << std::endl; - - //////////////////////////////////////////////////////////////////////////// - - //file << "CellIdx 1 " << 8 * this->cells.size() << " int" << std::endl; - - //for ( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - // for( uint i = 0; i < 8; i++ ) - // file << cellIdx << std::endl; - //} - - //////////////////////////////////////////////////////////////////////////// - - //file << "CellToCell 1 " << 8 * this->cells.size() << " int" << std::endl; - - //for ( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ - - // for( uint i = 0; i < 8; i++ ) - // file << i << std::endl; - //} - - //////////////////////////////////////////////////////////////////////////// - - //file.close(); -} - -void GksMeshAdapter::writeMeshFaceToCellVTK(std::string filename) -{ - //std::ofstream file; - - //file.open(filename); - - //file << "# vtk DataFile Version 3.0\n"; - //file << "by MeshGenerator\n"; - //file << "ASCII\n"; - //file << "DATASET UNSTRUCTURED_GRID\n"; - - //file << "POINTS " << this->cells.size() + this->faces.size() << " float" << std::endl; - - //for (auto cell : cells){ - // file << cell.cellCenter.x << " " << cell.cellCenter.y << " 0.0" << std::endl; - //} - - //for (auto face : faces){ - // file << face.faceCenter.x << " " << face.faceCenter.y << " 0.0" << std::endl; - //} - - //////////////////////////////////////////////////////////////////////////// - - //file << "CELLS " << 6 * this->faces.size() << " " << 3 * 6 * this->faces.size() << std::endl; - - //for ( uint faceIdx = 0; faceIdx < this->faces.size(); faceIdx++ ){ - - // for( uint i = 0; i < 6; i++ ) - // if( this->faces[ faceIdx ].faceToCell[ i ] != INVALID_INDEX ) - // file << "2 " << this->cells.size() + faceIdx << " " << this->faces[ faceIdx ].faceToCell[ i ] << " " << std::endl; - // else - // file << "2 " << this->cells.size() + faceIdx << " " << this->cells.size() + faceIdx << " " << std::endl; - //} - - //////////////////////////////////////////////////////////////////////////// - - //file << "CELL_TYPES " << 6 * this->faces.size() << std::endl; - - //for ( uint i = 0; i < 6 * this->faces.size(); i++ ){ - // file << "3" << std::endl; - //} - //////////////////////////////////////////////////////////////////////////// - - //file << "\nCELL_DATA " << 6 * this->faces.size() << std::endl; - - //file << "FIELD Label " << 2 << std::endl; - - //////////////////////////////////////////////////////////////////////////// - - //file << "FaceIdx 1 " << 6 * this->faces.size() << " int" << std::endl; - - //for ( uint faceIdx = 0; faceIdx < this->faces.size(); faceIdx++ ){ - - // for( uint i = 0; i < 6; i++ ) - // file << faceIdx << std::endl; - //} - - //////////////////////////////////////////////////////////////////////////// - - //file << "FaceToCell 1 " << 6 * this->faces.size() << " int" << std::endl; - - //for ( uint faceIdx = 0; faceIdx < this->faces.size(); faceIdx++ ){ - - // for( uint i = 0; i < 6; i++ ) - // file << i << std::endl; - //} - - //////////////////////////////////////////////////////////////////////////// - - //file.close(); -} - -double GksMeshAdapter::getDx(uint level) -{ - return dxCoarse / pow( 2.0, level ); -} diff --git a/src/gpu/GksMeshAdapter/GksMeshAdapter.h b/src/gpu/GksMeshAdapter/GksMeshAdapter.h deleted file mode 100644 index ede88301f7133fdb6685d94906960eec955ad449..0000000000000000000000000000000000000000 --- a/src/gpu/GksMeshAdapter/GksMeshAdapter.h +++ /dev/null @@ -1,160 +0,0 @@ -#ifndef GKS_MESH_ADAPTER_H -#define GKS_MESH_ADAPTER_H - -#include <memory> -#include <array> -#include <vector> - -#include "Core/DataTypes.h" -#include "PointerDefinitions.h" - -#include "MeshCell.h" -#include "MeshFace.h" - - - -#include "GksMeshAdapter_export.h" - -class MultipleGridBuilder; - -class GKSMESHADAPTER_EXPORT GksMeshAdapter{ - -public: - - SPtr<MultipleGridBuilder> gridBuilder; - - uint numberOfLevels; - - double dxCoarse; - - ////////////////////////////////////////////////////////////////////////// - - std::vector<Vec3> nodes; - - ////////////////////////////////////////////////////////////////////////// - // - // C e l l s o r t i n g : - // - // | Level 0 | Level 1 | Level 2 | - // | FluidCells | GhostCells | FluidCells | GhostCells | FluidCells | GhostCells | - // - // GhostCells: not included in Cell update, i.e. BoundaryCells and FCC-Cells - // FluidCells: all other, including CFF-Cells - // - std::vector<MeshCell> cells; - - std::vector<uint> numberOfCellsPerLevel; - std::vector<uint> numberOfBulkCellsPerLevel; - std::vector<uint> startOfCellsPerLevel; - - ////////////////////////////////////////////////////////////////////////// - // - // F a c e s o r t i n g : - // - // | Level 0 | Level 1 | Level 2 | - // | x-normal | y-normal | z-normal | x-normal | y-normal | z-normal | x-normal | y-normal | z-normal | - // - std::vector<MeshFace> faces; - - std::vector<uint> numberOfFacesPerLevelXYZ; - std::vector<uint> startOfFacesPerLevelXYZ; - - std::vector<uint> numberOfInnerFacesPerLevel; - - ////////////////////////////////////////////////////////////////////////// - // - // F i n e T o C o a r s e s o r t i n g : - // - // | Coarse Cell Idx | Child Idcs | ... - // - std::vector<uint_9> fineToCoarse; - - std::vector<uint> numberOfFineToCoarsePerLevel; - std::vector<uint> startOfFineToCoarsePerLevel; - - ////////////////////////////////////////////////////////////////////////// - // - // F i n e T o C o a r s e s o r t i n g : - // - // | Coarse Cell Idx | Coarse Neighbor Idcs | Child Idcs | ... - // - std::vector<uint_15> coarseToFine; - - std::vector<uint> numberOfCoarseToFinePerLevel; - std::vector<uint> startOfCoarseToFinePerLevel; - - ////////////////////////////////////////////////////////////////////////// - // - // Connectivity from LBM grid to GKS Mesh - // - // cellIdx = gridToMesh[ level ][ gridIdx ] - // - std::vector< std::vector<uint> > gridToMesh; - - ////////////////////////////////////////////////////////////////////////// - - std::vector< uint_2 > periodicBoundaryNeighbors; - - ////////////////////////////////////////////////////////////////////////// - - struct CommunicationIndices - { - std::array< std::vector< uint >, 6 > sendIndices; - std::array< std::vector< uint >, 6 > recvIndices; - }; - - std::vector< CommunicationIndices > communicationIndices; - - std::array<uint, 6> communicationProcesses; - -public: - - GksMeshAdapter( SPtr<MultipleGridBuilder> gridBuilder ); - - void inputGrid(); - - void findQuadtreeConnectivity(); - - void findCellToCellConnectivity(); - - void countCells(); - - void partitionCells(); - - void refreshCellConnectivity(const std::vector<uint>& idxMap); - - void findCornerCells(); - - void generateNodes(); - - void computeCellGeometry(); - - void generateFaces(); - - void sortFaces(); - - void countFaces(); - - void countInnerFaces(); - - void generateInterfaceConnectivity(); - - void findPeriodicBoundaryNeighbors(); - - void getCommunicationIndices(); - - void writeMeshVTK( std::string filename ); - - void writeMeshFaceVTK( std::string filename ); - - void writeMeshCellToCellVTK( std::string filename ); - - void writeMeshFaceToCellVTK( std::string filename ); - - ////////////////////////////////////////////////////////////////////////// - - double getDx(uint level); -}; - - -#endif \ No newline at end of file diff --git a/src/gpu/GksMeshAdapter/MeshCell.cpp b/src/gpu/GksMeshAdapter/MeshCell.cpp deleted file mode 100644 index 349d308ee498e89f9705091c72d3ca7013bf3d4e..0000000000000000000000000000000000000000 --- a/src/gpu/GksMeshAdapter/MeshCell.cpp +++ /dev/null @@ -1,74 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file MeshCell.cpp -//! \ingroup GksMeshAdapter -//! \author Stephan Lenz -//======================================================================================= -#include "MeshCell.h" - -#include "GridGenerator/grid/NodeValues.h" - -using namespace vf::gpu; - -MeshCell::MeshCell(){ - - level = INVALID_INDEX; - gridIdx = INVALID_INDEX; - - - for( uint& index : this->cellToNode ) index = INVALID_INDEX; - for( uint& index : this->cellToEdgeNode ) index = INVALID_INDEX; - for( uint& index : this->cellToFaceNode ) index = INVALID_INDEX; - for( uint& index : this->cellToCell ) index = INVALID_INDEX; - for( uint& index : this->children ) index = INVALID_INDEX; - - parent = INVALID_INDEX; - - for( bool& flag : this->faceExists ) flag = false; - - isGhostCell = false; - - isWall = false; - - isFluxBC = false; - - isInsulated = false; - - isRecvCell = false; -} - -bool MeshCell::isCoarseGhostCell() -{ - return this->type == FLUID_FCC; -} - -bool MeshCell::isFineGhostCell() -{ - return this->type == FLUID_CFF; -} diff --git a/src/gpu/GksMeshAdapter/MeshCell.h b/src/gpu/GksMeshAdapter/MeshCell.h deleted file mode 100644 index 1b09a69b847a27c98c27b65b3190ce00ebec18c4..0000000000000000000000000000000000000000 --- a/src/gpu/GksMeshAdapter/MeshCell.h +++ /dev/null @@ -1,113 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file MeshCell.h -//! \ingroup GksMeshAdapter -//! \author Stephan Lenz -//======================================================================================= -#ifndef MESH_CELL_H -#define MESH_CELL_H - -#include <array> - -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/ArrayTypes.h" - -#include "GksMeshAdapter_export.h" - -struct GKSMESHADAPTER_EXPORT MeshCell{ - - uint level; - uint gridIdx; - - ////////////////////////////////////////////////////////////////////////// - - uint_8 cellToNode; uint_12 cellToEdgeNode; uint_6 cellToFaceNode; - - // for sorting see LBM f numbering - // 8 - // 4 o--------o 0 o--------o o--------o - // /| /| 7/| 4/| /| 4 /| - // / | / | /3| 11 / | / | 2 / | - // 6 o--------o 2| o--------o |0 o--------o | - // | | | | | | 10 | | |1 | | 0| - // |5 o-----|--o 1 1| o-----|--o | o-----|--o - // | / | / |5/ 2| /6 | / 3 | / - // |/ |/ |/ 9 |/ |/ 5 |/ - // 7 o--------o 3 o--------o o--------o - // - // z | / y - // |/ - // +---- x - // - - ////////////////////////////////////////////////////////////////////////// - - uint_27 cellToCell; - - // for sorting see LBM f numbering - - ////////////////////////////////////////////////////////////////////////// - - uint_8 children; - - // for sorting see cellToNode - - uint parent; - - ////////////////////////////////////////////////////////////////////////// - - Vec3 cellCenter; - - ////////////////////////////////////////////////////////////////////////// - - // order: +x, -x, +y, -y, +z, -z (see cellToCell) - bool_6 faceExists; - - bool isGhostCell; // this denotes cells that do not have all neighbors, excluding coarse ghost cells - - bool isWall; - - bool isFluxBC; - - bool isInsulated; - - bool isRecvCell; - - char type; - - MeshCell(); - - bool isCoarseGhostCell(); - - bool isFineGhostCell(); -}; - - -#endif \ No newline at end of file diff --git a/src/gpu/GksMeshAdapter/MeshFace.cpp b/src/gpu/GksMeshAdapter/MeshFace.cpp deleted file mode 100644 index b07355583e50b4b88c9ce5f43c489b3f82310ce2..0000000000000000000000000000000000000000 --- a/src/gpu/GksMeshAdapter/MeshFace.cpp +++ /dev/null @@ -1,43 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file MeshFace.cpp -//! \ingroup GksMeshAdapter -//! \author Stephan Lenz -//======================================================================================= -#include "MeshFace.h" - -MeshFace::MeshFace() -{ - for( uint& node : this->faceToNode ) node = INVALID_INDEX; - - posCell = INVALID_INDEX; - negCell = INVALID_INDEX; - posCellCoarse = INVALID_INDEX; - negCellCoarse = INVALID_INDEX; -} \ No newline at end of file diff --git a/src/gpu/GksMeshAdapter/MeshFace.h b/src/gpu/GksMeshAdapter/MeshFace.h deleted file mode 100644 index 54a37dbbcdc89224037edeb3e01e34b67f8fc536..0000000000000000000000000000000000000000 --- a/src/gpu/GksMeshAdapter/MeshFace.h +++ /dev/null @@ -1,82 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file MeshFace.h -//! \ingroup GksMeshAdapter -//! \author Stephan Lenz -//======================================================================================= -#ifndef MESH_FACE_H -#define MESH_FACE_H - -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/ArrayTypes.h" - -#include "GksMeshAdapter_export.h" - -struct GKSMESHADAPTER_EXPORT MeshFace -{ - ////////////////////////////////////////////////////////////////////////// - - // o 2 - // /| - // / | - // o 3| n - // | -+---------> - // | o 1 - // | / - // |/ - // o 0 - // - // - - uint_4 faceToNode; - - ////////////////////////////////////////////////////////////////////////// - - uint posCell; - uint negCell; - - uint posCellCoarse; - uint negCellCoarse; - - ////////////////////////////////////////////////////////////////////////// - - Vec3 faceCenter; - - ////////////////////////////////////////////////////////////////////////// - - char orientation; - - uint level; - - MeshFace(); -}; - - -#endif \ No newline at end of file diff --git a/src/gpu/GksVtkAdapter/CMakeLists.txt b/src/gpu/GksVtkAdapter/CMakeLists.txt deleted file mode 100644 index fdc7a1eb56f548afc58e83ef7b0f7ad02ad12ea9..0000000000000000000000000000000000000000 --- a/src/gpu/GksVtkAdapter/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ - - -vf_add_library(BUILDTYPE static PRIVATE_LINK basics GksGpu) - -include (${VF_CMAKE_DIR}/3rd/vtk.cmake) \ No newline at end of file diff --git a/src/gpu/GksVtkAdapter/VTKAdapter.cpp b/src/gpu/GksVtkAdapter/VTKAdapter.cpp deleted file mode 100644 index df81524982a73e82ac3e5f564a1b82b057196854..0000000000000000000000000000000000000000 --- a/src/gpu/GksVtkAdapter/VTKAdapter.cpp +++ /dev/null @@ -1,905 +0,0 @@ -#include "VTKAdapter.h" -#include "VTKInterface.h" - -#include <vtkImageData.h> - -#include <vtkCellData.h> -#include <vtkPointData.h> - -#include <vtkResampleWithDataSet.h> -#include <vtkPNGWriter.h> - -#include <vtkGeometryFilter.h> -#include <vtkCleanPolyData.h> -#include <vtkCellDataToPointData.h> -#include <vtkPointDataToCellData.h> - -#include "Core/DataTypes.h" -#include "Core/VectorTypes.h" -#include "Core/Logger/Logger.h" - -#include "GksGpu/Analyzer/TurbulenceAnalyzer.h" - -#include "GksGpu/BoundaryConditions/ConcreteHeatFlux.h" - -#include "GksGpu/Definitions/MemoryAccessPattern.h" -#include "GksGpu/FlowStateData/FlowStateData.cuh" -#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" - -vtkGridPtr getVtkUnstructuredOctGrid( SPtr<GksGpu::DataBase> dataBase, bool excludeGhostCells ) -{ - vtkGridPtr grid = vtkGridPtr::New(); - - vtkPointsPtr points = vtkPointsPtr::New(); - - ////////////////////////////////////////////////////////////////////////// - - for( uint nodeIdx = 0; nodeIdx < dataBase->numberOfNodes; nodeIdx++ ){ - - Vec3& node = dataBase->nodeCoordinates[ nodeIdx ]; - - points->InsertNextPoint( node.x, node.y, node.z ); - } - - grid->SetPoints( points ); - - ////////////////////////////////////////////////////////////////////////// - - for( uint cellIdx = 0; cellIdx < dataBase->numberOfCells; cellIdx++ ){ - - if( dataBase->isGhostCell( cellIdx ) && excludeGhostCells ) continue; - - vtkIdListPtr idList = vtkIdListPtr::New(); - - idList->SetNumberOfIds( 8 ); - - idList->SetId( 0, dataBase->cellToNode[ cellIdx ][ 0 ] ); - idList->SetId( 1, dataBase->cellToNode[ cellIdx ][ 1 ] ); - idList->SetId( 2, dataBase->cellToNode[ cellIdx ][ 2 ] ); - idList->SetId( 3, dataBase->cellToNode[ cellIdx ][ 3 ] ); - idList->SetId( 4, dataBase->cellToNode[ cellIdx ][ 4 ] ); - idList->SetId( 5, dataBase->cellToNode[ cellIdx ][ 5 ] ); - idList->SetId( 6, dataBase->cellToNode[ cellIdx ][ 6 ] ); - idList->SetId( 7, dataBase->cellToNode[ cellIdx ][ 7 ] ); - - grid->InsertNextCell( 12, idList ); - } - - ////////////////////////////////////////////////////////////////////////// - - return grid; -} - -void addScalarIntCellData( vtkGridPtr grid, - uint numberOfCells, - std::string name, - std::function<int(uint)> getData ) -{ - vtkIntArrayPtr data = vtkIntArrayPtr::New(); - - data->SetNumberOfComponents( 1 ); - - data->SetName( name.c_str() ); - - for( uint cellIdx = 0; cellIdx < numberOfCells; cellIdx++ ){ - data->InsertNextValue( getData(cellIdx) ); - } - - grid->GetCellData()->AddArray( data ); -} - -void addScalarRealCellData( vtkGridPtr grid, - uint numberOfCells, - std::string name, - std::function<real(uint)> getData ) -{ - vtkDoubleArrayPtr data = vtkDoubleArrayPtr::New(); - - data->SetNumberOfComponents( 1 ); - - data->SetName( name.c_str() ); - - for( uint cellIdx = 0; cellIdx < numberOfCells; cellIdx++ ){ - data->InsertNextValue( getData(cellIdx) ); - } - - grid->GetCellData()->AddArray( data ); -} - -void addVectorCellData( vtkGridPtr grid, - uint numberOfCells, - std::string name, - std::function<Vec3(uint)> getData ) -{ - vtkDoubleArrayPtr data = vtkDoubleArrayPtr::New(); - - data->SetNumberOfComponents( 3 ); - - data->SetName( name.c_str() ); - - for( uint cellIdx = 0; cellIdx < numberOfCells; cellIdx++ ){ - Vec3 vec = getData(cellIdx); - double tupel[3] = {vec.x, vec.y, vec.z}; - data->InsertNextTuple(tupel); - } - - grid->GetCellData()->AddArray( data ); -} - -void addBaseData(vtkGridPtr grid, SPtr<GksGpu::DataBase> dataBase, GksGpu::Parameters parameters) -{ - addScalarIntCellData( grid, dataBase->numberOfCells, "CellIdx", [&] (uint cellIdx) { - return cellIdx; - } ); - - addScalarRealCellData( grid, dataBase->numberOfCells, "rho", [&] (uint cellIdx) { - return dataBase->dataHost[ RHO__(cellIdx, dataBase->numberOfCells) ]; - } ); - - addScalarRealCellData( grid, dataBase->numberOfCells, "T", [&] (uint cellIdx) { - - GksGpu::ConservedVariables cons; - - cons.rho = dataBase->dataHost[ RHO__(cellIdx, dataBase->numberOfCells) ]; - cons.rhoU = dataBase->dataHost[ RHO_U(cellIdx, dataBase->numberOfCells) ]; - cons.rhoV = dataBase->dataHost[ RHO_V(cellIdx, dataBase->numberOfCells) ]; - cons.rhoW = dataBase->dataHost[ RHO_W(cellIdx, dataBase->numberOfCells) ]; - cons.rhoE = dataBase->dataHost[ RHO_E(cellIdx, dataBase->numberOfCells) ]; -#ifdef USE_PASSIVE_SCALAR - cons.rhoS_1 = dataBase->dataHost[ RHO_S_1(cellIdx, dataBase->numberOfCells) ]; - cons.rhoS_2 = dataBase->dataHost[ RHO_S_2(cellIdx, dataBase->numberOfCells) ]; -#endif // USE_PASSIVE_SCALAR - - GksGpu::PrimitiveVariables prim = toPrimitiveVariables(cons, parameters.K); - -#ifdef USE_PASSIVE_SCALAR - return getT(prim); -#else // USE_PASSIVE_SCALAR - return 1.0 / prim.lambda; -#endif // USE_PASSIVE_SCALAR - } ); - - addScalarRealCellData( grid, dataBase->numberOfCells, "lambda", [&] (uint cellIdx) { - - GksGpu::ConservedVariables cons; - - cons.rho = dataBase->dataHost[ RHO__(cellIdx, dataBase->numberOfCells) ]; - cons.rhoU = dataBase->dataHost[ RHO_U(cellIdx, dataBase->numberOfCells) ]; - cons.rhoV = dataBase->dataHost[ RHO_V(cellIdx, dataBase->numberOfCells) ]; - cons.rhoW = dataBase->dataHost[ RHO_W(cellIdx, dataBase->numberOfCells) ]; - cons.rhoE = dataBase->dataHost[ RHO_E(cellIdx, dataBase->numberOfCells) ]; -#ifdef USE_PASSIVE_SCALAR - cons.rhoS_1 = dataBase->dataHost[ RHO_S_1(cellIdx, dataBase->numberOfCells) ]; - cons.rhoS_2 = dataBase->dataHost[ RHO_S_2(cellIdx, dataBase->numberOfCells) ]; -#endif // USE_PASSIVE_SCALAR - - GksGpu::PrimitiveVariables prim = toPrimitiveVariables(cons, parameters.K); - - return prim.lambda; - } ); - - addScalarRealCellData( grid, dataBase->numberOfCells, "p", [&] (uint cellIdx) { - - GksGpu::ConservedVariables cons; - - cons.rho = dataBase->dataHost[ RHO__(cellIdx, dataBase->numberOfCells) ]; - cons.rhoU = dataBase->dataHost[ RHO_U(cellIdx, dataBase->numberOfCells) ]; - cons.rhoV = dataBase->dataHost[ RHO_V(cellIdx, dataBase->numberOfCells) ]; - cons.rhoW = dataBase->dataHost[ RHO_W(cellIdx, dataBase->numberOfCells) ]; - cons.rhoE = dataBase->dataHost[ RHO_E(cellIdx, dataBase->numberOfCells) ]; -#ifdef USE_PASSIVE_SCALAR - cons.rhoS_1 = dataBase->dataHost[ RHO_S_1(cellIdx, dataBase->numberOfCells) ]; - cons.rhoS_2 = dataBase->dataHost[ RHO_S_2(cellIdx, dataBase->numberOfCells) ]; -#endif // USE_PASSIVE_SCALAR - - GksGpu::PrimitiveVariables prim = toPrimitiveVariables(cons, parameters.K); - - return 0.5 * prim.rho / prim.lambda; - } ); - - addScalarIntCellData( grid, dataBase->numberOfCells, "GhostCell", [&] (uint cellIdx) -> int { - return dataBase->isGhostCell( cellIdx ); - } ); - - addScalarIntCellData( grid, dataBase->numberOfCells, "Level", [&] (uint cellIdx) { - return dataBase->getCellLevel(cellIdx); - } ); - - addVectorCellData( grid, dataBase->numberOfCells, "Velocity", [&] (uint cellIdx) { - - GksGpu::ConservedVariables cons; - - cons.rho = dataBase->dataHost[ RHO__(cellIdx, dataBase->numberOfCells) ]; - cons.rhoU = dataBase->dataHost[ RHO_U(cellIdx, dataBase->numberOfCells) ]; - cons.rhoV = dataBase->dataHost[ RHO_V(cellIdx, dataBase->numberOfCells) ]; - cons.rhoW = dataBase->dataHost[ RHO_W(cellIdx, dataBase->numberOfCells) ]; - cons.rhoE = dataBase->dataHost[ RHO_E(cellIdx, dataBase->numberOfCells) ]; - - GksGpu::PrimitiveVariables prim = toPrimitiveVariables( cons, parameters.K ); - - return Vec3( prim.U, prim.V, prim.W ); - } ); - -#ifdef USE_PASSIVE_SCALAR - addScalarRealCellData( grid, dataBase->numberOfCells, "Y_F", [&] (uint cellIdx) { - return dataBase->dataHost[ RHO_S_1(cellIdx, dataBase->numberOfCells) ] - / dataBase->dataHost[ RHO__(cellIdx, dataBase->numberOfCells) ]; - } ); - - addScalarRealCellData( grid, dataBase->numberOfCells, "Y_P", [&] (uint cellIdx) { - return dataBase->dataHost[ RHO_S_2(cellIdx, dataBase->numberOfCells) ] - / dataBase->dataHost[ RHO__(cellIdx, dataBase->numberOfCells) ]; - } ); - - addScalarRealCellData( grid, dataBase->numberOfCells, "Y_A", [&] (uint cellIdx) { - return c1o1 - dataBase->dataHost[ RHO_S_1(cellIdx, dataBase->numberOfCells) ] - / dataBase->dataHost[ RHO__ (cellIdx, dataBase->numberOfCells) ] - - dataBase->dataHost[ RHO_S_2(cellIdx, dataBase->numberOfCells) ] - / dataBase->dataHost[ RHO__ (cellIdx, dataBase->numberOfCells) ] - ; - } ); - - addScalarRealCellData( grid, dataBase->numberOfCells, "rhoE", [&] (uint cellIdx) { - return dataBase->dataHost[ RHO_E(cellIdx, dataBase->numberOfCells) ]; - } ); -#endif // USE_PASSIVE_SCALAR - - addScalarRealCellData( grid, dataBase->numberOfCells, "D_LES", [&] (uint cellIdx) { - return dataBase->diffusivityHost[ cellIdx ]; - } ); - -} - -void writeVtkUnstructuredGrid( vtkGridPtr grid, int mode, std::string filename ) -{ - vtkWriterPtr writer = vtkWriterPtr::New(); - - writer->SetDataMode(mode); - - filename += "."; - filename += writer->GetDefaultFileExtension(); - - writer->SetFileName( filename.c_str() ); - - writer->SetInputData( grid ); - - writer->Write(); -} - -void GKSVTKADAPTER_EXPORT writeVtkParallelUnstructuredGridSummaryFile(vtkGridPtr grid, std::string filename, uint mpiWorldSize) -{ - uint numberOfArrays = grid->GetCellData()->GetNumberOfArrays(); - - const auto filenameWithoutPath=filename.substr( filename.find_last_of('/') + 1 ); - - std::ofstream file; - - file.open( filename + ".pvtu" ); - - ////////////////////////////////////////////////////////////////////////// - - file << "<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">" << std::endl; - file << " <PUnstructuredGrid GhostLevel=\"1\">" << std::endl; - - file << " <PCellData>" << std::endl; - - for( uint i = 0; i < numberOfArrays; i++ ) - { - int typeID( grid->GetCellData()->GetArray(i)->GetDataType() ); - std::string name( grid->GetCellData()->GetArray(i)->GetName() ); - - uint numberOfComponents = grid->GetCellData()->GetArray(i)->GetNumberOfComponents(); - - std::string type; - if( typeID == VTK_INT ) type = "Int32"; - if( typeID == VTK_FLOAT ) type = "Float32"; - if( typeID == VTK_DOUBLE ) type = "Float64"; - - file << " <PDataArray type=\"" << type << "\" Name=\"" << name << "\" NumberOfComponents=\"" << numberOfComponents << "\"/>" << std::endl; - } - - file << " </PCellData>" << std::endl; - - file << " <PPoints>" << std::endl; - file << " <PDataArray type=\"Float32\" Name=\"Points\" NumberOfComponents=\"3\"/>" << std::endl; - file << " </PPoints>" << std::endl; - - for( uint rank = 0; rank < mpiWorldSize; rank++ ) - { - file << " <Piece Source=\"" << filenameWithoutPath << "_rank_" << rank << ".vtu\"/>" << std::endl; - } - - file << " </PUnstructuredGrid>" << std::endl; - file << "</VTKFile>" << std::endl; - - ////////////////////////////////////////////////////////////////////////// -} - -rgbColor colorMapCoolToWarmExtended( double value, double min, double max ) -{ - // Color map exported from Paraview - const double colorMap[36][3] = - /* 0 */ { { 0, 0, 0.34902 }, - /* 1 */ { 0.039216000000000001, 0.062744999999999995, 0.38039200000000001 }, - /* 2 */ { 0.062744999999999995, 0.117647, 0.41176499999999999 }, - /* 3 */ { 0.090195999999999998, 0.18431400000000001, 0.45097999999999999 }, - /* 4 */ { 0.12548999999999999, 0.26274500000000001, 0.50196099999999999 }, - /* 5 */ { 0.16078400000000001, 0.33725500000000003, 0.54117599999999999 }, - /* 6 */ { 0.20000000000000001, 0.39607799999999999, 0.56862699999999999 }, - /* 7 */ { 0.23921600000000001, 0.45490199999999997, 0.59999999999999998 }, - /* 8 */ { 0.286275, 0.52156899999999995, 0.65098 }, - /* 9 */ { 0.33725500000000003, 0.59215700000000004, 0.70196099999999995 }, - /* 10 */ { 0.388235, 0.65490199999999998, 0.74902000000000002 }, - /* 11 */ { 0.466667, 0.73725499999999999, 0.819608 }, - /* 12 */ { 0.57254899999999997, 0.819608, 0.87843099999999996 }, - /* 13 */ { 0.65490199999999998, 0.86666699999999997, 0.90980399999999995 }, - /* 14 */ { 0.75294099999999997, 0.91764699999999999, 0.94117600000000001 }, - /* 15 */ { 0.82352899999999996, 0.95686300000000002, 0.96862700000000002 }, - ///* 15 */ { 1.0, 1.0, 1.0 }, - /* 16 */ { 0.98823499999999997, 0.96078399999999997, 0.90196100000000001 }, - ///* 16 */ { 1.0, 1.0, 1.0 }, - - ///* 17 */ { 1.0, 1.0, 1.0 }, - /* 17 */ { 0.94117600000000001, 0.98431400000000002, 0.98823499999999997 }, - ///* 18 */ { 1.0, 1.0, 1.0 }, - /* 18 */ { 0.98823499999999997, 0.94509799999999999, 0.85097999999999996 }, - ///* 19 */ { 1.0, 1.0, 1.0 }, - /* 19 */ { 0.98039200000000004, 0.89803900000000003, 0.78431399999999996 }, - /* 20 */ { 0.96862700000000002, 0.83529399999999998, 0.69803899999999997 }, - /* 21 */ { 0.94901999999999997, 0.73333300000000001, 0.58823499999999995 }, - /* 22 */ { 0.92941200000000002, 0.65098, 0.50980400000000003 }, - /* 23 */ { 0.90980399999999995, 0.56470600000000004, 0.43529400000000001 }, - /* 24 */ { 0.87843099999999996, 0.45882400000000001, 0.352941 }, - /* 25 */ { 0.83921599999999996, 0.388235, 0.286275 }, - /* 26 */ { 0.76078400000000002, 0.29411799999999999, 0.21176500000000001 }, - /* 27 */ { 0.70196099999999995, 0.21176500000000001, 0.168627 }, - /* 28 */ { 0.65098, 0.156863, 0.129412 }, - /* 29 */ { 0.59999999999999998, 0.094117999999999993, 0.094117999999999993 }, - /* 30 */ { 0.54901999999999995, 0.066667000000000004, 0.098039000000000001 }, - /* 31 */ { 0.50196099999999999, 0.050979999999999998, 0.12548999999999999 }, - /* 32 */ { 0.45097999999999999, 0.054901999999999999, 0.17254900000000001 }, - /* 33 */ { 0.40000000000000002, 0.054901999999999999, 0.19215699999999999 }, - /* 34 */ { 0.34902, 0.070587999999999998, 0.21176500000000001 }, - { 0.34902, 0.070587999999999998, 0.21176500000000001 } }; - - if( value < min ) - value = 0.0; - else if ( value > max ) - value = 1.0; - else - value = ( value - min ) / ( max - min ); - - unsigned int idx = value * 34; - double interpolation = value * 34.0 - double( idx ); - - rgbColor color; - - color.r = ( ( 1.0 - interpolation ) * colorMap[idx ][0] - + interpolation * colorMap[idx+1][0] ) * 200.0 * 1.2; - - color.g = ( ( 1.0 - interpolation ) * colorMap[idx ][1] - + interpolation * colorMap[idx+1][1] ) * 197.0 * 1.2; - - color.b = ( ( 1.0 - interpolation ) * colorMap[idx ][2] - + interpolation * colorMap[idx+1][2] ) * 189.0 * 1.2; - - return color; -} - -void writePNG( vtkDataObject * inputData, int nx, int ny, double L, double H, std::string filename ) -{ - vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>::New(); - image->SetDimensions( nx, ny, 1 ); - image->SetSpacing( L / ( nx - 1 ), H / ( ny - 1 ), 0 ); - - vtkSmartPointer<vtkResampleWithDataSet> resample = vtkSmartPointer<vtkResampleWithDataSet>::New(); - resample->SetSourceData( inputData ); - resample->SetInputData( image ); - resample->Update(); - - vtkSmartPointer<vtkImageData> image2 = (vtkImageData*) resample->GetOutput(); - - image2->GetPointData()->SetScalars( image2->GetPointData()->GetArray( 0 ) ); - - vtkSmartPointer<vtkPNGWriter> writerPNG = vtkSmartPointer<vtkPNGWriter>::New(); - writerPNG->SetFileName( ( filename + ".png" ).c_str() ); - writerPNG->SetInputData( image2 ); - writerPNG->Write(); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void writeVtkXML(std::shared_ptr<GksGpu::DataBase> dataBase, - GksGpu::Parameters parameters, - int mode, - std::string filename) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Write " << filename << ".vtu" << " ... \n"; - - vtkGridPtr grid = getVtkUnstructuredOctGrid(dataBase); - - addBaseData( grid, dataBase, parameters ); - - writeVtkUnstructuredGrid( grid, vtkXMLWriter::Binary, filename ); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -void GKSVTKADAPTER_EXPORT writeVtkXMLParallelSummaryFile(std::shared_ptr<GksGpu::DataBase> dataBase, GksGpu::Parameters parameters, std::string filename, uint mpiWorldSize) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Write " << filename << ".pvtu" << " ... \n"; - - vtkGridPtr grid = getVtkUnstructuredOctGrid(dataBase); - - addBaseData( grid, dataBase, parameters ); - - writeVtkParallelUnstructuredGridSummaryFile( grid, filename, mpiWorldSize ); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -void writeTurbulenceVtkXML(std::shared_ptr<GksGpu::DataBase> dataBase, - std::shared_ptr<GksGpu::TurbulenceAnalyzer> turbulenceAnalyzer, - int mode, - std::string filename) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Write " << filename << ".vtu" << " ... \n"; - - vtkGridPtr grid = getVtkUnstructuredOctGrid(dataBase); - - addScalarIntCellData( grid, dataBase->numberOfCells, "CellIdx", [&] (uint cellIdx) { - return cellIdx; - } ); - - addScalarIntCellData( grid, dataBase->numberOfCells, "GhostCell", [&] (uint cellIdx) -> int { - return dataBase->isGhostCell( cellIdx ); - } ); - - ////////////////////////////////////////////////////////////////////////// - - if( turbulenceAnalyzer->collect_U ) - addScalarRealCellData(grid, dataBase->numberOfCells, "U", [&](uint cellIdx) { - return turbulenceAnalyzer->h_U[ cellIdx ]; - }); - - if( turbulenceAnalyzer->collect_V ) - addScalarRealCellData(grid, dataBase->numberOfCells, "V", [&](uint cellIdx) { - return turbulenceAnalyzer->h_V[ cellIdx ]; - }); - - if( turbulenceAnalyzer->collect_W ) - addScalarRealCellData(grid, dataBase->numberOfCells, "W", [&](uint cellIdx) { - return turbulenceAnalyzer->h_W[ cellIdx ]; - }); - - ////////////////////////////////////////////////////////////////////////// - - if( turbulenceAnalyzer->collect_UU ) - addScalarRealCellData(grid, dataBase->numberOfCells, "UU", [&](uint cellIdx) { - return turbulenceAnalyzer->h_UU[ cellIdx ]; - }); - - if( turbulenceAnalyzer->collect_VV ) - addScalarRealCellData(grid, dataBase->numberOfCells, "VV", [&](uint cellIdx) { - return turbulenceAnalyzer->h_VV[ cellIdx ]; - }); - - if( turbulenceAnalyzer->collect_WW ) - addScalarRealCellData(grid, dataBase->numberOfCells, "WW", [&](uint cellIdx) { - return turbulenceAnalyzer->h_WW[ cellIdx ]; - }); - - ////////////////////////////////////////////////////////////////////////// - - if( turbulenceAnalyzer->collect_UV ) - addScalarRealCellData(grid, dataBase->numberOfCells, "UV", [&](uint cellIdx) { - return turbulenceAnalyzer->h_UV[ cellIdx ]; - }); - - if( turbulenceAnalyzer->collect_UW ) - addScalarRealCellData(grid, dataBase->numberOfCells, "UW", [&](uint cellIdx) { - return turbulenceAnalyzer->h_UW[ cellIdx ]; - }); - - if( turbulenceAnalyzer->collect_VW ) - addScalarRealCellData(grid, dataBase->numberOfCells, "VW", [&](uint cellIdx) { - return turbulenceAnalyzer->h_VW[ cellIdx ]; - }); - - ////////////////////////////////////////////////////////////////////////// - - if( turbulenceAnalyzer->collect_T ) - addScalarRealCellData(grid, dataBase->numberOfCells, "T", [&](uint cellIdx) { - return turbulenceAnalyzer->h_T[ cellIdx ]; - }); - - if( turbulenceAnalyzer->collect_TT ) - addScalarRealCellData(grid, dataBase->numberOfCells, "TT", [&](uint cellIdx) { - return turbulenceAnalyzer->h_TT[ cellIdx ]; - }); - - if( turbulenceAnalyzer->collect_p ) - addScalarRealCellData(grid, dataBase->numberOfCells, "p", [&](uint cellIdx) { - return turbulenceAnalyzer->h_p[ cellIdx ]; - }); - - ////////////////////////////////////////////////////////////////////////// - - writeVtkUnstructuredGrid( grid, vtkXMLWriter::Binary, filename ); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -void GKSVTKADAPTER_EXPORT writeTurbulenceVtkXMLParallelSummaryFile(std::shared_ptr<GksGpu::DataBase> dataBase, std::shared_ptr<GksGpu::TurbulenceAnalyzer> turbulenceAnalyzer,GksGpu::Parameters parameters, std::string filename, uint mpiWorldSize) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Write " << filename << ".pvtu" << " ... \n"; - - vtkGridPtr grid = getVtkUnstructuredOctGrid(dataBase); - - ////////////////////////////////////////////////////////////////////////// - - const auto filenameWithoutPath=filename.substr( filename.find_last_of('/') + 1 ); - - std::ofstream file; - - file.open( filename + ".pvtu" ); - - ////////////////////////////////////////////////////////////////////////// - - file << "<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">" << std::endl; - file << " <PUnstructuredGrid GhostLevel=\"1\">" << std::endl; - - file << " <PCellData>" << std::endl; - - file << " <PDataArray type=\"" << "Int32" << "\" Name=\"" << "CellIdx" << "\" NumberOfComponents=\"1\"/>" << std::endl; - file << " <PDataArray type=\"" << "Int32" << "\" Name=\"" << "GhostCell" << "\" NumberOfComponents=\"1\"/>" << std::endl; - - if( turbulenceAnalyzer->collect_U ) file << " <PDataArray type=\"" << "Float64" << "\" Name=\"" << "U" << "\" NumberOfComponents=\"1\"/>" << std::endl; - if( turbulenceAnalyzer->collect_V ) file << " <PDataArray type=\"" << "Float64" << "\" Name=\"" << "V" << "\" NumberOfComponents=\"1\"/>" << std::endl; - if( turbulenceAnalyzer->collect_W ) file << " <PDataArray type=\"" << "Float64" << "\" Name=\"" << "W" << "\" NumberOfComponents=\"1\"/>" << std::endl; - - if( turbulenceAnalyzer->collect_UU ) file << " <PDataArray type=\"" << "Float64" << "\" Name=\"" << "UU" << "\" NumberOfComponents=\"1\"/>" << std::endl; - if( turbulenceAnalyzer->collect_VV ) file << " <PDataArray type=\"" << "Float64" << "\" Name=\"" << "VV" << "\" NumberOfComponents=\"1\"/>" << std::endl; - if( turbulenceAnalyzer->collect_WW ) file << " <PDataArray type=\"" << "Float64" << "\" Name=\"" << "WW" << "\" NumberOfComponents=\"1\"/>" << std::endl; - - if( turbulenceAnalyzer->collect_UV ) file << " <PDataArray type=\"" << "Float64" << "\" Name=\"" << "UV" << "\" NumberOfComponents=\"1\"/>" << std::endl; - if( turbulenceAnalyzer->collect_UW ) file << " <PDataArray type=\"" << "Float64" << "\" Name=\"" << "UW" << "\" NumberOfComponents=\"1\"/>" << std::endl; - if( turbulenceAnalyzer->collect_VW ) file << " <PDataArray type=\"" << "Float64" << "\" Name=\"" << "VW" << "\" NumberOfComponents=\"1\"/>" << std::endl; - - if( turbulenceAnalyzer->collect_T ) file << " <PDataArray type=\"" << "Float64" << "\" Name=\"" << "T" << "\" NumberOfComponents=\"1\"/>" << std::endl; - if( turbulenceAnalyzer->collect_TT ) file << " <PDataArray type=\"" << "Float64" << "\" Name=\"" << "TT" << "\" NumberOfComponents=\"1\"/>" << std::endl; - if( turbulenceAnalyzer->collect_p ) file << " <PDataArray type=\"" << "Float64" << "\" Name=\"" << "p" << "\" NumberOfComponents=\"1\"/>" << std::endl; - - file << " </PCellData>" << std::endl; - - file << " <PPoints>" << std::endl; - file << " <PDataArray type=\"Float32\" Name=\"Points\" NumberOfComponents=\"3\"/>" << std::endl; - file << " </PPoints>" << std::endl; - - for( uint rank = 0; rank < mpiWorldSize; rank++ ) - { - file << " <Piece Source=\"" << filenameWithoutPath << "_rank_" << rank << ".vtu\"/>" << std::endl; - } - - file << " </PUnstructuredGrid>" << std::endl; - file << "</VTKFile>" << std::endl; - - ////////////////////////////////////////////////////////////////////////// - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -void mapFlowField(std::shared_ptr<GksGpu::DataBase> base, std::shared_ptr<GksGpu::DataBase> target) -{ - vtkGridPtr gridBase = getVtkUnstructuredOctGrid(base, true); - vtkGridPtr gridTarget = getVtkUnstructuredOctGrid(target, true); - - ////////////////////////////////////////////////////////////////////////// - - vtkSmartPointer<vtkDoubleArray> rho = vtkSmartPointer<vtkDoubleArray>::New(); - vtkSmartPointer<vtkDoubleArray> rhoU = vtkSmartPointer<vtkDoubleArray>::New(); - vtkSmartPointer<vtkDoubleArray> rhoE = vtkSmartPointer<vtkDoubleArray>::New(); - - rho->SetNumberOfComponents ( 1 ); - rhoU->SetNumberOfComponents( 3 ); - rhoE->SetNumberOfComponents( 1 ); - - rho->SetName ( "rho" ); - rhoU->SetName( "rhoU" ); - rhoE->SetName( "rhoW" ); - - for( uint cellIdx = 0; cellIdx < base->numberOfCells; cellIdx++ ){ - - if( base->isGhostCell( cellIdx ) ) continue; - - GksGpu::ConservedVariables cons; - - cons.rho = base->dataHost[ RHO__(cellIdx, base->numberOfCells) ]; - cons.rhoU = base->dataHost[ RHO_U(cellIdx, base->numberOfCells) ]; - cons.rhoV = base->dataHost[ RHO_V(cellIdx, base->numberOfCells) ]; - cons.rhoW = base->dataHost[ RHO_W(cellIdx, base->numberOfCells) ]; - cons.rhoE = base->dataHost[ RHO_E(cellIdx, base->numberOfCells) ]; - - rho->InsertNextTuple1 ( cons.rho ); - rhoU->InsertNextTuple3( cons.rhoU, cons.rhoV, cons.rhoW ); - rhoE->InsertNextTuple1( cons.rhoE ); - } - - gridBase->GetCellData()->AddArray( rho ); - gridBase->GetCellData()->AddArray( rhoU ); - gridBase->GetCellData()->AddArray( rhoE ); - -#ifdef USE_PASSIVE_SCALAR - - vtkSmartPointer<vtkDoubleArray> dataS_1 = vtkSmartPointer<vtkDoubleArray>::New(); - vtkSmartPointer<vtkDoubleArray> dataS_2 = vtkSmartPointer<vtkDoubleArray>::New(); - - dataS_1->SetNumberOfComponents(1); - dataS_2->SetNumberOfComponents(1); - - dataS_1->SetName("rhoS_1"); - dataS_2->SetName("rhoS_2"); - - for (uint cellIdx = 0; cellIdx < base->numberOfCells; cellIdx++) { - - if (base->isGhostCell(cellIdx)) continue; - - dataS_1->InsertNextTuple1(base->dataHost[RHO_S_1(cellIdx, base->numberOfCells)]); - dataS_2->InsertNextTuple1(base->dataHost[RHO_S_2(cellIdx, base->numberOfCells)]); - } - - gridBase->GetCellData()->AddArray(dataS_1); - gridBase->GetCellData()->AddArray(dataS_2); - -#endif // USE_PASSIVE_SCALAR - - ////////////////////////////////////////////////////////////////////////// - - vtkSmartPointer<vtkCellDataToPointData> cellDataToPointDataBase = vtkSmartPointer<vtkCellDataToPointData>::New(); - cellDataToPointDataBase->SetInputData( gridBase ); - cellDataToPointDataBase->Update(); - - vtkSmartPointer<vtkGeometryFilter> gridToPolyDataBase = vtkSmartPointer<vtkGeometryFilter>::New(); - gridToPolyDataBase->SetInputConnection( cellDataToPointDataBase->GetOutputPort() ); - gridToPolyDataBase->Update(); - - vtkSmartPointer<vtkCleanPolyData> cleanPolyData = vtkSmartPointer<vtkCleanPolyData>::New(); - cleanPolyData->SetInputConnection( gridToPolyDataBase->GetOutputPort() ); - cleanPolyData->Update(); - - vtkSmartPointer<vtkResampleWithDataSet> resampleWithDataSet = vtkSmartPointer<vtkResampleWithDataSet>::New(); - resampleWithDataSet->SetSourceConnection( cleanPolyData->GetOutputPort() ); - resampleWithDataSet->SetInputData( gridTarget ); - resampleWithDataSet->Update(); - - vtkSmartPointer<vtkPointDataToCellData> pointDataToCellDataTarget = vtkSmartPointer<vtkPointDataToCellData>::New(); - pointDataToCellDataTarget->SetInputConnection( resampleWithDataSet->GetOutputPort() ); - pointDataToCellDataTarget->Update(); - - gridTarget = (vtkUnstructuredGrid*) pointDataToCellDataTarget->GetOutput(); - - ////////////////////////////////////////////////////////////////////////// - - for( uint cellIdx = 0, gridCellIdx = 0; cellIdx < target->numberOfCells; cellIdx++ ){ - - if( target->isGhostCell( cellIdx ) ) continue; - - double rho = gridTarget->GetCellData()->GetArray(1)->GetTuple1(gridCellIdx); - double* rhoU = gridTarget->GetCellData()->GetArray(2)->GetTuple3(gridCellIdx); - double rhoE = gridTarget->GetCellData()->GetArray(3)->GetTuple1(gridCellIdx); - - target->dataHost[ RHO__(cellIdx, target->numberOfCells) ] = rho; - target->dataHost[ RHO_U(cellIdx, target->numberOfCells) ] = rhoU[0]; - target->dataHost[ RHO_V(cellIdx, target->numberOfCells) ] = rhoU[1]; - target->dataHost[ RHO_W(cellIdx, target->numberOfCells) ] = rhoU[2]; - target->dataHost[ RHO_E(cellIdx, target->numberOfCells) ] = rhoE; - -#ifdef USE_PASSIVE_SCALAR - { - double rhoS_1 = gridTarget->GetCellData()->GetArray(4)->GetTuple1(gridCellIdx); - double rhoS_2 = gridTarget->GetCellData()->GetArray(5)->GetTuple1(gridCellIdx); - - target->dataHost[RHO_S_1(cellIdx, target->numberOfCells)] = rhoS_1; - target->dataHost[RHO_S_2(cellIdx, target->numberOfCells)] = rhoS_2; - } -#endif // USE_PASSIVE_SCALAR - - gridCellIdx++; - } -} - -void GKSVTKADAPTER_EXPORT writeConcreteHeatFluxVtkXML(std::shared_ptr<GksGpu::DataBase> dataBase, std::shared_ptr<GksGpu::ConcreteHeatFlux> bc, GksGpu::Parameters parameters, int mode, std::string filename) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Write " << filename << ".vtu" << " ... \n"; - - bc->download(); - - vtkGridPtr grid = vtkGridPtr::New(); - - vtkPointsPtr points = vtkPointsPtr::New(); - - ////////////////////////////////////////////////////////////////////////// - - for( uint index = 0; index < bc->numberOfCells; index ++ ) - { - if( bc->domainCellsHost[index] > dataBase->perLevelCount[ dataBase->getCellLevel( bc->domainCellsHost[index] ) ].startOfCells - + dataBase->perLevelCount[ dataBase->getCellLevel( bc->domainCellsHost[index] ) ].numberOfBulkCells ) continue; - - if( GksGpu::isCellProperties( dataBase->cellPropertiesHost[ bc->domainCellsHost[index] ], CELL_PROPERTIES_FINE_GHOST ) ) continue; - - real dx = bc->L / real(bc->numberOfPoints + 1); - - Vec3 displacement = dataBase->nodeCoordinates[ dataBase->cellToNode[ bc->ghostCellsHost [index] ][0] ] - - dataBase->nodeCoordinates[ dataBase->cellToNode[ bc->domainCellsHost[index] ][0] ]; - real dn = displacement.length(); - displacement = ( c1o1 / displacement.length() ) * displacement; - - char direction = 'z'; - if ( std::abs(displacement.x) > std::abs(displacement.y) && std::abs(displacement.x) > std::abs(displacement.z) ) direction = 'x'; - if ( std::abs(displacement.y) > std::abs(displacement.x) && std::abs(displacement.y) > std::abs(displacement.z) ) direction = 'y'; - - Vec3 dn1, dn2, dn3, dn4; - if( direction == 'x' ) - { - dn1.y = c1o2*dn; dn1.z = c1o2*dn; - dn2.y = -c1o2*dn; dn2.z = c1o2*dn; - dn3.y = -c1o2*dn; dn3.z = -c1o2*dn; - dn4.y = c1o2*dn; dn4.z = -c1o2*dn; - } - if( direction == 'y' ) - { - dn1.x = c1o2*dn; dn1.z = c1o2*dn; - dn2.x = -c1o2*dn; dn2.z = c1o2*dn; - dn3.x = -c1o2*dn; dn3.z = -c1o2*dn; - dn4.x = c1o2*dn; dn4.z = -c1o2*dn; - } - if( direction == 'z' ) - { - dn1.x = c1o2*dn; dn1.y = c1o2*dn; - dn2.x = -c1o2*dn; dn2.y = c1o2*dn; - dn3.x = -c1o2*dn; dn3.y = -c1o2*dn; - dn4.x = c1o2*dn; dn4.y = -c1o2*dn; - } - - Vec3 faceCenter; - for( uint i = 0; i < 8; i++ ) - { - faceCenter = faceCenter + dataBase->nodeCoordinates[ dataBase->cellToNode[ bc->ghostCellsHost [index] ][i] ]; - faceCenter = faceCenter + dataBase->nodeCoordinates[ dataBase->cellToNode[ bc->domainCellsHost[index] ][i] ]; - } - faceCenter = c1o16 * faceCenter; - - uint nodeStartNumber = points->GetNumberOfPoints(); - - ////////////////////////////////////////////////////////////////////////// - - Vec3 tmp; - - tmp = faceCenter + dn1; points->InsertNextPoint( tmp.x, tmp.y, tmp.z ); - tmp = faceCenter + dn2; points->InsertNextPoint( tmp.x, tmp.y, tmp.z ); - tmp = faceCenter + dn3; points->InsertNextPoint( tmp.x, tmp.y, tmp.z ); - tmp = faceCenter + dn4; points->InsertNextPoint( tmp.x, tmp.y, tmp.z ); - - for( uint i = 1; i <= bc->numberOfPoints; i++ ) - { - Vec3 localDisplacement = real(i) * dx * displacement; - tmp = faceCenter + localDisplacement + dn1; points->InsertNextPoint( tmp.x, tmp.y, tmp.z ); - tmp = faceCenter + localDisplacement + dn2; points->InsertNextPoint( tmp.x, tmp.y, tmp.z ); - tmp = faceCenter + localDisplacement + dn3; points->InsertNextPoint( tmp.x, tmp.y, tmp.z ); - tmp = faceCenter + localDisplacement + dn4; points->InsertNextPoint( tmp.x, tmp.y, tmp.z ); - } - - Vec3 localDisplacement = bc->L * displacement; - tmp = faceCenter + localDisplacement + dn1; points->InsertNextPoint( tmp.x, tmp.y, tmp.z ); - tmp = faceCenter + localDisplacement + dn2; points->InsertNextPoint( tmp.x, tmp.y, tmp.z ); - tmp = faceCenter + localDisplacement + dn3; points->InsertNextPoint( tmp.x, tmp.y, tmp.z ); - tmp = faceCenter + localDisplacement + dn4; points->InsertNextPoint( tmp.x, tmp.y, tmp.z ); - - ////////////////////////////////////////////////////////////////////////// - - for( uint i = 0; i <= bc->numberOfPoints; i++ ) - { - vtkIdListPtr idList = vtkIdListPtr::New(); - - idList->SetNumberOfIds( 8 ); - - idList->SetId( 0, nodeStartNumber + (i ) * 4 ); - idList->SetId( 1, nodeStartNumber + (i ) * 4 + 1 ); - idList->SetId( 2, nodeStartNumber + (i ) * 4 + 2 ); - idList->SetId( 3, nodeStartNumber + (i ) * 4 + 3 ); - idList->SetId( 4, nodeStartNumber + (i + 1) * 4 ); - idList->SetId( 5, nodeStartNumber + (i + 1) * 4 + 1 ); - idList->SetId( 6, nodeStartNumber + (i + 1) * 4 + 2 ); - idList->SetId( 7, nodeStartNumber + (i + 1) * 4 + 3 ); - - grid->InsertNextCell( 12, idList ); - } - } - - grid->SetPoints( points ); - - ////////////////////////////////////////////////////////////////////////// - - vtkDoubleArrayPtr data = vtkDoubleArrayPtr::New(); - - data->SetNumberOfComponents( 1 ); - - data->SetName( "T" ); - - for( uint cellIdx = 0; cellIdx < bc->numberOfCells; cellIdx++ ) - { - if( bc->domainCellsHost[cellIdx] > dataBase->perLevelCount[ dataBase->getCellLevel( bc->domainCellsHost[cellIdx] ) ].startOfCells - + dataBase->perLevelCount[ dataBase->getCellLevel( bc->domainCellsHost[cellIdx] ) ].numberOfBulkCells ) continue; - - if( GksGpu::isCellProperties( dataBase->cellPropertiesHost[ bc->domainCellsHost[cellIdx] ], CELL_PROPERTIES_FINE_GHOST ) ) continue; - - real T = c0o1; - - { - GksGpu::ConservedVariables cons; - - cons.rho = dataBase->dataHost[RHO__(bc->domainCellsHost[cellIdx], dataBase->numberOfCells)]; - cons.rhoU = dataBase->dataHost[RHO_U(bc->domainCellsHost[cellIdx], dataBase->numberOfCells)]; - cons.rhoV = dataBase->dataHost[RHO_V(bc->domainCellsHost[cellIdx], dataBase->numberOfCells)]; - cons.rhoW = dataBase->dataHost[RHO_W(bc->domainCellsHost[cellIdx], dataBase->numberOfCells)]; - cons.rhoE = dataBase->dataHost[RHO_E(bc->domainCellsHost[cellIdx], dataBase->numberOfCells)]; - - GksGpu::PrimitiveVariables prim = GksGpu::toPrimitiveVariables(cons, parameters.K); - -#ifdef USE_PASSIVE_SCALAR - T += c3o2 * getT(prim); - //T += getT(prim); -#else // USE_PASSIVE_SCALAR - T += c3o2 * 1.0 / prim.lambda; -#endif // USE_PASSIVE_SCALAR - } - - { - GksGpu::ConservedVariables cons; - - cons.rho = dataBase->dataHost[RHO__(bc->secondCellsHost[cellIdx], dataBase->numberOfCells)]; - cons.rhoU = dataBase->dataHost[RHO_U(bc->secondCellsHost[cellIdx], dataBase->numberOfCells)]; - cons.rhoV = dataBase->dataHost[RHO_V(bc->secondCellsHost[cellIdx], dataBase->numberOfCells)]; - cons.rhoW = dataBase->dataHost[RHO_W(bc->secondCellsHost[cellIdx], dataBase->numberOfCells)]; - cons.rhoE = dataBase->dataHost[RHO_E(bc->secondCellsHost[cellIdx], dataBase->numberOfCells)]; - - GksGpu::PrimitiveVariables prim = GksGpu::toPrimitiveVariables(cons, parameters.K); - -#ifdef USE_PASSIVE_SCALAR - T -= c1o2 * getT(prim); -#else // USE_PASSIVE_SCALAR - T -= c1o2 * 1.0 / prim.lambda; -#endif // USE_PASSIVE_SCALAR - } - - data->InsertNextValue(T); - data->InsertNextValue(T); - data->InsertNextValue(T); - data->InsertNextValue(T); - - for( uint i = 0; i < bc->numberOfPoints; i++ ) - { - data->InsertNextValue(bc->temperaturesHost[ bc->numberOfPoints * cellIdx + i ]); - data->InsertNextValue(bc->temperaturesHost[ bc->numberOfPoints * cellIdx + i ]); - data->InsertNextValue(bc->temperaturesHost[ bc->numberOfPoints * cellIdx + i ]); - data->InsertNextValue(bc->temperaturesHost[ bc->numberOfPoints * cellIdx + i ]); - } - - data->InsertNextValue(bc->ambientTemperature); - data->InsertNextValue(bc->ambientTemperature); - data->InsertNextValue(bc->ambientTemperature); - data->InsertNextValue(bc->ambientTemperature); - } - - grid->GetPointData()->AddArray( data ); - - ////////////////////////////////////////////////////////////////////////// - - writeVtkUnstructuredGrid( grid, vtkXMLWriter::Binary, filename ); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} \ No newline at end of file diff --git a/src/gpu/GksVtkAdapter/VTKAdapter.h b/src/gpu/GksVtkAdapter/VTKAdapter.h deleted file mode 100644 index 5f3209a04e0d7942f890f2186779e75c6f14683f..0000000000000000000000000000000000000000 --- a/src/gpu/GksVtkAdapter/VTKAdapter.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef VTKAdapter_H -#define VTKAdapter_H - -#include <vtkSmartPointer.h> -#include <vtkVersion.h> - -#include <vtkPoints.h> -#include <vtkUnstructuredGrid.h> -#include <vtkDataObject.h> - - -#include <vtkIdList.h> - -#include <vtkIntArray.h> -#include <vtkDoubleArray.h> - -#include <vtkXMLUnstructuredGridWriter.h> - -#include <memory> -#include <functional> -#include <string> - -#include "PointerDefinitions.h" - - - -#include "DataBase/DataBase.h" -#include "Parameters/Parameters.h" - -#include "GksVtkAdapter_export.h" - -typedef vtkSmartPointer<vtkUnstructuredGrid> vtkGridPtr; -typedef vtkSmartPointer<vtkPoints> vtkPointsPtr; -typedef vtkSmartPointer<vtkIdList> vtkIdListPtr; -typedef vtkSmartPointer<vtkIntArray> vtkIntArrayPtr; -typedef vtkSmartPointer<vtkDoubleArray> vtkDoubleArrayPtr; -typedef vtkSmartPointer<vtkXMLUnstructuredGridWriter> vtkWriterPtr; - -struct rgbColor -{ - unsigned char r; - unsigned char g; - unsigned char b; -}; - -vtkGridPtr GKSVTKADAPTER_EXPORT getVtkUnstructuredOctGrid( SPtr<GksGpu::DataBase> dataBase, bool excludeGhostCells = false ); - -void GKSVTKADAPTER_EXPORT addScalarIntCellData( vtkGridPtr grid, - uint numberOfCells, - std::string name, - std::function<int(uint)> getData ); - -void GKSVTKADAPTER_EXPORT addScalarRealCellData( vtkGridPtr grid, - uint numberOfCells, - std::string name, - std::function<real(uint)> getData ); - -void GKSVTKADAPTER_EXPORT addVectorCellData( vtkGridPtr grid, - uint numberOfCells, - std::string name, - std::function<Vec3(uint)> getData ); - -void GKSVTKADAPTER_EXPORT addBaseData( vtkGridPtr grid, SPtr<GksGpu::DataBase> dataBase, GksGpu::Parameters parameters ); - -void GKSVTKADAPTER_EXPORT writeVtkUnstructuredGrid( vtkGridPtr grid, int mode, std::string filename ); - -void GKSVTKADAPTER_EXPORT writeVtkParallelUnstructuredGridSummaryFile( vtkGridPtr grid, std::string filename, uint mpiWorldSize ); - -rgbColor GKSVTKADAPTER_EXPORT colorMapCoolToWarmExtended( double value, double min, double max ); - -void GKSVTKADAPTER_EXPORT writePNG( vtkDataObject* inputData, int nx, int ny, double L, double H, std::string filename ); - -#endif \ No newline at end of file diff --git a/src/gpu/GksVtkAdapter/VTKInterface.h b/src/gpu/GksVtkAdapter/VTKInterface.h deleted file mode 100644 index 0120a7ad19d059a830530857b3ae118b4a50d224..0000000000000000000000000000000000000000 --- a/src/gpu/GksVtkAdapter/VTKInterface.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef VTKInterface_H -#define VTKInterface_H - -#include "GksGpu/Parameters/Parameters.h" - - -#include "GksVtkAdapter_export.h" - -namespace GksGpu{ -struct DataBase; -class TurbulenceAnalyzer; -struct ConcreteHeatFlux; -} - -void GKSVTKADAPTER_EXPORT writeVtkXML(std::shared_ptr<GksGpu::DataBase> dataBase, - GksGpu::Parameters parameters, - int mode, - std::string filename); - -void GKSVTKADAPTER_EXPORT writeVtkXMLParallelSummaryFile(std::shared_ptr<GksGpu::DataBase> dataBase, - GksGpu::Parameters parameters, - std::string filename, - uint mpiWorldSize); - -void GKSVTKADAPTER_EXPORT writeTurbulenceVtkXML(std::shared_ptr<GksGpu::DataBase> dataBase, - std::shared_ptr<GksGpu::TurbulenceAnalyzer> turbulenceAnalyzer, - int mode, - std::string filename); - -void GKSVTKADAPTER_EXPORT writeTurbulenceVtkXMLParallelSummaryFile(std::shared_ptr<GksGpu::DataBase> dataBase, - std::shared_ptr<GksGpu::TurbulenceAnalyzer> turbulenceAnalyzer, - GksGpu::Parameters parameters, - std::string filename, - uint mpiWorldSize); - -void GKSVTKADAPTER_EXPORT mapFlowField( std::shared_ptr<GksGpu::DataBase> base, std::shared_ptr<GksGpu::DataBase> target ); - -void GKSVTKADAPTER_EXPORT writeConcreteHeatFluxVtkXML(std::shared_ptr<GksGpu::DataBase> dataBase, - std::shared_ptr<GksGpu::ConcreteHeatFlux> bc, - GksGpu::Parameters parameters, - int mode, - std::string filename); - -#endif \ No newline at end of file diff --git a/src/gpu/GridGenerator/CMakeLists.txt b/src/gpu/GridGenerator/CMakeLists.txt index 8102ad3a10b53dded2ba6fe489753f20d1d2ed4f..7cc0f0e20e2b43601f9f70e639d0ecd61cadb2ae 100644 --- a/src/gpu/GridGenerator/CMakeLists.txt +++ b/src/gpu/GridGenerator/CMakeLists.txt @@ -1,6 +1,6 @@ project(GridGenerator LANGUAGES CXX) -vf_add_library(PRIVATE_LINK basics OpenMP::OpenMP_CXX) +vf_add_library(PUBLIC_LINK basics logger OpenMP::OpenMP_CXX) vf_add_tests() if(NOT MSVC) diff --git a/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.cpp b/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.cpp deleted file mode 100644 index bac17264d1c00389bbefacc4063d7801e8f5baa7..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.cpp +++ /dev/null @@ -1,145 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file JunctionReader.cpp -//! \ingroup StreetPointFinder -//! \author Stephan Lenz -//======================================================================================= -#include "JunctionReader.h" - -#include <fstream> -#include <iostream> -#include <string> - - -JunctionReaderData::JunctionReaderData(std::vector<uint> inCells, std::vector<uint> outCells, std::vector<int> carCanNotEnterThisOutCell, uint trafficLightSwitchTime = 0) : - inCells{ inCells }, outCells{ outCells }, carCanNotEnterThisOutCell{ carCanNotEnterThisOutCell }, trafficLightSwitchTime{ trafficLightSwitchTime } -{} - -void JunctionReader::readJunctions(std::string filename, StreetPointFinder* streetPointFinder) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::readJunctions( " << filename << " )" << "\n"; - - std::ifstream file; - file.open(filename.c_str()); - if (!file.is_open()) std::cerr << "File not found" << std::endl; - this->streetPointFinder = streetPointFinder; - - uint numberOfJunctions; - file >> numberOfJunctions; - - std::string inOutDummy; - int streetIndex = 0; - uint trafficLightTime = 0; - bool onlyNeighbors = false; - - file >> inOutDummy; - - for (uint i = 0; i < numberOfJunctions; i++) { - std::vector<uint> inCells, outCells; - std::vector<int> carCanNotEnterThisOutCell; - - //inCells - file >> inOutDummy; - while (inOutDummy.compare("out") != 0) { - streetIndex = std::stoi(inOutDummy); - - if (streetIndex >= 0) - inCells.push_back(getCellIndex(streetIndex, 'e')); - - file >> inOutDummy; - } - - //outCells - file >> inOutDummy; - while (inOutDummy.compare("in") != 0 && inOutDummy.compare("end") != 0 && inOutDummy.compare("t") != 0 && inOutDummy.compare("c") != 0) { - streetIndex = std::stoi(inOutDummy); - - if (streetIndex >= 0) { - outCells.push_back(getCellIndex(streetIndex, 's')); - if (carCanNotEnterThisOutCell.size() < inCells.size()) - carCanNotEnterThisOutCell.push_back(getCellIndex(streetIndex, 's')); - } - else if (streetIndex == -2) //no prohibited outCell - carCanNotEnterThisOutCell.push_back(-2); - - file >> inOutDummy; - } - - //trafficLightTime - if (inOutDummy.compare("t") == 0) { - file >> inOutDummy; - trafficLightTime = std::stoi(inOutDummy); - file >> inOutDummy; - } - else - trafficLightTime = 0; - - // only neighbors (used for curves) - if (inOutDummy.compare("c") == 0) { - onlyNeighbors = true; - file >> inOutDummy; - } - - - //make Junction or neighbors - if (onlyNeighbors) { - if (inCells.size() == 2 && outCells.size() == 2) { - specialNeighbors.cells.insert(specialNeighbors.cells.end(), inCells.begin(), inCells.end()); - specialNeighbors.neighbors.push_back(outCells[1]); - specialNeighbors.neighbors.push_back(outCells[0]); - - onlyNeighbors = false; - } - else - { - // TODO: this could be a bug, as before this change "continue" was not guarded by the "else" - // https://git.rz.tu-bs.de/irmb/VirtualFluids_dev/-/issues/11 - std::cerr << "can't add curve" << std::endl; - continue; - } - } - else - junctions.push_back(JunctionReaderData(inCells, outCells, carCanNotEnterThisOutCell, trafficLightTime)); - - } -} - - -unsigned int JunctionReader::getCellIndex(unsigned int streetIndex, char startOrEnd) -{ - uint i = 0; - unsigned int cellIndex = 0; - while (i < streetIndex) { - cellIndex += streetPointFinder->streets[i].numberOfCells; - ++i; - } - if (startOrEnd == 's') return cellIndex; - return cellIndex + streetPointFinder->streets[streetIndex].numberOfCells - 1; -} - diff --git a/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.h b/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.h deleted file mode 100644 index 5b68b0357ea2432dfde6d167b27908fe1aa4348a..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/StreetPointFinder/JunctionReader.h +++ /dev/null @@ -1,78 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file JunctionReader.h -//! \ingroup StreetPointFinder -//! \author Stephan Lenz -//======================================================================================= -#ifndef JUNCTIONREADER_H -#define JUNCTIONREADER_H - -#include <vector> - -#include "GridGenerator_export.h" - -#include "Core/DataTypes.h" -#include "Core/Logger/Logger.h" - -#include "StreetPointFinder.h" - - - -struct GRIDGENERATOR_EXPORT JunctionReaderData -{ - std::vector<uint> inCells; - std::vector<uint> outCells; - std::vector<int> carCanNotEnterThisOutCell; - uint trafficLightSwitchTime; - - JunctionReaderData(std::vector<uint> inCells, std::vector<uint> outCells, std::vector<int> carCanNotEnterThisOutCell, uint trafficLightSwitchTime); -}; - - -struct GRIDGENERATOR_EXPORT Neighbors -{ - std::vector<int> cells; - std::vector<int> neighbors; -}; - - - -struct GRIDGENERATOR_EXPORT JunctionReader -{ - std::vector<JunctionReaderData> junctions; - Neighbors specialNeighbors; - StreetPointFinder* streetPointFinder; - - void readJunctions(std::string filename, StreetPointFinder* streetPointFinder); - - -private: - unsigned int getCellIndex(unsigned int streetIndex, char startOrEnd); -}; -#endif diff --git a/src/gpu/GridGenerator/StreetPointFinder/SinkReader.cpp b/src/gpu/GridGenerator/StreetPointFinder/SinkReader.cpp deleted file mode 100644 index 1224f1bf7cad8e535e842426406aacc619dad314..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/StreetPointFinder/SinkReader.cpp +++ /dev/null @@ -1,75 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file SinkReader.cpp -//! \ingroup StreetPointFinder -//! \author Stephan Lenz -//======================================================================================= -#include "SinkReader.h" - -#include <fstream> -#include <iostream> - -SinkReaderData::SinkReaderData(uint sinkIndex, float sinkBlockedPossibility) : - sinkIndex{ sinkIndex }, sinkBlockedPossibility{ sinkBlockedPossibility } -{} - -void SinkReader::readSinks(std::string filename, StreetPointFinder* streetPointFinder) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::readSinks( " << filename << " )" << "\n"; - - this->streetPointFinder = streetPointFinder; - - std::ifstream file; - file.open(filename.c_str()); - if (!file.is_open()) std::cerr << "File not found" << std::endl; - - uint numberOfSinks; - file >> numberOfSinks; - - uint streetIndex; - float sinkBlockedPossibility; - - - for (uint i = 0; i < numberOfSinks; i++) { - file >> streetIndex >> sinkBlockedPossibility; - sinks.push_back(SinkReaderData(getCellIndexEnd(streetIndex), sinkBlockedPossibility)); - } -} - -unsigned int SinkReader::getCellIndexEnd(unsigned int streetIndex) -{ - uint i = 0; - unsigned int cellIndex = 0; - while (i < streetIndex) { - cellIndex += streetPointFinder->streets[i].numberOfCells; - ++i; - } - - return cellIndex + streetPointFinder->streets[streetIndex].numberOfCells - 1; -} diff --git a/src/gpu/GridGenerator/StreetPointFinder/SinkReader.h b/src/gpu/GridGenerator/StreetPointFinder/SinkReader.h deleted file mode 100644 index ba28596b0eb63954eb5f7162c4849f863e15f657..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/StreetPointFinder/SinkReader.h +++ /dev/null @@ -1,65 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file SinkReader.h -//! \ingroup StreetPointFinder -//! \author Stephan Lenz -//======================================================================================= -#ifndef SINKREADER_H -#define SINKREADER_H - -#include <vector> - -#include "GridGenerator_export.h" - -#include "Core/DataTypes.h" -#include "Core/Logger/Logger.h" - -#include "StreetPointFinder.h" - - - -struct GRIDGENERATOR_EXPORT SinkReaderData{ - uint sinkIndex; - float sinkBlockedPossibility; - SinkReaderData(uint sinkIndex, float sinkBlockedPossibility); -}; - -struct GRIDGENERATOR_EXPORT SinkReader -{ - std::vector<SinkReaderData> sinks; - StreetPointFinder* streetPointFinder; - - void readSinks(std::string filename, StreetPointFinder* streetPointFinder); - -private: - unsigned int getCellIndexEnd(unsigned int streetIndex); -}; - - -#endif \ No newline at end of file diff --git a/src/gpu/GridGenerator/StreetPointFinder/SourceReader.cpp b/src/gpu/GridGenerator/StreetPointFinder/SourceReader.cpp deleted file mode 100644 index a3a62f942f96fa1faf9e49448ed3ae627d985273..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/StreetPointFinder/SourceReader.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file SourceReader.cpp -//! \ingroup StreetPointFinder -//! \author Stephan Lenz -//======================================================================================= -#include "SourceReader.h" - -#include <fstream> -#include <iostream> - -SourceReaderData::SourceReaderData(unsigned int sourceIndex, float sourcePossibility): - sourceIndex{sourceIndex}, sourcePossibility{sourcePossibility} -{} - - -void SourceReader::readSources(std::string filename, StreetPointFinder* streetPointFinder) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::readSources( " << filename << " )" << "\n"; - - this->streetPointFinder = streetPointFinder; - - std::ifstream file; - file.open(filename.c_str()); - if (!file.is_open()) std::cerr << "File not found" << std::endl; - - uint numberOfSources; - file >> numberOfSources; - - uint streetIndex; - float sourcePossibility; - - - for (uint i = 0; i < numberOfSources; i++) { - file >> streetIndex >> sourcePossibility; - sources.push_back(SourceReaderData(getCellIndexStart(streetIndex), sourcePossibility)); - } -} - - -unsigned int SourceReader::getCellIndexStart(unsigned int streetIndex) -{ - uint i = 0; - unsigned int cellIndex = 0; - while (i < streetIndex) { - cellIndex += streetPointFinder->streets[i].numberOfCells; - ++i; - } - return cellIndex; -} - - diff --git a/src/gpu/GridGenerator/StreetPointFinder/SourceReader.h b/src/gpu/GridGenerator/StreetPointFinder/SourceReader.h deleted file mode 100644 index f79c618d06ff9f72738c7b69767a8dd3c5443fac..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/StreetPointFinder/SourceReader.h +++ /dev/null @@ -1,63 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file SourceReader.h -//! \ingroup StreetPointFinder -//! \author Stephan Lenz -//======================================================================================= -#ifndef SOURCEREADER_H -#define SOURCEREADER_H - -#include <vector> - -#include "Core/DataTypes.h" -#include "Core/Logger/Logger.h" - -#include "StreetPointFinder.h" - - - -struct GRIDGENERATOR_EXPORT SourceReaderData { - unsigned int sourceIndex; - float sourcePossibility; - SourceReaderData(unsigned int sourceIndex, float sourcePossibility); -}; - -struct GRIDGENERATOR_EXPORT SourceReader -{ - std::vector<SourceReaderData> sources; - StreetPointFinder* streetPointFinder; - - void readSources(std::string filename, StreetPointFinder* streetPointFinder); - -private: - unsigned int getCellIndexStart(unsigned int streetIndex); -}; - - -#endif \ No newline at end of file diff --git a/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.cpp b/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.cpp deleted file mode 100644 index 9fbd3933a5457e96d2d1aa01f1fadcf675be1980..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.cpp +++ /dev/null @@ -1,790 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file StreetPointFinder.cpp -//! \ingroup StreetPointFinder -//! \author Stephan Lenz -//======================================================================================= -#include "StreetPointFinder.h" - -#include "Core/Logger/Logger.h" - -#include <string> -#include <sstream> -#include <fstream> -#include <iostream> -#include <cmath> -#include <algorithm> -#include <numeric> - -#include "grid/Grid.h" -#include "grid/NodeValues.h" - -using namespace vf::gpu; - -Street::Street(real xStartCell, real yStartCell, real xEndCell, real yEndCell, real dx) -{ - real length = std::sqrt((xEndCell - xStartCell)*(xEndCell - xStartCell) - + (yEndCell - yStartCell)*(yEndCell - yStartCell)); - - this->numberOfCells = std::floor(length / dx); - - real realLength = dx * (this->numberOfCells); - - real vectorX = (xEndCell - xStartCell) / length; - real vectorY = (yEndCell - yStartCell) / length; - - this->xStart = xStartCell - 0.5 * (realLength - length) * vectorX + 0.5 * dx * vectorX; - this->yStart = yStartCell - 0.5 * (realLength - length) * vectorY + 0.5 * dx * vectorY; - - this->xEnd = xEndCell + 0.5 * (realLength - length) * vectorX - 0.5 * dx * vectorX; - this->yEnd = yEndCell + 0.5 * (realLength - length) * vectorY - 0.5 * dx * vectorY; - - //this->xStart = xStart + dx * (xEnd - xStart) / length; - //this->yStart = yStart + dx * (yEnd - yStart) / length; - // - //this->xEnd = xEnd - dx * (xEnd - xStart) / length; - //this->yEnd = yEnd - dx * (yEnd - yStart) / length; - - //this->numberOfCells = std::lround( length / dx ) + 1; -} - -real Street::getCoordinateX(int cellIndex) -{ - return xStart + real(cellIndex) / real(numberOfCells - 1) * (xEnd - xStart); -} - -real Street::getCoordinateY(int cellIndex) -{ - return yStart + real(cellIndex) / real(numberOfCells - 1) * (yEnd - yStart); -} - -real Street::getVectorX() -{ - real vecX = this->xEnd - this->xStart; - real vecY = this->yEnd - this->yStart; - - real length = sqrt(vecX*vecX + vecY*vecY); - - return vecX / length; -} - -real Street::getVectorY() -{ - real vecX = this->xEnd - this->xStart; - real vecY = this->yEnd - this->yStart; - - real length = sqrt(vecX*vecX + vecY*vecY); - - return vecY / length; -} - -void Street::findIndicesLB(SPtr<Grid> grid, real initialSearchHeight) -{ - for (uint i = 0; i < numberOfCells; i++) - { - real x = getCoordinateX(i); - real y = getCoordinateY(i); - - uint matrixIndex = grid->transCoordToIndex(x, y, initialSearchHeight); - - real xLB, yLB, zLB; - grid->transIndexToCoords(matrixIndex, xLB, yLB, zLB); - - while (grid->getFieldEntry(matrixIndex) != BC_SOLID || - grid->getFieldEntry(grid->transCoordToIndex(xLB, yLB, zLB-grid->getDelta())) != STOPPER_SOLID) - { - zLB -= grid->getDelta(); - matrixIndex = grid->transCoordToIndex(xLB, yLB, zLB); - } - - std::stringstream msg; - - - msg << "( " << x << ", " << y << " )" << " ==> "; - msg << "( " << xLB << ", " << yLB << ", " << zLB << " ), type = [" << (int)grid->getFieldEntry(matrixIndex) << "], z = " << zLB << " \n"; - - *logging::out << logging::Logger::INFO_LOW << msg.str(); - - this->matrixIndicesLB.push_back(matrixIndex); - this->sparseIndicesLB.push_back(grid->getSparseIndex(matrixIndex)); - } -} - -void StreetPointFinder::prepareSimulationFileData() -{ - ////////////////////////////////////////////////////////////////////////// - // Concatenate sparseIndicesLB - - for (auto& street : this->streets) this->sparseIndicesLB.insert(this->sparseIndicesLB.end(), street.sparseIndicesLB.begin(), street.sparseIndicesLB.end()); - - ////////////////////////////////////////////////////////////////////////// - // prepare vectors - - uint numberOfCells = (uint)this->sparseIndicesLB.size(); - - mapNashToConc.resize(numberOfCells); - - std::vector<uint> indexMap(numberOfCells); - std::iota(indexMap.begin(), indexMap.end(), 0); - - ////////////////////////////////////////////////////////////////////////// - // sort vectors - - std::stable_sort(indexMap.begin(), - indexMap.end(), - [&](uint lhs, uint rhs) { - return this->sparseIndicesLB[lhs] <= this->sparseIndicesLB[rhs]; - }); - - std::stable_sort(this->sparseIndicesLB.begin(), - this->sparseIndicesLB.end(), - [](uint lhs, uint rhs) { - return lhs <= rhs; - }); - ////////////////////////////////////////////////////////////////////////// - // invert idxMap - - { - std::vector<uint> buffer = indexMap; - for (uint idx = 0; idx < indexMap.size(); idx++) - indexMap[buffer[idx]] = idx; - } - - ////////////////////////////////////////////////////////////////////////// - // identify duplicates and find correct mapping indices - - std::vector<uint> reducedIndexMap(numberOfCells); - - uint currentSparseIndex = this->sparseIndicesLB[0]; - uint reducedIndex = 0; - for (uint index = 1; index < numberOfCells; index++) - { - if (this->sparseIndicesLB[index] == currentSparseIndex) - { - reducedIndexMap[index] = reducedIndex; - } - else - { - currentSparseIndex = this->sparseIndicesLB[index]; - reducedIndexMap[index] = ++reducedIndex; - } - } - - for (uint index = 0; index < numberOfCells; index++) - { - mapNashToConc[index] = reducedIndexMap[indexMap[index]]; - } - - ////////////////////////////////////////////////////////////////////////// - // erase duplicated - - auto newEnd = std::unique(this->sparseIndicesLB.begin(), this->sparseIndicesLB.end()); - - this->sparseIndicesLB.resize(std::distance(this->sparseIndicesLB.begin(), newEnd)); - - ////////////////////////////////////////////////////////////////////////// -} - -void StreetPointFinder::readStreets(std::string filename) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::readStreets( " << filename << " )" << "\n"; - - uint numberOfStreets; - - std::ifstream file; - - file.open(filename.c_str()); - - file >> numberOfStreets; - - for (uint i = 0; i < numberOfStreets; i++) - { - real xStart, yStart, xEnd, yEnd; - - real dx; - - file >> xStart >> yStart >> xEnd >> yEnd >> dx; - - streets.push_back(Street(xStart, yStart, xEnd, yEnd, dx)); - } - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -void StreetPointFinder::findIndicesLB(SPtr<Grid> grid, real initialSearchHeight) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::findIndicesLB()\n"; - - for (auto& street : streets) street.findIndicesLB(grid, initialSearchHeight); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -void StreetPointFinder::writeVTK(std::string filename, const std::vector<int>& cars) -{ - uint numberOfCells = 0; - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::writeVTK( " << filename << " )" << "\n"; - - std::ofstream file; - - file.open(filename); - - prepareWriteVTK(file, numberOfCells); - - ////////////////////////////////////////////////////////////////////////// - - file << "FIELD Label " << 3 << std::endl; - - ////////////////////////////////////////////////////////////////////////// - - writeStreetsVTK(file, numberOfCells); - - writeLengthsVTK(file, numberOfCells); - - writeCarsVTK(file, numberOfCells, cars); - - //////////////////////////////////////////////////////////////////////////// - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - - -void StreetPointFinder::writeReducedVTK(std::string filename, const std::vector<int>& cars) -{ - uint numberOfCells = 0; - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::writeVTK( " << filename << " )" << "\n"; - - std::ofstream file; - - file.open(filename); - - prepareWriteVTK(file, numberOfCells); - - ////////////////////////////////////////////////////////////////////////// - - file << "FIELD Label " << 1 << std::endl; - - ////////////////////////////////////////////////////////////////////////// - - writeCarsVTK(file, numberOfCells, cars); - - //////////////////////////////////////////////////////////////////////////// - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -void StreetPointFinder::prepareWriteVTK(std::ofstream & file, uint & numberOfCells) -{ - - uint numberOfNodes = 0; - - for (auto& street : streets) - { - numberOfCells += street.numberOfCells; - numberOfNodes += street.numberOfCells + 1; - } - - file << "# vtk DataFile Version 3.0\n"; - file << "by MeshGenerator\n"; - file << "ASCII\n"; - file << "DATASET UNSTRUCTURED_GRID\n"; - - file << "POINTS " << numberOfNodes << " float" << std::endl; - - for (auto& street : streets) - { - for (uint i = 0; i <= street.numberOfCells; i++) - { - file << 0.5 * (street.getCoordinateX(i - 1) + street.getCoordinateX(i)) << " " - << 0.5 * (street.getCoordinateY(i - 1) + street.getCoordinateY(i)) << " " << 0.0 << std::endl; - } - } - - ////////////////////////////////////////////////////////////////////////// - - file << "CELLS " << numberOfCells << " " << 3 * numberOfCells << std::endl; - - - uint nodeIndex = 0; - for (auto& street : streets) - { - for (uint i = 0; i < street.numberOfCells; i++) - { - file << "2 " << nodeIndex << " " << nodeIndex + 1 << std::endl; - nodeIndex++; - } - nodeIndex++; - } - - ////////////////////////////////////////////////////////////////////////// - - file << "CELL_TYPES " << numberOfCells << std::endl; - - for (uint i = 0; i < numberOfCells; i++) { - file << "3" << std::endl; - } - ////////////////////////////////////////////////////////////////////////// - - file << "\nCELL_DATA " << numberOfCells << std::endl; -} - - -void StreetPointFinder::writeStreetsVTK(std::ofstream & file, uint numberOfCells) -{ - file << "StreetIndex 1 " << numberOfCells << " int" << std::endl; - - uint streetIndex = 0; - for (auto& street : streets) - { - for (uint i = 0; i < street.numberOfCells; i++) - { - file << streetIndex << std::endl; - } - streetIndex++; - } -} - - - -void StreetPointFinder::writeCarsVTK(std::ofstream& file, uint numberOfCells, const std::vector<int>& cars) -{ - file << "Cars 1 " << numberOfCells << " float" << std::endl; - - uint index = 0; - for (auto& street : streets) - { - for (uint i = 0; i < street.numberOfCells; i++) - { - if (index < cars.size()) - file << cars[index] << std::endl; - else - file << -1 << std::endl; - index++; - } - } -} - - -void StreetPointFinder::writeLengthsVTK(std::ofstream & file, uint numberOfCells) -{ - file << "StreetLength 1 " << numberOfCells << " float" << std::endl; - - for (auto& street : streets) - { - for (uint i = 0; i < street.numberOfCells; i++) - { - real length = std::sqrt((street.getCoordinateX(i) - street.getCoordinateX(0)) * (street.getCoordinateX(i) - street.getCoordinateX(0)) - + (street.getCoordinateY(i) - street.getCoordinateY(0)) * (street.getCoordinateY(i) - street.getCoordinateY(0))); - - file << length << std::endl; - } - } -} - - -void StreetPointFinder::writeConnectionVTK(std::string filename, SPtr<Grid> grid) -{ - uint numberOfCells = 0; - - for (auto& street : streets) - { - numberOfCells += street.numberOfCells; - } - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::writeConnectionVTK( " << filename << " )" << "\n"; - - std::ofstream file; - - file.open(filename); - - file << "# vtk DataFile Version 3.0\n"; - file << "by MeshGenerator\n"; - file << "ASCII\n"; - file << "DATASET UNSTRUCTURED_GRID\n"; - - file << "POINTS " << 2 * numberOfCells << " float" << std::endl; - - for (auto& street : streets) - { - for (uint i = 0; i < street.numberOfCells; i++) - { - real xLB, yLB, zLB; - grid->transIndexToCoords(street.matrixIndicesLB[i], xLB, yLB, zLB); - - file << street.getCoordinateX(i) << " " << street.getCoordinateY(i) << " " << 5.0 << std::endl; - file << xLB << " " << yLB << " " << zLB << std::endl; - } - } - - ////////////////////////////////////////////////////////////////////////// - - file << "CELLS " << numberOfCells << " " << 3 * numberOfCells << std::endl; - - - uint nodeIndex = 0; - for (auto& street : streets) - { - for (uint i = 0; i < street.numberOfCells; i++) - { - file << "2 " << nodeIndex << " " << nodeIndex + 1 << std::endl; - nodeIndex += 2; - } - } - - ////////////////////////////////////////////////////////////////////////// - - file << "CELL_TYPES " << numberOfCells << std::endl; - - for (uint i = 0; i < numberOfCells; i++) { - file << "3" << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -void StreetPointFinder::writeSimulationFile(std::string gridPath, real concentration, uint numberOfLevels, uint level) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::writeSimulationFile( " << gridPath << "conc.dat )" << "\n"; - - std::ofstream file; - - file.open(gridPath + "conc.dat"); - - file << "concentration\n"; - - file << numberOfLevels - 1 << "\n"; - - for (uint currentLevel = 0; currentLevel < numberOfLevels; currentLevel++) - { - if (currentLevel == level) - { - uint numberOfCells = 0; - for (auto& street : streets) - { - numberOfCells += street.numberOfCells; - } - - file << numberOfCells << "\n"; - - for (auto& street : streets) - { - for (auto& sparseIndexLB : street.sparseIndicesLB) - { - // + 1 for numbering shift between GridGenerator and VF_GPU - file << sparseIndexLB + 1 << "\n"; - } - } - } - else - { - file << "0\n"; - } - } - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -void StreetPointFinder::writeStreetVectorFile(std::string gridPath, real concentration, uint numberOfLevels, uint level) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::writeStreetVectorFile( " << gridPath << "streetVector.dat )" << "\n"; - - std::ofstream file; - - file.open(gridPath + "streetVector.dat"); - - file << "streetVector\n"; - - file << numberOfLevels - 1 << "\n"; - - for (uint currentLevel = 0; currentLevel < numberOfLevels; currentLevel++) - { - if (currentLevel == level) - { - uint numberOfCells = 0; - for (auto& street : streets) - { - numberOfCells += street.numberOfCells; - } - - file << numberOfCells << "\n"; - - for (auto& street : streets) - { - for (auto& sparseIndexLB : street.sparseIndicesLB) - { - (void) sparseIndexLB; - // + 1 for numbering shift between GridGenerator and VF_GPU - file << street.getVectorX() << " " << street.getVectorY() << "\n"; - } - } - } - else - { - file << "0\n"; - } - } - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -void StreetPointFinder::writeSimulationFileSorted(std::string gridPath, real concentration, uint numberOfLevels, uint level) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::writeSimulationFile( " << gridPath << "concSorted.dat )" << "\n"; - - std::ofstream file; - - file.open(gridPath + "concSorted.dat"); - - file << "concentration\n"; - - file << numberOfLevels - 1 << "\n"; - - for (uint currentLevel = 0; currentLevel < numberOfLevels; currentLevel++) - { - if (currentLevel == level) - { - file << this->sparseIndicesLB.size() << "\n"; - - for (auto& sparseIndexLB : this->sparseIndicesLB) - { - // + 1 for numbering shift between GridGenerator and VF_GPU - file << sparseIndexLB + 1 << "\n"; - } - } - else - { - file << "0\n"; - } - } - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -void StreetPointFinder::writeMappingFile(std::string gridPath) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::writeMappingFile( " << gridPath << "mappingNashToConc.dat )" << "\n"; - - std::ofstream file; - - file.open(gridPath + "mappingNashToConc.dat"); - - file << this->mapNashToConc.size() << "\n"; - - for (auto& index : this->mapNashToConc) - { - file << index << "\n"; - } - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - - - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// Speed hackend by Stephan Lenz, not tested - -void StreetPointFinder::write3DVTK(std::string filename, const std::vector<int>& cars) -{ - uint numberOfCells = 0; - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::writeVTK( " << filename << " )" << "\n"; - - std::ofstream file; - - file.open(filename); - - prepareWrite3DVTK(file, numberOfCells, cars); - - //////////////////////////////////////////////////////////////////////////// - - file.close(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; -} - -void StreetPointFinder::prepareWrite3DVTK(std::ofstream & file, uint & numberOfCells, const std::vector<int>& cars) -{ - - uint numberOfNodes = 0; - - for (auto& street : streets) - { - numberOfCells += street.numberOfCells; - numberOfNodes += street.numberOfCells + 1; - } - - file << "# vtk DataFile Version 3.0\n"; - file << "by MeshGenerator\n"; - file << "ASCII\n"; - file << "DATASET UNSTRUCTURED_GRID\n"; - - uint index = 0; - uint numberOfCars = 0; - - for (auto& street : streets) - { - for (uint i = 0; i < street.numberOfCells; i++) - { - if (index < cars.size() && cars[index] != -1) - { - numberOfCars++; - } - - index++; - } - } - - file << "POINTS " << 8 * numberOfCars << " float" << std::endl; - - index = 0; - for (auto& street : streets) - { - for (uint i = 0; i < street.numberOfCells; i++) - { - if(index < cars.size() && cars[index] != -1 ) - { - real xStart = 0.5 * (street.getCoordinateX(i - 1) + street.getCoordinateX(i)); - real yStart = 0.5 * (street.getCoordinateY(i - 1) + street.getCoordinateY(i)); - - real xEnd = 0.5 * (street.getCoordinateX(i) + street.getCoordinateX(i + 1)); - real yEnd = 0.5 * (street.getCoordinateY(i) + street.getCoordinateY(i + 1)); - - real vecX = xEnd - xStart; - real vecY = yEnd - yStart; - - file << xStart + vecY << " " << yStart - vecX << " " << 0.0 << std::endl; - file << xStart - vecY << " " << yStart + vecX << " " << 0.0 << std::endl; - - file << xEnd + vecY << " " << yEnd - vecX << " " << 0.0 << std::endl; - file << xEnd - vecY << " " << yEnd + vecX << " " << 0.0 << std::endl; - - file << xStart + vecY << " " << yStart - vecX << " " << 1.5 << std::endl; - file << xStart - vecY << " " << yStart + vecX << " " << 1.5 << std::endl; - - file << xEnd + vecY << " " << yEnd - vecX << " " << 1.5 << std::endl; - file << xEnd - vecY << " " << yEnd + vecX << " " << 1.5 << std::endl; - } - - index++; - } - } - - ////////////////////////////////////////////////////////////////////////// - - file << "CELLS " << numberOfCars << " " << 9 * numberOfCars << std::endl; - - index = 0; - uint carIndex = 0; - for (auto& street : streets) - { - for (uint i = 0; i < street.numberOfCells; i++) - { - if (index < cars.size() && cars[index] != -1) - { - file << "8 " - << 8 * carIndex + 0 << " " - << 8 * carIndex + 1 << " " - << 8 * carIndex + 3 << " " - << 8 * carIndex + 2 << " " - << 8 * carIndex + 4 << " " - << 8 * carIndex + 5 << " " - << 8 * carIndex + 7 << " " - << 8 * carIndex + 6 << " " - << std::endl; - - carIndex++; - } - index++; - } - } - - ////////////////////////////////////////////////////////////////////////// - - file << "CELL_TYPES " << numberOfCars << std::endl; - - for (uint i = 0; i < numberOfCars; i++) { - file << "12" << std::endl; - } - - ////////////////////////////////////////////////////////////////////////// - - file << "\nCELL_DATA " << numberOfCars << std::endl; - - ////////////////////////////////////////////////////////////////////////// - - file << "FIELD Label " << 1 << std::endl; - - ////////////////////////////////////////////////////////////////////////// - - file << "Cars 1 " << numberOfCars << " float" << std::endl; - - index = 0; - for (auto& street : streets) - { - for (uint i = 0; i < street.numberOfCells; i++) - { - if (index < cars.size() && cars[index] != -1) - file << cars[index] << std::endl; - - index++; - } - } -} - - - - diff --git a/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.h b/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.h deleted file mode 100644 index feb3618f64b0a6f757930772594878a6ca7c0144..0000000000000000000000000000000000000000 --- a/src/gpu/GridGenerator/StreetPointFinder/StreetPointFinder.h +++ /dev/null @@ -1,120 +0,0 @@ -//======================================================================================= -// ____ ____ __ ______ __________ __ __ __ __ -// \ \ | | | | | _ \ |___ ___| | | | | / \ | | -// \ \ | | | | | |_) | | | | | | | / \ | | -// \ \ | | | | | _ / | | | | | | / /\ \ | | -// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ -// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| -// \ \ | | ________________________________________________________________ -// \ \ | | | ______________________________________________________________| -// \ \| | | | __ __ __ __ ______ _______ -// \ | | |_____ | | | | | | | | | _ \ / _____) -// \ | | _____| | | | | | | | | | | \ \ \_______ -// \ | | | | |_____ | \_/ | | | | |_/ / _____ | -// \ _____| |__| |________| \_______/ |__| |______/ (_______/ -// -// This file is part of VirtualFluids. VirtualFluids is free software: you can -// redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// You should have received a copy of the GNU General Public License along -// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. -// -//! \file StreetPointFinder.h -//! \ingroup StreetPointFinder -//! \author Stephan Lenz -//======================================================================================= -#ifndef StreetPointFinder_H -#define StreetPointFinder_H - -#include <vector> -#include <string> - -#include "GridGenerator_export.h" - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" - - - -class Grid; - -struct GRIDGENERATOR_EXPORT Street -{ - // The start and end coordinates are stored for cell centers! - // - // |---x---|---x---|---x---|---x---|---x---|---x---|---x---|---x---|---x---|---x---| - // |---> |<----->| <---| - // xStart dx xEnd - // - // dx = (xStart - xEnd) / (numberOfCells - 1) - - uint numberOfCells; - real xStart, yStart, xEnd, yEnd; - - std::vector<uint> matrixIndicesLB; - std::vector<uint> sparseIndicesLB; - - // The constructor expect start and end for cells - Street( real xStartCell, real yStartCell, real xEndCell, real yEndCell, real dx ); - - real getCoordinateX( int cellIndex ); - real getCoordinateY( int cellIndex ); - - real getVectorX(); - real getVectorY(); - - void findIndicesLB( SPtr<Grid> grid, real initialSearchHeight); -}; - -struct GRIDGENERATOR_EXPORT StreetPointFinder -{ - std::vector<Street> streets; - - std::vector<uint> sparseIndicesLB; - std::vector<uint> mapNashToConc; - - void prepareSimulationFileData(); - - void readStreets(std::string filename); - - void findIndicesLB( SPtr<Grid> grid, real initialSearchHeight ); - - void writeVTK(std::string filename, const std::vector<int>& cars = std::vector<int>()); - - void writeReducedVTK(std::string filename, const std::vector<int>& cars = std::vector<int>()); - - void prepareWriteVTK(std::ofstream& file, uint & numberOfCells); - - void writeCarsVTK(std::ofstream& file, uint numberOfCells, const std::vector<int>& cars); - - void writeLengthsVTK(std::ofstream& file, uint numberOfCells); - - void writeStreetsVTK(std::ofstream& file, uint numberOfCells); - - void writeConnectionVTK(std::string filename, SPtr<Grid> grid); - - void writeSimulationFile(std::string gridPath, real concentration, uint numberOfLevels, uint level); - - void writeStreetVectorFile(std::string gridPath, real concentration, uint numberOfLevels, uint level); - - void writeSimulationFileSorted( std::string gridPath, real concentration, uint numberOfLevels, uint level ); - - void writeMappingFile( std::string gridPath ); - - ////////////////////////////////////////////////////////////////////////// - // 3D cars writer hacked by Stephan L. - - void write3DVTK(std::string filename, const std::vector<int>& cars = std::vector<int>()); - - void prepareWrite3DVTK(std::ofstream& file, uint & numberOfCells, const std::vector<int>& cars); -}; - - -#endif \ No newline at end of file diff --git a/src/gpu/GridGenerator/TransientBCSetter/TransientBCSetter.h b/src/gpu/GridGenerator/TransientBCSetter/TransientBCSetter.h index 1663a3ff37ba1bb062647847462d4e364baed93b..bdf29745a0a60473d0454c33dcb10a193ca10780 100644 --- a/src/gpu/GridGenerator/TransientBCSetter/TransientBCSetter.h +++ b/src/gpu/GridGenerator/TransientBCSetter/TransientBCSetter.h @@ -1,8 +1,8 @@ #ifndef TRANSIENTBCSETTER_H_ #define TRANSIENTBCSETTER_H_ -#include "Core/DataTypes.h" -#include <Core/StringUtilities/StringUtil.h> +#include "DataTypes.h" +#include <StringUtilities/StringUtil.h> #include "PointerDefinitions.h" #include <string> diff --git a/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.cpp b/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.cpp index 331b928c6f5542584cffdcc1b17df7207981b8f8..b41813e12da1727ba03b7f179c93b4c6b042b76f 100644 --- a/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.cpp +++ b/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.cpp @@ -32,30 +32,14 @@ //======================================================================================= #include "Conglomerate.h" -Conglomerate::Conglomerate() -{ - addObjects = new Object*[MAX_NUMBER_OF_OBJECTS]; - subtractObjects = new Object*[MAX_NUMBER_OF_OBJECTS]; -} - -Conglomerate::~Conglomerate() -{ - for (uint i = 0; i < numberOfAddObjects; i++) - delete addObjects[i]; - - for (uint i = 0; i < numberOfSubtractObjects; i++) - delete subtractObjects[i]; - - delete[] addObjects; - delete[] subtractObjects; -} +#include <memory> SPtr<Conglomerate> Conglomerate::makeShared() { - return SPtr<Conglomerate>(new Conglomerate()); + return std::make_shared<Conglomerate>(); } -void Conglomerate::add(Object* object) +void Conglomerate::add(SPtr<Object> object) { if (numberOfAddObjects < MAX_NUMBER_OF_OBJECTS) { @@ -65,7 +49,7 @@ void Conglomerate::add(Object* object) printf("[WARNING] max numbers of %d reached! Object was not added.\n", MAX_NUMBER_OF_OBJECTS); } -void Conglomerate::subtract(Object* object) +void Conglomerate::subtract(SPtr<Object> object) { if (numberOfSubtractObjects < MAX_NUMBER_OF_OBJECTS) { @@ -76,9 +60,9 @@ void Conglomerate::subtract(Object* object) printf("[WARNING] max numbers of %d reached! Object was not added.\n", MAX_NUMBER_OF_OBJECTS); } -Object* Conglomerate::clone() const +SPtr<Object> Conglomerate::clone() const { - auto conglomerate = new Conglomerate(); + auto conglomerate = std::make_shared<Conglomerate>(); for (uint i = 0; i < numberOfAddObjects; i++) conglomerate->add(addObjects[i]->clone()); @@ -193,5 +177,5 @@ void Conglomerate::findInnerNodes(SPtr<GridImp> grid) addObjects[i]->findInnerNodes(grid); if( numberOfSubtractObjects > 0 ) - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Warning: Conglomerate::substract() is currently nut fully implemented!\n"; + VF_LOG_WARNING("Warning: Conglomerate::substract() is currently nut fully implemented!"); } diff --git a/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.h b/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.h index 8cb26137d6ab4e4c52bed34aa1d044121ac4bf3d..0b3f7ad7b67554b72ad78188d68d9570bf21e090 100644 --- a/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.h +++ b/src/gpu/GridGenerator/geometries/Conglomerate/Conglomerate.h @@ -33,25 +33,25 @@ #ifndef CONGLOMERATE_H #define CONGLOMERATE_H +#include <array> + #include "global.h" #include "geometries/Object.h" +#include "basics/PointerDefinitions.h" #define MAX_NUMBER_OF_OBJECTS 20 class GRIDGENERATOR_EXPORT Conglomerate : public Object { -public: - Conglomerate(); - virtual ~Conglomerate(); - +public: static SPtr<Conglomerate> makeShared(); - void add(Object* object); - void subtract(Object* objectStub); + void add(SPtr<Object> object); + void subtract(SPtr<Object> objectStub); - Object* clone() const override; + SPtr<Object> clone() const override; double getX1Centroid() override; double getX1Minimum() override; @@ -74,8 +74,8 @@ protected: static double getMaximum(double val1, double val2); - Object** addObjects; - Object** subtractObjects; + std::array<SPtr<Object>, MAX_NUMBER_OF_OBJECTS> addObjects; + std::array<SPtr<Object>, MAX_NUMBER_OF_OBJECTS> subtractObjects; uint numberOfAddObjects = 0; uint numberOfSubtractObjects = 0; }; diff --git a/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.cpp b/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.cpp index 7b0dbcdbdcbd679f1eb47ed5db7d828da8c31767..2cf56a867954abecf14f7dc2a74f735ebb0660a7 100644 --- a/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.cpp +++ b/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.cpp @@ -32,6 +32,7 @@ //======================================================================================= #include "Cuboid.h" +#include "PointerDefinitions.h" #include "utilities/math/Math.h" Cuboid::Cuboid(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b) @@ -40,14 +41,9 @@ Cuboid::Cuboid(const double& x1a,const double& x2a, const double& x3a, const dou } -Cuboid::~Cuboid() +SPtr<Object> Cuboid::clone() const { - -} - -Object* Cuboid::clone() const -{ - return new Cuboid(minX1, minX2, minX3, maxX1, maxX2, maxX3); + return std::make_shared<Cuboid>(minX1, minX2, minX3, maxX1, maxX2, maxX3); } double Cuboid::getX1Centroid() diff --git a/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.h b/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.h index 0351bd3ed847f9702e3c64bce4dcef514804e23a..7ff5c14c2f17b4ed80f4f1e0c03d26ea1a2eb196 100644 --- a/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.h +++ b/src/gpu/GridGenerator/geometries/Cuboid/Cuboid.h @@ -41,9 +41,8 @@ class GRIDGENERATOR_EXPORT Cuboid : public Object { public: Cuboid(const double& minX1, const double& minX2, const double& minX3, const double& maxX1,const double& maxX2, const double& maxX3); - virtual ~Cuboid(); - Object* clone() const override; + SPtr<Object> clone() const override; double getX1Centroid() override; double getX1Minimum() override; diff --git a/src/gpu/GridGenerator/geometries/Object.h b/src/gpu/GridGenerator/geometries/Object.h index b92cca7992dcb06c1f230da8d8c9ce46bb7a3416..8bb0a35d5e38df1f7db390fdf5ee750295788395 100644 --- a/src/gpu/GridGenerator/geometries/Object.h +++ b/src/gpu/GridGenerator/geometries/Object.h @@ -43,8 +43,8 @@ struct Vertex; class GRIDGENERATOR_EXPORT Object { public: - virtual ~Object() {} - virtual Object* clone() const = 0; + virtual ~Object() = default; + virtual SPtr<Object> clone() const = 0; virtual double getX1Centroid() = 0; virtual double getX1Minimum() = 0; diff --git a/src/gpu/GridGenerator/geometries/Sphere/Sphere.cpp b/src/gpu/GridGenerator/geometries/Sphere/Sphere.cpp index fa460bc021cdca1159f272e3bcb4d4dad50fc352..4669bbcfb9848a910bc86f9331a394daf6c55dd5 100644 --- a/src/gpu/GridGenerator/geometries/Sphere/Sphere.cpp +++ b/src/gpu/GridGenerator/geometries/Sphere/Sphere.cpp @@ -44,18 +44,14 @@ Sphere::Sphere(const double& centerX, const double& centerY, const double& cente } -Sphere::~Sphere() -{ -} - SPtr<Sphere> Sphere::makeShared(double centerX, double centerY, double centerZ, double radius) { - return SPtr<Sphere>(new Sphere(centerX, centerY, centerZ, radius)); + return std::make_shared<Sphere>(centerX, centerY, centerZ, radius); } -Object* Sphere::clone() const +SPtr<Object> Sphere::clone() const { - return new Sphere(centerX, centerY, centerZ, radius); + return std::make_shared<Sphere>(centerX, centerY, centerZ, radius); } double Sphere::getX1Centroid() diff --git a/src/gpu/GridGenerator/geometries/Sphere/Sphere.h b/src/gpu/GridGenerator/geometries/Sphere/Sphere.h index 03b9ef9fd101f19dbaff7d4e4109000cce6e3c49..9ac8821a9c95fce8de16c22688ef3c585197804a 100644 --- a/src/gpu/GridGenerator/geometries/Sphere/Sphere.h +++ b/src/gpu/GridGenerator/geometries/Sphere/Sphere.h @@ -33,6 +33,7 @@ #ifndef SPHERE_H #define SPHERE_H +#include "PointerDefinitions.h" #include "global.h" #include "geometries/Object.h" @@ -40,11 +41,10 @@ class GRIDGENERATOR_EXPORT Sphere : public Object { public: Sphere(const double& centerX, const double& centerY, const double& centerZ, const double& radius); - virtual ~Sphere(); static SPtr<Sphere> makeShared(double centerX, double centerY, double centerZ, double radius); - Object* clone() const override; + SPtr<Object> clone() const override; double getX1Centroid() override; double getX1Minimum() override; diff --git a/src/gpu/GridGenerator/geometries/Triangle/Triangle.cpp b/src/gpu/GridGenerator/geometries/Triangle/Triangle.cpp index bf272b9e7f46c413ae6edce62c05d1be20d327de..8d459e75b5b27c5d5a1c9e645b08b5fc663e8be6 100644 --- a/src/gpu/GridGenerator/geometries/Triangle/Triangle.cpp +++ b/src/gpu/GridGenerator/geometries/Triangle/Triangle.cpp @@ -40,7 +40,6 @@ using namespace vf::gpu; Triangle::Triangle(Vertex &v1, Vertex &v2, Vertex &v3, Vertex &normal) : v1(v1), v2(v2), v3(v3), normal(normal), patchIndex(INVALID_INDEX) {} Triangle::Triangle(Vertex &v1, Vertex &v2, Vertex &v3) : v1(v1), v2(v2), v3(v3), patchIndex(INVALID_INDEX) { calcNormal(); } -Triangle::Triangle(){} void Triangle::set(const Vertex &v1, const Vertex &v2, const Vertex &v3) { diff --git a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.cpp b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.cpp index 883ca0deaf34f45e4608c4e59908b4562932db77..91bb8f030e76fa6e083e7765feb18c7ccc517ee1 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.cpp +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.cpp @@ -32,7 +32,7 @@ //======================================================================================= #include "TriangularMesh.h" -#include "Core/Timer/Timer.h" +#include "Timer/Timer.h" #include "basics/geometry3d/GbTriFaceMesh3D.h" @@ -79,9 +79,9 @@ TriangularMesh::TriangularMesh() this->minmax = BoundingBox::makeInvalidMinMaxBox(); // blame Lenz } -Object* TriangularMesh::clone() const +SPtr<Object> TriangularMesh::clone() const { - auto mesh = new TriangularMesh(); + auto mesh = std::make_shared<TriangularMesh>(); mesh->setTriangles(this->triangleVec); return mesh; } @@ -95,7 +95,7 @@ uint TriangularMesh::getNumberOfTriangles() const void TriangularMesh::findNeighbors() { - *logging::out << logging::Logger::INFO_INTERMEDIATE << "start finding neighbors ...\n"; + VF_LOG_INFO("start finding neighbors ..."); auto t = Timer::makeStart(); @@ -103,8 +103,7 @@ void TriangularMesh::findNeighbors() finder.fillWithNeighborAngles(this); t->end(); - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "time finding neighbors: " << t->getTimeInSeconds() << "s\n"; + VF_LOG_INFO("time finding neighbors = {}", t->getTimeInSeconds()); } void TriangularMesh::setTriangles(std::vector<Triangle> triangles) @@ -152,7 +151,7 @@ GRIDGENERATOR_EXPORT void TriangularMesh::generateGbTriFaceMesh3D() { if( this->VF_GbTriFaceMesh3D ) return; - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start generating GbTriFaceMesh3D:\n"; + VF_LOG_INFO("Start generating GbTriFaceMesh3D"); std::vector<GbTriFaceMesh3D::Vertex> *gbVertices = new std::vector<GbTriFaceMesh3D::Vertex>(this->triangleVec.size() * 3); std::vector<GbTriFaceMesh3D::TriFace> *gbTriangles = new std::vector<GbTriFaceMesh3D::TriFace>(this->triangleVec.size()); @@ -168,7 +167,7 @@ GRIDGENERATOR_EXPORT void TriangularMesh::generateGbTriFaceMesh3D() this->VF_GbTriFaceMesh3D = std::make_shared<GbTriFaceMesh3D>( "stl", gbVertices, gbTriangles, GbTriFaceMesh3D::KDTREE_SAHPLIT, false ); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Done generating GbTriFaceMesh3D\n"; + VF_LOG_INFO("Done generating GbTriFaceMesh3D"); } @@ -238,9 +237,9 @@ void TriangularMesh::scale(double offset) const int vertexTriangleID = (int)vertexID % 3; Vertex intersection; - Vertex p = this->triangleVec[triangleID].v1 + this->triangleVec[triangleID].normal * offset; + // Vertex p = this->triangleVec[triangleID].v1 + this->triangleVec[triangleID].normal * offset; // TODO: https://git.rz.tu-bs.de/irmb/VirtualFluids_dev/-/issues/85 Vertex lineOrigin = this->triangleVec[triangleID].get(vertexTriangleID); - //bool b = intersectPlane(this->triangleVec[triangleID].normal, p, lineOrigin, averrageNormal, intersection); + // bool b = intersectPlane(this->triangleVec[triangleID].normal, p, lineOrigin, averrageNormal, intersection); triangles[triangleID].set(vertexTriangleID, intersection); triangles[triangleID].calcNormal(); diff --git a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.h b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.h index 2e876e1d3c50b377ef6df9a8489fe8a189849594..7c050dd70b3908f3e4b021872887c74833594a26 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.h +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMesh.h @@ -87,7 +87,7 @@ private: static void eliminateTriangleswithIdenticialNormal(std::vector<Triangle> &triangles); public: - Object* clone() const override; + SPtr<Object> clone() const override; double getX1Centroid() override { throw "Not implemented in TriangularMesh"; } double getX1Minimum() override { return minmax.minX; } double getX1Maximum() override { return minmax.maxX; } diff --git a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.cpp b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.cpp index d9c1486e2ca9469d55174eca673f22f180a78294..f66b216525253d26d0402c08ec89131130245ca0 100644 --- a/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.cpp +++ b/src/gpu/GridGenerator/geometries/TriangularMesh/TriangularMeshStrategy.cpp @@ -32,7 +32,7 @@ //======================================================================================= #include "TriangularMeshStrategy.h" -#include "Core/Timer/Timer.h" +#include "Timer/Timer.h" #include "basics/geometry3d/GbTriFaceMesh3D.h" @@ -56,7 +56,7 @@ void PointInObjectDiscretizationStrategy::doDiscretize(TriangularMesh* triangula { triangularMesh->generateGbTriFaceMesh3D(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start Point-In-Object Test:\n"; + VF_LOG_INFO("Start Point-In-Object Test"); // trigger the GbTriFaceMesh3D to generate a kd-tree triangularMesh->getGbTriFaceMesh3D()->isPointInGbObject3D(0.0, 0.0, 0.0); @@ -79,12 +79,11 @@ void PointInObjectDiscretizationStrategy::doDiscretize(TriangularMesh* triangula // grid->setNodeTo(i, OuterType); if( timer->getCurrentRuntimeInSeconds() > outputTime ){ - *logging::out << logging::Logger::INFO_INTERMEDIATE << " " << index << "/" << grid->getSize() <<" nodes tested!\n"; + VF_LOG_INFO(" {} / {} nodes tested", index, grid->getSize()); timer->start(); } } - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Done Point-In-Object Test\n"; + VF_LOG_INFO("Done Point-In-Object Test"); } diff --git a/src/gpu/GridGenerator/geometries/Vertex/Vertex.h b/src/gpu/GridGenerator/geometries/Vertex/Vertex.h index ec5fc0f1ced64f7757de26deaf3053504e29d7c6..48e4712d7d701e3710c6ff7c0876e3f762a464d9 100644 --- a/src/gpu/GridGenerator/geometries/Vertex/Vertex.h +++ b/src/gpu/GridGenerator/geometries/Vertex/Vertex.h @@ -46,7 +46,6 @@ public: Vertex(real x, real y, real z); Vertex(); - ~Vertex() {} real getEuclideanDistanceTo(const Vertex &w) const; Vertex operator-(const Vertex &v) const; diff --git a/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.cpp b/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.cpp index 89bcd50349fe1a7591c5a873b5924a0c8ce8c2f3..5019f2a7547c509df6b7afd034cae179356c74ec 100644 --- a/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.cpp +++ b/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.cpp @@ -38,18 +38,14 @@ VerticalCylinder::VerticalCylinder(const double& centerX, const double& centerY, } -VerticalCylinder::~VerticalCylinder() -{ -} - SPtr<VerticalCylinder> VerticalCylinder::makeShared(double centerX, double centerY, double centerZ, double radius, double height) { - return SPtr<VerticalCylinder>(new VerticalCylinder(centerX, centerY, centerZ, radius, height)); + return std::make_shared<VerticalCylinder>(centerX, centerY, centerZ, radius, height); } -Object* VerticalCylinder::clone() const +SPtr<Object> VerticalCylinder::clone() const { - return new VerticalCylinder(centerX, centerY, centerZ, radius, height); + return std::make_shared<VerticalCylinder>(centerX, centerY, centerZ, radius, height); } double VerticalCylinder::getX1Centroid() diff --git a/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h b/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h index e995d2ba16eba17930401c99c260f81b9c6077b4..64cdecef5824388a31a4f545c85b1194d3f4c77b 100644 --- a/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h +++ b/src/gpu/GridGenerator/geometries/VerticalCylinder/VerticalCylinder.h @@ -40,11 +40,10 @@ class GRIDGENERATOR_EXPORT VerticalCylinder : public Object { public: VerticalCylinder(const double& centerX, const double& centerY, const double& centerZ, const double& radius, const double& height); - virtual ~VerticalCylinder(); static SPtr<VerticalCylinder> makeShared(double centerX, double centerY, double centerZ, double radius, double height); - Object* clone() const override; + SPtr<Object> clone() const override; double getX1Centroid() override; double getX1Minimum() override; diff --git a/src/gpu/GridGenerator/global.h b/src/gpu/GridGenerator/global.h index 79f62bb354bed18075f6a8327a18f24d1d0fd1e2..296c6727f248933e259065e68cb81d8bf4e6c119 100644 --- a/src/gpu/GridGenerator/global.h +++ b/src/gpu/GridGenerator/global.h @@ -43,8 +43,8 @@ #include "GridGenerator_export.h" #include "basics/PointerDefinitions.h" -#include "basics/Core/DataTypes.h" +#include "basics/DataTypes.h" -#include "basics/Core/Logger/Logger.h" +#include <logger/Logger.h> #endif diff --git a/src/gpu/GridGenerator/grid/Grid.h b/src/gpu/GridGenerator/grid/Grid.h index ad2ce473fb65fe4414f6da5c4caf0d3e140b7e02..d0969cd8a5318a91c5a486ba1f8811940aa69bd0 100644 --- a/src/gpu/GridGenerator/grid/Grid.h +++ b/src/gpu/GridGenerator/grid/Grid.h @@ -33,8 +33,6 @@ #ifndef GRID_H #define GRID_H -#include "Core/LbmOrGks.h" - #include "gpu/GridGenerator/global.h" #include "gpu/GridGenerator/geometries/Vertex/Vertex.h" @@ -54,7 +52,7 @@ class GRIDGENERATOR_EXPORT Grid public: virtual ~Grid() = default; - virtual const Object* getObject() const = 0; + virtual SPtr<const Object> getObject() const = 0; virtual real getDelta() const = 0; virtual uint getSparseSize() const = 0; @@ -101,7 +99,7 @@ public: virtual uint *getFC_offset() const = 0; virtual real *getDistribution() const = 0; - virtual int* getDirection() const = 0; + virtual const std::vector<int> &getDirection() const = 0; virtual int getStartDirection() const = 0; virtual int getEndDirection() const = 0; @@ -114,11 +112,11 @@ public: virtual void setOddStart(bool xOddStart, bool yOddStart, bool zOddStart) = 0; - virtual void findGridInterface(SPtr<Grid> grid, LbmOrGks lbmOrGks) = 0; + virtual void findGridInterface(SPtr<Grid> grid) = 0; virtual void repairGridInterfaceOnMultiGPU(SPtr<Grid> fineGrid) = 0; - virtual void limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) = 0; + virtual void limitToSubDomain(SPtr<BoundingBox> subDomainBox) = 0; virtual void enableFindSolidBoundaryNodes() = 0; virtual void enableComputeQs() = 0; @@ -161,7 +159,7 @@ public: virtual void setNumberOfLayers(uint numberOfLayers) = 0; - virtual void findCommunicationIndices(int direction, SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) = 0; + virtual void findCommunicationIndices(int direction, SPtr<BoundingBox> subDomainBox) = 0; virtual uint getNumberOfSendNodes(int direction) = 0; virtual uint getNumberOfReceiveNodes(int direction) = 0; diff --git a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp index 003e6dcd223d2bf019c83f71349a9a7bec84efdc..87ec7bab021064de527d251b5fe2908af8b5055d 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp +++ b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp @@ -94,7 +94,7 @@ void LevelGridBuilder::setSlipBoundaryCondition(SideType sideType, real normalX, slipBoundaryCondition->fillSlipNormalLists(); boundaryConditions[level]->slipBoundaryConditions.push_back(slipBoundaryCondition); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Slip BC on level " << level << " with " << (int)slipBoundaryCondition->indices.size() << "\n"; + VF_LOG_INFO("Set Slip BC on level {} with {}", level, slipBoundaryCondition->indices.size()); } } } @@ -114,7 +114,7 @@ void LevelGridBuilder::setSlipGeometryBoundaryCondition(real normalX, real norma boundaryConditions[level]->geometryBoundaryCondition->fillSlipNormalLists(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Geometry Slip BC on level " << level << " with " << (int)boundaryConditions[level]->geometryBoundaryCondition->indices.size() <<"\n"; + VF_LOG_INFO("Set Geometry Slip BC on level {} with {}", level, boundaryConditions[level]->geometryBoundaryCondition->indices.size()); } } } @@ -144,7 +144,7 @@ void LevelGridBuilder::setStressBoundaryCondition( SideType sideType, boundaryConditions[level]->stressBoundaryConditions.push_back(stressBoundaryCondition); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Stress BC on level " << level << " with " << (int)stressBoundaryCondition->indices.size() << "\n"; + VF_LOG_INFO("Set Stress BC on level {} with {}", level, stressBoundaryCondition->indices.size()); } } @@ -167,7 +167,7 @@ void LevelGridBuilder::setVelocityBoundaryCondition(SideType sideType, real vx, boundaryConditions[level]->velocityBoundaryConditions.push_back(velocityBoundaryCondition); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Velocity BC on level " << level << " with " << (int)velocityBoundaryCondition->indices.size() <<"\n"; + VF_LOG_INFO("Set Velocity BC on level {} with {}", level, velocityBoundaryCondition->indices.size()); } } } @@ -187,7 +187,7 @@ void LevelGridBuilder::setVelocityGeometryBoundaryCondition(real vx, real vy, re boundaryConditions[level]->geometryBoundaryCondition->fillVelocityLists(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Geometry Velocity BC on level " << level << " with " << (int)boundaryConditions[level]->geometryBoundaryCondition->indices.size() <<"\n"; + VF_LOG_INFO("Set Geometry BC on level {} with {}", level, boundaryConditions[level]->geometryBoundaryCondition->indices.size()); } } } @@ -204,7 +204,7 @@ void LevelGridBuilder::setPressureBoundaryCondition(SideType sideType, real rho) boundaryConditions[level]->pressureBoundaryConditions.push_back(pressureBoundaryCondition); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Pressure BC on level " << level << " with " << (int)pressureBoundaryCondition->indices.size() <<"\n"; + VF_LOG_INFO("Set Pressure BC on level {} with {}", level, pressureBoundaryCondition->indices.size()); } } @@ -245,7 +245,7 @@ void LevelGridBuilder::setNoSlipGeometryBoundaryCondition() { boundaryConditions[level]->geometryBoundaryCondition->side->addIndices(grids, level, boundaryConditions[level]->geometryBoundaryCondition); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Geometry No-Slip BC on level " << level << " with " << (int)boundaryConditions[level]->geometryBoundaryCondition->indices.size() <<"\n"; + VF_LOG_INFO("Set Geometry No-Slip BC on level {} with {}", level, boundaryConditions[level]->geometryBoundaryCondition->indices.size()); } } } @@ -255,7 +255,7 @@ void LevelGridBuilder::setPrecursorBoundaryCondition(SideType sideType, SPtr<Fil { if(fileLevelToGridLevelMap.empty()) { - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Mapping precursor file levels to the corresponding grid levels" << "\n"; + VF_LOG_INFO("Mapping precursor file levels to the corresponding grid levels"); for (uint level = 0; level < getNumberOfGridLevels(); level++) fileLevelToGridLevelMap.push_back(level); @@ -264,7 +264,7 @@ void LevelGridBuilder::setPrecursorBoundaryCondition(SideType sideType, SPtr<Fil { if(fileLevelToGridLevelMap.size()!=getNumberOfGridLevels()) throw std::runtime_error("In setPrecursorBoundaryCondition: fileLevelToGridLevelMap does not match with the number of levels"); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Using user defined file to grid level mapping" << "\n"; + VF_LOG_INFO("Using user defined file to grid level mapping"); } for (uint level = 0; level < getNumberOfGridLevels(); level++) @@ -279,7 +279,7 @@ void LevelGridBuilder::setPrecursorBoundaryCondition(SideType sideType, SPtr<Fil boundaryConditions[level]->precursorBoundaryConditions.push_back(precursorBoundaryCondition); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Set Precursor BC on level " << level << " with " << (int)precursorBoundaryCondition->indices.size() << "\n"; + VF_LOG_INFO("Set Precursor BC on level {} with {}", level, precursorBoundaryCondition->indices.size()); } } @@ -790,10 +790,10 @@ GRIDGENERATOR_EXPORT SPtr<GeometryBoundaryCondition> LevelGridBuilder::getGeomet void LevelGridBuilder::findFluidNodes(bool splitDomain) { - *logging::out << logging::Logger::INFO_HIGH << "Start findFluidNodes()\n"; + VF_LOG_TRACE("Start findFluidNodes()"); for (uint i = 0; i < grids.size(); i++) grids[i]->findFluidNodeIndices(splitDomain); - *logging::out << logging::Logger::INFO_HIGH << "Done with findFluidNodes()\n"; + VF_LOG_TRACE("Done findFluidNodes()"); } diff --git a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h index 2e0eaf13080c46260de2a0c845fbf784a2cc3e09..4924432dbf05ca2213e5fa08cf16a28ea75f8c9e 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h +++ b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h @@ -38,7 +38,7 @@ #include <memory> #include <array> -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> #include "gpu/GridGenerator/global.h" @@ -47,7 +47,7 @@ #include "gpu/GridGenerator/grid/GridInterface.h" #include "gpu/GridGenerator/grid/NodeValues.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; struct Vertex; class Grid; diff --git a/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.cpp b/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.cpp index da18a883181069f089e7232c9cd1b4f19cc9dc35..e45ad99d8a63c332aa3723eb682b61dbc267f4db 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.cpp +++ b/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.cpp @@ -61,7 +61,7 @@ SPtr<MultipleGridBuilder> MultipleGridBuilder::makeShared(SPtr<GridFactory> grid void MultipleGridBuilder::addCoarseGrid(real startX, real startY, real startZ, real endX, real endY, real endZ, real delta) { - boundaryConditions.push_back(SPtr<BoundaryConditions>(new BoundaryConditions)); + boundaryConditions.push_back(std::make_shared<BoundaryConditions>()); startX -= 0.5 * delta; startY -= 0.5 * delta; @@ -70,11 +70,11 @@ void MultipleGridBuilder::addCoarseGrid(real startX, real startY, real startZ, r endY += 0.5 * delta; endZ += 0.5 * delta; - const auto grid = this->makeGrid(new Cuboid(startX, startY, startZ, endX, endY, endZ), startX, startY, startZ, endX, endY, endZ, delta, 0); + const auto grid = this->makeGrid(std::make_shared<Cuboid>(startX, startY, startZ, endX, endY, endZ), startX, startY, startZ, endX, endY, endZ, delta, 0); addGridToList(grid); } -void MultipleGridBuilder::addGeometry(Object* solidObject) +void MultipleGridBuilder::addGeometry(SPtr<Object> solidObject) { this->solidObject = solidObject; @@ -85,7 +85,7 @@ void MultipleGridBuilder::addGeometry(Object* solidObject) } } -void MultipleGridBuilder::addGeometry(Object* solidObject, uint level) +void MultipleGridBuilder::addGeometry(SPtr<Object> solidObject, uint level) { this->solidObject = solidObject; auto gridShape = solidObject->clone(); @@ -94,7 +94,7 @@ void MultipleGridBuilder::addGeometry(Object* solidObject, uint level) this->addGrid(gridShape, level); } -void MultipleGridBuilder::addGrid(Object* gridShape) +void MultipleGridBuilder::addGrid(SPtr<Object> gridShape) { if (!coarseGridExists()) return emitNoCoarseGridExistsWarning(); @@ -104,7 +104,7 @@ void MultipleGridBuilder::addGrid(Object* gridShape) addGridToListIfValid(grid); } -void MultipleGridBuilder::addGrid(Object* gridShape, uint levelFine) +void MultipleGridBuilder::addGrid(SPtr<Object> gridShape, uint levelFine) { if (!coarseGridExists()) return emitNoCoarseGridExistsWarning(); @@ -140,13 +140,13 @@ void MultipleGridBuilder::addGrid(Object* gridShape, uint levelFine) //eraseGridsFromListIfInvalid(oldGridSize); } -void MultipleGridBuilder::addFineGridToList(uint level, Object* gridShape) +void MultipleGridBuilder::addFineGridToList(uint level, SPtr<Object> gridShape) { const auto grid = makeGrid(gridShape, level, 0); grids.push_back(grid); } -void MultipleGridBuilder::addIntermediateGridsToList(uint levelDifference, uint levelFine, uint nodesBetweenGrids, Object* gridShape) +void MultipleGridBuilder::addIntermediateGridsToList(uint levelDifference, uint levelFine, uint nodesBetweenGrids, SPtr<Object> gridShape) { if (levelDifference > 0) { @@ -156,7 +156,7 @@ void MultipleGridBuilder::addIntermediateGridsToList(uint levelDifference, uint for (int i = levelDifference - 1; i >= 0; i--) { const real scalingFactor = nodesBetweenGrids * spacings[i] * calculateDelta(levelFine); - Object* gridShapeClone = gridShape->clone(); + SPtr<Object> gridShapeClone = gridShape->clone(); gridShapeClone->scale(scalingFactor); const auto grid = makeGrid(gridShapeClone, level++, 0); @@ -193,7 +193,7 @@ void MultipleGridBuilder::addGridToListIfValid(SPtr<Grid> grid) addGridToList(grid); } -SPtr<Grid> MultipleGridBuilder::makeGrid(Object* gridShape, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, uint level) const +SPtr<Grid> MultipleGridBuilder::makeGrid(SPtr<Object> gridShape, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, uint level) const { return gridFactory->makeGrid(gridShape, startX, startY, startZ, endX, endY, endZ, delta, level); } @@ -203,9 +203,9 @@ bool MultipleGridBuilder::coarseGridExists() const return !grids.empty(); } -SPtr<Grid> MultipleGridBuilder::makeGrid(Object* gridShape, uint level, uint levelFine) +SPtr<Grid> MultipleGridBuilder::makeGrid(SPtr<Object> gridShape, uint level, uint levelFine) { - boundaryConditions.push_back(SPtr<BoundaryConditions>(new BoundaryConditions)); + boundaryConditions.push_back(std::make_shared<BoundaryConditions>()); const real delta = calculateDelta(level); @@ -213,11 +213,11 @@ SPtr<Grid> MultipleGridBuilder::makeGrid(Object* gridShape, uint level, uint lev auto staggeredCoordinates = getStaggeredCoordinates(gridShape, level, levelFine, xOddStart, yOddStart, zOddStart); - SPtr<Grid> newGrid = this->makeGrid(gridShape, staggeredCoordinates[0], - staggeredCoordinates[1], - staggeredCoordinates[2], - staggeredCoordinates[3], - staggeredCoordinates[4], + SPtr<Grid> newGrid = this->makeGrid(gridShape, staggeredCoordinates[0], + staggeredCoordinates[1], + staggeredCoordinates[2], + staggeredCoordinates[3], + staggeredCoordinates[4], staggeredCoordinates[5], delta, level); newGrid->setOddStart( xOddStart, yOddStart, zOddStart ); @@ -233,7 +233,7 @@ real MultipleGridBuilder::calculateDelta(uint level) const return delta; } -std::array<real, 6> MultipleGridBuilder::getStaggeredCoordinates(Object* gridShape, uint level, uint levelFine, bool& xOddStart, bool& yOddStart, bool& zOddStart) const +std::array<real, 6> MultipleGridBuilder::getStaggeredCoordinates(SPtr<Object> gridShape, uint level, uint levelFine, bool& xOddStart, bool& yOddStart, bool& zOddStart) const { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // @@ -466,7 +466,7 @@ std::vector<SPtr<Grid> > MultipleGridBuilder::getGrids() const // => MultipleGridBuilder::findCommunicationIndices(...) // => LevelGridBuilder::setCommunicationProcess(...) // -void MultipleGridBuilder::buildGrids( LbmOrGks lbmOrGks, bool enableThinWalls ) +void MultipleGridBuilder::buildGrids(bool enableThinWalls ) { ////////////////////////////////////////////////////////////////////////// @@ -490,7 +490,7 @@ void MultipleGridBuilder::buildGrids( LbmOrGks lbmOrGks, bool enableThinWalls ) // for( int level = (int)grids.size()-1; level >= 0; level-- ) { - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start initializing level " << level << "\n"; + VF_LOG_INFO("Start initializing level {}", level); // On the coarse grid every thing is Fluid (w.r.t. the refinement) // On the finest grid the Fluid region is defined by the Object @@ -502,7 +502,7 @@ void MultipleGridBuilder::buildGrids( LbmOrGks lbmOrGks, bool enableThinWalls ) else grids[level]->inital( grids[level+1], this->numberOfLayersBetweenLevels ); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Done initializing level " << level << "\n"; + VF_LOG_INFO("Done initializing level {}", level); } ////////////////////////////////////////////////////////////////////////// @@ -516,8 +516,7 @@ void MultipleGridBuilder::buildGrids( LbmOrGks lbmOrGks, bool enableThinWalls ) // if (solidObject) { - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start with Q Computation\n"; + VF_LOG_TRACE("Start with Q Computation"); // Currently the solid object is only used on the finest grid, // because refinement into solid objects is not yet implemented. @@ -529,13 +528,13 @@ void MultipleGridBuilder::buildGrids( LbmOrGks lbmOrGks, bool enableThinWalls ) //for( uint level = 0; level < grids.size(); level++ ) uint level = (uint)grids.size() - 1; { - // the Grid::mesh(...) method distinguishes inside and ouside regions + // the Grid::mesh(...) method distinguishes inside and outside regions // of the solid domain.: // => set inner nodes to INVALID_SOLID // => close needle sells // => set one layer of STOPPER_SOLID nodes in the solid domain // => set one layer of BC_SOLID nodes in the fluid domain - grids[level]->mesh(solidObject); + grids[level]->mesh(solidObject.get()); // if thin walls are enables additional BC_SOLID nodes are found by // Grid::findOs(...). To prevent the actual Q computation, @@ -544,18 +543,17 @@ void MultipleGridBuilder::buildGrids( LbmOrGks lbmOrGks, bool enableThinWalls ) // additionally some needle cells are closed in this process. if (enableThinWalls) { grids[level]->enableFindSolidBoundaryNodes(); - grids[level]->findQs(solidObject); + grids[level]->findQs(solidObject.get()); grids[level]->closeNeedleCellsThinWall(); grids[level]->enableComputeQs(); } // compute the sub grid distances // this works for STL and Sphere objects, but not yet for other primitives! - if( lbmOrGks == LBM ) - grids[level]->findQs(solidObject); + grids[level]->findQs(solidObject.get()); } - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Done with Q Computation\n"; + VF_LOG_TRACE("Done with Q Computation"); } ////////////////////////////////////////////////////////////////////////// @@ -566,7 +564,7 @@ void MultipleGridBuilder::buildGrids( LbmOrGks lbmOrGks, bool enableThinWalls ) // https://publikationsserver.tu-braunschweig.de/receive/dbbs_mods_00068716 // for (size_t i = 0; i < grids.size() - 1; i++) - grids[i]->findGridInterface(grids[i + 1], lbmOrGks); + grids[i]->findGridInterface(grids[i + 1]); ////////////////////////////////////////////////////////////////////////// @@ -574,7 +572,7 @@ void MultipleGridBuilder::buildGrids( LbmOrGks lbmOrGks, bool enableThinWalls ) // and INVALID_OUT_OF_GRID if( this->subDomainBox ) for (size_t i = 0; i < grids.size(); i++) - grids[i]->limitToSubDomain( this->subDomainBox, lbmOrGks ); + grids[i]->limitToSubDomain( this->subDomainBox); ////////////////////////////////////////////////////////////////////////// @@ -588,12 +586,10 @@ void MultipleGridBuilder::buildGrids( LbmOrGks lbmOrGks, bool enableThinWalls ) // => computes the sparse indices // => generates neighbor connectivity taking into account periodic boundaries // => undates the interface connectivity to sparse indices (overwrites matrix indices!) - if (lbmOrGks == LBM) { - for (size_t i = 0; i < grids.size() - 1; i++) - grids[i]->findSparseIndices(grids[i + 1]); + for (size_t i = 0; i < grids.size() - 1; i++) + grids[i]->findSparseIndices(grids[i + 1]); - grids[grids.size() - 1]->findSparseIndices(nullptr); - } + grids[grids.size() - 1]->findSparseIndices(nullptr); ////////////////////////////////////////////////////////////////////////// } @@ -606,24 +602,24 @@ GRIDGENERATOR_EXPORT void MultipleGridBuilder::setNumberOfLayers(uint numberOfLa void MultipleGridBuilder::emitNoCoarseGridExistsWarning() { - *logging::out << logging::Logger::WARNING << "No Coarse grid was added before. Actual Grid is not added, please create coarse grid before.\n"; + VF_LOG_WARNING("No Coarse grid was added before. Actual Grid is not added, please create coarse grid before."); } void MultipleGridBuilder::emitGridIsNotInCoarseGridWarning() { - *logging::out << logging::Logger::WARNING << "Grid lies not inside of coarse grid. Actual Grid is not added.\n"; + VF_LOG_WARNING("Grid lies not inside of coarse grid. Actual Grid is not added."); } -void MultipleGridBuilder::findCommunicationIndices(int direction, LbmOrGks lbmOrGks) +void MultipleGridBuilder::findCommunicationIndices(int direction) { - *logging::out << logging::Logger::INFO_HIGH << "Start findCommunicationIndices()\n"; + VF_LOG_TRACE("Start findCommunicationIndices()"); if( this->subDomainBox ) for (size_t i = 0; i < grids.size(); i++) - grids[i]->findCommunicationIndices(direction, this->subDomainBox, lbmOrGks); + grids[i]->findCommunicationIndices(direction, this->subDomainBox); - *logging::out << logging::Logger::INFO_HIGH << "Done with findCommunicationIndices()\n"; + VF_LOG_TRACE("Done findCommunicationIndices()"); } void MultipleGridBuilder::writeGridsToVtk(const std::string& path) const diff --git a/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.h b/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.h index 2d2dc8bf0345288912132551c5d94b5caec44965..8d94edd0f42b237ef4e45e5a4f4246d739a51b46 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.h +++ b/src/gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.h @@ -35,7 +35,6 @@ #include <vector> #include <array> -#include "Core/LbmOrGks.h" #include "global.h" @@ -55,11 +54,11 @@ public: GRIDGENERATOR_EXPORT static SPtr<MultipleGridBuilder> makeShared(SPtr<GridFactory> gridFactory); GRIDGENERATOR_EXPORT void addCoarseGrid(real startX, real startY, real startZ, real endX, real endY, real endZ, real delta); - GRIDGENERATOR_EXPORT void addGrid(Object *gridShape); - GRIDGENERATOR_EXPORT void addGrid(Object *gridShape, uint levelFine); + GRIDGENERATOR_EXPORT void addGrid(SPtr<Object> gridShape); + GRIDGENERATOR_EXPORT void addGrid(SPtr<Object> gridShape, uint levelFine); - GRIDGENERATOR_EXPORT void addGeometry(Object *gridShape); - GRIDGENERATOR_EXPORT void addGeometry(Object *solidObject, uint level); + GRIDGENERATOR_EXPORT void addGeometry(SPtr<Object> gridShape); + GRIDGENERATOR_EXPORT void addGeometry(SPtr<Object> solidObject, uint level); GRIDGENERATOR_EXPORT uint getNumberOfLevels() const; GRIDGENERATOR_EXPORT real getDelta(uint level) const; @@ -73,7 +72,7 @@ public: GRIDGENERATOR_EXPORT real getEndZ(uint level) const; GRIDGENERATOR_EXPORT std::vector<SPtr<Grid> > getGrids() const; - GRIDGENERATOR_EXPORT void buildGrids(LbmOrGks lbmOrGks, bool enableThinWalls = false); + GRIDGENERATOR_EXPORT void buildGrids(bool enableThinWalls = false); GRIDGENERATOR_EXPORT void setNumberOfLayers( uint numberOfLayersFine, uint numberOfLayersBetweenLevels ); @@ -87,24 +86,24 @@ private: bool coarseGridExists() const; bool isGridInCoarseGrid(SPtr<Grid> grid) const; - void addFineGridToList(uint level, Object *gridShape); - void addIntermediateGridsToList(uint levelDifference, uint levelFine, uint nodesBetweenGrids, Object *gridShape); + void addFineGridToList(uint level, SPtr<Object> gridShape); + void addIntermediateGridsToList(uint levelDifference, uint levelFine, uint nodesBetweenGrids, SPtr<Object>gridShape); void eraseGridsFromListIfInvalid(uint oldSize); void addGridToListIfValid(SPtr<Grid> grid); - std::array<real, 6> getStaggeredCoordinates(Object *gridShape, uint level, uint levelFine, bool &xOddStart, bool &yOddStart, bool &zOddStart) const; + std::array<real, 6> getStaggeredCoordinates(SPtr<Object> gridShape, uint level, uint levelFine, bool &xOddStart, bool &yOddStart, bool &zOddStart) const; std::array<real, 6> getStaggeredCoordinates(real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, uint level) const; std::array<real, 3> getOffset(real delta) const; std::vector<uint> getSpacingFactors(uint levelDifference) const; - SPtr<Grid> makeGrid(Object *gridShape, uint level, uint levelFine); - SPtr<Grid> makeGrid(Object *gridShape, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, uint level) const; + SPtr<Grid> makeGrid(SPtr<Object> gridShape, uint level, uint levelFine); + SPtr<Grid> makeGrid(SPtr<Object> gridShape, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, uint level) const; static void emitNoCoarseGridExistsWarning(); static void emitGridIsNotInCoarseGridWarning(); SPtr<GridFactory> gridFactory; - Object *solidObject = nullptr; + SPtr<Object> solidObject = nullptr; uint numberOfLayersFine; uint numberOfLayersBetweenLevels; @@ -112,7 +111,7 @@ private: SPtr<BoundingBox> subDomainBox; public: - GRIDGENERATOR_EXPORT void findCommunicationIndices(int direction, LbmOrGks lbmOrGks); + GRIDGENERATOR_EXPORT void findCommunicationIndices(int direction); }; #endif diff --git a/src/gpu/GridGenerator/grid/GridFactory.h b/src/gpu/GridGenerator/grid/GridFactory.h index 53d358d5325390394f1d38694de605e5cc0d2f56..a78dfe6d848a5f180bea9073056522d0e2196433 100644 --- a/src/gpu/GridGenerator/grid/GridFactory.h +++ b/src/gpu/GridGenerator/grid/GridFactory.h @@ -50,16 +50,16 @@ class GRIDGENERATOR_EXPORT GridFactory public: static SPtr<GridFactory> make() { - return SPtr<GridFactory>(new GridFactory()); + return std::make_shared<GridFactory>(); } - SPtr<Grid> makeGrid(Object* gridShape, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, uint level, const std::string& d3Qxx = "D3Q27") + SPtr<Grid> makeGrid(SPtr<Object> gridShape, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, uint level, const std::string& d3Qxx = "D3Q27") { SPtr<GridImp> grid; grid = GridImp::makeShared(gridShape, startX, startY, startZ, endX, endY, endZ, delta, d3Qxx, level); - grid->setTriangularMeshDiscretizationStrategy(new PointInObjectDiscretizationStrategy()); + grid->setTriangularMeshDiscretizationStrategy(std::make_shared<PointInObjectDiscretizationStrategy>()); // Probably a bug, as this->triangularMeshDiscretizationStrategy is never used. Until ad5efd332a1d6808fccdf8e54fa547630eff401b this line was ``grid->setTriangularMeshDiscretizationStrategy(this->triangularMeshDiscretizationStrategy);`` return grid; } @@ -69,19 +69,19 @@ public: switch (triangularMeshDiscretizationMethod) { case TriangularMeshDiscretizationMethod::POINT_UNDER_TRIANGLE: - triangularMeshDiscretizationStrategy = new PointUnderTriangleStrategy(); + triangularMeshDiscretizationStrategy = std::make_shared<PointUnderTriangleStrategy>(); break; case TriangularMeshDiscretizationMethod::RAYCASTING: - triangularMeshDiscretizationStrategy = new RayCastingDiscretizationStrategy(); + triangularMeshDiscretizationStrategy = std::make_shared<RayCastingDiscretizationStrategy>(); break; case TriangularMeshDiscretizationMethod::POINT_IN_OBJECT: - triangularMeshDiscretizationStrategy = new PointInObjectDiscretizationStrategy(); + triangularMeshDiscretizationStrategy = std::make_shared<PointInObjectDiscretizationStrategy>(); break; } } private: - TriangularMeshDiscretizationStrategy* triangularMeshDiscretizationStrategy; + SPtr<TriangularMeshDiscretizationStrategy> triangularMeshDiscretizationStrategy; }; diff --git a/src/gpu/GridGenerator/grid/GridImp.cpp b/src/gpu/GridGenerator/grid/GridImp.cpp index 9fc3c099e9f382c8d22fa64626c89219ef29c360..8ece061168883544d9857f109d505614ca005a43 100644 --- a/src/gpu/GridGenerator/grid/GridImp.cpp +++ b/src/gpu/GridGenerator/grid/GridImp.cpp @@ -36,6 +36,7 @@ #include <sstream> # include <algorithm> #include <cmath> +#include <vector> #include "global.h" @@ -60,7 +61,7 @@ int DIRECTIONS[DIR_END_MAX][DIMENSION]; using namespace vf::gpu; -GridImp::GridImp(Object* object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, Distribution distribution, uint level) +GridImp::GridImp(SPtr<Object> object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, Distribution distribution, uint level) : object(object), startX(startX), startY(startY), @@ -91,7 +92,7 @@ GridImp::GridImp(Object* object, real startX, real startY, real startZ, real end initalNumberOfNodesAndSize(); } -SPtr<GridImp> GridImp::makeShared(Object* object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, std::string d3Qxx, uint level) +SPtr<GridImp> GridImp::makeShared(SPtr<Object> object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, std::string d3Qxx, uint level) { Distribution distribution = DistributionHelper::getDistribution(d3Qxx); SPtr<GridImp> grid(new GridImp(object, startX, startY, startZ, endX, endY, endZ, delta, distribution, level)); @@ -130,31 +131,31 @@ void GridImp::inital(const SPtr<Grid> fineGrid, uint numberOfLayers) for (uint i = 0; i < this->size; i++) this->qIndices[i] = INVALID_INDEX; - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start initalNodesToOutOfGrid()\n"; + VF_LOG_TRACE("Start initalNodesToOutOfGrid()"); + #pragma omp parallel for for (int index = 0; index < (int)this->size; index++) this->initalNodeToOutOfGrid(index); if( this->innerRegionFromFinerGrid ){ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start setInnerBasedOnFinerGrid()\n"; + VF_LOG_TRACE("Start setInnerBasedOnFinerGrid()"); this->setInnerBasedOnFinerGrid(fineGrid); } else{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start findInnerNodes()\n"; + VF_LOG_TRACE("Start findInnerNodes()"); this->object->findInnerNodes( shared_from_this() ); } - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start addOverlap()\n"; + VF_LOG_TRACE("Start addOverlap()"); this->addOverlap(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start fixOddCells()\n"; + VF_LOG_TRACE("Start fixOddCells()"); #pragma omp parallel for for (int index = 0; index < (int)this->size; index++) this->fixOddCell(index); if( enableFixRefinementIntoTheWall ) { - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start fixRefinementIntoWall()\n"; + VF_LOG_TRACE("Start fixRefinementIntoWall()"); #pragma omp parallel for for (int xIdx = 0; xIdx < (int)this->nx; xIdx++) { for (uint yIdx = 0; yIdx < this->ny; yIdx++) { @@ -179,15 +180,13 @@ void GridImp::inital(const SPtr<Grid> fineGrid, uint numberOfLayers) } } } - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start findEndOfGridStopperNodes()\n"; + VF_LOG_TRACE("Start findEndOfGridStopperNodes()"); #pragma omp parallel for for (int index = 0; index < (int)this->size; index++) this->findEndOfGridStopperNode(index); - *logging::out << logging::Logger::INFO_INTERMEDIATE - << "Grid created: " << "from (" << this->startX << ", " << this->startY << ", " << this->startZ << ") to (" << this->endX << ", " << this->endY << ", " << this->endZ << ")\n" - << "nodes: " << this->nx << " x " << this->ny << " x " << this->nz << " = " << this->size << "\n"; + VF_LOG_INFO("Grid created: from ({}, {}, {}) to ({}, {}, {})", this->startX, this->startY, this->startZ, this->endX, this->endY, this->endZ); + VF_LOG_INFO("nodes: {} x {} x {} = {}", this->nx, this->ny, this->nz, this->size); } void GridImp::setOddStart(bool xOddStart, bool yOddStart, bool zOddStart) @@ -515,7 +514,7 @@ bool GridImp::cellContainsOnly(Cell &cell, char typeA, char typeB) const return true; } -const Object * GridImp::getObject() const +SPtr<const Object> GridImp::getObject() const { return this->object; } @@ -812,12 +811,12 @@ uint GridImp::getLevel() const return this->level; } -void GridImp::setTriangularMeshDiscretizationStrategy(TriangularMeshDiscretizationStrategy* triangularMeshDiscretizationStrategy) +void GridImp::setTriangularMeshDiscretizationStrategy(SPtr<TriangularMeshDiscretizationStrategy> triangularMeshDiscretizationStrategy) { this->triangularMeshDiscretizationStrategy = triangularMeshDiscretizationStrategy; } -TriangularMeshDiscretizationStrategy * GridImp::getTriangularMeshDiscretizationStrategy() +SPtr<TriangularMeshDiscretizationStrategy> GridImp::getTriangularMeshDiscretizationStrategy() { return this->triangularMeshDiscretizationStrategy; } @@ -861,7 +860,7 @@ void GridImp::setNumberOfLayers(uint numberOfLayers) void GridImp::findSparseIndices(SPtr<Grid> finerGrid) { - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Find sparse indices..."; + VF_LOG_TRACE("Find sparse indices..."); auto fineGrid = std::static_pointer_cast<GridImp>(finerGrid); this->updateSparseIndices(); @@ -876,8 +875,7 @@ void GridImp::findSparseIndices(SPtr<Grid> finerGrid) } const uint newGridSize = this->getSparseSize(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "... done. new size: " << newGridSize - << ", delete nodes:" << this->getSize() - newGridSize << "\n"; + VF_LOG_TRACE("... done. new size: {}, delete nodes: {}", newGridSize, this->getSize() - newGridSize); } void GridImp::findForGridInterfaceNewIndices(SPtr<GridImp> fineGrid) @@ -1105,14 +1103,13 @@ int GridImp::getSparseIndex(const real &x, const real &y, const real &z) const // --------------------------------------------------------- // // Find Interface // // --------------------------------------------------------- // -void GridImp::findGridInterface(SPtr<Grid> finerGrid, LbmOrGks lbmOrGks) +void GridImp::findGridInterface(SPtr<Grid> finerGrid) { auto fineGrid = std::static_pointer_cast<GridImp>(finerGrid); const auto coarseLevel = this->getLevel(); const auto fineLevel = fineGrid->getLevel(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "find interface level " << coarseLevel << " -> " - << fineLevel; + VF_LOG_TRACE("find interface level {} -> {}", coarseLevel, fineLevel); this->gridInterface = new GridInterface(); // TODO: this is stupid! concave refinements can easily have many more interface cells @@ -1125,7 +1122,7 @@ void GridImp::findGridInterface(SPtr<Grid> finerGrid, LbmOrGks lbmOrGks) this->gridInterface->fc.offset = new uint[sizeCF]; for (uint index = 0; index < this->getSize(); index++) - this->findGridInterfaceCF(index, *fineGrid, lbmOrGks); + this->findGridInterfaceCF(index, *fineGrid); for (uint index = 0; index < this->getSize(); index++) this->findGridInterfaceFC(index, *fineGrid); @@ -1133,12 +1130,7 @@ void GridImp::findGridInterface(SPtr<Grid> finerGrid, LbmOrGks lbmOrGks) for (uint index = 0; index < this->getSize(); index++) this->findOverlapStopper(index, *fineGrid); - if (lbmOrGks == GKS) { - for (uint index = 0; index < this->getSize(); index++) - this->findInvalidBoundaryNodes(index); - } - - *logging::out << logging::Logger::INFO_INTERMEDIATE << " ... done. \n"; + VF_LOG_TRACE(" ... done."); } void GridImp::repairGridInterfaceOnMultiGPU(SPtr<Grid> fineGrid) @@ -1146,7 +1138,7 @@ void GridImp::repairGridInterfaceOnMultiGPU(SPtr<Grid> fineGrid) this->gridInterface->repairGridInterfaceOnMultiGPU( shared_from_this(), std::static_pointer_cast<GridImp>(fineGrid) ); } -void GridImp::limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) +void GridImp::limitToSubDomain(SPtr<BoundingBox> subDomainBox) { for( uint index = 0; index < this->size; index++ ){ @@ -1157,8 +1149,7 @@ void GridImp::limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks BoundingBox tmpSubDomainBox = *subDomainBox; // one layer for receive nodes and one for stoppers - if( lbmOrGks == LBM ) - tmpSubDomainBox.extend(this->delta); + tmpSubDomainBox.extend(this->delta); if (!tmpSubDomainBox.isInside(x, y, z) && ( this->getFieldEntry(index) == FLUID || @@ -1176,10 +1167,7 @@ void GridImp::limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks BoundingBox tmpSubDomainBox = *subDomainBox; // one layer for receive nodes and one for stoppers - if( lbmOrGks == LBM ) - tmpSubDomainBox.extend(2.0 * this->delta); - else - tmpSubDomainBox.extend(1.0 * this->delta); + tmpSubDomainBox.extend(2.0 * this->delta); if (!tmpSubDomainBox.isInside(x, y, z)) this->setFieldEntry(index, INVALID_OUT_OF_GRID); @@ -1187,15 +1175,10 @@ void GridImp::limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks } } -void GridImp::findGridInterfaceCF(uint index, GridImp& finerGrid, LbmOrGks lbmOrGks) +void GridImp::findGridInterfaceCF(uint index, GridImp& finerGrid) { - if (lbmOrGks == LBM) - { - gridInterface->findInterfaceCF (index, this, &finerGrid); - gridInterface->findBoundaryGridInterfaceCF(index, this, &finerGrid); - } - else if (lbmOrGks == GKS) - gridInterface->findInterfaceCF_GKS(index, this, &finerGrid); + gridInterface->findInterfaceCF (index, this, &finerGrid); + gridInterface->findBoundaryGridInterfaceCF(index, this, &finerGrid); } void GridImp::findGridInterfaceFC(uint index, GridImp& finerGrid) @@ -1249,7 +1232,7 @@ void GridImp::mesh(TriangularMesh &triangularMesh) const clock_t end = clock(); const real time = (real)(real(end - begin) / CLOCKS_PER_SEC); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "time grid generation: " << time << "s\n"; + VF_LOG_INFO("time grid generation: {}s", time); } void GridImp::mesh(Triangle &triangle) @@ -1280,7 +1263,7 @@ void GridImp::mesh(Triangle &triangle) void GridImp::closeNeedleCells() { - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start closeNeedleCells()\n"; + VF_LOG_TRACE("Start closeNeedleCells()"); uint numberOfClosedNeedleCells = 0; @@ -1292,7 +1275,7 @@ void GridImp::closeNeedleCells() numberOfClosedNeedleCells++; } - *logging::out << logging::Logger::INFO_INTERMEDIATE << numberOfClosedNeedleCells << " cells closed!\n"; + VF_LOG_TRACE("{} cells closed!", numberOfClosedNeedleCells); } while( numberOfClosedNeedleCells > 0 ); } @@ -1321,7 +1304,7 @@ bool GridImp::closeCellIfNeedle(uint index) void GridImp::closeNeedleCellsThinWall() { - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start closeNeedleCellsThinWall()\n"; + VF_LOG_TRACE("Start closeNeedleCellsThinWall()"); uint numberOfClosedNeedleCells = 0; @@ -1332,8 +1315,7 @@ void GridImp::closeNeedleCellsThinWall() if (this->closeCellIfNeedleThinWall(index)) numberOfClosedNeedleCells++; } - - *logging::out << logging::Logger::INFO_INTERMEDIATE << numberOfClosedNeedleCells << " cells closed!\n"; + VF_LOG_TRACE("{} cells closed!", numberOfClosedNeedleCells); } while( numberOfClosedNeedleCells > 0 ); } @@ -1393,7 +1375,7 @@ void GridImp::findQs(TriangularMesh &triangularMesh) const clock_t end = clock(); const real time = (real)(real(end - begin) / CLOCKS_PER_SEC); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "time finding qs: " << time << "s\n"; + VF_LOG_TRACE("time finding qs: {}s", time); } void GridImp::findQs(Triangle &triangle) @@ -1650,7 +1632,7 @@ bool GridImp::checkIfAtLeastOneValidQ(const uint index, const Vertex & point, co return false; } -void GridImp::findCommunicationIndices(int direction, SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) +void GridImp::findCommunicationIndices(int direction, SPtr<BoundingBox> subDomainBox) { for( uint index = 0; index < this->size; index++ ){ real x, y, z; @@ -1662,8 +1644,8 @@ void GridImp::findCommunicationIndices(int direction, SPtr<BoundingBox> subDomai this->getFieldEntry(index) == STOPPER_OUT_OF_GRID || this->getFieldEntry(index) == STOPPER_COARSE_UNDER_FINE ) continue; - if( lbmOrGks == LBM && this->getFieldEntry(index) == STOPPER_OUT_OF_GRID_BOUNDARY ) continue; - if( lbmOrGks == LBM && this->getFieldEntry(index) == STOPPER_SOLID ) continue; + if( this->getFieldEntry(index) == STOPPER_OUT_OF_GRID_BOUNDARY ) continue; + if( this->getFieldEntry(index) == STOPPER_SOLID ) continue; if( direction == CommunicationDirections::MX ) findCommunicationIndex( index, x, subDomainBox->minX, direction); if( direction == CommunicationDirections::PX ) findCommunicationIndex( index, x, subDomainBox->maxX, direction); if( direction == CommunicationDirections::MY ) findCommunicationIndex( index, y, subDomainBox->minY, direction); @@ -1740,12 +1722,8 @@ void GridImp::repairCommunicationIndices(int direction) this->communicationIndices[direction].receiveIndices = this->communicationIndices[direction+1].receiveIndices; - - - - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size send " << (int)this->communicationIndices[direction].sendIndices.size() << "\n"; - *logging::out << logging::Logger::INFO_INTERMEDIATE << "recv send " << (int)this->communicationIndices[direction].receiveIndices.size() << "\n"; + VF_LOG_INFO("size send {}", (int)this->communicationIndices[direction].sendIndices.size()); + VF_LOG_INFO("recv send {}",(int)this->communicationIndices[direction].receiveIndices.size()); } @@ -1762,7 +1740,7 @@ real* GridImp::getDistribution() const return this->distribution.f; } -int* GridImp::getDirection() const +const std::vector<int>& GridImp::getDirection() const { return this->distribution.dirs; } diff --git a/src/gpu/GridGenerator/grid/GridImp.h b/src/gpu/GridGenerator/grid/GridImp.h index 2cd322ebed78daaf135ad97b881923ca5831bbcd..9377bbd407475add75a25af3fa38cb1fa74c833c 100644 --- a/src/gpu/GridGenerator/grid/GridImp.h +++ b/src/gpu/GridGenerator/grid/GridImp.h @@ -36,8 +36,6 @@ #include <array> #include <vector> -#include "Core/LbmOrGks.h" - #include "gpu/GridGenerator/global.h" #include "gpu/GridGenerator/grid/distributions/Distribution.h" @@ -74,10 +72,10 @@ class GRIDGENERATOR_EXPORT GridImp : public enableSharedFromThis<GridImp>, publi { protected: GridImp() = default; - GridImp(Object* object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, Distribution d, uint level); + GridImp(SPtr<Object> object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, Distribution d, uint level); public: - static SPtr<GridImp> makeShared(Object* object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, std::string d3Qxx, uint level); + static SPtr<GridImp> makeShared(SPtr<Object> object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, std::string d3Qxx, uint level); ~GridImp() override = default; private: @@ -113,7 +111,7 @@ private: uint sparseSize; bool periodicityX = false, periodicityY = false, periodicityZ = false; - Object* object; + SPtr<Object> object; GridInterface *gridInterface; int *sparseIndices; @@ -132,7 +130,7 @@ private: uint numberOfLayers; - TriangularMeshDiscretizationStrategy *triangularMeshDiscretizationStrategy; + SPtr<TriangularMeshDiscretizationStrategy> triangularMeshDiscretizationStrategy; uint numberOfSolidBoundaryNodes = 0; @@ -166,19 +164,19 @@ public: uint transCoordToIndex(const real &x, const real &y, const real &z) const override; void transIndexToCoords(uint index, real &x, real &y, real &z) const override; - void findGridInterface(SPtr<Grid> grid, LbmOrGks lbmOrGks) override; + void findGridInterface(SPtr<Grid> grid) override; void repairGridInterfaceOnMultiGPU(SPtr<Grid> fineGrid) override; - void limitToSubDomain(SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) override; + void limitToSubDomain(SPtr<BoundingBox> subDomainBox) override; void freeMemory() override; uint getLevel(real levelNull) const; uint getLevel() const; - void setTriangularMeshDiscretizationStrategy(TriangularMeshDiscretizationStrategy *triangularMeshDiscretizationStrategy); - TriangularMeshDiscretizationStrategy *getTriangularMeshDiscretizationStrategy(); + void setTriangularMeshDiscretizationStrategy(SPtr<TriangularMeshDiscretizationStrategy> triangularMeshDiscretizationStrategy); + SPtr<TriangularMeshDiscretizationStrategy> getTriangularMeshDiscretizationStrategy(); uint getNumberOfSolidBoundaryNodes() const override; void setNumberOfSolidBoundaryNodes(uint numberOfSolidBoundaryNodes) override; @@ -217,7 +215,7 @@ public: void findSolidStopperNode(uint index); void findBoundarySolidNode(uint index); - void findGridInterfaceCF(uint index, GridImp &finerGrid, LbmOrGks lbmOrGks); + void findGridInterfaceCF(uint index, GridImp &finerGrid); void findGridInterfaceFC(uint index, GridImp &finerGrid); void findOverlapStopper(uint index, GridImp &finerGrid); void findInvalidBoundaryNodes(uint index); @@ -231,7 +229,7 @@ public: bool cellContainsOnly(Cell &cell, char type) const; bool cellContainsOnly(Cell &cell, char typeA, char typeB) const; - const Object* getObject() const override; + SPtr<const Object> getObject() const override; Field getField() const; char getFieldEntry(uint index) const override; @@ -243,7 +241,7 @@ public: uint getSparseSize() const override; int getSparseIndex(uint matrixIndex) const override; real* getDistribution() const override; - int* getDirection() const override; + const std::vector<int>& getDirection() const override; int getStartDirection() const override; int getEndDirection() const override; @@ -355,7 +353,7 @@ private: void allocateQs(); public: - void findCommunicationIndices(int direction, SPtr<BoundingBox> subDomainBox, LbmOrGks lbmOrGks) override; + void findCommunicationIndices(int direction, SPtr<BoundingBox> subDomainBox) override; void findCommunicationIndex(uint index, real coordinate, real limit, int direction); uint getNumberOfSendNodes(int direction) override; diff --git a/src/gpu/GridGenerator/grid/GridImpTest.cpp b/src/gpu/GridGenerator/grid/GridImpTest.cpp index 8f5ddb1b01dd88cca7d750017ec328efe02cd92f..07b2a03f429ad8baf0badd0c966dd88235644c0a 100644 --- a/src/gpu/GridGenerator/grid/GridImpTest.cpp +++ b/src/gpu/GridGenerator/grid/GridImpTest.cpp @@ -169,17 +169,12 @@ class findNeighborsIntegrationTest : public ::testing::Test { protected: SPtr<MultipleGridBuilder> gridBuilder; + void SetUp() override { auto gridFactory = GridFactory::make(); gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - // init logger to avoid segmentation fault in buildGrids - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::Level::WARNING); - logging::Logger::timeStamp(logging::Logger::ENABLE); - logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); } }; @@ -188,7 +183,7 @@ TEST_F(findNeighborsIntegrationTest, grid1) const real dx = 0.15; gridBuilder->addCoarseGrid(0.0, 0.0, 0.0, 1.0, 1.0, 1.0, dx); - gridBuilder->buildGrids(LBM, false); + gridBuilder->buildGrids(false); auto grid = gridBuilder->getGrid(0); // Only the last layer of nodes should have invalid neighbors. The grid is a cube with a side length of 9 nodes @@ -211,7 +206,7 @@ TEST_F(findNeighborsIntegrationTest, grid2) const real dx = 1.0 / 64; gridBuilder->addCoarseGrid(-0.6, -0.6, -0.6, 0.6, 0.6, 0.6, dx); - gridBuilder->buildGrids(LBM, false); + gridBuilder->buildGrids(false); auto grid = gridBuilder->getGrid(0); // Only the last layer of nodes should have invalid neighbors. The grid is a cube with a side length of 79 nodes @@ -234,7 +229,7 @@ TEST_F(findNeighborsIntegrationTest, validFluidNeighbors1) real dx = 0.17; gridBuilder->addCoarseGrid(0.0, 0.0, 0.0, 1.0, 1.0, 1.0, dx); - gridBuilder->buildGrids(LBM, false); + gridBuilder->buildGrids(false); auto grid = gridBuilder->getGrid(0); auto numberInvalidFluidNeighbors = testFluidNodeNeighbors(grid); @@ -248,7 +243,7 @@ TEST_F(findNeighborsIntegrationTest, validFluidNeighbors2) real dx = 0.18; gridBuilder->addCoarseGrid(0.0, 0.0, 0.0, 1.0, 1.0, 1.0, dx); - gridBuilder->buildGrids(LBM, false); + gridBuilder->buildGrids(false); auto grid = gridBuilder->getGrid(0); auto numberInvalidFluidNeighbors = testFluidNodeNeighbors(grid); diff --git a/src/gpu/GridGenerator/grid/GridInterface.cpp b/src/gpu/GridGenerator/grid/GridInterface.cpp index a373b0eafbdb6a33338f54bf3efdc47a0edca315..4b69cebd16d4c529e4889b84ff881d4ed660f124 100644 --- a/src/gpu/GridGenerator/grid/GridInterface.cpp +++ b/src/gpu/GridGenerator/grid/GridInterface.cpp @@ -125,28 +125,6 @@ void GridInterface::findBoundaryGridInterfaceCF(const uint& indexOnCoarseGrid, G } } -void GridInterface::findInterfaceCF_GKS(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid) -{ - const bool nodeOnCoarseGridIsFluid = coarseGrid->getField().isFluid(indexOnCoarseGrid); - if (!nodeOnCoarseGridIsFluid) - return; - - real x, y, z; - coarseGrid->transIndexToCoords(indexOnCoarseGrid, x, y, z); - - for (const auto dir : coarseGrid->distribution) - { - const uint indexOnFineGrid = fineGrid->transCoordToIndex(x + 0.25 * dir[0] * coarseGrid->getDelta(), - y + 0.25 * dir[1] * coarseGrid->getDelta(), - z + 0.25 * dir[2] * coarseGrid->getDelta()); - - if (indexOnFineGrid != INVALID_INDEX && fineGrid->getField().is(indexOnFineGrid, STOPPER_OUT_OF_GRID)) - { - coarseGrid->getField().setFieldEntry(indexOnCoarseGrid, FLUID_CFC); - break; - } - } -} void GridInterface::findInterfaceFC(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid) { diff --git a/src/gpu/GridGenerator/grid/GridInterface.h b/src/gpu/GridGenerator/grid/GridInterface.h index 713d495d4386e0fe743357a803b84be02c061561..ae90f513de436324e982a8ac34db7bb1a07f908d 100644 --- a/src/gpu/GridGenerator/grid/GridInterface.h +++ b/src/gpu/GridGenerator/grid/GridInterface.h @@ -46,9 +46,6 @@ public: void GRIDGENERATOR_EXPORT findInterfaceCF(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); void GRIDGENERATOR_EXPORT findBoundaryGridInterfaceCF(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); - - void GRIDGENERATOR_EXPORT findInterfaceCF_GKS(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); - void GRIDGENERATOR_EXPORT findInterfaceFC(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); void GRIDGENERATOR_EXPORT findOverlapStopper(const uint& indexOnCoarseGrid, GridImp* coarseGrid, GridImp* fineGrid); diff --git a/src/gpu/GridGenerator/grid/distributions/Distribution.cpp b/src/gpu/GridGenerator/grid/distributions/Distribution.cpp index a6e11ac909186618d765596f15263035b3b6401a..31d2e2f8a927e7141d80a55f4164dfcb0f52a8e0 100644 --- a/src/gpu/GridGenerator/grid/distributions/Distribution.cpp +++ b/src/gpu/GridGenerator/grid/distributions/Distribution.cpp @@ -46,9 +46,9 @@ Distribution DistributionHelper::getDistribution27() d27.dir_start = STARTDIR; d27.dir_end = ENDDIR; - d27.dirs = new int[(ENDDIR + 1) * DIMENSION]; + d27.dirs.resize((ENDDIR + 1) * DIMENSION); - d27.directions = new Direction[ENDDIR + 1]; + d27.directions.resize(ENDDIR + 1); d27.directions[DIR_P00] = Direction(DIR_27_E_X, DIR_27_E_Y, DIR_27_E_Z); d27.directions[DIR_M00] = Direction(DIR_27_W_X, DIR_27_W_Y, DIR_27_W_Z); d27.directions[DIR_0P0] = Direction(DIR_27_N_X, DIR_27_N_Y, DIR_27_N_Z); diff --git a/src/gpu/GridGenerator/grid/distributions/Distribution.h b/src/gpu/GridGenerator/grid/distributions/Distribution.h index 7982abc235b020003526b10c885f4936bf661936..39cea3747e71a5c26bfd9172267366284dbc94ff 100644 --- a/src/gpu/GridGenerator/grid/distributions/Distribution.h +++ b/src/gpu/GridGenerator/grid/distributions/Distribution.h @@ -73,8 +73,8 @@ struct Distribution typedef const Direction* const_iterator; real* f; - int *dirs; - Direction* directions; + std::vector<int> dirs; + std::vector<Direction> directions; int dir_start; int dir_end; const char* name; diff --git a/src/gpu/GridGenerator/io/GridVTKWriter/GridVTKWriter.cpp b/src/gpu/GridGenerator/io/GridVTKWriter/GridVTKWriter.cpp index 7f818f3217e682f21c2b41c62070924243fcb3b0..e5ddf7932e8505c713387f96157a80626d37aa1e 100644 --- a/src/gpu/GridGenerator/io/GridVTKWriter/GridVTKWriter.cpp +++ b/src/gpu/GridGenerator/io/GridVTKWriter/GridVTKWriter.cpp @@ -38,8 +38,8 @@ #include <sstream> #include <memory> -#include "basics/basics/writer/WbWriterVtkXmlBinary.h" -#include "basics/basics/container/CbArray3D.h" +#include "basics/writer/WbWriterVtkXmlBinary.h" +#include "basics/container/CbArray3D.h" #include "geometries/Vertex/Vertex.h" @@ -85,7 +85,7 @@ void GridVTKWriter::writeGridToVTKXML(SPtr<Grid> grid, const std::string& name) std::vector<std::string> nodedatanames; std::vector< std::vector<double> > nodedata; - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Write Grid to XML VTK (*.vtu) output file : " + name + "_Part_" + std::to_string(part) + "\n"; + VF_LOG_INFO("Write Grid to XML VTK (*.vtu) output file : {}_Part_{}", name, part); nodedatanames.emplace_back("types"); nodedatanames.emplace_back("sparse_id"); @@ -154,7 +154,7 @@ void GridVTKWriter::writeGridToVTKXML(SPtr<Grid> grid, const std::string& name) } } WbWriterVtkXmlBinary::getInstance()->writeOctsWithNodeData(name + "_Part_" + std::to_string(part), nodes, cells, nodedatanames, nodedata); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "done. \n"; + VF_LOG_INFO("done."); } } @@ -282,14 +282,14 @@ void GridVTKWriter::initalVtkWriter(WRITING_FORMAT format, const std::string& na { GridVTKWriter::format = format; - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Write Grid to vtk output file : " + name + "\n"; + VF_LOG_INFO("Write Grid to vtk output file: {}", name); std::string mode = "w"; if (isBinaryWritingFormat()) mode = "wb"; GridVTKWriter::openFile(name, mode); - *logging::out << logging::Logger::INFO_INTERMEDIATE << " Output file opened ...\n"; + VF_LOG_INFO("Output file opened ..."); } bool GridVTKWriter::isBinaryWritingFormat() @@ -306,14 +306,14 @@ void GridVTKWriter::writeVtkFile(SPtr<Grid> grid) GridVTKWriter::writeTypes(grid); GridVTKWriter::closeFile(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Output file closed\n"; + VF_LOG_INFO("Output file closed"); } void GridVTKWriter::openFile(const std::string& name, const std::string& mode) { file = fopen(name.c_str(), mode.c_str()); if(file==NULL) - *logging::out << logging::Logger::INFO_HIGH << " cannot open file ...\n"; + VF_LOG_CRITICAL("cannot open file {}", name); } void GridVTKWriter::closeFile() diff --git a/src/gpu/GridGenerator/io/QLineWriter.cpp b/src/gpu/GridGenerator/io/QLineWriter.cpp index 29894e8d589fb59c1dbf57e08692dddfc03619a1..1aece49ceeabc5ca195146f2ac6dcb7ba960f3ea 100644 --- a/src/gpu/GridGenerator/io/QLineWriter.cpp +++ b/src/gpu/GridGenerator/io/QLineWriter.cpp @@ -36,7 +36,7 @@ #include <string> #include <fstream> -#include "basics/basics/utilities/UbTuple.h" +#include "basics/utilities/UbTuple.h" #include "geometries/Vertex/Vertex.h" @@ -50,7 +50,7 @@ void QLineWriter::writeArrows(std::string fileName, SPtr<GeometryBoundaryConditi { if (geometryBoundaryCondition == nullptr) { - *logging::out << logging::Logger::WARNING << "(QLineWriter::writeArrows) no geometry bc on this grid level.\n"; + VF_LOG_WARNING("(QLineWriter::writeArrows) no geometry bc on this grid level."); return; } std::vector<UbTupleFloat3> nodes; diff --git a/src/gpu/GridGenerator/io/STLReaderWriter/STLReader.cpp b/src/gpu/GridGenerator/io/STLReaderWriter/STLReader.cpp index d3eb221265b2f8c79d5aece8729585733c2d60e8..d73adc73eeffce56397829c115def5bfd1d8bc59 100644 --- a/src/gpu/GridGenerator/io/STLReaderWriter/STLReader.cpp +++ b/src/gpu/GridGenerator/io/STLReaderWriter/STLReader.cpp @@ -55,17 +55,17 @@ std::vector<Triangle> STLReader::readSTL(const std::string& name) line[strcspn(line.c_str(), "\r\n")] = 0; if (strcmp(line.c_str(), "solid ascii") == 0) { file.close(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "start reading ascii STL file: " + name + "\n"; + VF_LOG_INFO("start reading ascii STL file: {}" , name); return readASCIISTL(name); } else { file.close(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "start reading binary STL file: " + name + "\n"; + VF_LOG_INFO("start reading binary STL file: {}" , name); + return readBinarySTL(name); } } - - *logging::out << logging::Logger::INFO_INTERMEDIATE << "can't open STL-file" + name + " ... exit program! \n"; + VF_LOG_CRITICAL("can't open STL-file {} ... exit program!" , name); exit(1); } @@ -81,7 +81,7 @@ std::vector<Triangle> STLReader::readASCIISTL(const std::string& name) const int lines = countLinesInFile(name); const int nTriangles = (lines) / 7; // seven lines per triangle - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Number of Triangles: " << nTriangles << "\n"; + VF_LOG_INFO("Number of Triangles: {}" , nTriangles); std::vector<Triangle> triangles; std::string line; @@ -109,8 +109,7 @@ std::vector<Triangle> STLReader::readASCIISTL(const std::string& name) std::vector<Triangle> STLReader::readASCIISTLWithPatches(const std::string& name, const std::vector<uint> ignorePatches) { - *logging::out << logging::Logger::INFO_HIGH << "Start reading ascii STL file:\n"; - *logging::out << logging::Logger::INFO_HIGH << " " + name + "\n"; + VF_LOG_INFO("Start reading ascii STL file: {}" , name); std::vector<Triangle> triangles; @@ -141,9 +140,10 @@ std::vector<Triangle> STLReader::readASCIISTLWithPatches(const std::string& name ignoreCurrentPatch = std::find( ignorePatches.begin(), ignorePatches.end(), currentPatchIndex ) != ignorePatches.end(); if( !ignoreCurrentPatch ) - *logging::out << logging::Logger::INFO_INTERMEDIATE << " Reading STL-Group " << line.substr( line.find(' ') + 1 ) << " as patch " << currentPatchIndex << "\n"; + VF_LOG_INFO(" Reading STL-Group {} as patch {}" , line.substr( line.find(' ') + 1 ) , currentPatchIndex); else - *logging::out << logging::Logger::WARNING << " Ignoring STL-Group " << line.substr( line.find(' ') + 1 ) << " as patch " << currentPatchIndex << "\n"; + VF_LOG_WARNING(" Ignoring STL-Group {} as patch {}" , line.substr( line.find(' ') + 1 ) , currentPatchIndex); + currentFacetLine++; } @@ -202,7 +202,7 @@ std::vector<Triangle> STLReader::readASCIISTLWithPatches(const std::string& name file.close(); - *logging::out << logging::Logger::INFO_HIGH << "Done reading ascii STL file\n"; + VF_LOG_INFO("Done reading ascii STL file"); return triangles; } @@ -218,7 +218,7 @@ std::vector<Triangle> STLReader::readBinarySTL(const std::string& name) char nTri[4]; sizef = fread(nTri, sizeof(char), 4, file); unsigned long nTriLong = *((unsigned long*)nTri); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Number of Triangles: " << nTriLong << "\n"; + VF_LOG_INFO("Number of Triangles: {}" , nTriLong); std::vector<Triangle> triangles; char facet[50]; @@ -248,18 +248,18 @@ std::vector<Triangle> STLReader::readSTL(const BoundingBox &box, const std::stri line[strcspn(line.c_str(), "\r\n")] = 0; if (strcmp(line.c_str(), "solid ascii") == 0) { file.close(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "start reading ascii STL file: " + name + "\n"; + VF_LOG_INFO("start reading ascii STL file {}", name); return readASCIISTL(box, name); } else { file.close(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "start reading binary STL file: " + name + "\n"; + VF_LOG_INFO("start reading binary STL file {}", name); std::vector<Triangle> triangles = readBinarySTL(box, name); return triangles; } } else { - *logging::out << logging::Logger::INFO_INTERMEDIATE << "can't open STL-file" + name + "\n"; + VF_LOG_CRITICAL("can't open STL-file {}", name); exit(1); } } @@ -311,7 +311,7 @@ std::vector<Triangle> STLReader::readBinarySTL(const BoundingBox &box, const std sizef = fread(nTri, sizeof(char), 4, file); nTriLong = *((unsigned long*)nTri); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Number of Triangles complete geometry: " << nTriLong << "\n"; + VF_LOG_INFO("Number of Triangles complete geometry: {}", nTriLong); std::vector<Triangle> triangles; char facet[50]; @@ -329,8 +329,8 @@ std::vector<Triangle> STLReader::readBinarySTL(const BoundingBox &box, const std triangles.push_back(t); } int size = (int)triangles.size(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Number of Triangles in process: " << size << "\n"; - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Complete reading STL file. \n"; + VF_LOG_INFO("Number of Triangles in process: {}", size); + VF_LOG_INFO("Complete reading STL file"); (void)sizef; fclose(file); diff --git a/src/gpu/GridGenerator/io/STLReaderWriter/STLWriter.cpp b/src/gpu/GridGenerator/io/STLReaderWriter/STLWriter.cpp index e29320cbd6867e1ae5a65cf41623780cd83aead7..c1f306839e7ed7a9815c041c4e000df044d43630 100644 --- a/src/gpu/GridGenerator/io/STLReaderWriter/STLWriter.cpp +++ b/src/gpu/GridGenerator/io/STLReaderWriter/STLWriter.cpp @@ -42,7 +42,7 @@ void STLWriter::writeSTL(std::vector<Triangle> &vec, const std::string &name, bool writeBinary) { const int size = (int)vec.size(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Write " << size << " Triangles to STL : " + name + "\n"; + VF_LOG_INFO("Write {} Triangles to STL : {}" , size, name); std::ios_base::openmode mode = std::ios::out; if (writeBinary) @@ -51,7 +51,7 @@ void STLWriter::writeSTL(std::vector<Triangle> &vec, const std::string &name, bo std::ofstream ofstream(name, mode); if (!ofstream.is_open()) { - *logging::out << logging::Logger::INFO_HIGH << " Output file not open - exit function\n"; + VF_LOG_WARNING("Output file not open - exit function"); return; } @@ -61,7 +61,7 @@ void STLWriter::writeSTL(std::vector<Triangle> &vec, const std::string &name, bo writeAsciiSTL(ofstream, vec); ofstream.close(); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Output file closed\n"; + VF_LOG_INFO("Output file closed"); } diff --git a/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.cpp b/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.cpp index 0238434dc87b453dc21164577d8abd4ce1819793..eb7e6b22e160de4fedb5832be807dabf36531c9c 100644 --- a/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.cpp +++ b/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.cpp @@ -38,7 +38,7 @@ #include <omp.h> #include <cmath> -#include "Core/Timer/Timer.h" +#include "Timer/Timer.h" #include "grid/NodeValues.h" #include "grid/Grid.h" @@ -59,13 +59,13 @@ void SimulationFileWriter::write(const std::string& folder, SPtr<GridBuilder> bu { SimulationFileWriter::folder = folder; - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Start writing simulation files to " << folder << ":\n"; + VF_LOG_INFO("Start writing simulation files to {}", folder); auto timer = Timer::makeStart(); write(builder, format); - *logging::out << logging::Logger::INFO_INTERMEDIATE << " Time writing files: " << timer->getCurrentRuntimeInSeconds() << " sec\n"; - *logging::out << logging::Logger::INFO_INTERMEDIATE << "Done writing simulation Files!\n"; + VF_LOG_INFO(" Time writing files: {} sec", timer->getCurrentRuntimeInSeconds()); + VF_LOG_INFO("Done writing simulation Files!"); } @@ -79,7 +79,7 @@ void SimulationFileWriter::write(SPtr<GridBuilder> builder, FILEFORMAT format) writeLevel(numberOfLevel); //auto qs = createBCVectors(builder->getGrid(0)); - *logging::out << logging::Logger::INFO_INTERMEDIATE << " Coordinate and neighbor files:\n"; + VF_LOG_INFO(" Coordinate and neighbor files:"); for (uint level = 0; level < numberOfLevel; level++) { writeNumberNodes(builder, level); @@ -95,10 +95,10 @@ void SimulationFileWriter::write(SPtr<GridBuilder> builder, FILEFORMAT format) } } - *logging::out << logging::Logger::INFO_INTERMEDIATE << " Boundary Condition files:\n"; + VF_LOG_INFO(" Boundary Condition files:"); writeBoundaryQsFile(builder); - *logging::out << logging::Logger::INFO_INTERMEDIATE << " Communication files:\n"; + VF_LOG_INFO(" Communication files:"); writeCommunicationFiles(builder); closeFiles(); diff --git a/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h b/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h index f3851abfd3372e5d3548cf7c0cd02344aa8acbaa..a4ba3d4b53f2feb63d0363bf47e92152bea05c57 100644 --- a/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h +++ b/src/gpu/GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h @@ -40,8 +40,6 @@ #include <vector> #include <array> -#include "Core/NonCreatable.h" - #include "gpu/GridGenerator/global.h" class UnstructuredGridBuilder; @@ -57,7 +55,7 @@ enum class FILEFORMAT BINARY, ASCII }; -class SimulationFileWriter : private NonCreatable +class SimulationFileWriter { public: GRIDGENERATOR_EXPORT static void write(const std::string& folder, SPtr<GridBuilder> builder, FILEFORMAT format); diff --git a/src/gpu/Traffic/CMakeLists.txt b/src/gpu/Traffic/CMakeLists.txt deleted file mode 100644 index 249594e0434bc01aecd8f95f524a25a0745013d4..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -project(Traffic LANGUAGES CUDA CXX) - -vf_add_library(BUILDTYPE shared PRIVATE_LINK GridGenerator basics) diff --git a/src/gpu/Traffic/GPU/TrafficTimestep.cu b/src/gpu/Traffic/GPU/TrafficTimestep.cu deleted file mode 100644 index 34ea17549bdec9b99631f999e4108018e8829318..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/GPU/TrafficTimestep.cu +++ /dev/null @@ -1,936 +0,0 @@ -#include "TrafficTimestep.h" - -#include <cuda.h> -#include <cuda_runtime.h> -#include <helper_cuda.h> - -#include <cmath> - -#include "RoadNetwork/RoadNetworkData.h" -#include "Junction/Junction.h" -#include "Sink/Sink.h" -#include "Source/Source.h" -#include "Utilities/safe_casting.h" -#include "Utilities/invalidInput_error.h" - -//kernel -__global__ void trafficTimestepKernel(int* roadCurrent, int* roadNext, int* neighbors, real * pConcArray, uint* juncInCellIndices, bool* juncCarCanEnter, - int* juncCarsOnJunction, uint* juncAlreadyMoved, uint* juncOldSpeeds, real* sinkCarBlockedPossibilities, - uint size_road, uint size_juncInCells, uint maxVelocity, uint maxAcceleration, uint safetyDistance, bool useSlowToStart, real slowStartPossibility, real dawdlePossibility, curandState *state); - -__global__ void sourceTimestepKernel(int* roadCurrent, int* roadNext, int* neighbors, uint* sourceIndices, real* sinkCarBlockedPossibilities, - float* sourcePossibilities, real * pConcArray, uint maxVelocity, uint safetyDistance, uint size_sources, curandState *state); - -__global__ void junctionTimestepKernel(int* juncCarsOnJunction, uint* juncInCellIndices, int* juncOutCellIndices, uint* juncStartInIncells, uint* juncStartInOutcells, - uint* juncAlreadyMoved, int* juncCarCanNotEnterThisOutCell, bool* juncOutCellIsOpen, uint* juncOldSpeeds, bool* juncCarCanEnter, uint* juncTrafficLightSwitchTime, - int* roadCurrent, int* roadNext, int* neighbors, real * pConcArray, real* sinkCarBlockedPossibilities, uint safetyDistance, - uint size_juncInCells, uint size_juncOutCells, uint size_junctions, uint numTimestep, curandState *state); - -__global__ void calculationOfNaschVelocityForFluidBCKernel(int* roadNext, int* neighbors, int* naschVelocity, uint size_road, uint safetyDistance); - -__global__ void randomSetupKernel(curandState *state, uint size); - -__global__ void resetNext(int* roadNext, uint size_road); - -//device functions for movement -__device__ inline uint getJunctionInCellsVectorIndex(uint * juncInCellIndices, uint size_juncInCells, uint cell); - -__device__ uint getGapAfterOutCell(int* roadCurrent, int* neighbors, real* sinkCarBlockedPossibilities, int sourceIndex, uint speed, uint safetyDistance, curandState* state); - -__device__ inline void carStaysOnJunction(int* juncCarsOnJunction, uint* juncInCellIndices, uint* juncAlreadyMoved, uint*juncOldSpeeds, real* pConcArray, uint inCellVectorIndex); - - - -//device functions for concentrations -__device__ inline real calcConcentration(uint oldSpeed, uint newSpeed); - -__device__ inline void putConcIntoArray(real * pConcArray, uint oldSpeed, uint newSpeed, uint newIndex); - -__device__ inline void addConcToArray(real * pConcArray, uint oldSpeed, uint newSpeed, uint newIndex); - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - -TrafficTimestep::TrafficTimestep(std::shared_ptr<RoadNetworkData> road, real * pConcArray, int* naschVelocity) -{ - //calculate sizes - this->size_roads = road->roadLength; - this->size_junctions = castSizeT_Uint(road->junctions.size()); - this->size_sources = castSizeT_Uint(road->sources.size()); - this->size_sinks = castSizeT_Uint(road->sinks.size()); - - //set attributes - this->maxVelocity = road->maxVelocity; - this->safetyDistance = road->safetyDistance; - this->dawdlePossibility = road->dawdlePossibility; - this->useSlowToStart = road->useSlowToStart; - this->slowStartPossibility = road->slowStartPossibility; - this->maxAcceleration = road->maxAcceleration; - - //prepare road - this->neighbors = road->neighbors; - this->roadCurrent = *road->pcurrent; - - this->roadNext.resize(size_roads); - thrust::fill(roadNext.begin(), roadNext.end(), -1); - - //prepare junctions - combineJuncInCellIndices(road->junctions); - combineJuncOutCellIndices(road->junctions); - combineJuncCarCanNotEnterThisOutCell(road->junctions); - combineUseTrafficLights(road->junctions); - - initJuncCarCanEnter(); - initJuncCarsOnJunction(); - initJuncAlreadyMoved(); - initjuncOutCellIsOpen(); - initJuncOldSpeeds(); - - //prepare sinks - combineSinkBlockedPossibilities(road->sinks); - - //prepare sources - combineSourcePossibilities(road->sources); - combineSourceIndices(road->sources); - - //preapre grid dimensions - calculateTrafficTimestepKernelDimensions(); - calculateJunctionKernelDimensions(); - calculateSourceKernelDimensions(); - - ////setUp random numbers - checkCudaErrors(cudaMalloc((void **)&statesRoad, gridRoad.x * gridRoad.y * threadsRoads.x * sizeof(curandState))); - randomSetupKernel << <gridRoad, threadsRoads >> > (statesRoad, size_roads); - cudaDeviceSynchronize(); - getLastCudaError("random_setup_kernel for roads execution failed"); - - checkCudaErrors(cudaMalloc((void **)&statesJunctions, gridJunctions.x * gridJunctions.y * threadsJunctions.x * sizeof(curandState))); - randomSetupKernel << <gridJunctions, threadsJunctions >> > (statesJunctions, size_junctions); - cudaDeviceSynchronize(); - getLastCudaError("random_setup_kernel for junctions execution failed"); - - checkCudaErrors(cudaMalloc((void **)&statesSources, gridSources.x * gridSources.y * threadsSources.x * sizeof(curandState))); - randomSetupKernel << <gridSources, threadsSources >> > (statesSources, size_sources); - cudaDeviceSynchronize(); - getLastCudaError("random_setup_kernel for sources execution failed"); - - //prepare ConcWriter - if (pConcArray == nullptr) { - checkCudaErrors(cudaMalloc((void **)&this->pConcArray, size_roads * sizeof(real))); - checkCudaErrors(cudaMemset(this->pConcArray, 0.0, size_t(size_roads) * sizeof(real))); - printf("No Pointer for pConcArray!!!"); - } - else this->pConcArray = pConcArray; - - //prepare naschVelocity for fluid BC - if (naschVelocity == nullptr) { - checkCudaErrors(cudaMalloc((void **)&this->naschVelocity, size_roads * sizeof(int))); - checkCudaErrors(cudaMemset(this->naschVelocity, 0, size_t(size_roads) * sizeof(int))); - //printf("\nsize_roads = %d\n",size_roads); - printf("No Pointer for naschVelocity!!!"); - } - else this->naschVelocity = naschVelocity; -} - - -void TrafficTimestep::calculateTimestep(std::shared_ptr<RoadNetworkData> road) -{ - switchCurrentNext(); - - //reset Junction open outcells - resetOutCellIsOpen(); - - //resetNext - resetNext(); - - callTrafficTimestepKernel(); - getLastCudaError("trafficTimestepKernel execution failed"); - - callJunctionTimestepKernel(); - getLastCudaError("junctionTimestepKernel execution failed"); - - callSourceTimestepKernel(); - getLastCudaError("sourceTimestepKernel execution failed"); - - callCalculationOfNaschVelocityForFluidBCKernel(); - getLastCudaError("callCalculationOfNaschVelocityForFluidBCKernel execution failed"); - - numTimestep++; -} - - -void TrafficTimestep::switchCurrentNext() -{ - if (timestepIsEven) { - timestepIsEven = false; - pRoadCurrent = roadCurrent.data().get(); - pRoadNext = roadNext.data().get(); - } - else { - timestepIsEven = true; - pRoadCurrent = roadNext.data().get(); - pRoadNext = roadCurrent.data().get(); - } -} - - -void TrafficTimestep::copyCurrentDeviceToHost(std::shared_ptr<RoadNetworkData> road) -{ - if (timestepIsEven) thrust::copy(roadCurrent.begin(), roadCurrent.end(), road->pcurrent->begin()); - else thrust::copy(roadNext.begin(), roadNext.end(), road->pcurrent->begin()); - - //checkCudaErrors(cudaMemcpy(&(road->conc[0]), pConcArray, size_roads * sizeof(real), cudaMemcpyDeviceToHost)); //dispConcFromGPU -} - - -void TrafficTimestep::cleanUp() -{ - cudaFree(statesRoad); - cudaFree(statesJunctions); - cudaFree(statesSources); -} - - -void TrafficTimestep::callTrafficTimestepKernel() -{ - trafficTimestepKernel << < gridRoad, threadsRoads >> > ( - pRoadCurrent, - pRoadNext, - neighbors.data().get(), - pConcArray, - juncInCellIndices.data().get(), - juncCarCanEnter.data().get(), - juncCarsOnJunction.data().get(), - juncAlreadyMoved.data().get(), - juncOldSpeeds.data().get(), - sinkCarBlockedPossibilities.data().get(), - size_roads, - size_juncInCells, - maxVelocity, - maxAcceleration, - safetyDistance, - useSlowToStart, - slowStartPossibility, - dawdlePossibility, - statesRoad); -} - - -void TrafficTimestep::callSourceTimestepKernel() -{ - sourceTimestepKernel << < gridSources, threadsSources >> > ( - pRoadCurrent, - pRoadNext, - neighbors.data().get(), - sourceIndices.data().get(), - sinkCarBlockedPossibilities.data().get(), - sourcePossibilities.data().get(), - pConcArray, - maxVelocity, - safetyDistance, - size_sources, - statesSources); -} - - -void TrafficTimestep::callJunctionTimestepKernel() -{ - junctionTimestepKernel << < gridJunctions, threadsJunctions >> > ( - juncCarsOnJunction.data().get(), - juncInCellIndices.data().get(), - juncOutCellIndices.data().get(), - juncStartInIncells.data().get(), - juncStartInOutcells.data().get(), - juncAlreadyMoved.data().get(), - juncCarCanNotEnterThisOutCell.data().get(), - juncOutCellIsOpen.data().get(), - juncOldSpeeds.data().get(), - juncCarCanEnter.data().get(), - juncTrafficLightSwitchTime.data().get(), - pRoadCurrent, - pRoadNext, - neighbors.data().get(), - pConcArray, - sinkCarBlockedPossibilities.data().get(), - safetyDistance, - size_juncInCells, - size_juncOutCells, - size_junctions, - numTimestep, - statesJunctions); -} - - -void TrafficTimestep::callCalculationOfNaschVelocityForFluidBCKernel() -{ - calculationOfNaschVelocityForFluidBCKernel << < gridRoad, threadsRoads >> > ( - pRoadNext, - neighbors.data().get(), - naschVelocity, - size_roads, - safetyDistance); -} - - - -__global__ void calculationOfNaschVelocityForFluidBCKernel(int* roadNext, int* neighbors, int* naschVelocity, uint size_road, uint safetyDistance) -{ - const uint x = threadIdx.x; // Globaler x-Index - const uint y = blockIdx.x; // Globaler y-Index - const uint z = blockIdx.y; // Globaler z-Index - - const uint nx = blockDim.x; - const uint ny = gridDim.x; - const uint index = nx*(ny*z + y) + x; - - if (index >= size_road) return; - ////////////////////////////////////////////////////////////////////////// - //reset - naschVelocity[index] = -1; - ////////////////////////////////////////////////////////////////////////// - if (roadNext[index] < 0) return; - - int speed = roadNext[index]; - - naschVelocity[index] = speed; - - int neighbor = neighbors[index]; - - for (uint j = 1; j <= safetyDistance; j++) { - if (neighbor <= -1000) - return; - else - naschVelocity[neighbor] = speed; - neighbor = neighbors[neighbor]; - } -} - -__global__ void resetNext(int * roadNext, uint size_road) -{ - const uint x = threadIdx.x; // Globaler x-Index - const uint y = blockIdx.x; // Globaler y-Index - const uint z = blockIdx.y; // Globaler z-Index - - const uint nx = blockDim.x; - const uint ny = gridDim.x; - const uint index = nx*(ny*z + y) + x; - - if (index >= size_road) return; - - roadNext[index] = -1; -} - - - -__global__ void trafficTimestepKernel(int* roadCurrent, int* roadNext, int* neighbors, real * pConcArray, uint* juncInCellIndices, bool* juncCarCanEnter, - int* juncCarsOnJunction, uint* juncAlreadyMoved, uint* juncOldSpeeds, real* sinkCarBlockedPossibilities, - uint size_road, uint size_juncInCells, uint maxVelocity, uint maxAcceleration, uint safetyDistance, bool useSlowToStart, real slowStartPossibility, real dawdlePossibility, curandState *state) -{ - ////////////////////////////////////////////////////////////////////////// - const uint x = threadIdx.x; // Globaler x-Index - const uint y = blockIdx.x; // Globaler y-Index - const uint z = blockIdx.y; // Globaler z-Index - - const uint nx = blockDim.x; - const uint ny = gridDim.x; - const uint index = nx*(ny*z + y) + x; - - if (index >= size_road) return; - //////////////////////////////////////////////////////////////////////////////// - if (roadCurrent[index] < 0) return; - - //reset concentrations - pConcArray[index] = 0.0; - - //printf("index %d ", index); - - uint speed = roadCurrent[index]; - - - //// accelerate car //////////////////////////////////////////////////////////////////// - if (speed < maxVelocity) { - if (speed <= maxVelocity - maxAcceleration) - speed += maxAcceleration; - else - speed = maxVelocity; - } - - - //////// brake car ///////////////////////////////////////////////////////////////////////// - //getGapAfterCar - uint gap = speed; - uint idx = 0; - int neighbor = neighbors[index]; - uint currentCell = index; - - for (uint i = 0; i < (speed + safetyDistance); i++) { - - //sink - if (neighbor <= -2000) { - curandState localState = state[index]; - float random = curand_uniform(&localState); - - if (i <= speed && !(random < sinkCarBlockedPossibilities[(neighbor + 2000)*-1])) gap = speed; - else gap = i; - - state[index] = localState; - break; - } - - //junction - if (neighbor <= -1000 && neighbor > -2000) { - idx = getJunctionInCellsVectorIndex(juncInCellIndices, size_juncInCells, currentCell); - if (juncCarCanEnter[idx] && i <= speed) gap = speed; - else gap = i; - break; - } - - //car in Cell - if (roadCurrent[neighbor] > -1) { - if (i <= safetyDistance) gap = 0; - else gap = i - safetyDistance; - break; - } - - //empty cell -> get next neighbor, update currentCell - currentCell = neighbor; - neighbor = neighbors[neighbor]; - } - - //brake - if (speed > gap) - speed = gap; - - - ////// dawdleCar /////////////////////////////////////////////////////////////////////////// - curandState localState = state[index]; - float random = curand_uniform(&localState); - state[index] = localState; - - //Barlovic / SlowToStart - if (useSlowToStart == true && roadCurrent[index] == 0) { - if (random < slowStartPossibility) speed = 0; - } - else if (random < dawdlePossibility) //Standard NaSch - if (speed >= maxAcceleration) - speed -= maxAcceleration; - else - speed = 0; - - - ////// moveCar ///////////////////////////////////////////////////////////////////////////// - if (speed == 0) { - (roadNext)[index] = 0; - putConcIntoArray(pConcArray, roadCurrent[index], speed, index); - return; - } - - neighbor = neighbors[index]; - currentCell = index; - - // iterateNeighborsInMove - uint numberOfCellsMoved = 0; - for (uint i = 2; i <= speed; i++) { - if (neighbor >= 0) { - currentCell = neighbor; - neighbor = neighbors[neighbor]; - ++numberOfCellsMoved; - } - else - break; - } - - if (neighbor <= -2000) return; - - if (neighbor <= -1000 && neighbor > -2000) { - //registerCar - - juncCarsOnJunction[idx] = speed; - //getCarsOnJunction[index] = speed -2; //all cars, which enter the junction have to slow down - juncOldSpeeds[idx] = roadCurrent[index]; - juncCarCanEnter[idx] = false; - juncAlreadyMoved[idx] = numberOfCellsMoved; - return; - } - - if (neighbor >= 0) { - roadNext[neighbor] = speed; - putConcIntoArray(pConcArray, roadCurrent[index], speed, neighbor); - } -} - - - -__global__ void sourceTimestepKernel(int* roadCurrent, int* roadNext, int* neighbors, uint* sourceIndices, real* sinkCarBlockedPossibilities, float* sourcePossibilities, real* pConcArray, - uint maxVelocity, uint safetyDistance, uint size_sources, curandState *state) -{ - ////////////////////////////////////////////////////////////////////////// - const uint x = threadIdx.x; // Globaler x-Index - const uint y = blockIdx.x; // Globaler y-Index - const uint z = blockIdx.y; // Globaler z-Index - - const uint nx = blockDim.x; - const uint ny = gridDim.x; - - const uint index = nx*(ny*z + y) + x; - //////////////////////////////////////////////////////////////////////////////// - - if (index >= size_sources) return; - //////////////////////////////////////////////////////////////////////////////// - - int sourceIndex = sourceIndices[index]; - - uint gap = getGapAfterOutCell(roadCurrent, neighbors, sinkCarBlockedPossibilities, sourceIndex, maxVelocity, safetyDistance, state); - if (gap > 0) { - //get car with random speed - curandState localState = state[index]; - if (curand_uniform(&localState) < sourcePossibilities[index]) { - unsigned int speed = ceilf(curand_uniform(&localState) * (maxVelocity + 1)) - 1; - roadNext[sourceIndex] = speed; - putConcIntoArray(pConcArray, speed, speed, sourceIndex); - } - state[index] = localState; - } -} - - - -__global__ void junctionTimestepKernel(int* juncCarsOnJunction, uint* juncInCellIndices, int* juncOutCellIndices, uint* juncStartInIncells, uint* juncStartInOutcells, - uint* juncAlreadyMoved, int* juncCarCanNotEnterThisOutCell, bool* juncOutCellIsOpen, uint* juncOldSpeeds, bool* juncCarCanEnter, uint* juncTrafficLightSwitchTime, - int* roadCurrent, int* roadNext, int* neighbors, real* pConcArray, real* sinkCarBlockedPossibilities, uint safetyDistance, - uint size_juncInCells, uint size_juncOutCells, uint size_junctions, uint numTimestep, curandState* state) { - ////////////////////////////////////////////////////////////////////////// - const uint x = threadIdx.x; // Globaler x-Index - const uint y = blockIdx.x; // Globaler y-Index - const uint z = blockIdx.y; // Globaler z-Index - - const uint nx = blockDim.x; - const uint ny = gridDim.x; - - const uint index = nx*(ny*z + y) + x; - - //////////////////////////////////////////////////////////////////////////////// - - if (index >= size_junctions) return; - //printf("junctionKernelIndex %d ", index); - - //////////////////////////////////////////////////////////////////////////////// - - //calc indices - - uint inCellsSize = 0; - uint firstInCellIndex = juncStartInIncells[index]; - if (index < size_junctions - 1) inCellsSize = juncStartInIncells[index + 1] - firstInCellIndex; - else inCellsSize = size_juncInCells - firstInCellIndex; - - uint outCellSize = 0; - uint firstOutCellIndex = juncStartInOutcells[index]; - if (index < size_junctions - 1) outCellSize = juncStartInOutcells[index + 1] - firstOutCellIndex; - else outCellSize = size_juncOutCells - firstOutCellIndex; - - - //// loop through all cars ///////////////////////////////////////////////////////////////////////////// - - for (uint inCellVectorIndex = firstInCellIndex; inCellVectorIndex < firstInCellIndex + inCellsSize; inCellVectorIndex++) { - - if (juncCarsOnJunction[inCellVectorIndex] >= 0) { - - //// applyRules ///////////////////////////////////////////////////////////////////////////// - uint speed = juncCarsOnJunction[inCellVectorIndex]; - if (speed == 0 && juncAlreadyMoved[inCellVectorIndex] == 0) speed += 1; - int remainingDist = speed - static_cast<int>(juncAlreadyMoved[inCellVectorIndex]); - - //printf(" incell %d, speed %d, remainingDist %d, alreadyMoved %d ", inCellVectorIndex, speed, remainingDist, juncAlreadyMoved[inCellVectorIndex]); - - if (remainingDist == 0) { //car can't leave the junction - carStaysOnJunction(juncCarsOnJunction, juncInCellIndices, juncAlreadyMoved, juncOldSpeeds, pConcArray, inCellVectorIndex); - continue; - } - - else { - - //// calc numberOfPossibleOutCells //////////////////////////////////////////////////////////////// - uint numberOfPossibleOutCells = 0; - - for (uint outCellIndex = firstOutCellIndex; outCellIndex < firstOutCellIndex + outCellSize; outCellIndex++) - if (juncCarCanNotEnterThisOutCell[inCellVectorIndex] != juncOutCellIndices[outCellIndex] && juncOutCellIsOpen[outCellIndex] == true) - numberOfPossibleOutCells++; - - - if (numberOfPossibleOutCells == 0) //car can't leave the junction - { - carStaysOnJunction(juncCarsOnJunction, juncInCellIndices, juncAlreadyMoved, juncOldSpeeds, pConcArray, inCellVectorIndex); - continue; - } - - //// chooseOutCell /////////////////////////////////////////////////////////////////////////////// - int chosenCell = -1; - curandState localState = state[index]; - uint random = ceilf(curand_uniform(&localState) * numberOfPossibleOutCells); - for (uint outCellVectorIndex = firstOutCellIndex; outCellVectorIndex < firstOutCellIndex + outCellSize; outCellVectorIndex++) { - if (juncCarCanNotEnterThisOutCell[inCellVectorIndex] != juncOutCellIndices[outCellVectorIndex] && juncOutCellIsOpen[outCellVectorIndex] == true) { - if (random == 1) { - chosenCell = juncOutCellIndices[outCellVectorIndex]; - juncOutCellIsOpen[outCellVectorIndex] = false; - break; - } - random--; - } - } - state[index] = localState; - - //// brakeCar //////////////////////////////////////////////////////////////////////////////////// - if (chosenCell < 0); - uint gap = getGapAfterOutCell(roadCurrent, neighbors, sinkCarBlockedPossibilities, chosenCell, speed, safetyDistance, state); - if (gap < remainingDist) { - if (gap > speed) gap = speed; - speed = speed - remainingDist + gap; - remainingDist = gap; - } - - //// moveCar ///////////////////////////////////////////////////////////////////////////////////// - if (remainingDist <= 0) { //car can't leave the junction - carStaysOnJunction(juncCarsOnJunction, juncInCellIndices, juncAlreadyMoved, juncOldSpeeds, pConcArray, inCellVectorIndex); - continue; - } - - if (remainingDist > 0) { - - if (remainingDist == 1) { - roadNext[chosenCell] = speed; - putConcIntoArray(pConcArray, juncOldSpeeds[inCellVectorIndex], speed, chosenCell); - juncCarsOnJunction[inCellVectorIndex] = -1; - juncCarCanEnter[inCellVectorIndex] = true; - break; - } - - //iterate through neighbors - int neighbor = chosenCell; - for (uint i = 2; i <= remainingDist; i++) { - if (neighbor >= 0) { - chosenCell = neighbor; - neighbor = neighbors[neighbor]; - } - else - break; - } - - if (neighbor >= 0) { - roadNext[neighbor] = speed; - putConcIntoArray(pConcArray, juncOldSpeeds[inCellVectorIndex], speed, neighbor); - } - - juncCarsOnJunction[inCellVectorIndex] = -1; - juncCarCanEnter[inCellVectorIndex] = true; - } - } - } - } - - - //generate red TrafficLights - - if (juncTrafficLightSwitchTime[index] > 0) { - - uint halfNumStreets = (uint)(std::floor((float)inCellsSize * 0.5f)); - - if ((uint)(std::floor((float)numTimestep / (float)juncTrafficLightSwitchTime[index])) % 2 == 0) { - for (uint i = firstInCellIndex; i < firstInCellIndex + halfNumStreets; i++) - juncCarCanEnter[i] = false; - - if (numTimestep % juncTrafficLightSwitchTime[index] == 0) //first timestep with green light --> open the streets that were closed before - for (uint i = firstInCellIndex + halfNumStreets; i < firstInCellIndex + inCellsSize; i++) - if (juncCarsOnJunction[i] == -1) - juncCarCanEnter[i] = true; - } - else { - for (uint i = firstInCellIndex + halfNumStreets; i < firstInCellIndex + inCellsSize; i++) - juncCarCanEnter[i] = false; - - if (numTimestep % juncTrafficLightSwitchTime[index] == 0) //first timestep with green light --> open the streets that were closed before - for (uint i = firstInCellIndex; i < firstInCellIndex + halfNumStreets; i++) - if (juncCarsOnJunction[i] == -1) - juncCarCanEnter[i] = true; - } - } - -} - - -__device__ inline void carStaysOnJunction(int* juncCarsOnJunction, uint* juncInCellIndices, uint* juncAlreadyMoved, uint*juncOldSpeeds, real* pConcArray, uint inCellVectorIndex) { - addConcToArray(pConcArray, juncOldSpeeds[inCellVectorIndex], 0, juncInCellIndices[inCellVectorIndex]); - juncCarsOnJunction[inCellVectorIndex] = 0; - juncAlreadyMoved[inCellVectorIndex] = 0; - juncOldSpeeds[inCellVectorIndex] = 0; -} - - -__device__ inline uint getGapAfterOutCell(int* roadCurrent, int* neighbors, real* sinkCarBlockedPossibilities, int outCellIndex, uint speed, uint safetyDistance, curandState* state) -{ - if (roadCurrent[outCellIndex] > -1) - return 0; - - for (uint i = 0; i < (speed + safetyDistance); i++) { - //sink - if (outCellIndex <= -2000) { - const uint index = blockDim.x*(gridDim.x*blockIdx.y + blockIdx.x) + threadIdx.x; - curandState localState = state[index]; - float randomNumber = curand_uniform(&localState); - state[index] = localState; - if (i <= speed && !(randomNumber < sinkCarBlockedPossibilities[(outCellIndex + 2000)*-1])) - return speed; - return i; - } - //junction - if (outCellIndex <= -1000) - return i; - - //car in Cell - if (roadCurrent[outCellIndex] > -1) { - if (i <= safetyDistance) return 0; - return i - safetyDistance; - } - - //empty cell -> get next neighbor - outCellIndex = neighbors[outCellIndex]; - } - return speed; -} - - -inline __device__ uint getJunctionInCellsVectorIndex(uint* juncInCellIndices, uint size_juncInCells, uint cell) { - for (uint i = 0; i < size_juncInCells; i++) - if (juncInCellIndices[i] == cell) - return i; - //TODO real Error - printf("no matching incoming cell to a junction found in: getJunctionInCellsVectorIndex()"); - return 65000; -} - - -__global__ void randomSetupKernel(curandState *state, uint size) { - const uint x = threadIdx.x; // Globaler x-Index - const uint y = blockIdx.x; // Globaler y-Index - const uint z = blockIdx.y; // Globaler z-Index - - const uint nx = blockDim.x; - const uint ny = gridDim.x; - - const uint index = nx*(ny*z + y) + x; - - if (index >= size) return; - - curand_init((unsigned long long)clock() + index, index, 0, &state[index]); -} - - -__device__ real calcConcentration(uint oldSpeed, uint newSpeed) -{ - //printf("newIndex %d ", newIndex ); - if (oldSpeed == 0 && newSpeed > 0) //Start - return 0.833f; - else if (oldSpeed == 0 && newSpeed == 0) //Idle - return 0.069f; - else if (newSpeed == oldSpeed) //Drive - return 0.221f; - else if (newSpeed > oldSpeed) //Accelerate - return 0.625f; - else if (newSpeed < oldSpeed) //Brake - return 0.379f; - else - printf("couldn't choose driving state in calcConcentration"); - return -1; -} - - -__device__ void putConcIntoArray(real * pConcArray, uint oldSpeed, uint newSpeed, uint newIndex) -{ - pConcArray[newIndex] = calcConcentration(oldSpeed, newSpeed); -} - - -__device__ void addConcToArray(real * pConcArray, uint oldSpeed, uint newSpeed, uint newIndex) -{ - pConcArray[newIndex] += calcConcentration(oldSpeed, newSpeed); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -void TrafficTimestep::combineJuncInCellIndices(std::vector<std::shared_ptr<Junction>> &junctions) -{ - for (auto& j : junctions) { - if (juncInCellIndices.size() == 0) juncStartInIncells.push_back(0); - else juncStartInIncells.push_back(castSizeT_Uint(juncInCellIndices.size())); - - for (uint i : j->getInCellIndices()) - this->juncInCellIndices.push_back(i); - } - size_juncInCells = castSizeT_Uint(juncInCellIndices.size()); -} - - -void TrafficTimestep::combineJuncOutCellIndices(std::vector<std::shared_ptr<Junction>> &junctions) -{ - for (auto& j : junctions) { - if (juncOutCellIndices.size() == 0) juncStartInOutcells.push_back(0); - else juncStartInOutcells.push_back(castSizeT_Uint(juncOutCellIndices.size())); - - for (uint i : j->getOutCellIndices()) - this->juncOutCellIndices.push_back(i); - } - size_juncOutCells = castSizeT_Uint(juncOutCellIndices.size()); -} - - -void TrafficTimestep::initJuncCarCanEnter() -{ - juncCarCanEnter.resize(size_juncInCells); - thrust::fill(juncCarCanEnter.begin(), juncCarCanEnter.end(), true); -} - -void TrafficTimestep::initJuncCarsOnJunction() -{ - juncCarsOnJunction.resize(size_juncInCells); - thrust::fill(juncCarsOnJunction.begin(), juncCarsOnJunction.end(), -1); -} - - -void TrafficTimestep::combineSinkBlockedPossibilities(std::vector<std::shared_ptr<Sink>> &sinks) -{ - for (auto& s : sinks) - this->sinkCarBlockedPossibilities.push_back(s->getPossibilityBeingBlocked()); -} - - -void TrafficTimestep::combineSourcePossibilities(std::vector<std::shared_ptr<Source>> &sources) { - for (auto& s : sources) - this->sourcePossibilities.push_back(s->getPossibility()); -} - -void TrafficTimestep::combineSourceIndices(std::vector<std::shared_ptr<Source>> &sources) -{ - for (auto& s : sources) - this->sourceIndices.push_back(s->getIndex()); -} - - -void TrafficTimestep::initJuncAlreadyMoved() -{ - juncAlreadyMoved.resize(size_juncInCells); - thrust::fill(juncAlreadyMoved.begin(), juncAlreadyMoved.end(), 0); -} - -void TrafficTimestep::initJuncOldSpeeds() -{ - juncOldSpeeds.resize(size_juncInCells); - thrust::fill(juncOldSpeeds.begin(), juncOldSpeeds.end(), 0); -} - -void TrafficTimestep::combineUseTrafficLights(std::vector<std::shared_ptr<Junction>>& junctions) -{ - for (auto& j : junctions) - juncTrafficLightSwitchTime.push_back(j->getTrafficLightSwitchTime()); -} - -void TrafficTimestep::initjuncOutCellIsOpen() -{ - juncOutCellIsOpen.resize(juncOutCellIndices.size()); - resetOutCellIsOpen(); -} - -void TrafficTimestep::combineJuncCarCanNotEnterThisOutCell(std::vector<std::shared_ptr<Junction>>& junctions) -{ - for (auto& j : junctions) - for (int i : j->getCarCanNotEnterThisOutCell()) - this->juncCarCanNotEnterThisOutCell.push_back(i); - - if (juncCarCanNotEnterThisOutCell.size() < size_juncInCells) - juncCarCanNotEnterThisOutCell.push_back(-2); -} - -uint TrafficTimestep::getNumCarsOnJunctions() -{ - uint num = 0; - for (int car : juncCarsOnJunction) - if (car >= 0) ++num; - return num; -} - -void TrafficTimestep::resetOutCellIsOpen() -{ - thrust::fill(juncOutCellIsOpen.begin(), juncOutCellIsOpen.end(), true); -} - -void TrafficTimestep::resetNext() -{ - if (timestepIsEven) - thrust::fill(roadCurrent.begin(), roadCurrent.end(), -1); - else - thrust::fill(roadNext.begin(), roadNext.end(), -1); -} - - -void TrafficTimestep::calculateTrafficTimestepKernelDimensions() -{ - unsigned int numberOfThreads = 64; - int Grid = (size_roads / numberOfThreads) + 1; - int Grid1, Grid2; - if (Grid > 512) - { - Grid1 = 512; - Grid2 = (Grid / Grid1) + 1; - } - else - { - Grid1 = 1; - Grid2 = Grid; - } - dim3 gridRoad1(Grid1, Grid2); - this->gridRoad = gridRoad1; - dim3 threadsRoads1(numberOfThreads, 1, 1); - this->threadsRoads = threadsRoads1; -} - -void TrafficTimestep::calculateJunctionKernelDimensions() -{ - unsigned int numberOfThreads = 32; - int Grid = (size_junctions / numberOfThreads) + 1; - int Grid1, Grid2; - if (Grid > 512) - { - Grid1 = 512; - Grid2 = (Grid / Grid1) + 1; - } - else - { - Grid1 = 1; - Grid2 = Grid; - } - dim3 gridJunctions1(Grid1, Grid2); - this->gridJunctions = gridJunctions1; - dim3 threadsJunctions1(numberOfThreads, 1, 1); - this->threadsJunctions = threadsJunctions1; -} - -void TrafficTimestep::calculateSourceKernelDimensions() -{ - unsigned int numberOfThreads = 32; - int Grid = (size_sinks / numberOfThreads) + 1; - int Grid1, Grid2; - if (Grid > 512) - { - Grid1 = 512; - Grid2 = (Grid / Grid1) + 1; - } - else - { - Grid1 = 1; - Grid2 = Grid; - } - dim3 gridSources1(Grid1, Grid2); - this->gridSources = gridSources1; - dim3 threadsSources1(numberOfThreads, 1, 1); - this->threadsSources = threadsSources1; -} diff --git a/src/gpu/Traffic/GPU/TrafficTimestep.h b/src/gpu/Traffic/GPU/TrafficTimestep.h deleted file mode 100644 index 113cc3d11260d7e89231e50951e75e43e17faf33..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/GPU/TrafficTimestep.h +++ /dev/null @@ -1,144 +0,0 @@ -#ifndef TrafficTimestep_H -#define TrafficTimestep_H - -#include <vector> -#include <memory> - -#include <thrust/device_vector.h> -#include <curand_kernel.h> - - -#include "PointerDefinitions.h" -#include "Core/DataTypes.h" -#include "Traffic_export.h" - -struct RoadNetworkData; -class Sink; -class Junction; -class Source; - -class TRAFFIC_EXPORT TrafficTimestep -{ -private: - - bool timestepIsEven = true; - uint numTimestep = 0; - - - uint maxVelocity; - uint safetyDistance; - real dawdlePossibility; - bool useSlowToStart; - real slowStartPossibility; - uint maxAcceleration; - - - //sizes - uint size_roads; - uint size_junctions; - uint size_juncInCells; - uint size_juncOutCells; - uint size_sources; - uint size_sinks; - - - //grids - dim3 gridRoad; - dim3 threadsRoads; - dim3 gridJunctions; - dim3 threadsJunctions; - dim3 gridSources; - dim3 threadsSources; - - - //road - thrust::device_vector<int> neighbors; - thrust::device_vector<int> roadCurrent; - thrust::device_vector<int> roadNext; - - - //junctions - thrust::device_vector<uint> juncTrafficLightSwitchTime; //no TrafficLight: 0 - - thrust::device_vector<uint> juncInCellIndices; - thrust::device_vector<bool> juncCarCanEnter; - thrust::device_vector<int> juncCarsOnJunction; - thrust::device_vector<uint> juncAlreadyMoved; - thrust::device_vector<uint> juncOldSpeeds; - - thrust::device_vector<int> juncOutCellIndices; - thrust::device_vector<int> juncCarCanNotEnterThisOutCell; //no such inCell: -2 - thrust::device_vector<bool> juncOutCellIsOpen; - thrust::device_vector<uint> juncStartInIncells; - thrust::device_vector<uint> juncStartInOutcells; - - - //sinks - thrust::device_vector<real> sinkCarBlockedPossibilities; - - - //sources - thrust::device_vector<float> sourcePossibilities; - thrust::device_vector<uint> sourceIndices; - - - //concentrations - real * pConcArray; - - //nasch velocity to set fluidBC - int* naschVelocity; - - //curandStates - curandState *statesJunctions; - curandState *statesSources; - curandState *statesRoad; - - int* pRoadCurrent; - int* pRoadNext; - -public: - - TrafficTimestep(std::shared_ptr<RoadNetworkData> road, real * pConcArray, int* naschVelocity); - void calculateTimestep(std::shared_ptr<RoadNetworkData> road); - void cleanUp(); - uint getNumCarsOnJunctions(); //only used for debugging - void copyCurrentDeviceToHost(std::shared_ptr<RoadNetworkData> road); - -private: - - //timestep - void switchCurrentNext(); - void resetOutCellIsOpen(); - void resetNext(); - - //kernel calls - void callTrafficTimestepKernel(); - void callSourceTimestepKernel(); - void callJunctionTimestepKernel(); - void callCalculationOfNaschVelocityForFluidBCKernel(); - - //init grids - void calculateTrafficTimestepKernelDimensions(); - void calculateJunctionKernelDimensions(); - void calculateSourceKernelDimensions(); - - //init junctions - void combineJuncInCellIndices(std::vector<std::shared_ptr<Junction> > &junctions); - void combineJuncOutCellIndices(std::vector<std::shared_ptr<Junction> > &junctions); - void combineJuncCarCanNotEnterThisOutCell(std::vector<std::shared_ptr<Junction> > &junctions); - void combineUseTrafficLights(std::vector<std::shared_ptr<Junction>>& junctions); - void initjuncOutCellIsOpen(); - void initJuncCarCanEnter(); - void initJuncCarsOnJunction(); - void initJuncAlreadyMoved(); - void initJuncOldSpeeds(); - - //init sinks - void combineSinkBlockedPossibilities(std::vector<std::shared_ptr<Sink>>& sinks); - - //init sources - void combineSourcePossibilities(std::vector<std::shared_ptr<Source> > &sources); - void combineSourceIndices(std::vector<std::shared_ptr<Source> > &sources); -}; - -#endif diff --git a/src/gpu/Traffic/Junction/Junction.h b/src/gpu/Traffic/Junction/Junction.h deleted file mode 100644 index 68da2bb1063c30e2259925dca6b6aeaec994107d..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Junction/Junction.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include <vector> - - -#include "Core/DataTypes.h" - -#include "JunctionData.h" -#include "Traffic_export.h" - -class TrafficMovement; - -class TRAFFIC_EXPORT Junction -{ -public: - virtual void checkOutCellIndices(const uint roadLength) const = 0; - - virtual void setCellIndicesForNoUTurn(std::vector<int> carCanNotEnterThisOutCell) = 0; - - virtual bool acceptsCar(uint cellIndex) = 0; //determines if a car can enter the junction - virtual void registerCar(uint cellIndex, uint numberOfCellsAlreadyMoved, uint speed, uint oldSpeed) = 0; //registers all cars entering the junction - virtual void calculateTimeStep(TrafficMovement &road, uint currentTimestep) = 0; - - virtual const std::vector<uint>& getInCellIndices()const = 0; - virtual const std::vector<uint>& getOutCellIndices() const = 0; - virtual const std::vector<bool>& getCarCanEnter() const = 0; - virtual const std::vector<int>& getCarsOnJunction()const = 0; - virtual const std::vector<uint>& getAlreadyMoved()const = 0; - virtual const std::vector<uint>& getOldSpeeds()const = 0; - virtual const std::vector<int>& getCarCanNotEnterThisOutCell() const = 0; - virtual uint getTrafficLightSwitchTime()const = 0; - - virtual void dispJunction(const uint index, const uint roadLength) const = 0; - virtual uint getNumCarsOnJunction() const = 0; -}; \ No newline at end of file diff --git a/src/gpu/Traffic/Junction/JunctionData.h b/src/gpu/Traffic/Junction/JunctionData.h deleted file mode 100644 index 3b72b1ef5db4d60515a2634586e6096aa115731a..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Junction/JunctionData.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - - -#include <vector> -#include <memory> - -#include "Utilities/RandomHelper.h" -#include "Traffic_export.h" - - -struct TRAFFIC_EXPORT JunctionData -{ -public: - std::vector<uint> inCellIndices; - std::vector<uint> outCellIndices; - std::vector<int> carCanNotEnterThisOutCell; //no such inCell: -2 - - std::vector<uint> possibleOutCells; - - std::vector<bool> carCanEnter; - std::vector<int> carsOnJunction; - std::vector<uint> alreadyMoved; - std::vector<uint> oldSpeeds; - - uint trafficLightSwitchTime; //no TrafficLight: 0 - uint halfNumStreets; - - std::mt19937 engine = RandomHelper::make_engine(); - std::uniform_real_distribution<float> distFloat{ 0.0, 1.0 }; -}; - diff --git a/src/gpu/Traffic/Junction/JunctionRandom.cpp b/src/gpu/Traffic/Junction/JunctionRandom.cpp deleted file mode 100644 index 7e6815a2a19193b6149e31e49e268a1606c7a3a7..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Junction/JunctionRandom.cpp +++ /dev/null @@ -1,298 +0,0 @@ -#include "JunctionRandom.h" - -#include <iostream> -#include <iomanip> //formatting output streams -#include <algorithm> //used for find() -#include <math.h> //used for floor() - -#include "TrafficMovement.h" - -#include "Utilities/invalidInput_error.h" -#include "Utilities/VectorHelper.h" -#include "Utilities/safe_casting.h" - - -JunctionRandom::JunctionRandom(const std::vector<uint> &inCellIndices, const std::vector<uint> &outCellIndices, uint trafficLightSwitchTime) -{ - data.inCellIndices = inCellIndices; - data.outCellIndices = outCellIndices; - - uint inRoads = castSizeT_Uint(inCellIndices.size()); - - data.carCanEnter.resize(inRoads); - std::fill(data.carCanEnter.begin(), data.carCanEnter.end(), true); - - data.carsOnJunction.resize(inRoads); - std::fill(data.carsOnJunction.begin(), data.carsOnJunction.end(), -1); - - data.alreadyMoved.resize(inRoads); - std::fill(data.alreadyMoved.begin(), data.alreadyMoved.end(), 0); - - data.oldSpeeds.resize(inRoads); - - this->data.trafficLightSwitchTime = trafficLightSwitchTime; - data.halfNumStreets = static_cast<uint>(std::floor(static_cast<float>(data.inCellIndices.size()) * 0.5f)); -} - - -void JunctionRandom::setCellIndicesForNoUTurn(std::vector<int> carCanNotEnterThisOutCell) -{ - try { - - if (data.inCellIndices.size() != carCanNotEnterThisOutCell.size()) throw invalidInput_error("The Vector carCanNotEnterThisOutCell and inCellIndices have to be the same size."); - data.carCanNotEnterThisOutCell = carCanNotEnterThisOutCell; - - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } -} - - -bool JunctionRandom::acceptsCar(uint cellIndex) -{ - return data.carCanEnter[getInCellsVectorIndex(cellIndex)]; -} - - -void JunctionRandom::registerCar(uint cellIndex, uint alreadyMoved, uint speed, uint oldSpeed) -{ - uint index = getInCellsVectorIndex(cellIndex); - - data.carsOnJunction[index] = speed; - //data.carsOnJunction[index] = 0; //all cars, which enter the junction have to stop - data.oldSpeeds[index] = oldSpeed; - data.carCanEnter[index] = false; - data.alreadyMoved[index] = alreadyMoved; -} - - -uint JunctionRandom::getInCellsVectorIndex(uint cellIndex) -{ - try { - auto it = find(data.inCellIndices.begin(), data.inCellIndices.end(), cellIndex); - - if (it != data.inCellIndices.end()) - return static_cast <uint> (distance(data.inCellIndices.begin(), it)); - - throw std::runtime_error("The passed cell is not an incoming cell to this junction."); - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } -} - - -void JunctionRandom::calculateTimeStep(TrafficMovement& road, uint currentTimestep) -{ - data.possibleOutCells = data.outCellIndices; - - uint index = 0; - for (int carSpeed : data.carsOnJunction) { - if (carSpeed >= 0) { //check if there is a car on the junction - applyRules(carSpeed, index, road); - } - ++index; - } - writeConcentrations(road); - - calculateTrafficLightTimeStep(currentTimestep); -} - - -void JunctionRandom::calculateTrafficLightTimeStep(uint currentTimestep) -{ - if (data.trafficLightSwitchTime > 0) { - if (static_cast<uint>(std::floor(static_cast<float>(currentTimestep) / static_cast<float>(data.trafficLightSwitchTime))) % 2 == 0) - turnFirstHalfRed(currentTimestep); - else - turnSecondHalfRed(currentTimestep); - } -} - -void JunctionRandom::turnFirstHalfRed(uint currentTimestep) -{ - for (uint i = 0; i < data.halfNumStreets; i++) - data.carCanEnter[i] = false; - - if (currentTimestep % data.trafficLightSwitchTime == 0) //first timestep with green light --> open the streets that were closed before - for (uint i = data.halfNumStreets; i < data.inCellIndices.size(); i++) - if (data.carsOnJunction[i] == -1) - data.carCanEnter[i] = true; -} - -void JunctionRandom::turnSecondHalfRed(uint currentTimestep) -{ - for (uint i = data.halfNumStreets; i < data.inCellIndices.size(); i++) - data.carCanEnter[i] = false; - - if (currentTimestep % data.trafficLightSwitchTime == 0) //first timestep with green light --> open the streets that were closed before - for (uint i = 0; i < data.halfNumStreets; i++) - if (data.carsOnJunction[i] == -1) - data.carCanEnter[i] = true; -} - - -void JunctionRandom::applyRules(int & carSpeed, int index, TrafficMovement& road) -{ - if (carSpeed == 0 && data.alreadyMoved[index] == 0) - carSpeed += 1; - - int remainingDistance = carSpeed - static_cast<int>(data.alreadyMoved[index]); - if (remainingDistance > 0) { - int outCell = chooseOutCell(index); - if (outCell >= 0) { - brakeCar(outCell, carSpeed, remainingDistance, road); - if (remainingDistance > 0) { - moveCar(outCell, carSpeed, index, remainingDistance, road); - return; - } - } - } - data.alreadyMoved[index] = 0; - data.carsOnJunction[index] = 0; //cars, which can't cross the junctionin one timestep, because they already moved to many cells, loose their speed. - //data.getCarsOnJunction[index] = carSpeed; //cars, which can't cross the junction in one timestep, because they already moved to many cells, keep their speed. -} - - -void JunctionRandom::brakeCar(uint outCellIndex, int &speed, int &remainingDistance, TrafficMovement& road) -{ - int gap = road.getGapAfterOutCell(outCellIndex, remainingDistance); - if (gap < remainingDistance) { - if (gap > speed) gap = speed; - speed = speed - remainingDistance + gap; - remainingDistance = gap; - } -} - - -void JunctionRandom::moveCar(uint outCell, int carSpeed, int index, int remainingDistance, TrafficMovement& road) -{ - road.moveJunctionCar(outCell, remainingDistance, carSpeed, data.oldSpeeds[index]); - data.carsOnJunction[index] = -1; - data.carCanEnter[index] = true; -} - - -int JunctionRandom::chooseOutCell(int index) -{ - std::vector<uint> outCellsTemp; - - if (data.carCanNotEnterThisOutCell.size() > 0 && data.carCanNotEnterThisOutCell[index] >= 0) { - for (uint cell : data.possibleOutCells) { - if (cell != data.carCanNotEnterThisOutCell[index]) - outCellsTemp.push_back(cell); - } - } - else - outCellsTemp = data.possibleOutCells; - - if (outCellsTemp.size() == 0) return -1; - int random = generateRandomOutCellIndex(castSizeT_Uint(outCellsTemp.size())); - - int outCell = outCellsTemp[random]; - data.possibleOutCells.erase(std::remove(data.possibleOutCells.begin(), data.possibleOutCells.end(), outCell), data.possibleOutCells.end()); - return outCell; -} - - -int JunctionRandom::generateRandomOutCellIndex(uint outCellsTempSize) -{ - if (outCellsTempSize == 0) - return 0; - - return static_cast<int>(std::floor(data.distFloat(data.engine) * outCellsTempSize)); -} - -void JunctionRandom::writeConcentrations(TrafficMovement& road) -{ - int i = 0; - for (int carSpeed : data.carsOnJunction) { - if (carSpeed >= 0) { - road.writeConcentrationForJunction(data.inCellIndices[i], data.oldSpeeds[i], data.carsOnJunction[i]); - data.oldSpeeds[i] = data.carsOnJunction[i]; - } - ++i; - } -} - -const std::vector<uint>& JunctionRandom::getInCellIndices() const -{ - return data.inCellIndices; -} - -const std::vector<uint>& JunctionRandom::getOutCellIndices() const -{ - return data.outCellIndices; -} - -const std::vector<bool>& JunctionRandom::getCarCanEnter() const -{ - return data.carCanEnter; -} - -const std::vector<int>& JunctionRandom::getCarsOnJunction() const -{ - return data.carsOnJunction; -} - -const std::vector<uint>& JunctionRandom::getAlreadyMoved() const -{ - return data.alreadyMoved; -} - -const std::vector<uint>& JunctionRandom::getOldSpeeds() const -{ - return data.oldSpeeds; -} - -const std::vector<int>& JunctionRandom::getCarCanNotEnterThisOutCell() const -{ - return data.carCanNotEnterThisOutCell; -} - -uint JunctionRandom::getTrafficLightSwitchTime() const -{ - return data.trafficLightSwitchTime; -} - -void JunctionRandom::dispJunction(const uint index, const uint roadLength) const -{ - if (find(data.inCellIndices.begin(), data.inCellIndices.end(), (roadLength - index - 1)) != data.inCellIndices.end()) { - std::cout << std::setw(4) << "in"; - } - else if (find(data.outCellIndices.begin(), data.outCellIndices.end(), (roadLength - index - 1)) != data.outCellIndices.end()) { - std::cout << std::setw(4) << "out"; - } - else { - std::cout << std::setw(4) << " "; - } -} - -uint JunctionRandom::getNumCarsOnJunction() const -{ - uint num = 0; - for (auto car : data.carsOnJunction) - if (car >= 0) - ++num; - return num; -} - -void JunctionRandom::checkOutCellIndices(const uint roadLength) const -{ - try { - for (uint cell : data.outCellIndices) - if (cell >= roadLength) throw invalidInput_error("The indices of incoming cells to a junction are greater than the roadLength."); - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } -} - - diff --git a/src/gpu/Traffic/Junction/JunctionRandom.h b/src/gpu/Traffic/Junction/JunctionRandom.h deleted file mode 100644 index 21ce459685ec6cb09fe5b9d12f2a7e923cb63748..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Junction/JunctionRandom.h +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once -#include <random> -#include <vector> - - -#include "Core/DataTypes.h" - -#include "Junction.h" -#include "Traffic_export.h" - -class TrafficMovement; - -class TRAFFIC_EXPORT JunctionRandom : - public Junction -{ - -private: - JunctionData data; - -public: - JunctionRandom(const std::vector<uint> &inCellIndices, const std::vector<uint> &outCellIndices, uint trafficLightSwitchTime = 0); - ~JunctionRandom() {}; - - virtual void setCellIndicesForNoUTurn(std::vector<int> carCanNotEnterThisOutCell); - - virtual bool acceptsCar(uint cellIndex); //determines if a car can enter the junction - virtual void registerCar(uint cellIndex, uint numberOfCellsAlreadyMoved, uint speed, uint oldSpeed); //registers all cars entering the junction - virtual void calculateTimeStep(TrafficMovement &road, uint currentTimestep); - - virtual const std::vector<uint>& getInCellIndices() const; - virtual const std::vector<uint>& getOutCellIndices() const; - virtual const std::vector<bool>& getCarCanEnter() const; - virtual const std::vector<int>& getCarsOnJunction()const; - virtual const std::vector<uint>& getAlreadyMoved()const; - virtual const std::vector<uint>& getOldSpeeds()const; - virtual const std::vector<int>& getCarCanNotEnterThisOutCell()const; - virtual uint getTrafficLightSwitchTime()const; - - virtual void dispJunction(const uint index, const uint roadLength) const; - virtual uint getNumCarsOnJunction() const; - - virtual void checkOutCellIndices(const uint roadLength) const; - -private: - uint getInCellsVectorIndex(uint cellIndex); - - void applyRules(int &carSpeed,int index, TrafficMovement &road); - void brakeCar(uint outCellIndex, int &speed, int &remainingDistance, TrafficMovement &road); - void moveCar(uint outCell, int carSpeed, int index, int remainingDistance, TrafficMovement &road); - int chooseOutCell(int index); - int generateRandomOutCellIndex(uint outCellsTempSize); - - void calculateTrafficLightTimeStep(uint currentTimestep); - void turnFirstHalfRed(uint currentTimestep); - void turnSecondHalfRed(uint currentTimestep); - - - void writeConcentrations(TrafficMovement &road); - -}; - diff --git a/src/gpu/Traffic/Output/CarDisplay.cpp b/src/gpu/Traffic/Output/CarDisplay.cpp deleted file mode 100644 index 06d19ef187a6602e9ed5d70f935600dc2cd630f5..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Output/CarDisplay.cpp +++ /dev/null @@ -1,178 +0,0 @@ -#include "CarDisplay.h" - -#include <fstream> -#include <iostream> -#include <iomanip> //formatting output streams -#include <stdexcept> - -#include "Utilities/VectorHelper.h" -#include "Utilities/safe_casting.h" -#include "Utilities/ConsoleColor.h" - -CarDisplay::CarDisplay(std::vector<int> **pcurrent, const uint safetyDistance): - safetyDistance{ safetyDistance } -{ - this->ppcurrent = pcurrent; - roadLength = castSizeT_Uint((*pcurrent)->size()); -} - - -void CarDisplay::initResults(uint timeSteps) -{ - this->timeSteps = timeSteps; - - results.resize(roadLength, std::vector<int>(1)); - - for (uint i = 0; i < roadLength; i++) { - results[i].resize(timeSteps + 1); - } - - VectorHelper::fillVector(results, -1); - putCurrentIntoResults(0); -} - - -void CarDisplay::putCurrentIntoResults(uint step) -{ - writingStep = step; - for (uint i = 0; i < roadLength; i++) - results[i][writingStep] = (**ppcurrent)[i]; -} - - -void CarDisplay::writeResultsToFile() const -{ - try { - - - std::fstream outFile("results.txt", std::fstream::out | std::fstream::trunc); - if (outFile.is_open()) - { - for (uint i = 0; i < results.size(); i++) { - for (uint j = 0; j < results[i].size() - 1; j++) - outFile << results[i][j] << " "; - - outFile << results[i][results[i].size() - 1]; - outFile << std::endl; - } - std::cout << "Finished writing data to file" << std::endl; - } - - - else - throw std::runtime_error("Couldn't open file"); - - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } - catch (...) { - std::cerr << "unknown exception while writing to file" << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } -} - - -void CarDisplay::dispCurrentRoad() const -{ - std::cout << "current: ( step: " << writingStep << " )" << std::endl; - VectorHelper::dispVectorColour(**ppcurrent); -} - - -void CarDisplay::dispResults(const std::vector<int> * neighbors, const std::vector<std::shared_ptr<Sink> > & sinks, const std::vector<std::shared_ptr<Junction> > & junctions, const std::vector<std::shared_ptr<Source> > & sources) -{ - writeResultsToFile(); - - visualizeSafetyDistanceForConsole(neighbors); - //reverse(results.begin(), results.end()); - // new implementation based on https://en.cppreference.com/w/cpp/algorithm/reverse - { - auto first = results.begin(); - auto last = results.end(); - while ((first != last) && (first != --last)) { - std::iter_swap(first++, last); - } - } - - for (uint i = 0; i < results.size(); i++) { - - dispJunctionsAtCell(i, junctions); - dispSinksAtCell(i, sinks); - dispSourcesAtCell(i, sources); - - for (uint j = 0; j < results[i].size(); j++) { - VectorHelper::makeVectorOutputColourful(results[i][j]); - std::cout << std::setw(4) << results[i][j]; - } - - std::cout << std::endl; - } - std::cout << std::endl; - ConsoleColor::setDefaultWhite(); -} - - -void CarDisplay::dispJunctionsAtCell(uint index, const std::vector<std::shared_ptr<Junction> > & junctions) const -{ - for (auto& junc : junctions) { - ConsoleColor::setDefaultWhite(); - junc->dispJunction(index, roadLength); - } -} - - -void CarDisplay::dispSinksAtCell(uint index, const std::vector<std::shared_ptr<Sink> > & sinks) const -{ - for (auto& sink : sinks) { - if (sink->getIndex() == roadLength - index - 1) { - ConsoleColor::setBrightRed(); - std::cout << std::setw(4) << 1 - (sink->getPossibilityBeingBlocked()); - return; - } - std::cout << std::setw(4) << " "; - } -} - - -void CarDisplay::dispSourcesAtCell(uint index, const std::vector<std::shared_ptr<Source> > & sources) const -{ - for (auto& source : sources) { - if (source->getIndex() == roadLength - index - 1) { - ConsoleColor::setBrightRed(); - std::cout << std::setw(4) << source->getPossibility(); - return; - } - std::cout << std::setw(4) << " "; - } -} - - -void CarDisplay::visualizeSafetyDistanceForConsole(const std::vector<int>* neighbors) -{ - if (safetyDistance != 0) { - int neighbor; - for (uint step = 0; step <= timeSteps; step++) { - for (uint i = 0; i < roadLength; i++) { - if (results[i][step] > -1) { - neighbor = (*neighbors)[i]; - for (uint j = 1; j <= safetyDistance; j++) { - //junction or sink - if (neighbor <= -1000) - break; - if (results[neighbor][step] > -1) { - std::cerr << "safetyDistance was violated: timestep: " << step << "\t carIndex: " << i << std::endl; - break; - } - else - results[neighbor][step] = -5; - neighbor = (*neighbors)[neighbor]; - } - } - } - } - } -} diff --git a/src/gpu/Traffic/Output/CarDisplay.h b/src/gpu/Traffic/Output/CarDisplay.h deleted file mode 100644 index 336160139220424346a0f4faf2fd269b01840ac1..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Output/CarDisplay.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - - -#include <vector> -#include <memory> - -#include "Sink/Sink.h" -#include "Source/Source.h" -#include "Junction/Junction.h" - -#include "Traffic_export.h" - - -class TRAFFIC_EXPORT CarDisplay { -public: - CarDisplay(std::vector<int> **pcurrent, const uint safetyDistance); - ~CarDisplay() {}; - - void initResults(uint timeSteps); - - void dispCurrentRoad() const; - void dispResults(const std::vector<int> * neighbors, const std::vector<std::shared_ptr<Sink> > & sinks, const std::vector<std::shared_ptr<Junction> > & junctions, const std::vector<std::shared_ptr<Source> > & sources); - void writeResultsToFile() const; - - void putCurrentIntoResults(uint step); - -private: - void visualizeSafetyDistanceForConsole(const std::vector<int> * neighbors); - - void dispJunctionsAtCell(uint index, const std::vector<std::shared_ptr<Junction> > & junctions) const; - void dispSinksAtCell(uint index, const std::vector<std::shared_ptr<Sink> > & sinks) const; - void dispSourcesAtCell(uint index, const std::vector<std::shared_ptr<Source> > & sources) const; - -private: - std::vector<std::vector<int> > results; //saves the results of the calculation; x-axis = timesteps, y axis = positions - - std::vector<int> **ppcurrent; - uint roadLength; - const uint safetyDistance; - - uint timeSteps; - uint writingStep; -}; \ No newline at end of file diff --git a/src/gpu/Traffic/Output/ConcBySpeedAndAcceleration.cpp b/src/gpu/Traffic/Output/ConcBySpeedAndAcceleration.cpp deleted file mode 100644 index e62f87f44492583c24d04aaf3bdf4b72667dd1df..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Output/ConcBySpeedAndAcceleration.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "ConcBySpeedAndAcceleration.h" - -#include <iostream> - -ConcBySpeedAndAcceleration::ConcBySpeedAndAcceleration(uint roadLength, real * concArrayStart) -{ - if (concArrayStart == nullptr) { - std::cout << "using ConcBySpeedAndAcceleration::concentration-vector for concentrations" << std::endl; - concentration.resize(roadLength); - this->roadLength = roadLength; - } - else { - std::cout << "using passed array for concentrations" << std::endl; - useLBMConcArray = true; - this->roadLength = roadLength; - this->concArrayStart = concArrayStart; - } - -} - -void ConcBySpeedAndAcceleration::calculateConcForSingleCar(uint index, uint oldSpeed, uint speed) -{ - putConcIntoArrayOrVector(index, chooseConc(oldSpeed, speed)); -} - - -void ConcBySpeedAndAcceleration::calculateConcForAllCars(const std::vector<int> oldSpeeds, const std::vector<int> newSpeeds) -{ - for (uint i = 0; i < roadLength; i++) { - if (newSpeeds[i] > -1) - putConcIntoArrayOrVector(i, chooseConc(oldSpeeds[i], newSpeeds[i])); - } -} - -void ConcBySpeedAndAcceleration::calculateConcForJunctionCar(uint index, uint oldSpeed, uint speed) -{ - addConcToArrayOrVector(index, chooseConc(oldSpeed, speed)); - -} - -real ConcBySpeedAndAcceleration::chooseConc(uint oldSpeed, uint speed) -{ - if (oldSpeed == 0 && speed > 0) //Start - return 0.833f; - else if (oldSpeed == 0 && speed == 0) //Idle - return 0.069f; - else if (speed == oldSpeed) //Drive - return 0.221f; - else if (speed > oldSpeed) //Accelerate - return 0.625f; - else if (speed < oldSpeed) //Brake - return 0.379f; - else - std::cerr << "couldn't choose driving state in ConcentrationBySpeedAndAcceleration::chooseConc" << std::endl; - return -1.0f; -} diff --git a/src/gpu/Traffic/Output/ConcBySpeedAndAcceleration.h b/src/gpu/Traffic/Output/ConcBySpeedAndAcceleration.h deleted file mode 100644 index 50f9671080bf049baef6b37e509a54faa02d8110..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Output/ConcBySpeedAndAcceleration.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include "ConcentrationOutwriter.h" - -#include "Traffic_export.h" - -class TRAFFIC_EXPORT ConcBySpeedAndAcceleration : - public ConcentrationOutwriter -{ -public: - ConcBySpeedAndAcceleration(uint roadlength, real* concArrayStart = 0); - ~ConcBySpeedAndAcceleration() {}; - - virtual void calculateConcForSingleCar(uint index, uint oldSpeed, uint speed); - virtual void calculateConcForJunctionCar(uint index, uint oldSpeed, uint speed); - virtual void calculateConcForAllCars(const std::vector<int> oldSpeeds, const std::vector<int> newSpeeds); - - -private: - real chooseConc(uint oldSpeed, uint speed); - -}; - diff --git a/src/gpu/Traffic/Output/ConcentrationByPosition.cpp b/src/gpu/Traffic/Output/ConcentrationByPosition.cpp deleted file mode 100644 index bdfc46e13b319e542805b50c5a76cb89f7aeacec..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Output/ConcentrationByPosition.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "ConcentrationByPosition.h" - -#include <iostream> - -ConcentrationByPosition::ConcentrationByPosition(uint roadLength, real * concArrayStart, uint maxSpeed) -{ - if (concArrayStart == nullptr) { - std::cout << "using ConcentrationByPosition::concentration-vector for concentrations" << std::endl; - concentration.resize(roadLength); - this->roadLength = roadLength; - } - else { - std::cout << "using passed array for concentrations" << std::endl; - useLBMConcArray = true; - this->roadLength = roadLength; - this->concArrayStart = concArrayStart; - } - -} - -//void ConcentrationByPosition::calculateConcFromCarDistribution(const std::vector<int>& currentCarDistribution) -//{ -// for (uint i = 0; i < currentCarDistribution.size(); i++) { -// if (currentCarDistribution[i] >= 0) -// concentration[i] = 1.0; -// else -// concentration[i] = 0.0; -// } -// -// //dispConcentration(); -//} - - -void ConcentrationByPosition::calculateConcForSingleCar(uint index, uint oldSpeed, uint speed) -{ - putConcIntoArrayOrVector(index, 1.0); -} - -void ConcentrationByPosition::calculateConcForJunctionCar(uint index, uint oldSpeed, uint speed) -{ - addConcToArrayOrVector(index, 1.0); -} - -void ConcentrationByPosition::calculateConcForAllCars(const std::vector<int> oldSpeeds, const std::vector<int> newSpeeds) -{ - for (uint i = 0; i < roadLength; i++) - if (newSpeeds[i] >= 0) - putConcIntoArrayOrVector(i, 1.0); -} - - diff --git a/src/gpu/Traffic/Output/ConcentrationByPosition.h b/src/gpu/Traffic/Output/ConcentrationByPosition.h deleted file mode 100644 index cd136d1689c6888b4da2097e02ee9bd2e97e2743..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Output/ConcentrationByPosition.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include "ConcentrationOutwriter.h" - -#include "Traffic_export.h" - -class TRAFFIC_EXPORT ConcentrationByPosition: - public ConcentrationOutwriter -{ -public: - ConcentrationByPosition(uint roadlength, real* concArrayStart = nullptr, uint maxSpeed = 0); - ~ConcentrationByPosition() {}; - - virtual void calculateConcForSingleCar(uint index, uint oldSpeed = 0, uint speed = 0); - virtual void calculateConcForJunctionCar(uint index, uint oldSpeed = 0, uint speed = 0); - virtual void calculateConcForAllCars(const std::vector<int> oldSpeeds, const std::vector<int> newSpeeds) = 0; -}; - diff --git a/src/gpu/Traffic/Output/ConcentrationOutwriter.cpp b/src/gpu/Traffic/Output/ConcentrationOutwriter.cpp deleted file mode 100644 index cf8d13a7047855ee10eb452e7ff74fad7b8be410..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Output/ConcentrationOutwriter.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "ConcentrationOutwriter.h" - -#include <iostream> -#include <iomanip> //formatting output streams - -#include "Utilities/ConsoleColor.h" - -void ConcentrationOutwriter::resetConcentrations() -{ - if (useLBMConcArray) - for (real* p = concArrayStart; p < concArrayStart + roadLength; ++p) - *p = 0.0; - else - std::fill(concentration.begin(), concentration.end(), 0.0f); -} - - -void ConcentrationOutwriter::putConcIntoArrayOrVector(uint index, real conc) -{ - if (useLBMConcArray) { - real *pos = concArrayStart + index; - *pos = conc; - } - else - concentration[index] = conc; -} - - -void ConcentrationOutwriter::addConcToArrayOrVector(uint index, real conc) -{ - if (useLBMConcArray) { - real *pos = concArrayStart + index; - //if ((*pos + conc) > 1.0) *pos = 1.0; - //else - *pos += conc; - } - else - // if (concentration[index] + conc > 1.0) concentration[index] = 1.0; - // else - concentration[index] += conc; -} - - -void ConcentrationOutwriter::dispCurrentConcentrations() -{ - if (useLBMConcArray) - for (real* p = concArrayStart; p < concArrayStart + roadLength; ++p) - dispSingleConcentration(*p); - else - for (auto cell : concentration) - dispSingleConcentration(cell); - - - std::cout << std::endl; - - ConsoleColor::setDefaultWhite(); -} - - -void ConcentrationOutwriter::dispSingleConcentration(real conc) -{ - if (conc > 0) - ConsoleColor::setBrightRed(); - else - ConsoleColor::setDarkGrey(); - std::cout << std::setw(4) << conc; -} diff --git a/src/gpu/Traffic/Output/ConcentrationOutwriter.h b/src/gpu/Traffic/Output/ConcentrationOutwriter.h deleted file mode 100644 index 9589e5f4b6751899e20106cfa41cb4cd29b11205..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Output/ConcentrationOutwriter.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include <vector> - - -#include "Core/DataTypes.h" - -#include "Traffic_export.h" - -class TRAFFIC_EXPORT ConcentrationOutwriter -{ -public: - virtual void resetConcentrations(); - virtual void calculateConcForSingleCar(uint index, uint oldSpeed = 0, uint speed = 0) = 0; - virtual void calculateConcForJunctionCar(uint index, uint oldSpeed = 0, uint speed = 0) = 0; - virtual void calculateConcForAllCars(const std::vector<int> oldSpeeds, const std::vector<int> newSpeeds)=0; - void dispCurrentConcentrations(); - -protected: - void putConcIntoArrayOrVector(uint index, real conc); - void addConcToArrayOrVector(uint index, real conc); - -protected: - std::vector<real> concentration; - bool useLBMConcArray = false; - real* concArrayStart; - uint roadLength; - -private: - void dispSingleConcentration(real conc); - -}; - diff --git a/src/gpu/Traffic/RoadNetwork/RoadMaker.cpp b/src/gpu/Traffic/RoadNetwork/RoadMaker.cpp deleted file mode 100644 index d024ab6b0c5d4af48bb464b162bdc916b557d6c3..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/RoadNetwork/RoadMaker.cpp +++ /dev/null @@ -1,292 +0,0 @@ -#include "RoadMaker.h" - -#include <iostream> - -#include "Utilities/VectorHelper.h" -#include "Utilities/invalidInput_error.h" -#include "Utilities/safe_casting.h" - - -//random vehicle Distribution -RoadMaker::RoadMaker(const uint roadLength, const uint maxVelocity, uint vehicleLength, const real vehicleDensity) -{ - std::uniform_int_distribution<uint> distInt2{ 0, maxVelocity }; - distInt = distInt2; - - this->roadLength = roadLength; - this->maxVelocity = maxVelocity; - initVehicleLength(vehicleLength); - - //init vectors - //this->conc.resize(this->roadLength); - initCurrentAsEmpty(); - initNext(); - initNeighbors(); - initCurrentWithLongVehicles(); - - initVehicleDensity(vehicleDensity); -} - - -//given vehicle distribution -RoadMaker::RoadMaker(const std::vector<int> vehicleDistribution, const uint maxVelocity, uint vehicleLength) -{ - this->roadLength = castSizeT_Uint(vehicleDistribution.size()); - - this->maxVelocity = maxVelocity; - initVehicleLength(vehicleLength); - - //init vectors - //this->conc.resize(this->roadLength); - current = vehicleDistribution; - initNext(); - initNeighbors(); - initCurrentWithLongVehicles(); -} - - -//empty road -RoadMaker::RoadMaker(const uint roadLength, const uint maxVelocity, uint vehicleLength) -{ - this->roadLength = roadLength; - this->maxVelocity = maxVelocity; - initVehicleLength(vehicleLength); - - //init vectors - //this->conc.resize(this->roadLength); - initCurrentAsEmpty(); - initNext(); - initNeighbors(); - initCurrentWithLongVehicles(); -} - - -RoadMaker::~RoadMaker() -{ -} - - -void RoadMaker::initNext() -{ - next.resize(roadLength); - VectorHelper::fillVector(next, -1); -} - - -void RoadMaker::initNeighbors() -{ - neighbors.resize(roadLength); - for (uint i = 0; i < roadLength - 1; i++) { - neighbors[i] = i + 1; - } - neighbors[roadLength - 1] = 0; -} - - -void RoadMaker::initCurrentAsEmpty() -{ - current.resize(roadLength); - VectorHelper::fillVector(current, -1); -} - - -void RoadMaker::initCurrentWithLongVehicles() -{ - currentWithLongVehicles.resize(roadLength); -} - - -void RoadMaker::initVehicleDensity(const real vehicleDensity) -{ - try { - if (vehicleDensity > 0 && vehicleDensity < 1) { - initRandomCars(vehicleDensity); - } - else { - throw invalidInput_error("The vehicleDensity should be between 0 and 1"); - } - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } -} - - -void RoadMaker::initRandomCars(const real vehicleDensity) -{ - //this method doesn't fill the first cells, so that the safetyDistance isn't violated in a periodic road - for (uint i = safetyDistance; i < roadLength; i++) { - double randomNumber = distFloat(engine); - if (randomNumber <= vehicleDensity) { - current[i] = randomSpeed(); - i += safetyDistance; - } - } -} - - -int RoadMaker::randomSpeed() -{ - return distInt(engine); -} - - -void RoadMaker::initVehicleLength(const uint vehicleLength) -{ - try { - if (vehicleLength == 0) throw invalidInput_error("The vehicleLength has to be greater than 0"); - this->vehicleLength = vehicleLength; - this->safetyDistance = vehicleLength - 1; - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } -} - - -void RoadMaker::setJunctions(std::vector<std::shared_ptr<Junction> > & junctions) -{ - for (auto& junc : junctions) - addJunction(junc); -} - - -void RoadMaker::addJunction(std::shared_ptr<Junction>& junction) -{ - try { - - junction->checkOutCellIndices(roadLength); - setJunctionAsNeighbor(junction); - this->junctions.push_back(junction); - - if (junctions.size() > 999) throw std::runtime_error("too many junctions"); - - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } -} - - -void RoadMaker::setJunctionAsNeighbor(std::shared_ptr<Junction> & junction) -{ - //set the junction as neighbor of the incoming cells - - int junctionIndex = -1000 - castSizeT_Int(junctions.size()); //value range: -1000 to -1999 - std::vector<uint> inCells = junction->getInCellIndices(); - - try { - - for (auto cell : inCells) { - if (cell >= roadLength) throw invalidInput_error("The index of an incoming cell to a junction ist greater than the roadLength."); - if (neighbors[cell] < 0) - std::cout << "The neighboring cell of cell " << cell << " was already definded as sink or junction, no new junction added." << std::endl; - else - neighbors[cell] = junctionIndex; - } - - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } -} - - -void RoadMaker::setSinks(std::vector<std::shared_ptr<Sink> > & sinks) -{ - for (auto& sink : sinks) - addSink(sink); -} - - -void RoadMaker::addSink(std::shared_ptr<Sink>& sink) -{ - - try { - - setSinkAsNeighbor(sink); - this->sinks.push_back(sink); - if (sinks.size() > 999) throw std::runtime_error("too many sinks"); - - - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } - -} - - -void RoadMaker::setSinkAsNeighbor(std::shared_ptr<Sink> & sink) -{ - //set the sink as neighbor of the incoming cell - - int sinkIndex = -2000 - castSizeT_Int(sinks.size()); //value range: -2000 to -2999 - uint sinkCell = sink->getIndex(); - - if (sinkCell >= roadLength) throw invalidInput_error("The index of a sink ist greater than the roadLength."); - - if (neighbors[sinkCell] < 0) { - std::cout << "The neighboring cell of cell " << sinkCell << " was already definded as sink or junction, no new sink added." << std::endl; - } - else - { - neighbors[sinkCell] = sinkIndex; - } -} - - - -void RoadMaker::setSources(std::vector< std::shared_ptr<Source> > & sources) -{ - for (auto& source : sources) - addSource(source); -} - - -void RoadMaker::addSource(std::shared_ptr<Source>& source) -{ - try { - if (source->getIndex() >= roadLength) throw invalidInput_error("Source index is greater than roadlength"); - this->sources.push_back(source); - } - - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } -} - - -void RoadMaker::setNeighbor(uint index, uint neighbor) -{ - this->neighbors[index] = neighbor; -} - -void RoadMaker::setNeighborForCurve(uint index, uint neighbor) -{ - this->neighbors[index] = neighbor; - for (uint i = 0; i < this->vehicleLength; i++) { - if (neighbor < 0) break; - this->current[neighbor] = -1; - neighbor = neighbors[neighbor]; - } -} - - -uint RoadMaker::getMaxVelocity() -{ - return maxVelocity; -} - diff --git a/src/gpu/Traffic/RoadNetwork/RoadMaker.h b/src/gpu/Traffic/RoadNetwork/RoadMaker.h deleted file mode 100644 index 9d6d324608db6f348a6a8dacb1121c279ba6452f..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/RoadNetwork/RoadMaker.h +++ /dev/null @@ -1,52 +0,0 @@ - #pragma once -#include <random> - -#include "RoadNetworkData.h" - -#include "Utilities/RandomHelper.h" - -#include "Traffic_export.h" - - -struct TRAFFIC_EXPORT RoadMaker : - public RoadNetworkData -{ -public: - RoadMaker(const uint roadLength, const uint maxVelocity, uint vehicleLength, const real vehicleDensity); //random vehicle Distribution - RoadMaker(const std::vector<int> vehicleDistribution, const uint maxVelocity, uint vehicleLength); //given vehicle distribution - RoadMaker(const uint roadLength, const uint maxVelocity, uint vehicleLength);//empty road - - ~RoadMaker(); - - void setJunctions( std::vector<std::shared_ptr<Junction> > & junctions); //max 999 junctions - void addJunction(std::shared_ptr<Junction> & junction); - void setSinks(std::vector< std::shared_ptr<Sink> > & sinks); //max 999 sinks - void addSink(std::shared_ptr<Sink> & sink); - void setSources(std::vector< std::shared_ptr<Source> > & sources); - void addSource(std::shared_ptr<Source> & source); - - void setNeighbor(uint index, uint neighbor); // don't use it for setting sinks or junctions! - void setNeighborForCurve(uint index, uint neighbor); - - uint getMaxVelocity(); - -private: - std::mt19937 engine = RandomHelper::make_engine(); - std::uniform_real_distribution<real> distFloat{ 0.0, 1.0 }; - std::uniform_int_distribution<uint> distInt{ 0, maxVelocity }; - -private: - void initNext(); - void initNeighbors(); - void initCurrentAsEmpty(); - void initCurrentWithLongVehicles(); - void initVehicleDensity(const real vehicleDensity); - void initRandomCars(const real vehicleDensity); - void initVehicleLength(const uint vehicleLength); - int randomSpeed(); - - void setJunctionAsNeighbor(std::shared_ptr<Junction> & junction); - void setSinkAsNeighbor(std::shared_ptr<Sink> & sink); - -}; - diff --git a/src/gpu/Traffic/RoadNetwork/RoadNetworkData.h b/src/gpu/Traffic/RoadNetwork/RoadNetworkData.h deleted file mode 100644 index 3839c53c8449b6c52bfaf7cf0e026559ee5aa9d7..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/RoadNetwork/RoadNetworkData.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once -#include <memory> -#include <vector> - - - -#include "Source/Source.h" -#include "Sink/Sink.h" -#include "Junction/Junction.h" - -#include "Traffic_export.h" - - -struct TRAFFIC_EXPORT RoadNetworkData -{ -protected: - friend class TrafficMovement; - friend class TrafficTimestep; - - uint roadLength; - uint maxVelocity; - uint vehicleLength; - uint safetyDistance; - - std::vector<int> current; - std::vector<int> currentWithLongVehicles; - std::vector<int> next; //for temporary calculations - std::vector<int> neighbors; - - std::vector<std::shared_ptr<Sink> > sinks; - std::vector<std::shared_ptr<Junction> > junctions; - std::vector<std::shared_ptr<Source> > sources; - - std::vector<int> *pcurrent; - std::vector<int> *pnext; - std::vector<int> *pdummy; - - std::vector<int> oldSpeeds; - - real dawdlePossibility; - bool useSlowToStart = false; - real slowStartPossibility; - uint maxAcceleration = 1; - - std::vector<real> conc; //dispConcFromGPU -}; - diff --git a/src/gpu/Traffic/Sink/Sink.h b/src/gpu/Traffic/Sink/Sink.h deleted file mode 100644 index 792e32e8dd4031722d3a65da8148ffbd402e3e6c..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Sink/Sink.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "SinkData.h" - -#include "Traffic_export.h" - -class TRAFFIC_EXPORT Sink -{ -public: - virtual real getPossibilityBeingBlocked() const = 0; - virtual bool carCanEnter() = 0; - virtual uint getIndex() const = 0; -}; - diff --git a/src/gpu/Traffic/Sink/SinkData.h b/src/gpu/Traffic/Sink/SinkData.h deleted file mode 100644 index 9603c816ae0733e7f73e4b70c165ba06f5a40e9f..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Sink/SinkData.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - - -#include "Core/DataTypes.h" - -#include "Traffic_export.h" - -struct TRAFFIC_EXPORT SinkData { - uint sinkIndex; - real sinkBlockedPossibility; -}; \ No newline at end of file diff --git a/src/gpu/Traffic/Sink/SinkRandom.cpp b/src/gpu/Traffic/Sink/SinkRandom.cpp deleted file mode 100644 index 9e49f83d1b693eace90b285aafaaa54be0ee58c7..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Sink/SinkRandom.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "SinkRandom.h" - -#include <iostream> - -#include "Utilities/invalidInput_error.h" - -SinkRandom::SinkRandom(uint sinkIndex, real sinkBlockedPossibility) -{ - data.sinkIndex = sinkIndex; - - try { - if (sinkBlockedPossibility >= 0 && sinkBlockedPossibility <= 1) { - data.sinkBlockedPossibility = sinkBlockedPossibility; - } - else { - throw invalidInput_error("possibility of the sink being blocked should be between 0 and 1"); - } - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - }; -} - - -bool SinkRandom::carCanEnter() -{ - return !(distFloat(engine) < data.sinkBlockedPossibility); -} - - -real SinkRandom::getPossibilityBeingBlocked() const -{ - return data.sinkBlockedPossibility; -} - - -uint SinkRandom::getIndex() const -{ - return data.sinkIndex; -} - diff --git a/src/gpu/Traffic/Sink/SinkRandom.h b/src/gpu/Traffic/Sink/SinkRandom.h deleted file mode 100644 index d6126acd1dc90b36ee1faed7f7d0ea3131f279c9..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Sink/SinkRandom.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - - -#include <random> - -#include "Sink.h" - -#include "Utilities/RandomHelper.h" - -#include "Traffic_export.h" - -class TRAFFIC_EXPORT SinkRandom: - public Sink -{ -private: - SinkData data; - - std::mt19937 engine = RandomHelper::make_engine(); - std::uniform_real_distribution<float> distFloat{ 0.0, 1.0 }; - -public: - SinkRandom(uint sinkIndex, real sinkBlockedPossibility); - ~SinkRandom() {}; - - real getPossibilityBeingBlocked() const; - bool carCanEnter(); - uint getIndex() const; -}; - diff --git a/src/gpu/Traffic/Source/Source.h b/src/gpu/Traffic/Source/Source.h deleted file mode 100644 index 3c786b7ee7e1e1a2c0ec38c5a42da293b927f9a1..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Source/Source.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - - -#include "SourceData.h" -#include "Traffic_export.h" - -class TRAFFIC_EXPORT Source -{ -public: - virtual uint getIndex() const = 0; - virtual real getPossibility() const = 0; - virtual uint getSourceCar() = 0; -}; - diff --git a/src/gpu/Traffic/Source/SourceData.h b/src/gpu/Traffic/Source/SourceData.h deleted file mode 100644 index e71ec4b5c91581f364a60074f60e1d574fe7d832..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Source/SourceData.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "Core/DataTypes.h" - -#include <memory> -#include <vector> -#include "Traffic_export.h" - - -struct TRAFFIC_EXPORT SourceData { - uint sourceIndex; - real sourcePossibility; - uint maxVelocity; -}; \ No newline at end of file diff --git a/src/gpu/Traffic/Source/SourceRandom.cpp b/src/gpu/Traffic/Source/SourceRandom.cpp deleted file mode 100644 index 7def2c237b81d5c014cab2bebbea1474dac69b36..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Source/SourceRandom.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "SourceRandom.h" - -#include <iostream> - -#include "Utilities/invalidInput_error.h" - -SourceRandom::SourceRandom(const uint sourceIndex, const real sourcePossibility, uint maxVelocity) -{ - data.sourceIndex = sourceIndex; - data.maxVelocity = maxVelocity; - - try { - if (sourcePossibility >= 0 && sourcePossibility <= 1) { - data.sourcePossibility = sourcePossibility; - std::uniform_int_distribution<uint> distInt2{ 0, maxVelocity }; - distInt = distInt2; - } - else { - throw invalidInput_error("possibility of a car leaving the sink should be between 0 and 1"); - } - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - }; -} - - - -SourceRandom::~SourceRandom() -{ -} - -uint SourceRandom::getIndex() const -{ - return data.sourceIndex; -} - -real SourceRandom::getPossibility() const -{ - return data.sourcePossibility; -} - - -uint SourceRandom::getSourceCar() -{ - randomNumber = distFloat(engine); - if (randomNumber < data.sourcePossibility) { - return randomSpeed(); - } - return -1; -} - - -uint SourceRandom::randomSpeed() -{ - return distInt(engine); -} diff --git a/src/gpu/Traffic/Source/SourceRandom.h b/src/gpu/Traffic/Source/SourceRandom.h deleted file mode 100644 index 5acf83fd788223c011717130d82c1867b5501757..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Source/SourceRandom.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - - -#include <random> - -#include "Source.h" -#include "Utilities/RandomHelper.h" - -#include "Traffic_export.h" - -class TRAFFIC_EXPORT SourceRandom: - public Source -{ -private: - SourceData data; - - std::mt19937 engine = RandomHelper::make_engine(); - std::uniform_real_distribution<float> distFloat{ 0.0, 1.0 }; - std::uniform_int_distribution<uint> distInt{ 0, 1 }; - -public: - SourceRandom(const uint sourceIndex, const real sourcePossibility, uint maxVelocity); - ~SourceRandom(); - - virtual uint getIndex() const; - virtual real getPossibility() const; - virtual uint getSourceCar(); - -private: - uint randomSpeed(); - -private: - //variables for temporaray calculations - real randomNumber; -}; - diff --git a/src/gpu/Traffic/TrafficMovement.cpp b/src/gpu/Traffic/TrafficMovement.cpp deleted file mode 100644 index fccf6f583ed0a87a8da0e87d67a62e5d0f531cf5..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/TrafficMovement.cpp +++ /dev/null @@ -1,575 +0,0 @@ -#include "TrafficMovement.h" - -#include <memory> -#include <iostream> -#include <stdexcept> - -#include "Utilities/invalidInput_error.h" -#include "Utilities/VectorHelper.h" -#include "Utilities/RandomHelper.h" -#include "Utilities/Logger.h" -#include "GPU/TrafficTimestep.h" - -#include "Output/ConcBySpeedAndAcceleration.h" -#include "Output/ConcentrationByPosition.h" - - -TrafficMovement::TrafficMovement(std::shared_ptr<RoadNetworkData> road, const real dawdlePossibility) -{ - this->road = std::move(road); - - this->road->pcurrent = &(this->road->current); - this->road->pnext = &(this->road->next); - - checkCurrentForSafetyDistance(); - - initDawdle(dawdlePossibility); - - //this->road->conc.resize(this->road->roadLength); //dispConcFromGPU -} - - -TrafficMovement::~TrafficMovement() -{ - gpuCalculation->cleanUp(); - road->pcurrent = NULL; - road->pnext = NULL; - road->pdummy = NULL; -} - - -void TrafficMovement::initDawdle(const real dawdlePossibility) -{ - try { - if (dawdlePossibility >= 0 && dawdlePossibility < 1) { - this->road->dawdlePossibility = dawdlePossibility; - } - else { - throw invalidInput_error("The dawdlePossibility should be between 0 and 1."); - } - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } -} - - -void TrafficMovement::setSlowToStart(const real slowStartPossibility) -{ - try { - if (slowStartPossibility >= 0 && slowStartPossibility < 1) { - if (slowStartPossibility > 0) { - this->road->slowStartPossibility = slowStartPossibility; - road->useSlowToStart = true; - } - } - else { - throw invalidInput_error("The slowStartPossibility should be between 0 and 1."); - } - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } -} - -void TrafficMovement::setUseGPU(real * pConcArray, int* naschVelocity) -{ - std::cout << "usingGPU for calculation" << std::endl; - this->useGPU = true; - this->gpuCalculation = std::make_unique<TrafficTimestep>(TrafficTimestep(this->road, pConcArray, naschVelocity)); -} - -void TrafficMovement::setMaxAcceleration(uint maxAcceleration) -{ - this->road->maxAcceleration = maxAcceleration; -} - -void TrafficMovement::setConcentrationOutwriter(uint roadlength, real* concArrayStart) -{ - this->concWriter = std::make_unique<ConcBySpeedAndAcceleration>(ConcBySpeedAndAcceleration(roadlength, concArrayStart)); -} - - -void TrafficMovement::setSaveResultsTrue(uint timeSteps) -{ - this->display = std::make_unique<CarDisplay>(&road->pcurrent, road->safetyDistance); - if (display != nullptr) display->initResults(timeSteps); -} - - -uint TrafficMovement::getNumberOfCars() const -{ - uint num = 0; - if (useGPU) num = gpuCalculation->getNumCarsOnJunctions(); - else - for (auto& junc : road->junctions) - num += junc->getNumCarsOnJunction(); - - for (auto cell : *(road->pcurrent)) - if (cell >= 0) ++num; - - return num; -} - - -int TrafficMovement::getSpeedAtPosition(uint pos) const -{ - return (*(road->pcurrent))[pos]; -} - - -uint TrafficMovement::getRoadLength() const -{ - return road->roadLength; -} - - -uint TrafficMovement::getMaxVelocity() const -{ - return road->maxVelocity; -} - - -real TrafficMovement::getDawdlePossibility() -{ - return road->dawdlePossibility; -} - -bool TrafficMovement::getUseSlowToStart() -{ - return road->useSlowToStart; -} - -real TrafficMovement::getSlowToStartPossibility() -{ - return road->slowStartPossibility; -} - -uint TrafficMovement::getMaxAcceleration() -{ - return road->maxAcceleration; -} - - - -void TrafficMovement::loopTroughTimesteps(uint timeSteps) -{ - for (uint step = 1; step < timeSteps + 1; step++) { - calculateTimestep(step); - } - dispResults(); -} - - -void TrafficMovement::calculateTimestep(uint step) -{ - - if (useGPU) { - - //GPU - - copiedDevToHost = false; - this->gpuCalculation->calculateTimestep(road); - - - } - else { - - //CPU - - if (concWriter != nullptr) concWriter->resetConcentrations(); - - VectorHelper::fillVector(*(road->pnext), -1); - - for (uint i = 0; i < road->roadLength; i++) - if ((*(road->pcurrent))[i] > -1) - applyRules(i); - - calculateJunctionStep(); - - calculateSourceStep(); - - switchCurrentNext(); - - } - - - if (display != nullptr) { - if (useGPU) copyDevToHost(); - display->putCurrentIntoResults(step); - } - - ////disp current road - //if (display != nullptr) { - // if (useGPU) copyDevToHost(); - // display->dispCurrentRoad(); - //} - - ////disp current conc - //if (useGPU) dispCurrentConcFromGPU(); - //else if (concWriter != nullptr) concWriter->dispCurrentConcentrations(); - - currentStep += 1; -} - - -void TrafficMovement::calculateSourceStep() -{ - uint sourceIndex; - uint gap; - for (auto &source : road->sources) { - sourceIndex = source->getIndex(); - gap = getGapAfterOutCell(sourceIndex, road->maxVelocity); - if (gap > 0) { - uint speed = source->getSourceCar(); - (*(road->pnext))[sourceIndex] = speed; - writeConcentration(sourceIndex, speed); - } - } -} - -void TrafficMovement::calculateJunctionStep() -{ - for (auto &junction : road->junctions) { - junction->calculateTimeStep(*this, currentStep); - } -} - -void TrafficMovement::switchCurrentNext() -{ - road->pdummy = road->pcurrent; - road->pcurrent = road->pnext; - road->pnext = road->pdummy; -} - -void TrafficMovement::applyRules(uint carIndex) -{ - uint speed = (*(road->pcurrent))[carIndex]; - accelerateCar(speed); - brakeCar(carIndex, speed); - dawdleCar(carIndex, speed); - moveCar(carIndex, speed); -} - -void TrafficMovement::accelerateCar(uint & speed) -{ - if (speed < road->maxVelocity) { - if (speed <= road->maxVelocity - road->maxAcceleration) - speed += road->maxAcceleration; - else - speed = road->maxVelocity; - } -} - -void TrafficMovement::brakeCar(uint carIndex, uint &speed) -{ - int neighbor = road->neighbors[carIndex]; - gap = getGapAfterCar(carIndex, speed, neighbor); - if (speed > gap) - speed = gap; -} - -void TrafficMovement::dawdleCar(uint carIndex, uint & speed) -{ - randomNumber = distFloat(engine); - - //Barlovic / SlowToStart - if (road->useSlowToStart == true && (*(road->pcurrent))[carIndex] == 0) { - if (randomNumber < road->slowStartPossibility) { - speed = 0; - } - return; - } - - //Standard NaSch - if (randomNumber < road->dawdlePossibility) { - if (speed >= road->maxAcceleration) - speed -= road->maxAcceleration; - else - speed = 0; - } -} - -void TrafficMovement::moveCar(const uint carIndex, uint speed) -{ - if (speed == 0) { - (*(road->pnext))[carIndex] = 0; - writeConcentration(carIndex, (*(road->pcurrent))[carIndex]); - return; - } - - int neighbor = road->neighbors[carIndex]; - uint currentCell = carIndex; - - uint numberOfCellsMoved = iterateNeighborsInMove(currentCell, speed, neighbor); - - if (neighbor <= -1000 && neighbor > -2000) { - getJunctionFromNeighbor(neighbor)->registerCar(currentCell, numberOfCellsMoved, speed, (*(road->pcurrent))[carIndex]); - return; - } - - if (neighbor >= 0) { - (*(road->pnext))[neighbor] = speed; - writeConcentration(neighbor, (*(road->pcurrent))[carIndex]); - } -} - - -void TrafficMovement::moveJunctionCar(uint outCellIndex, uint remainingDistance, uint speed, uint oldSpeed) -{ - if (remainingDistance == 1) { - (*(road->pnext))[outCellIndex] = speed; - writeConcentration(outCellIndex, oldSpeed); - return; - } - - int neighbor = outCellIndex; - - uint numberOfCellsMoved = iterateNeighborsInMove(outCellIndex, remainingDistance, neighbor); - - try { - if (neighbor <= -1000 && neighbor > -2000) { - throw std::runtime_error("car entered two junctions in one timestep"); - } - } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } - - if (neighbor >= 0) { - (*(road->pnext))[neighbor] = speed; - writeConcentration(neighbor, oldSpeed); - } -} - - -uint TrafficMovement::iterateNeighborsInMove(uint & currentCell, uint speed, int & neighbor) -{ - uint numberOfCellsMoved = 1; - - for (uint i = 2; i <= speed; i++) { - if (neighbor >= 0) { - currentCell = neighbor; - neighbor = road->neighbors[neighbor]; - ++numberOfCellsMoved; - } - else - break; - } - return numberOfCellsMoved; -} - - -std::shared_ptr<Junction>& TrafficMovement::getJunctionFromNeighbor(int neighbor) -{ - //calculate index in junctions vector for neighbor (-1000 to -1999) - return road->junctions[((neighbor + 1000)*-1)]; -} - - -std::shared_ptr<Sink>& TrafficMovement::getSinkFromNeighbor(int neighbor) -{ - //calculate index in junctions vector for neighbor (-2000 to -2999) - int index = ((neighbor + 2000)*-1); - return road->sinks[index]; -} - - -uint TrafficMovement::getGapAfterCar(uint carIndex, uint speed, int neighbor) -{ - for (uint i = 0; i < (speed + road->safetyDistance); i++) { - - if (neighbor <= -2000) - return getGapToSink(neighbor, i, speed); - if (neighbor <= -1000) - return getGapToJunction(neighbor, i, speed, carIndex); - - //car in Cell - if ((*(road->pcurrent))[neighbor] > -1) - return adjustGapToSafetyDist(i); - - //empty cell -> get next neighbor, update currentCell - carIndex = neighbor; - neighbor = road->neighbors[neighbor]; - } - return speed; -} - - -uint TrafficMovement::getGapAfterOutCell(uint outCellIndex, uint speed) -{ - if ((*(road->pcurrent))[outCellIndex] > -1) - return 0; - - int neighbor = outCellIndex; - - for (uint i = 0; i < (speed + road->safetyDistance); i++) { - - if (neighbor <= -2000) - return getGapToSink(neighbor, i, speed); - if (neighbor <= -1000) - return i; - - //car in Cell - if ((*(road->pcurrent))[neighbor] > -1) - return adjustGapToSafetyDist(i); - - //empty cell -> get next neighbor - neighbor = road->neighbors[neighbor]; - } - return speed; -} - - -uint TrafficMovement::getGapToSink(int neighbor, uint i, uint speed) -{ - if (getSinkFromNeighbor(neighbor)->carCanEnter() && i <= speed) - return speed; - return i; -} - - -uint TrafficMovement::getGapToJunction(int neighbor, uint i, uint speed, uint currentCell) -{ - if (getJunctionFromNeighbor(neighbor)->acceptsCar(currentCell) && i <= speed) - return speed; - return i; -} - - -uint TrafficMovement::adjustGapToSafetyDist(uint gap) -{ - if (gap <= road->safetyDistance) - return 0; - else - return gap - road->safetyDistance; -} - -void TrafficMovement::writeConcentration(uint index, uint oldSpeed) -{ - if (concWriter != nullptr) { - concWriter->calculateConcForSingleCar(index, oldSpeed, (*(road->pnext))[index]); - } -} - -void TrafficMovement::copyDevToHost() -{ - if (copiedDevToHost == false) { - gpuCalculation->copyCurrentDeviceToHost(road); - copiedDevToHost = true; - } -} - - -void TrafficMovement::writeConcentrationForJunction(uint inCellIndex, uint oldSpeed, uint speed) -{ - if (concWriter != nullptr) { - concWriter->calculateConcForJunctionCar(inCellIndex, oldSpeed, speed); - } -} - - -void TrafficMovement::dispResults() { - if (display == nullptr) - std::cout << "No results were saved." << std::endl; - else - display->dispResults(&road->neighbors, road->sinks, road->junctions, road->sources); -} - - -void TrafficMovement::dispCurrentConcFromGPU() -{ - //for (auto cell : road->conc) { - // if (cell > 0) - // SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12); - // else - // SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 8); - // std::cout << std::setw(4) << cell; - //} - //std::cout << std::endl; - //SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7); -} - - - -void TrafficMovement::checkCurrentForSafetyDistance() -{ - if (road->safetyDistance > 0) { - uint neighbor; - for (uint i = 0; i < road->roadLength; i++) { - if ((*(road->pcurrent))[i] > -1) { - neighbor = road->neighbors[i]; - - for (uint j = 1; j <= road->safetyDistance; j++) { - if (neighbor <= -1000) - break; - if ((*(road->pcurrent))[neighbor] > -1) { - std::cerr << "timestep 0: safetyDistance was violated: carIndex: " << i << std::endl; - if (useLogger) TrafficLogger::writeError("safetyDistance was violated : carIndex: " + std::to_string(i), 0); - break; - } - neighbor = road->neighbors[neighbor]; - } - } - } - } -} - - -const std::vector<int> & TrafficMovement::getVehiclesForVTK() -{ - return road->currentWithLongVehicles; -} - - -void TrafficMovement::visualizeVehicleLengthForVTK() -{ - if (useGPU) copyDevToHost(); - - road->currentWithLongVehicles = *(road->pcurrent); - int speed; - - if (road->safetyDistance != 0) { - for (uint i = 0; i < road->roadLength; i++) { - speed = (*(road->pcurrent))[i]; - if (speed > -1) { - //checkSpeed((*(road->pcurrent))[i]); - int neighbor = road->neighbors[i]; - for (uint j = 1; j <= road->safetyDistance; j++) { - - if (neighbor <= -1000) - break; - if ((*(road->pcurrent))[neighbor] > -1) { - std::cerr << "safetyDistance was violated: timestep: " << currentStep << "\t carIndex: " << i << std::endl; - if (useLogger) TrafficLogger::writeError("safetyDistance was violated : carIndex: " + std::to_string(i), currentStep); - break; - } - else - (road->currentWithLongVehicles)[neighbor] = speed; - neighbor = road->neighbors[neighbor]; - } - } - } - } -} - - -void TrafficMovement::checkSpeed(uint speed) -{ - if (speed > road->maxVelocity) { - std::cerr << "Speed is greater than allowed maxSpeed" << std::endl; - if (useLogger) TrafficLogger::writeError("Speed is greater than allowed maxSpeed", currentStep); - } -} - - -void TrafficMovement::setUseLogger() -{ - this->useLogger = true; -} \ No newline at end of file diff --git a/src/gpu/Traffic/TrafficMovement.h b/src/gpu/Traffic/TrafficMovement.h deleted file mode 100644 index 8655e8af0fb1e8aba747cac837ce88e17e3fe0b8..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/TrafficMovement.h +++ /dev/null @@ -1,125 +0,0 @@ -#pragma once - -#include <vector> -#include <random> -#include <memory> - - -#include "Core/DataTypes.h" - -#include "RoadNetwork/RoadNetworkData.h" -#include "Utilities/RandomHelper.h" - -#include "Output/ConcentrationOutwriter.h" -#include "Output/CarDisplay.h" - -#include "Traffic_export.h" - -class TrafficLogger; -//class ConcentrationOutwriter; -//class CarDisplay; -class TrafficTimestep; - -class TRAFFIC_EXPORT TrafficMovement -{ -public: - TrafficMovement(std::shared_ptr<RoadNetworkData> road, const real dawdlePossibility); - //TrafficMovement() {}; - TrafficMovement(const TrafficMovement&) = delete; - ~TrafficMovement(); - - //setUp - void setSlowToStart(const real slowStartPossibility); - void setMaxAcceleration(uint maxAcceleration); - void setConcentrationOutwriter(uint roadlength, real* concArrayStart = 0); - void setSaveResultsTrue(uint timeSteps); - void setUseGPU(real * pConcArray = nullptr, int* naschVelocity = nullptr); - void setUseLogger(); - - //timpestep - void loopTroughTimesteps(uint numberOfTimesteps); - void calculateTimestep(uint step); - - //get - uint getRoadLength() const; - uint getMaxVelocity() const; - uint getNumberOfCars() const; //only use for testing - int getSpeedAtPosition(uint pos) const; //only use for testing - real getDawdlePossibility(); - bool getUseSlowToStart(); - real getSlowToStartPossibility(); - uint getMaxAcceleration(); - - - //methods used by junctions and sources - uint getGapAfterOutCell(uint outCellIndex, uint speed); - void moveJunctionCar(uint outCellIndex, uint remainingDistance, uint speed, uint oldSpeed); - void writeConcentrationForJunction(uint inCellIndex, uint oldSpeed, uint speed); - - //vtk - void visualizeVehicleLengthForVTK(); - const std::vector<int> & getVehiclesForVTK(); - - //for debugging - void checkSpeed(uint speed); - -private: - //init - void initDawdle(const real dawdlePossibility); - void checkCurrentForSafetyDistance(); - - //calculate timestep - void calculateSourceStep(); - void calculateJunctionStep(); - void switchCurrentNext(); - - //gap - uint getGapAfterCar(uint carIndex, uint speed, int neighbor); - uint getGapToSink(int neighbor, uint i, uint speed); - uint getGapToJunction(int neighbor, uint i, uint speed, uint currentCell); - uint adjustGapToSafetyDist(uint gap); - - //getVectorIndex - std::shared_ptr<Junction>& getJunctionFromNeighbor(int neighbor); - std::shared_ptr<Sink>& getSinkFromNeighbor(int neighbor); - - //apply rules - void applyRules(uint carIndex); - void accelerateCar(uint &speed); - void brakeCar(uint carIndex, uint &speed); - void dawdleCar(uint carIndex, uint &speed); - void moveCar(const uint carIndex, uint speed); - uint iterateNeighborsInMove(uint ¤tCell, uint speed, int &neighbor); - - //disp - void dispResults(); - void dispCurrentConcFromGPU(); - - //pollution - void writeConcentration(uint index, uint oldSpeed); - - //gpu - void copyDevToHost(); - -private: - std::shared_ptr<RoadNetworkData> road; - std::unique_ptr<ConcentrationOutwriter> concWriter = nullptr; - std::unique_ptr<CarDisplay> display = nullptr; - - bool useGPU = false; - std::unique_ptr<TrafficTimestep> gpuCalculation; - bool copiedDevToHost = false; - - bool useLogger = false; - - uint currentStep = 0; - - std::mt19937 engine = RandomHelper::make_engine(); - std::uniform_real_distribution<real> distFloat{ 0.0, 1.0 }; - -private: - //temporary variables for calculation - uint gap; - float randomNumber; -}; - diff --git a/src/gpu/Traffic/TrafficMovementFactory - Kopie.cpp b/src/gpu/Traffic/TrafficMovementFactory - Kopie.cpp deleted file mode 100644 index 539d8cc37f46417be75a9b5b9ef2ce990d4a5c90..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/TrafficMovementFactory - Kopie.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "TrafficMovementFactory - Kopie.h" - -#include <iostream> - -#include "GridGenerator/StreetPointFinder/JunctionReader.h" -#include "GridGenerator/StreetPointFinder/SourceReader.h" -#include "GridGenerator/StreetPointFinder/SinkReader.h" - -#include "RoadNetwork/RoadMaker.h" -#include "TrafficMovement.h" -#include "Source/SourceRandom.h" -#include "Junction/JunctionRandom.h" -#include "Sink/SinkRandom.h" -#include "Output/ConcentrationByPosition.h" -#include "Output/ConcBySpeedAndAcceleration.h" -#include "Utilities/safe_casting.h" - - -void TrafficMovementFactoryTest::initTrafficMovement(bool useGPU, real * pConcArray) -{ - //Variables - - uint roadLength = 40; - - real vehicleDensity = 0.1f; - - uint vehicleLength = 2; - uint maxVelocity = 5; - uint maxAcceleration = 1; - - real dawdlePossibility = (real) 0.2; //typical value: 0.2 - real slowToStartPossibility = (real) 0.4; - - this->useGPU = true; - bool useSlowToStart = true; - - - //make RoadNetwork - std::vector<int> road(40); - std::fill(road.begin(), road.end(), -1); - road[9] = 5; - auto roadNetwork = std::make_shared<RoadMaker>(road, maxVelocity, vehicleLength); - //RoadMaker(const uint roadLength, const uint maxVelocity, uint vehicleLength, const real vehicleDensity); //random vehicle Distribution - //RoadMaker(const std::vector<int> vehicleDistribution, const uint maxVelocity, uint vehicleLength); //given vehicle distribution - //RoadMaker(const uint roadLength, const uint maxVelocity, uint vehicleLength);//empty road - - //Sources - std::shared_ptr<Source> source = std::make_shared <SourceRandom>(SourceRandom(0, 0.9f, maxVelocity)); - std::shared_ptr<Source> source1 = std::make_shared <SourceRandom>(SourceRandom(11, 0.9f, maxVelocity)); - roadNetwork->addSource(source); - roadNetwork->addSource(source1); - - //Sinks - std::shared_ptr<Sink> s = std::make_shared <SinkRandom>(SinkRandom(roadLength-1, 0.5f)); - std::shared_ptr<Sink> s1 = std::make_shared <SinkRandom>(SinkRandom(29, 0.5f)); - roadNetwork->addSink(s); - roadNetwork->addSink(s1); - - //Junctions - std::vector<uint> inCellIndices = { 9,19 }; - std::vector<uint> outCellIndices = { 21,31 }; - - std::shared_ptr<Junction> j = std::make_shared<JunctionRandom>(JunctionRandom(inCellIndices, outCellIndices,5)); - roadNetwork->addJunction(j); - - //init TrafficMovement - this->simulator = std::make_shared<TrafficMovement>(roadNetwork, dawdlePossibility); - if (useSlowToStart) simulator->setSlowToStart(slowToStartPossibility); - simulator->setMaxAcceleration(maxAcceleration); - if (this->useGPU) simulator->setUseGPU(pConcArray); - - //init ConcentrationOutwriter - if (!this->useGPU) {; - simulator->setConcentrationOutwriter(simulator->getRoadLength(), pConcArray); - } -} - - -void TrafficMovementFactoryTest::calculateTimestep(uint step, uint stepForVTK) -{ - simulator->calculateTimestep(step); - writeTimestep(step); -} - -void TrafficMovementFactoryTest::loopThroughTimesteps(uint timeSteps) -{ - simulator->setSaveResultsTrue(timeSteps); - simulator->loopTroughTimesteps(timeSteps); - //std::cout << "Number of Cars: " << simulator->getNumberOfCars() << std::endl; -} diff --git a/src/gpu/Traffic/TrafficMovementFactory - Kopie.h b/src/gpu/Traffic/TrafficMovementFactory - Kopie.h deleted file mode 100644 index ba27cf68e34dff215984835a097829240c349a2d..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/TrafficMovementFactory - Kopie.h +++ /dev/null @@ -1,23 +0,0 @@ -# pragma once - - -#include "Core/DataTypes.h" - -#include <vector> -#include <memory> - -#include "TrafficMovementFactory.h" -#include "GridGenerator/StreetPointFinder/StreetPointFinder.h" - -#include "Traffic_export.h" - - -class TRAFFIC_EXPORT TrafficMovementFactoryTest : - public TrafficMovementFactory { -public: - TrafficMovementFactoryTest() {}; - ~TrafficMovementFactoryTest() {}; - virtual void initTrafficMovement(bool useGPU, real * pConcArray = nullptr); - virtual void calculateTimestep(uint step, uint stepForVTK); - void loopThroughTimesteps(uint timeSteps); -}; \ No newline at end of file diff --git a/src/gpu/Traffic/TrafficMovementFactory.cpp b/src/gpu/Traffic/TrafficMovementFactory.cpp deleted file mode 100644 index 0e3f116a81d3e35d1d791bd2fe56b269cc26bb63..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/TrafficMovementFactory.cpp +++ /dev/null @@ -1,197 +0,0 @@ -#include "TrafficMovementFactory.h" - -#include <iostream> - -#include "GridGenerator/StreetPointFinder/JunctionReader.h" -#include "GridGenerator/StreetPointFinder/SourceReader.h" -#include "GridGenerator/StreetPointFinder/SinkReader.h" - -#include "RoadNetwork/RoadMaker.h" -#include "TrafficMovement.h" -#include "Source/SourceRandom.h" -#include "Junction/JunctionRandom.h" -#include "Sink/SinkRandom.h" -#include "Output/ConcentrationByPosition.h" -#include "Output/ConcBySpeedAndAcceleration.h" -#include "Utilities/safe_casting.h" -#include "Utilities/Logger.h" - - -TrafficMovementFactory::TrafficMovementFactory() -{ -} - - -void TrafficMovementFactory::initTrafficMovement(std::string path, bool useGPU, real * pConcArray, int* naschVelocity) -{ - //Variables - - real vehicleDensity = 0.03f; - - uint vehicleLength = 7; - uint maxVelocity = 14; - uint maxAcceleration = 2; - - real dawdlePossibility = (real) 0.2; //typical value: 0.2 - real slowToStartPossibility = (real) 0.3; - - this->useGPU = useGPU; - bool useSlowToStart = true; - useLogger = false; - - std::string info = "Only Traffic"; - - - - //Paths - -#ifdef _WIN32 - //Baumbart - inputPath = "C:/Users/schoen/Desktop/git/MS2/git/targets/apps/LBM/Basel/resources/"; - outputPath = path + "results/"; - //Gamling - //inputPath = path + "VirtualFluidsGPU/git/targets/apps/LBM/Basel/resources/"; - //outputPath = path + "Basel_Ergebnisse/"; -#else - //Phoenix - inputPath = "/work/marschoe/Basel4GPU/source/git/targets/apps/LBM/Basel/resources/"; - outputPath = path + "/traffic/"; -#endif - outputFilename = "Basel_Traffic_Test"; - std::string logfile = outputPath + "TrafficLog.txt"; - - - - //TrafficLogger - if (useLogger) { - TrafficLogger::startLogger(logfile); - TrafficLogger::writeSimulationStart(info, this->useGPU); - } - - - //StreetPointFinder M:/Basel2019 C:/Users/schoen/Desktop/git/MS2 - //finder.readStreets("C:/Users/schoen/Desktop/git/MS2/git/targets/apps/LBM/streetTest/resources/ExampleStreets.txt"); - //finder.writeVTK("M:/Basel2019/results/ExampleStreets.vtk"); - finder.readStreets(inputPath + "Streets.txt"); - finder.writeVTK(outputPath + outputFilename + ".vtk"); - finder.write3DVTK(outputPath + outputFilename + ".vtk"); - - - JunctionReader junctionReader; - //junctionReader.readJunctions("C:/Users/schoen/Desktop/git/MS2/git/targets/apps/LBM/Basel/resources/Junctions.txt", finder); - junctionReader.readJunctions(inputPath + "Junctions.txt", &finder); - - - SinkReader sinkReader; - //sinkReader.readSinks("C:/Users/schoen/Desktop/git/MS2/git/targets/apps/LBM/Basel/resources/Sinks.txt", finder); - sinkReader.readSinks(inputPath + "Sinks.txt", &finder); - - - SourceReader sourceReader; - //sourceReader.readSources("C:/Users/schoen/Desktop/git/MS2/git/targets/apps/LBM/Basel/resources/Sources.txt", finder); - sourceReader.readSources(inputPath + "Sources.txt", &finder); - - - //calculate RoadLength - uint roadLength = 0; - uint numberOfStreets = castSizeT_Uint(finder.streets.size()); - for (uint i = 0; i < numberOfStreets; i++) { - roadLength += finder.streets[i].numberOfCells; - } - - - //make RoadNetwork - auto roadNetwork = std::make_shared<RoadMaker>(roadLength, maxVelocity, vehicleLength, vehicleDensity); - - - //Sources - std::shared_ptr<Source> source; - for (uint i = 0; i < sourceReader.sources.size(); i++) { - source = std::make_shared <SourceRandom>(sourceReader.sources[i].sourceIndex, sourceReader.sources[i].sourcePossibility, roadNetwork->getMaxVelocity()); - roadNetwork->addSource(source); - } - - - //Sinks - std::shared_ptr<Sink> sink; - for (uint i = 0; i < sinkReader.sinks.size(); i++) { - sink = std::make_shared <SinkRandom>(sinkReader.sinks[i].sinkIndex, sinkReader.sinks[i].sinkBlockedPossibility); - roadNetwork->addSink(sink); - } - - - //Junctions - std::shared_ptr<Junction> junction; - for (uint i = 0; i < junctionReader.junctions.size(); i++) { - junction = std::make_shared <JunctionRandom>(junctionReader.junctions[i].inCells, junctionReader.junctions[i].outCells, junctionReader.junctions[i].trafficLightSwitchTime); - junction->setCellIndicesForNoUTurn(junctionReader.junctions[i].carCanNotEnterThisOutCell); - roadNetwork->addJunction(junction); - } - - - //set neighbors for curves - for (uint i = 0; i < junctionReader.specialNeighbors.cells.size(); i++) { - roadNetwork->setNeighborForCurve(junctionReader.specialNeighbors.cells[i], junctionReader.specialNeighbors.neighbors[i]); - } - - - //init TrafficMovement - this->simulator = std::make_shared<TrafficMovement>(roadNetwork, dawdlePossibility); - simulator->setMaxAcceleration(maxAcceleration); - if (useSlowToStart) simulator->setSlowToStart(slowToStartPossibility); - if (useLogger) simulator->setUseLogger(); - - - //init ConcentrationOutwriter - if (!this->useGPU) { - simulator->setConcentrationOutwriter(simulator->getRoadLength(), pConcArray); - } - - - //prepare writing to vtk - //this->outputPath = "M:/Basel2019/results/"; - this->cars = &(simulator->getVehiclesForVTK()); - - - //write initial Timestep - simulator->visualizeVehicleLengthForVTK(); - finder.writeVTK(outputPath + outputFilename + "_" + std::to_string(0) + ".vtk", *cars); - finder.write3DVTK(outputPath + outputFilename + "_3D_" + std::to_string(0) + ".vtk", *cars); - - - //GPU - if (this->useGPU) simulator->setUseGPU(pConcArray, naschVelocity); -} - - -void TrafficMovementFactory::calculateTimestep(uint step) -{ - simulator->calculateTimestep(step); - - //std::cout << "Number of Cars: " << simulator->getNumberOfCars() << std::endl; -} - -void TrafficMovementFactory::writeTimestep(uint stepForVTK) -{ - simulator->visualizeVehicleLengthForVTK(); - finder.writeVTK (outputPath + outputFilename + "_" + std::to_string(stepForVTK) + ".vtk", *cars); - finder.write3DVTK(outputPath + outputFilename + "_3D_" + std::to_string(stepForVTK) + ".vtk", *cars); -} - - -void TrafficMovementFactory::writeReducedTimestep(uint stepForVTK) -{ - simulator->visualizeVehicleLengthForVTK(); - finder.writeReducedVTK(outputPath + outputFilename + "_" + std::to_string(stepForVTK) + ".vtk", *cars); - finder.write3DVTK (outputPath + outputFilename + "_3D_" + std::to_string(stepForVTK) + ".vtk", *cars); -} - - -void TrafficMovementFactory::endSimulation(uint numTimesteps, double duration) -{ - if (!useLogger) return; - TrafficLogger::writeSimulationEnd(simulator->getRoadLength(), numTimesteps, duration); -} - - - diff --git a/src/gpu/Traffic/TrafficMovementFactory.h b/src/gpu/Traffic/TrafficMovementFactory.h deleted file mode 100644 index c934d276073afe9c6bec69786a48148470e69b61..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/TrafficMovementFactory.h +++ /dev/null @@ -1,38 +0,0 @@ -# pragma once - - -#include "Core/DataTypes.h" - -#include <vector> -#include <memory> - -#include "Traffic_export.h" - -#include "GridGenerator/StreetPointFinder/StreetPointFinder.h" - -class TrafficMovement; -class TrafficLogger; - -class TRAFFIC_EXPORT TrafficMovementFactory -{ -public: - TrafficMovementFactory(); - ~TrafficMovementFactory() {}; - virtual void initTrafficMovement(std::string path, bool useGPU, real * pConcArray = nullptr, int* naschVelocity = nullptr); - virtual void calculateTimestep(uint step); - virtual void writeTimestep(uint stepForVTK); - void writeReducedTimestep(uint stepForVTK); - virtual void endSimulation(uint numTimesteps, double duration); - -protected: - StreetPointFinder finder; - std::shared_ptr<TrafficMovement> simulator; - - std::string inputPath; - std::string outputPath; - std::string outputFilename; - const std::vector<int>* cars; - - bool useLogger; - bool useGPU; -}; \ No newline at end of file diff --git a/src/gpu/Traffic/TrafficMovementFactoryTestRoads.cpp b/src/gpu/Traffic/TrafficMovementFactoryTestRoads.cpp deleted file mode 100644 index 3439b4c803d7c64822ed4d1cda75ab4fb068e22a..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/TrafficMovementFactoryTestRoads.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "TrafficMovementFactory - Kopie.h" - -#include <iostream> - -#include "GridGenerator/StreetPointFinder/JunctionReader.h" -#include "GridGenerator/StreetPointFinder/SourceReader.h" -#include "GridGenerator/StreetPointFinder/SinkReader.h" - -#include "RoadNetwork/RoadMaker.h" -#include "TrafficMovement.h" -#include "Source/SourceRandom.h" -#include "Junction/JunctionRandom.h" -#include "Sink/SinkRandom.h" -#include "Output/ConcentrationByPosition.h" -#include "Output/ConcBySpeedAndAcceleration.h" -#include "Utilities/safe_casting.h" - - -void TrafficMovementFactoryTest::initTrafficMovement(real * pConcArray) -{ - //Variables - - uint roadLength = 40; - - real vehicleDensity = 0.1f; - - uint vehicleLength = 2; - uint maxVelocity = 5; - uint maxAcceleration = 1; - - real dawdlePossibility = (real) 0.2; //typical value: 0.2 - real slowToStartPossibility = (real) 0.4; - - bool useGPU = true; - bool useSlowToStart = true; - - - //make RoadNetwork - std::vector<int> road(40); - std::fill(road.begin(), road.end(), -1); - road[9] = 5; - auto roadNetwork = std::make_unique<RoadMaker>(road, maxVelocity, vehicleLength); - //RoadMaker(const uint roadLength, const uint maxVelocity, uint vehicleLength, const real vehicleDensity); //random vehicle Distribution - //RoadMaker(const std::vector<int> vehicleDistribution, const uint maxVelocity, uint vehicleLength); //given vehicle distribution - //RoadMaker(const uint roadLength, const uint maxVelocity, uint vehicleLength);//empty road - - //Sources - std::unique_ptr<Source> source = std::make_unique <SourceRandom>(SourceRandom(0, 0.9f, maxVelocity)); - std::unique_ptr<Source> source1 = std::make_unique <SourceRandom>(SourceRandom(11, 0.9f, maxVelocity)); - roadNetwork->addSource(source); - roadNetwork->addSource(source1); - - //Sinks - std::unique_ptr<Sink> s = std::make_unique <SinkRandom>(SinkRandom(roadLength-1, 0.5f)); - std::unique_ptr<Sink> s1 = std::make_unique <SinkRandom>(SinkRandom(29, 0.5f)); - roadNetwork->addSink(move(s)); - roadNetwork->addSink(move(s1)); - - //Junctions - std::vector<uint> inCellIndices = { 9,19 }; - std::vector<uint> outCellIndices = { 21,31 }; - - std::unique_ptr<Junction> j = std::make_unique<JunctionRandom>(JunctionRandom(inCellIndices, outCellIndices,5)); - roadNetwork->addJunction(std::move(j)); - - //init TrafficMovement - this->simulator = std::make_shared<TrafficMovement>(std::move(roadNetwork), dawdlePossibility); - if (useSlowToStart) simulator->setSlowToStart(slowToStartPossibility); - simulator->setMaxAcceleration(maxAcceleration); - if (useGPU) simulator->setUseGPU(pConcArray); - - //init ConcentrationOutwriter - if (!useGPU) { - std::unique_ptr<ConcentrationOutwriter> writer = std::make_unique<ConcBySpeedAndAcceleration>(ConcBySpeedAndAcceleration(simulator->getRoadLength(), pConcArray)); - simulator->setConcentrationOutwriter(move(writer)); - } -} - - -void TrafficMovementFactoryTest::calculateTimestep(uint step, uint stepForVTK) -{ - simulator->calculateTimestep(step); - writeTimestep(step); -} - -void TrafficMovementFactoryTest::loopThroughTimesteps(uint timeSteps) -{ - simulator->setSaveResultsTrue(timeSteps); - simulator->loopTroughTimesteps(timeSteps); - //std::cout << "Number of Cars: " << simulator->getNumberOfCars() << std::endl; -} diff --git a/src/gpu/Traffic/TrafficMovementFactoryTestRoads.h b/src/gpu/Traffic/TrafficMovementFactoryTestRoads.h deleted file mode 100644 index faafcf89f7911a0589369bca0dfb60ae431d6e03..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/TrafficMovementFactoryTestRoads.h +++ /dev/null @@ -1,23 +0,0 @@ -# pragma once - - - -#include <vector> -#include <memory> - -#include "TrafficMovementFactory.h" -#include "Core/DataTypes.h" -#include "GridGenerator/StreetPointFinder/StreetPointFinder.h" - -#include "Traffic_export.h" - - -class TRAFFIC_EXPORT TrafficMovementFactoryTest : - public TrafficMovementFactory { -public: - TrafficMovementFactoryTest() {}; - ~TrafficMovementFactoryTest() {}; - virtual void initTrafficMovement(real * pConcArray = nullptr); - virtual void calculateTimestep(uint step, uint stepForVTK); - void loopThroughTimesteps(uint timeSteps); -}; \ No newline at end of file diff --git a/src/gpu/Traffic/Utilities/ConsoleColor.cpp b/src/gpu/Traffic/Utilities/ConsoleColor.cpp deleted file mode 100644 index f015fe18fefa656c1495d285b5b928ebcfe26965..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Utilities/ConsoleColor.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "ConsoleColor.h" - - - - -#include "Core/DataTypes.h" - - -//// Windows ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifdef WIN32 - -#include <iostream> -#include <iomanip> //formatting output streams -#include <windows.h> //for colourful console output - - -void ConsoleColor::setDefaultWhite() -{ - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7); // set output default white 7; -} - - -void ConsoleColor::setDarkGrey() -{ - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 8); //set output dark grey 8, dark blue 1, black 0; -} - - -void ConsoleColor::setBrightRed() -{ - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12); //set output bright green 10, bright red 12; -} - - -void ConsoleColor::setBlack() -{ - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0); //set output dark grey 8, dark blue 1, black 0; -} - - -void ConsoleColor::setBrightGreen() -{ - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10); //set output bright green 10, bright red 12; -} - - -#endif WIN32 - - - - - -//// Linux ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef WIN32 - -void ConsoleColor::setDefaultWhite() -{} - -void ConsoleColor::setDarkGrey() -{} - -void ConsoleColor::setBrightRed() -{} - -void ConsoleColor::setBlack() -{} - -void ConsoleColor::setBrightGreen() -{} - -#endif // !WIN32 - - diff --git a/src/gpu/Traffic/Utilities/ConsoleColor.h b/src/gpu/Traffic/Utilities/ConsoleColor.h deleted file mode 100644 index 8b5234bde9f42ac8d3daf24887c81dab6558639f..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Utilities/ConsoleColor.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "Traffic_export.h" - -class TRAFFIC_EXPORT ConsoleColor -{ -public: - static void setDefaultWhite(); - static void setDarkGrey(); - static void setBrightRed(); - static void setBlack(); - static void setBrightGreen(); - -}; - diff --git a/src/gpu/Traffic/Utilities/Logger.cpp b/src/gpu/Traffic/Utilities/Logger.cpp deleted file mode 100644 index af060b90b6a9ff31d0fe3fe2be68b5db7509ece0..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Utilities/Logger.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "Logger.h" - -#include <stdexcept> -#include <iostream> -#include <time.h> -#include <cmath> - -TrafficLogger TrafficLogger::instance; - -void TrafficLogger::startLogger(std::string filename) -{ - instance.filename = filename; - - instance.file.open(filename.c_str(), std::ios::app); - try { if (instance.file.fail()) throw std::runtime_error("couldn't open file for logger: " + filename); } - catch (const std::exception& e) { - std::cerr << e.what() << std::endl; - std::cin.get(); - exit(EXIT_FAILURE); - } -} - - -void TrafficLogger::writeSimulationStart(std::string info, bool useGPU) -{ - time_t now = time(0); - - instance.file << "Simulation started at: " << ctime(&now); - instance.file << "Info: " << info << "\t \t" << "simulating on the "; - if (useGPU) instance.file << "GPU \t\t"; - else instance.file << "CPU \t\t"; - #ifdef NDEBUG - instance.file << "Release \n"; - #else - instance.file << "Debug \n"; - #endif -} - - -void TrafficLogger::writeError(std::string error, uint currentTimestep) -{ - instance.file << "Error: " << error << "\t timestep: " << currentTimestep << "\n"; -} - - -void TrafficLogger::writeSimulationEnd(uint numRoadCells, uint numTimesteps, double duration) -{ - uint hours = static_cast<uint>(std::floor(duration / 3600)); - uint minutes = static_cast<uint>(std::floor((duration - 3600 * hours) / 60)); - uint seconds = static_cast<uint>(duration - 3600 * hours - 60 * minutes); - - std::string durationString = std::to_string(hours) + " h \t" + std::to_string(minutes) + " m \t" + std::to_string(seconds) + " s"; - - instance.file << "Simulation finished: Number of roadcells : \t" << numRoadCells << "\t total number of timesteps: " << numTimesteps; - instance.file << "\t duration: " << duration << " s" << "\t\t => " << durationString << "\n\n"; - instance.file.close(); -} \ No newline at end of file diff --git a/src/gpu/Traffic/Utilities/Logger.h b/src/gpu/Traffic/Utilities/Logger.h deleted file mode 100644 index a10a567ac5f0e986fafab735e36019698feaf395..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Utilities/Logger.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - - -#include "Core/DataTypes.h" - -#include <string> -#include <fstream> - -#include "Traffic_export.h" - -class TRAFFIC_EXPORT TrafficLogger -{ -private: - std::string filename; - std::ofstream file; - static TrafficLogger instance; - -public: - TrafficLogger() {}; - TrafficLogger(const TrafficLogger& logger) {} - static void startLogger(std::string filename); - - static void writeSimulationStart(std::string info, bool useGPU); - static void writeError(std::string error, uint currentTimestep); - static void writeSimulationEnd(uint numRoadCells, uint numTimesteps, double duration); -}; - diff --git a/src/gpu/Traffic/Utilities/RandomHelper.cpp b/src/gpu/Traffic/Utilities/RandomHelper.cpp deleted file mode 100644 index 264dcd6eb9b5335914119a034f7e879b66126dd3..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Utilities/RandomHelper.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "RandomHelper.h" - - -std::mt19937 RandomHelper::make_engine() -{ - std::random_device r; - std::seed_seq seed{r()}; - return std::mt19937(seed); -} \ No newline at end of file diff --git a/src/gpu/Traffic/Utilities/RandomHelper.h b/src/gpu/Traffic/Utilities/RandomHelper.h deleted file mode 100644 index 869e93ed3e3e2b013a1c79090dc02ccaf6e23897..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Utilities/RandomHelper.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include <random> - -#include "Traffic_export.h" - -class TRAFFIC_EXPORT RandomHelper -{ -public: - static std::mt19937 make_engine(); -}; - diff --git a/src/gpu/Traffic/Utilities/VectorHelper.cpp b/src/gpu/Traffic/Utilities/VectorHelper.cpp deleted file mode 100644 index a239991aa8f81d17efdb113457fc87cb3589842d..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Utilities/VectorHelper.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "VectorHelper.h" - -#include <iostream> -#include <iomanip> //formatting output streams - -#include "ConsoleColor.h" - -void VectorHelper::fillVector(std::vector<int> &vector, int insertNumber) { - fill(vector.begin(), vector.end(), insertNumber); -} - -void VectorHelper::fillVector(std::vector<std::vector<int> > &vector, int insertNumber) { - for (uint i = 0; i < vector.size(); i++) { - fill(vector[i].begin(), vector[i].end(), insertNumber); - } -} - -void VectorHelper::dispVector(const std::vector<int> &vector) -{ - for (int number : vector) { - std::cout << std::setw(4) << number; - } - std::cout << std::endl; -} - -void VectorHelper::dispVector(const std::vector<std::vector<int> > &vector) -{ - for (uint i = 0; i < vector.size(); i++) { - for (uint j = 0; j < vector[i].size(); j++) { - std::cout << std::setw(4) << vector[i][j]; - } - std::cout << std::endl; - } - std::cout << std::endl; -} - -void VectorHelper::dispVectorColour(const std::vector<int> &vector) -{ - for (int number : vector) { - makeVectorOutputColourful(number); - std::cout << std::setw(4) << number; - } - std::cout << std::endl; - ConsoleColor::setDefaultWhite(); -} - -void VectorHelper::dispVectorColour(const std::vector<std::vector<int>>& vector) -{ - for (uint i = 0; i < vector.size(); i++) { - for (uint j = 0; j < vector[i].size(); j++) { - makeVectorOutputColourful(vector[i][j]); - std::cout << std::setw(4) << vector[i][j]; - } - std::cout << std::endl; - } - std::cout << std::endl; - ConsoleColor::setDefaultWhite(); -} - -void VectorHelper::makeVectorOutputColourful(int outputNumber) -{ - switch (outputNumber) { - case -1: - ConsoleColor::setDarkGrey(); - break; - case 0: - ConsoleColor::setBrightRed(); - break; - case -5: - ConsoleColor::setBlack(); - break; - default: - ConsoleColor::setBrightGreen(); - } - -} \ No newline at end of file diff --git a/src/gpu/Traffic/Utilities/VectorHelper.h b/src/gpu/Traffic/Utilities/VectorHelper.h deleted file mode 100644 index eccc2b385ea72b3804a5d5aacc03e239e571808c..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Utilities/VectorHelper.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include <vector> - - -#include "Core/DataTypes.h" - -#include "Traffic_export.h" - -class TRAFFIC_EXPORT VectorHelper -{ -public: - static void fillVector(std::vector<int>& vector, int insertNumber); - static void fillVector(std::vector<std::vector<int> > &vector, int insertNumber); - - static void dispVector(const std::vector<int> &vector); - static void dispVector(const std::vector<std::vector<int> >& vector); - static void dispVectorColour(const std::vector<int> &vector); - static void dispVectorColour(const std::vector<std::vector<int> >& vector); - static void makeVectorOutputColourful(const int outputNumber); -}; - diff --git a/src/gpu/Traffic/Utilities/invalidInput_error.cpp b/src/gpu/Traffic/Utilities/invalidInput_error.cpp deleted file mode 100644 index 9d72fd451fd080b176b3cf99ef6ffd251bfda9bb..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Utilities/invalidInput_error.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "invalidInput_error.h" - -#include <iostream> - - -invalidInput_error::invalidInput_error(char const * const message) throw() : runtime_error(message) -{ -} - -char const * invalidInput_error::what() const throw() -{ - return runtime_error::what(); -} - diff --git a/src/gpu/Traffic/Utilities/invalidInput_error.h b/src/gpu/Traffic/Utilities/invalidInput_error.h deleted file mode 100644 index d3ce3654588328d68f66f398f002f74125d1ea25..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Utilities/invalidInput_error.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - - -// using standard exceptions -#include <stdexcept> - -#include "Traffic_export.h" - -class TRAFFIC_EXPORT invalidInput_error : - public std::runtime_error -{ -public: - invalidInput_error(char const* const message) throw(); - virtual char const* what() const throw(); -}; - diff --git a/src/gpu/Traffic/Utilities/safe_casting.h b/src/gpu/Traffic/Utilities/safe_casting.h deleted file mode 100644 index ae8bcc2efba997ca5117ed79b0a7d814bf90f5b2..0000000000000000000000000000000000000000 --- a/src/gpu/Traffic/Utilities/safe_casting.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include <stdexcept> -#include "Core/DataTypes.h" -#include <climits> - - -static uint castSizeT_Uint(size_t number) { - if (number > UINT_MAX) - { - throw std::overflow_error("number is larger than UINT_MAX"); - } - return static_cast<uint>(number); -} - -static int castSizeT_Int(size_t number) { - if (number > INT_MAX) - { - throw std::overflow_error("number is larger than INT_MAX"); - } - return static_cast<uint>(number); -} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Calculation/CalcTurbulenceIntensity.cpp b/src/gpu/VirtualFluids_GPU/Calculation/CalcTurbulenceIntensity.cpp index 9572252965e1c619702370f8b9a3756bf035035e..681e4702b5f119c0f0c29273ee5d868a32fca0c7 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/CalcTurbulenceIntensity.cpp +++ b/src/gpu/VirtualFluids_GPU/Calculation/CalcTurbulenceIntensity.cpp @@ -8,7 +8,7 @@ #include "Calculation/CalcTurbulenceIntensity.h" #include <cuda_runtime.h> #include <helper_cuda.h> -#include <basics/Core/StringUtilities/StringUtil.h> +#include <basics/StringUtilities/StringUtil.h> void allocTurbulenceIntensity(Parameter *para, CudaMemoryManager *cudaMemoryManager) { diff --git a/src/gpu/VirtualFluids_GPU/Calculation/CollisisionStrategy.cpp b/src/gpu/VirtualFluids_GPU/Calculation/CollisisionStrategy.cpp index 49543f37df7fb54290f4ab6c09edb8d10c0b67be..334212f903e62608676a3473523182113a7a7723 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/CollisisionStrategy.cpp +++ b/src/gpu/VirtualFluids_GPU/Calculation/CollisisionStrategy.cpp @@ -1,7 +1,7 @@ #include "CollisionStrategy.h" #include "Parameter/CudaStreamManager.h" #include "Parameter/Parameter.h" -#include "logger/Logger.h" +#include <logger/Logger.h> std::function<void(UpdateGrid27 *updateGrid, Parameter *para, int level, unsigned int t)> getFunctionForCollisionAndExchange(const bool useStreams, const int numberOfMpiProcesses, diff --git a/src/gpu/VirtualFluids_GPU/Calculation/Cp.cpp b/src/gpu/VirtualFluids_GPU/Calculation/Cp.cpp index 9ee4cb917cdbf76dddf988b4456d5d611c9a11e0..3956bcbee4478e7c780559ef2dc74b2bd1fc79f7 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/Cp.cpp +++ b/src/gpu/VirtualFluids_GPU/Calculation/Cp.cpp @@ -7,7 +7,7 @@ #include <fstream> #include <sstream> -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" #include <cassert> //#include <math.h> @@ -230,16 +230,16 @@ void excludeGridInterfaceNodesForMirror(Parameter* para, int lev) //define bool vector for nodes outside the interface for (unsigned int it = 0; it < para->getParH(lev + 1)->numberOfPointsCpTop; it++) { - for (unsigned int ifit = 0; ifit < para->getParH((int)lev)->K_CF; ifit++) + for (unsigned int ifit = 0; ifit < para->getParH((int)lev)->coarseToFine.numberOfCells; ifit++) { - if ((para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH((int)lev)->intCF.ICellCFF[ifit]) || - (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborX[para->getParH((int)lev)->intCF.ICellCFF[ifit]]) || - (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborY[para->getParH((int)lev)->intCF.ICellCFF[ifit]]) || - (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborZ[para->getParH((int)lev)->intCF.ICellCFF[ifit]]) || - (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborY[para->getParH(lev + 1)->neighborX[para->getParH((int)lev)->intCF.ICellCFF[ifit]]]) || - (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborZ[para->getParH(lev + 1)->neighborX[para->getParH((int)lev)->intCF.ICellCFF[ifit]]]) || - (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborZ[para->getParH(lev + 1)->neighborY[para->getParH((int)lev)->intCF.ICellCFF[ifit]]]) || - (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborZ[para->getParH(lev + 1)->neighborY[para->getParH(lev + 1)->neighborX[para->getParH((int)lev)->intCF.ICellCFF[ifit]]]])) + if ((para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH((int)lev)->coarseToFine.fineCellIndices[ifit]) || + (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborX[para->getParH((int)lev)->coarseToFine.fineCellIndices[ifit]]) || + (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborY[para->getParH((int)lev)->coarseToFine.fineCellIndices[ifit]]) || + (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborZ[para->getParH((int)lev)->coarseToFine.fineCellIndices[ifit]]) || + (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborY[para->getParH(lev + 1)->neighborX[para->getParH((int)lev)->coarseToFine.fineCellIndices[ifit]]]) || + (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborZ[para->getParH(lev + 1)->neighborX[para->getParH((int)lev)->coarseToFine.fineCellIndices[ifit]]]) || + (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborZ[para->getParH(lev + 1)->neighborY[para->getParH((int)lev)->coarseToFine.fineCellIndices[ifit]]]) || + (para->getParH(lev + 1)->cpTopIndex[it] == (int)para->getParH(lev + 1)->neighborZ[para->getParH(lev + 1)->neighborY[para->getParH(lev + 1)->neighborX[para->getParH((int)lev)->coarseToFine.fineCellIndices[ifit]]]])) { para->getParH(lev + 1)->isOutsideInterface.push_back(false); tempBool = false; @@ -256,9 +256,9 @@ void excludeGridInterfaceNodesForMirror(Parameter* para, int lev) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// for (unsigned int it = 0; it < para->getParH((int)lev)->numberOfPointsCpTop; it++) { - for (unsigned int ifit = 0; ifit < para->getParH((int)lev)->K_FC; ifit++) + for (unsigned int ifit = 0; ifit < para->getParH((int)lev)->fineToCoarse.numberOfCells; ifit++) { - if (para->getParH((int)lev)->cpTopIndex[it] == (int)para->getParH((int)lev)->intFC.ICellFCC[ifit]) + if (para->getParH((int)lev)->cpTopIndex[it] == (int)para->getParH((int)lev)->fineToCoarse.coarseCellIndices[ifit]) { para->getParH((int)lev)->isOutsideInterface.push_back(false); tempBool = false; diff --git a/src/gpu/VirtualFluids_GPU/Calculation/DragLift.cpp b/src/gpu/VirtualFluids_GPU/Calculation/DragLift.cpp index 97d2af28ef7f801e817dd6cae6ad58d244249e02..2c2dc19795959c87a02705778a9768210580be41 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/DragLift.cpp +++ b/src/gpu/VirtualFluids_GPU/Calculation/DragLift.cpp @@ -7,7 +7,7 @@ #include <fstream> #include <sstream> -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" //#include <math.h> //#include "LB.h" diff --git a/src/gpu/VirtualFluids_GPU/Calculation/ForceCalculations.cpp b/src/gpu/VirtualFluids_GPU/Calculation/ForceCalculations.cpp index cc1d2eb748b01835b46f5fc69f47ed3ddc17a28d..f220c9a811486d14977ac9e55527c9e3e60c2478 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/ForceCalculations.cpp +++ b/src/gpu/VirtualFluids_GPU/Calculation/ForceCalculations.cpp @@ -9,7 +9,7 @@ #include <sstream> #include "GPU/CudaMemoryManager.h" -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" //using namespace std; ////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/Calculation/PlaneCalculations.cpp b/src/gpu/VirtualFluids_GPU/Calculation/PlaneCalculations.cpp index 13b6bd662a1b51a9a7a850211751c8b8b5ecf329..6557a2a0730c14cc1b26097c5025827128d3a1ce 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/PlaneCalculations.cpp +++ b/src/gpu/VirtualFluids_GPU/Calculation/PlaneCalculations.cpp @@ -9,7 +9,7 @@ #include <sstream> //using namespace std; ////////////////////////////////////////////////////////////////////////// -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" void setSizeOfPlane(Parameter* para, int lev, unsigned int z) { diff --git a/src/gpu/VirtualFluids_GPU/Calculation/RefinementStrategy.cpp b/src/gpu/VirtualFluids_GPU/Calculation/RefinementStrategy.cpp index b8ca4e9c2020e17cd0192267ac5d931b510afc3a..9428b07987f832ae0101196a8a430495fe27d508 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/RefinementStrategy.cpp +++ b/src/gpu/VirtualFluids_GPU/Calculation/RefinementStrategy.cpp @@ -1,7 +1,7 @@ #include "RefinementStrategy.h" #include "Parameter/CudaStreamManager.h" #include "Parameter/Parameter.h" -#include "logger/Logger.h" +#include <logger/Logger.h> std::function<void(UpdateGrid27 *updateGrid, Parameter *para, int level)> getFunctionForRefinementAndExchange(const bool useStreams, const int numberOfMpiProcesses, const int maxLevel, @@ -42,7 +42,7 @@ void RefinementAndExchange_streams_exchangeInterface::operator()(UpdateGrid27 *u //! //! 1. Interpolation fine to coarse for nodes which are at the border of the gpus/processes //! - updateGrid->fineToCoarse(level, ¶->getParD(level)->intFCBorder, para->getParD(level)->offFC, CudaStreamIndex::SubDomainBorder); + updateGrid->fineToCoarse(level, ¶->getParD(level)->fineToCoarseBorder, para->getParD(level)->neighborFineToCoarse, CudaStreamIndex::SubDomainBorder); //! 2. prepare the exchange between gpus (collect the send nodes for communication in a buffer on the gpu) and trigger bulk kernel execution when finished //! @@ -53,8 +53,8 @@ void RefinementAndExchange_streams_exchangeInterface::operator()(UpdateGrid27 *u //! 3. launch the bulk kernels for both interpolation processes (fine to coarse and coarse to fine) //! para->getStreamManager()->waitOnStartBulkKernelEvent(CudaStreamIndex::Bulk); - updateGrid->fineToCoarse(level, ¶->getParD(level)->intFCBulk, para->getParD(level)->offFCBulk, CudaStreamIndex::SubDomainBorder); - updateGrid->coarseToFine(level, ¶->getParD(level)->intCFBulk, para->getParD(level)->offCFBulk, CudaStreamIndex::SubDomainBorder); + updateGrid->fineToCoarse(level, ¶->getParD(level)->fineToCoarseBulk, para->getParD(level)->neighborFineToCoarseBulk, CudaStreamIndex::SubDomainBorder); + updateGrid->coarseToFine(level, ¶->getParD(level)->coarseToFineBulk, para->getParD(level)->neighborCoarseToFineBulk, CudaStreamIndex::SubDomainBorder); //! 4. exchange information between GPUs (only nodes which are part of the interpolation) //! @@ -62,7 +62,7 @@ void RefinementAndExchange_streams_exchangeInterface::operator()(UpdateGrid27 *u // 5. interpolation fine to coarse for nodes which are at the border of the gpus/processes //! - updateGrid->coarseToFine(level, ¶->getParD(level)->intCFBorder, para->getParD(level)->offCF, CudaStreamIndex::SubDomainBorder); + updateGrid->coarseToFine(level, ¶->getParD(level)->coarseToFineBorder, para->getParD(level)->neighborCoarseToFine, CudaStreamIndex::SubDomainBorder); cudaDeviceSynchronize(); } @@ -73,7 +73,7 @@ void RefinementAndExchange_streams_exchangeAllNodes::operator()(UpdateGrid27 *up //! //! 1. interpolation fine to coarse for nodes which are at the border of the gpus/processes //! - updateGrid->fineToCoarse(level, ¶->getParD(level)->intFCBorder, para->getParD(level)->offFC, CudaStreamIndex::SubDomainBorder); + updateGrid->fineToCoarse(level, ¶->getParD(level)->fineToCoarseBorder, para->getParD(level)->neighborFineToCoarse, CudaStreamIndex::SubDomainBorder); //! 2. prepare the exchange between gpus (collect the send nodes for communication in a buffer on the gpu) and trigger bulk kernel execution when finished //! @@ -84,8 +84,8 @@ void RefinementAndExchange_streams_exchangeAllNodes::operator()(UpdateGrid27 *up //! 3. launch the bulk kernels for both interpolation processes (fine to coarse and coarse to fine) //! para->getStreamManager()->waitOnStartBulkKernelEvent(CudaStreamIndex::Bulk); - updateGrid->fineToCoarse(level, ¶->getParD(level)->intFCBulk, para->getParD(level)->offFCBulk, CudaStreamIndex::SubDomainBorder); - updateGrid->coarseToFine(level, ¶->getParD(level)->intCFBulk, para->getParD(level)->offCFBulk, CudaStreamIndex::SubDomainBorder); + updateGrid->fineToCoarse(level, ¶->getParD(level)->fineToCoarseBulk, para->getParD(level)->neighborFineToCoarseBulk, CudaStreamIndex::SubDomainBorder); + updateGrid->coarseToFine(level, ¶->getParD(level)->coarseToFineBulk, para->getParD(level)->neighborCoarseToFineBulk, CudaStreamIndex::SubDomainBorder); //! 4. exchange information between GPUs (all nodes) //! @@ -93,7 +93,7 @@ void RefinementAndExchange_streams_exchangeAllNodes::operator()(UpdateGrid27 *up // 5. interpolation fine to coarse for nodes which are at the border of the gpus/processes //! - updateGrid->coarseToFine(level, ¶->getParD(level)->intCFBorder, para->getParD(level)->offCF, CudaStreamIndex::SubDomainBorder); + updateGrid->coarseToFine(level, ¶->getParD(level)->coarseToFineBorder, para->getParD(level)->neighborCoarseToFine, CudaStreamIndex::SubDomainBorder); cudaDeviceSynchronize(); } @@ -104,14 +104,14 @@ void RefinementAndExchange_noStreams_exchangeInterface::operator()(UpdateGrid27 //! //! 1. interpolation fine to coarse //! - updateGrid->fineToCoarse(level, ¶->getParD(level)->intFC, para->getParD(level)->offFC, CudaStreamIndex::Legacy); + updateGrid->fineToCoarse(level, ¶->getParD(level)->fineToCoarse, para->getParD(level)->neighborFineToCoarse, CudaStreamIndex::Legacy); //! 2. exchange information between GPUs (only nodes which are part of the interpolation) //! updateGrid->exchangeMultiGPU_noStreams_withPrepare(level, true); //! 3. interpolation coarse to fine - updateGrid->coarseToFine(level, ¶->getParD(level)->intCF, para->getParD(level)->offCF, CudaStreamIndex::Legacy); + updateGrid->coarseToFine(level, ¶->getParD(level)->coarseToFine, para->getParD(level)->neighborCoarseToFine, CudaStreamIndex::Legacy); } void RefinementAndExchange_noStreams_exchangeAllNodes::operator()(UpdateGrid27 *updateGrid, Parameter *para, int level) @@ -120,14 +120,14 @@ void RefinementAndExchange_noStreams_exchangeAllNodes::operator()(UpdateGrid27 * //! //! 1. interpolation fine to coarse //! - updateGrid->fineToCoarse(level, ¶->getParD(level)->intFC, para->getParD(level)->offFC, CudaStreamIndex::Legacy); + updateGrid->fineToCoarse(level, ¶->getParD(level)->fineToCoarse, para->getParD(level)->neighborFineToCoarse, CudaStreamIndex::Legacy); //! 2. exchange information between GPUs (all nodes) //! updateGrid->exchangeMultiGPU_noStreams_withPrepare(level, false); //! 3. interpolation coarse to fine - updateGrid->coarseToFine(level, ¶->getParD(level)->intCF, para->getParD(level)->offCF, CudaStreamIndex::Legacy); + updateGrid->coarseToFine(level, ¶->getParD(level)->coarseToFine, para->getParD(level)->neighborCoarseToFine, CudaStreamIndex::Legacy); } void Refinement_noExchange::operator()(UpdateGrid27 *updateGrid, Parameter *para, int level) @@ -136,7 +136,7 @@ void Refinement_noExchange::operator()(UpdateGrid27 *updateGrid, Parameter *para //! //! 1. interpolation fine to coarse //! - updateGrid->fineToCoarse(level, ¶->getParD(level)->intFC, para->getParD(level)->offFC, CudaStreamIndex::Legacy); + updateGrid->fineToCoarse(level, ¶->getParD(level)->fineToCoarse, para->getParD(level)->neighborFineToCoarse, CudaStreamIndex::Legacy); //! 2. interpolation coarse to fine - updateGrid->coarseToFine(level, ¶->getParD(level)->intCF, para->getParD(level)->offCF, CudaStreamIndex::Legacy); + updateGrid->coarseToFine(level, ¶->getParD(level)->coarseToFine, para->getParD(level)->neighborCoarseToFine, CudaStreamIndex::Legacy); } diff --git a/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp b/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp index 4136614dfbfc9e0d2fc1bf7f4b01624f94eabb6f..a2b1039afca4eaa3fcd75e28cae16cb5f68f6c9b 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp +++ b/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.cpp @@ -328,9 +328,9 @@ void UpdateGrid27::preCollisionBC(int level, unsigned int t) ////////////////////////////////////////////////////////////////////////////////// } -void UpdateGrid27::fineToCoarse(int level, InterpolationCellFC* icellFC, OffFC &offFC, CudaStreamIndex streamIndex) +void UpdateGrid27::fineToCoarse(int level, InterpolationCells* fineToCoarse, ICellNeigh &neighborFineToCoarse, CudaStreamIndex streamIndex) { - gridScalingKernelManager->runFineToCoarseKernelLB(level, icellFC, offFC, streamIndex); + gridScalingKernelManager->runFineToCoarseKernelLB(level, fineToCoarse, neighborFineToCoarse, streamIndex); if (para->getDiffOn()) { if (para->getStreamManager()->streamIsRegistered(streamIndex)) { @@ -341,9 +341,9 @@ void UpdateGrid27::fineToCoarse(int level, InterpolationCellFC* icellFC, OffFC & } } -void UpdateGrid27::coarseToFine(int level, InterpolationCellCF* icellCF, OffCF &offCF, CudaStreamIndex streamIndex) +void UpdateGrid27::coarseToFine(int level, InterpolationCells* coarseToFine, ICellNeigh &neighborCoarseToFine, CudaStreamIndex streamIndex) { - this->gridScalingKernelManager->runCoarseToFineKernelLB(level, icellCF, offCF, streamIndex); + this->gridScalingKernelManager->runCoarseToFineKernelLB(level, coarseToFine, neighborCoarseToFine, streamIndex); if (para->getDiffOn()) { diff --git a/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.h b/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.h index 8ce2cf5bfd72f9f53cdb35bc92502ee9ca0d3ad8..9c6ff48725f4e17121de0a1a8681d0bafcfb58ee 100644 --- a/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.h +++ b/src/gpu/VirtualFluids_GPU/Calculation/UpdateGrid27.h @@ -38,8 +38,8 @@ private: void preCollisionBC(int level, unsigned int t); void collisionPorousMedia(int level); - void fineToCoarse(int level, InterpolationCellFC* icellFC, OffFC &offFC, CudaStreamIndex streamIndex); - void coarseToFine(int level, InterpolationCellCF* icellCF, OffCF &offCF, CudaStreamIndex streamIndex); + void fineToCoarse(int level, InterpolationCells* fineToCoarse, ICellNeigh &neighborFineToCoarse, CudaStreamIndex streamIndex); + void coarseToFine(int level, InterpolationCells* coarseToFine, ICellNeigh &neighborCoarseToFine, CudaStreamIndex streamIndex); void prepareExchangeMultiGPU(int level, CudaStreamIndex streamIndex); void prepareExchangeMultiGPUAfterFtoC(int level, CudaStreamIndex streamIndex); diff --git a/src/gpu/VirtualFluids_GPU/Communication/CommunicationRoutine.h b/src/gpu/VirtualFluids_GPU/Communication/CommunicationRoutine.h index 39866728b713c9c0c72cb5c62ba02f242e0ca68c..26c017f939b0795457d74008a21cb9e7a4b75bd0 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/CommunicationRoutine.h +++ b/src/gpu/VirtualFluids_GPU/Communication/CommunicationRoutine.h @@ -1,7 +1,7 @@ #ifndef INDEX_EXCHANGE #define INDEX_EXCHANGE -#include <basics/Core/DataTypes.h> +#include <basics/DataTypes.h> namespace vf::gpu { diff --git a/src/gpu/VirtualFluids_GPU/Communication/Communicator.h b/src/gpu/VirtualFluids_GPU/Communication/Communicator.h index d7f57c5630270f87cd7df08492d8ff96585d7a50..716eb6c7c2c091cb79ce502504d634d53ea40937 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/Communicator.h +++ b/src/gpu/VirtualFluids_GPU/Communication/Communicator.h @@ -8,7 +8,7 @@ #include "VirtualFluids_GPU_export.h" #include "CommunicationRoutine.h" -#include <basics/Core/DataTypes.h> +#include <basics/DataTypes.h> ////////////////////////////////// #ifdef VF_DOUBLE_ACCURACY diff --git a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp index 00a7b45668e2050467f3d1122455dc74d0ad4f1c..48a27efa674e5fa85d47cb9439c52d0c558dac44 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp +++ b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp @@ -82,7 +82,7 @@ void copyEdgeNodes(std::vector<LBMSimulationParameter::EdgeNodePositions> &edgeN int numNodesInBufferSend = 0; #pragma omp parallel for - for (uint i = 0; i < edgeNodes.size(); i++) { + for (int i = 0; i < (int)edgeNodes.size(); i++) { indexInSubdomainRecv = edgeNodes[i].indexOfProcessNeighborRecv; indexInSubdomainSend = edgeNodes[i].indexOfProcessNeighborSend; numNodesInBufferRecv = recvProcessNeighborHost[indexInSubdomainRecv].numberOfNodes; @@ -777,7 +777,7 @@ void exchangePreCollDataADXGPU27(Parameter* para, vf::gpu::Communicator& comm, C //copy Device to Host for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - GetSendFsPreDev27(para->getParD(level)->distributionsAD27.f[0], + GetSendFsPreDev27(para->getParD(level)->distributionsAD.f[0], para->getParD(level)->sendProcessNeighborADX[i].f[0], para->getParD(level)->sendProcessNeighborADX[i].index, para->getParD(level)->sendProcessNeighborADX[i].numberOfNodes, @@ -838,7 +838,7 @@ void exchangePreCollDataADXGPU27(Parameter* para, vf::gpu::Communicator& comm, C { cudaMemoryManager->cudaCopyProcessNeighborADXFsHD(level, i); ////////////////////////////////////////////////////////////////////////// - SetRecvFsPreDev27(para->getParD(level)->distributionsAD27.f[0], + SetRecvFsPreDev27(para->getParD(level)->distributionsAD.f[0], para->getParD(level)->recvProcessNeighborADX[i].f[0], para->getParD(level)->recvProcessNeighborADX[i].index, para->getParD(level)->recvProcessNeighborADX[i].numberOfNodes, @@ -858,7 +858,7 @@ void exchangePostCollDataADXGPU27(Parameter* para, vf::gpu::Communicator& comm, //copy Device to Host for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsX(level, "send")); i++) { - GetSendFsPostDev27(para->getParD(level)->distributionsAD27.f[0], + GetSendFsPostDev27(para->getParD(level)->distributionsAD.f[0], para->getParD(level)->sendProcessNeighborADX[i].f[0], para->getParD(level)->sendProcessNeighborADX[i].index, para->getParD(level)->sendProcessNeighborADX[i].numberOfNodes, @@ -919,7 +919,7 @@ void exchangePostCollDataADXGPU27(Parameter* para, vf::gpu::Communicator& comm, { cudaMemoryManager->cudaCopyProcessNeighborADXFsHD(level, i); ////////////////////////////////////////////////////////////////////////// - SetRecvFsPostDev27(para->getParD(level)->distributionsAD27.f[0], + SetRecvFsPostDev27(para->getParD(level)->distributionsAD.f[0], para->getParD(level)->recvProcessNeighborADX[i].f[0], para->getParD(level)->recvProcessNeighborADX[i].index, para->getParD(level)->recvProcessNeighborADX[i].numberOfNodes, @@ -946,7 +946,7 @@ void exchangePreCollDataADYGPU27(Parameter* para, vf::gpu::Communicator& comm, C //copy Device to Host for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - GetSendFsPreDev27(para->getParD(level)->distributionsAD27.f[0], + GetSendFsPreDev27(para->getParD(level)->distributionsAD.f[0], para->getParD(level)->sendProcessNeighborADY[i].f[0], para->getParD(level)->sendProcessNeighborADY[i].index, para->getParD(level)->sendProcessNeighborADY[i].numberOfNodes, @@ -1007,7 +1007,7 @@ void exchangePreCollDataADYGPU27(Parameter* para, vf::gpu::Communicator& comm, C { cudaMemoryManager->cudaCopyProcessNeighborADYFsHD(level, i); ////////////////////////////////////////////////////////////////////////// - SetRecvFsPreDev27(para->getParD(level)->distributionsAD27.f[0], + SetRecvFsPreDev27(para->getParD(level)->distributionsAD.f[0], para->getParD(level)->recvProcessNeighborADY[i].f[0], para->getParD(level)->recvProcessNeighborADY[i].index, para->getParD(level)->recvProcessNeighborADY[i].numberOfNodes, @@ -1027,7 +1027,7 @@ void exchangePostCollDataADYGPU27(Parameter* para, vf::gpu::Communicator& comm, //copy Device to Host for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) { - GetSendFsPostDev27(para->getParD(level)->distributionsAD27.f[0], + GetSendFsPostDev27(para->getParD(level)->distributionsAD.f[0], para->getParD(level)->sendProcessNeighborADY[i].f[0], para->getParD(level)->sendProcessNeighborADY[i].index, para->getParD(level)->sendProcessNeighborADY[i].numberOfNodes, @@ -1088,7 +1088,7 @@ void exchangePostCollDataADYGPU27(Parameter* para, vf::gpu::Communicator& comm, { cudaMemoryManager->cudaCopyProcessNeighborADYFsHD(level, i); ////////////////////////////////////////////////////////////////////////// - SetRecvFsPostDev27(para->getParD(level)->distributionsAD27.f[0], + SetRecvFsPostDev27(para->getParD(level)->distributionsAD.f[0], para->getParD(level)->recvProcessNeighborADY[i].f[0], para->getParD(level)->recvProcessNeighborADY[i].index, para->getParD(level)->recvProcessNeighborADY[i].numberOfNodes, @@ -1115,7 +1115,7 @@ void exchangePreCollDataADZGPU27(Parameter* para, vf::gpu::Communicator& comm, C //copy Device to Host for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - GetSendFsPreDev27(para->getParD(level)->distributionsAD27.f[0], + GetSendFsPreDev27(para->getParD(level)->distributionsAD.f[0], para->getParD(level)->sendProcessNeighborADZ[i].f[0], para->getParD(level)->sendProcessNeighborADZ[i].index, para->getParD(level)->sendProcessNeighborADZ[i].numberOfNodes, @@ -1176,7 +1176,7 @@ void exchangePreCollDataADZGPU27(Parameter* para, vf::gpu::Communicator& comm, C { cudaMemoryManager->cudaCopyProcessNeighborADZFsHD(level, i); ////////////////////////////////////////////////////////////////////////// - SetRecvFsPreDev27(para->getParD(level)->distributionsAD27.f[0], + SetRecvFsPreDev27(para->getParD(level)->distributionsAD.f[0], para->getParD(level)->recvProcessNeighborADZ[i].f[0], para->getParD(level)->recvProcessNeighborADZ[i].index, para->getParD(level)->recvProcessNeighborADZ[i].numberOfNodes, @@ -1196,7 +1196,7 @@ void exchangePostCollDataADZGPU27(Parameter* para, vf::gpu::Communicator& comm, //copy Device to Host for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsZ(level, "send")); i++) { - GetSendFsPostDev27(para->getParD(level)->distributionsAD27.f[0], + GetSendFsPostDev27(para->getParD(level)->distributionsAD.f[0], para->getParD(level)->sendProcessNeighborADZ[i].f[0], para->getParD(level)->sendProcessNeighborADZ[i].index, para->getParD(level)->sendProcessNeighborADZ[i].numberOfNodes, @@ -1257,7 +1257,7 @@ void exchangePostCollDataADZGPU27(Parameter* para, vf::gpu::Communicator& comm, { cudaMemoryManager->cudaCopyProcessNeighborADZFsHD(level, i); ////////////////////////////////////////////////////////////////////////// - SetRecvFsPostDev27(para->getParD(level)->distributionsAD27.f[0], + SetRecvFsPostDev27(para->getParD(level)->distributionsAD.f[0], para->getParD(level)->recvProcessNeighborADZ[i].f[0], para->getParD(level)->recvProcessNeighborADZ[i].index, para->getParD(level)->recvProcessNeighborADZ[i].numberOfNodes, diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryValues.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryValues.cpp index e987e74be46c881da98fea35cfad6606395f0aca..9fbf2105b85424996ac67c8edbc42915b369a04e 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryValues.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryValues.cpp @@ -93,8 +93,6 @@ int BoundaryValues::getNumberOfColumns() return 0; if (boundaryCondition == "concentration") return 0; - if (boundaryCondition == "streetVector") - return 1; else return -1; } @@ -261,13 +259,3 @@ void BoundaryValues::setOutflowValues(real *RhoBC, int* kN, int level) const } } -void BoundaryValues::setStreetVelocityFractions(real *vxf, real *vyf, int level) const -{ - for (std::size_t column = 0; column < values[level].size(); column++) { - for (std::size_t index = 0; index < values[level][column].size(); index++) { - if (column == 0) vxf[index] = values[level][column][index]; - if (column == 1) vyf[index] = values[level][column][index]; - } - } -} - diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryValues.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryValues.h index 9adf0b08e308ea6e080fe7ce0d5410a35e2cdeb5..da3693d5c7e7fcf3c8879ec14464050359a44e28 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryValues.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/BoundaryValues.h @@ -42,7 +42,6 @@ public: void setPressValues(real *RhoBC, int* kN, int level) const; void setVelocityValues(real *vx, real *vy, real *vz, int level) const; void setOutflowValues(real *RhoBC, int* kN, int level) const; - void setStreetVelocityFractions(real *vxf, real *vyf, int level) const; private: void init(); diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.cpp index a1c8554cc4e262e9f1eca4204aed4ffcfd4c3a87..c126b2f79e02272a0bd86bfe0f76fe5efe09a5a7 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.cpp @@ -35,11 +35,6 @@ GridReader::GridReader(FILEFORMAT format, std::shared_ptr<Parameter> para, std:: channelDirections[5] = "bottom"; } -GridReader::~GridReader() -{ - -} - bool GridReader::getBinaer() { return binaer; @@ -58,7 +53,7 @@ void rearrangeGeometry(Parameter* para, int lev) void GridReader::allocArrays_CoordNeighborGeo() { - std::cout << "-----Config Arrays Coord, Neighbor, Geo------" << std::endl; + VF_LOG_TRACE("-----Config Arrays Coord, Neighbor, Geo------"); CoordNeighborGeoV coordX(para->getcoordX(), binaer, true); CoordNeighborGeoV coordY(para->getcoordY(), binaer, true); @@ -70,15 +65,15 @@ void GridReader::allocArrays_CoordNeighborGeo() CoordNeighborGeoV geoV(para->getgeoVec(), binaer, false); uint maxLevel = coordX.getLevel(); - std::cout << "Number of Level: " << maxLevel + 1 << std::endl; + VF_LOG_INFO("Number of Level: {}", maxLevel + 1); uint numberOfNodesGlobal = 0; - std::cout << "Number of Nodes: " << std::endl; + VF_LOG_INFO("Number of Nodes: "); for (uint level = 0; level <= maxLevel; level++) { const uint numberOfNodesPerLevel = coordX.getSize(level) + 1; numberOfNodesGlobal += numberOfNodesPerLevel; - std::cout << "Level " << level << " = " << numberOfNodesPerLevel << " Nodes" << std::endl; + VF_LOG_INFO("Level {} = {} Nodes", level, numberOfNodesPerLevel); setNumberOfNodes(numberOfNodesPerLevel, level); @@ -105,13 +100,14 @@ void GridReader::allocArrays_CoordNeighborGeo() cudaMemoryManager->cudaCopySP(level); cudaMemoryManager->cudaCopyCoord(level); } - std::cout << "Number of Nodes: " << numberOfNodesGlobal << std::endl; - std::cout << "-----finish Coord, Neighbor, Geo------" <<std::endl; + VF_LOG_INFO("Number of Nodes: {}", numberOfNodesGlobal); + VF_LOG_TRACE("-----finish Config Arrays Coord, Neighbor, Geo------"); } void GridReader::allocArrays_BoundaryValues() { - std::cout << "------read BoundaryValues------" <<std::endl; + VF_LOG_TRACE("------read BoundaryValues-------"); + this->makeReader(para); this->setChannelBoundaryCondition(); @@ -142,7 +138,7 @@ void GridReader::allocArrays_BoundaryValues() void GridReader::allocArrays_OffsetScale() { - std::cout << "-----Config Arrays OffsetScale------" << std::endl; + VF_LOG_TRACE("------Config Arrays OffsetScale-------"); OffsetScale *obj_offCF = new OffsetScale(para->getscaleOffsetCF(), true); OffsetScale *obj_offFC = new OffsetScale(para->getscaleOffsetFC(), true); OffsetScale *obj_scaleCFC = new OffsetScale(para->getscaleCFC(), false); @@ -157,33 +153,21 @@ void GridReader::allocArrays_OffsetScale() for (int i = 0; i<level; i++) { unsigned int tempCF = obj_offCF->getSize(i); - std::cout << "Groesse der Daten CF vom Level " << i << " : " << tempCF << std::endl; + VF_LOG_INFO("Size Data CF from Level {}: {}", i, tempCF); unsigned int tempFC = obj_offFC->getSize(i); - std::cout << "Groesse der Daten FC vom Level " << i << " : " << tempFC << std::endl; + VF_LOG_INFO("Size Data CF from Level {}: {}", i, tempFC); AnzahlKnotenGesCF += tempCF; AnzahlKnotenGesFC += tempFC; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //size + memsize CF - para->getParH(i)->K_CF = tempCF; - para->getParD(i)->K_CF = para->getParH(i)->K_CF; - para->getParH(i)->intCF.kCF = para->getParH(i)->K_CF; - para->getParD(i)->intCF.kCF = para->getParH(i)->K_CF; - para->getParH(i)->mem_size_kCF = sizeof(unsigned int)* para->getParH(i)->K_CF; - para->getParD(i)->mem_size_kCF = sizeof(unsigned int)* para->getParD(i)->K_CF; - para->getParH(i)->mem_size_kCF_off = sizeof(real)* para->getParH(i)->K_CF; - para->getParD(i)->mem_size_kCF_off = sizeof(real)* para->getParD(i)->K_CF; + //size CF + para->getParH(i)->coarseToFine.numberOfCells = tempCF; + para->getParD(i)->coarseToFine.numberOfCells = para->getParH(i)->coarseToFine.numberOfCells; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //size + memsize FC - para->getParH(i)->K_FC = tempFC; - para->getParD(i)->K_FC = para->getParH(i)->K_FC; - para->getParH(i)->intFC.kFC = para->getParH(i)->K_FC; - para->getParD(i)->intFC.kFC = para->getParH(i)->K_FC; - para->getParH(i)->mem_size_kFC = sizeof(unsigned int)* para->getParH(i)->K_FC; - para->getParD(i)->mem_size_kFC = sizeof(unsigned int)* para->getParD(i)->K_FC; - para->getParH(i)->mem_size_kFC_off = sizeof(real)* para->getParH(i)->K_FC; - para->getParD(i)->mem_size_kFC_off = sizeof(real)* para->getParD(i)->K_FC; + //size FC + para->getParH(i)->fineToCoarse.numberOfCells = tempFC; + para->getParD(i)->fineToCoarse.numberOfCells = para->getParH(i)->fineToCoarse.numberOfCells; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //alloc cudaMemoryManager->cudaAllocInterfaceCF(i); @@ -192,12 +176,12 @@ void GridReader::allocArrays_OffsetScale() cudaMemoryManager->cudaAllocInterfaceOffFC(i); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //init - obj_offCF->initArrayOffset(para->getParH(i)->offCF.xOffCF, para->getParH(i)->offCF.yOffCF, para->getParH(i)->offCF.zOffCF, i); - obj_offFC->initArrayOffset(para->getParH(i)->offFC.xOffFC, para->getParH(i)->offFC.yOffFC, para->getParH(i)->offFC.zOffFC, i); - obj_scaleCFC->initScale(para->getParH(i)->intCF.ICellCFC, i); - obj_scaleCFF->initScale(para->getParH(i)->intCF.ICellCFF, i); - obj_scaleFCC->initScale(para->getParH(i)->intFC.ICellFCC, i); - obj_scaleFCF->initScale(para->getParH(i)->intFC.ICellFCF, i); + obj_offCF->initArrayOffset(para->getParH(i)->neighborCoarseToFine.x, para->getParH(i)->neighborCoarseToFine.y, para->getParH(i)->neighborCoarseToFine.z, i); + obj_offFC->initArrayOffset(para->getParH(i)->neighborFineToCoarse.x, para->getParH(i)->neighborFineToCoarse.y, para->getParH(i)->neighborFineToCoarse.z, i); + obj_scaleCFC->initScale(para->getParH(i)->coarseToFine.coarseCellIndices, i); + obj_scaleCFF->initScale(para->getParH(i)->coarseToFine.fineCellIndices, i); + obj_scaleFCC->initScale(para->getParH(i)->fineToCoarse.coarseCellIndices, i); + obj_scaleFCF->initScale(para->getParH(i)->fineToCoarse.fineCellIndices, i); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy cudaMemoryManager->cudaCopyInterfaceCF(i); @@ -206,8 +190,8 @@ void GridReader::allocArrays_OffsetScale() cudaMemoryManager->cudaCopyInterfaceOffFC(i); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } - std::cout << "Gesamtanzahl Knoten CF = " << AnzahlKnotenGesCF << std::endl; - std::cout << "Gesamtanzahl Knoten FC = " << AnzahlKnotenGesFC << std::endl; + VF_LOG_INFO("Total number of Nodes CF = {}", AnzahlKnotenGesCF); + VF_LOG_INFO("Total number of Nodes FC = {}", AnzahlKnotenGesFC); delete obj_offCF; delete obj_offFC; @@ -215,21 +199,21 @@ void GridReader::allocArrays_OffsetScale() delete obj_scaleCFF; delete obj_scaleFCC; delete obj_scaleFCF; - std::cout << "-----Ende OffsetScale------" << std::endl; + VF_LOG_TRACE("Finish OffsetScale"); } void GridReader::allocArrays_taggedFluidNodes() { - std::cout << "GridReader::allocArrays_fluidNodeIndices not implemented" << std::endl; + VF_LOG_WARNING("GridReader::allocArrays_fluidNodeIndices not implemented"); // TODO } void GridReader::tagFluidNodeIndices(const std::vector<uint>& taggedFluidNodeIndices, CollisionTemplate tag, uint level){ - std::cout << "GridReader::tagFluidNodeIndices not implemented" << std::endl; + VF_LOG_WARNING("GridReader::tagFluidNodeIndices not implemented"); // TODO } void GridReader::sortFluidNodeTags(){ - std::cout << "GridReader::sortFluidNodeTags not implemented" << std::endl; + VF_LOG_WARNING("GridReader::sortFluidNodeTags not implemented"); // TODO } @@ -242,7 +226,7 @@ void GridReader::setPressureValues(int channelSide) const if (sizePerLevel > 0) { - std::cout << "size pressure level " << level << " : " << sizePerLevel << std::endl; + VF_LOG_INFO("size pressure level {}: {}", level, sizePerLevel); cudaMemoryManager->cudaAllocPress(level); @@ -273,7 +257,7 @@ void GridReader::fillVelocityVectors(int channelSide) real *veloY_ValuesPerSide = new real[sizePerLevel]; real *veloZ_ValuesPerSide = new real[sizePerLevel]; - std::cout << "size velocity level " << level << " : " << sizePerLevel << std::endl; + VF_LOG_INFO("size velocity level {}: {}", level, sizePerLevel); BC_Values[channelSide]->setVelocityValues(veloX_ValuesPerSide, veloY_ValuesPerSide, veloZ_ValuesPerSide, level); for (int i = 0; i < sizePerLevel; i++) { @@ -295,7 +279,7 @@ void GridReader::setVelocityValues() { for (int level = 0; level < (int)(velocityX_BCvalues.size()); level++) { int sizePerLevel = (int) velocityX_BCvalues[level].size(); - std::cout << "complete size velocity level " << level << " : " << sizePerLevel << std::endl; + VF_LOG_INFO("Complete size velocity level {}: {}", level, sizePerLevel); setVelocitySizePerLevel(level, sizePerLevel); if (sizePerLevel > 1) { @@ -326,7 +310,7 @@ void GridReader::setOutflowValues(int channelSide) const if (sizePerLevel > 1) { - std::cout << "size outflow level " << level << " : " << sizePerLevel << std::endl; + VF_LOG_INFO("size outflow level {}: {}", level, sizePerLevel); cudaMemoryManager->cudaAllocOutflowBC(level); @@ -402,7 +386,7 @@ void GridReader::initalValuesDomainDecompostion(int level) { //////////////////////////////////////////////////////////////////////////////////////// //send - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for X send buffer, Level " << i << " : " << tempSend << "\n"; + VF_LOG_INFO("size of Data for X send buffer, Level {} : {}", i, tempSend); //////////////////////////////////////////////////////////////////////////////////////// para->setNumberOfProcessNeighborsX((unsigned int)procNeighborsSendX.size(), i, "send"); para->getParH(i)->sendProcessNeighborX[j].rankNeighbor = neighborRankX[j]; @@ -560,7 +544,7 @@ void GridReader::initalValuesDomainDecompostion(int level) void GridReader::allocArrays_BoundaryQs() { - std::cout << "------read BoundaryQs-------" <<std::endl; + VF_LOG_TRACE("------read BoundaryQs-------"); std::vector<std::shared_ptr<BoundaryQs> > BC_Qs(channelDirections.size()); this->makeReader(BC_Qs, para); @@ -584,7 +568,7 @@ void GridReader::allocArrays_BoundaryQs() if (para->getIsGeo()) setGeoQs(obj_geomQ); - std::cout << "-----finish BoundaryQs------" <<std::endl; + VF_LOG_TRACE("------finish BoundaryQs-------"); } @@ -924,6 +908,6 @@ void GridReader::setChannelBoundaryCondition() for (std::size_t i = 0; i < channelDirections.size(); i++) { this->channelBoundaryConditions[i] = BC_Values[i]->getBoundaryCondition(); - std::cout << this->channelDirections[i] << " Boundary: " << channelBoundaryConditions[i] << std::endl; + VF_LOG_INFO("{} Boundary: {}", this->channelDirections[i], channelBoundaryConditions[i]); } } diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h index 041d2c3ce94592f792c5a850eebd14c07f4db1b4..d244e76569fe213978086ab412725e4450da66e4 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h @@ -35,7 +35,7 @@ private: public: GridReader(FILEFORMAT format, std::shared_ptr<Parameter> para, std::shared_ptr<CudaMemoryManager> cudaMemoryManager); - ~GridReader() override; + ~GridReader() {}; void allocArrays_CoordNeighborGeo() override; void allocArrays_BoundaryValues() override; void allocArrays_OffsetScale() override; diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp index c2f86721de26d516ed60f497a65d1d46a34aa182..789db6d192cfffe5630eb093ad108df57b6870f4 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.cpp @@ -31,7 +31,7 @@ GridGenerator::GridGenerator(std::shared_ptr<GridBuilder> builder, std::shared_p std::make_unique<InterpolationCellGrouper>(para->getParHallLevels(), para->getParDallLevels(), builder); } -GridGenerator::~GridGenerator() = default; +GridGenerator::~GridGenerator() {} void GridGenerator::setIndexRearrangementForStreams(std::unique_ptr<IndexRearrangementForStreams> &&indexRearrangement) { @@ -58,15 +58,15 @@ void GridGenerator::initalGridInformations() void GridGenerator::allocArrays_CoordNeighborGeo() { const uint numberOfLevels = builder->getNumberOfGridLevels(); - std::cout << "Number of Level: " << numberOfLevels << std::endl; + VF_LOG_INFO("Number of Level: {}", numberOfLevels); int numberOfNodesGlobal = 0; - std::cout << "Number of Nodes: " << std::endl; + VF_LOG_INFO("Number of Nodes: "); for (uint level = 0; level < numberOfLevels; level++) { const uint numberOfNodesPerLevel = builder->getNumberOfNodes(level) + 1; numberOfNodesGlobal += numberOfNodesPerLevel; - std::cout << "Level " << level << " = " << numberOfNodesPerLevel << " Nodes" << std::endl; + VF_LOG_INFO("Level {} = {} Nodes", level, numberOfNodesPerLevel); setNumberOfNodes(numberOfNodesPerLevel, level); @@ -99,11 +99,9 @@ void GridGenerator::allocArrays_CoordNeighborGeo() cudaMemoryManager->cudaCopyCoord(level); if(para->getIsBodyForce()) cudaMemoryManager->cudaCopyBodyForce(level); - - //std::cout << verifyNeighborIndices(level); } - std::cout << "Number of Nodes: " << numberOfNodesGlobal << std::endl; - std::cout << "-----finish Coord, Neighbor, Geo------" << std::endl; + VF_LOG_INFO("Number of Nodes: {}", numberOfNodesGlobal); + VF_LOG_TRACE("-----finish Coord, Neighbor, Geo------"); } void GridGenerator::allocArrays_taggedFluidNodes() { @@ -202,12 +200,12 @@ void GridGenerator::sortFluidNodeTags() { void GridGenerator::allocArrays_BoundaryValues() { - std::cout << "------read BoundaryValues------" << std::endl; + VF_LOG_TRACE("-----alloc BoundaryValues------"); int blocks; for (uint level = 0; level < builder->getNumberOfGridLevels(); level++) { const auto numberOfPressureValues = int(builder->getPressureSize(level)); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size pressure level " << level << " : " << numberOfPressureValues << "\n"; + VF_LOG_INFO("size pressure level {}: {}", level, numberOfPressureValues); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->pressureBC.numberOfBCnodes = 0; @@ -227,7 +225,7 @@ void GridGenerator::allocArrays_BoundaryValues() for (uint level = 0; level < builder->getNumberOfGridLevels(); level++) { const auto numberOfSlipValues = int(builder->getSlipSize(level)); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size slip level " << level << " : " << numberOfSlipValues << "\n"; + VF_LOG_INFO("size slip level {}: {}", level, numberOfSlipValues); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->slipBC.numberOfBCnodes = 0; @@ -246,7 +244,7 @@ void GridGenerator::allocArrays_BoundaryValues() for (uint level = 0; level < builder->getNumberOfGridLevels(); level++) { const auto numberOfStressValues = int(builder->getStressSize(level)); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size stress level " << level << " : " << numberOfStressValues << "\n"; + VF_LOG_INFO("size stress level {}: {}", level, numberOfStressValues); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->stressBC.numberOfBCnodes = 0; @@ -274,7 +272,7 @@ void GridGenerator::allocArrays_BoundaryValues() for (uint level = 0; level < builder->getNumberOfGridLevels(); level++) { const auto numberOfVelocityValues = int(builder->getVelocitySize(level)); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size velocity level " << level << " : " << numberOfVelocityValues << "\n"; + VF_LOG_INFO("size velocity level {}: {}", level, numberOfVelocityValues); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->velocityBC.numberOfBCnodes = 0; @@ -300,8 +298,8 @@ void GridGenerator::allocArrays_BoundaryValues() ////////////////////////////////////////////////////////////////////////// para->getParH(level)->TempVel.kTemp = para->getParH(level)->velocityBC.numberOfBCnodes; //cout << "Groesse kTemp = " << para->getParH(i)->TempPress.kTemp << endl; - std::cout << "getTemperatureInit = " << para->getTemperatureInit() << std::endl; - std::cout << "getTemperatureBC = " << para->getTemperatureBC() << std::endl; + VF_LOG_INFO("getTemperatureInit = {}", para->getTemperatureInit()); + VF_LOG_INFO("getTemperatureBC = {}", para->getTemperatureBC()); ////////////////////////////////////////////////////////////////////////// cudaMemoryManager->cudaAllocTempVeloBC(level); //cout << "nach alloc " << endl; @@ -328,7 +326,7 @@ void GridGenerator::allocArrays_BoundaryValues() for (uint level = 0; level < builder->getNumberOfGridLevels(); level++) { const auto numberOfPrecursorValues = int(builder->getPrecursorSize(level)); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size precursor level " << level << " : " << numberOfPrecursorValues << "\n"; + VF_LOG_INFO("size precursor level {}: {}", level, numberOfPrecursorValues); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// blocks = (numberOfPrecursorValues / para->getParH(level)->numberofthreads) + 1; para->getParH(level)->precursorBC.sizeQ = blocks * para->getParH(level)->numberofthreads; @@ -426,7 +424,7 @@ void GridGenerator::allocArrays_BoundaryValues() para->setUseGeometryValues(true); for (uint level = 0; level < builder->getNumberOfGridLevels(); level++) { int numberOfGeometryValues = builder->getGeometrySize(level); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size geometry values, Level " << level << " : " << numberOfGeometryValues << "\n"; + VF_LOG_INFO("size geometry values, Level {} : {}", level, numberOfGeometryValues); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->geometryBC.numberOfBCnodes = 0; @@ -521,8 +519,7 @@ void GridGenerator::initalValuesDomainDecompostion() para->getParH(level)->sendProcessNeighborX.back().rankNeighbor = builder->getCommunicationProcess(direction); //////////////////////////////////////////////////////////////////////////////////////// - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for X send buffer, \t\tLevel " << level << " : " << tempSend - << " \t(neighbor rank: " << builder->getCommunicationProcess(direction) << ")\n"; + VF_LOG_INFO("size of Data for X send buffer, \t\tLevel {}: {} \t(neighbor rank: {})", level, tempSend, builder->getCommunicationProcess(direction)); //////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->sendProcessNeighborX.back().numberOfNodes = tempSend; para->getParD(level)->sendProcessNeighborX.back().numberOfNodes = tempSend; @@ -536,8 +533,7 @@ void GridGenerator::initalValuesDomainDecompostion() para->getParD(level)->sendProcessNeighborX.back().memsizeFs = sizeof(real) * tempSend; //////////////////////////////////////////////////////////////////////////////////////// // recv - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for X receive buffer, \tLevel " << level << " : " << tempRecv - << " \t(neighbor rank: " << builder->getCommunicationProcess(direction) << ")\n"; + VF_LOG_INFO("size of Data for X receive buffer, \t\tLevel {}: {} \t(neighbor rank: {})", level, tempRecv, builder->getCommunicationProcess(direction)); //////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->recvProcessNeighborX.back().rankNeighbor = builder->getCommunicationProcess(direction); @@ -587,8 +583,7 @@ void GridGenerator::initalValuesDomainDecompostion() } //////////////////////////////////////////////////////////////////////////////////////// // send - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for Y send buffer, \t\tLevel " << level << " : " << tempSend - << " \t(neighbor rank: " << builder->getCommunicationProcess(direction) << ")\n"; + VF_LOG_INFO("size of Data for Y send buffer, \t\tLevel {}: {} \t(neighbor rank: {})", level, tempSend, builder->getCommunicationProcess(direction)); //////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->sendProcessNeighborY.back().rankNeighbor = builder->getCommunicationProcess(direction); @@ -605,8 +600,7 @@ void GridGenerator::initalValuesDomainDecompostion() para->getParD(level)->sendProcessNeighborY.back().memsizeFs = sizeof(real) * tempSend; //////////////////////////////////////////////////////////////////////////////////////// // recv - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for Y receive buffer, \tLevel " << level << " : " << tempRecv - << " \t(neighbor rank: " << builder->getCommunicationProcess(direction) << ")\n"; + VF_LOG_INFO("size of Data for Y receive buffer, \t\tLevel {}: {} \t(neighbor rank: {})", level, tempRecv, builder->getCommunicationProcess(direction)); //////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->recvProcessNeighborY.back().rankNeighbor = builder->getCommunicationProcess(direction); @@ -656,8 +650,7 @@ void GridGenerator::initalValuesDomainDecompostion() } //////////////////////////////////////////////////////////////////////////////////////// // send - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for Z send buffer, \t\tLevel " << level << " : " << tempSend - << " \t(neighbor rank: " << builder->getCommunicationProcess(direction) << ")\n"; + VF_LOG_INFO("size of Data for Z send buffer, \t\tLevel {}: {} \t(neighbor rank: {})", level, tempSend, builder->getCommunicationProcess(direction)); //////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->sendProcessNeighborZ.back().rankNeighbor = builder->getCommunicationProcess(direction); @@ -674,8 +667,7 @@ void GridGenerator::initalValuesDomainDecompostion() para->getParD(level)->sendProcessNeighborZ.back().memsizeFs = sizeof(real) * tempSend; //////////////////////////////////////////////////////////////////////////////////////// // recv - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for Z receive buffer, \tLevel " << level << " : " << tempRecv - << " \t(neighbor rank: " << builder->getCommunicationProcess(direction) << ")\n"; + VF_LOG_INFO("size of Data for Z receive buffer, \t\tLevel {}: {} \t(neighbor rank: {})", level, tempRecv, builder->getCommunicationProcess(direction)); //////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->recvProcessNeighborZ.back().rankNeighbor = builder->getCommunicationProcess(direction); @@ -729,8 +721,7 @@ void GridGenerator::initalValuesDomainDecompostion() if (tempSend > 0) { //////////////////////////////////////////////////////////////////////////////////////// // send - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for X send buffer, \t\tLevel " << level << " : " << tempSend - << " \t(neighbor rank: " << builder->getCommunicationProcess(direction) << ")\n"; + VF_LOG_INFO("size of Data for X send buffer, \t\tLevel {}: {} \t(neighbor rank: {})", level, tempSend, builder->getCommunicationProcess(direction)); //////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->sendProcessNeighborF3X.back().rankNeighbor = builder->getCommunicationProcess(direction); @@ -749,8 +740,7 @@ void GridGenerator::initalValuesDomainDecompostion() sizeof(real) * para->getParH(level)->sendProcessNeighborF3X.back().numberOfGs; //////////////////////////////////////////////////////////////////////////////////////// // recv - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for X receive buffer, \tLevel " << level << " : " << tempRecv - << " \t(neighbor rank: " << builder->getCommunicationProcess(direction) << ")\n"; + VF_LOG_INFO("size of Data for X recv buffer, \t\tLevel {}: {} \t(neighbor rank: {})", level, tempRecv, builder->getCommunicationProcess(direction)); //////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->recvProcessNeighborF3X.back().rankNeighbor = builder->getCommunicationProcess(direction); @@ -795,8 +785,7 @@ void GridGenerator::initalValuesDomainDecompostion() if (tempSend > 0) { //////////////////////////////////////////////////////////////////////////////////////// // send - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for Y send buffer, \t\tLevel " << level << " : " << tempSend - << " \t(neighbor rank: " << builder->getCommunicationProcess(direction) << ")\n"; + VF_LOG_INFO("size of Data for Y send buffer, \t\tLevel {}: {} \t(neighbor rank: {})", level, tempSend, builder->getCommunicationProcess(direction)); //////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->sendProcessNeighborF3Y.back().rankNeighbor = builder->getCommunicationProcess(direction); @@ -815,8 +804,7 @@ void GridGenerator::initalValuesDomainDecompostion() sizeof(real) * para->getParH(level)->sendProcessNeighborF3Y.back().numberOfGs; //////////////////////////////////////////////////////////////////////////////////////// // recv - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for Y receive buffer, \tLevel " << level << " : " << tempRecv - << " \t(neighbor rank: " << builder->getCommunicationProcess(direction) << ")\n"; + VF_LOG_INFO("size of Data for Y recv buffer, \t\tLevel {}: {} \t(neighbor rank: {})", level, tempRecv, builder->getCommunicationProcess(direction)); //////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->recvProcessNeighborF3Y.back().rankNeighbor = builder->getCommunicationProcess(direction); @@ -861,8 +849,7 @@ void GridGenerator::initalValuesDomainDecompostion() if (tempSend > 0) { //////////////////////////////////////////////////////////////////////////////////////// // send - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for Z send buffer, \t\tLevel " << level << " : " << tempSend - << " \t(neighbor rank: " << builder->getCommunicationProcess(direction) << ")\n"; + VF_LOG_INFO("size of Data for Z send buffer, \t\tLevel {}: {} \t(neighbor rank: {})", level, tempSend, builder->getCommunicationProcess(direction)); //////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->sendProcessNeighborF3Z.back().rankNeighbor = builder->getCommunicationProcess(direction); @@ -881,8 +868,7 @@ void GridGenerator::initalValuesDomainDecompostion() sizeof(real) * para->getParH(level)->sendProcessNeighborF3Z.back().numberOfGs; //////////////////////////////////////////////////////////////////////////////////////// // recv - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of Data for Z receive buffer, \tLevel " << level << " : " << tempRecv - << " \t(neighbor rank: " << builder->getCommunicationProcess(direction) << ")\n"; + VF_LOG_INFO("size of Data for Z recv buffer, \t\tLevel {}: {} \t(neighbor rank: {})", level, tempRecv, builder->getCommunicationProcess(direction)); //////////////////////////////////////////////////////////////////////////////////////// para->getParH(level)->recvProcessNeighborF3Z.back().rankNeighbor = builder->getCommunicationProcess(direction); @@ -920,15 +906,14 @@ void GridGenerator::initalValuesDomainDecompostion() void GridGenerator::allocArrays_BoundaryQs() { - std::cout << "------read BoundaryQs-------" << std::endl; + VF_LOG_TRACE("allocArrays_BoundaryQs()"); for (uint i = 0; i < builder->getNumberOfGridLevels(); i++) { const auto numberOfPressureValues = (int)builder->getPressureSize(i); if (numberOfPressureValues > 0) { - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size Pressure: " << i << " : " << numberOfPressureValues << "\n"; - //cout << "Groesse Pressure: " << i << " : " << temp1 << "MyID: " << para->getMyID() << endl; + VF_LOG_INFO("size Pressure: {}: {}", i, numberOfPressureValues); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //preprocessing real* QQ = para->getParH(i)->pressureBC.q27[0]; @@ -940,17 +925,15 @@ void GridGenerator::allocArrays_BoundaryQs() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // advection - diffusion stuff - //cout << "vor advec diff" << endl; - if (para->getDiffOn() == true) { + // advection - diffusion + if (para->getDiffOn()) { ////////////////////////////////////////////////////////////////////////// //cout << "vor setzen von kTemp" << endl; para->getParH(i)->TempPress.kTemp = numberOfPressureValues; para->getParD(i)->TempPress.kTemp = numberOfPressureValues; - std::cout << "Groesse TempPress.kTemp = " << para->getParH(i)->TempPress.kTemp << std::endl; + VF_LOG_INFO("size TempPress.kTemp: {}: {}", i, para->getParH(i)->TempPress.kTemp); ////////////////////////////////////////////////////////////////////////// cudaMemoryManager->cudaAllocTempPressBC(i); - //cout << "nach alloc" << endl; ////////////////////////////////////////////////////////////////////////// for (int m = 0; m < numberOfPressureValues; m++) { @@ -959,9 +942,7 @@ void GridGenerator::allocArrays_BoundaryQs() para->getParH(i)->TempPress.k[m] = para->getParH(i)->pressureBC.k[m]; } ////////////////////////////////////////////////////////////////////////// - //cout << "vor copy" << endl; cudaMemoryManager->cudaCopyTempPressBCHD(i); - //cout << "nach copy" << endl; ////////////////////////////////////////////////////////////////////////// } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -974,8 +955,7 @@ void GridGenerator::allocArrays_BoundaryQs() int numberOfSlipValues = (int)builder->getSlipSize(i); if (numberOfSlipValues > 0) { - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size Slip: " << i << " : " << numberOfSlipValues << "\n"; - //cout << "Groesse Pressure: " << i << " : " << temp1 << "MyID: " << para->getMyID() << endl; + VF_LOG_INFO("size Slip: {}: {}", i, numberOfSlipValues); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //preprocessing real* QQ = para->getParH(i)->slipBC.q27[0]; @@ -994,8 +974,7 @@ void GridGenerator::allocArrays_BoundaryQs() int numberOfStressValues = (int)builder->getStressSize(i); if (numberOfStressValues > 0) { - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size Stress: " << i << " : " << numberOfStressValues << "\n"; - //cout << "Groesse Pressure: " << i << " : " << temp1 << "MyID: " << para->getMyID() << endl; + VF_LOG_INFO("size Stress: {}: {}", i, numberOfStressValues); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //preprocessing real* QQ = para->getParH(i)->stressBC.q27[0]; @@ -1014,8 +993,7 @@ void GridGenerator::allocArrays_BoundaryQs() const auto numberOfVelocityNodes = int(builder->getVelocitySize(i)); if (numberOfVelocityNodes > 0) { - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size velocity level " << i << " : " << numberOfVelocityNodes << "\n"; - //cout << "Groesse velocity level: " << i << " : " << temp3 << "MyID: " << para->getMyID() << "\n"; + VF_LOG_INFO("size velocity level {}: {}", i, numberOfVelocityNodes); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //preprocessing real* QQ = para->getParH(i)->velocityBC.q27[0]; @@ -1028,12 +1006,11 @@ void GridGenerator::allocArrays_BoundaryQs() ////////////////////////////////////////////////////////////////////////// para->getParH(i)->TempVel.kTemp = numberOfVelocityNodes; para->getParD(i)->TempVel.kTemp = numberOfVelocityNodes; - std::cout << "Groesse TempVel.kTemp = " << para->getParH(i)->TempPress.kTemp << std::endl; - std::cout << "getTemperatureInit = " << para->getTemperatureInit() << std::endl; - std::cout << "getTemperatureBC = " << para->getTemperatureBC() << std::endl; + VF_LOG_INFO("size TempVel.kTemp: {}", para->getParH(i)->TempVel.kTemp); + VF_LOG_INFO("getTemperatureInit: {}", para->getTemperatureInit()); + VF_LOG_INFO("getTemperatureBC: {}", para->getTemperatureBC()); ////////////////////////////////////////////////////////////////////////// cudaMemoryManager->cudaAllocTempVeloBC(i); - //cout << "nach alloc " << "\n"; ////////////////////////////////////////////////////////////////////////// for (int m = 0; m < numberOfVelocityNodes; m++) { @@ -1042,11 +1019,7 @@ void GridGenerator::allocArrays_BoundaryQs() para->getParH(i)->TempVel.velo[m] = para->getVelocity(); para->getParH(i)->TempVel.k[m] = para->getParH(i)->velocityBC.k[m]; } - ////////////////////////////////////////////////////////////////////////// - //cout << "vor copy " << "\n"; cudaMemoryManager->cudaCopyTempVeloBCHD(i); - //cout << "nach copy " << "\n"; - ////////////////////////////////////////////////////////////////////////// } cudaMemoryManager->cudaCopyVeloBC(i); } @@ -1056,7 +1029,7 @@ void GridGenerator::allocArrays_BoundaryQs() const auto numberOfPrecursorNodes = int(builder->getPrecursorSize(i)); if (numberOfPrecursorNodes > 0) { - std::cout << "size velocity level " << i << " : " << numberOfPrecursorNodes << std::endl; + VF_LOG_INFO("size velocity level {}: {}", i, numberOfPrecursorNodes); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //preprocessing real* QQ = para->getParH(i)->precursorBC.q27[0]; @@ -1099,7 +1072,7 @@ void GridGenerator::allocArrays_BoundaryQs() for (uint i = 0; i < builder->getNumberOfGridLevels(); i++) { const int numberOfGeometryNodes = builder->getGeometrySize(i); - *logging::out << logging::Logger::INFO_INTERMEDIATE << "size of GeomBoundaryQs, Level " << i << " : " << numberOfGeometryNodes << "\n"; + VF_LOG_INFO("size of GeomBoundaryQs, Level {}: {}", i, numberOfGeometryNodes); para->getParH(i)->geometryBC.numberOfBCnodes = numberOfGeometryNodes; para->getParD(i)->geometryBC.numberOfBCnodes = para->getParH(i)->geometryBC.numberOfBCnodes; @@ -1164,8 +1137,7 @@ void GridGenerator::allocArrays_BoundaryQs() } } - - std::cout << "-----finish BoundaryQs------" << std::endl; + VF_LOG_TRACE("-----finish BoundaryQs------"); } void GridGenerator::allocArrays_OffsetScale() @@ -1175,29 +1147,17 @@ void GridGenerator::allocArrays_OffsetScale() const uint numberOfNodesPerLevelCF = builder->getNumberOfNodesCF(level); const uint numberOfNodesPerLevelFC = builder->getNumberOfNodesFC(level); - std::cout << "number of nodes CF Level " << level << " : " << numberOfNodesPerLevelCF << std::endl; - std::cout << "number of nodes FC level " << level << " : " << numberOfNodesPerLevelFC << std::endl; + VF_LOG_INFO("number of nodes CF Level {}: {}", level, numberOfNodesPerLevelCF); + VF_LOG_INFO("number of nodes FC Level {}: {}", level, numberOfNodesPerLevelFC); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //size + memsize CF - para->getParH(level)->K_CF = numberOfNodesPerLevelCF; - para->getParD(level)->K_CF = para->getParH(level)->K_CF; - para->getParH(level)->intCF.kCF = para->getParH(level)->K_CF; - para->getParD(level)->intCF.kCF = para->getParH(level)->K_CF; - para->getParH(level)->mem_size_kCF = sizeof(uint)* para->getParH(level)->K_CF; - para->getParD(level)->mem_size_kCF = sizeof(uint)* para->getParD(level)->K_CF; - para->getParH(level)->mem_size_kCF_off = sizeof(real)* para->getParH(level)->K_CF; - para->getParD(level)->mem_size_kCF_off = sizeof(real)* para->getParD(level)->K_CF; + //size CF + para->getParH(level)->coarseToFine.numberOfCells = numberOfNodesPerLevelCF; + para->getParD(level)->coarseToFine.numberOfCells = para->getParH(level)->coarseToFine.numberOfCells; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //size + memsize FC - para->getParH(level)->K_FC = numberOfNodesPerLevelFC; - para->getParD(level)->K_FC = para->getParH(level)->K_FC; - para->getParH(level)->intFC.kFC = para->getParH(level)->K_FC; - para->getParD(level)->intFC.kFC = para->getParH(level)->K_FC; - para->getParH(level)->mem_size_kFC = sizeof(uint)* para->getParH(level)->K_FC; - para->getParD(level)->mem_size_kFC = sizeof(uint)* para->getParD(level)->K_FC; - para->getParH(level)->mem_size_kFC_off = sizeof(real)* para->getParH(level)->K_FC; - para->getParD(level)->mem_size_kFC_off = sizeof(real)* para->getParD(level)->K_FC; + //size FC + para->getParH(level)->fineToCoarse.numberOfCells = numberOfNodesPerLevelFC; + para->getParD(level)->fineToCoarse.numberOfCells = para->getParH(level)->fineToCoarse.numberOfCells; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //alloc cudaMemoryManager->cudaAllocInterfaceCF(level); @@ -1206,9 +1166,9 @@ void GridGenerator::allocArrays_OffsetScale() cudaMemoryManager->cudaAllocInterfaceOffFC(level); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //init - builder->getOffsetCF(para->getParH(level)->offCF.xOffCF, para->getParH(level)->offCF.yOffCF, para->getParH(level)->offCF.zOffCF, level); - builder->getOffsetFC(para->getParH(level)->offFC.xOffFC, para->getParH(level)->offFC.yOffFC, para->getParH(level)->offFC.zOffFC, level); - builder->getGridInterfaceIndices(para->getParH(level)->intCF.ICellCFC, para->getParH(level)->intCF.ICellCFF, para->getParH(level)->intFC.ICellFCC, para->getParH(level)->intFC.ICellFCF, level); + builder->getOffsetCF(para->getParH(level)->neighborCoarseToFine.x, para->getParH(level)->neighborCoarseToFine.y, para->getParH(level)->neighborCoarseToFine.z, level); + builder->getOffsetFC(para->getParH(level)->neighborFineToCoarse.x, para->getParH(level)->neighborFineToCoarse.y, para->getParH(level)->neighborFineToCoarse.z, level); + builder->getGridInterfaceIndices(para->getParH(level)->coarseToFine.coarseCellIndices, para->getParH(level)->coarseToFine.fineCellIndices, para->getParH(level)->fineToCoarse.coarseCellIndices, para->getParH(level)->fineToCoarse.fineCellIndices, level); if (para->getUseStreams() || para->getNumprocs() > 1) { // split fine-to-coarse indices into border and bulk diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h index c97ed02a64da1d5fafa18150c75d149f96484d44..157eb5c37660f4de5f5d547b7bac2bbc5c749fc8 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h @@ -64,8 +64,7 @@ private: public: VIRTUALFLUIDS_GPU_EXPORT GridGenerator(std::shared_ptr<GridBuilder> builder, std::shared_ptr<Parameter> para, std::shared_ptr<CudaMemoryManager> cudaMemoryManager, vf::gpu::Communicator& communicator); - VIRTUALFLUIDS_GPU_EXPORT ~GridGenerator() override; - + ~GridGenerator() override; //! \brief overwrites the default IndexRearrangementForStreams void setIndexRearrangementForStreams(std::unique_ptr<IndexRearrangementForStreams>&& indexRearrangement); diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGeneratorTest.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGeneratorTest.cpp index 3009bc4ae449b917f494cdf39145a2e94df2ddb8..23d858f5bb5d8abcfda34a9ccfb5b3ff91ff313c 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGeneratorTest.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGeneratorTest.cpp @@ -104,9 +104,6 @@ protected: private: void SetUp() override { - logging::Logger::addStream(&std::cout); - logging::Logger::setDebugLevel(logging::Logger::WARNING); - para = std::make_shared<Parameter>(); para->setMaxLevel(level + 1); // setMaxLevel resizes parH and parD for (uint i = 0; i <= level; i++) { diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp index 4cd8769407220ec97030489585009d435a6cce8e..696254c44e0fe1150ded8566650483878377928c 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp @@ -333,7 +333,7 @@ void IndexRearrangementForStreams::reorderSendIndicesForCommAfterFtoC( { VF_LOG_INFO("Reorder send indices for communication after fine to coarse: level: {} direction: {}", level, direction); - if (para->getParH(level)->intCF.kCF == 0 || para->getParH(level)->intFC.kFC == 0) + if (para->getParH(level)->coarseToFine.numberOfCells == 0 || para->getParH(level)->fineToCoarse.numberOfCells == 0) VF_LOG_CRITICAL("reorderSendIndicesForCommAfterFtoC(): para->getParH(level)->intCF needs to be initialized " "before calling this function"); @@ -342,19 +342,19 @@ void IndexRearrangementForStreams::reorderSendIndicesForCommAfterFtoC( std::vector<int> sendIndicesOther; uint numberOfSendIndices = builder->getNumberOfSendIndices(direction, level); - // iCellFCC + // coarse cells of interpolation fine to coarse (iCellFCC) for (uint posInSendIndices = 0; posInSendIndices < numberOfSendIndices; posInSendIndices++) { sparseIndexSend = sendIndices[posInSendIndices]; - if (isSparseIndexInICellFCC(para->getParH(level)->intFC.kFC, sparseIndexSend, level)) { + if (isSparseIndexInCoarseIndexForFtoC(para->getParH(level)->fineToCoarse.numberOfCells, sparseIndexSend, level)) { addUniqueIndexToCommunicationVectors(sendIndicesAfterFtoC, sparseIndexSend, sendIndicesForCommAfterFtoCPositions, posInSendIndices); } } - // iCellCFC - std::vector<uint> nodesCFC; - aggregateNodesInICellCFC(level, nodesCFC); - for (auto sparseIndex : nodesCFC) + // coarse cells of interpolation coarse to fine (iCellCFC) + std::vector<uint> coarseCellsForCtoF; + aggregateCoarseNodesForCtoF(level, coarseCellsForCtoF); + for (auto sparseIndex : coarseCellsForCtoF) findIfSparseIndexIsInSendIndicesAndAddToCommVectors(sparseIndex, sendIndices, numberOfSendIndices, sendIndicesAfterFtoC, sendIndicesForCommAfterFtoCPositions); @@ -378,27 +378,27 @@ void IndexRearrangementForStreams::reorderSendIndicesForCommAfterFtoC( } } -bool IndexRearrangementForStreams::isSparseIndexInICellFCC(uint sizeOfICellFCC, int sparseIndex, int level) const +bool IndexRearrangementForStreams::isSparseIndexInCoarseIndexForFtoC(uint numberOfCoarseNodesForFtoC, int sparseIndex, int level) const { - for (uint j = 0; j < sizeOfICellFCC; j++) { + for (uint j = 0; j < numberOfCoarseNodesForFtoC; j++) { if (sparseIndex < 0) return false; - if (para->getParH(level)->intFC.ICellFCC[j] == (uint)sparseIndex) { + if (para->getParH(level)->fineToCoarse.coarseCellIndices[j] == (uint)sparseIndex) { return true; } } return false; } -void IndexRearrangementForStreams::aggregateNodesInICellCFC(int level, std::vector<uint> &nodesCFC) const +void IndexRearrangementForStreams::aggregateCoarseNodesForCtoF(int level, std::vector<uint> &nodesCFC) const { uint sparseIndex; uint *neighborX = para->getParH(level)->neighborX; uint *neighborY = para->getParH(level)->neighborY; uint *neighborZ = para->getParH(level)->neighborZ; - for (uint x = 0; x < para->getParH(level)->intCF.kCF; x++) { - sparseIndex = para->getParH(level)->intCF.ICellCFC[x]; + for (uint x = 0; x < para->getParH(level)->coarseToFine.numberOfCells; x++) { + sparseIndex = para->getParH(level)->coarseToFine.coarseCellIndices[x]; nodesCFC.push_back(sparseIndex); nodesCFC.push_back(neighborX[sparseIndex]); nodesCFC.push_back(neighborY[sparseIndex]); diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.h index e6753e21be43a4f004d812cca8b9adafa501ffe8..6102c2b10f70e54feb10c4b575cd8c07473b608b 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.h @@ -9,7 +9,7 @@ #include <memory> #include <vector> -#include <basics/Core/DataTypes.h> +#include <basics/DataTypes.h> class Parameter; class GridBuilder; @@ -89,12 +89,12 @@ protected: //! \param sendIndicesForCommAfterFtoCPositions stores each sendIndex's positions before reordering void reorderSendIndicesForCommAfterFtoC(int *sendIndices, int &numberOfSendNodesAfterFtoC, int direction, int level, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; - //! \brief Check if a sparse index occurs in the ICellFCC - bool isSparseIndexInICellFCC(uint sizeOfICellFCC, int sparseIndexSend, int level) const; + //! \brief Check if a sparse index occurs in the coarse nodes for the interpolation from fine to coarse + bool isSparseIndexInCoarseIndexForFtoC(uint numberOfCoarseNodesForFtoC, int sparseIndexSend, int level) const; //! \brief Aggregate all nodes in the coarse cells for the interpolation in coarse to fine //! \details For the coarse cells in the interpolation from coarse to fine only one node is stored. This methods //! looks for the other nodes of each cell and puts them into vector. Duplicate nodes are only stored once. - void aggregateNodesInICellCFC(int level, std::vector<uint> &nodesCFC) const; + void aggregateCoarseNodesForCtoF(int level, std::vector<uint> &nodesCFC) const; //! \brief Add index to sendIndicesAfterFtoC and sendIndicesForCommAfterFtoCPositions, but omit indices which are already in sendIndicesAfterFtoC void addUniqueIndexToCommunicationVectors(std::vector<int> &sendIndicesAfterFtoC, int &sparseIndexSend, std::vector<unsigned int> &sendIndicesForCommAfterFtoCPositions, diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp index 7bf534013ab68ba6a58fb3f33ca4ae03610cc12d..3fe22394823e3c33d43f8fe8709d499e57ee66f9 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp @@ -57,16 +57,16 @@ private: std::vector<uint> fluidNodeIndicesBorder; public: - GridImpDouble(Object *object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, + GridImpDouble(SPtr<Object> object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, Distribution d, uint level) : GridImp(object, startX, startY, startZ, endX, endY, endZ, delta, d, level) { } - static SPtr<GridImpDouble> makeShared(Object *object, real startX, real startY, real startZ, real endX, real endY, + static SPtr<GridImpDouble> makeShared(SPtr<Object> object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, Distribution d, uint level) { - SPtr<GridImpDouble> grid(new GridImpDouble(object, startX, startY, startZ, endX, endY, endZ, delta, d, level)); + SPtr<GridImpDouble> grid(std::make_shared<GridImpDouble>(object, startX, startY, startZ, endX, endY, endZ, delta, d, level)); return grid; } }; @@ -86,10 +86,10 @@ struct SendIndicesForCommAfterFtoCX { const int numberOfProcessNeighbors = 1; const int indexOfProcessNeighbor = 0; - std::vector<uint> iCellCFC = { 8, 10, 12 }; - std::vector<uint> iCellFCC = { 14, 16, 18 }; - const uint kCF = (uint)iCellCFC.size(); - const uint kFC = (uint)iCellFCC.size(); + std::vector<uint> interpolationCellCoarseToFineCoarse = { 8, 10, 12 }; + std::vector<uint> interpolationCellFineToCoarseCoarse = { 14, 16, 18 }; + const uint numNodesCtoF = (uint)interpolationCellCoarseToFineCoarse.size(); + const uint numNodesFtoC = (uint)interpolationCellFineToCoarseCoarse.size(); uint neighborX[18] = { 0u }; uint neighborY[18] = { 0u }; uint neighborZ[18] = { 0u }; @@ -106,39 +106,37 @@ struct SendIndicesForCommAfterFtoCX { class IndexRearrangementForStreamsTest_reorderSendIndices : public testing::Test { protected: - SendIndicesForCommAfterFtoCX si; + SendIndicesForCommAfterFtoCX sendIndices; SPtr<Parameter> para; std::unique_ptr<IndexRearrangementForStreams> testSubject; void act() { - testSubject->reorderSendIndicesForCommAfterFtoCX(si.direction, si.level, si.indexOfProcessNeighbor, - si.sendIndicesForCommAfterFtoCPositions); + testSubject->reorderSendIndicesForCommAfterFtoCX(sendIndices.direction, sendIndices.level, sendIndices.indexOfProcessNeighbor, + sendIndices.sendIndicesForCommAfterFtoCPositions); }; private: void SetUp() override { - logging::Logger::addStream(&std::cout); - SPtr<GridImpDouble> grid = GridImpDouble::makeShared(nullptr, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, Distribution(), 1); std::shared_ptr<LevelGridBuilderDouble> builder = std::make_shared<LevelGridBuilderDouble>(grid); - builder->setNumberOfSendIndices((uint)si.sendIndices.size()); + builder->setNumberOfSendIndices((uint)sendIndices.sendIndices.size()); - para = testingVF::createParameterForLevel(si.level); + para = testingVF::createParameterForLevel(sendIndices.level); - para->getParH(si.level)->intFC.kFC = si.kFC; - para->getParH(si.level)->intFC.ICellFCC = &(si.iCellFCC.front()); - para->getParH(si.level)->intCF.ICellCFC = &(si.iCellCFC.front()); - para->getParH(si.level)->intCF.kCF = si.kCF; - para->getParH(si.level)->neighborX = si.neighborX; - para->getParH(si.level)->neighborY = si.neighborY; - para->getParH(si.level)->neighborZ = si.neighborZ; + para->getParH(sendIndices.level)->fineToCoarse.numberOfCells = sendIndices.numNodesFtoC; + para->getParH(sendIndices.level)->fineToCoarse.coarseCellIndices = &(sendIndices.interpolationCellFineToCoarseCoarse.front()); + para->getParH(sendIndices.level)->coarseToFine.coarseCellIndices = &(sendIndices.interpolationCellCoarseToFineCoarse.front()); + para->getParH(sendIndices.level)->coarseToFine.numberOfCells = sendIndices.numNodesCtoF; + para->getParH(sendIndices.level)->neighborX = sendIndices.neighborX; + para->getParH(sendIndices.level)->neighborY = sendIndices.neighborY; + para->getParH(sendIndices.level)->neighborZ = sendIndices.neighborZ; - para->setNumberOfProcessNeighborsX(si.numberOfProcessNeighbors, si.level, "send"); - para->getParH(si.level)->sendProcessNeighborX[si.indexOfProcessNeighbor].index = si.sendIndices.data(); - para->initProcessNeighborsAfterFtoCX(si.level); + para->setNumberOfProcessNeighborsX(sendIndices.numberOfProcessNeighbors, sendIndices.level, "send"); + para->getParH(sendIndices.level)->sendProcessNeighborX[sendIndices.indexOfProcessNeighbor].index = sendIndices.sendIndices.data(); + para->initProcessNeighborsAfterFtoCX(sendIndices.level); testSubject = std::make_unique<IndexRearrangementForStreams>( IndexRearrangementForStreams(para, builder, vf::gpu::Communicator::getInstance())); @@ -149,14 +147,14 @@ TEST_F(IndexRearrangementForStreamsTest_reorderSendIndices, reorderSendIndicesFo { act(); - EXPECT_THAT(si.sendIndicesForCommAfterFtoCPositions.size(), - testing::Eq(si.sendIndicesForCommAfterFtoCPositions_expected.size())); - EXPECT_THAT(si.sendIndicesForCommAfterFtoCPositions, testing::Eq(si.sendIndicesForCommAfterFtoCPositions_expected)); + EXPECT_THAT(sendIndices.sendIndicesForCommAfterFtoCPositions.size(), + testing::Eq(sendIndices.sendIndicesForCommAfterFtoCPositions_expected.size())); + EXPECT_THAT(sendIndices.sendIndicesForCommAfterFtoCPositions, testing::Eq(sendIndices.sendIndicesForCommAfterFtoCPositions_expected)); - EXPECT_THAT(para->getParH(si.level)->sendProcessNeighborsAfterFtoCX[si.indexOfProcessNeighbor].numberOfNodes, - testing::Eq(si.numberOfSendNodesAfterFtoC_expected)); - EXPECT_TRUE(vectorsAreEqual(para->getParH(si.level)->sendProcessNeighborX[si.indexOfProcessNeighbor].index, - si.sendProcessNeighborX_expected)) + EXPECT_THAT(para->getParH(sendIndices.level)->sendProcessNeighborsAfterFtoCX[sendIndices.indexOfProcessNeighbor].numberOfNodes, + testing::Eq(sendIndices.numberOfSendNodesAfterFtoC_expected)); + EXPECT_TRUE(vectorsAreEqual(para->getParH(sendIndices.level)->sendProcessNeighborX[sendIndices.indexOfProcessNeighbor].index, + sendIndices.sendProcessNeighborX_expected)) << "sendProcessNeighborX[].index does not match the expected vector"; } @@ -216,8 +214,6 @@ protected: private: void SetUp() override { - logging::Logger::addStream(&std::cout); - para = testingVF::createParameterForLevel(level); para->setNumberOfProcessNeighborsX(numberOfProcessNeighbors, level, "send"); @@ -337,8 +333,6 @@ protected: private: void SetUp() override { - logging::Logger::addStream(&std::cout); - para = testingVF::createParameterForLevel(level); para->setNumberOfProcessNeighborsY(numberOfProcessNeighbors, level, "send"); @@ -458,8 +452,6 @@ protected: private: void SetUp() override { - logging::Logger::addStream(&std::cout); - para = testingVF::createParameterForLevel(level); para->setNumberOfProcessNeighborsZ(numberOfProcessNeighbors, level, "send"); diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/InterpolationCellGrouper.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/InterpolationCellGrouper.cpp index 347ab362d1f6b28a6c2b46f2e885085f955fb34e..f3717b58fca0e81e23be100eb8d15371703f8010 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/InterpolationCellGrouper.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/InterpolationCellGrouper.cpp @@ -14,77 +14,77 @@ void InterpolationCellGrouper::splitFineToCoarseIntoBorderAndBulk(uint level) co { this->reorderFineToCoarseIntoBorderAndBulk(level); - parDs[level]->intFCBorder.kFC = parHs[level]->intFCBorder.kFC; - parDs[level]->intFCBulk.kFC = parHs[level]->intFCBulk.kFC; - parDs[level]->intFCBorder.ICellFCC = parDs[level]->intFC.ICellFCC; - parDs[level]->intFCBulk.ICellFCC = parDs[level]->intFCBorder.ICellFCC + parDs[level]->intFCBorder.kFC; - parDs[level]->intFCBorder.ICellFCF = parDs[level]->intFC.ICellFCF; - parDs[level]->intFCBulk.ICellFCF = parDs[level]->intFCBorder.ICellFCF + parDs[level]->intFCBorder.kFC; - parDs[level]->offFCBulk.xOffFC = parDs[level]->offFC.xOffFC + parDs[level]->intFCBorder.kFC; - parDs[level]->offFCBulk.yOffFC = parDs[level]->offFC.yOffFC + parDs[level]->intFCBorder.kFC; - parDs[level]->offFCBulk.zOffFC = parDs[level]->offFC.zOffFC + parDs[level]->intFCBorder.kFC; + parDs[level]->fineToCoarseBorder.numberOfCells = parHs[level]->fineToCoarseBorder.numberOfCells; + parDs[level]->fineToCoarseBulk.numberOfCells = parHs[level]->fineToCoarseBulk.numberOfCells; + parDs[level]->fineToCoarseBorder.coarseCellIndices = parDs[level]->fineToCoarse.coarseCellIndices; + parDs[level]->fineToCoarseBulk.coarseCellIndices = parDs[level]->fineToCoarseBorder.coarseCellIndices + parDs[level]->fineToCoarseBorder.numberOfCells; + parDs[level]->fineToCoarseBorder.fineCellIndices = parDs[level]->fineToCoarse.fineCellIndices; + parDs[level]->fineToCoarseBulk.fineCellIndices = parDs[level]->fineToCoarseBorder.fineCellIndices + parDs[level]->fineToCoarseBorder.numberOfCells; + parDs[level]->neighborFineToCoarseBulk.x = parDs[level]->neighborFineToCoarse.x + parDs[level]->fineToCoarseBorder.numberOfCells; + parDs[level]->neighborFineToCoarseBulk.y = parDs[level]->neighborFineToCoarse.y + parDs[level]->fineToCoarseBorder.numberOfCells; + parDs[level]->neighborFineToCoarseBulk.z = parDs[level]->neighborFineToCoarse.z + parDs[level]->fineToCoarseBorder.numberOfCells; } void InterpolationCellGrouper::reorderFineToCoarseIntoBorderAndBulk(uint level) const { // create some local variables for better readability - uint *iCellFccAll = parHs[level]->intFC.ICellFCC; - uint *iCellFcfAll = parHs[level]->intFC.ICellFCF; + uint *fineToCoarseCoarseAll = parHs[level]->fineToCoarse.coarseCellIndices; + uint *fineToCoarseFineAll = parHs[level]->fineToCoarse.fineCellIndices; auto grid = this->builder->getGrid(level); - std::vector<uint> iCellFccBorderVector; - std::vector<uint> iCellFccBulkVector; - std::vector<uint> iCellFcfBorderVector; - std::vector<uint> iCellFcfBulkVector; - std::vector<real> xOffFCBorderVector; - std::vector<real> yOffFCBorderVector; - std::vector<real> zOffFCBorderVector; - std::vector<real> xOffFCBulkVector; - std::vector<real> yOffFCBulkVector; - std::vector<real> zOffFCBulkVector; - - // fill border and bulk vectors with iCellFCs - for (uint i = 0; i < parHs[level]->intFC.kFC; i++) - if (grid->isSparseIndexInFluidNodeIndicesBorder(iCellFccAll[i])) { - iCellFccBorderVector.push_back(iCellFccAll[i]); - iCellFcfBorderVector.push_back(iCellFcfAll[i]); - xOffFCBorderVector.push_back(parHs[level]->offFC.xOffFC[i]); - yOffFCBorderVector.push_back(parHs[level]->offFC.yOffFC[i]); - zOffFCBorderVector.push_back(parHs[level]->offFC.zOffFC[i]); + std::vector<uint> fineToCoarseCoarseBorderVector; + std::vector<uint> fineToCoarseCoarseBulkVector; + std::vector<uint> fineToCoarseFineBorderVector; + std::vector<uint> fineToCoarseFineBulkVector; + std::vector<real> neighborXBorder; + std::vector<real> neighborYBorder; + std::vector<real> neighborZBorder; + std::vector<real> neighborXBulk; + std::vector<real> neighborYBulk; + std::vector<real> neighborZBulk; + + // fill border and bulk vectors with interpolation cells fine to coarse + for (uint i = 0; i < parHs[level]->fineToCoarse.numberOfCells; i++) + if (grid->isSparseIndexInFluidNodeIndicesBorder(fineToCoarseCoarseAll[i])) { + fineToCoarseCoarseBorderVector.push_back(fineToCoarseCoarseAll[i]); + fineToCoarseFineBorderVector.push_back(fineToCoarseFineAll[i]); + neighborXBorder.push_back(parHs[level]->neighborFineToCoarse.x[i]); + neighborYBorder.push_back(parHs[level]->neighborFineToCoarse.y[i]); + neighborZBorder.push_back(parHs[level]->neighborFineToCoarse.z[i]); } else { - iCellFccBulkVector.push_back(iCellFccAll[i]); - iCellFcfBulkVector.push_back(iCellFcfAll[i]); - xOffFCBulkVector.push_back(parHs[level]->offFC.xOffFC[i]); - yOffFCBulkVector.push_back(parHs[level]->offFC.yOffFC[i]); - zOffFCBulkVector.push_back(parHs[level]->offFC.zOffFC[i]); + fineToCoarseCoarseBulkVector.push_back(fineToCoarseCoarseAll[i]); + fineToCoarseFineBulkVector.push_back(fineToCoarseFineAll[i]); + neighborXBulk.push_back(parHs[level]->neighborFineToCoarse.x[i]); + neighborYBulk.push_back(parHs[level]->neighborFineToCoarse.y[i]); + neighborZBulk.push_back(parHs[level]->neighborFineToCoarse.z[i]); } // set new sizes and pointers - parHs[level]->intFCBorder.ICellFCC = iCellFccAll; - parHs[level]->intFCBorder.ICellFCF = iCellFcfAll; - parHs[level]->intFCBorder.kFC = (uint)iCellFccBorderVector.size(); - parHs[level]->intFCBulk.kFC = (uint)iCellFccBulkVector.size(); - parHs[level]->intFCBulk.ICellFCC = iCellFccAll + parHs[level]->intFCBorder.kFC; - parHs[level]->intFCBulk.ICellFCF = iCellFcfAll + parHs[level]->intFCBorder.kFC; - parHs[level]->offFCBulk.xOffFC = parHs[level]->offFC.xOffFC + parHs[level]->intFCBorder.kFC; - parHs[level]->offFCBulk.yOffFC = parHs[level]->offFC.yOffFC + parHs[level]->intFCBorder.kFC; - parHs[level]->offFCBulk.zOffFC = parHs[level]->offFC.zOffFC + parHs[level]->intFCBorder.kFC; + parHs[level]->fineToCoarseBorder.coarseCellIndices = fineToCoarseCoarseAll; + parHs[level]->fineToCoarseBorder.fineCellIndices = fineToCoarseFineAll; + parHs[level]->fineToCoarseBorder.numberOfCells = (uint)fineToCoarseCoarseBorderVector.size(); + parHs[level]->fineToCoarseBulk.numberOfCells = (uint)fineToCoarseCoarseBulkVector.size(); + parHs[level]->fineToCoarseBulk.coarseCellIndices = fineToCoarseCoarseAll + parHs[level]->fineToCoarseBorder.numberOfCells; + parHs[level]->fineToCoarseBulk.fineCellIndices = fineToCoarseFineAll + parHs[level]->fineToCoarseBorder.numberOfCells; + parHs[level]->neighborFineToCoarseBulk.x = parHs[level]->neighborFineToCoarse.x + parHs[level]->fineToCoarseBorder.numberOfCells; + parHs[level]->neighborFineToCoarseBulk.y = parHs[level]->neighborFineToCoarse.y + parHs[level]->fineToCoarseBorder.numberOfCells; + parHs[level]->neighborFineToCoarseBulk.z = parHs[level]->neighborFineToCoarse.z + parHs[level]->fineToCoarseBorder.numberOfCells; // copy the created vectors to the memory addresses of the old arrays // this is inefficient :( - for (uint i = 0; i < (uint)iCellFccBorderVector.size(); i++) { - iCellFccAll[i] = iCellFccBorderVector[i]; - iCellFcfAll[i] = iCellFcfBorderVector[i]; - parHs[level]->offFC.xOffFC[i] = xOffFCBorderVector[i]; - parHs[level]->offFC.yOffFC[i] = yOffFCBorderVector[i]; - parHs[level]->offFC.zOffFC[i] = zOffFCBorderVector[i]; + for (uint i = 0; i < (uint)fineToCoarseCoarseBorderVector.size(); i++) { + fineToCoarseCoarseAll[i] = fineToCoarseCoarseBorderVector[i]; + fineToCoarseFineAll[i] = fineToCoarseFineBorderVector[i]; + parHs[level]->neighborFineToCoarse.x[i] = neighborXBorder[i]; + parHs[level]->neighborFineToCoarse.y[i] = neighborYBorder[i]; + parHs[level]->neighborFineToCoarse.z[i] = neighborZBorder[i]; } - for (uint i = 0; i < (uint)iCellFccBulkVector.size(); i++) { - parHs[level]->intFCBulk.ICellFCC[i] = iCellFccBulkVector[i]; - parHs[level]->intFCBulk.ICellFCF[i] = iCellFcfBulkVector[i]; - parHs[level]->offFCBulk.xOffFC[i] = xOffFCBulkVector[i]; - parHs[level]->offFCBulk.yOffFC[i] = yOffFCBulkVector[i]; - parHs[level]->offFCBulk.zOffFC[i] = zOffFCBulkVector[i]; + for (uint i = 0; i < (uint)fineToCoarseCoarseBulkVector.size(); i++) { + parHs[level]->fineToCoarseBulk.coarseCellIndices[i] = fineToCoarseCoarseBulkVector[i]; + parHs[level]->fineToCoarseBulk.fineCellIndices[i] = fineToCoarseFineBulkVector[i]; + parHs[level]->neighborFineToCoarseBulk.x[i] = neighborXBulk[i]; + parHs[level]->neighborFineToCoarseBulk.y[i] = neighborYBulk[i]; + parHs[level]->neighborFineToCoarseBulk.z[i] = neighborZBulk[i]; } } @@ -92,42 +92,42 @@ void InterpolationCellGrouper::splitCoarseToFineIntoBorderAndBulk(uint level) co { this->reorderCoarseToFineIntoBorderAndBulk(level); - parDs[level]->intCFBorder.kCF = parHs[level]->intCFBorder.kCF; - parDs[level]->intCFBulk.kCF = parHs[level]->intCFBulk.kCF; - parDs[level]->intCFBorder.ICellCFC = parDs[level]->intCF.ICellCFC; - parDs[level]->intCFBulk.ICellCFC = parDs[level]->intCFBorder.ICellCFC + parDs[level]->intCFBorder.kCF; - parDs[level]->intCFBorder.ICellCFF = parDs[level]->intCF.ICellCFF; - parDs[level]->intCFBulk.ICellCFF = parDs[level]->intCFBorder.ICellCFF + parDs[level]->intCFBorder.kCF; - parDs[level]->offCFBulk.xOffCF = parDs[level]->offCF.xOffCF + parDs[level]->intCFBorder.kCF; - parDs[level]->offCFBulk.yOffCF = parDs[level]->offCF.yOffCF + parDs[level]->intCFBorder.kCF; - parDs[level]->offCFBulk.zOffCF = parDs[level]->offCF.zOffCF + parDs[level]->intCFBorder.kCF; + parDs[level]->coarseToFineBorder.numberOfCells = parHs[level]->coarseToFineBorder.numberOfCells; + parDs[level]->coarseToFineBulk.numberOfCells = parHs[level]->coarseToFineBulk.numberOfCells; + parDs[level]->coarseToFineBorder.coarseCellIndices = parDs[level]->coarseToFine.coarseCellIndices; + parDs[level]->coarseToFineBulk.coarseCellIndices = parDs[level]->coarseToFineBorder.coarseCellIndices + parDs[level]->coarseToFineBorder.numberOfCells; + parDs[level]->coarseToFineBorder.fineCellIndices = parDs[level]->coarseToFine.fineCellIndices; + parDs[level]->coarseToFineBulk.fineCellIndices = parDs[level]->coarseToFineBorder.fineCellIndices + parDs[level]->coarseToFineBorder.numberOfCells; + parDs[level]->neighborCoarseToFineBulk.x = parDs[level]->neighborCoarseToFine.x + parDs[level]->coarseToFineBorder.numberOfCells; + parDs[level]->neighborCoarseToFineBulk.y = parDs[level]->neighborCoarseToFine.y + parDs[level]->coarseToFineBorder.numberOfCells; + parDs[level]->neighborCoarseToFineBulk.z = parDs[level]->neighborCoarseToFine.z + parDs[level]->coarseToFineBorder.numberOfCells; } void InterpolationCellGrouper::reorderCoarseToFineIntoBorderAndBulk(uint level) const { // create some local variables for better readability - uint *iCellCfcAll = parHs[level]->intCF.ICellCFC; - uint *iCellCffAll = parHs[level]->intCF.ICellCFF; + uint *coarseToFineCoarseAll = parHs[level]->coarseToFine.coarseCellIndices; + uint *coarseToFineFineAll = parHs[level]->coarseToFine.fineCellIndices; uint *neighborX = this->parHs[level]->neighborX; uint *neighborY = this->parHs[level]->neighborY; uint *neighborZ = this->parHs[level]->neighborZ; auto grid = this->builder->getGrid(level); - std::vector<uint> iCellCfcBorderVector; - std::vector<uint> iCellCfcBulkVector; - std::vector<uint> iCellCffBorderVector; - std::vector<uint> iCellCffBulkVector; - std::vector<real> xOffCFBorderVector; - std::vector<real> yOffCFBorderVector; - std::vector<real> zOffCFBorderVector; - std::vector<real> xOffCFBulkVector; - std::vector<real> yOffCFBulkVector; - std::vector<real> zOffCFBulkVector; + std::vector<uint> coarseToFineCoarseBorderVector; + std::vector<uint> coarseToFineCoarseBulkVector; + std::vector<uint> coarseToFineFineBorderVector; + std::vector<uint> coarseToFineFineBulkVector; + std::vector<real> neighborXBorder; + std::vector<real> neighborYBorder; + std::vector<real> neighborZBorder; + std::vector<real> neighborXBulk; + std::vector<real> neighborYBulk; + std::vector<real> neighborZBulk; uint sparseIndexOfICellBSW; - // fill border and bulk vectors with iCellCFs - for (uint i = 0; i < parHs[level]->intCF.kCF; i++) { - sparseIndexOfICellBSW = iCellCfcAll[i]; + // fill border and bulk vectors with interpolation cells coarse to fine + for (uint i = 0; i < parHs[level]->coarseToFine.numberOfCells; i++) { + sparseIndexOfICellBSW = coarseToFineCoarseAll[i]; if (grid->isSparseIndexInFluidNodeIndicesBorder(sparseIndexOfICellBSW) || grid->isSparseIndexInFluidNodeIndicesBorder(neighborX[sparseIndexOfICellBSW]) || @@ -138,45 +138,45 @@ void InterpolationCellGrouper::reorderCoarseToFineIntoBorderAndBulk(uint level) grid->isSparseIndexInFluidNodeIndicesBorder(neighborZ[neighborY[sparseIndexOfICellBSW]]) || grid->isSparseIndexInFluidNodeIndicesBorder(neighborZ[neighborY[neighborX[sparseIndexOfICellBSW]]])) { - iCellCfcBorderVector.push_back(iCellCfcAll[i]); - iCellCffBorderVector.push_back(iCellCffAll[i]); - xOffCFBorderVector.push_back(parHs[level]->offCF.xOffCF[i]); - yOffCFBorderVector.push_back(parHs[level]->offCF.yOffCF[i]); - zOffCFBorderVector.push_back(parHs[level]->offCF.zOffCF[i]); + coarseToFineCoarseBorderVector.push_back(coarseToFineCoarseAll[i]); + coarseToFineFineBorderVector.push_back(coarseToFineFineAll[i]); + neighborXBorder.push_back(parHs[level]->neighborCoarseToFine.x[i]); + neighborYBorder.push_back(parHs[level]->neighborCoarseToFine.y[i]); + neighborZBorder.push_back(parHs[level]->neighborCoarseToFine.z[i]); } else { - iCellCfcBulkVector.push_back(iCellCfcAll[i]); - iCellCffBulkVector.push_back(iCellCffAll[i]); - xOffCFBulkVector.push_back(parHs[level]->offCF.xOffCF[i]); - yOffCFBulkVector.push_back(parHs[level]->offCF.yOffCF[i]); - zOffCFBulkVector.push_back(parHs[level]->offCF.zOffCF[i]); + coarseToFineCoarseBulkVector.push_back(coarseToFineCoarseAll[i]); + coarseToFineFineBulkVector.push_back(coarseToFineFineAll[i]); + neighborXBulk.push_back(parHs[level]->neighborCoarseToFine.x[i]); + neighborYBulk.push_back(parHs[level]->neighborCoarseToFine.y[i]); + neighborZBulk.push_back(parHs[level]->neighborCoarseToFine.z[i]); } } // set new sizes and pointers - parHs[level]->intCFBorder.ICellCFC = parHs[level]->intCF.ICellCFC; - parHs[level]->intCFBorder.ICellCFF = parHs[level]->intCF.ICellCFF; - parHs[level]->intCFBorder.kCF = (uint)iCellCfcBorderVector.size(); - parHs[level]->intCFBulk.kCF = (uint)iCellCfcBulkVector.size(); - parHs[level]->intCFBulk.ICellCFC = parHs[level]->intCF.ICellCFC + parHs[level]->intCFBorder.kCF; - parHs[level]->intCFBulk.ICellCFF = parHs[level]->intCF.ICellCFF + parHs[level]->intCFBorder.kCF; - parHs[level]->offCFBulk.xOffCF = parHs[level]->offCF.xOffCF + parHs[level]->intCFBorder.kCF; - parHs[level]->offCFBulk.yOffCF = parHs[level]->offCF.yOffCF + parHs[level]->intCFBorder.kCF; - parHs[level]->offCFBulk.zOffCF = parHs[level]->offCF.zOffCF + parHs[level]->intCFBorder.kCF; + parHs[level]->coarseToFineBorder.coarseCellIndices = parHs[level]->coarseToFine.coarseCellIndices; + parHs[level]->coarseToFineBorder.fineCellIndices = parHs[level]->coarseToFine.fineCellIndices; + parHs[level]->coarseToFineBorder.numberOfCells = (uint)coarseToFineCoarseBorderVector.size(); + parHs[level]->coarseToFineBulk.numberOfCells = (uint)coarseToFineCoarseBulkVector.size(); + parHs[level]->coarseToFineBulk.coarseCellIndices = parHs[level]->coarseToFine.coarseCellIndices + parHs[level]->coarseToFineBorder.numberOfCells; + parHs[level]->coarseToFineBulk.fineCellIndices = parHs[level]->coarseToFine.fineCellIndices + parHs[level]->coarseToFineBorder.numberOfCells; + parHs[level]->neighborCoarseToFineBulk.x = parHs[level]->neighborCoarseToFine.x + parHs[level]->coarseToFineBorder.numberOfCells; + parHs[level]->neighborCoarseToFineBulk.y = parHs[level]->neighborCoarseToFine.y + parHs[level]->coarseToFineBorder.numberOfCells; + parHs[level]->neighborCoarseToFineBulk.z = parHs[level]->neighborCoarseToFine.z + parHs[level]->coarseToFineBorder.numberOfCells; // copy the created vectors to the memory addresses of the old arrays // this is inefficient :( - for (uint i = 0; i < (uint)iCellCfcBorderVector.size(); i++) { - parHs[level]->intCFBorder.ICellCFC[i] = iCellCfcBorderVector[i]; - parHs[level]->intCFBorder.ICellCFF[i] = iCellCffBorderVector[i]; - parHs[level]->offCF.xOffCF[i] = xOffCFBorderVector[i]; - parHs[level]->offCF.yOffCF[i] = yOffCFBorderVector[i]; - parHs[level]->offCF.zOffCF[i] = zOffCFBorderVector[i]; + for (uint i = 0; i < (uint)coarseToFineCoarseBorderVector.size(); i++) { + parHs[level]->coarseToFineBorder.coarseCellIndices[i] = coarseToFineCoarseBorderVector[i]; + parHs[level]->coarseToFineBorder.fineCellIndices[i] = coarseToFineFineBorderVector[i]; + parHs[level]->neighborCoarseToFine.x[i] = neighborXBorder[i]; + parHs[level]->neighborCoarseToFine.y[i] = neighborYBorder[i]; + parHs[level]->neighborCoarseToFine.z[i] = neighborZBorder[i]; } - for (uint i = 0; i < (uint)iCellCfcBulkVector.size(); i++) { - parHs[level]->intCFBulk.ICellCFC[i] = iCellCfcBulkVector[i]; - parHs[level]->intCFBulk.ICellCFF[i] = iCellCffBulkVector[i]; - parHs[level]->offCFBulk.xOffCF[i] = xOffCFBulkVector[i]; - parHs[level]->offCFBulk.yOffCF[i] = yOffCFBulkVector[i]; - parHs[level]->offCFBulk.zOffCF[i] = zOffCFBulkVector[i]; + for (uint i = 0; i < (uint)coarseToFineCoarseBulkVector.size(); i++) { + parHs[level]->coarseToFineBulk.coarseCellIndices[i] = coarseToFineCoarseBulkVector[i]; + parHs[level]->coarseToFineBulk.fineCellIndices[i] = coarseToFineFineBulkVector[i]; + parHs[level]->neighborCoarseToFineBulk.x[i] = neighborXBulk[i]; + parHs[level]->neighborCoarseToFineBulk.y[i] = neighborYBulk[i]; + parHs[level]->neighborCoarseToFineBulk.z[i] = neighborZBulk[i]; } } diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/InterpolationCellGrouper.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/InterpolationCellGrouper.h index 5471194f643e044a7c2cdca1db45017b9d3a1022..f619d785e1f6c30cee0c698cbc9d8dd8249f414f 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/InterpolationCellGrouper.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/InterpolationCellGrouper.h @@ -6,7 +6,7 @@ #ifndef InterpolationCellGrouper_H #define InterpolationCellGrouper_H -#include <basics/Core/DataTypes.h> +#include <basics/DataTypes.h> #include <basics/PointerDefinitions.h> #include <memory> #include <vector> @@ -54,14 +54,14 @@ protected: ////////////////////////////////////////////////////////////////////////// //! \brief This function reorders the arrays of CFC/CFF indices and sets the pointers and sizes of the new - //! subarrays: \details The coarse cells for interpolation from coarse to fine (iCellCFC) are divided into two - //! subgroups: border and bulk. The fine cells (iCellCFF) are reordered accordingly. The offset cells (xOffCF, + //! subarrays: \details The coarse cells for interpolation from coarse to fine (coarseToFineCoarse) are divided into two + //! subgroups: border and bulk. The fine cells (coarseToFineFine) are reordered accordingly. The offset cells (xOffCF, //! yOffCF, zOffCF) must be reordered in the same way. void reorderCoarseToFineIntoBorderAndBulk(uint level) const; //! \brief This function reorders the arrays of FCC/FCF indices and return pointers and sizes of the new subarrays: - //! \details The coarse cells for interpolation from fine to coarse (iCellFCC) are divided into two subgroups: - //! border and bulk. The fine cells (iCellFCF) are reordered accordingly. The offset cells (xOffFC, + //! \details The coarse cells for interpolation from fine to coarse (fineToCoarseCoarse) are divided into two subgroups: + //! border and bulk. The fine cells (fineToCoarseFine) are reordered accordingly. The offset cells (xOffFC, //! yOffFC, zOffFC) must be reordered in the same way. void reorderFineToCoarseIntoBorderAndBulk(uint level) const; diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/InterpolationCellGrouperTest.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/InterpolationCellGrouperTest.cpp index 664552b2f47542cc6ae3d4940c2b74ede1beff91..4f4e8525f17ef004d65ee2eaa3d4d533d9d40734 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/InterpolationCellGrouperTest.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/InterpolationCellGrouperTest.cpp @@ -38,7 +38,7 @@ private: std::vector<uint> fluidNodeIndicesBorder; public: - GridImpDouble(Object *object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, + GridImpDouble(SPtr<Object> object, real startX, real startY, real startZ, real endX, real endY, real endZ, real delta, Distribution d, uint level) : GridImp(object, startX, startY, startZ, endX, endY, endZ, delta, d, level) { @@ -62,37 +62,37 @@ public: } }; -struct CFBorderBulk { +struct CoarseToFineBorderBulk { // data to work on std::vector<uint> fluidNodeIndicesBorder = { 10, 11, 12, 13, 14, 15, 16 }; - std::vector<uint> iCellCFC = { 1, 11, 3, 13, 5, 15, 7 }; - std::vector<uint> iCellCFF = { 2, 12, 4, 14, 6, 16, 8 }; - const uint sizeOfICellCf = (uint)iCellCFC.size(); + std::vector<uint> intCtoFcoarse = { 1, 11, 3, 13, 5, 15, 7 }; + std::vector<uint> fineCellIndices = { 2, 12, 4, 14, 6, 16, 8 }; + const uint sizeOfInterpolationCoarseToFine = (uint)intCtoFcoarse.size(); uint neighborX[17] = { 0u }; uint neighborY[17] = { 0u }; uint neighborZ[17] = { 0u }; const int level = 0; - std::vector<real> offsetCFx = { 1, 11, 3, 13, 5, 15, 7 }; - std::vector<real> offsetCFy = { 101, 111, 103, 113, 105, 115, 107 }; - std::vector<real> offsetCFz = { 1001, 1011, 1003, 1013, 1005, 1015, 1007 }; + std::vector<real> neighborCFx = { 1, 11, 3, 13, 5, 15, 7 }; + std::vector<real> neighborCFy = { 101, 111, 103, 113, 105, 115, 107 }; + std::vector<real> neighborCFz = { 1001, 1011, 1003, 1013, 1005, 1015, 1007 }; // expected data - std::vector<uint> iCellCfcBorder_expected = { 11, 13, 15 }; - std::vector<uint> iCellCfcBulk_expected = { 1, 3, 5, 7 }; - std::vector<uint> iCellCffBorder_expected = { 12, 14, 16 }; - std::vector<uint> iCellCffBulk_expected = { 2, 4, 6, 8 }; - std::vector<real> offsetCFx_Border_expected = { 11, 13, 15 }; - std::vector<real> offsetCFx_Bulk_expected = { 1, 3, 5, 7 }; - std::vector<real> offsetCFy_Border_expected = { 111, 113, 115 }; - std::vector<real> offsetCFy_Bulk_expected = { 101, 103, 105, 107 }; - std::vector<real> offsetCFz_Border_expected = { 1011, 1013, 1015 }; - std::vector<real> offsetCFz_Bulk_expected = { 1001, 1003, 1005, 1007 }; + std::vector<uint> intCtoFcoarseBorder_expected = { 11, 13, 15 }; + std::vector<uint> intCtoFcoarseBulk_expected = { 1, 3, 5, 7 }; + std::vector<uint> fineCellIndicesBorder_expected = { 12, 14, 16 }; + std::vector<uint> fineCellIndicesBulk_expected = { 2, 4, 6, 8 }; + std::vector<real> neighborCFx_Border_expected = { 11, 13, 15 }; + std::vector<real> neighborCFx_Bulk_expected = { 1, 3, 5, 7 }; + std::vector<real> neighborCFy_Border_expected = { 111, 113, 115 }; + std::vector<real> neighborCFy_Bulk_expected = { 101, 103, 105, 107 }; + std::vector<real> neighborCFz_Border_expected = { 1011, 1013, 1015 }; + std::vector<real> neighborCFz_Bulk_expected = { 1001, 1003, 1005, 1007 }; }; class InterpolationCellGrouperTest_IndicesCFBorderBulkTest : public testing::Test { protected: - CFBorderBulk cf; + CoarseToFineBorderBulk cf; SPtr<Parameter> para; std::unique_ptr<InterpolationCellGrouper> testSubject; @@ -105,15 +105,15 @@ private: std::shared_ptr<LevelGridBuilderDouble> builder = std::make_shared<LevelGridBuilderDouble>(grid); para = testingVF::createParameterForLevel(cf.level); - para->getParH(cf.level)->intCF.ICellCFC = &(cf.iCellCFC.front()); - para->getParH(cf.level)->intCF.ICellCFF = &(cf.iCellCFF.front()); + para->getParH(cf.level)->coarseToFine.coarseCellIndices = &(cf.intCtoFcoarse.front()); + para->getParH(cf.level)->coarseToFine.fineCellIndices = &(cf.fineCellIndices.front()); para->getParH(cf.level)->neighborX = cf.neighborX; para->getParH(cf.level)->neighborY = cf.neighborY; para->getParH(cf.level)->neighborZ = cf.neighborZ; - para->getParH(cf.level)->intCF.kCF = cf.sizeOfICellCf; - para->getParH(cf.level)->offCF.xOffCF = &(cf.offsetCFx.front()); - para->getParH(cf.level)->offCF.yOffCF = &(cf.offsetCFy.front()); - para->getParH(cf.level)->offCF.zOffCF = &(cf.offsetCFz.front()); + para->getParH(cf.level)->coarseToFine.numberOfCells = cf.sizeOfInterpolationCoarseToFine; + para->getParH(cf.level)->neighborCoarseToFine.x = &(cf.neighborCFx.front()); + para->getParH(cf.level)->neighborCoarseToFine.y = &(cf.neighborCFy.front()); + para->getParH(cf.level)->neighborCoarseToFine.z = &(cf.neighborCFz.front()); return std::make_unique<InterpolationCellGrouper>(para->getParHallLevels(), para->getParDallLevels(), builder); }; @@ -128,65 +128,65 @@ TEST_F(InterpolationCellGrouperTest_IndicesCFBorderBulkTest, splitCoarseToFineIn { testSubject->splitCoarseToFineIntoBorderAndBulk(cf.level); - EXPECT_THAT(para->getParH(cf.level)->intCFBorder.kCF + para->getParH(cf.level)->intCFBulk.kCF, - testing::Eq(cf.sizeOfICellCf)) + EXPECT_THAT(para->getParH(cf.level)->coarseToFineBorder.numberOfCells + para->getParH(cf.level)->coarseToFineBulk.numberOfCells, + testing::Eq(cf.sizeOfInterpolationCoarseToFine)) << "The number of interpolation cells from coarse to fine changed during reordering."; // check coarse to fine border (coarse nodes) - EXPECT_THAT(para->getParH(cf.level)->intCFBorder.kCF, testing::Eq((uint)cf.iCellCfcBorder_expected.size())); - EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->intCFBorder.ICellCFC, cf.iCellCfcBorder_expected)) - << "intCFBorder.ICellCFC does not match the expected border vector"; + EXPECT_THAT(para->getParH(cf.level)->coarseToFineBorder.numberOfCells, testing::Eq((uint)cf.intCtoFcoarseBorder_expected.size())); + EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->coarseToFineBorder.coarseCellIndices, cf.intCtoFcoarseBorder_expected)) + << "coarseToFineBorder.intCtoFcoarse does not match the expected border vector"; // check coarse to fine border (fine nodes) - EXPECT_THAT(para->getParH(cf.level)->intCFBorder.kCF, testing::Eq((uint)cf.iCellCffBorder_expected.size())); - EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->intCFBorder.ICellCFF, cf.iCellCffBorder_expected)) - << "intCFBorder.ICellCFF does not match the expected border vector"; + EXPECT_THAT(para->getParH(cf.level)->coarseToFineBorder.numberOfCells, testing::Eq((uint)cf.fineCellIndicesBorder_expected.size())); + EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->coarseToFineBorder.fineCellIndices, cf.fineCellIndicesBorder_expected)) + << "coarseToFineBorder.fineCellIndices does not match the expected border vector"; // check coarse to fine bulk (coarse nodes) - EXPECT_THAT(para->getParH(cf.level)->intCFBulk.kCF, testing::Eq((uint)cf.iCellCfcBulk_expected.size())); - EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->intCFBulk.ICellCFC, cf.iCellCfcBulk_expected)) - << "intCFBulk.ICellCFC does not match the expected bulk vector"; + EXPECT_THAT(para->getParH(cf.level)->coarseToFineBulk.numberOfCells, testing::Eq((uint)cf.intCtoFcoarseBulk_expected.size())); + EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->coarseToFineBulk.coarseCellIndices, cf.intCtoFcoarseBulk_expected)) + << "coarseToFineBulk.intCtoFcoarse does not match the expected bulk vector"; // check coarse to fine bulk (fine nodes) - EXPECT_THAT(para->getParH(cf.level)->intCFBulk.kCF, testing::Eq((uint)cf.iCellCffBulk_expected.size())); - EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->intCFBulk.ICellCFF, cf.iCellCffBulk_expected)) - << "intCFBulk.ICellCFF does not match the expected bulk vector"; - - // check offset cells - EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->offCF.xOffCF, cf.offsetCFx_Border_expected)); - EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->offCFBulk.xOffCF, cf.offsetCFx_Bulk_expected)); - EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->offCF.yOffCF, cf.offsetCFy_Border_expected)); - EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->offCFBulk.yOffCF, cf.offsetCFy_Bulk_expected)); - EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->offCF.zOffCF, cf.offsetCFz_Border_expected)); - EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->offCFBulk.zOffCF, cf.offsetCFz_Bulk_expected)); + EXPECT_THAT(para->getParH(cf.level)->coarseToFineBulk.numberOfCells, testing::Eq((uint)cf.fineCellIndicesBulk_expected.size())); + EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->coarseToFineBulk.fineCellIndices, cf.fineCellIndicesBulk_expected)) + << "coarseToFineBulk.fineCellIndices does not match the expected bulk vector"; + + // check neighbor cells + EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->neighborCoarseToFine.x, cf.neighborCFx_Border_expected)); + EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->neighborCoarseToFineBulk.x, cf.neighborCFx_Bulk_expected)); + EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->neighborCoarseToFine.y, cf.neighborCFy_Border_expected)); + EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->neighborCoarseToFineBulk.y, cf.neighborCFy_Bulk_expected)); + EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->neighborCoarseToFine.z, cf.neighborCFz_Border_expected)); + EXPECT_TRUE(vectorsAreEqual(para->getParH(cf.level)->neighborCoarseToFineBulk.z, cf.neighborCFz_Bulk_expected)); } -struct FCBorderBulk { +struct FineToCoarseBorderBulk { // data to work on std::vector<uint> fluidNodeIndicesBorder = { 110, 111, 112, 113, 114, 115, 116 }; - std::vector<uint> iCellFCC = { 11, 111, 13, 113, 15, 115, 17 }; - std::vector<uint> iCellFCF = { 12, 112, 14, 114, 16, 116, 18 }; - const uint sizeOfICellFC = (uint)iCellFCC.size(); + std::vector<uint> coarseCellIndices = { 11, 111, 13, 113, 15, 115, 17 }; + std::vector<uint> fineCellIndices = { 12, 112, 14, 114, 16, 116, 18 }; + const uint sizeOfIntFineToCoarse = (uint)coarseCellIndices.size(); const int level = 1; - std::vector<real> offsetFCx = { 11, 111, 13, 113, 15, 115, 17 }; - std::vector<real> offsetFCy = { 1101, 1111, 1103, 1113, 1105, 1115, 1107 }; - std::vector<real> offsetFCz = { 11001, 11011, 11003, 11013, 11005, 11015, 11007 }; + std::vector<real> neighborx = { 11, 111, 13, 113, 15, 115, 17 }; + std::vector<real> neighbory = { 1101, 1111, 1103, 1113, 1105, 1115, 1107 }; + std::vector<real> neighborz = { 11001, 11011, 11003, 11013, 11005, 11015, 11007 }; // expected data - std::vector<uint> iCellFccBorder_expected = { 111, 113, 115 }; - std::vector<uint> iCellFccBulk_expected = { 11, 13, 15, 17 }; - std::vector<uint> iCellFcfBorder_expected = { 112, 114, 116 }; - std::vector<uint> iCellFcfBulk_expected = { 12, 14, 16, 18 }; - std::vector<real> offsetFCx_Border_expected = { 111, 113, 115 }; - std::vector<real> offsetFCx_Bulk_expected = { 11, 13, 15, 17 }; - std::vector<real> offsetFCy_Border_expected = { 1111, 1113, 1115 }; - std::vector<real> offsetFCy_Bulk_expected = { 1101, 1103, 1105, 1107 }; - std::vector<real> offsetFCz_Border_expected = { 11011, 11013, 11015 }; - std::vector<real> offsetFCz_Bulk_expected = { 11001, 11003, 11005, 11007 }; + std::vector<uint> coarseCellIndicesBorder_expected = { 111, 113, 115 }; + std::vector<uint> coarseCellIndicesBulk_expected = { 11, 13, 15, 17 }; + std::vector<uint> fineCellIndicesBorder_expected = { 112, 114, 116 }; + std::vector<uint> fineCellIndicesBulk_expected = { 12, 14, 16, 18 }; + std::vector<real> neighborx_Border_expected = { 111, 113, 115 }; + std::vector<real> neighborx_Bulk_expected = { 11, 13, 15, 17 }; + std::vector<real> neighbory_Border_expected = { 1111, 1113, 1115 }; + std::vector<real> neighbory_Bulk_expected = { 1101, 1103, 1105, 1107 }; + std::vector<real> neighborz_Border_expected = { 11011, 11013, 11015 }; + std::vector<real> neighborz_Bulk_expected = { 11001, 11003, 11005, 11007 }; }; class InterpolationCellGrouperTest_IndicesFCBorderBulkTest : public testing::Test { protected: - FCBorderBulk fc; + FineToCoarseBorderBulk fc; SPtr<Parameter> para; std::unique_ptr<InterpolationCellGrouper> testSubject; @@ -199,12 +199,12 @@ private: std::shared_ptr<LevelGridBuilderDouble> builder = std::make_shared<LevelGridBuilderDouble>(grid); para = testingVF::createParameterForLevel(fc.level); - para->getParH(fc.level)->intFC.ICellFCC = &(fc.iCellFCC.front()); - para->getParH(fc.level)->intFC.ICellFCF = &(fc.iCellFCF.front()); - para->getParH(fc.level)->intFC.kFC = fc.sizeOfICellFC; - para->getParH(fc.level)->offFC.xOffFC = &(fc.offsetFCx.front()); - para->getParH(fc.level)->offFC.yOffFC = &(fc.offsetFCy.front()); - para->getParH(fc.level)->offFC.zOffFC = &(fc.offsetFCz.front()); + para->getParH(fc.level)->fineToCoarse.coarseCellIndices = &(fc.coarseCellIndices.front()); + para->getParH(fc.level)->fineToCoarse.fineCellIndices = &(fc.fineCellIndices.front()); + para->getParH(fc.level)->fineToCoarse.numberOfCells = fc.sizeOfIntFineToCoarse; + para->getParH(fc.level)->neighborFineToCoarse.x = &(fc.neighborx.front()); + para->getParH(fc.level)->neighborFineToCoarse.y = &(fc.neighbory.front()); + para->getParH(fc.level)->neighborFineToCoarse.z = &(fc.neighborz.front()); return std::make_unique<InterpolationCellGrouper>(para->getParHallLevels(), para->getParDallLevels(), builder); }; @@ -219,33 +219,33 @@ TEST_F(InterpolationCellGrouperTest_IndicesFCBorderBulkTest, splitFineToCoarseIn { testSubject->splitFineToCoarseIntoBorderAndBulk(fc.level); - EXPECT_THAT(para->getParH(fc.level)->intFCBorder.kFC + para->getParH(fc.level)->intFCBulk.kFC, - testing::Eq(fc.sizeOfICellFC)) + EXPECT_THAT(para->getParH(fc.level)->fineToCoarseBorder.numberOfCells + para->getParH(fc.level)->fineToCoarseBulk.numberOfCells, + testing::Eq(fc.sizeOfIntFineToCoarse)) << "The number of interpolation cells from coarse to fine changed during reordering."; // check coarse to fine border (coarse nodes) - EXPECT_THAT(para->getParH(fc.level)->intFCBorder.kFC, testing::Eq((uint)fc.iCellFccBorder_expected.size())); - EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->intFCBorder.ICellFCC, fc.iCellFccBorder_expected)) - << "intFCBorder.ICellFCC does not match the expected border vector"; + EXPECT_THAT(para->getParH(fc.level)->fineToCoarseBorder.numberOfCells, testing::Eq((uint)fc.coarseCellIndicesBorder_expected.size())); + EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->fineToCoarseBorder.coarseCellIndices, fc.coarseCellIndicesBorder_expected)) + << "fineToCoarseBorder.coarseCellIndices does not match the expected border vector"; // check coarse to fine border (fine nodes) - EXPECT_THAT(para->getParH(fc.level)->intFCBorder.kFC, testing::Eq((uint)fc.iCellFcfBorder_expected.size())); - EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->intFCBorder.ICellFCF, fc.iCellFcfBorder_expected)) - << "intFCBorder.ICellFCF does not match the expected border vector"; + EXPECT_THAT(para->getParH(fc.level)->fineToCoarseBorder.numberOfCells, testing::Eq((uint)fc.fineCellIndicesBorder_expected.size())); + EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->fineToCoarseBorder.fineCellIndices, fc.fineCellIndicesBorder_expected)) + << "fineToCoarseBorder.fineCellIndices does not match the expected border vector"; // check coarse to fine bulk (coarse nodes) - EXPECT_THAT(para->getParH(fc.level)->intFCBulk.kFC, testing::Eq((uint)fc.iCellFccBulk_expected.size())); - EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->intFCBulk.ICellFCC, fc.iCellFccBulk_expected)) - << "intFCBulk.ICellFCC does not match the expected bulk vector"; + EXPECT_THAT(para->getParH(fc.level)->fineToCoarseBulk.numberOfCells, testing::Eq((uint)fc.coarseCellIndicesBulk_expected.size())); + EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->fineToCoarseBulk.coarseCellIndices, fc.coarseCellIndicesBulk_expected)) + << "fineToCoarseBulk.coarseCellIndices does not match the expected bulk vector"; // check coarse to fine bulk (fine nodes) - EXPECT_THAT(para->getParH(fc.level)->intFCBulk.kFC, testing::Eq((uint)fc.iCellFcfBulk_expected.size())); - EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->intFCBulk.ICellFCF, fc.iCellFcfBulk_expected)) - << "intFCBulk.ICellFCF does not match the expected bulk vector"; - - // check offset cells - EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->offFC.xOffFC, fc.offsetFCx_Border_expected)); - EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->offFCBulk.xOffFC, fc.offsetFCx_Bulk_expected)); - EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->offFC.yOffFC, fc.offsetFCy_Border_expected)); - EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->offFCBulk.yOffFC, fc.offsetFCy_Bulk_expected)); - EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->offFC.zOffFC, fc.offsetFCz_Border_expected)); - EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->offFCBulk.zOffFC, fc.offsetFCz_Bulk_expected)); + EXPECT_THAT(para->getParH(fc.level)->fineToCoarseBulk.numberOfCells, testing::Eq((uint)fc.fineCellIndicesBulk_expected.size())); + EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->fineToCoarseBulk.fineCellIndices, fc.fineCellIndicesBulk_expected)) + << "fineToCoarseBulk.fineCellIndices does not match the expected bulk vector"; + + // check neighbor cells + EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->neighborFineToCoarse.x, fc.neighborx_Border_expected)); + EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->neighborFineToCoarseBulk.x, fc.neighborx_Bulk_expected)); + EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->neighborFineToCoarse.y, fc.neighbory_Border_expected)); + EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->neighborFineToCoarseBulk.y, fc.neighbory_Bulk_expected)); + EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->neighborFineToCoarse.z, fc.neighborz_Border_expected)); + EXPECT_TRUE(vectorsAreEqual(para->getParH(fc.level)->neighborFineToCoarseBulk.z, fc.neighborz_Bulk_expected)); } diff --git a/src/gpu/VirtualFluids_GPU/Factories/GridScalingFactory.cpp b/src/gpu/VirtualFluids_GPU/Factories/GridScalingFactory.cpp index 49a6887ef2e462aba190023d334caa0012e2254e..297e2ac9c05fd225811f40439a26e0b3b4ce4811 100644 --- a/src/gpu/VirtualFluids_GPU/Factories/GridScalingFactory.cpp +++ b/src/gpu/VirtualFluids_GPU/Factories/GridScalingFactory.cpp @@ -3,13 +3,13 @@ void GridScalingFactory::setScalingFactory(const GridScalingFactory::GridScaling gridScalingType) { - this->gridScaling = gridScalingType; + this->gridScalingType = gridScalingType; } -gridScalingFC GridScalingFactory::getGridScalingFC(bool hasTurbulentViscosity) const +gridScaling GridScalingFactory::getGridScalingFC(bool hasTurbulentViscosity) const { // for descriptions of the scaling types refer to the header - switch (gridScaling) { + switch (gridScalingType) { case GridScaling::ScaleRhoSq: return ScaleFC_RhoSq_comp_27; break; @@ -22,10 +22,10 @@ gridScalingFC GridScalingFactory::getGridScalingFC(bool hasTurbulentViscosity) c } } -gridScalingCF GridScalingFactory::getGridScalingCF(bool hasTurbulentViscosity) const +gridScaling GridScalingFactory::getGridScalingCF(bool hasTurbulentViscosity) const { // for descriptions of the scaling types refer to the header - switch (gridScaling) { + switch (gridScalingType) { case GridScaling::ScaleRhoSq: return ScaleCF_RhoSq_comp_27; break; diff --git a/src/gpu/VirtualFluids_GPU/Factories/GridScalingFactory.h b/src/gpu/VirtualFluids_GPU/Factories/GridScalingFactory.h index d760240c2c5ed429799cd89e57704464515a92f5..f8729b0ed9df784eb8d409b6ea97a0ab0f9cbb5a 100644 --- a/src/gpu/VirtualFluids_GPU/Factories/GridScalingFactory.h +++ b/src/gpu/VirtualFluids_GPU/Factories/GridScalingFactory.h @@ -42,8 +42,7 @@ struct LBMSimulationParameter; class Parameter; struct CUstream_st; -using gridScalingFC = std::function<void(LBMSimulationParameter *, LBMSimulationParameter *, ICellFC *, OffFC&, CUstream_st *stream)>; -using gridScalingCF = std::function<void(LBMSimulationParameter *, LBMSimulationParameter *, ICellCF *, OffCF&, CUstream_st *stream)>; +using gridScaling = std::function<void(LBMSimulationParameter *, LBMSimulationParameter *, ICells *, ICellNeigh&, CUstream_st *stream)>; class GridScalingFactory { @@ -59,11 +58,11 @@ public: void setScalingFactory(const GridScalingFactory::GridScaling gridScalingType); - [[nodiscard]] gridScalingFC getGridScalingFC(bool hasTurbulentViscosity) const; - [[nodiscard]] gridScalingCF getGridScalingCF(bool hasTurbulentViscosity) const; + [[nodiscard]] gridScaling getGridScalingFC(bool hasTurbulentViscosity) const; + [[nodiscard]] gridScaling getGridScalingCF(bool hasTurbulentViscosity) const; private: - GridScaling gridScaling = GridScaling::NotSpecified; + GridScaling gridScalingType = GridScaling::NotSpecified; }; #endif diff --git a/src/gpu/VirtualFluids_GPU/FindInterface/FindInterface.cpp b/src/gpu/VirtualFluids_GPU/FindInterface/FindInterface.cpp index ec435f0647ba973dbb405aefad069b285e09d6b5..9a0eae2282ca0abf11c77e6e8503c2a5b2bcc0b7 100644 --- a/src/gpu/VirtualFluids_GPU/FindInterface/FindInterface.cpp +++ b/src/gpu/VirtualFluids_GPU/FindInterface/FindInterface.cpp @@ -1,11 +1,11 @@ #include "FindInterface/FindInterface.h" -void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, +void interpolation(InterpolationCells &intCF, InterpolationCells &intFC, unsigned int LxCoarse, unsigned int LyCoarse, unsigned int LzCoarse, unsigned int LxFine, unsigned int LyFine, unsigned int LzFine, unsigned int dNx, unsigned int dNy, unsigned int dNz, unsigned int *kCoarse, unsigned int *kFine, bool* needInterface, - OffsetCF &offCF, OffsetFC &offFC) + InterpolationCellNeighbor &offCF, InterpolationCellNeighbor &offFC) { unsigned int iC,iF,jC,jF,hC,hF; unsigned int posCSWB, posFSWB; @@ -13,8 +13,8 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, real xOff = (real)0.0f; real yOff = (real)0.0f; real zOff = (real)0.0f; - intCF.kCF = 0; - intFC.kFC = 0; + intCF.numberOfCells = 0; + intFC.numberOfCells = 0; /////////////////////////////////////////////////////////////////////////// //Defines @@ -125,12 +125,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } } ////////////////////////// fine->coarse //////////////////////////// @@ -142,12 +142,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -166,12 +166,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } } ////////////////////////// fine->coarse //////////////////////////// @@ -183,12 +183,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -207,12 +207,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } } ////////////////////////// fine->coarse //////////////////////////// @@ -224,12 +224,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -248,12 +248,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } } ////////////////////////// fine->coarse //////////////////////////// @@ -265,12 +265,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -289,12 +289,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } } ////////////////////////// fine->coarse //////////////////////////// @@ -306,12 +306,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] =xOff; - offFC.yOffFC[intFC.kFC] =yOff; - offFC.zOffFC[intFC.kFC] =zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] =xOff; + offFC.y[intFC.numberOfCells] =yOff; + offFC.z[intFC.numberOfCells] =zOff; + intFC.numberOfCells++; } } } @@ -330,12 +330,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } } ////////////////////////// fine->coarse //////////////////////////// @@ -347,12 +347,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -401,12 +401,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } ////////////////////////////////////////////////////////////////////////// @@ -427,12 +427,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_E]==false) { @@ -443,12 +443,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } else if (needInterface[INTERFACE_N]==false) @@ -460,12 +460,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -506,12 +506,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } ////////////////////////////////////////////////////////////////////////// @@ -532,12 +532,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_E]==false) { @@ -548,12 +548,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } else if (needInterface[INTERFACE_S]==false) @@ -565,12 +565,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -611,12 +611,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } ////////////////////////////////////////////////////////////////////////// @@ -637,12 +637,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_E]==false) { @@ -653,12 +653,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } else if (needInterface[INTERFACE_T]==false) @@ -670,12 +670,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -716,12 +716,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } ////////////////////////////////////////////////////////////////////////// @@ -742,12 +742,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_E]==false) { @@ -758,12 +758,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } else if (needInterface[INTERFACE_B]==false) @@ -775,12 +775,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -821,12 +821,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } ////////////////////////////////////////////////////////////////////////// @@ -847,12 +847,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_W]==false) { @@ -863,12 +863,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } else if (needInterface[INTERFACE_N]==false) @@ -880,12 +880,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -926,12 +926,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } ////////////////////////////////////////////////////////////////////////// @@ -952,12 +952,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_W]==false) { @@ -968,12 +968,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } else if (needInterface[INTERFACE_S]==false) @@ -985,12 +985,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -1031,12 +1031,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } ////////////////////////////////////////////////////////////////////////// @@ -1057,12 +1057,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_W]==false) { @@ -1073,12 +1073,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } else if (needInterface[INTERFACE_T]==false) @@ -1090,12 +1090,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -1136,12 +1136,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } ////////////////////////////////////////////////////////////////////////// @@ -1162,12 +1162,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_W]==false) { @@ -1178,12 +1178,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } else if (needInterface[INTERFACE_B]==false) @@ -1195,12 +1195,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -1241,12 +1241,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } ////////////////////////////////////////////////////////////////////////// @@ -1267,12 +1267,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[ INTERFACE_N]==false) { @@ -1283,12 +1283,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } else if (needInterface[ INTERFACE_T]==false) @@ -1300,12 +1300,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -1346,12 +1346,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } ////////////////////////////////////////////////////////////////////////// @@ -1372,12 +1372,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[ INTERFACE_N]==false) { @@ -1388,12 +1388,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } else if (needInterface[ INTERFACE_B]==false) @@ -1405,12 +1405,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -1451,12 +1451,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } ////////////////////////////////////////////////////////////////////////// @@ -1477,12 +1477,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[ INTERFACE_S]==false) { @@ -1493,12 +1493,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } else if (needInterface[ INTERFACE_T]==false) @@ -1510,12 +1510,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -1556,12 +1556,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; } ////////////////////////////////////////////////////////////////////////// @@ -1582,12 +1582,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[ INTERFACE_S]==false) { @@ -1598,12 +1598,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } else if (needInterface[ INTERFACE_B]==false) @@ -1615,12 +1615,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, { posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } } @@ -1665,12 +1665,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, ////////////////////////////////////////////////////////////////////////// posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; ////////////////////////////////////////////////////////////////////////// @@ -1691,12 +1691,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; if (needInterface[INTERFACE_E]==false) { @@ -1706,12 +1706,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_N]==false) { @@ -1721,12 +1721,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_T]==false) { @@ -1736,12 +1736,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_E]==false) && (needInterface[INTERFACE_N]==false)) { @@ -1751,12 +1751,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_E]==false) && (needInterface[INTERFACE_T]==false)) { @@ -1766,12 +1766,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_N]==false) && (needInterface[INTERFACE_T]==false)) { @@ -1781,12 +1781,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } @@ -1822,12 +1822,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, ////////////////////////////////////////////////////////////////////////// posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; ////////////////////////////////////////////////////////////////////////// @@ -1848,12 +1848,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; if (needInterface[INTERFACE_E]==false) { @@ -1863,12 +1863,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_N]==false) { @@ -1878,12 +1878,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_B]==false) { @@ -1893,12 +1893,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_E]==false) && (needInterface[INTERFACE_N]==false)) { @@ -1908,12 +1908,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_E]==false) && (needInterface[INTERFACE_B]==false)) { @@ -1923,12 +1923,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_N]==false) && (needInterface[INTERFACE_B]==false)) { @@ -1938,12 +1938,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } @@ -1979,12 +1979,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, ////////////////////////////////////////////////////////////////////////// posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; ////////////////////////////////////////////////////////////////////////// @@ -2005,12 +2005,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; if (needInterface[INTERFACE_E]==false) { @@ -2020,12 +2020,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_S]==false) { @@ -2035,12 +2035,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_T]==false) { @@ -2050,12 +2050,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_E]==false) && (needInterface[INTERFACE_S]==false)) { @@ -2065,12 +2065,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_E]==false) && (needInterface[INTERFACE_T]==false)) { @@ -2080,12 +2080,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_S]==false) && (needInterface[INTERFACE_T]==false)) { @@ -2095,12 +2095,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } @@ -2136,12 +2136,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, ////////////////////////////////////////////////////////////////////////// posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; ////////////////////////////////////////////////////////////////////////// @@ -2162,12 +2162,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; if (needInterface[INTERFACE_E]==false) { @@ -2177,12 +2177,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_S]==false) { @@ -2192,12 +2192,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_B]==false) { @@ -2207,12 +2207,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_E]==false) && (needInterface[INTERFACE_S]==false)) { @@ -2222,12 +2222,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_E]==false) && (needInterface[INTERFACE_B]==false)) { @@ -2237,12 +2237,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_S]==false) && (needInterface[INTERFACE_B]==false)) { @@ -2252,12 +2252,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } @@ -2293,12 +2293,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, ////////////////////////////////////////////////////////////////////////// posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; ////////////////////////////////////////////////////////////////////////// @@ -2319,12 +2319,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; if (needInterface[INTERFACE_W]==false) { @@ -2334,12 +2334,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_N]==false) { @@ -2349,12 +2349,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_T]==false) { @@ -2364,12 +2364,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_W]==false) && (needInterface[INTERFACE_N]==false)) { @@ -2379,12 +2379,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_W]==false) && (needInterface[INTERFACE_T]==false)) { @@ -2394,12 +2394,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_N]==false) && (needInterface[INTERFACE_T]==false)) { @@ -2409,12 +2409,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } @@ -2450,12 +2450,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, ////////////////////////////////////////////////////////////////////////// posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; ////////////////////////////////////////////////////////////////////////// @@ -2476,12 +2476,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; if (needInterface[INTERFACE_W]==false) { @@ -2491,12 +2491,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_N]==false) { @@ -2506,12 +2506,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_B]==false) { @@ -2521,12 +2521,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_W]==false) && (needInterface[INTERFACE_N]==false)) { @@ -2536,12 +2536,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_W]==false) && (needInterface[INTERFACE_B]==false)) { @@ -2551,12 +2551,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_N]==false) && (needInterface[INTERFACE_B]==false)) { @@ -2566,12 +2566,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } @@ -2607,12 +2607,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, ////////////////////////////////////////////////////////////////////////// posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; ////////////////////////////////////////////////////////////////////////// @@ -2633,12 +2633,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; if (needInterface[INTERFACE_W]==false) { @@ -2648,12 +2648,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_S]==false) { @@ -2663,12 +2663,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_T]==false) { @@ -2678,12 +2678,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_W]==false) && (needInterface[INTERFACE_S]==false)) { @@ -2693,12 +2693,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_W]==false) && (needInterface[INTERFACE_T]==false)) { @@ -2708,12 +2708,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_S]==false) && (needInterface[INTERFACE_T]==false)) { @@ -2723,12 +2723,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } @@ -2764,12 +2764,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, ////////////////////////////////////////////////////////////////////////// posCSWB=vectorPosition(iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine , LyFine); - intCF.ICellCFC[intCF.kCF] = kCoarse[posCSWB]; - intCF.ICellCFF[intCF.kCF] = kFine[posFSWB]; - offCF.xOffCF[intCF.kCF] = xOff; - offCF.yOffCF[intCF.kCF] = yOff; - offCF.zOffCF[intCF.kCF] = zOff; - intCF.kCF++; + intCF.coarseCellIndices[intCF.numberOfCells] = kCoarse[posCSWB]; + intCF.fineCellIndices[intCF.numberOfCells] = kFine[posFSWB]; + offCF.x[intCF.numberOfCells] = xOff; + offCF.y[intCF.numberOfCells] = yOff; + offCF.z[intCF.numberOfCells] = zOff; + intCF.numberOfCells++; ////////////////////////////////////////////////////////////////////////// @@ -2790,12 +2790,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; if (needInterface[INTERFACE_W]==false) { @@ -2805,12 +2805,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_S]==false) { @@ -2820,12 +2820,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if (needInterface[INTERFACE_B]==false) { @@ -2835,12 +2835,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_W]==false) && (needInterface[INTERFACE_S]==false)) { @@ -2850,12 +2850,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_W]==false) && (needInterface[INTERFACE_B]==false)) { @@ -2865,12 +2865,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } if ((needInterface[INTERFACE_S]==false) && (needInterface[INTERFACE_B]==false)) { @@ -2880,12 +2880,12 @@ void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, posC=vectorPosition( iC, jC, hC, LxCoarse, LyCoarse); posFSWB=vectorPosition(iF, jF, hF, LxFine, LyFine); - intFC.ICellFCC[intFC.kFC] = kCoarse[posC]; - intFC.ICellFCF[intFC.kFC] = kFine[posFSWB]; - offFC.xOffFC[intFC.kFC] = xOff; - offFC.yOffFC[intFC.kFC] = yOff; - offFC.zOffFC[intFC.kFC] = zOff; - intFC.kFC++; + intFC.coarseCellIndices[intFC.numberOfCells] = kCoarse[posC]; + intFC.fineCellIndices[intFC.numberOfCells] = kFine[posFSWB]; + offFC.x[intFC.numberOfCells] = xOff; + offFC.y[intFC.numberOfCells] = yOff; + offFC.z[intFC.numberOfCells] = zOff; + intFC.numberOfCells++; } } diff --git a/src/gpu/VirtualFluids_GPU/FindInterface/FindInterface.h b/src/gpu/VirtualFluids_GPU/FindInterface/FindInterface.h index 3be49570b33d99f9517796b33934dee1e2f31221..17e63824f930161656291bf2d7ecc05e23af9161 100644 --- a/src/gpu/VirtualFluids_GPU/FindInterface/FindInterface.h +++ b/src/gpu/VirtualFluids_GPU/FindInterface/FindInterface.h @@ -5,11 +5,11 @@ #include "lbm/constants/D3Q27.h" -void interpolation(InterpolationCellCF &intCF, InterpolationCellFC &intFC, +void interpolation(InterpolationCells &intCF, InterpolationCells &intFC, unsigned int LxCoarse, unsigned int LyCoarse, unsigned int LzCoarse, unsigned int LxFine, unsigned int LyFine, unsigned int LzFine, unsigned int dNx, unsigned int dNy, unsigned int dNz, unsigned int *kCoarse, unsigned int *kFine, bool* needInterface, - OffsetCF &offCF, OffsetFC &offFC); + InterpolationCellNeighbor &offCF, InterpolationCellNeighbor &offFC); #endif diff --git a/src/gpu/VirtualFluids_GPU/FindQ/FindQ.cpp b/src/gpu/VirtualFluids_GPU/FindQ/FindQ.cpp index 19be37ed5324f48627506bb3e2508a9a1b97cf52..bc12456ceb632b3249d8757fe23c811aad6ec541 100644 --- a/src/gpu/VirtualFluids_GPU/FindQ/FindQ.cpp +++ b/src/gpu/VirtualFluids_GPU/FindQ/FindQ.cpp @@ -1,5 +1,5 @@ #include "FindQ/FindQ.h" -#include "logger/Logger.h" +#include <logger/Logger.h> #include "lbm/constants/D3Q27.h" using namespace vf::lbm::dir; diff --git a/src/gpu/VirtualFluids_GPU/GPU/AdvectionDiffusion27chim.cu b/src/gpu/VirtualFluids_GPU/GPU/AdvectionDiffusion27chim.cu index 04f6afe4cf9ebd99dc293ded16f55a56f0d77036..a22e7f6e842fcfb4474e009975eb65f1920513a9 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/AdvectionDiffusion27chim.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/AdvectionDiffusion27chim.cu @@ -34,9 +34,9 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/AdvectionDiffusionBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/AdvectionDiffusionBCs27.cu index 116ce20389985e0efa650598108224b2e3e25221..278d01e149aeb6de5241f5c84463e4e80d360512 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/AdvectionDiffusionBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/AdvectionDiffusionBCs27.cu @@ -2,9 +2,9 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; ////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/CP27.cu b/src/gpu/VirtualFluids_GPU/GPU/CP27.cu index 8d02f4e1c110fc82b65adda4db67976f29796d07..41a50e5dde7dd8e024721653f43652f2e4a17548 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/CP27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/CP27.cu @@ -1,9 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/Calc2ndMoments27.cu b/src/gpu/VirtualFluids_GPU/GPU/Calc2ndMoments27.cu index c41751dc1b5cea53983d94d9cc7c3c75c8a84101..15b8ecefee35463895d8bf5a48cc64868763bf93 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Calc2ndMoments27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Calc2ndMoments27.cu @@ -1,9 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/CalcConc27.cu b/src/gpu/VirtualFluids_GPU/GPU/CalcConc27.cu index ad5a05b12a1b3ae2541e36ccffae4635fccfe62a..0986a42b07351456f684ae5141d38245e5e17c57 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/CalcConc27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/CalcConc27.cu @@ -33,9 +33,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/CalcMac27.cu b/src/gpu/VirtualFluids_GPU/GPU/CalcMac27.cu index f7bb09f816f45973fd4e2319a1bfa35cf9172caa..8907e846757c8923c3aed46f9c90d6c67f465eee 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/CalcMac27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/CalcMac27.cu @@ -32,12 +32,12 @@ //====================================================================================== #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include "lbm/MacroscopicQuantities.h" #include "Kernel/Utilities/DistributionHelper.cuh" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; diff --git a/src/gpu/VirtualFluids_GPU/GPU/Cascade27.cu b/src/gpu/VirtualFluids_GPU/GPU/Cascade27.cu index 457623d4ee62b624248306b6b900fcff3f026286..e05a711015e372b3fc3169bf61bea9965ccf7c12 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Cascade27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Cascade27.cu @@ -1,9 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.cpp b/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.cpp index 9fd2a6b2f5c5c10a36856852db47f989ace714ce..14e090ff3f02eaec87a9f709fc0e0ac8df711189 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.cpp +++ b/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.cpp @@ -13,7 +13,7 @@ #include "Calculation/PorousMedia.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" void CudaMemoryManager::cudaCopyPrint(int lev) @@ -422,9 +422,9 @@ void CudaMemoryManager::cudaAllocLevelForcing(int level) { real fx_t{ 1. }, fy_t{ 1. }, fz_t{ 1. }; for (int i = 0; i < level; i++) { - fx_t *= vf::lbm::constant::c2o1; - fy_t *= vf::lbm::constant::c2o1; - fz_t *= vf::lbm::constant::c2o1; + fx_t *= vf::basics::constant::c2o1; + fy_t *= vf::basics::constant::c2o1; + fz_t *= vf::basics::constant::c2o1; } const unsigned int mem_size = sizeof(real) * 3; @@ -1106,116 +1106,131 @@ void CudaMemoryManager::cudaFreeMedianOut(int lev) //Interface CF void CudaMemoryManager::cudaAllocInterfaceCF(int lev) { + uint mem_size_kCF = sizeof(uint) * parameter->getParH(lev)->coarseToFine.numberOfCells; //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->intCF.ICellCFC), parameter->getParH(lev)->mem_size_kCF )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->intCF.ICellCFF), parameter->getParH(lev)->mem_size_kCF )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->coarseToFine.coarseCellIndices), mem_size_kCF )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->coarseToFine.fineCellIndices), mem_size_kCF )); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->intCF.ICellCFC), parameter->getParD(lev)->mem_size_kCF )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->intCF.ICellCFF), parameter->getParD(lev)->mem_size_kCF )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->coarseToFine.coarseCellIndices), mem_size_kCF )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->coarseToFine.fineCellIndices), mem_size_kCF )); ////////////////////////////////////////////////////////////////////////// - double tmp = 2. * (double)parameter->getParH(lev)->mem_size_kCF; + double tmp = 2. * (double)mem_size_kCF; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyInterfaceCF(int lev) { - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->intCF.ICellCFC, parameter->getParH(lev)->intCF.ICellCFC, parameter->getParH(lev)->mem_size_kCF, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->intCF.ICellCFF, parameter->getParH(lev)->intCF.ICellCFF, parameter->getParH(lev)->mem_size_kCF, cudaMemcpyHostToDevice)); + uint mem_size_kCF = sizeof(uint) * parameter->getParH(lev)->coarseToFine.numberOfCells; + + checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->coarseToFine.coarseCellIndices, parameter->getParH(lev)->coarseToFine.coarseCellIndices, mem_size_kCF, cudaMemcpyHostToDevice)); + checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->coarseToFine.fineCellIndices, parameter->getParH(lev)->coarseToFine.fineCellIndices, mem_size_kCF, cudaMemcpyHostToDevice)); } void CudaMemoryManager::cudaFreeInterfaceCF(int lev) { - checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->intCF.ICellCFC)); - checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->intCF.ICellCFF)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->coarseToFine.coarseCellIndices)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->coarseToFine.fineCellIndices)); } //Interface FC void CudaMemoryManager::cudaAllocInterfaceFC(int lev) { + uint mem_size_kFC = sizeof(uint) * parameter->getParH(lev)->fineToCoarse.numberOfCells; + //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->intFC.ICellFCF), parameter->getParH(lev)->mem_size_kFC )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->intFC.ICellFCC), parameter->getParH(lev)->mem_size_kFC )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->fineToCoarse.fineCellIndices), mem_size_kFC )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->fineToCoarse.coarseCellIndices), mem_size_kFC )); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->intFC.ICellFCF), parameter->getParD(lev)->mem_size_kFC )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->intFC.ICellFCC), parameter->getParD(lev)->mem_size_kFC )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->fineToCoarse.fineCellIndices), mem_size_kFC )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->fineToCoarse.coarseCellIndices), mem_size_kFC )); ////////////////////////////////////////////////////////////////////////// - double tmp = 2. * (double)parameter->getParH(lev)->mem_size_kFC; + double tmp = 2. * (double)mem_size_kFC; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyInterfaceFC(int lev) { - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->intFC.ICellFCF, parameter->getParH(lev)->intFC.ICellFCF, parameter->getParH(lev)->mem_size_kFC, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->intFC.ICellFCC, parameter->getParH(lev)->intFC.ICellFCC, parameter->getParH(lev)->mem_size_kFC, cudaMemcpyHostToDevice)); + uint mem_size_kFC = sizeof(uint) * parameter->getParH(lev)->fineToCoarse.numberOfCells; + + checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->fineToCoarse.fineCellIndices, parameter->getParH(lev)->fineToCoarse.fineCellIndices, mem_size_kFC, cudaMemcpyHostToDevice)); + checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->fineToCoarse.coarseCellIndices, parameter->getParH(lev)->fineToCoarse.coarseCellIndices, mem_size_kFC, cudaMemcpyHostToDevice)); } void CudaMemoryManager::cudaCheckInterfaceFCBulk(int lev) { // only use for testing! - size_t memsize = sizeof(uint) * parameter->getParH(lev)->intFCBulk.kFC; - checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->intFCBulk.ICellFCC, parameter->getParH(lev)->intFCBulk.ICellFCC, memsize, cudaMemcpyDeviceToDevice)); - for (uint i = 0; i < parameter->getParH(lev)->intFCBulk.kFC; i++) - printf("%d %d\n", i, parameter->getParH(lev)->intFCBulk.ICellFCC[i]); + size_t memsize = sizeof(uint) * parameter->getParH(lev)->fineToCoarseBulk.numberOfCells; + checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->fineToCoarseBulk.coarseCellIndices, parameter->getParH(lev)->fineToCoarseBulk.coarseCellIndices, memsize, cudaMemcpyDeviceToDevice)); + for (uint i = 0; i < parameter->getParH(lev)->fineToCoarseBulk.numberOfCells; i++) + printf("%d %d\n", i, parameter->getParH(lev)->fineToCoarseBulk.coarseCellIndices[i]); } void CudaMemoryManager::cudaFreeInterfaceFC(int lev) { - checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->intFC.ICellFCF)); - checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->intFC.ICellFCC)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->fineToCoarse.fineCellIndices)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->fineToCoarse.coarseCellIndices)); } //Interface Offset CF void CudaMemoryManager::cudaAllocInterfaceOffCF(int lev) { + uint mem_size_kCF_off = sizeof(real) * parameter->getParH(lev)->coarseToFine.numberOfCells; + //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->offCF.xOffCF), parameter->getParH(lev)->mem_size_kCF_off )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->offCF.yOffCF), parameter->getParH(lev)->mem_size_kCF_off )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->offCF.zOffCF), parameter->getParH(lev)->mem_size_kCF_off )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->neighborCoarseToFine.x), mem_size_kCF_off )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->neighborCoarseToFine.y), mem_size_kCF_off )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->neighborCoarseToFine.z), mem_size_kCF_off )); getLastCudaError("Allocate host memory"); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->offCF.xOffCF), parameter->getParD(lev)->mem_size_kCF_off )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->offCF.yOffCF), parameter->getParD(lev)->mem_size_kCF_off )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->offCF.zOffCF), parameter->getParD(lev)->mem_size_kCF_off )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->neighborCoarseToFine.x), mem_size_kCF_off )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->neighborCoarseToFine.y), mem_size_kCF_off )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->neighborCoarseToFine.z), mem_size_kCF_off )); getLastCudaError("Allocate device memory"); ////////////////////////////////////////////////////////////////////////// - double tmp = 3. * (double)parameter->getParH(lev)->mem_size_kCF_off; + double tmp = 3. * (double)mem_size_kCF_off; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyInterfaceOffCF(int lev) { - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->offCF.xOffCF, parameter->getParH(lev)->offCF.xOffCF, parameter->getParH(lev)->mem_size_kCF_off, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->offCF.yOffCF, parameter->getParH(lev)->offCF.yOffCF, parameter->getParH(lev)->mem_size_kCF_off, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->offCF.zOffCF, parameter->getParH(lev)->offCF.zOffCF, parameter->getParH(lev)->mem_size_kCF_off, cudaMemcpyHostToDevice)); + uint mem_size_kCF_off = sizeof(real) * parameter->getParH(lev)->coarseToFine.numberOfCells; + + checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->neighborCoarseToFine.x, parameter->getParH(lev)->neighborCoarseToFine.x, mem_size_kCF_off, cudaMemcpyHostToDevice)); + checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->neighborCoarseToFine.y, parameter->getParH(lev)->neighborCoarseToFine.y, mem_size_kCF_off, cudaMemcpyHostToDevice)); + checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->neighborCoarseToFine.z, parameter->getParH(lev)->neighborCoarseToFine.z, mem_size_kCF_off, cudaMemcpyHostToDevice)); getLastCudaError("Copy host memory to device"); } void CudaMemoryManager::cudaFreeInterfaceOffCF(int lev) { - checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->offCF.xOffCF)); - checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->offCF.yOffCF)); - checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->offCF.zOffCF)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->neighborCoarseToFine.x)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->neighborCoarseToFine.y)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->neighborCoarseToFine.z)); } //Interface Offset FC void CudaMemoryManager::cudaAllocInterfaceOffFC(int lev) { + uint mem_size_kFC_off = sizeof(real) * parameter->getParH(lev)->fineToCoarse.numberOfCells; + //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->offFC.xOffFC), parameter->getParH(lev)->mem_size_kFC_off )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->offFC.yOffFC), parameter->getParH(lev)->mem_size_kFC_off )); - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->offFC.zOffFC), parameter->getParH(lev)->mem_size_kFC_off )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->neighborFineToCoarse.x), mem_size_kFC_off )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->neighborFineToCoarse.y), mem_size_kFC_off )); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->neighborFineToCoarse.z), mem_size_kFC_off )); getLastCudaError("Allocate host memory"); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->offFC.xOffFC), parameter->getParD(lev)->mem_size_kFC_off )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->offFC.yOffFC), parameter->getParD(lev)->mem_size_kFC_off )); - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->offFC.zOffFC), parameter->getParD(lev)->mem_size_kFC_off )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->neighborFineToCoarse.x), mem_size_kFC_off )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->neighborFineToCoarse.y), mem_size_kFC_off )); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->neighborFineToCoarse.z), mem_size_kFC_off )); getLastCudaError("Allocate device memory"); ////////////////////////////////////////////////////////////////////////// - double tmp = 3. * (double)parameter->getParH(lev)->mem_size_kFC_off; + double tmp = 3. * (double)mem_size_kFC_off; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyInterfaceOffFC(int lev) { - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->offFC.xOffFC, parameter->getParH(lev)->offFC.xOffFC, parameter->getParH(lev)->mem_size_kFC_off, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->offFC.yOffFC, parameter->getParH(lev)->offFC.yOffFC, parameter->getParH(lev)->mem_size_kFC_off, cudaMemcpyHostToDevice)); - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->offFC.zOffFC, parameter->getParH(lev)->offFC.zOffFC, parameter->getParH(lev)->mem_size_kFC_off, cudaMemcpyHostToDevice)); + uint mem_size_kFC_off = sizeof(real) * parameter->getParH(lev)->fineToCoarse.numberOfCells; + + checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->neighborFineToCoarse.x, parameter->getParH(lev)->neighborFineToCoarse.x, mem_size_kFC_off, cudaMemcpyHostToDevice)); + checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->neighborFineToCoarse.y, parameter->getParH(lev)->neighborFineToCoarse.y, mem_size_kFC_off, cudaMemcpyHostToDevice)); + checkCudaErrors(cudaMemcpy(parameter->getParD(lev)->neighborFineToCoarse.z, parameter->getParH(lev)->neighborFineToCoarse.z, mem_size_kFC_off, cudaMemcpyHostToDevice)); getLastCudaError("Copy host memory to device"); } void CudaMemoryManager::cudaFreeInterfaceOffFC(int lev) { - checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->offFC.xOffFC)); - checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->offFC.yOffFC)); - checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->offFC.zOffFC)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->neighborFineToCoarse.x)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->neighborFineToCoarse.y)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->neighborFineToCoarse.z)); } //Inlet @@ -2519,24 +2534,24 @@ void CudaMemoryManager::cudaFreePorousMedia(PorousMedia* pm, int lev) void CudaMemoryManager::cudaAllocConcentration(int lev) { //Host - checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->Conc), parameter->getParH(lev)->memSizeRealLBnodes)); + checkCudaErrors( cudaMallocHost((void**) &(parameter->getParH(lev)->concentration), parameter->getParH(lev)->memSizeRealLBnodes)); //Device - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->Conc), parameter->getParD(lev)->memSizeRealLBnodes)); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->concentration), parameter->getParD(lev)->memSizeRealLBnodes)); ////////////////////////////////////////////////////////////////////////// double tmp = (double)parameter->getParH(lev)->memSizeRealLBnodes; setMemsizeGPU(tmp, false); } void CudaMemoryManager::cudaCopyConcentrationDeviceToHost(int lev) { - checkCudaErrors( cudaMemcpy(parameter->getParH(lev)->Conc, parameter->getParD(lev)->Conc, parameter->getParH(lev)->memSizeRealLBnodes , cudaMemcpyDeviceToHost)); + checkCudaErrors( cudaMemcpy(parameter->getParH(lev)->concentration, parameter->getParD(lev)->concentration, parameter->getParH(lev)->memSizeRealLBnodes , cudaMemcpyDeviceToHost)); } void CudaMemoryManager::cudaCopyConcentrationHostToDevice(int lev) { - checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->Conc, parameter->getParH(lev)->Conc, parameter->getParH(lev)->memSizeRealLBnodes, cudaMemcpyHostToDevice)); + checkCudaErrors( cudaMemcpy(parameter->getParD(lev)->concentration, parameter->getParH(lev)->concentration, parameter->getParH(lev)->memSizeRealLBnodes, cudaMemcpyHostToDevice)); } void CudaMemoryManager::cudaFreeConcentration(int lev) { - checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->Conc)); + checkCudaErrors( cudaFreeHost(parameter->getParH(lev)->concentration)); } ////////////////////////////////////////////////////////////////////////// void CudaMemoryManager::cudaAllocTempFs(int lev) @@ -2548,7 +2563,7 @@ void CudaMemoryManager::cudaAllocTempFs(int lev) } else if (parameter->getDiffMod() == 27) { - checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->distributionsAD27.f[0]), parameter->getDiffMod()*parameter->getParH(lev)->memSizeRealLBnodes)); + checkCudaErrors( cudaMalloc((void**) &(parameter->getParD(lev)->distributionsAD.f[0]), parameter->getDiffMod()*parameter->getParH(lev)->memSizeRealLBnodes)); } ////////////////////////////////////////////////////////////////////////// double tmp = (double)(parameter->getDiffMod() * parameter->getParH(lev)->memSizeRealLBnodes); @@ -3158,33 +3173,33 @@ void CudaMemoryManager::cudaFreeBladeOrientations(ActuatorFarm* actuatorFarm) void CudaMemoryManager::cudaAllocBladeCoords(ActuatorFarm* actuatorFarm) { - checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeCoordsXH, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeCoordsYH, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeCoordsZH, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeCoordsXH, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeCoordsYH, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeCoordsZH, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeCoordsXDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeCoordsYDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeCoordsZDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeCoordsXDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeCoordsYDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeCoordsZDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeCoordsXDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeCoordsYDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeCoordsZDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeCoordsXDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeCoordsYDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeCoordsZDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); - setMemsizeGPU(6.f*actuatorFarm->getNumberOfNodes(), false); + setMemsizeGPU(6.f*actuatorFarm->getNumberOfGridNodes(), false); } void CudaMemoryManager::cudaCopyBladeCoordsHtoD(ActuatorFarm* actuatorFarm) { - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeCoordsXDCurrentTimestep, actuatorFarm->bladeCoordsXH, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyHostToDevice) ); - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeCoordsYDCurrentTimestep, actuatorFarm->bladeCoordsYH, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyHostToDevice) ); - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeCoordsZDCurrentTimestep, actuatorFarm->bladeCoordsZH, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeCoordsXDCurrentTimestep, actuatorFarm->bladeCoordsXH, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeCoordsYDCurrentTimestep, actuatorFarm->bladeCoordsYH, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeCoordsZDCurrentTimestep, actuatorFarm->bladeCoordsZH, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyHostToDevice) ); } void CudaMemoryManager::cudaCopyBladeCoordsDtoH(ActuatorFarm* actuatorFarm) { - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeCoordsXH, actuatorFarm->bladeCoordsXDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeCoordsYH, actuatorFarm->bladeCoordsYDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeCoordsZH, actuatorFarm->bladeCoordsZDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeCoordsXH, actuatorFarm->bladeCoordsXDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeCoordsYH, actuatorFarm->bladeCoordsYDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeCoordsZH, actuatorFarm->bladeCoordsZDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyDeviceToHost) ); } void CudaMemoryManager::cudaFreeBladeCoords(ActuatorFarm* actuatorFarm) @@ -3204,16 +3219,16 @@ void CudaMemoryManager::cudaFreeBladeCoords(ActuatorFarm* actuatorFarm) void CudaMemoryManager::cudaAllocBladeIndices(ActuatorFarm* actuatorFarm) { - checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeIndicesH, sizeof(uint)*actuatorFarm->getNumberOfNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeIndicesH, sizeof(uint)*actuatorFarm->getNumberOfGridNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeIndicesD, sizeof(uint)*actuatorFarm->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeIndicesD, sizeof(uint)*actuatorFarm->getNumberOfGridNodes()) ); - setMemsizeGPU(sizeof(uint)*actuatorFarm->getNumberOfNodes(), false); + setMemsizeGPU(sizeof(uint)*actuatorFarm->getNumberOfGridNodes(), false); } void CudaMemoryManager::cudaCopyBladeIndicesHtoD(ActuatorFarm* actuatorFarm) { - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeIndicesD, actuatorFarm->bladeIndicesH, sizeof(uint)*actuatorFarm->getNumberOfNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeIndicesD, actuatorFarm->bladeIndicesH, sizeof(uint)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyHostToDevice) ); } void CudaMemoryManager::cudaFreeBladeIndices(ActuatorFarm* actuatorFarm) @@ -3225,33 +3240,33 @@ void CudaMemoryManager::cudaFreeBladeIndices(ActuatorFarm* actuatorFarm) void CudaMemoryManager::cudaAllocBladeVelocities(ActuatorFarm* actuatorFarm) { - checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeVelocitiesXH, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeVelocitiesYH, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeVelocitiesZH, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeVelocitiesXH, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeVelocitiesYH, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeVelocitiesZH, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeVelocitiesXDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeVelocitiesYDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeVelocitiesZDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeVelocitiesXDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeVelocitiesYDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeVelocitiesZDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeVelocitiesXDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeVelocitiesYDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeVelocitiesZDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeVelocitiesXDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeVelocitiesYDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeVelocitiesZDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); - setMemsizeGPU(3.*sizeof(real)*actuatorFarm->getNumberOfNodes(), false); + setMemsizeGPU(3.*sizeof(real)*actuatorFarm->getNumberOfGridNodes(), false); } void CudaMemoryManager::cudaCopyBladeVelocitiesHtoD(ActuatorFarm* actuatorFarm) { - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeVelocitiesXDCurrentTimestep, actuatorFarm->bladeVelocitiesXH, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyHostToDevice) ); - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeVelocitiesYDCurrentTimestep, actuatorFarm->bladeVelocitiesYH, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyHostToDevice) ); - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeVelocitiesZDCurrentTimestep, actuatorFarm->bladeVelocitiesZH, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeVelocitiesXDCurrentTimestep, actuatorFarm->bladeVelocitiesXH, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeVelocitiesYDCurrentTimestep, actuatorFarm->bladeVelocitiesYH, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeVelocitiesZDCurrentTimestep, actuatorFarm->bladeVelocitiesZH, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyHostToDevice) ); } void CudaMemoryManager::cudaCopyBladeVelocitiesDtoH(ActuatorFarm* actuatorFarm) { - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeVelocitiesXH, actuatorFarm->bladeVelocitiesXDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeVelocitiesYH, actuatorFarm->bladeVelocitiesYDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeVelocitiesZH, actuatorFarm->bladeVelocitiesZDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeVelocitiesXH, actuatorFarm->bladeVelocitiesXDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeVelocitiesYH, actuatorFarm->bladeVelocitiesYDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeVelocitiesZH, actuatorFarm->bladeVelocitiesZDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyDeviceToHost) ); } void CudaMemoryManager::cudaFreeBladeVelocities(ActuatorFarm* actuatorFarm) @@ -3271,33 +3286,33 @@ void CudaMemoryManager::cudaFreeBladeVelocities(ActuatorFarm* actuatorFarm) void CudaMemoryManager::cudaAllocBladeForces(ActuatorFarm* actuatorFarm) { - checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeForcesXH, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeForcesYH, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeForcesZH, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeForcesXH, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeForcesYH, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMallocHost((void**) &actuatorFarm->bladeForcesZH, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeForcesXDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeForcesYDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeForcesZDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeForcesXDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeForcesYDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeForcesZDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeForcesXDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeForcesYDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); - checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeForcesZDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeForcesXDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeForcesYDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); + checkCudaErrors( cudaMalloc((void**) &actuatorFarm->bladeForcesZDPreviousTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes()) ); - setMemsizeGPU(3.*sizeof(real)*actuatorFarm->getNumberOfNodes(), false); + setMemsizeGPU(3.*sizeof(real)*actuatorFarm->getNumberOfGridNodes(), false); } void CudaMemoryManager::cudaCopyBladeForcesHtoD(ActuatorFarm* actuatorFarm) { - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeForcesXDCurrentTimestep, actuatorFarm->bladeForcesXH, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyHostToDevice) ); - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeForcesYDCurrentTimestep, actuatorFarm->bladeForcesYH, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyHostToDevice) ); - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeForcesZDCurrentTimestep, actuatorFarm->bladeForcesZH, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeForcesXDCurrentTimestep, actuatorFarm->bladeForcesXH, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeForcesYDCurrentTimestep, actuatorFarm->bladeForcesYH, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyHostToDevice) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeForcesZDCurrentTimestep, actuatorFarm->bladeForcesZH, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyHostToDevice) ); } void CudaMemoryManager::cudaCopyBladeForcesDtoH(ActuatorFarm* actuatorFarm) { - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeForcesXH, actuatorFarm->bladeForcesXDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeForcesYH, actuatorFarm->bladeForcesYDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); - checkCudaErrors( cudaMemcpy(actuatorFarm->bladeForcesZH, actuatorFarm->bladeForcesZDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeForcesXH, actuatorFarm->bladeForcesXDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeForcesYH, actuatorFarm->bladeForcesYDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyDeviceToHost) ); + checkCudaErrors( cudaMemcpy(actuatorFarm->bladeForcesZH, actuatorFarm->bladeForcesZDCurrentTimestep, sizeof(real)*actuatorFarm->getNumberOfGridNodes(), cudaMemcpyDeviceToHost) ); } void CudaMemoryManager::cudaFreeBladeForces(ActuatorFarm* actuatorFarm) diff --git a/src/gpu/VirtualFluids_GPU/GPU/Cumulant27.cu b/src/gpu/VirtualFluids_GPU/GPU/Cumulant27.cu index 553e1f34f7993a42682605b66d53407ede9292fd..59b24df1061af16e79ad35eeceb949e6326407fd 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Cumulant27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Cumulant27.cu @@ -7,11 +7,11 @@ ////////////////////////////////////////////////////////////////////////// /* Device code */ #include "LBM/LB.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include "lbm/constants/D3Q27.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/Cumulant27chim.cu b/src/gpu/VirtualFluids_GPU/GPU/Cumulant27chim.cu index 3706e5f929b50a2a72c107a982525ec3172eb144..2c482c3b0fc368c52cca1e74246c75210131b326 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Cumulant27chim.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Cumulant27chim.cu @@ -33,9 +33,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/GPU/Cumulant_F3_27.cu b/src/gpu/VirtualFluids_GPU/GPU/Cumulant_F3_27.cu index c89c3cfe87560c808d47163b45d512fa0d7e494f..9e0275e7be38b8b56cf71cfa0b8299dc1b49106c 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Cumulant_F3_27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Cumulant_F3_27.cu @@ -8,9 +8,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/GPU/DragLift27.cu b/src/gpu/VirtualFluids_GPU/GPU/DragLift27.cu index 0e3945829725c0614ed4da01d0bae3b99ba2720a..d1fc15a6b7a8f73083b41b926ce58916bdf61b59 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/DragLift27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/DragLift27.cu @@ -1,9 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/EnstrophyAnalyzer.cu b/src/gpu/VirtualFluids_GPU/GPU/EnstrophyAnalyzer.cu index 93879d73a32458d5403fd3fd16e68e0fcea7753d..e447062d292908c02800c4559cc4444476290629 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/EnstrophyAnalyzer.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/EnstrophyAnalyzer.cu @@ -18,9 +18,9 @@ #include "Parameter/Parameter.h" // includes, kernels #include "GPU/GPU_Kernels.cuh" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; __global__ void enstrophyKernel ( real* veloX, real* veloY, real* veloZ, real* rho, uint* neighborX, uint* neighborY, uint* neighborZ, uint* neighborWSB, uint* geo, real* enstrophy, uint* isFluid, unsigned long long numberOfLBnodes ); @@ -325,7 +325,6 @@ EnstrophyAnalyzer::EnstrophyAnalyzer(SPtr<Parameter> para, uint analyzeIter) void EnstrophyAnalyzer::writeToFile( std::string filename ) { - //*logging::out << logging::Logger::INFO_INTERMEDIATE << "EnstrophyAnalyzer::writeToFile( " << filename << " )" << "\n"; std::cout << "EnstrophyAnalyzer::writeToFile( " << filename << " )" << "\n"; std::ofstream file; @@ -338,7 +337,6 @@ void EnstrophyAnalyzer::writeToFile( std::string filename ) file.close(); std::cout << "done!\n"; - //*logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; } diff --git a/src/gpu/VirtualFluids_GPU/GPU/EnstrophyAnalyzer.h b/src/gpu/VirtualFluids_GPU/GPU/EnstrophyAnalyzer.h index 27915f1acdfc9bfecc291442727647dc4abda206..ab5c52e77cd4c028e044bfd6ec4b25b974f80ee2 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/EnstrophyAnalyzer.h +++ b/src/gpu/VirtualFluids_GPU/GPU/EnstrophyAnalyzer.h @@ -7,7 +7,7 @@ #include "PointerDefinitions.h" -#include "Core/DataTypes.h" +#include "DataTypes.h" #include "VirtualFluids_GPU_export.h" class Parameter; diff --git a/src/gpu/VirtualFluids_GPU/GPU/ExchangeData27.cu b/src/gpu/VirtualFluids_GPU/GPU/ExchangeData27.cu index 4ced64c0152bdbbd9752f736e2edca2c51fbc2ff..288ec7ff26bae5b7415e08f4d39aa8cd2ffa4a9b 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/ExchangeData27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/ExchangeData27.cu @@ -1,9 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/GPU_Interface.h b/src/gpu/VirtualFluids_GPU/GPU/GPU_Interface.h index 4a5b7816c1b6591e4193639bcdf71242e77688c0..78e6bf8ecf0588eaf6e216916505ec0cbab6c215 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GPU_Interface.h +++ b/src/gpu/VirtualFluids_GPU/GPU/GPU_Interface.h @@ -811,21 +811,6 @@ void QVeloDevEQ27(unsigned int numberOfThreads, unsigned long long numberOfLBnodes, bool isEvenTimestep); -void QVeloStreetDevEQ27( - uint numberOfThreads, - real* veloXfraction, - real* veloYfraction, - int* naschVelo, - real* DD, - int* naschIndex, - int numberOfStreetNodes, - real velocityRatio, - uint* neighborX, - uint* neighborY, - uint* neighborZ, - uint size_Mat, - bool isEvenTimestep); - void QSlipDev27(LBMSimulationParameter* parameterDevice, QforBoundaryConditions* boundaryCondition); void QSlipDevComp27(LBMSimulationParameter* parameterDevice, QforBoundaryConditions* boundaryCondition); @@ -1353,7 +1338,7 @@ void ScaleCFEff27(real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF); + ICellNeigh neighborCoarseToFine); void ScaleFCEff27(real* DC, real* DF, @@ -1377,7 +1362,7 @@ void ScaleFCEff27(real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC); + ICellNeigh neighborFineToCoarse); void ScaleCFLast27(real* DC, real* DF, @@ -1401,7 +1386,7 @@ void ScaleCFLast27(real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF); + ICellNeigh neighborCoarseToFine); void ScaleFCLast27(real* DC, real* DF, @@ -1425,7 +1410,7 @@ void ScaleFCLast27(real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC); + ICellNeigh neighborFineToCoarse); void ScaleCFpress27(real* DC, real* DF, @@ -1449,7 +1434,7 @@ void ScaleCFpress27(real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF); + ICellNeigh neighborCoarseToFine); void ScaleFCpress27( real* DC, real* DF, @@ -1473,7 +1458,7 @@ void ScaleFCpress27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC); + ICellNeigh neighborFineToCoarse); void ScaleCF_Fix_27(real* DC, real* DF, @@ -1497,7 +1482,7 @@ void ScaleCF_Fix_27(real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF); + ICellNeigh neighborCoarseToFine); void ScaleCF_Fix_comp_27( real* DC, real* DF, @@ -1521,7 +1506,7 @@ void ScaleCF_Fix_comp_27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF); + ICellNeigh neighborCoarseToFine); void ScaleCF_0817_comp_27( real* DC, real* DF, @@ -1545,7 +1530,7 @@ void ScaleCF_0817_comp_27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF, + ICellNeigh neighborCoarseToFine, CUstream_st* stream); void ScaleCF_comp_D3Q27F3_2018( real* DC, @@ -1571,7 +1556,7 @@ void ScaleCF_comp_D3Q27F3_2018( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF); + ICellNeigh neighborCoarseToFine); void ScaleCF_comp_D3Q27F3(real* DC, real* DF, @@ -1596,7 +1581,7 @@ void ScaleCF_comp_D3Q27F3(real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF, + ICellNeigh neighborCoarseToFine, CUstream_st *stream); void ScaleCF_staggered_time_comp_27( real* DC, @@ -1621,11 +1606,11 @@ void ScaleCF_staggered_time_comp_27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF); + ICellNeigh neighborCoarseToFine); -void ScaleCF_RhoSq_comp_27(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICellCF * icellCF, OffCF &offsetCF, CUstream_st *stream); +void ScaleCF_RhoSq_comp_27(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICells * interpolationCellsCoarseToFine, ICellNeigh &neighborCoarseToFine, CUstream_st *stream); -template<bool hasTurbulentViscosity> void ScaleCF_compressible(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICellCF * icellCF, OffCF &offsetCF, CUstream_st *stream); +template<bool hasTurbulentViscosity> void ScaleCF_compressible(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICells * interpolationCellsCoarseToFine, ICellNeigh &neighborCoarseToFine, CUstream_st *stream); void ScaleCF_RhoSq_3rdMom_comp_27( real* DC, real* DF, @@ -1649,7 +1634,7 @@ void ScaleCF_RhoSq_3rdMom_comp_27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF, + ICellNeigh neighborCoarseToFine, CUstream_st *stream); void ScaleCF_AA2016_comp_27( real* DC, @@ -1674,7 +1659,7 @@ void ScaleCF_AA2016_comp_27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF, + ICellNeigh neighborCoarseToFine, CUstream_st *stream); void ScaleCF_NSPress_27(real* DC, @@ -1699,7 +1684,7 @@ void ScaleCF_NSPress_27(real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF); + ICellNeigh neighborCoarseToFine); void ScaleFC_Fix_27( real* DC, real* DF, @@ -1723,7 +1708,7 @@ void ScaleFC_Fix_27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC); + ICellNeigh neighborFineToCoarse); void ScaleFC_Fix_comp_27( real* DC, real* DF, @@ -1747,7 +1732,7 @@ void ScaleFC_Fix_comp_27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC); + ICellNeigh neighborFineToCoarse); void ScaleFC_0817_comp_27( real* DC, real* DF, @@ -1771,7 +1756,7 @@ void ScaleFC_0817_comp_27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC, + ICellNeigh neighborFineToCoarse, CUstream_st *stream); void ScaleFC_comp_D3Q27F3_2018(real* DC, @@ -1797,7 +1782,7 @@ void ScaleFC_comp_D3Q27F3_2018(real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC); + ICellNeigh neighborFineToCoarse); void ScaleFC_comp_D3Q27F3( real* DC, real* DF, @@ -1822,7 +1807,7 @@ void ScaleFC_comp_D3Q27F3( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC, + ICellNeigh neighborFineToCoarse, CUstream_st *stream); void ScaleFC_staggered_time_comp_27( real* DC, @@ -1847,11 +1832,11 @@ void ScaleFC_staggered_time_comp_27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC); + ICellNeigh neighborFineToCoarse); -void ScaleFC_RhoSq_comp_27(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICellFC * icellFC, OffFC& offsetFC, CUstream_st *stream); +void ScaleFC_RhoSq_comp_27(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICells * interpolationCellsFineToCoarse, ICellNeigh& neighborFineToCoarse, CUstream_st *stream); -template<bool hasTurbulentViscosity> void ScaleFC_compressible(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICellFC * icellFC, OffFC& offsetFC, CUstream_st *stream); +template<bool hasTurbulentViscosity> void ScaleFC_compressible(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICells * icellFC, ICellNeigh& neighborFineToCoarse, CUstream_st *stream); void ScaleFC_RhoSq_3rdMom_comp_27( real* DC, real* DF, @@ -1875,7 +1860,7 @@ void ScaleFC_RhoSq_3rdMom_comp_27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC, + ICellNeigh neighborFineToCoarse, CUstream_st *stream); void ScaleFC_AA2016_comp_27( real* DC, @@ -1900,7 +1885,7 @@ void ScaleFC_AA2016_comp_27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC, + ICellNeigh neighborFineToCoarse, CUstream_st *stream); void ScaleFC_NSPress_27( real* DC, @@ -1925,7 +1910,7 @@ void ScaleFC_NSPress_27( real* DC, unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC); + ICellNeigh neighborFineToCoarse); void ScaleCFThS7( real* DC, real* DF, @@ -1986,7 +1971,7 @@ void ScaleCFThSMG7( real* DC, real nu, real diffusivity_fine, unsigned int numberOfThreads, - OffCF offCF); + ICellNeigh neighborCoarseToFine); void ScaleFCThSMG7(real* DC, real* DF, @@ -2007,7 +1992,7 @@ void ScaleFCThSMG7(real* DC, real nu, real diffusivity_coarse, unsigned int numberOfThreads, - OffFC offFC); + ICellNeigh neighborFineToCoarse); void ScaleCFThS27( real* DC, real* DF, @@ -2028,7 +2013,7 @@ void ScaleCFThS27( real* DC, real nu, real diffusivity_fine, unsigned int numberOfThreads, - OffCF offCF); + ICellNeigh neighborCoarseToFine); void ScaleFCThS27( real* DC, real* DF, @@ -2049,7 +2034,7 @@ void ScaleFCThS27( real* DC, real nu, real diffusivity_coarse, unsigned int numberOfThreads, - OffFC offFC); + ICellNeigh neighborFineToCoarse); void DragLiftPostD27(real* DD, int* k_Q, diff --git a/src/gpu/VirtualFluids_GPU/GPU/GPU_Kernels.cuh b/src/gpu/VirtualFluids_GPU/GPU/GPU_Kernels.cuh index 0c3c7fcefc2bbb7bc87d7d95863c8c74f14735a3..877390c822b4828b0007249be524d2534a2482f0 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GPU_Kernels.cuh +++ b/src/gpu/VirtualFluids_GPU/GPU/GPU_Kernels.cuh @@ -845,20 +845,6 @@ __global__ void QVeloDeviceEQ27(real* VeloX, unsigned long long numberOfLBnodes, bool isEvenTimestep); -__global__ void QVeloStreetDeviceEQ27( - real* veloXfraction, - real* veloYfraction, - int* naschVelo, - real* DD, - int* naschIndex, - int numberOfStreetNodes, - real velocityRatio, - uint* neighborX, - uint* neighborY, - uint* neighborZ, - unsigned long long numberOfLBnodes, - bool isEvenTimestep); - //Slip BCs __global__ void QSlipDevice27(real* DD, int* k_Q, @@ -1648,7 +1634,7 @@ __global__ void scaleCFEff27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCFLast27( real* DC, real* DF, @@ -1671,7 +1657,7 @@ __global__ void scaleCFLast27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCFpress27(real* DC, real* DF, @@ -1694,7 +1680,7 @@ __global__ void scaleCFpress27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCF_Fix_27(real* DC, real* DF, @@ -1717,7 +1703,7 @@ __global__ void scaleCF_Fix_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCF_Fix_comp_27( real* DC, real* DF, @@ -1740,7 +1726,7 @@ __global__ void scaleCF_Fix_comp_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCF_0817_comp_27( real* DC, real* DF, @@ -1763,7 +1749,7 @@ __global__ void scaleCF_0817_comp_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCF_comp_D3Q27F3_2018( real* DC, real* DF, @@ -1787,7 +1773,7 @@ __global__ void scaleCF_comp_D3Q27F3_2018( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCF_comp_D3Q27F3( real* DC, real* DF, @@ -1811,7 +1797,7 @@ __global__ void scaleCF_comp_D3Q27F3( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCF_staggered_time_comp_27(real* DC, @@ -1835,7 +1821,7 @@ __global__ void scaleCF_staggered_time_comp_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCF_RhoSq_comp_27( real* DC, real* DF, @@ -1858,7 +1844,7 @@ __global__ void scaleCF_RhoSq_comp_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); template<bool hasTurbulentViscosity> __global__ void scaleCF_compressible( real* distributionsCoarse, @@ -1879,7 +1865,7 @@ template<bool hasTurbulentViscosity> __global__ void scaleCF_compressible( real omegaFine, real* turbulentViscosityCoarse, real* turbulentViscosityFine, - OffCF offsetCF); + ICellNeigh offsetCF); __global__ void scaleCF_RhoSq_3rdMom_comp_27(real* DC, real* DF, @@ -1902,7 +1888,7 @@ __global__ void scaleCF_RhoSq_3rdMom_comp_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCF_AA2016_comp_27(real* DC, real* DF, @@ -1925,7 +1911,7 @@ __global__ void scaleCF_AA2016_comp_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCF_NSPress_27(real* DC, real* DF, @@ -1948,7 +1934,7 @@ __global__ void scaleCF_NSPress_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCFThSMG7( real* DC, real* DF, @@ -1968,7 +1954,7 @@ __global__ void scaleCFThSMG7( real* DC, unsigned int kCF, real nu, real diffusivity_fine, - OffCF offCF); + ICellNeigh neighborCoarseToFine); __global__ void scaleCFThS7(real* DC, real* DF, @@ -2007,7 +1993,7 @@ __global__ void scaleCFThS27(real* DC, unsigned int kCF, real nu, real diffusivity_fine, - OffCF offCF); + ICellNeigh neighborCoarseToFine); //fine to coarse __global__ void scaleFC27(real* DC, @@ -2053,7 +2039,7 @@ __global__ void scaleFCEff27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFCLast27( real* DC, real* DF, @@ -2076,7 +2062,7 @@ __global__ void scaleFCLast27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFCpress27( real* DC, real* DF, @@ -2099,7 +2085,7 @@ __global__ void scaleFCpress27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFC_Fix_27( real* DC, real* DF, @@ -2122,7 +2108,7 @@ __global__ void scaleFC_Fix_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFC_Fix_comp_27( real* DC, real* DF, @@ -2145,7 +2131,7 @@ __global__ void scaleFC_Fix_comp_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFC_0817_comp_27( real* DC, real* DF, @@ -2168,7 +2154,7 @@ __global__ void scaleFC_0817_comp_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFC_comp_D3Q27F3_2018( real* DC, real* DF, @@ -2192,7 +2178,7 @@ __global__ void scaleFC_comp_D3Q27F3_2018( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFC_comp_D3Q27F3( real* DC, real* DF, @@ -2216,7 +2202,7 @@ __global__ void scaleFC_comp_D3Q27F3( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFC_staggered_time_comp_27(real* DC, @@ -2240,7 +2226,7 @@ __global__ void scaleFC_staggered_time_comp_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFC_RhoSq_comp_27( real* DC, real* DF, @@ -2263,7 +2249,7 @@ __global__ void scaleFC_RhoSq_comp_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); template<bool hasTurbulentViscosity> __global__ void scaleFC_compressible( real *distributionsCoarse, @@ -2284,7 +2270,7 @@ template<bool hasTurbulentViscosity> __global__ void scaleFC_compressible( real omegaFine, real* turbulentViscosityCoarse, real* turbulentViscosityFine, - OffFC offsetFC); + ICellNeigh offsetFC); __global__ void scaleFC_RhoSq_3rdMom_comp_27(real* DC, real* DF, @@ -2307,7 +2293,7 @@ __global__ void scaleFC_RhoSq_3rdMom_comp_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFC_AA2016_comp_27(real* DC, real* DF, @@ -2330,7 +2316,7 @@ __global__ void scaleFC_AA2016_comp_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFC_NSPress_27(real* DC, real* DF, @@ -2353,7 +2339,7 @@ __global__ void scaleFC_NSPress_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFCThSMG7( real* DC, real* DF, @@ -2373,7 +2359,7 @@ __global__ void scaleFCThSMG7( real* DC, unsigned int kFC, real nu, real diffusivity_coarse, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void scaleFCThS7(real* DC, real* DF, @@ -2412,7 +2398,7 @@ __global__ void scaleFCThS27( real* DC, unsigned int kFC, real nu, real diffusivity_coarse, - OffFC offFC); + ICellNeigh neighborFineToCoarse); __global__ void DragLiftPost27( real* DD, int* k_Q, diff --git a/src/gpu/VirtualFluids_GPU/GPU/GeometryUtils.h b/src/gpu/VirtualFluids_GPU/GPU/GeometryUtils.h index 4dbf525e173c4acb00ff53e70f7485852bf956ac..d312c826036c1b5d856da0f0ab52832ba89c2f57 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GeometryUtils.h +++ b/src/gpu/VirtualFluids_GPU/GPU/GeometryUtils.h @@ -1,5 +1,7 @@ #ifndef _GEOMETRYUTILS_H #define _GEOMETRYUTILS_H +#include "DataTypes.h" + __inline__ __host__ __device__ void getNeighborIndicesOfBSW( uint k, //index of DIR_MMM node uint &ke, uint &kn, uint &kt, uint &kne, uint &kte,uint &ktn, uint &ktne, @@ -53,46 +55,45 @@ __inline__ __host__ __device__ real trilinearInterpolation( real dW, real dE, re uint k, uint ke, uint kn, uint kt, uint kne, uint kte, uint ktn, uint ktne, real* quantity ) { - real interpolatedValue = ( dE*dN*dT*quantity[k] + dW*dN*dT*quantity[ke] - + dE*dS*dT*quantity[kn] + dW*dS*dT*quantity[kne] - + dE*dN*dB*quantity[kt] + dW*dN*dB*quantity[kte] - + dE*dS*dB*quantity[ktn] + dW*dS*dB*quantity[ktne] ); - return interpolatedValue; + return ( dE*dN*dT*quantity[k] + dW*dN*dT*quantity[ke] + + dE*dS*dT*quantity[kn] + dW*dS*dT*quantity[kne] + + dE*dN*dB*quantity[kt] + dW*dN*dB*quantity[kte] + + dE*dS*dB*quantity[ktn] + dW*dS*dB*quantity[ktne] ); } -__inline__ __host__ __device__ void translate2D(real &posX, real &posY, real &newPosX, real &newPosY, real &translationX, real &translationY) +__inline__ __host__ __device__ void translate2D(real posX, real posY, real &newPosX, real &newPosY, real translationX, real translationY) { newPosX = posX + translationX; newPosY = posY + translationY; } -__inline__ __host__ __device__ void invTranslate2D(real &posX, real &posY, real &newPosX, real &newPosY, real &translationX, real &translationY) +__inline__ __host__ __device__ void invTranslate2D(real posX, real posY, real &newPosX, real &newPosY, real translationX, real translationY) { newPosX = posX - translationX; newPosY = posY - translationY; } -__inline__ __host__ __device__ void translate3D(real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &translationX, real &translationY, real &translationZ) +__inline__ __host__ __device__ void translate3D(real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ, real translationX, real translationY, real translationZ) { newPosX = posX + translationX; newPosY = posY + translationY; newPosZ = posZ + translationZ; } -__inline__ __host__ __device__ void invTranslate3D(real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &translationX, real &translationY, real &translationZ) +__inline__ __host__ __device__ void invTranslate3D(real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ, real translationX, real translationY, real translationZ) { newPosX = posX - translationX; newPosY = posY - translationY; newPosZ = posZ - translationZ; } -__inline__ __host__ __device__ void rotate2D(real &angle, real &posX, real &posY, real &newPosX, real &newPosY) +__inline__ __host__ __device__ void rotate2D(real angle, real posX, real posY, real &newPosX, real &newPosY) { newPosX = posX*cos(angle) - posY*sin(angle); newPosY = posX*sin(angle) + posY*cos(angle); } -__inline__ __host__ __device__ void rotate2D(real &angle, real &posX, real &posY, real &newPosX, real &newPosY, real &originX, real &originY) +__inline__ __host__ __device__ void rotate2D(real angle, real posX, real posY, real &newPosX, real &newPosY, real originX, real originY) { real tmpX, tmpY; invTranslate2D(posX, posY, newPosX, newPosY, originX, originY); @@ -100,13 +101,13 @@ __inline__ __host__ __device__ void rotate2D(real &angle, real &posX, real &posY translate2D(tmpX, tmpY, newPosX, newPosY, originX, originY); } -__inline__ __host__ __device__ void invRotate2D(real &angle, real &posX, real &posY, real &newPosX, real &newPosY) +__inline__ __host__ __device__ void invRotate2D(real angle, real posX, real posY, real &newPosX, real &newPosY) { newPosX = posX*cos(angle) + posY*sin(angle); newPosY = -posX*sin(angle) + posY*cos(angle); } -__inline__ __host__ __device__ void invRotate2D(real &angle, real &posX, real &posY, real &newPosX, real &newPosY, real &originX, real &originY) +__inline__ __host__ __device__ void invRotate2D(real angle, real posX, real posY, real &newPosX, real &newPosY, real originX, real originY) { real tmpX, tmpY; invTranslate2D(posX, posY, newPosX, newPosY, originX, originY); @@ -114,13 +115,13 @@ __inline__ __host__ __device__ void invRotate2D(real &angle, real &posX, real &p translate2D(tmpX, tmpY, newPosX, newPosY, originX, originY); } -__inline__ __host__ __device__ void rotateAboutX3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ) +__inline__ __host__ __device__ void rotateAboutX3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ) { newPosX = posX; rotate2D(angle, posY, posZ, newPosY, newPosZ); } -__inline__ __host__ __device__ void rotateAboutX3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &originX, real &originY, real &originZ) +__inline__ __host__ __device__ void rotateAboutX3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ, real originX, real originY, real originZ) { real tmpX, tmpY, tmpZ; invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); @@ -128,13 +129,13 @@ __inline__ __host__ __device__ void rotateAboutX3D(real &angle, real &posX, real translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ); } -__inline__ __host__ __device__ void invRotateAboutX3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ) +__inline__ __host__ __device__ void invRotateAboutX3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ) { newPosX = posX; invRotate2D(angle, posY, posZ, newPosY, newPosZ); } -__inline__ __host__ __device__ void invRotateAboutX3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &originX, real &originY, real &originZ) +__inline__ __host__ __device__ void invRotateAboutX3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ, real originX, real originY, real originZ) { real tmpX, tmpY, tmpZ; invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); @@ -142,13 +143,13 @@ __inline__ __host__ __device__ void invRotateAboutX3D(real &angle, real &posX, r translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ); } -__inline__ __host__ __device__ void rotateAboutY3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ) +__inline__ __host__ __device__ void rotateAboutY3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ) { newPosY = posY; rotate2D(angle, posX, posZ, newPosX, newPosZ); } -__inline__ __host__ __device__ void rotateAboutY3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &originX, real &originY, real &originZ) +__inline__ __host__ __device__ void rotateAboutY3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ, real originX, real originY, real originZ) { real tmpX, tmpY, tmpZ; invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); @@ -156,13 +157,13 @@ __inline__ __host__ __device__ void rotateAboutY3D(real &angle, real &posX, real translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ); } -__inline__ __host__ __device__ void invRotateAboutY3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ) +__inline__ __host__ __device__ void invRotateAboutY3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ) { newPosY = posY; invRotate2D(angle, posX, posZ, newPosX, newPosZ); } -__inline__ __host__ __device__ void invRotateAboutY3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &originX, real &originY, real &originZ) +__inline__ __host__ __device__ void invRotateAboutY3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ, real originX, real originY, real originZ) { real tmpX, tmpY, tmpZ; invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); @@ -171,13 +172,13 @@ __inline__ __host__ __device__ void invRotateAboutY3D(real &angle, real &posX, r } -__inline__ __host__ __device__ void rotateAboutZ3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ) +__inline__ __host__ __device__ void rotateAboutZ3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ) { newPosZ = posZ; rotate2D(angle, posX, posY, newPosX, newPosY); } -__inline__ __host__ __device__ void rotateAboutZ3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &originX, real &originY, real &originZ) +__inline__ __host__ __device__ void rotateAboutZ3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ, real originX, real originY, real originZ) { real tmpX, tmpY, tmpZ; invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); @@ -185,13 +186,13 @@ __inline__ __host__ __device__ void rotateAboutZ3D(real &angle, real &posX, real translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ); } -__inline__ __host__ __device__ void invRotateAboutZ3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ) +__inline__ __host__ __device__ void invRotateAboutZ3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ) { newPosZ = posZ; invRotate2D(angle, posX, posY, newPosX, newPosY); } -__inline__ __host__ __device__ void invRotateAboutZ3D(real &angle, real &posX, real &posY, real &posZ, real &newPosX, real &newPosY, real &newPosZ, real &originX, real &originY, real &originZ) +__inline__ __host__ __device__ void invRotateAboutZ3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ, real originX, real originY, real originZ) { real tmpX, tmpY, tmpZ; invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); diff --git a/src/gpu/VirtualFluids_GPU/GPU/GeometryUtilsTest.cu b/src/gpu/VirtualFluids_GPU/GPU/GeometryUtilsTest.cu new file mode 100644 index 0000000000000000000000000000000000000000..797a8f72195c57faa7889c8dadc30fb8eccb6288 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/GPU/GeometryUtilsTest.cu @@ -0,0 +1,301 @@ +#include "GeometryUtils.h" +#include "basics/constants/NumericConstants.h" +#include "tests/testUtilities.h" + +TEST(GeometryUtilsTest, translate2D) +{ + real newPositionX; + real newPositionY; + + translate2D(0., 0., newPositionX, newPositionY, 0., 0.); + EXPECT_THAT(newPositionX, RealEq(0.)); + EXPECT_THAT(newPositionY, RealEq(0.)); + + translate2D(0.5, 0.5, newPositionX, newPositionY, 1., 1.); + EXPECT_THAT(newPositionX, RealEq(1.5)); + EXPECT_THAT(newPositionY, RealEq(1.5)); + + translate2D(0.5, 0.5, newPositionX, newPositionY, -1., -1.); + EXPECT_THAT(newPositionX, RealEq(-0.5)); + EXPECT_THAT(newPositionY, RealEq(-0.5)); +} + +TEST(GeometryUtilsTest, inverseTranslate2D) +{ + real newPositionX; + real newPositionY; + + invTranslate2D(0., 0., newPositionX, newPositionY, 0., 0.); + EXPECT_THAT(newPositionX, RealEq(0.)); + EXPECT_THAT(newPositionY, RealEq(0.)); + + invTranslate2D(0.5, 0.5, newPositionX, newPositionY, 1., 1.); + EXPECT_THAT(newPositionX, RealEq(-0.5)); + EXPECT_THAT(newPositionY, RealEq(-0.5)); + + invTranslate2D(0.5, 0.5, newPositionX, newPositionY, -1., -1.); + EXPECT_THAT(newPositionX, RealEq(1.5)); + EXPECT_THAT(newPositionY, RealEq(1.5)); +} + +TEST(GeometryUtilsTest, rotate2dAround0) +{ + auto posX = 2.0; + auto posY = 0.0; + real newPosX; + real newPosY; + + auto angle = 0.0; + rotate2D(angle, posX, posY, newPosX, newPosY); + EXPECT_THAT(newPosX, RealNear(2.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(0.0, 10e-5)); + + angle = 0.5 * vf::basics::constant::cPi; + rotate2D(angle, posX, posY, newPosX, newPosY); + EXPECT_THAT(newPosX, RealNear(0.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(2.0, 10e-5)); + + angle = 1.0 * vf::basics::constant::cPi; + rotate2D(angle, posX, posY, newPosX, newPosY); + EXPECT_THAT(newPosX, RealNear(-2.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(0.0, 10e-5)); + + angle = 1.5 * vf::basics::constant::cPi; + rotate2D(angle, posX, posY, newPosX, newPosY); + EXPECT_THAT(newPosX, RealNear(0.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-2.0, 10e-5)); + + angle = 2.0 * vf::basics::constant::cPi; + rotate2D(angle, posX, posY, newPosX, newPosY); + EXPECT_THAT(newPosX, RealNear(2.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(0.0, 10e-5)); + + angle = -0.5 * vf::basics::constant::cPi; + rotate2D(angle, posX, posY, newPosX, newPosY); + EXPECT_THAT(newPosX, RealNear(0.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-2.0, 10e-5)); +} + +TEST(GeometryUtilsTest, rotate2dWithOrigin) +{ + auto posX = 3.0; + auto posY = -1.0; + auto originX = 1.0; + auto originY = -1.0; + real newPosX; + real newPosY; + + auto angle = 0.0; + rotate2D(angle, posX, posY, newPosX, newPosY, originX, originY); + EXPECT_THAT(newPosX, RealNear(3.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-1.0, 10e-5)); + + angle = 0.5 * vf::basics::constant::cPi; + rotate2D(angle, posX, posY, newPosX, newPosY, originX, originY); + EXPECT_THAT(newPosX, RealNear(1.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(1.0, 10e-5)); + + angle = 1.0 * vf::basics::constant::cPi; + rotate2D(angle, posX, posY, newPosX, newPosY, originX, originY); + EXPECT_THAT(newPosX, RealNear(-1.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-1.0, 10e-5)); + + angle = 1.5 * vf::basics::constant::cPi; + rotate2D(angle, posX, posY, newPosX, newPosY, originX, originY); + EXPECT_THAT(newPosX, RealNear(1.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-3.0, 10e-5)); + + angle = 2.0 * vf::basics::constant::cPi; + rotate2D(angle, posX, posY, newPosX, newPosY, originX, originY); + EXPECT_THAT(newPosX, RealNear(3.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-1.0, 10e-5)); + + angle = -0.5 * vf::basics::constant::cPi; + rotate2D(angle, posX, posY, newPosX, newPosY, originX, originY); + EXPECT_THAT(newPosX, RealNear(1.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-3.0, 10e-5)); +} + +TEST(GeometryUtilsTest, inverseRotate2DWithOrigin) +{ + auto posX = 3.0; + auto posY = -1.0; + auto originX = 1.0; + auto originY = -1.0; + real newPosX; + real newPosY; + + auto angle = 0.0; + invRotate2D(angle, posX, posY, newPosX, newPosY, originX, originY); + EXPECT_THAT(newPosX, RealNear(3.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-1.0, 10e-5)); + + angle = 0.5 * vf::basics::constant::cPi; + invRotate2D(angle, posX, posY, newPosX, newPosY, originX, originY); + EXPECT_THAT(newPosX, RealNear(1.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-3.0, 10e-5)); + + angle = 1.0 * vf::basics::constant::cPi; + invRotate2D(angle, posX, posY, newPosX, newPosY, originX, originY); + EXPECT_THAT(newPosX, RealNear(-1.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-1.0, 10e-5)); + + angle = 1.5 * vf::basics::constant::cPi; + invRotate2D(angle, posX, posY, newPosX, newPosY, originX, originY); + EXPECT_THAT(newPosX, RealNear(1.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(1.0, 10e-5)); + + angle = 2.0 * vf::basics::constant::cPi; + invRotate2D(angle, posX, posY, newPosX, newPosY, originX, originY); + EXPECT_THAT(newPosX, RealNear(3.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-1.0, 10e-5)); + + angle = -1.5 * vf::basics::constant::cPi; + invRotate2D(angle, posX, posY, newPosX, newPosY, originX, originY); + EXPECT_THAT(newPosX, RealNear(1.0, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-3.0, 10e-5)); +} + +TEST(GeometryUtilsTest, rotateAboutX3dAround0) +{ + auto posX = 0.5; + auto posY = 2.0; + auto posZ = 0.0; + real newPosX; + real newPosY; + real newPosZ; + + auto angle = 0.0; + rotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(2.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(0.0, 10e-5)); + + angle = 0.5 * vf::basics::constant::cPi; + rotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(0.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(2.0, 10e-5)); + + angle = 1.0 * vf::basics::constant::cPi; + rotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-2.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(0.0, 10e-5)); + + angle = 1.5 * vf::basics::constant::cPi; + rotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(0.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(-2.0, 10e-5)); + + angle = 2.0 * vf::basics::constant::cPi; + rotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(2.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(0.0, 10e-5)); + + angle = -0.5 * vf::basics::constant::cPi; + rotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(0.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(-2.0, 10e-5)); +} + +TEST(GeometryUtilsTest, rotateAboutX3dWithOrigin) +{ + auto posX = 0.5; + auto posY = 3.0; + auto posZ = -1.0; + auto originX = -0.75; + auto originY = 1.0; + auto originZ = -1.0; + real newPosX; + real newPosY; + real newPosZ; + + auto angle = 0.0; + rotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(3.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(-1.0, 10e-5)); + + angle = 0.5 * vf::basics::constant::cPi; + rotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(1.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(1.0, 10e-5)); + + angle = 1.0 * vf::basics::constant::cPi; + rotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-1.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(-1.0, 10e-5)); + + angle = 1.5 * vf::basics::constant::cPi; + rotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(1.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(-3.0, 10e-5)); + + angle = 2.0 * vf::basics::constant::cPi; + rotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(3.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(-1.0, 10e-5)); + + angle = -0.5 * vf::basics::constant::cPi; + rotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(1.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(-3.0, 10e-5)); +} + +TEST(GeometryUtilsTest, inverseRotateAboutX3dWithOrigin) +{ + auto posX = 0.5; + auto posY = 3.0; + auto posZ = -1.0; + auto originX = -0.75; + auto originY = 1.0; + auto originZ = -1.0; + real newPosX; + real newPosY; + real newPosZ; + + auto angle = 0.0; + invRotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(3.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(-1.0, 10e-5)); + + angle = 0.5 * vf::basics::constant::cPi; + invRotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(1.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(-3.0, 10e-5)); + + angle = 1.0 * vf::basics::constant::cPi; + invRotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(-1.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(-1.0, 10e-5)); + + angle = 1.5 * vf::basics::constant::cPi; + invRotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(1.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(1.0, 10e-5)); + + angle = 2.0 * vf::basics::constant::cPi; + invRotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(3.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(-1.0, 10e-5)); + + angle = -0.5 * vf::basics::constant::cPi; + invRotateAboutX3D(angle, posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ); + EXPECT_THAT(newPosX, RealNear(0.5, 10e-5)); + EXPECT_THAT(newPosY, RealNear(1.0, 10e-5)); + EXPECT_THAT(newPosZ, RealNear(1.0, 10e-5)); +} \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleCF27.cu b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleCF27.cu index 641d6519669b1522430fe88990c00d0630d00e9b..4c586faa2fa60fe2894d86f97c680c5f0f11087b 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleCF27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleCF27.cu @@ -8,9 +8,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; ////////////////////////////////////////////////////////////////////////// @@ -35,7 +35,7 @@ __global__ void scaleCF_0817_comp_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *fP00dest, *fM00dest, *f0P0dest, *f0M0dest, *f00Pdest, *f00Mdest, *fPP0dest, *fMM0dest, *fPM0dest, @@ -188,9 +188,9 @@ __global__ void scaleCF_0817_comp_27( real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -4104,7 +4104,7 @@ __global__ void scaleCF_AA2016_comp_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -4270,9 +4270,9 @@ __global__ void scaleCF_AA2016_comp_27(real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -10987,7 +10987,7 @@ __global__ void scaleCF_RhoSq_3rdMom_comp_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -11153,9 +11153,9 @@ __global__ void scaleCF_RhoSq_3rdMom_comp_27(real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -17862,7 +17862,7 @@ __global__ void scaleCF_RhoSq_comp_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -18008,9 +18008,9 @@ __global__ void scaleCF_RhoSq_comp_27(real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -22146,7 +22146,7 @@ __global__ void scaleCF_staggered_time_comp_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -22292,9 +22292,9 @@ __global__ void scaleCF_staggered_time_comp_27( real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -26382,7 +26382,7 @@ __global__ void scaleCF_Fix_comp_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -26531,9 +26531,9 @@ __global__ void scaleCF_Fix_comp_27( real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -31149,7 +31149,7 @@ __global__ void scaleCF_NSPress_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -31294,9 +31294,9 @@ __global__ void scaleCF_NSPress_27( real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -35093,7 +35093,7 @@ __global__ void scaleCF_Fix_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -35239,9 +35239,9 @@ __global__ void scaleCF_Fix_27( real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -39351,7 +39351,7 @@ __global__ void scaleCFpress27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -39496,9 +39496,9 @@ __global__ void scaleCFpress27( real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -41025,7 +41025,7 @@ __global__ void scaleCFLast27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -41170,9 +41170,9 @@ __global__ void scaleCFLast27( real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -43257,7 +43257,7 @@ __global__ void scaleCFThSMG7( real* DC, unsigned int kCF, real nu, real diffusivity_fine, - OffCF offCF) + ICellNeigh offCF) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, /**fzeroF,*/ *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -43425,9 +43425,9 @@ __global__ void scaleCFThSMG7( real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - real xoff = offCF.xOffCF[k]; - real yoff = offCF.yOffCF[k]; - real zoff = offCF.zOffCF[k]; + real xoff = offCF.x[k]; + real yoff = offCF.y[k]; + real zoff = offCF.z[k]; real xoff_sq = xoff * xoff; real yoff_sq = yoff * yoff; real zoff_sq = zoff * zoff; @@ -45607,7 +45607,7 @@ __global__ void scaleCFThS27( real* DC, unsigned int kCF, real nu, real diffusivity_fine, - OffCF offCF) + ICellNeigh offCF) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, /**fzeroF,*/ *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -45835,9 +45835,9 @@ __global__ void scaleCFThS27( real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -47300,7 +47300,7 @@ __global__ void scaleCFEff27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -47445,9 +47445,9 @@ __global__ void scaleCFEff27(real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; diff --git a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleCF_F3_27.cu b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleCF_F3_27.cu index 386493280fd71fff93c117483e754a248bb0830d..a3044503b2e08b8bc713c7431c43a98395ec3298 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleCF_F3_27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleCF_F3_27.cu @@ -8,9 +8,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; ////////////////////////////////////////////////////////////////////////// @@ -36,7 +36,7 @@ __global__ void scaleCF_comp_D3Q27F3_2018(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *fP00dest, *fM00dest, *f0P0dest, *f0M0dest, *f00Pdest, *f00Mdest, *fPP0dest, *fMM0dest, *fPM0dest, @@ -198,9 +198,9 @@ __global__ void scaleCF_comp_D3Q27F3_2018(real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -4383,7 +4383,7 @@ __global__ void scaleCF_comp_D3Q27F3( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffCF offCF) + ICellNeigh offCF) { real *fP00dest, *fM00dest, *f0P0dest, *f0M0dest, *f00Pdest, *f00Mdest, *fPP0dest, *fMM0dest, *fPM0dest, @@ -4545,9 +4545,9 @@ __global__ void scaleCF_comp_D3Q27F3( real* DC, if(k<kCF) { ////////////////////////////////////////////////////////////////////////// - xoff = offCF.xOffCF[k]; - yoff = offCF.yOffCF[k]; - zoff = offCF.zOffCF[k]; + xoff = offCF.x[k]; + yoff = offCF.y[k]; + zoff = offCF.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; diff --git a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleFC27.cu b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleFC27.cu index b37ab44d81d15fbbde46c875c860acd7198b8041..08c47230faa5ffeed0b996e2b1125d3c45e6bce1 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleFC27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleFC27.cu @@ -8,9 +8,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; ////////////////////////////////////////////////////////////////////////// @@ -35,7 +35,7 @@ __global__ void scaleFC_0817_comp_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { real *fP00source, *fM00source, *f0P0source, *f0M0source, *f00Psource, *f00Msource, *fPP0source, *fMM0source, *fPM0source, @@ -183,9 +183,9 @@ __global__ void scaleFC_0817_comp_27( real* DC, if(k<kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -1231,7 +1231,7 @@ __global__ void scaleFC_AA2016_comp_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -1393,9 +1393,9 @@ __global__ void scaleFC_AA2016_comp_27(real* DC, if(k<kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -5420,7 +5420,7 @@ __global__ void scaleFC_RhoSq_3rdMom_comp_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -5582,9 +5582,9 @@ __global__ void scaleFC_RhoSq_3rdMom_comp_27(real* DC, if(k<kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -9608,7 +9608,7 @@ __device__ void scaleFC_RhoSq_comp_27_Calculation( unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC, + ICellNeigh offFC, const unsigned k) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, @@ -9741,9 +9741,9 @@ __device__ void scaleFC_RhoSq_comp_27_Calculation( if (k < kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -11094,7 +11094,7 @@ __global__ void scaleFC_RhoSq_comp_27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { //////////////////////////////////////////////////////////////////////////////// const unsigned ix = threadIdx.x; // Globaler x-Index @@ -11187,7 +11187,7 @@ __global__ void scaleFC_staggered_time_comp_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -11329,9 +11329,9 @@ __global__ void scaleFC_staggered_time_comp_27( real* DC, if(k<kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -12487,7 +12487,7 @@ __global__ void scaleFC_Fix_comp_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -12631,9 +12631,9 @@ __global__ void scaleFC_Fix_comp_27( real* DC, if(k<kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -14347,7 +14347,7 @@ __global__ void scaleFC_NSPress_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -14488,9 +14488,9 @@ __global__ void scaleFC_NSPress_27( real* DC, if(k<kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -15553,7 +15553,7 @@ __global__ void scaleFC_Fix_27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -15695,9 +15695,9 @@ __global__ void scaleFC_Fix_27( real* DC, if(k<kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -16913,7 +16913,7 @@ __global__ void scaleFCpress27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -17057,9 +17057,9 @@ __global__ void scaleFCpress27(real* DC, if(k<kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -17838,7 +17838,7 @@ __global__ void scaleFCLast27( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -17982,9 +17982,9 @@ __global__ void scaleFCLast27( real* DC, if(k<kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -19231,7 +19231,7 @@ __global__ void scaleFCThSMG7( real* DC, unsigned int kFC, real nu, real diffusivity_coarse, - OffFC offFC) + ICellNeigh offFC) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, //*fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -19392,9 +19392,9 @@ __global__ void scaleFCThSMG7( real* DC, if(k<kFC){ ////////////////////////////////////////////////////////////////////////// - real xoff = offFC.xOffFC[k]; - real yoff = offFC.yOffFC[k]; - real zoff = offFC.zOffFC[k]; + real xoff = offFC.x[k]; + real yoff = offFC.y[k]; + real zoff = offFC.z[k]; real xoff_sq = xoff * xoff; real yoff_sq = yoff * yoff; real zoff_sq = zoff * zoff; @@ -20889,7 +20889,7 @@ __global__ void scaleFCThS27( real* DC, unsigned int kFC, real nu, real diffusivity_coarse, - OffFC offFC) + ICellNeigh offFC) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, //*fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -21110,9 +21110,9 @@ __global__ void scaleFCThS27( real* DC, if(k<kFC){ ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -22012,7 +22012,7 @@ __global__ void scaleFCEff27(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { real *feF, *fwF, *fnF, *fsF, *ftF, *fbF, *fneF, *fswF, *fseF, *fnwF, *fteF, *fbwF, *fbeF, *ftwF, *ftnF, *fbsF, *fbnF, *ftsF, *fzeroF, *ftneF, *ftswF, *ftseF, *ftnwF, *fbneF, *fbswF, *fbseF, *fbnwF; @@ -22156,9 +22156,9 @@ __global__ void scaleFCEff27(real* DC, if(k<kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; diff --git a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleFC_F3_27.cu b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleFC_F3_27.cu index 3b108ad4ae43bd63698f3516a207630214695797..7de51b3b0aec87e3e8773c08435c3ada445e9a41 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleFC_F3_27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/ScaleFC_F3_27.cu @@ -8,9 +8,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; ////////////////////////////////////////////////////////////////////////// @@ -36,7 +36,7 @@ __global__ void scaleFC_comp_D3Q27F3_2018(real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { real *fP00source, *fM00source, *f0P0source, *f0M0source, *f00Psource, *f00Msource, *fPP0source, *fMM0source, *fPM0source, @@ -205,9 +205,9 @@ __global__ void scaleFC_comp_D3Q27F3_2018(real* DC, if(k<kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; @@ -1283,7 +1283,7 @@ __global__ void scaleFC_comp_D3Q27F3( real* DC, unsigned int nyC, unsigned int nxF, unsigned int nyF, - OffFC offFC) + ICellNeigh offFC) { real *fP00source, *fM00source, *f0P0source, *f0M0source, *f00Psource, *f00Msource, *fPP0source, *fMM0source, *fPM0source, @@ -1452,9 +1452,9 @@ __global__ void scaleFC_comp_D3Q27F3( real* DC, if(k<kFC) { ////////////////////////////////////////////////////////////////////////// - xoff = offFC.xOffFC[k]; - yoff = offFC.yOffFC[k]; - zoff = offFC.zOffFC[k]; + xoff = offFC.x[k]; + yoff = offFC.y[k]; + zoff = offFC.z[k]; xoff_sq = xoff * xoff; yoff_sq = yoff * yoff; zoff_sq = zoff * zoff; diff --git a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/scaleCF_compressible.cu b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/scaleCF_compressible.cu index 84529ef2694b57448291957f7792360088bd954f..ec1c8207bdd38666f4222270be81b91960142e62 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/scaleCF_compressible.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/scaleCF_compressible.cu @@ -36,7 +36,7 @@ #include "LBM/GPUHelperFunctions/ChimeraTransformation.h" #include "LBM/GPUHelperFunctions/ScalingUtilities.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; @@ -237,7 +237,7 @@ template<bool hasTurbulentViscosity> __global__ void scaleCF_compressible( real omegaFine, real* turbulentViscosityCoarse, real* turbulentViscosityFine, - OffCF offsetCF) + ICellNeigh neighborCoarseToFine) { //////////////////////////////////////////////////////////////////////////////// //! - Get the node index coordinates from threadId_100, blockId_100, blockDim and gridDim. @@ -758,9 +758,9 @@ template<bool hasTurbulentViscosity> __global__ void scaleCF_compressible( //////////////////////////////////////////////////////////////////////////////// //! - Set the relative position of the offset cell {-1, 0, 1} //! - real xoff = offsetCF.xOffCF[nodeIndex]; - real yoff = offsetCF.yOffCF[nodeIndex]; - real zoff = offsetCF.zOffCF[nodeIndex]; + real xoff = neighborCoarseToFine.x[nodeIndex]; + real yoff = neighborCoarseToFine.y[nodeIndex]; + real zoff = neighborCoarseToFine.z[nodeIndex]; real xoff_sq = xoff * xoff; real yoff_sq = yoff * yoff; @@ -1487,6 +1487,6 @@ template<bool hasTurbulentViscosity> __global__ void scaleCF_compressible( (distFine.f[DIR_MMM])[k_MMM] = f_MMM; } -template __global__ void scaleCF_compressible<true>( real* distributionsCoarse, real* distributionsFine, unsigned int* neighborXcoarse, unsigned int* neighborYcoarse, unsigned int* neighborZcoarse, unsigned int* neighborXfine, unsigned int* neighborYfine, unsigned int* neighborZfine, unsigned long long numberOfLBnodesCoarse, unsigned long long numberOfLBnodesFine, bool isEvenTimestep, unsigned int* indicesCoarseMMM, unsigned int* indicesFineMMM, unsigned int numberOfInterfaceNodes, real omegaCoarse, real omegaFine, real* turbulentViscosityCoarse, real* turbulentViscosityFine, OffCF offsetCF); +template __global__ void scaleCF_compressible<true>( real* distributionsCoarse, real* distributionsFine, unsigned int* neighborXcoarse, unsigned int* neighborYcoarse, unsigned int* neighborZcoarse, unsigned int* neighborXfine, unsigned int* neighborYfine, unsigned int* neighborZfine, unsigned long long numberOfLBnodesCoarse, unsigned long long numberOfLBnodesFine, bool isEvenTimestep, unsigned int* indicesCoarseMMM, unsigned int* indicesFineMMM, unsigned int numberOfInterfaceNodes, real omegaCoarse, real omegaFine, real* turbulentViscosityCoarse, real* turbulentViscosityFine, ICellNeigh offsetCF); -template __global__ void scaleCF_compressible<false>( real* distributionsCoarse, real* distributionsFine, unsigned int* neighborXcoarse, unsigned int* neighborYcoarse, unsigned int* neighborZcoarse, unsigned int* neighborXfine, unsigned int* neighborYfine, unsigned int* neighborZfine, unsigned long long numberOfLBnodesCoarse, unsigned long long numberOfLBnodesFine, bool isEvenTimestep, unsigned int* indicesCoarseMMM, unsigned int* indicesFineMMM, unsigned int numberOfInterfaceNodes, real omegaCoarse, real omegaFine, real* turbulentViscosityCoarse, real* turbulentViscosityFine, OffCF offsetCF); \ No newline at end of file +template __global__ void scaleCF_compressible<false>( real* distributionsCoarse, real* distributionsFine, unsigned int* neighborXcoarse, unsigned int* neighborYcoarse, unsigned int* neighborZcoarse, unsigned int* neighborXfine, unsigned int* neighborYfine, unsigned int* neighborZfine, unsigned long long numberOfLBnodesCoarse, unsigned long long numberOfLBnodesFine, bool isEvenTimestep, unsigned int* indicesCoarseMMM, unsigned int* indicesFineMMM, unsigned int numberOfInterfaceNodes, real omegaCoarse, real omegaFine, real* turbulentViscosityCoarse, real* turbulentViscosityFine, ICellNeigh offsetCF); \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/scaleFC_compressible.cu b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/scaleFC_compressible.cu index c89a524c1dd63f426254c395d1e4881a7e96ce7a..5776ba476e3537360b32ee85f32514324946ff75 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/GridScaling/scaleFC_compressible.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/GridScaling/scaleFC_compressible.cu @@ -35,7 +35,7 @@ #include "LBM/GPUHelperFunctions/KernelUtilities.h" #include "LBM/GPUHelperFunctions/ScalingUtilities.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; @@ -65,7 +65,7 @@ template<bool hasTurbulentViscosity> __global__ void scaleFC_compressible( real omegaFine, real* turbulentViscosityCoarse, real* turbulentViscosityFine, - OffFC offsetFC) + ICellNeigh neighborFineToCoarse) { //////////////////////////////////////////////////////////////////////////////// //! - Get the node index coordinates from threadIdx, blockIdx, blockDim and gridDim. @@ -424,9 +424,9 @@ template<bool hasTurbulentViscosity> __global__ void scaleFC_compressible( //////////////////////////////////////////////////////////////////////////////// //! - Set the relative position of the offset cell {-1, 0, 1} //! - real xoff = offsetFC.xOffFC[nodeIndex]; - real yoff = offsetFC.yOffFC[nodeIndex]; - real zoff = offsetFC.zOffFC[nodeIndex]; + real xoff = neighborFineToCoarse.x[nodeIndex]; + real yoff = neighborFineToCoarse.y[nodeIndex]; + real zoff = neighborFineToCoarse.z[nodeIndex]; real xoff_sq = xoff * xoff; real yoff_sq = yoff * yoff; @@ -708,6 +708,6 @@ template<bool hasTurbulentViscosity> __global__ void scaleFC_compressible( //////////////////////////////////////////////////////////////////////////////////// } -template __global__ void scaleFC_compressible<true>( real *distributionsCoarse, real *distributionsFine, unsigned int *neighborXcoarse, unsigned int *neighborYcoarse, unsigned int *neighborZcoarse, unsigned int *neighborXfine, unsigned int *neighborYfine, unsigned int *neighborZfine, unsigned long long numberOfLBnodesCoarse, unsigned long long numberOfLBnodesFine, bool isEvenTimestep, unsigned int *indicesCoarse000, unsigned int *indicesFineMMM, unsigned int numberOfInterfaceNodes, real omegaCoarse, real omegaFine, real* turbulentViscosityCoarse, real* turbulentViscosityFine, OffFC offsetFC); +template __global__ void scaleFC_compressible<true>( real *distributionsCoarse, real *distributionsFine, unsigned int *neighborXcoarse, unsigned int *neighborYcoarse, unsigned int *neighborZcoarse, unsigned int *neighborXfine, unsigned int *neighborYfine, unsigned int *neighborZfine, unsigned long long numberOfLBnodesCoarse, unsigned long long numberOfLBnodesFine, bool isEvenTimestep, unsigned int *indicesCoarse000, unsigned int *indicesFineMMM, unsigned int numberOfInterfaceNodes, real omegaCoarse, real omegaFine, real* turbulentViscosityCoarse, real* turbulentViscosityFine, ICellNeigh neighborFineToCoarse); -template __global__ void scaleFC_compressible<false>( real *distributionsCoarse, real *distributionsFine, unsigned int *neighborXcoarse, unsigned int *neighborYcoarse, unsigned int *neighborZcoarse, unsigned int *neighborXfine, unsigned int *neighborYfine, unsigned int *neighborZfine, unsigned long long numberOfLBnodesCoarse, unsigned long long numberOfLBnodesFine, bool isEvenTimestep, unsigned int *indicesCoarse000, unsigned int *indicesFineMMM, unsigned int numberOfInterfaceNodes, real omegaCoarse, real omegaFine, real* turbulentViscosityCoarse, real* turbulentViscosityFine, OffFC offsetFC); \ No newline at end of file +template __global__ void scaleFC_compressible<false>( real *distributionsCoarse, real *distributionsFine, unsigned int *neighborXcoarse, unsigned int *neighborYcoarse, unsigned int *neighborZcoarse, unsigned int *neighborXfine, unsigned int *neighborYfine, unsigned int *neighborZfine, unsigned long long numberOfLBnodesCoarse, unsigned long long numberOfLBnodesFine, bool isEvenTimestep, unsigned int *indicesCoarse000, unsigned int *indicesFineMMM, unsigned int numberOfInterfaceNodes, real omegaCoarse, real omegaFine, real* turbulentViscosityCoarse, real* turbulentViscosityFine, ICellNeigh neighborFineToCoarse); \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/GPU/Init27.cu b/src/gpu/VirtualFluids_GPU/GPU/Init27.cu index 23666fdcf6714d30b40b4750c52f129cc472761c..ff844cfecd9e4cad02e41879ddd68246d0fe9ab2 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Init27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Init27.cu @@ -1,9 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; //////////////////////////////////////////////////////////////////////////////// @@ -358,7 +358,7 @@ __global__ void LBInitNonEqPartSP27( unsigned int* neighborX, ////////////////////////////////////////////////////////////////////////// - // the following code is copy and pasted from VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp + // the following code is copy and pasted from VirtualFluidsVisitors/InitDistributionsBlockVisitor.cpp // i.e. Konstantins code real ax = dvx1dx; diff --git a/src/gpu/VirtualFluids_GPU/GPU/InitAdvectionDiffusion27.cu b/src/gpu/VirtualFluids_GPU/GPU/InitAdvectionDiffusion27.cu index 7f67d1692f7e136a6537be6780fe8625adc33e22..a4172403158adbd712e255676baa2616081e83b4 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/InitAdvectionDiffusion27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/InitAdvectionDiffusion27.cu @@ -33,9 +33,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; __global__ void InitAD27( diff --git a/src/gpu/VirtualFluids_GPU/GPU/KineticEnergyAnalyzer.cu b/src/gpu/VirtualFluids_GPU/GPU/KineticEnergyAnalyzer.cu index b05cb9201ce30038bd6edf52e2e95a13c6f6d7d4..df88632f8fd48b3ae8d50b444a65076ab0a0c12f 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/KineticEnergyAnalyzer.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/KineticEnergyAnalyzer.cu @@ -19,9 +19,9 @@ #include "Parameter/Parameter.h" // includes, kernels #include "GPU/GPU_Kernels.cuh" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; __global__ void kineticEnergyKernel (real* vx, real* vy, real* vz, real* rho, uint* neighborX, uint* neighborY, uint* neighborZ, uint* neighborWSB, uint* geo, real* kineticEnergy, uint* isFluid, unsigned long long numberOfLBnodes); @@ -139,7 +139,6 @@ KineticEnergyAnalyzer::KineticEnergyAnalyzer(SPtr<Parameter> para, uint analyzeI void KineticEnergyAnalyzer::writeToFile(std::string filename) { - //*logging::out << logging::Logger::INFO_INTERMEDIATE << "KineticEnergyAnalyzer::writeToFile( " << filename << " )" << "\n"; std::cout << "KineticEnergyAnalyzer::writeToFile( " << filename << " )" << "\n"; std::ofstream file; @@ -151,7 +150,6 @@ void KineticEnergyAnalyzer::writeToFile(std::string filename) file.close(); - //*logging::out << logging::Logger::INFO_INTERMEDIATE << "done!\n"; std::cout << "done!\n"; } diff --git a/src/gpu/VirtualFluids_GPU/GPU/KineticEnergyAnalyzer.h b/src/gpu/VirtualFluids_GPU/GPU/KineticEnergyAnalyzer.h index ca5a97aaef3432dfef78a1ce8822e85dca115207..11759c24460a1541d9aa66e325e6b04c15c1d488 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/KineticEnergyAnalyzer.h +++ b/src/gpu/VirtualFluids_GPU/GPU/KineticEnergyAnalyzer.h @@ -7,7 +7,7 @@ #include "PointerDefinitions.h" -#include "Core/DataTypes.h" +#include "DataTypes.h" #include "VirtualFluids_GPU_export.h" class Parameter; diff --git a/src/gpu/VirtualFluids_GPU/GPU/LBMKernel.cu b/src/gpu/VirtualFluids_GPU/GPU/LBMKernel.cu index 9abac27969e74dc90ecdcc707f4fcb2234010d07..0a54db35bc4598702f3c3a3b194eb054a9ca478a 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/LBMKernel.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/LBMKernel.cu @@ -2541,39 +2541,6 @@ void QVeloDevEQ27( getLastCudaError("QVeloDeviceEQ27 execution failed"); } ////////////////////////////////////////////////////////////////////////// -void QVeloStreetDevEQ27( - uint numberOfThreads, - real* veloXfraction, - real* veloYfraction, - int* naschVelo, - real* DD, - int* naschIndex, - int numberOfStreetNodes, - real velocityRatio, - uint* neighborX, - uint* neighborY, - uint* neighborZ, - uint numberOfLBnodes, - bool isEvenTimestep) -{ - vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, numberOfStreetNodes); - - QVeloStreetDeviceEQ27 << < grid.grid, grid.threads >> > ( - veloXfraction, - veloYfraction, - naschVelo, - DD, - naschIndex, - numberOfStreetNodes, - velocityRatio, - neighborX, - neighborY, - neighborZ, - numberOfLBnodes, - isEvenTimestep); - getLastCudaError("QVeloStreetDeviceEQ27 execution failed"); -} -////////////////////////////////////////////////////////////////////////// void QSlipDev27(LBMSimulationParameter* parameterDevice, QforBoundaryConditions* boundaryCondition) { dim3 grid = vf::cuda::getCudaGrid( parameterDevice->numberofthreads, boundaryCondition->numberOfBCnodes); @@ -3563,7 +3530,7 @@ void ScaleCFEff27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF) + ICellNeigh neighborCoarseToFine) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -3589,7 +3556,7 @@ void ScaleCFEff27( nyC, nxF, nyF, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCFEff27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -3616,7 +3583,7 @@ void ScaleCFLast27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF) + ICellNeigh neighborCoarseToFine) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -3642,7 +3609,7 @@ void ScaleCFLast27( nyC, nxF, nyF, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCFLast27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -3669,7 +3636,7 @@ void ScaleCFpress27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF) + ICellNeigh neighborCoarseToFine) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -3695,7 +3662,7 @@ void ScaleCFpress27( nyC, nxF, nyF, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCFpress27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -3722,7 +3689,7 @@ void ScaleCF_Fix_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF) + ICellNeigh neighborCoarseToFine) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -3748,7 +3715,7 @@ void ScaleCF_Fix_27( nyC, nxF, nyF, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCF_Fix_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -3775,7 +3742,7 @@ void ScaleCF_Fix_comp_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF) + ICellNeigh neighborCoarseToFine) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -3801,7 +3768,7 @@ void ScaleCF_Fix_comp_27( nyC, nxF, nyF, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCF_Fix_comp_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -3828,7 +3795,7 @@ void ScaleCF_0817_comp_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF, + ICellNeigh neighborCoarseToFine, CUstream_st *stream) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -3855,7 +3822,7 @@ void ScaleCF_0817_comp_27( nyC, nxF, nyF, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCF_0817_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -3883,7 +3850,7 @@ void ScaleCF_comp_D3Q27F3_2018( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF) + ICellNeigh neighborCoarseToFine) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -3910,7 +3877,7 @@ void ScaleCF_comp_D3Q27F3_2018( nyC, nxF, nyF, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCF_comp_D3Q27F3_2018 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -3938,7 +3905,7 @@ void ScaleCF_comp_D3Q27F3( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF, + ICellNeigh neighborCoarseToFine, CUstream_st *stream) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -3966,7 +3933,7 @@ void ScaleCF_comp_D3Q27F3( nyC, nxF, nyF, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCF_comp_D3Q27F3 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -3993,7 +3960,7 @@ void ScaleCF_staggered_time_comp_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF) + ICellNeigh neighborCoarseToFine) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -4019,13 +3986,13 @@ void ScaleCF_staggered_time_comp_27( nyC, nxF, nyF, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCF_staggered_time_comp_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// -void ScaleCF_RhoSq_comp_27(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICellCF * icellCF, OffCF& offsetCF, CUstream_st *stream) +void ScaleCF_RhoSq_comp_27(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICells * coarseToFine, ICellNeigh& neighborCoarseToFine, CUstream_st *stream) { - dim3 grid = vf::cuda::getCudaGrid(parameterDeviceC->numberofthreads, icellCF->kCF); + dim3 grid = vf::cuda::getCudaGrid(parameterDeviceC->numberofthreads, coarseToFine->numberOfCells); dim3 threads(parameterDeviceC->numberofthreads, 1, 1 ); scaleCF_RhoSq_comp_27<<<grid, threads, 0, stream>>>( @@ -4040,23 +4007,23 @@ void ScaleCF_RhoSq_comp_27(LBMSimulationParameter * parameterDeviceC, LBMSimulat parameterDeviceC->numberOfNodes, parameterDeviceF->numberOfNodes, parameterDeviceC->isEvenTimestep, - icellCF->ICellCFC, - icellCF->ICellCFF, - icellCF->kCF, + coarseToFine->coarseCellIndices, + coarseToFine->fineCellIndices, + coarseToFine->numberOfCells, parameterDeviceC->omega, parameterDeviceF->omega, - parameterDeviceC->vis, + parameterDeviceC->viscosity, parameterDeviceC->nx, parameterDeviceC->ny, parameterDeviceF->nx, parameterDeviceF->ny, - offsetCF); + neighborCoarseToFine); getLastCudaError("scaleCF_RhoSq_27 execution failed"); } -template<bool hasTurbulentViscosity> void ScaleCF_compressible(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICellCF * icellCF, OffCF& offsetCF, CUstream_st *stream) +template<bool hasTurbulentViscosity> void ScaleCF_compressible(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICells * coarseToFine, ICellNeigh& neighborCoarseToFine, CUstream_st *stream) { - dim3 grid = vf::cuda::getCudaGrid(parameterDeviceC->numberofthreads, icellCF->kCF); + dim3 grid = vf::cuda::getCudaGrid(parameterDeviceC->numberofthreads, coarseToFine->numberOfCells); dim3 threads(parameterDeviceC->numberofthreads, 1, 1 ); scaleCF_compressible<hasTurbulentViscosity><<<grid, threads, 0, stream>>>( @@ -4071,19 +4038,19 @@ template<bool hasTurbulentViscosity> void ScaleCF_compressible(LBMSimulationPara parameterDeviceC->numberOfNodes, parameterDeviceF->numberOfNodes, parameterDeviceC->isEvenTimestep, - icellCF->ICellCFC, - icellCF->ICellCFF, - icellCF->kCF, + coarseToFine->coarseCellIndices, + coarseToFine->fineCellIndices, + coarseToFine->numberOfCells, parameterDeviceC->omega, parameterDeviceF->omega, parameterDeviceC->turbViscosity, parameterDeviceF->turbViscosity, - offsetCF); + neighborCoarseToFine); getLastCudaError("scaleCF_compressible execution failed"); } -template void ScaleCF_compressible<true>(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICellCF * icellCF, OffCF& offsetCF, CUstream_st *stream); -template void ScaleCF_compressible<false>(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICellCF * icellCF, OffCF& offsetCF, CUstream_st *stream); +template void ScaleCF_compressible<true>(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICells * coarseToFine, ICellNeigh& neighborCoarseToFine, CUstream_st *stream); +template void ScaleCF_compressible<false>(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICells * coarseToFine, ICellNeigh& neighborCoarseToFine, CUstream_st *stream); ////////////////////////////////////////////////////////////////////////// void ScaleCF_RhoSq_3rdMom_comp_27( @@ -4109,7 +4076,7 @@ void ScaleCF_RhoSq_3rdMom_comp_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF, + ICellNeigh neighborCoarseToFine, CUstream_st *stream) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -4136,7 +4103,7 @@ void ScaleCF_RhoSq_3rdMom_comp_27( nyC, nxF, nyF, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCF_RhoSq_3rdMom_comp_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4163,7 +4130,7 @@ void ScaleCF_AA2016_comp_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF, + ICellNeigh neighborCoarseToFine, CUstream_st *stream) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -4190,7 +4157,7 @@ void ScaleCF_AA2016_comp_27( nyC, nxF, nyF, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCF_AA2016_comp_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4217,7 +4184,7 @@ void ScaleCF_NSPress_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffCF offCF) + ICellNeigh neighborCoarseToFine) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -4243,7 +4210,7 @@ void ScaleCF_NSPress_27( nyC, nxF, nyF, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCF_NSPress_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4267,7 +4234,7 @@ void ScaleCFThSMG7( real nu, real diffusivity_fine, unsigned int numberOfThreads, - OffCF offCF) + ICellNeigh neighborCoarseToFine) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -4290,7 +4257,7 @@ void ScaleCFThSMG7( kCF, nu, diffusivity_fine, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCFThSMG7 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4359,7 +4326,7 @@ void ScaleCFThS27( real nu, real diffusivity_fine, unsigned int numberOfThreads, - OffCF offCF) + ICellNeigh neighborCoarseToFine) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kCF); @@ -4382,7 +4349,7 @@ void ScaleCFThS27( kCF, nu, diffusivity_fine, - offCF); + neighborCoarseToFine); getLastCudaError("scaleCFThS27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4460,7 +4427,7 @@ void ScaleFCEff27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC) + ICellNeigh neighborFineToCoarse) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -4486,7 +4453,7 @@ void ScaleFCEff27( nyC, nxF, nyF, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFCEff27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4513,7 +4480,7 @@ void ScaleFCLast27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC) + ICellNeigh neighborFineToCoarse) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -4539,7 +4506,7 @@ void ScaleFCLast27( nyC, nxF, nyF, - offFC); + neighborFineToCoarse); getLastCudaError("Kernel execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4566,7 +4533,7 @@ void ScaleFCpress27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC) + ICellNeigh neighborFineToCoarse) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -4592,7 +4559,7 @@ void ScaleFCpress27( nyC, nxF, nyF, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFCpress27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4619,7 +4586,7 @@ void ScaleFC_Fix_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC) + ICellNeigh neighborFineToCoarse) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -4645,7 +4612,7 @@ void ScaleFC_Fix_27( nyC, nxF, nyF, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFC_Fix_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4672,7 +4639,7 @@ void ScaleFC_Fix_comp_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC) + ICellNeigh neighborFineToCoarse) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -4698,7 +4665,7 @@ void ScaleFC_Fix_comp_27( nyC, nxF, nyF, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFC_Fix_comp_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4725,7 +4692,7 @@ void ScaleFC_0817_comp_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC, + ICellNeigh neighborFineToCoarse, CUstream_st *stream) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -4752,7 +4719,7 @@ void ScaleFC_0817_comp_27( nyC, nxF, nyF, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFC_0817_comp_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4780,7 +4747,7 @@ void ScaleFC_comp_D3Q27F3_2018( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC) + ICellNeigh neighborFineToCoarse) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -4807,7 +4774,7 @@ void ScaleFC_comp_D3Q27F3_2018( nyC, nxF, nyF, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFC_comp_D3Q27F3_2018 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4835,7 +4802,7 @@ void ScaleFC_comp_D3Q27F3( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC, + ICellNeigh neighborFineToCoarse, CUstream_st *stream) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -4863,7 +4830,7 @@ void ScaleFC_comp_D3Q27F3( nyC, nxF, nyF, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFC_comp_D3Q27F3 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -4890,7 +4857,7 @@ void ScaleFC_staggered_time_comp_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC) + ICellNeigh neighborFineToCoarse) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -4916,13 +4883,13 @@ void ScaleFC_staggered_time_comp_27( nyC, nxF, nyF, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFC_staggered_time_comp_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// -void ScaleFC_RhoSq_comp_27(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICellFC * icellFC, OffFC &offsetFC, CUstream_st *stream) +void ScaleFC_RhoSq_comp_27(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICells * fineToCoarse, ICellNeigh &neighborFineToCoarse, CUstream_st *stream) { - dim3 grid = vf::cuda::getCudaGrid(parameterDeviceC->numberofthreads, icellFC->kFC); + dim3 grid = vf::cuda::getCudaGrid(parameterDeviceC->numberofthreads, fineToCoarse->numberOfCells); dim3 threads(parameterDeviceC->numberofthreads, 1, 1 ); scaleFC_RhoSq_comp_27<<<grid, threads, 0, stream>>>( @@ -4937,23 +4904,23 @@ void ScaleFC_RhoSq_comp_27(LBMSimulationParameter * parameterDeviceC, LBMSimulat parameterDeviceC->numberOfNodes, parameterDeviceF->numberOfNodes, parameterDeviceC->isEvenTimestep, - icellFC->ICellFCC, - icellFC->ICellFCF, - icellFC->kFC, + fineToCoarse->coarseCellIndices, + fineToCoarse->fineCellIndices, + fineToCoarse->numberOfCells, parameterDeviceC->omega, parameterDeviceF->omega, - parameterDeviceC->vis, + parameterDeviceC->viscosity, parameterDeviceC->nx, parameterDeviceC->ny, parameterDeviceF->nx, parameterDeviceF->ny, - offsetFC); + neighborFineToCoarse); getLastCudaError("scaleFC_RhoSq_comp_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// -template<bool hasTurbulentViscosity> void ScaleFC_compressible(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICellFC * icellFC, OffFC &offsetFC, CUstream_st *stream) +template<bool hasTurbulentViscosity> void ScaleFC_compressible(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICells * fineToCoarse, ICellNeigh &neighborFineToCoarse, CUstream_st *stream) { - dim3 grid = vf::cuda::getCudaGrid(parameterDeviceC->numberofthreads, icellFC->kFC); + dim3 grid = vf::cuda::getCudaGrid(parameterDeviceC->numberofthreads, fineToCoarse->numberOfCells); dim3 threads(parameterDeviceC->numberofthreads, 1, 1 ); scaleFC_compressible<hasTurbulentViscosity><<<grid, threads, 0, stream>>>( @@ -4968,19 +4935,19 @@ template<bool hasTurbulentViscosity> void ScaleFC_compressible(LBMSimulationPara parameterDeviceC->numberOfNodes, parameterDeviceF->numberOfNodes, parameterDeviceC->isEvenTimestep, - icellFC->ICellFCC, - icellFC->ICellFCF, - icellFC->kFC, + fineToCoarse->coarseCellIndices, + fineToCoarse->fineCellIndices, + fineToCoarse->numberOfCells, parameterDeviceC->omega, parameterDeviceF->omega, parameterDeviceC->turbViscosity, parameterDeviceF->turbViscosity, - offsetFC); + neighborFineToCoarse); getLastCudaError("scaleFC_compressible execution failed"); } -template void ScaleFC_compressible<true>(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICellFC * icellFC, OffFC &offsetFC, CUstream_st *stream); -template void ScaleFC_compressible<false>(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICellFC * icellFC, OffFC &offsetFC, CUstream_st *stream); +template void ScaleFC_compressible<true>(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICells * fineToCoarse, ICellNeigh &neighborFineToCoarse, CUstream_st *stream); +template void ScaleFC_compressible<false>(LBMSimulationParameter * parameterDeviceC, LBMSimulationParameter* parameterDeviceF, ICells * fineToCoarse, ICellNeigh &neighborFineToCoarse, CUstream_st *stream); ////////////////////////////////////////////////////////////////////////// void ScaleFC_RhoSq_3rdMom_comp_27( @@ -5006,7 +4973,7 @@ void ScaleFC_RhoSq_3rdMom_comp_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC, + ICellNeigh neighborFineToCoarse, CUstream_st *stream) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -5033,7 +5000,7 @@ void ScaleFC_RhoSq_3rdMom_comp_27( nyC, nxF, nyF, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFC_RhoSq_3rdMom_comp_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -5060,7 +5027,7 @@ void ScaleFC_AA2016_comp_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC, + ICellNeigh neighborFineToCoarse, CUstream_st *stream) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -5087,7 +5054,7 @@ void ScaleFC_AA2016_comp_27( nyC, nxF, nyF, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFC_AA2016_comp_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -5114,7 +5081,7 @@ void ScaleFC_NSPress_27( unsigned int nxF, unsigned int nyF, unsigned int numberOfThreads, - OffFC offFC) + ICellNeigh neighborFineToCoarse) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -5140,7 +5107,7 @@ void ScaleFC_NSPress_27( nyC, nxF, nyF, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFC_NSPress_27 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -5164,7 +5131,7 @@ void ScaleFCThSMG7( real nu, real diffusivity_coarse, unsigned int numberOfThreads, - OffFC offFC) + ICellNeigh neighborFineToCoarse) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -5187,7 +5154,7 @@ void ScaleFCThSMG7( kFC, nu, diffusivity_coarse, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFCThSMG7 execution failed"); } ////////////////////////////////////////////////////////////////////////// @@ -5256,7 +5223,7 @@ void ScaleFCThS27( real nu, real diffusivity_coarse, unsigned int numberOfThreads, - OffFC offFC) + ICellNeigh neighborFineToCoarse) { vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(numberOfThreads, kFC); @@ -5279,7 +5246,7 @@ void ScaleFCThS27( kFC, nu, diffusivity_coarse, - offFC); + neighborFineToCoarse); getLastCudaError("scaleFCThS27 execution failed"); } ////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/NoSlipBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/NoSlipBCs27.cu index 79dedee58afb7b11c4c3ede9911f54df65cf859f..0013ae977d41cb52ce163a53f2f1342d4d7b4c73 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/NoSlipBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/NoSlipBCs27.cu @@ -32,10 +32,10 @@ //====================================================================================== #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> #include "LBM/GPUHelperFunctions/KernelUtilities.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; diff --git a/src/gpu/VirtualFluids_GPU/GPU/Particles.cu b/src/gpu/VirtualFluids_GPU/GPU/Particles.cu index 22d9df4a3b4ae706dcf9b76d93940122015248f1..7a82c694ef55ff5bc6770b9ae333e2de7ed1938c 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Particles.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Particles.cu @@ -1,9 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; ////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/PrecursorBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/PrecursorBCs27.cu index 177eb41587896dd7993b06f98a1506abfc4f3f5f..64c6b6085c353e16c08f9057f603a7799ce14289 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/PrecursorBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/PrecursorBCs27.cu @@ -31,13 +31,13 @@ //! \author Henry Korb, Henrik Asmuth //====================================================================================== #include "LBM/LB.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> #include <lbm/constants/D3Q27.h> #include <lbm/MacroscopicQuantities.h> #include "LBM/GPUHelperFunctions/KernelUtilities.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; diff --git a/src/gpu/VirtualFluids_GPU/GPU/PressBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/PressBCs27.cu index 02cfd2bce3723162b645cef568c87ca3b1dd2720..e0ea3c05251e995c55c2b980327059dfa7fd4069 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/PressBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/PressBCs27.cu @@ -32,11 +32,11 @@ //====================================================================================== #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include "lbm/MacroscopicQuantities.h" #include "LBM/GPUHelperFunctions/KernelUtilities.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; diff --git a/src/gpu/VirtualFluids_GPU/GPU/Random.cu b/src/gpu/VirtualFluids_GPU/GPU/Random.cu index a605fbd42d2977e0f0b6e15aeb50f8c78654f31c..2f9417f2404d773b222f1b79f8456adfaf741018 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/Random.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/Random.cu @@ -1,9 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; //random numbers diff --git a/src/gpu/VirtualFluids_GPU/GPU/SchlafferBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/SchlafferBCs27.cu index 5d4572e234fdcad072e9b666c911f3250c32346a..70e938db5df2bae442034ce0303081e8b175e5f6 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/SchlafferBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/SchlafferBCs27.cu @@ -1,9 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; // TODO: https://git.rz.tu-bs.de/irmb/VirtualFluids_dev/-/issues/29 diff --git a/src/gpu/VirtualFluids_GPU/GPU/SetForcing27.cu b/src/gpu/VirtualFluids_GPU/GPU/SetForcing27.cu index 07fc5853eb7042d5567c38a03cb27418142bf642..d847d00193f68127927e2f3fa3fbf1eda7f9a736 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/SetForcing27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/SetForcing27.cu @@ -1,9 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/SlipBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/SlipBCs27.cu index 80e3c273987092aa63e4a2724df0df3df7152145..ecd7427665427376aaee290e918fd5c723576f73 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/SlipBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/SlipBCs27.cu @@ -33,10 +33,10 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" #include "Kernel/Utilities/DistributionHelper.cuh" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include "LBM/GPUHelperFunctions/KernelUtilities.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; diff --git a/src/gpu/VirtualFluids_GPU/GPU/StressBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/StressBCs27.cu index 0838402693e469efb10be2f9cd59094107383b66..1cc5017816aed29d52e74823a8c910bfed35ad42 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/StressBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/StressBCs27.cu @@ -43,10 +43,10 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" #include "Kernel/Utilities/DistributionHelper.cuh" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> #include "LBM/GPUHelperFunctions/KernelUtilities.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; diff --git a/src/gpu/VirtualFluids_GPU/GPU/ThinWallBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/ThinWallBCs27.cu index b96d961c9b92ae5d041beeb23482d7144e7a8acb..f76b31c768553aed46fd640d9cdace8ba753b6b8 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/ThinWallBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/ThinWallBCs27.cu @@ -9,9 +9,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; ///////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/GPU/TurbulenceIntensity.cu b/src/gpu/VirtualFluids_GPU/GPU/TurbulenceIntensity.cu index 3f440454ef272b13c24fe2a2882d67d32d32a841..82e5f98fda0086458f2bc937dbe33e7b66feb2c5 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/TurbulenceIntensity.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/TurbulenceIntensity.cu @@ -9,14 +9,14 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include "lbm/MacroscopicQuantities.h" #include "../Kernel/Utilities/DistributionHelper.cuh" #include "LBM/GPUHelperFunctions/KernelUtilities.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; diff --git a/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosityInlines.cuh b/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosityInlines.cuh index 58856f624fa1dfd2488c3061721e9dac53a67d07..ebf67339b65782a5c10c1b756c3fe5e06c3977d1 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosityInlines.cuh +++ b/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosityInlines.cuh @@ -38,9 +38,9 @@ #include <cuda_runtime.h> #include "LBM/LB.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; __inline__ __device__ real calcTurbulentViscositySmagorinsky(real Cs, real dxux, real dyuy, real dzuz, real Dxy, real Dxz , real Dyz) { diff --git a/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosityKernels.cu b/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosityKernels.cu index 7147629c448b8b730e4ae8c4eff8a0a400863de9..d00941aba35d2885e893eea1ffe23c89002046c4 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosityKernels.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosityKernels.cu @@ -32,7 +32,7 @@ //====================================================================================== #include "TurbulentViscosityKernels.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include "Parameter/Parameter.h" #include "cuda/CudaGrid.h" #include <cuda_runtime.h> @@ -40,7 +40,7 @@ #include "LBM/LB.h" #include "LBM/GPUHelperFunctions/KernelUtilities.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; __host__ __device__ __forceinline__ void calcDerivatives(const uint& k, uint& kM, uint& kP, uint* typeOfGridNode, real* vx, real* vy, real* vz, real& dvx, real& dvy, real& dvz) { diff --git a/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosityKernels.h b/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosityKernels.h index b227e680301cd4639d48a5cf3ce74f08eb7e1b9f..74d0e69a181e94c6d34e9207f203fb852d9d2fd1 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosityKernels.h +++ b/src/gpu/VirtualFluids_GPU/GPU/TurbulentViscosityKernels.h @@ -38,10 +38,10 @@ #include <cuda_runtime.h> #include "LBM/LB.h" -#include "Core/DataTypes.h" -#include <lbm/constants/NumericConstants.h> +#include "DataTypes.h" +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; class Parameter; diff --git a/src/gpu/VirtualFluids_GPU/GPU/VelocityBCs27.cu b/src/gpu/VirtualFluids_GPU/GPU/VelocityBCs27.cu index ccf9d1771ec0e1895e5cb79fae63675429b02c73..6207c98f9290520199e3cd9c31294ef5520b1798 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/VelocityBCs27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/VelocityBCs27.cu @@ -32,10 +32,10 @@ //====================================================================================== #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include "LBM/GPUHelperFunctions/KernelUtilities.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; @@ -857,254 +857,6 @@ __global__ void QVeloDeviceEQ27( -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -__global__ void QVeloStreetDeviceEQ27( - real* veloXfraction, - real* veloYfraction, - int* naschVelo, - real* DD, - int* naschIndex, - int numberOfStreetNodes, - real velocityRatio, - uint* neighborX, - uint* neighborY, - uint* neighborZ, - unsigned long long numberOfLBnodes, - bool isEvenTimestep) -{ - //////////////////////////////////////////////////////////////////////////////// - const unsigned x = threadIdx.x; // Globaler x-Index - const unsigned y = blockIdx.x; // Globaler y-Index - const unsigned z = blockIdx.y; // Globaler z-Index - - const unsigned nx = blockDim.x; - const unsigned ny = gridDim.x; - - const unsigned k = nx*(ny*z + y) + x; - ////////////////////////////////////////////////////////////////////////// - - if (k < numberOfStreetNodes) - { - //////////////////////////////////////////////////////////////////////////////// - //index - unsigned int KQK = naschIndex[k]; - unsigned int kzero = KQK; - unsigned int ke = KQK; - unsigned int kw = neighborX[KQK]; - unsigned int kn = KQK; - unsigned int ks = neighborY[KQK]; - unsigned int kt = KQK; - unsigned int kb = neighborZ[KQK]; - unsigned int ksw = neighborY[kw]; - unsigned int kne = KQK; - unsigned int kse = ks; - unsigned int knw = kw; - unsigned int kbw = neighborZ[kw]; - unsigned int kte = KQK; - unsigned int kbe = kb; - unsigned int ktw = kw; - unsigned int kbs = neighborZ[ks]; - unsigned int ktn = KQK; - unsigned int kbn = kb; - unsigned int kts = ks; - unsigned int ktse = ks; - unsigned int kbnw = kbw; - unsigned int ktnw = kw; - unsigned int kbse = kbs; - unsigned int ktsw = ksw; - unsigned int kbne = kb; - unsigned int ktne = KQK; - unsigned int kbsw = neighborZ[ksw]; - //////////////////////////////////////////////////////////////////////////////// - Distributions27 D; - if (isEvenTimestep == true) - { - D.f[DIR_P00] = &DD[DIR_P00 * numberOfLBnodes]; - D.f[DIR_M00] = &DD[DIR_M00 * numberOfLBnodes]; - D.f[DIR_0P0] = &DD[DIR_0P0 * numberOfLBnodes]; - D.f[DIR_0M0] = &DD[DIR_0M0 * numberOfLBnodes]; - D.f[DIR_00P] = &DD[DIR_00P * numberOfLBnodes]; - D.f[DIR_00M] = &DD[DIR_00M * numberOfLBnodes]; - D.f[DIR_PP0] = &DD[DIR_PP0 * numberOfLBnodes]; - D.f[DIR_MM0] = &DD[DIR_MM0 * numberOfLBnodes]; - D.f[DIR_PM0] = &DD[DIR_PM0 * numberOfLBnodes]; - D.f[DIR_MP0] = &DD[DIR_MP0 * numberOfLBnodes]; - D.f[DIR_P0P] = &DD[DIR_P0P * numberOfLBnodes]; - D.f[DIR_M0M] = &DD[DIR_M0M * numberOfLBnodes]; - D.f[DIR_P0M] = &DD[DIR_P0M * numberOfLBnodes]; - D.f[DIR_M0P] = &DD[DIR_M0P * numberOfLBnodes]; - D.f[DIR_0PP] = &DD[DIR_0PP * numberOfLBnodes]; - D.f[DIR_0MM] = &DD[DIR_0MM * numberOfLBnodes]; - D.f[DIR_0PM] = &DD[DIR_0PM * numberOfLBnodes]; - D.f[DIR_0MP] = &DD[DIR_0MP * numberOfLBnodes]; - D.f[DIR_000] = &DD[DIR_000 * numberOfLBnodes]; - D.f[DIR_PPP] = &DD[DIR_PPP * numberOfLBnodes]; - D.f[DIR_MMP] = &DD[DIR_MMP * numberOfLBnodes]; - D.f[DIR_PMP] = &DD[DIR_PMP * numberOfLBnodes]; - D.f[DIR_MPP] = &DD[DIR_MPP * numberOfLBnodes]; - D.f[DIR_PPM] = &DD[DIR_PPM * numberOfLBnodes]; - D.f[DIR_MMM] = &DD[DIR_MMM * numberOfLBnodes]; - D.f[DIR_PMM] = &DD[DIR_PMM * numberOfLBnodes]; - D.f[DIR_MPM] = &DD[DIR_MPM * numberOfLBnodes]; - } - else - { - D.f[DIR_M00] = &DD[DIR_P00 * numberOfLBnodes]; - D.f[DIR_P00] = &DD[DIR_M00 * numberOfLBnodes]; - D.f[DIR_0M0] = &DD[DIR_0P0 * numberOfLBnodes]; - D.f[DIR_0P0] = &DD[DIR_0M0 * numberOfLBnodes]; - D.f[DIR_00M] = &DD[DIR_00P * numberOfLBnodes]; - D.f[DIR_00P] = &DD[DIR_00M * numberOfLBnodes]; - D.f[DIR_MM0] = &DD[DIR_PP0 * numberOfLBnodes]; - D.f[DIR_PP0] = &DD[DIR_MM0 * numberOfLBnodes]; - D.f[DIR_MP0] = &DD[DIR_PM0 * numberOfLBnodes]; - D.f[DIR_PM0] = &DD[DIR_MP0 * numberOfLBnodes]; - D.f[DIR_M0M] = &DD[DIR_P0P * numberOfLBnodes]; - D.f[DIR_P0P] = &DD[DIR_M0M * numberOfLBnodes]; - D.f[DIR_M0P] = &DD[DIR_P0M * numberOfLBnodes]; - D.f[DIR_P0M] = &DD[DIR_M0P * numberOfLBnodes]; - D.f[DIR_0MM] = &DD[DIR_0PP * numberOfLBnodes]; - D.f[DIR_0PP] = &DD[DIR_0MM * numberOfLBnodes]; - D.f[DIR_0MP] = &DD[DIR_0PM * numberOfLBnodes]; - D.f[DIR_0PM] = &DD[DIR_0MP * numberOfLBnodes]; - D.f[DIR_000] = &DD[DIR_000 * numberOfLBnodes]; - D.f[DIR_PPP] = &DD[DIR_MMM * numberOfLBnodes]; - D.f[DIR_MMP] = &DD[DIR_PPM * numberOfLBnodes]; - D.f[DIR_PMP] = &DD[DIR_MPM * numberOfLBnodes]; - D.f[DIR_MPP] = &DD[DIR_PMM * numberOfLBnodes]; - D.f[DIR_PPM] = &DD[DIR_MMP * numberOfLBnodes]; - D.f[DIR_MMM] = &DD[DIR_PPP * numberOfLBnodes]; - D.f[DIR_PMM] = &DD[DIR_MPP * numberOfLBnodes]; - D.f[DIR_MPM] = &DD[DIR_PMP * numberOfLBnodes]; - } - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // based on BGK Plus Comp - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - real mfcbb = (D.f[DIR_P00])[ke ]; - real mfabb = (D.f[DIR_M00])[kw ]; - real mfbcb = (D.f[DIR_0P0])[kn ]; - real mfbab = (D.f[DIR_0M0])[ks ]; - real mfbbc = (D.f[DIR_00P])[kt ]; - real mfbba = (D.f[DIR_00M])[kb ]; - real mfccb = (D.f[DIR_PP0])[kne ]; - real mfaab = (D.f[DIR_MM0])[ksw ]; - real mfcab = (D.f[DIR_PM0])[kse ]; - real mfacb = (D.f[DIR_MP0])[knw ]; - real mfcbc = (D.f[DIR_P0P])[kte ]; - real mfaba = (D.f[DIR_M0M])[kbw ]; - real mfcba = (D.f[DIR_P0M])[kbe ]; - real mfabc = (D.f[DIR_M0P])[ktw ]; - real mfbcc = (D.f[DIR_0PP])[ktn ]; - real mfbaa = (D.f[DIR_0MM])[kbs ]; - real mfbca = (D.f[DIR_0PM])[kbn ]; - real mfbac = (D.f[DIR_0MP])[kts ]; - real mfbbb = (D.f[DIR_000])[kzero]; - real mfccc = (D.f[DIR_PPP])[ktne ]; - real mfaac = (D.f[DIR_MMP])[ktsw ]; - real mfcac = (D.f[DIR_PMP])[ktse ]; - real mfacc = (D.f[DIR_MPP])[ktnw ]; - real mfcca = (D.f[DIR_PPM])[kbne ]; - real mfaaa = (D.f[DIR_MMM])[kbsw ]; - real mfcaa = (D.f[DIR_PMM])[kbse ]; - real mfaca = (D.f[DIR_MPM])[kbnw ]; - //////////////////////////////////////////////////////////////////////////////////// - real rho = (mfccc + mfaaa + mfaca + mfcac + mfacc + mfcaa + mfaac + mfcca + - mfbac + mfbca + mfbaa + mfbcc + mfabc + mfcba + mfaba + mfcbc + mfacb + mfcab + mfaab + mfccb + - mfabb + mfcbb + mfbab + mfbcb + mfbba + mfbbc + mfbbb + c1o1); - //!!!!Achtung + one - //////////////////////////////////////////////////////////////////////////////////// - real vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + - (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + - (mfcbb - mfabb)) / rho; - real vvy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + - (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + - (mfbcb - mfbab)) / rho; - real vvz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + - (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + - (mfbbc - mfbba)) / rho; - //////////////////////////////////////////////////////////////////////////////////// - if (naschVelo[k] >= 0) - { - real VeloX = naschVelo[k] * veloXfraction[k] / velocityRatio; - real VeloY = naschVelo[k] * veloYfraction[k] / velocityRatio; - vvx = VeloX; - vvy = VeloY; - } - //////////////////////////////////////////////////////////////////////////////////// - real vx2 = vvx * vvx; - real vy2 = vvy * vvy; - real vz2 = vvz * vvz; - //////////////////////////////////////////////////////////////////////////////////// - real XXb = -c2o3 + vx2; - real XXc = -c1o2 * (XXb + c1o1 + vvx); - real XXa = XXc + vvx; - real YYb = -c2o3 + vy2; - real YYc = -c1o2 * (YYb + c1o1 + vvy); - real YYa = YYc + vvy; - real ZZb = -c2o3 + vz2; - real ZZc = -c1o2 * (ZZb + c1o1 + vvz); - real ZZa = ZZc + vvz; - //////////////////////////////////////////////////////////////////////////////////// - mfcbb = -rho * XXc * YYb * ZZb - c2o27; - mfabb = -rho * XXa * YYb * ZZb - c2o27; - mfbcb = -rho * XXb * YYc * ZZb - c2o27; - mfbab = -rho * XXb * YYa * ZZb - c2o27; - mfbbc = -rho * XXb * YYb * ZZc - c2o27; - mfbba = -rho * XXb * YYb * ZZa - c2o27; - mfccb = -rho * XXc * YYc * ZZb - c1o54; - mfaab = -rho * XXa * YYa * ZZb - c1o54; - mfcab = -rho * XXc * YYa * ZZb - c1o54; - mfacb = -rho * XXa * YYc * ZZb - c1o54; - mfcbc = -rho * XXc * YYb * ZZc - c1o54; - mfaba = -rho * XXa * YYb * ZZa - c1o54; - mfcba = -rho * XXc * YYb * ZZa - c1o54; - mfabc = -rho * XXa * YYb * ZZc - c1o54; - mfbcc = -rho * XXb * YYc * ZZc - c1o54; - mfbaa = -rho * XXb * YYa * ZZa - c1o54; - mfbca = -rho * XXb * YYc * ZZa - c1o54; - mfbac = -rho * XXb * YYa * ZZc - c1o54; - mfbbb = -rho * XXb * YYb * ZZb - c8o27; - mfccc = -rho * XXc * YYc * ZZc - c1o216; - mfaac = -rho * XXa * YYa * ZZc - c1o216; - mfcac = -rho * XXc * YYa * ZZc - c1o216; - mfacc = -rho * XXa * YYc * ZZc - c1o216; - mfcca = -rho * XXc * YYc * ZZa - c1o216; - mfaaa = -rho * XXa * YYa * ZZa - c1o216; - mfcaa = -rho * XXc * YYa * ZZa - c1o216; - mfaca = -rho * XXa * YYc * ZZa - c1o216; - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - (D.f[DIR_P00])[ke ] = mfabb;//mfcbb; - (D.f[DIR_M00])[kw ] = mfcbb;//mfabb; - (D.f[DIR_0P0])[kn ] = mfbab;//mfbcb; - (D.f[DIR_0M0])[ks ] = mfbcb;//mfbab; - (D.f[DIR_00P])[kt ] = mfbba;//mfbbc; - (D.f[DIR_00M])[kb ] = mfbbc;//mfbba; - (D.f[DIR_PP0])[kne ] = mfaab;//mfccb; - (D.f[DIR_MM0])[ksw ] = mfccb;//mfaab; - (D.f[DIR_PM0])[kse ] = mfacb;//mfcab; - (D.f[DIR_MP0])[knw ] = mfcab;//mfacb; - (D.f[DIR_P0P])[kte ] = mfaba;//mfcbc; - (D.f[DIR_M0M])[kbw ] = mfcbc;//mfaba; - (D.f[DIR_P0M])[kbe ] = mfabc;//mfcba; - (D.f[DIR_M0P])[ktw ] = mfcba;//mfabc; - (D.f[DIR_0PP])[ktn ] = mfbaa;//mfbcc; - (D.f[DIR_0MM])[kbs ] = mfbcc;//mfbaa; - (D.f[DIR_0PM])[kbn ] = mfbac;//mfbca; - (D.f[DIR_0MP])[kts ] = mfbca;//mfbac; - (D.f[DIR_000])[kzero] = mfbbb;//mfbbb; - (D.f[DIR_PPP])[ktne ] = mfaaa;//mfccc; - (D.f[DIR_MMP])[ktsw ] = mfcca;//mfaac; - (D.f[DIR_PMP])[ktse ] = mfaca;//mfcac; - (D.f[DIR_MPP])[ktnw ] = mfcaa;//mfacc; - (D.f[DIR_PPM])[kbne ] = mfaac;//mfcca; - (D.f[DIR_MMM])[kbsw ] = mfccc;//mfaaa; - (D.f[DIR_PMM])[kbse ] = mfacc;//mfcaa; - (D.f[DIR_MPM])[kbnw ] = mfcac;//mfaca; - } -} -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - diff --git a/src/gpu/VirtualFluids_GPU/GPU/WaleCumulant27.cu b/src/gpu/VirtualFluids_GPU/GPU/WaleCumulant27.cu index cbb892296322bc164241ad18c8ab63201d34647e..6bac690a881494520a33e901c35c3f51e4d2bfc7 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/WaleCumulant27.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/WaleCumulant27.cu @@ -1,9 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/GPU/WallFunction.cu b/src/gpu/VirtualFluids_GPU/GPU/WallFunction.cu index d2fe5935af9b2d3ad78f492e3a9d182873d20808..6de196e1788494b20c24a73cb9ec02a360f868ea 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/WallFunction.cu +++ b/src/gpu/VirtualFluids_GPU/GPU/WallFunction.cu @@ -1,9 +1,9 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; diff --git a/src/gpu/VirtualFluids_GPU/Init/InitLattice.cpp b/src/gpu/VirtualFluids_GPU/Init/InitLattice.cpp index 508e4498c36d352761c3ecaf24abaa52a5f84bbe..ba4a5cae5259ff43a1d85e6ee97dd125e3da912f 100644 --- a/src/gpu/VirtualFluids_GPU/Init/InitLattice.cpp +++ b/src/gpu/VirtualFluids_GPU/Init/InitLattice.cpp @@ -82,7 +82,7 @@ void initLattice(SPtr<Parameter> para, SPtr<PreProcessor> preProcessor, SPtr<Cud cudaMemoryManager->cudaAllocConcentration(lev); for (size_t index = 0; index < para->getParH(lev)->numberOfNodes; index++) { - para->getParH(lev)->Conc[index] = para->getTemperatureInit(); + para->getParH(lev)->concentration[index] = para->getTemperatureInit(); } initTemperatur(para.get(), cudaMemoryManager.get(), lev); } diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod27/ADComp27/ADComp27.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod27/ADComp27/ADComp27.cu index dd30516ac4229908a418d932177c1b63d8f5d685..4d4467acb20232ecb364451f61265b71f1692517 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod27/ADComp27/ADComp27.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod27/ADComp27/ADComp27.cu @@ -20,7 +20,7 @@ void ADComp27::run() para->getParD(level)->neighborY, para->getParD(level)->neighborZ, para->getParD(level)->distributions.f[0], - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->numberOfNodes, para->getParD(level)->isEvenTimestep); getLastCudaError("LB_KERNEL_AD_COMP_27 execution failed"); diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod27/ADComp27/ADComp27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod27/ADComp27/ADComp27_Device.cu index 40adfff91713b7d6db1e861be9282d1f38516c22..eb6c9814efdedb822ddc3052d6b577750be83b12 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod27/ADComp27/ADComp27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod27/ADComp27/ADComp27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod7/ADComp7/ADComp7_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod7/ADComp7/ADComp7_Device.cu index ddaed84703640cd9c7d12d142ccc1bf8f9ea7efc..075063bc6c3d260376256bd46f5669fae658a7a0 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod7/ADComp7/ADComp7_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Compressible/Mod7/ADComp7/ADComp7_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod27/ADIncomp27/ADIncomp27.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod27/ADIncomp27/ADIncomp27.cu index 150245a312509d50b77cf86fec18fdb063dbcc2c..3c10e7a6996a9a26668a18390ddee4e2cbbec853 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod27/ADIncomp27/ADIncomp27.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod27/ADIncomp27/ADIncomp27.cu @@ -20,7 +20,7 @@ void ADIncomp27::run() para->getParD(level)->neighborY, para->getParD(level)->neighborZ, para->getParD(level)->distributions.f[0], - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->numberOfNodes, para->getParD(level)->isEvenTimestep); getLastCudaError("LB_Kernel_AD_Incomp_27 execution failed"); diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod27/ADIncomp27/ADIncomp27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod27/ADIncomp27/ADIncomp27_Device.cu index f9fdcee0f34106b05da0edc16e3fdd89f859752e..4a5cbb1168940bd6bfc9d9a48568b5964b736ae4 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod27/ADIncomp27/ADIncomp27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod27/ADIncomp27/ADIncomp27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod7/ADIncomp7/ADIncomp7_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod7/ADIncomp7/ADIncomp7_Device.cu index e0bcc4e515b1b2ccf71f1050e2d572b60a40d94b..1d393e0c4a5f80fb331c109311876673a86a9d8d 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod7/ADIncomp7/ADIncomp7_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/AdvectionDiffusion/Incompressible/Mod7/ADIncomp7/ADIncomp7_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGK/BGKCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGK/BGKCompSP27_Device.cu index 3bdb65c455bd67d66e8b35961f2fa7e1de45f763..44add98d9607642531a6068021d0a4e831cb3d4e 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGK/BGKCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGK/BGKCompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKPlus/BGKPlusCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKPlus/BGKPlusCompSP27_Device.cu index 1f44fee9ea8b20241f87bea6310c96db2b82d1c4..638210bd2da8ebf30bda603a3f6d70c19468193e 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKPlus/BGKPlusCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/BGKPlus/BGKPlusCompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cascade/CascadeCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cascade/CascadeCompSP27_Device.cu index af0a7c118191243c80c420856a70711a1fc17d2b..6bd4415c7edcb5c9954874c074801b865cce3efe 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cascade/CascadeCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cascade/CascadeCompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cumulant/CumulantCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cumulant/CumulantCompSP27_Device.cu index 1dfab5846795e61509cdba28478fe6ce623983b5..6ab3385b86611614eceeb0018f6beef73031711c 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cumulant/CumulantCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/Cumulant/CumulantCompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantAll4/CumulantAll4CompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantAll4/CumulantAll4CompSP27_Device.cu index 3593b41c4c62c8a8b19719e22e9d65d6b5fd987d..7a5e39d6f1f95f5b34bb38f1514ab728f477c34b 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantAll4/CumulantAll4CompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantAll4/CumulantAll4CompSP27_Device.cu @@ -2,9 +2,9 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp_Device.cu index f7fb1f0a6441cfc6f38ad9684fd5bc8dd1be7135..9c5d484ee00c1dfab92e1d5eaf0cdffb61fd122b 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15/CumulantK15Comp_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Bulk/CumulantK15BulkComp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Bulk/CumulantK15BulkComp_Device.cu index 085775d324bf65d783afdd745c06429d697c3788..c0e48a9d5754f79d62b11129cef754adf91dbe03 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Bulk/CumulantK15BulkComp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Bulk/CumulantK15BulkComp_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Sponge/CumulantK15SpongeComp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Sponge/CumulantK15SpongeComp_Device.cu index 13788e65e70eb30803111a39a70d39682648a006..20f3f913589f26978dcf713cd0175fc2ad425545 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Sponge/CumulantK15SpongeComp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK15Sponge/CumulantK15SpongeComp_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17/CumulantK17_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17/CumulantK17_Device.cu index 2044c6ad8d7f242c96479cd060c70b91c1dfb216..c206381d4b54130a7a5489536729465f398e5ee4 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17/CumulantK17_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17/CumulantK17_Device.cu @@ -43,13 +43,13 @@ //======================================================================================= #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include "LBM/GPUHelperFunctions/KernelUtilities.h" #include "LBM/GPUHelperFunctions/ChimeraTransformation.h" #include "GPU/TurbulentViscosityInlines.cuh" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Bulk/CumulantK17BulkComp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Bulk/CumulantK17BulkComp_Device.cu index b33a3c251b5fb0cde8b1da0fcce097f955353d69..5e98ebe6db990f5d16fd9d7a839c0e5f0927ba87 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Bulk/CumulantK17BulkComp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17Bulk/CumulantK17BulkComp_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim_Device.cu index a0db78d27b00372feab8490111183481abbec8b9..1da801654adb3682ea11ca87c7c7a2fd10b065d3 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17chim/CumulantK17CompChim_Device.cu @@ -33,10 +33,10 @@ /* Device code */ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include "LBM/GPUHelperFunctions/ChimeraTransformation.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK18/CumulantK18Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK18/CumulantK18Comp_Device.cu index 0e4ae5caebb9bd4b1c889a78bfadb62487742c98..c585c19aaca870e97fec63b0cd1742f7aad32556 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK18/CumulantK18Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK18/CumulantK18Comp_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK20/CumulantK20Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK20/CumulantK20Comp_Device.cu index 2dbe0bb62412f9363fdd0e714f5da296f81ae5b3..0a26eff29c3624bd78ef7dd4a8f675b8cb1a99d3 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK20/CumulantK20Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK20/CumulantK20Comp_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/MRT/MRTCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/MRT/MRTCompSP27_Device.cu index c3eb51a114e5c4a3be7605765d0889a7bae25cf0..41b24a349da75586be4fb818c9eb3f194a2447fd 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/MRT/MRTCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Compressible/MRT/MRTCompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGK/BGKIncompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGK/BGKIncompSP27_Device.cu index 233595656720f5c84cf5be9e555565af0e9c95d0..6cfde7648bdfe8808cb39dd1b80d6537bb3c3280 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGK/BGKIncompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGK/BGKIncompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGKPlus/BGKPlusIncompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGKPlus/BGKPlusIncompSP27_Device.cu index b49b76c6224be4b3543c01647a6553e6fc64b74e..1fee181619070e3bc30370a1bc32b949a3af9a2a 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGKPlus/BGKPlusIncompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/BGKPlus/BGKPlusIncompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cascade/CascadeIncompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cascade/CascadeIncompSP27_Device.cu index 8e607cabb4cc40bbb22c5ad3ec6db2c63154add6..0346f12cf609c355aedd4743dd7f971f444d5fe9 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cascade/CascadeIncompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cascade/CascadeIncompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cumulant1hSP27/Cumulant1hIncompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cumulant1hSP27/Cumulant1hIncompSP27_Device.cu index 5130017acc642c92b064a500e79ff685ec2f6d97..ac88396b42483e3178869be585124fb031d099ec 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cumulant1hSP27/Cumulant1hIncompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/Cumulant1hSP27/Cumulant1hIncompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantIsoSP27/CumulantIsoIncompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantIsoSP27/CumulantIsoIncompSP27_Device.cu index 1f0ef2ec84c8d4b9b4be57548bde396c3316a80d..623d3c2c26b2c4d8fdfdaa718ca92662dfe5b548 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantIsoSP27/CumulantIsoIncompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantIsoSP27/CumulantIsoIncompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantK15/CumulantK15Incomp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantK15/CumulantK15Incomp_Device.cu index 01b60b3bf8067a81f99b912c4c0c700963f5448c..9fcfeaa97d97b9bfcf2ad0227464cbcabbc28f44 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantK15/CumulantK15Incomp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/CumulantK15/CumulantK15Incomp_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/MRT/MRTIncompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/MRT/MRTIncompSP27_Device.cu index a6663cc3c72696fda2ce9819203cd19195088730..2fbc7d64d5f10a2c6313647e508fbb2192dd435b 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/MRT/MRTIncompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/BasicKernels/FluidFlow/Incompressible/MRT/MRTIncompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/PorousMediaKernels/FluidFlow/Compressible/CumulantOne/PMCumulantOneCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/PorousMediaKernels/FluidFlow/Compressible/CumulantOne/PMCumulantOneCompSP27_Device.cu index 4f5f61f9d7a61fee8fd3438de5c588c861d8604c..1ed7cf3af37251550d38affe512f841a3779b918 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/PorousMediaKernels/FluidFlow/Compressible/CumulantOne/PMCumulantOneCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/PorousMediaKernels/FluidFlow/Compressible/CumulantOne/PMCumulantOneCompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15/WaleCumulantK15Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15/WaleCumulantK15Comp_Device.cu index a7018d1246c0832753df144ffbf2625b55f5508e..62658ccbdcead27f77d3b72d2daa311ade5baa59 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15/WaleCumulantK15Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15/WaleCumulantK15Comp_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15BySoniMalav/WaleBySoniMalavCumulantK15Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15BySoniMalav/WaleBySoniMalavCumulantK15Comp_Device.cu index 6258c72c36cafa27b06b2934db42a5813ed74f99..d266aac648c6163fb24764879f391304f32aba87 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15BySoniMalav/WaleBySoniMalavCumulantK15Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK15BySoniMalav/WaleBySoniMalavCumulantK15Comp_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17/WaleCumulantK17Comp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17/WaleCumulantK17Comp_Device.cu index e3161e0d26efe8993bb4b6c34bda32bf15af5d3d..71d3ed0604feb43422e3e738bb2ca9bca147ab17 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17/WaleCumulantK17Comp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17/WaleCumulantK17Comp_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17Debug/WaleCumulantK17DebugComp_Device.cu b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17Debug/WaleCumulantK17DebugComp_Device.cu index 63f4ecc8716fcd606fb6a75709408b0885d781e9..0a48c68059d794ddd7aed85c266604d51809d978 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17Debug/WaleCumulantK17DebugComp_Device.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Kernels/WaleKernels/FluidFlow/Compressible/CumulantK17Debug/WaleCumulantK17DebugComp_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelper.cu b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelper.cu index 240a6ffbace64147aa67224fe72c946761fdc452..a1d9ba6665576c90406eee13084e5133acdb448c 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelper.cu +++ b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/DistributionHelper.cu @@ -2,7 +2,7 @@ #include <cuda_runtime.h> -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include "lbm/constants/D3Q27.h" using namespace vf::lbm::dir; diff --git a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.cpp b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.cpp index 27c061ce99f71c349ac1c479efb5f9b780cff3b2..7b7b857d5c3ac157445bb154aecfb4dfa9c4b0bc 100644 --- a/src/gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.cpp +++ b/src/gpu/VirtualFluids_GPU/Kernel/Utilities/KernelFactory/KernelFactoryImp.cpp @@ -1,5 +1,7 @@ #include "KernelFactoryImp.h" +#include <logger/Logger.h> + #include "Parameter/Parameter.h" #include "Kernel/Utilities/KernelTypes.h" @@ -94,7 +96,7 @@ void KernelFactoryImp::setKernelAtLevel(std::vector<std::shared_ptr<Kernel>> ker std::shared_ptr<Kernel> KernelFactoryImp::makeKernel(std::shared_ptr<Parameter> para, std::string kernel, int level) { - printf("Instantiating Kernel: %s\n", kernel.c_str()); + VF_LOG_INFO("Instantiating Kernel: {}", kernel); std::shared_ptr<KernelImp> newKernel; std::shared_ptr<CheckParameterStrategy> checkStrategy; diff --git a/src/gpu/VirtualFluids_GPU/KernelManager/ADKernelManager.cpp b/src/gpu/VirtualFluids_GPU/KernelManager/ADKernelManager.cpp index 5a36daecd5a82fc8a052bf51fedc1cb35b94a960..34a0c589919058d4edd1969812c16e75941d28b4 100644 --- a/src/gpu/VirtualFluids_GPU/KernelManager/ADKernelManager.cpp +++ b/src/gpu/VirtualFluids_GPU/KernelManager/ADKernelManager.cpp @@ -56,7 +56,7 @@ void ADKernelManager::initAD(const int level) const para->getParD(level)->velocityY, para->getParD(level)->velocityZ, para->getParD(level)->numberOfNodes, - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->isEvenTimestep); ////////////////////////////////////////////////////////////////////////// para->getParD(level)->isEvenTimestep = false; @@ -72,7 +72,7 @@ void ADKernelManager::initAD(const int level) const para->getParD(level)->velocityY, para->getParD(level)->velocityZ, para->getParD(level)->numberOfNodes, - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->isEvenTimestep); ////////////////////////////////////////////////////////////////////////// CalcConcentration27( @@ -83,7 +83,7 @@ void ADKernelManager::initAD(const int level) const para->getParD(level)->neighborY, para->getParD(level)->neighborZ, para->getParD(level)->numberOfNodes, - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->isEvenTimestep); } @@ -173,7 +173,7 @@ void ADKernelManager::runADcollisionKernel(const int level)const para->getParD(level)->neighborY, para->getParD(level)->neighborZ, para->getParD(level)->distributions.f[0], - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->numberOfNodes, para->getParD(level)->forcing, para->getParD(level)->isEvenTimestep); @@ -188,7 +188,7 @@ void ADKernelManager::runADslipBCKernel(const int level) const{ para->getParD(level)->slipBC.normalY, para->getParD(level)->slipBC.normalZ, para->getParD(level)->distributions.f[0], - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->slipBC.k, para->getParD(level)->slipBC.q27[0], para->getParD(level)->slipBC.numberOfBCnodes, @@ -265,7 +265,7 @@ void ADKernelManager::runADpressureBCKernel(const int level) const{ QADPressDev27( para->getParD(level)->numberofthreads, para->getParD(level)->distributions.f[0], - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->TempPress.temp, para->getParD(level)->TempPress.velo, para->getParD(level)->diffusivity, @@ -346,7 +346,7 @@ void ADKernelManager::runADgeometryBCKernel(const int level) const QADBBDev27( para->getParD(level)->numberofthreads, para->getParD(level)->distributions.f[0], - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->Temp.temp, para->getParD(level)->diffusivity, para->getParD(level)->Temp.k, @@ -428,7 +428,7 @@ void ADKernelManager::runADveloBCKernel(const int level) const{ QADVelDev27( para->getParD(level)->numberofthreads, para->getParD(level)->distributions.f[0], - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->TempVel.tempPulse, para->getParD(level)->TempVel.velo, para->getParD(level)->diffusivity, @@ -498,7 +498,7 @@ void ADKernelManager::printAD(const int level, SPtr<CudaMemoryManager> cudaMemor para->getParD(level)->neighborY, para->getParD(level)->neighborZ, para->getParD(level)->numberOfNodes, - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->isEvenTimestep); cudaMemoryManager->cudaCopyConcentrationDeviceToHost(level); diff --git a/src/gpu/VirtualFluids_GPU/KernelManager/ADKernelManager.h b/src/gpu/VirtualFluids_GPU/KernelManager/ADKernelManager.h index 1c069a364ab5ef2837ffd05d0ef4b6488365e4e3..d961452575b905acb96fbc1c30ff0d5e71af2722 100644 --- a/src/gpu/VirtualFluids_GPU/KernelManager/ADKernelManager.h +++ b/src/gpu/VirtualFluids_GPU/KernelManager/ADKernelManager.h @@ -33,7 +33,7 @@ #ifndef ADVECTION_DIFFUSION_H #define ADVECTION_DIFFUSION_H -#include "Core/DataTypes.h" +#include "DataTypes.h" #include "PointerDefinitions.h" #include "VirtualFluids_GPU_export.h" diff --git a/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.cpp b/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.cpp index 0841d6931bba32440b47d02c9f83864a80f724be..229922b1ec1654e7ca664f9d19a7b7c6e264fd83 100644 --- a/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.cpp +++ b/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.cpp @@ -47,8 +47,8 @@ GridScalingKernelManager::GridScalingKernelManager(SPtr<Parameter> parameter, Gr if(!gridScalingFactory){ throw std::runtime_error("There is more than one level, but no scalingFactory was provided."); } - checkScalingFunction(gridScalingFactory->getGridScalingFC(parameter->getUseTurbulentViscosity()), this->para->getParD(0)->intFC, "scalingFineToCoarse"); - checkScalingFunction(gridScalingFactory->getGridScalingCF(parameter->getUseTurbulentViscosity()), this->para->getParD(0)->intCF, "scalingCoarseToFine"); + checkScalingFunction(gridScalingFactory->getGridScalingFC(parameter->getUseTurbulentViscosity()), this->para->getParD(0)->fineToCoarse, "scalingFineToCoarse"); + checkScalingFunction(gridScalingFactory->getGridScalingCF(parameter->getUseTurbulentViscosity()), this->para->getParD(0)->coarseToFine, "scalingCoarseToFine"); this->scalingFineToCoarse = gridScalingFactory->getGridScalingFC(parameter->getUseTurbulentViscosity()); this->scalingCoarseToFine = gridScalingFactory->getGridScalingCF(parameter->getUseTurbulentViscosity()); } @@ -59,11 +59,11 @@ GridScalingKernelManager::GridScalingKernelManager(SPtr<Parameter> parameter, Gr VF_LOG_TRACE("Function for scalingCoarseToFine is nullptr"); } -void GridScalingKernelManager::runFineToCoarseKernelLB(const int level, InterpolationCellFC *icellFC, OffFC &offFC, CudaStreamIndex streamIndex) const +void GridScalingKernelManager::runFineToCoarseKernelLB(const int level, InterpolationCells *fineToCoarse, ICellNeigh &neighborFineToCoarse, CudaStreamIndex streamIndex) const { cudaStream_t stream = para->getStreamManager()->getStream(streamIndex); - this->scalingFineToCoarse(para->getParD(level).get(), para->getParD(level+1).get(), icellFC, offFC, stream); + this->scalingFineToCoarse(para->getParD(level).get(), para->getParD(level+1).get(), fineToCoarse, neighborFineToCoarse, stream); // ScaleFC_comp_D3Q27F3( // para->getParD(level)->distributions.f[0], @@ -294,21 +294,21 @@ void GridScalingKernelManager::runFineToCoarseKernelAD(const int level) const para->getParD(level)->numberOfNodes, para->getParD(level+1)->numberOfNodes, para->getParD(level)->isEvenTimestep, - para->getParD(level)->intFC.ICellFCC, - para->getParD(level)->intFC.ICellFCF, - para->getParD(level)->K_FC, - para->getParD(level)->vis, + para->getParD(level)->fineToCoarse.coarseCellIndices, + para->getParD(level)->fineToCoarse.fineCellIndices, + para->getParD(level)->fineToCoarse.numberOfCells, + para->getParD(level)->viscosity, para->getParD(level)->diffusivity, para->getParD(level)->numberofthreads, - para->getParD(level)->offFC); + para->getParD(level)->neighborFineToCoarse); } else if (para->getDiffMod() == 27) { ScaleFCThS27( para->getParD(level)->distributions.f[0], para->getParD(level+1)->distributions.f[0], - para->getParD(level)->distributionsAD27.f[0], - para->getParD(level+1)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], + para->getParD(level+1)->distributionsAD.f[0], para->getParD(level)->neighborX, para->getParD(level)->neighborY, para->getParD(level)->neighborZ, @@ -318,20 +318,20 @@ void GridScalingKernelManager::runFineToCoarseKernelAD(const int level) const para->getParD(level)->numberOfNodes, para->getParD(level+1)->numberOfNodes, para->getParD(level)->isEvenTimestep, - para->getParD(level)->intFC.ICellFCC, - para->getParD(level)->intFC.ICellFCF, - para->getParD(level)->K_FC, - para->getParD(level)->vis, + para->getParD(level)->fineToCoarse.coarseCellIndices, + para->getParD(level)->fineToCoarse.fineCellIndices, + para->getParD(level)->fineToCoarse.numberOfCells, + para->getParD(level)->viscosity, para->getParD(level)->diffusivity, para->getParD(level)->numberofthreads, - para->getParD(level)->offFC); + para->getParD(level)->neighborFineToCoarse); } } -void GridScalingKernelManager::runCoarseToFineKernelLB(const int level, InterpolationCellCF* icellCF, OffCF &offCF, CudaStreamIndex streamIndex) const +void GridScalingKernelManager::runCoarseToFineKernelLB(const int level, InterpolationCells* coarseToFine, ICellNeigh &neighborFineToCoarse, CudaStreamIndex streamIndex) const { cudaStream_t stream = para->getStreamManager()->getStream(streamIndex); - this->scalingCoarseToFine(para->getParD(level).get(), para->getParD(level+1).get(), icellCF, offCF, stream); + this->scalingCoarseToFine(para->getParD(level).get(), para->getParD(level+1).get(), coarseToFine, neighborFineToCoarse, stream); // ScaleCF_comp_D3Q27F3( // para->getParD(level)->distributions.f[0], @@ -563,21 +563,21 @@ void GridScalingKernelManager::runCoarseToFineKernelAD(const int level) const para->getParD(level)->numberOfNodes, para->getParD(level+1)->numberOfNodes, para->getParD(level)->isEvenTimestep, - para->getParD(level)->intCF.ICellCFC, - para->getParD(level)->intCF.ICellCFF, - para->getParD(level)->K_CF, - para->getParD(level)->vis, + para->getParD(level)->coarseToFine.coarseCellIndices, + para->getParD(level)->coarseToFine.fineCellIndices, + para->getParD(level)->coarseToFine.numberOfCells, + para->getParD(level)->viscosity, para->getParD(level+1)->diffusivity, para->getParD(level)->numberofthreads, - para->getParD(level)->offCF); + para->getParD(level)->neighborCoarseToFine); } else if (para->getDiffMod() == 27) { ScaleCFThS27( para->getParD(level)->distributions.f[0], para->getParD(level+1)->distributions.f[0], - para->getParD(level)->distributionsAD27.f[0], - para->getParD(level+1)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], + para->getParD(level+1)->distributionsAD.f[0], para->getParD(level)->neighborX, para->getParD(level)->neighborY, para->getParD(level)->neighborZ, @@ -587,12 +587,12 @@ void GridScalingKernelManager::runCoarseToFineKernelAD(const int level) const para->getParD(level)->numberOfNodes, para->getParD(level+1)->numberOfNodes, para->getParD(level)->isEvenTimestep, - para->getParD(level)->intCF.ICellCFC, - para->getParD(level)->intCF.ICellCFF, - para->getParD(level)->K_CF, - para->getParD(level)->vis, + para->getParD(level)->coarseToFine.coarseCellIndices, + para->getParD(level)->coarseToFine.fineCellIndices, + para->getParD(level)->coarseToFine.numberOfCells, + para->getParD(level)->viscosity, para->getParD(level+1)->diffusivity, para->getParD(level)->numberofthreads, - para->getParD(level)->offCF); + para->getParD(level)->neighborCoarseToFine); } } diff --git a/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.h b/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.h index 3c78ee7f9db254556e8ec6dbbafaf51cd995f10b..0c24801506b9a19985d1a805b349d0b58e9bbf84 100644 --- a/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.h +++ b/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.h @@ -36,7 +36,7 @@ #include "LBM/LB.h" #include "PointerDefinitions.h" #include "VirtualFluids_GPU_export.h" -#include "logger/Logger.h" +#include <logger/Logger.h> #include <functional> #include <memory> #include <stdexcept> @@ -48,10 +48,8 @@ enum class CudaStreamIndex; struct LBMSimulationParameter; struct CUstream_st; -using gridScalingFC = - std::function<void(LBMSimulationParameter *, LBMSimulationParameter *, ICellFC *, OffFC &, CUstream_st *stream)>; -using gridScalingCF = - std::function<void(LBMSimulationParameter *, LBMSimulationParameter *, ICellCF *, OffCF &, CUstream_st *stream)>; +using gridScaling = + std::function<void(LBMSimulationParameter *, LBMSimulationParameter *, ICells *, ICellNeigh &, CUstream_st *stream)>; //! \class GridScalingKernelManager //! \brief manage the cuda kernel calls @@ -64,13 +62,13 @@ public: GridScalingKernelManager(SPtr<Parameter> parameter, GridScalingFactory *gridScalingFactory); //! \brief calls the device function of the fine to coarse grid interpolation kernelH - void runFineToCoarseKernelLB(const int level, InterpolationCellFC *icellFC, OffFC &offFC, CudaStreamIndex streamIndex) const; + void runFineToCoarseKernelLB(const int level, InterpolationCells *fineToCoarse, ICellNeigh &neighborFineToCoarse, CudaStreamIndex streamIndex) const; //! \brief calls the device function of the fine to coarse grid interpolation kernel (advection diffusion) void runFineToCoarseKernelAD(const int level) const; //! \brief calls the device function of the coarse to fine grid interpolation kernel - void runCoarseToFineKernelLB(const int level, InterpolationCellCF *icellCF, OffCF &offCF, CudaStreamIndex streamIndex) const; + void runCoarseToFineKernelLB(const int level, InterpolationCells *coarseToFine, ICellNeigh &neighborCoarseToFine, CudaStreamIndex streamIndex) const; //! \brief calls the device function of the coarse to fine grid interpolation kernel (advection diffusion) void runCoarseToFineKernelAD(const int level) const; @@ -78,35 +76,21 @@ public: private: //! \brief check if grid scaling was set //! \throws std::runtime_error if interpolation nodes were assigned, but no scaling function was set in the grid - //! scaling factory \param scalingFunctionFC: a kernel function for the grid scaling \param scalingStruct: a struct + //! scaling factory \param scalingFunction: a kernel function for the grid scaling \param scalingStruct: a struct //! containing the grid nodes which are part of the interpolation \param scalingName: the name of the checked //! scaling function - void checkScalingFunction(const gridScalingFC &scalingFunctionFC, const InterpolationCellFC &scalingStruct, + void checkScalingFunction(const gridScaling &scalingFunction, const InterpolationCells &scalingStruct, const std::string &scalingName) { - if (!scalingFunctionFC && scalingStruct.kFC > 0) + if (!scalingFunction && scalingStruct.numberOfCells > 0) throw std::runtime_error("The scaling function " + scalingName + " was not set!"); - if (scalingFunctionFC && scalingStruct.kFC == 0) - VF_LOG_WARNING("The scaling function {} was set, although there is no refinement", scalingName); - } - - //! \brief check if grid scaling was set - //! \throws std::runtime_error if interpolation nodes were assigned, but no scaling function was set in the grid - //! scaling factory \param scalingFunctionCF: a kernel function for the grid scaling \param scalingStruct: a struct - //! containing the grid nodes which are part of the interpolation \param scalingName: the name of the checked - //! scaling function - void checkScalingFunction(const gridScalingCF &scalingFunctionCF, const InterpolationCellCF &scalingStruct, - const std::string &scalingName) - { - if (!scalingFunctionCF && scalingStruct.kCF > 0) - throw std::runtime_error("The scaling function " + scalingName + " was not set!"); - if (scalingFunctionCF && scalingStruct.kCF == 0) + if (scalingFunction && scalingStruct.numberOfCells == 0) VF_LOG_WARNING("The scaling function {} was set, although there is no refinement", scalingName); } SPtr<Parameter> para; - gridScalingFC scalingFineToCoarse = nullptr; - gridScalingCF scalingCoarseToFine = nullptr; + gridScaling scalingFineToCoarse = nullptr; + gridScaling scalingCoarseToFine = nullptr; }; #endif diff --git a/src/gpu/VirtualFluids_GPU/LBM/GPUHelperFunctions/ChimeraTransformation.h b/src/gpu/VirtualFluids_GPU/LBM/GPUHelperFunctions/ChimeraTransformation.h index 225f615ec3ad2d8ef11ec295f8d9e8a4166d99fe..4ba786cc1f281725ed24bc9f5c587f33cec78f56 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/GPUHelperFunctions/ChimeraTransformation.h +++ b/src/gpu/VirtualFluids_GPU/LBM/GPUHelperFunctions/ChimeraTransformation.h @@ -35,9 +35,9 @@ #include "LBM/LB.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; namespace vf::gpu { diff --git a/src/gpu/VirtualFluids_GPU/LBM/GPUHelperFunctions/KernelUtilities.h b/src/gpu/VirtualFluids_GPU/LBM/GPUHelperFunctions/KernelUtilities.h index e910f8ac5a71053d927e2531dcb225199d708749..5541bc54597ea02c5e3e89d00169b6eb6ff6564b 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/GPUHelperFunctions/KernelUtilities.h +++ b/src/gpu/VirtualFluids_GPU/LBM/GPUHelperFunctions/KernelUtilities.h @@ -35,9 +35,9 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; namespace vf::gpu diff --git a/src/gpu/VirtualFluids_GPU/LBM/GPUHelperFunctions/ScalingUtilities.h b/src/gpu/VirtualFluids_GPU/LBM/GPUHelperFunctions/ScalingUtilities.h index 53990e452be06dc6840c801816e8231d26861e2e..a7c1390c728df1d0ca83424fb7f9f4fb09faba65 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/GPUHelperFunctions/ScalingUtilities.h +++ b/src/gpu/VirtualFluids_GPU/LBM/GPUHelperFunctions/ScalingUtilities.h @@ -35,9 +35,9 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; namespace vf::gpu diff --git a/src/gpu/VirtualFluids_GPU/LBM/LB.h b/src/gpu/VirtualFluids_GPU/LBM/LB.h index cfdbbbae040a13f94e97d40d702b93d5a1e19c86..a5ae5f5ceef213e8ec9b2306106035a09b1ffd0d 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/LB.h +++ b/src/gpu/VirtualFluids_GPU/LBM/LB.h @@ -1,10 +1,35 @@ -// _ ___ __ __________ _ __ ______________ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ / ___/ __ / / / / -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ / /___/ /_/ / / / / -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) / /_) / ____/ /__/ / -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ \____/_/ \_____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // -////////////////////////////////////////////////////////////////////////// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file lb.h +//! \ingroup LBM +//! \author Martin Schoenherr +//=======================================================================================#ifndef _LB_H_ #ifndef _LB_H_ #define _LB_H_ @@ -45,7 +70,7 @@ #define INTERFACE_B 5 -#include "Core/DataTypes.h" +#include "DataTypes.h" #include <string> #include <vector> @@ -80,127 +105,33 @@ enum class CollisionTemplate { constexpr std::initializer_list<CollisionTemplate> all_CollisionTemplate = { CollisionTemplate::Default, CollisionTemplate::WriteMacroVars, CollisionTemplate::ApplyBodyForce, CollisionTemplate::AllFeatures, CollisionTemplate::SubDomainBorder}; constexpr std::initializer_list<CollisionTemplate> bulk_CollisionTemplate = { CollisionTemplate::Default, CollisionTemplate::WriteMacroVars, CollisionTemplate::ApplyBodyForce, CollisionTemplate::AllFeatures}; -struct InitCondition -{ - real Re; - real factorPressBC {1.0}; - real Diffusivity {0.001}; - real Temp {0.0}; - real TempBC {1.0}; - real RealX {1.0}; - real RealY {1.0}; - int numprocs {1}; - int myProcessId {0}; - int maxdev {1}; - uint tDoCheckPoint {0}; - uint tDoRestart {0}; - uint tCalcMedStart {0}; - uint tCalcMedEnd {10}; - uint tend {10}; - uint tout {1}; - uint tStartOut {0}; - uint PressInID {0}; - uint PressOutID {0}; - uint PressInZ {1}; - uint PressOutZ {2}; - std::vector<uint> devices {0, 1}; // one device with ID = 0 - std::vector<int> GridX, GridY, GridZ, DistX, DistY, DistZ; - std::vector<real> scaleLBMtoSI, translateLBMtoSI; - std::vector<real> minCoordX, minCoordY, minCoordZ, maxCoordX, maxCoordY, maxCoordZ; - std::string fname {"output/simulation"}; - std::string oPath {"output/"}; - std::string gridPath {"grid/"}; - std::string oPrefix {"simulation"}; - std::string geometryFileC, geometryFileM, geometryFileF; - std::string kFull, geoFull, geoVec, coordX, coordY, coordZ, neighborX, neighborY, neighborZ, neighborWSB, scaleCFC, scaleCFF, scaleFCC, scaleFCF, scaleOffsetCF, scaleOffsetFC; - std::string noSlipBcPos, noSlipBcQs, noSlipBcValue; - std::string slipBcPos, slipBcQs, slipBcValue; - std::string pressBcPos, pressBcQs, pressBcValue; - std::string geomBoundaryBcQs,velBcQs; - std::string geomBoundaryBcValues,velBcValues,pressBcValues,noSlipBcValues; - std::string propellerCylinder, propellerValues, propellerQs, measurePoints; - std::string inletBcQs, inletBcValues; - std::string outletBcQs, outletBcValues; - std::string topBcQs, topBcValues; - std::string bottomBcQs, bottomBcValues; - std::string frontBcQs, frontBcValues; - std::string backBcQs, backBcValues; - std::string wallBcQs, wallBcValues; - std::string periodicBcQs, periodicBcValues; - std::string numberNodes, LBMvsSI; - std::string cpTop, cpBottom, cpBottom2; - std::string concentration, streetVelocity; - std::string geomNormalX, geomNormalY, geomNormalZ, inflowNormalX, inflowNormalY, inflowNormalZ, outflowNormalX, outflowNormalY, outflowNormalZ; - uint timeStepForMP {10}; - real clockCycleForMP {1.0}; - real vis {0.001}; - real vis_ratio {1.0}; - real u0 {0.01}; - real u0_ratio {1.0}; - real delta_rho {0.0}; - real delta_press {1.0}; - bool printFiles {false}; - bool doRestart {false}; - bool doCheckPoint {false}; - bool readGeo {false}; - bool isGeo, isProp, isCp; - bool GeometryValues {false}; - bool is2ndOrderMoments {false}; - bool is3rdOrderMoments {false}; - bool isHighOrderMoments {false}; - bool calcMedian {false}; - bool isConc {false}; - bool isWale {false}; - TurbulenceModel turbulenceModel {TurbulenceModel::None}; - bool isTurbulentViscosity {false}; - real SGSConstant {0.0}; - bool isMeasurePoints {false}; - bool isInitNeq {false}; - bool isGeoNormal, isInflowNormal, isOutflowNormal; - bool hasWallModelMonitor {false}; - bool simulatePorousMedia {false}; - bool streetVelocityFile {false}; - real outflowPressureCorrectionFactor {0.0}; -}; - //Interface Cells -typedef struct ICellCF{ - uint* ICellCFF; - uint* ICellCFC; - uint kCF; -} InterpolationCellCF; - -typedef struct ICellFC{ - uint* ICellFCF; - uint* ICellFCC; - uint kFC; -} InterpolationCellFC; - -//Offset of the interface cells at the wall -typedef struct OffCF{ - real* xOffCF; - real* yOffCF; - real* zOffCF; -} OffsetCF; - -typedef struct OffFC{ - real* xOffFC; - real* yOffFC; - real* zOffFC; -} OffsetFC; +// example of old names (pre 2023) ICellCFC: interpolation from Coarse (C) to Fine (F), indices of the Coarse cells (C) +typedef struct ICells{ + uint* fineCellIndices; + uint* coarseCellIndices; + uint numberOfCells; +} InterpolationCells; + +//! \brief stores location of neighboring cell (necessary for refinement into the wall) +typedef struct ICellNeigh{ + real* x; + real* y; + real* z; +} InterpolationCellNeighbor; // Distribution functions g 6 -typedef struct Distri6 { +typedef struct Distri6 { // ADD IN FUTURE RELEASE real* g[6]; } Distributions6; // Distribution functions f 7 -typedef struct Distri7{ +typedef struct Distri7{ // ADD IN FUTURE RELEASE real* f[7]; } Distributions7; // Distribution functions f 19 -typedef struct Distri19{ +typedef struct Distri19{ // DEPRECATED real* f[19]; } Distributions19; @@ -247,14 +178,14 @@ typedef struct QforPrecursorBC{ }QforPrecursorBoundaryConditions; //BCTemp -typedef struct TempforBC{ +typedef struct TempforBC{ // ADD IN FUTURE RELEASE int* k; real* temp; int kTemp=0; }TempforBoundaryConditions; //BCTempVel -typedef struct TempVelforBC{ +typedef struct TempVelforBC{ // ADD IN FUTURE RELEASE int* k; real* temp; real* tempPulse; @@ -263,7 +194,7 @@ typedef struct TempVelforBC{ }TempVelforBoundaryConditions; //BCTempPress -typedef struct TempPressforBC{ +typedef struct TempPressforBC{ // ADD IN FUTURE RELEASE int* k; real* temp; real* velo; @@ -283,7 +214,7 @@ typedef struct WMparas{ //measurePoints -typedef struct MeasP{ +typedef struct MeasP{ // ADD IN FUTURE RELEASE std::string name; uint k; std::vector<real> Vx; @@ -307,7 +238,7 @@ typedef struct PN27{ int numberOfFs; }ProcessNeighbor27; -typedef struct PN_F3 { +typedef struct PN_F3 { // ADD IN FUTURE RELEASE real* g[6]; uint memsizeGs; int* index; @@ -317,7 +248,7 @@ typedef struct PN_F3 { int numberOfGs; }ProcessNeighborF3; -//path line particles +//path line particles // DEPRECATED typedef struct PLP{ bool *stuck, *hot; real *coordXabsolut, *coordYabsolut, *coordZabsolut; @@ -332,6 +263,7 @@ typedef struct PLP{ }PathLineParticles; ////////////////////////////////////////////////////////////////////////// +// DEPRECATED inline int vectorPosition(int i, int j, int k, int Lx, int Ly ) { //return((j+15)*(Lx+2*16)+(i+15)); diff --git a/src/gpu/VirtualFluids_GPU/LBM/Simulation.cpp b/src/gpu/VirtualFluids_GPU/LBM/Simulation.cpp index 84ab84ff93fa7706bcc27d7e61a18f580f3c8dbe..55c0250223901a94d03bd1e65bbb72438bcc99c3 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/Simulation.cpp +++ b/src/gpu/VirtualFluids_GPU/LBM/Simulation.cpp @@ -25,7 +25,7 @@ #include "Output/VeloASCIIWriter.hpp" ////////////////////////////////////////////////////////////////////////// #include "Utilities/Buffer2D.hpp" -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" ////////////////////////////////////////////////////////////////////////// #include "Init/InitLattice.h" #include "Init/VfReader.h" @@ -420,6 +420,18 @@ void Simulation::setFactories(std::unique_ptr<KernelFactory> &&kernelFactory_, this->preProcessorFactory = std::move(preProcessorFactory_); } +void Simulation::initTimers() +{ + previousTimestepForAveraging = para->getTimeCalcMedStart(); + previousTimestepForTurbulenceIntensityCalculation = 0; + timestepForMeasuringPoints = 0; + + para->setStepEnsight(0); + + averageTimer = std::make_unique<Timer>("Average performance"); + averageTimer->startTimer(); +} + void Simulation::allocNeighborsOffsetsScalesAndBoundaries(GridProvider &gridProvider) { @@ -432,603 +444,546 @@ void Simulation::allocNeighborsOffsetsScalesAndBoundaries(GridProvider &gridProv void Simulation::run() { - unsigned int timestep, t_prev; - uint t_turbulenceIntensity = 0; - unsigned int t_MP = 0; - - ////////////////////////////////////////////////////////////////////////// - para->setStepEnsight(0); - - //turning Ship - real Pi = (real)3.14159265358979323846; - real delta_x_F = (real)0.1; - real delta_t_F = (real)((double)para->getVelocity() * (double)delta_x_F / (double)3.75); - real delta_t_C = (real)(delta_t_F * pow(2.,para->getMaxLevel())); - real timesteps_C = (real)(12.5 / delta_t_C); - real AngularVelocity = (real)(12.5 / timesteps_C * Pi / 180.); - para->setAngularVelocity(AngularVelocity); - for (int i = 0; i<= para->getMaxLevel(); i++) - { - para->getParD(i)->deltaPhi = (real)(para->getAngularVelocity()/(pow(2.,i))); - } - ////////////////////////////////////////////////////////////////////////// - - t_prev = para->getTimeCalcMedStart(); - - Timer* averageTimer = new Timer("Average performance"); - averageTimer->startTimer(); + this->initTimers(); + + ////////////////////////////////////////////////////////////////////////// + // turning Ship + real Pi = (real)3.14159265358979323846; + real delta_x_F = (real)0.1; + real delta_t_F = (real)((double)para->getVelocity() * (double)delta_x_F / (double)3.75); + real delta_t_C = (real)(delta_t_F * pow(2., para->getMaxLevel())); + real timesteps_C = (real)(12.5 / delta_t_C); + real AngularVelocity = (real)(12.5 / timesteps_C * Pi / 180.); + para->setAngularVelocity(AngularVelocity); + for (int i = 0; i <= para->getMaxLevel(); i++) { + para->getParD(i)->deltaPhi = (real)(para->getAngularVelocity() / (pow(2., i))); + } //////////////////////////////////////////////////////////////////////////////// // Time loop //////////////////////////////////////////////////////////////////////////////// - for(timestep=para->getTimestepStart();timestep<=para->getTimestepEnd();timestep++) + for(uint timestep=para->getTimestepStart();timestep<=para->getTimestepEnd();timestep++) { - this->updateGrid27->updateGrid(0, timestep); - - //////////////////////////////////////////////////////////////////////////////// - //Particles - //////////////////////////////////////////////////////////////////////////////// - if (para->getCalcParticles()) propagateParticles(para.get(), timestep); - //////////////////////////////////////////////////////////////////////////////// - - - - - //////////////////////////////////////////////////////////////////////////////// - // run Analyzers for kinetic energy and enstrophy for TGV in 3D - // these analyzers only work on level 0 - //////////////////////////////////////////////////////////////////////////////// - if (this->kineticEnergyAnalyzer || this->enstrophyAnalyzer) { - updateGrid27->exchangeData(0); - } + this->calculateTimestep(timestep); + } - if( this->kineticEnergyAnalyzer ) this->kineticEnergyAnalyzer->run(timestep); - if( this->enstrophyAnalyzer ) this->enstrophyAnalyzer->run(timestep); - //////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + // printDragLift(para); + //////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + if (para->getDiffOn() == true) printPlaneConc(para.get(), cudaMemoryManager.get()); + //////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + ////for (int lev = para->getCoarse(); lev <= para->getFine(); lev++) + ////{ + //// if (para->getParH(lev)->cpTop.size() > 0) + //// { + //// printCpTop(para, lev); + //// } + ////} + // for (int lev = 7; lev <= 8; lev++) + //{ + // printCpTop(para, lev); + //} + ////printCpTop(para); + ////printCpBottom(para); + ////printCpBottom2(para); + //////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// + // //Copy Measure Values + // for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) + //{ + // VF_LOG_INFO("Copy MeasurePoints at level = {}", lev); + // para->cudaCopyMeasurePointsToHost(lev); + // para->copyMeasurePointsArrayToVector(lev); + // VF_LOG_INFO("Write MeasurePoints at level = {}", lev); + // for(int j = 0; j < (int)para->getParH(lev)->MP.size(); j++) + // { + // MeasurePointWriter::writeMeasurePoints(para, lev, j, 0); + // } + //} + // ////////////////////////////////////////////////////////////////////////// +} - //////////////////////////////////////////////////////////////////////////////// - //Calc Median - //////////////////////////////////////////////////////////////////////////////// - if (para->getCalcMedian() && ((int)timestep >= para->getTimeCalcMedStart()) && ((int)timestep <= para->getTimeCalcMedEnd())) +void Simulation::calculateTimestep(uint timestep) +{ + this->updateGrid27->updateGrid(0, timestep); + //////////////////////////////////////////////////////////////////////////////// + //Particles + //////////////////////////////////////////////////////////////////////////////// + if (para->getCalcParticles()) propagateParticles(para.get(), timestep); + //////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + // run Analyzers for kinetic energy and enstrophy for TGV in 3D + // these analyzers only work on level 0 + //////////////////////////////////////////////////////////////////////////////// + if (this->kineticEnergyAnalyzer || this->enstrophyAnalyzer) { + updateGrid27->exchangeData(0); + } + if( this->kineticEnergyAnalyzer ) this->kineticEnergyAnalyzer->run(timestep); + if( this->enstrophyAnalyzer ) this->enstrophyAnalyzer->run(timestep); + //////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + //Calc Median + //////////////////////////////////////////////////////////////////////////////// + if (para->getCalcMedian() && ((int)timestep >= para->getTimeCalcMedStart()) && ((int)timestep <= para->getTimeCalcMedEnd())) + { + for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) { - for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) - { - //CalcMedSP27(para->getParD(lev)->vx_SP_Med, - // para->getParD(lev)->vy_SP_Med, - // para->getParD(lev)->vz_SP_Med, - // para->getParD(lev)->rho_SP_Med, - // para->getParD(lev)->press_SP_Med, - // para->getParD(lev)->geoSP, - // para->getParD(lev)->neighborX_SP, - // para->getParD(lev)->neighborY_SP, - // para->getParD(lev)->neighborZ_SP, - // para->getParD(lev)->size_Mat_SP, - // para->getParD(lev)->numberofthreads, - // para->getParD(lev)->d0SP.f[0], - // para->getParD(lev)->evenOrOdd); - //getLastCudaError("CalcMacSP27 execution failed"); - - CalcMedCompSP27(para->getParD(lev)->vx_SP_Med, - para->getParD(lev)->vy_SP_Med, - para->getParD(lev)->vz_SP_Med, - para->getParD(lev)->rho_SP_Med, - para->getParD(lev)->press_SP_Med, - para->getParD(lev)->typeOfGridNode, - para->getParD(lev)->neighborX, - para->getParD(lev)->neighborY, - para->getParD(lev)->neighborZ, - para->getParD(lev)->numberOfNodes, - para->getParD(lev)->numberofthreads, - para->getParD(lev)->distributions.f[0], - para->getParD(lev)->isEvenTimestep); - getLastCudaError("CalcMacMedCompSP27 execution failed"); - - } + //CalcMedSP27(para->getParD(lev)->vx_SP_Med, + // para->getParD(lev)->vy_SP_Med, + // para->getParD(lev)->vz_SP_Med, + // para->getParD(lev)->rho_SP_Med, + // para->getParD(lev)->press_SP_Med, + // para->getParD(lev)->geoSP, + // para->getParD(lev)->neighborX_SP, + // para->getParD(lev)->neighborY_SP, + // para->getParD(lev)->neighborZ_SP, + // para->getParD(lev)->size_Mat_SP, + // para->getParD(lev)->numberofthreads, + // para->getParD(lev)->d0SP.f[0], + // para->getParD(lev)->evenOrOdd); + //getLastCudaError("CalcMacSP27 execution failed"); + CalcMedCompSP27(para->getParD(lev)->vx_SP_Med, + para->getParD(lev)->vy_SP_Med, + para->getParD(lev)->vz_SP_Med, + para->getParD(lev)->rho_SP_Med, + para->getParD(lev)->press_SP_Med, + para->getParD(lev)->typeOfGridNode, + para->getParD(lev)->neighborX, + para->getParD(lev)->neighborY, + para->getParD(lev)->neighborZ, + para->getParD(lev)->numberOfNodes, + para->getParD(lev)->numberofthreads, + para->getParD(lev)->distributions.f[0], + para->getParD(lev)->isEvenTimestep); + getLastCudaError("CalcMacMedCompSP27 execution failed"); } - - if (para->getCalcTurbulenceIntensity()) { - for (int lev = para->getCoarse(); lev <= para->getFine(); lev++) { - CalcTurbulenceIntensityDevice( - para->getParD(lev)->vxx, - para->getParD(lev)->vyy, - para->getParD(lev)->vzz, - para->getParD(lev)->vxy, - para->getParD(lev)->vxz, - para->getParD(lev)->vyz, - para->getParD(lev)->vx_mean, - para->getParD(lev)->vy_mean, - para->getParD(lev)->vz_mean, - para->getParD(lev)->distributions.f[0], - para->getParD(lev)->typeOfGridNode, - para->getParD(lev)->neighborX, - para->getParD(lev)->neighborY, - para->getParD(lev)->neighborZ, - para->getParD(lev)->numberOfNodes, - para->getParD(lev)->isEvenTimestep, - para->getParD(lev)->numberofthreads - ); - } + } + if (para->getCalcTurbulenceIntensity()) { + for (int lev = para->getCoarse(); lev <= para->getFine(); lev++) { + CalcTurbulenceIntensityDevice( + para->getParD(lev)->vxx, + para->getParD(lev)->vyy, + para->getParD(lev)->vzz, + para->getParD(lev)->vxy, + para->getParD(lev)->vxz, + para->getParD(lev)->vyz, + para->getParD(lev)->vx_mean, + para->getParD(lev)->vy_mean, + para->getParD(lev)->vz_mean, + para->getParD(lev)->distributions.f[0], + para->getParD(lev)->typeOfGridNode, + para->getParD(lev)->neighborX, + para->getParD(lev)->neighborY, + para->getParD(lev)->neighborZ, + para->getParD(lev)->numberOfNodes, + para->getParD(lev)->isEvenTimestep, + para->getParD(lev)->numberofthreads + ); } - //////////////////////////////////////////////////////////////////////////////// - - - - - //////////////////////////////////////////////////////////////////////////////// - // CheckPoint - //////////////////////////////////////////////////////////////////////////////// - if(para->getDoCheckPoint() && para->getTimeDoCheckPoint()>0 && timestep%para->getTimeDoCheckPoint()==0 && timestep>0 && !para->overWritingRestart(timestep)) + } + //////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + // CheckPoint + //////////////////////////////////////////////////////////////////////////////// + if(para->getDoCheckPoint() && para->getTimeDoCheckPoint()>0 && timestep%para->getTimeDoCheckPoint()==0 && timestep>0 && !para->overWritingRestart(timestep)) + { + averageTimer->stopTimer(); + ////////////////////////////////////////////////////////////////////////// + if( para->getDoCheckPoint() ) { - averageTimer->stopTimer(); - ////////////////////////////////////////////////////////////////////////// - - if( para->getDoCheckPoint() ) + VF_LOG_INFO("Copy data for CheckPoint t = {}....", timestep); + for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) { - VF_LOG_INFO("Copy data for CheckPoint t = {}....", timestep); - - for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) - { - cudaMemoryManager->cudaCopyFsForCheckPoint(lev); - } - - VF_LOG_INFO("Write data for CheckPoint t = {}...", timestep); - - const auto name = getFileName(para->getFName(), timestep, para->getMyProcessID()); - restart_object->serialize(name, para); - - VF_LOG_INFO("done"); + cudaMemoryManager->cudaCopyFsForCheckPoint(lev); } - ////////////////////////////////////////////////////////////////////////// - averageTimer->startTimer(); + VF_LOG_INFO("Write data for CheckPoint t = {}...", timestep); + const auto name = getFileName(para->getFName(), timestep, para->getMyProcessID()); + restart_object->serialize(name, para); + VF_LOG_INFO("done"); } - ////////////////////////////////////////////////////////////////////////////// - - - - - - //////////////////////////////////////////////////////////////////////////////// - //Measure Points - //////////////////////////////////////////////////////////////////////////////// - //set MP-Time - if (para->getUseMeasurePoints()) + ////////////////////////////////////////////////////////////////////////// + averageTimer->startTimer(); + } + ////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + //Measure Points + //////////////////////////////////////////////////////////////////////////////// + //set MP-Time + if (para->getUseMeasurePoints()) + { + if ((timestep%para->getTimestepForMP()) == 0) { - if ((timestep%para->getTimestepForMP()) == 0) + unsigned int valuesPerClockCycle = (unsigned int)(para->getclockCycleForMP() / para->getTimestepForMP()); + for (int lev = para->getCoarse(); lev <= para->getFine(); lev++) { - unsigned int valuesPerClockCycle = (unsigned int)(para->getclockCycleForMP() / para->getTimestepForMP()); - for (int lev = para->getCoarse(); lev <= para->getFine(); lev++) - { - // VF_LOG_INFO("start level = {}", lev); - LBCalcMeasurePoints27( para->getParD(lev)->VxMP, para->getParD(lev)->VyMP, para->getParD(lev)->VzMP, - para->getParD(lev)->RhoMP, para->getParD(lev)->kMP, para->getParD(lev)->numberOfPointskMP, - valuesPerClockCycle, t_MP, para->getParD(lev)->typeOfGridNode, - para->getParD(lev)->neighborX, para->getParD(lev)->neighborY, para->getParD(lev)->neighborZ, - para->getParD(lev)->numberOfNodes, para->getParD(lev)->distributions.f[0], para->getParD(lev)->numberofthreads, - para->getParD(lev)->isEvenTimestep); - } - t_MP++; + // VF_LOG_INFO("start level = {}", lev); + LBCalcMeasurePoints27( para->getParD(lev)->VxMP, para->getParD(lev)->VyMP, para->getParD(lev)->VzMP, + para->getParD(lev)->RhoMP, para->getParD(lev)->kMP, para->getParD(lev)->numberOfPointskMP, + valuesPerClockCycle, timestepForMeasuringPoints, para->getParD(lev)->typeOfGridNode, + para->getParD(lev)->neighborX, para->getParD(lev)->neighborY, para->getParD(lev)->neighborZ, + para->getParD(lev)->numberOfNodes, para->getParD(lev)->distributions.f[0], para->getParD(lev)->numberofthreads, + para->getParD(lev)->isEvenTimestep); } - - //Copy Measure Values - if ((timestep % (unsigned int)para->getclockCycleForMP()) == 0) + timestepForMeasuringPoints++; + } + //Copy Measure Values + if ((timestep % (unsigned int)para->getclockCycleForMP()) == 0) + { + for (int lev = para->getCoarse(); lev <= para->getFine(); lev++) { - for (int lev = para->getCoarse(); lev <= para->getFine(); lev++) + cudaMemoryManager->cudaCopyMeasurePointsToHost(lev); + para->copyMeasurePointsArrayToVector(lev); + VF_LOG_INFO("Write MeasurePoints at level = {} and timestep = {}", lev, timestep); + for (int j = 0; j < (int)para->getParH(lev)->MP.size(); j++) { - cudaMemoryManager->cudaCopyMeasurePointsToHost(lev); - para->copyMeasurePointsArrayToVector(lev); - VF_LOG_INFO("Write MeasurePoints at level = {} and timestep = {}", lev, timestep); - for (int j = 0; j < (int)para->getParH(lev)->MP.size(); j++) - { - MeasurePointWriter::writeMeasurePoints(para.get(), lev, j, timestep); - } - //MeasurePointWriter::calcAndWriteMeanAndFluctuations(para.get(), lev, t, para->getTStartOut()); + MeasurePointWriter::writeMeasurePoints(para.get(), lev, j, timestep); } - t_MP = 0; + //MeasurePointWriter::calcAndWriteMeanAndFluctuations(para.get(), lev, t, para->getTStartOut()); } + timestepForMeasuringPoints = 0; } + } + ////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////// + ////get concentration at the plane + ////////////////////////////////////////////////////////////////////////////////// + if (para->getDiffOn() && para->getCalcPlaneConc()) + { + PlaneConcThS27( para->getParD(0)->ConcPlaneIn, + para->getParD(0)->cpTopIndex, + para->getParD(0)->numberOfPointsCpTop, + para->getParD(0)->typeOfGridNode, + para->getParD(0)->neighborX, + para->getParD(0)->neighborY, + para->getParD(0)->neighborZ, + para->getParD(0)->numberOfNodes, + para->getParD(0)->numberofthreads, + para->getParD(0)->distributionsAD.f[0], + para->getParD(0)->isEvenTimestep); + getLastCudaError("PlaneConcThS27 execution failed"); + PlaneConcThS27( para->getParD(0)->ConcPlaneOut1, + para->getParD(0)->cpBottomIndex, + para->getParD(0)->numberOfPointsCpBottom, + para->getParD(0)->typeOfGridNode, + para->getParD(0)->neighborX, + para->getParD(0)->neighborY, + para->getParD(0)->neighborZ, + para->getParD(0)->numberOfNodes, + para->getParD(0)->numberofthreads, + para->getParD(0)->distributionsAD.f[0], + para->getParD(0)->isEvenTimestep); + getLastCudaError("PlaneConcThS27 execution failed"); + PlaneConcThS27( para->getParD(0)->ConcPlaneOut2, + para->getParD(0)->pressureBC.kN, + para->getParD(0)->pressureBC.numberOfBCnodes, + para->getParD(0)->typeOfGridNode, + para->getParD(0)->neighborX, + para->getParD(0)->neighborY, + para->getParD(0)->neighborZ, + para->getParD(0)->numberOfNodes, + para->getParD(0)->numberofthreads, + para->getParD(0)->distributionsAD.f[0], + para->getParD(0)->isEvenTimestep); + getLastCudaError("PlaneConcThS27 execution failed"); ////////////////////////////////////////////////////////////////////////////////// - - - - + ////Calculation of concentration at the plane ////////////////////////////////////////////////////////////////////////////////// - ////get concentration at the plane + calcPlaneConc(para.get(), cudaMemoryManager.get(), 0); + } + ////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + // File IO + //////////////////////////////////////////////////////////////////////////////// + //communicator->startTimer(); + if(para->getTimestepOut()>0 && timestep%para->getTimestepOut()==0 && timestep>para->getTimestepStartOut()) + { ////////////////////////////////////////////////////////////////////////////////// - if (para->getDiffOn() && para->getCalcPlaneConc()) - { - PlaneConcThS27( para->getParD(0)->ConcPlaneIn, - para->getParD(0)->cpTopIndex, - para->getParD(0)->numberOfPointsCpTop, - para->getParD(0)->typeOfGridNode, - para->getParD(0)->neighborX, - para->getParD(0)->neighborY, - para->getParD(0)->neighborZ, - para->getParD(0)->numberOfNodes, - para->getParD(0)->numberofthreads, - para->getParD(0)->distributionsAD27.f[0], - para->getParD(0)->isEvenTimestep); - getLastCudaError("PlaneConcThS27 execution failed"); - PlaneConcThS27( para->getParD(0)->ConcPlaneOut1, - para->getParD(0)->cpBottomIndex, - para->getParD(0)->numberOfPointsCpBottom, - para->getParD(0)->typeOfGridNode, - para->getParD(0)->neighborX, - para->getParD(0)->neighborY, - para->getParD(0)->neighborZ, - para->getParD(0)->numberOfNodes, - para->getParD(0)->numberofthreads, - para->getParD(0)->distributionsAD27.f[0], - para->getParD(0)->isEvenTimestep); - getLastCudaError("PlaneConcThS27 execution failed"); - PlaneConcThS27( para->getParD(0)->ConcPlaneOut2, - para->getParD(0)->pressureBC.kN, - para->getParD(0)->pressureBC.numberOfBCnodes, - para->getParD(0)->typeOfGridNode, - para->getParD(0)->neighborX, - para->getParD(0)->neighborY, - para->getParD(0)->neighborZ, - para->getParD(0)->numberOfNodes, - para->getParD(0)->numberofthreads, - para->getParD(0)->distributionsAD27.f[0], - para->getParD(0)->isEvenTimestep); - getLastCudaError("PlaneConcThS27 execution failed"); - ////////////////////////////////////////////////////////////////////////////////// - ////Calculation of concentration at the plane - ////////////////////////////////////////////////////////////////////////////////// - calcPlaneConc(para.get(), cudaMemoryManager.get(), 0); - } + //if (para->getParD(0)->evenOrOdd==true) para->getParD(0)->evenOrOdd=false; + //else para->getParD(0)->evenOrOdd=true; ////////////////////////////////////////////////////////////////////////////////// - - - - - //////////////////////////////////////////////////////////////////////////////// - // File IO - //////////////////////////////////////////////////////////////////////////////// - //communicator->startTimer(); - if(para->getTimestepOut()>0 && timestep%para->getTimestepOut()==0 && timestep>para->getTimestepStartOut()) - { - ////////////////////////////////////////////////////////////////////////////////// - //if (para->getParD(0)->evenOrOdd==true) para->getParD(0)->evenOrOdd=false; - //else para->getParD(0)->evenOrOdd=true; - ////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// averageTimer->stopTimer(); averageTimer->outputPerformance(timestep, para.get(), communicator); ////////////////////////////////////////////////////////////////////////// + if( para->getPrintFiles() ) + { + readAndWriteFiles(timestep); + } + averageTimer->startTimer(); + } +} - if( para->getPrintFiles() ) - { - VF_LOG_INFO("Write files t = {} ...", timestep); - for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) - { - ////////////////////////////////////////////////////////////////////////// - //exchange data for valid post process - updateGrid27->exchangeData(lev); - ////////////////////////////////////////////////////////////////////////// - //if (para->getD3Qxx()==19) - //{ - //CalcMac(para->getParD(lev)->vx, para->getParD(lev)->vy, para->getParD(lev)->vz, para->getParD(lev)->rho, - // para->getParD(lev)->geo, para->getParD(lev)->size_Mat, para->getParD(lev)->gridNX, para->getParD(lev)->gridNY, - // para->getParD(lev)->gridNZ, para->getParD(lev)->d0.f[0], para->getParD(lev)->evenOrOdd); - //} - //else if (para->getD3Qxx()==27) - //{ - //if (para->getCalcMedian() && ((int)t > para->getTimeCalcMedStart()) && ((int)t <= para->getTimeCalcMedEnd())) - //{ - // unsigned int tdiff = t - t_prev; - // CalcMacMedSP27(para->getParD(lev)->vx_SP_Med, - // para->getParD(lev)->vy_SP_Med, - // para->getParD(lev)->vz_SP_Med, - // para->getParD(lev)->rho_SP_Med, - // para->getParD(lev)->press_SP_Med, - // para->getParD(lev)->geoSP, - // para->getParD(lev)->neighborX_SP, - // para->getParD(lev)->neighborY_SP, - // para->getParD(lev)->neighborZ_SP, - // tdiff, - // para->getParD(lev)->size_Mat_SP, - // para->getParD(lev)->numberofthreads, - // para->getParD(lev)->evenOrOdd); - // getLastCudaError("CalcMacMedSP27 execution failed"); - //} - - //CalcMacSP27(para->getParD(lev)->vx_SP, - // para->getParD(lev)->vy_SP, - // para->getParD(lev)->vz_SP, - // para->getParD(lev)->rho, - // para->getParD(lev)->pressure, - // para->getParD(lev)->geoSP, - // para->getParD(lev)->neighborX_SP, - // para->getParD(lev)->neighborY_SP, - // para->getParD(lev)->neighborZ_SP, - // para->getParD(lev)->size_Mat_SP, - // para->getParD(lev)->numberofthreads, - // para->getParD(lev)->d0SP.f[0], - // para->getParD(lev)->evenOrOdd); - // getLastCudaError("CalcMacSP27 execution failed"); - - - CalcMacCompSP27(para->getParD(lev)->velocityX, - para->getParD(lev)->velocityY, - para->getParD(lev)->velocityZ, - para->getParD(lev)->rho, - para->getParD(lev)->pressure, - para->getParD(lev)->typeOfGridNode, - para->getParD(lev)->neighborX, - para->getParD(lev)->neighborY, - para->getParD(lev)->neighborZ, - para->getParD(lev)->numberOfNodes, - para->getParD(lev)->numberofthreads, - para->getParD(lev)->distributions.f[0], - para->getParD(lev)->isEvenTimestep); - getLastCudaError("CalcMacSP27 execution failed"); - - // // overwrite with wall nodes - // SetOutputWallVelocitySP27( para->getParD(lev)->numberofthreads, - // para->getParD(lev)->velocityX, - // para->getParD(lev)->velocityY, - // para->getParD(lev)->velocityZ, - // para->getParD(lev)->geometryBC.Vx, - // para->getParD(lev)->geometryBC.Vy, - // para->getParD(lev)->geometryBC.Vz, - // para->getParD(lev)->geometryBC.numberOfBCnodes, - // para->getParD(lev)->geometryBC.k, - // para->getParD(lev)->rho, - // para->getParD(lev)->pressure, - // para->getParD(lev)->typeOfGridNode, - // para->getParD(lev)->neighborX, - // para->getParD(lev)->neighborY, - // para->getParD(lev)->neighborZ, - // para->getParD(lev)->size_Mat, - // para->getParD(lev)->distributions.f[0], - // para->getParD(lev)->isEvenTimestep); - // getLastCudaError("SetOutputWallVelocitySP27 execution failed"); - - // SetOutputWallVelocitySP27( para->getParD(lev)->numberofthreads, - // para->getParD(lev)->velocityX, - // para->getParD(lev)->velocityY, - // para->getParD(lev)->velocityZ, - // para->getParD(lev)->velocityBC.Vx, - // para->getParD(lev)->velocityBC.Vy, - // para->getParD(lev)->velocityBC.Vz, - // para->getParD(lev)->velocityBC.numberOfBCnodes, - // para->getParD(lev)->velocityBC.k, - // para->getParD(lev)->rho, - // para->getParD(lev)->pressure, - // para->getParD(lev)->typeOfGridNode, - // para->getParD(lev)->neighborX, - // para->getParD(lev)->neighborY, - // para->getParD(lev)->neighborZ, - // para->getParD(lev)->size_Mat, - // para->getParD(lev)->distributions.f[0], - // para->getParD(lev)->isEvenTimestep); - // getLastCudaError("SetOutputWallVelocitySP27 execution failed"); - - //} - - cudaMemoryManager->cudaCopyPrint(lev); - if (para->getCalcMedian()) - { - cudaMemoryManager->cudaCopyMedianPrint(lev); - } - - ////////////////////////////////////////////////////////////////////////// - //TODO: implement flag to write ASCII data - if (para->getWriteVeloASCIIfiles()) - VeloASCIIWriter::writeVelocitiesAsTXT(para.get(), lev, timestep); - ////////////////////////////////////////////////////////////////////////// - if( this->kineticEnergyAnalyzer || this->enstrophyAnalyzer ) - { - std::string fname = para->getFName() + "_ID_" + StringUtil::toString<int>(para->getMyProcessID()) + "_t_" + StringUtil::toString<int>(timestep); - - if (this->kineticEnergyAnalyzer) this->kineticEnergyAnalyzer->writeToFile(fname); - if (this->enstrophyAnalyzer) this->enstrophyAnalyzer->writeToFile(fname); - } - ////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (para->getDiffOn()==true) - { - if (para->getDiffMod() == 7) - { - CalcMacThS7( para->getParD(lev)->Conc, - para->getParD(lev)->typeOfGridNode, - para->getParD(lev)->neighborX, - para->getParD(lev)->neighborY, - para->getParD(lev)->neighborZ, - para->getParD(lev)->numberOfNodes, - para->getParD(lev)->numberofthreads, - para->getParD(lev)->distributionsAD7.f[0], - para->getParD(lev)->isEvenTimestep); - getLastCudaError("CalcMacTh7 execution failed"); - } - else if (para->getDiffMod() == 27) - { - CalcConcentration27( - para->getParD(lev)->numberofthreads, - para->getParD(lev)->Conc, - para->getParD(lev)->typeOfGridNode, - para->getParD(lev)->neighborX, - para->getParD(lev)->neighborY, - para->getParD(lev)->neighborZ, - para->getParD(lev)->numberOfNodes, - para->getParD(lev)->distributionsAD27.f[0], - para->getParD(lev)->isEvenTimestep); - } - - cudaMemoryManager->cudaCopyConcentrationDeviceToHost(lev); - //cudaMemoryCopy(para->getParH(lev)->Conc, para->getParD(lev)->Conc, para->getParH(lev)->mem_size_real_SP , cudaMemcpyDeviceToHost); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ////print cp - //if ((para->getParH(lev)->cpTop.size() > 0) && (t > para->getTStartOut())) - //{ - // printCpTopIntermediateStep(para, t, lev); - //} - //////////////////////////////////////////////////////////////////////////////// - //MeasurePointWriter::writeSpacialAverageForXZSlices(para, lev, t); - //////////////////////////////////////////////////////////////////////////////// - //MeasurePointWriter::writeTestAcousticXY(para, lev, t); - //MeasurePointWriter::writeTestAcousticYZ(para, lev, t); - //MeasurePointWriter::writeTestAcousticXZ(para, lev, t); - //////////////////////////////////////////////////////////////////////// - } - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ////test print press mirror - //if (t > para->getTStartOut()) - //{ - // //////////////////////////////////////////////////////////////////////////////// - // //Level 7 - // CalcCPtop27(para->getParD(7)->d0SP.f[0], - // para->getParD(7)->cpTopIndex, - // para->getParD(7)->numberOfPointsCpTop, - // para->getParD(7)->cpPressTop, - // para->getParD(7)->neighborX_SP, - // para->getParD(7)->neighborY_SP, - // para->getParD(7)->neighborZ_SP, - // para->getParD(7)->size_Mat_SP, - // para->getParD(7)->evenOrOdd, - // para->getParD(7)->numberofthreads); - // ////////////////////////////////////////////////////////////////////////////////// - // calcPressForMirror(para, 7); - // //////////////////////////////////////////////////////////////////////////////// - // //Level 8 - // CalcCPtop27(para->getParD(8)->d0SP.f[0], - // para->getParD(8)->cpTopIndex, - // para->getParD(8)->numberOfPointsCpTop, - // para->getParD(8)->cpPressTop, - // para->getParD(8)->neighborX_SP, - // para->getParD(8)->neighborY_SP, - // para->getParD(8)->neighborZ_SP, - // para->getParD(8)->size_Mat_SP, - // para->getParD(8)->evenOrOdd, - // para->getParD(8)->numberofthreads); - // ////////////////////////////////////////////////////////////////////////////////// - // calcPressForMirror(para, 8); - // //////////////////////////////////////////////////////////////////////////////// - // //print press mirror - // printScalars(para, false); - // //////////////////////////////////////////////////////////////////////////////// - //} - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //t_prev = t; - - ////////////////////////////////////////////////////////////////////////// - ////Data Analysis - ////AnalysisData::writeAnalysisData(para, t); - //AnalysisData::writeAnalysisDataX(para, t); - //AnalysisData::writeAnalysisDataZ(para, t); - ////////////////////////////////////////////////////////////////////////// +void Simulation::readAndWriteFiles(uint timestep) +{ + VF_LOG_INFO("Write files t = {} ...", timestep); - //////////////////////////////////////////////////////////////////////// - //pressure difference - //////////////////////////////////////////////////////////////////////// - //if (para->getMyID() == para->getPressInID()) calcPressure(para, "in", 0); - //else if (para->getMyID() == para->getPressOutID()) calcPressure(para, "out", 0); - //////////////////////////////////////////////////////////////////////// - //flow rate - //////////////////////////////////////////////////////////////////////// - //calcFlowRate(para, 0); - //////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////// - //calculate 2nd, 3rd and higher order moments - //////////////////////////////////////////////////////////////////////// - if (para->getCalc2ndOrderMoments()) calc2ndMoments(para.get(), cudaMemoryManager.get()); - if (para->getCalc3rdOrderMoments()) calc3rdMoments(para.get(), cudaMemoryManager.get()); - if (para->getCalcHighOrderMoments()) calcHigherOrderMoments(para.get(), cudaMemoryManager.get()); - //////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////// - //calculate median on host - //////////////////////////////////////////////////////////////////////// - if (para->getCalcMedian() && ((int)timestep > para->getTimeCalcMedStart()) && ((int)timestep <= para->getTimeCalcMedEnd()) && ((timestep%(unsigned int)para->getclockCycleForMP())==0)) + for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) + { + ////////////////////////////////////////////////////////////////////////// + //exchange data for valid post process + updateGrid27->exchangeData(lev); + + // //////////////////////////////////////////////////////////////////////// + // if (para->getD3Qxx()==19) + // { + // CalcMac(para->getParD(lev)->vx, para->getParD(lev)->vy, para->getParD(lev)->vz, para->getParD(lev)->rho, + // para->getParD(lev)->geo, para->getParD(lev)->size_Mat, para->getParD(lev)->gridNX, para->getParD(lev)->gridNY, + // para->getParD(lev)->gridNZ, para->getParD(lev)->d0.f[0], para->getParD(lev)->evenOrOdd); + // } + // else if (para->getD3Qxx()==27) + // { + // if (para->getCalcMedian() && ((int)t > para->getTimeCalcMedStart()) && ((int)t <= para->getTimeCalcMedEnd())) + // { + // unsigned int tdiff = t - t_prev; + // CalcMacMedSP27(para->getParD(lev)->vx_SP_Med, + // para->getParD(lev)->vy_SP_Med, + // para->getParD(lev)->vz_SP_Med, + // para->getParD(lev)->rho_SP_Med, + // para->getParD(lev)->press_SP_Med, + // para->getParD(lev)->geoSP, + // para->getParD(lev)->neighborX_SP, + // para->getParD(lev)->neighborY_SP, + // para->getParD(lev)->neighborZ_SP, + // tdiff, + // para->getParD(lev)->size_Mat_SP, + // para->getParD(lev)->numberofthreads, + // para->getParD(lev)->evenOrOdd); + // getLastCudaError("CalcMacMedSP27 execution failed"); + // } + // CalcMacSP27(para->getParD(lev)->vx_SP, + // para->getParD(lev)->vy_SP, + // para->getParD(lev)->vz_SP, + // para->getParD(lev)->rho, + // para->getParD(lev)->pressure, + // para->getParD(lev)->geoSP, + // para->getParD(lev)->neighborX_SP, + // para->getParD(lev)->neighborY_SP, + // para->getParD(lev)->neighborZ_SP, + // para->getParD(lev)->size_Mat_SP, + // para->getParD(lev)->numberofthreads, + // para->getParD(lev)->d0SP.f[0], + // para->getParD(lev)->evenOrOdd); + // getLastCudaError("CalcMacSP27 execution failed"); + CalcMacCompSP27(para->getParD(lev)->velocityX, + para->getParD(lev)->velocityY, + para->getParD(lev)->velocityZ, + para->getParD(lev)->rho, + para->getParD(lev)->pressure, + para->getParD(lev)->typeOfGridNode, + para->getParD(lev)->neighborX, + para->getParD(lev)->neighborY, + para->getParD(lev)->neighborZ, + para->getParD(lev)->numberOfNodes, + para->getParD(lev)->numberofthreads, + para->getParD(lev)->distributions.f[0], + para->getParD(lev)->isEvenTimestep); + getLastCudaError("CalcMacSP27 execution failed"); + // // overwrite with wall nodes + // SetOutputWallVelocitySP27( para->getParD(lev)->numberofthreads, + // para->getParD(lev)->velocityX, + // para->getParD(lev)->velocityY, + // para->getParD(lev)->velocityZ, + // para->getParD(lev)->geometryBC.Vx, + // para->getParD(lev)->geometryBC.Vy, + // para->getParD(lev)->geometryBC.Vz, + // para->getParD(lev)->geometryBC.numberOfBCnodes, + // para->getParD(lev)->geometryBC.k, + // para->getParD(lev)->rho, + // para->getParD(lev)->pressure, + // para->getParD(lev)->typeOfGridNode, + // para->getParD(lev)->neighborX, + // para->getParD(lev)->neighborY, + // para->getParD(lev)->neighborZ, + // para->getParD(lev)->size_Mat, + // para->getParD(lev)->distributions.f[0], + // para->getParD(lev)->isEvenTimestep); + // getLastCudaError("SetOutputWallVelocitySP27 execution failed"); + // SetOutputWallVelocitySP27( para->getParD(lev)->numberofthreads, + // para->getParD(lev)->velocityX, + // para->getParD(lev)->velocityY, + // para->getParD(lev)->velocityZ, + // para->getParD(lev)->velocityBC.Vx, + // para->getParD(lev)->velocityBC.Vy, + // para->getParD(lev)->velocityBC.Vz, + // para->getParD(lev)->velocityBC.numberOfBCnodes, + // para->getParD(lev)->velocityBC.k, + // para->getParD(lev)->rho, + // para->getParD(lev)->pressure, + // para->getParD(lev)->typeOfGridNode, + // para->getParD(lev)->neighborX, + // para->getParD(lev)->neighborY, + // para->getParD(lev)->neighborZ, + // para->getParD(lev)->size_Mat, + // para->getParD(lev)->distributions.f[0], + // para->getParD(lev)->isEvenTimestep); + // getLastCudaError("SetOutputWallVelocitySP27 execution failed"); + // } + + cudaMemoryManager->cudaCopyPrint(lev); + if (para->getCalcMedian()) + { + cudaMemoryManager->cudaCopyMedianPrint(lev); + } + ////////////////////////////////////////////////////////////////////////// + //TODO: implement flag to write ASCII data + if (para->getWriteVeloASCIIfiles()) + VeloASCIIWriter::writeVelocitiesAsTXT(para.get(), lev, timestep); + ////////////////////////////////////////////////////////////////////////// + if( this->kineticEnergyAnalyzer || this->enstrophyAnalyzer ) + { + std::string fname = para->getFName() + "_ID_" + StringUtil::toString<int>(para->getMyProcessID()) + "_t_" + StringUtil::toString<int>(timestep); + if (this->kineticEnergyAnalyzer) this->kineticEnergyAnalyzer->writeToFile(fname); + if (this->enstrophyAnalyzer) this->enstrophyAnalyzer->writeToFile(fname); + } + ////////////////////////////////////////////////////////////////////////// + if (para->getDiffOn()==true) + { + if (para->getDiffMod() == 7) { - unsigned int tdiff = timestep - t_prev; - calcMedian(para.get(), tdiff); - - ///////////////////////////////// - //added for incremental averaging - t_prev = timestep; - resetMedian(para.get()); - ///////////////////////////////// + CalcMacThS7( para->getParD(lev)->concentration, + para->getParD(lev)->typeOfGridNode, + para->getParD(lev)->neighborX, + para->getParD(lev)->neighborY, + para->getParD(lev)->neighborZ, + para->getParD(lev)->numberOfNodes, + para->getParD(lev)->numberofthreads, + para->getParD(lev)->distributionsAD7.f[0], + para->getParD(lev)->isEvenTimestep); + getLastCudaError("CalcMacTh7 execution failed"); } - if (para->getCalcTurbulenceIntensity()) + else if (para->getDiffMod() == 27) { - uint t_diff = timestep - t_turbulenceIntensity; - calcTurbulenceIntensity(para.get(), cudaMemoryManager.get(), t_diff); - //writeAllTiDatafToFile(para.get(), t); - } - //////////////////////////////////////////////////////////////////////// - dataWriter->writeTimestep(para, timestep); - //////////////////////////////////////////////////////////////////////// - if (para->getCalcTurbulenceIntensity()) { - t_turbulenceIntensity = timestep; - resetVelocityFluctuationsAndMeans(para.get(), cudaMemoryManager.get()); + CalcConcentration27( + para->getParD(lev)->numberofthreads, + para->getParD(lev)->concentration, + para->getParD(lev)->typeOfGridNode, + para->getParD(lev)->neighborX, + para->getParD(lev)->neighborY, + para->getParD(lev)->neighborZ, + para->getParD(lev)->numberOfNodes, + para->getParD(lev)->distributionsAD.f[0], + para->getParD(lev)->isEvenTimestep); } - //////////////////////////////////////////////////////////////////////// - if (para->getCalcDragLift()) printDragLift(para.get(), cudaMemoryManager.get(), timestep); - //////////////////////////////////////////////////////////////////////// - if (para->getCalcParticles()) copyAndPrintParticles(para.get(), cudaMemoryManager.get(), timestep, false); - //////////////////////////////////////////////////////////////////////// - VF_LOG_INFO("... done"); - //////////////////////////////////////////////////////////////////////// - } - + cudaMemoryManager->cudaCopyConcentrationDeviceToHost(lev); + //cudaMemoryCopy(para->getParH(lev)->Conc, para->getParD(lev)->Conc, para->getParH(lev)->mem_size_real_SP , cudaMemcpyDeviceToHost); + } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////print cp + //if ((para->getParH(lev)->cpTop.size() > 0) && (t > para->getTStartOut())) + //{ + // printCpTopIntermediateStep(para, t, lev); + //} + //////////////////////////////////////////////////////////////////////////////// + //MeasurePointWriter::writeSpacialAverageForXZSlices(para, lev, t); + //////////////////////////////////////////////////////////////////////////////// + //MeasurePointWriter::writeTestAcousticXY(para, lev, t); + //MeasurePointWriter::writeTestAcousticYZ(para, lev, t); + //MeasurePointWriter::writeTestAcousticXZ(para, lev, t); //////////////////////////////////////////////////////////////////////// - averageTimer->startTimer(); - } } - - ///////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////// - //printDragLift(para); - //////////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////// - if (para->getDiffOn()==true) printPlaneConc(para.get(), cudaMemoryManager.get()); - //////////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////// - ////for (int lev = para->getCoarse(); lev <= para->getFine(); lev++) - ////{ - //// if (para->getParH(lev)->cpTop.size() > 0) - //// { - //// printCpTop(para, lev); - //// } - ////} - //for (int lev = 7; lev <= 8; lev++) + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////test print press mirror + //if (t > para->getTStartOut()) //{ - // printCpTop(para, lev); + // //////////////////////////////////////////////////////////////////////////////// + // //Level 7 + // CalcCPtop27(para->getParD(7)->d0SP.f[0], + // para->getParD(7)->cpTopIndex, + // para->getParD(7)->numberOfPointsCpTop, + // para->getParD(7)->cpPressTop, + // para->getParD(7)->neighborX_SP, + // para->getParD(7)->neighborY_SP, + // para->getParD(7)->neighborZ_SP, + // para->getParD(7)->size_Mat_SP, + // para->getParD(7)->evenOrOdd, + // para->getParD(7)->numberofthreads); + // ////////////////////////////////////////////////////////////////////////////////// + // calcPressForMirror(para, 7); + // //////////////////////////////////////////////////////////////////////////////// + // //Level 8 + // CalcCPtop27(para->getParD(8)->d0SP.f[0], + // para->getParD(8)->cpTopIndex, + // para->getParD(8)->numberOfPointsCpTop, + // para->getParD(8)->cpPressTop, + // para->getParD(8)->neighborX_SP, + // para->getParD(8)->neighborY_SP, + // para->getParD(8)->neighborZ_SP, + // para->getParD(8)->size_Mat_SP, + // para->getParD(8)->evenOrOdd, + // para->getParD(8)->numberofthreads); + // ////////////////////////////////////////////////////////////////////////////////// + // calcPressForMirror(para, 8); + // //////////////////////////////////////////////////////////////////////////////// + // //print press mirror + // printScalars(para, false); + // //////////////////////////////////////////////////////////////////////////////// //} - ////printCpTop(para); - ////printCpBottom(para); - ////printCpBottom2(para); - //////////////////////////////////////////////////////////////////////////////// - - // ////////////////////////////////////////////////////////////////////////// - // //Copy Measure Values - //for (int lev=para->getCoarse(); lev <= para->getFine(); lev++) - //{ - // VF_LOG_INFO("Copy MeasurePoints at level = {}", lev); - // para->cudaCopyMeasurePointsToHost(lev); - // para->copyMeasurePointsArrayToVector(lev); - // VF_LOG_INFO("Write MeasurePoints at level = {}", lev); - // for(int j = 0; j < (int)para->getParH(lev)->MP.size(); j++) - // { - // MeasurePointWriter::writeMeasurePoints(para, lev, j, 0); - // } - //} - // ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //t_prev = t; + ////////////////////////////////////////////////////////////////////////// + ////Data Analysis + ////AnalysisData::writeAnalysisData(para, t); + //AnalysisData::writeAnalysisDataX(para, t); + //AnalysisData::writeAnalysisDataZ(para, t); + ////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// + //pressure difference + //////////////////////////////////////////////////////////////////////// + //if (para->getMyID() == para->getPressInID()) calcPressure(para, "in", 0); + //else if (para->getMyID() == para->getPressOutID()) calcPressure(para, "out", 0); + //////////////////////////////////////////////////////////////////////// + //flow rate + //////////////////////////////////////////////////////////////////////// + //calcFlowRate(para, 0); + //////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// + //calculate 2nd, 3rd and higher order moments + //////////////////////////////////////////////////////////////////////// + if (para->getCalc2ndOrderMoments()) calc2ndMoments(para.get(), cudaMemoryManager.get()); + if (para->getCalc3rdOrderMoments()) calc3rdMoments(para.get(), cudaMemoryManager.get()); + if (para->getCalcHighOrderMoments()) calcHigherOrderMoments(para.get(), cudaMemoryManager.get()); + //////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// + //calculate median on host + //////////////////////////////////////////////////////////////////////// + if (para->getCalcMedian() && ((int)timestep > para->getTimeCalcMedStart()) && ((int)timestep <= para->getTimeCalcMedEnd()) && ((timestep%(unsigned int)para->getclockCycleForMP())==0)) + { + unsigned int tdiff = timestep - previousTimestepForAveraging; + calcMedian(para.get(), tdiff); + ///////////////////////////////// + //added for incremental averaging + previousTimestepForAveraging = timestep; + resetMedian(para.get()); + ///////////////////////////////// + } + if (para->getCalcTurbulenceIntensity()) + { + uint t_diff = timestep - previousTimestepForTurbulenceIntensityCalculation; + calcTurbulenceIntensity(para.get(), cudaMemoryManager.get(), t_diff); + //writeAllTiDatafToFile(para.get(), t); + } + //////////////////////////////////////////////////////////////////////// + dataWriter->writeTimestep(para, timestep); + //////////////////////////////////////////////////////////////////////// + if (para->getCalcTurbulenceIntensity()) { + previousTimestepForTurbulenceIntensityCalculation = timestep; + resetVelocityFluctuationsAndMeans(para.get(), cudaMemoryManager.get()); + } + //////////////////////////////////////////////////////////////////////// + if (para->getCalcDragLift()) + { + printDragLift(para.get(), cudaMemoryManager.get(), timestep); + } + //////////////////////////////////////////////////////////////////////// + if (para->getCalcParticles()) copyAndPrintParticles(para.get(), cudaMemoryManager.get(), timestep, false); + //////////////////////////////////////////////////////////////////////// + VF_LOG_INFO("... done"); + //////////////////////////////////////////////////////////////////////// } void Simulation::porousMedia() @@ -1214,7 +1169,7 @@ Simulation::~Simulation() for (int lev = para->getCoarse(); lev < para->getFine(); lev++) { checkCudaErrors(cudaFreeHost(para->getParH(lev)->Conc_Full)); - checkCudaErrors(cudaFreeHost(para->getParH(lev)->Conc)); + checkCudaErrors(cudaFreeHost(para->getParH(lev)->concentration)); checkCudaErrors(cudaFreeHost(para->getParH(lev)->Temp.temp)); checkCudaErrors(cudaFreeHost(para->getParH(lev)->Temp.k)); checkCudaErrors(cudaFreeHost(para->getParH(lev)->TempVel.temp)); diff --git a/src/gpu/VirtualFluids_GPU/LBM/Simulation.h b/src/gpu/VirtualFluids_GPU/LBM/Simulation.h index 5bb58827ea58a8fe135b934f6e1aa0a5ee42cdfd..ba2a321707db4138aee9e1c30bae4dede017a5b8 100644 --- a/src/gpu/VirtualFluids_GPU/LBM/Simulation.h +++ b/src/gpu/VirtualFluids_GPU/LBM/Simulation.h @@ -31,6 +31,7 @@ class EnstrophyAnalyzer; class BoundaryConditionFactory; class GridScalingFactory; class TurbulenceModelFactory; +class Timer; class Simulation { @@ -44,16 +45,22 @@ public: void run(); void setFactories(std::unique_ptr<KernelFactory> &&kernelFactory, - std::unique_ptr<PreProcessorFactory> &&preProcessorFactory); + std::unique_ptr<PreProcessorFactory> &&preProcessorFactory); void setDataWriter(std::shared_ptr<DataWriter> dataWriter); void addKineticEnergyAnalyzer(uint tAnalyse); void addEnstrophyAnalyzer(uint tAnalyse); + //! \brief can be used as an alternative to run(), if the simulation needs to be controlled from the outside (e. g. for fluid structure interaction FSI) + void calculateTimestep(uint timestep); + //! \brief needed to initialize the simulation timers if calculateTimestep is used instead of run() + void initTimers(); + private: void init(GridProvider &gridProvider, BoundaryConditionFactory *bcFactory, SPtr<TurbulenceModelFactory> tmFactory, GridScalingFactory *scalingFactory); void allocNeighborsOffsetsScalesAndBoundaries(GridProvider& gridProvider); void porousMedia(); void definePMarea(std::shared_ptr<PorousMedia>& pm); + void readAndWriteFiles(uint timestep); std::unique_ptr<KernelFactory> kernelFactory; std::shared_ptr<PreProcessorFactory> preProcessorFactory; @@ -80,6 +87,13 @@ private: SPtr<RestartObject> restart_object; + // Timer + std::unique_ptr<Timer> averageTimer; + uint previousTimestepForAveraging; + uint previousTimestepForTurbulenceIntensityCalculation; + uint timestepForMeasuringPoints; + + //Forcing Calculation std::shared_ptr<ForceCalculations> forceCalculator; diff --git a/src/gpu/VirtualFluids_GPU/Output/AnalysisData.hpp b/src/gpu/VirtualFluids_GPU/Output/AnalysisData.hpp index d091f38ea228d43345235132cd4947ff750436d6..882cc2b46c3faf3eb81a5296a7b8c6f2e1bc3ac8 100644 --- a/src/gpu/VirtualFluids_GPU/Output/AnalysisData.hpp +++ b/src/gpu/VirtualFluids_GPU/Output/AnalysisData.hpp @@ -3,7 +3,7 @@ #include "basics/utilities/UbFileOutputASCII.h" #include "Parameter/Parameter.h" -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" class AnalysisData { diff --git a/src/gpu/VirtualFluids_GPU/Output/DataWriter.h b/src/gpu/VirtualFluids_GPU/Output/DataWriter.h index 48a9b56da3abd5337e1c6042a7dcba3304c449e6..67a50867c1ef957c2e80b338f8597262508c468d 100644 --- a/src/gpu/VirtualFluids_GPU/Output/DataWriter.h +++ b/src/gpu/VirtualFluids_GPU/Output/DataWriter.h @@ -2,7 +2,7 @@ #define DATA_WRITER_H #include "PointerDefinitions.h" -#include "Core/DataTypes.h" +#include "DataTypes.h" #include <memory> #include <vector> diff --git a/src/gpu/VirtualFluids_GPU/Output/DistributionDebugInspector.cu b/src/gpu/VirtualFluids_GPU/Output/DistributionDebugInspector.cu index f7bb2e680c0fb3ea597239ee0cbc1772f2efe81b..e5062a8ec63940ab6e23e567c0674681d4af6509 100644 --- a/src/gpu/VirtualFluids_GPU/Output/DistributionDebugInspector.cu +++ b/src/gpu/VirtualFluids_GPU/Output/DistributionDebugInspector.cu @@ -34,7 +34,7 @@ #include "Parameter/Parameter.h" #include "lbm/constants/D3Q27.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include "LBM/GPUHelperFunctions/KernelUtilities.h" #include <cuda/CudaGrid.h> @@ -42,7 +42,7 @@ #include <iostream> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; using namespace vf::gpu; diff --git a/src/gpu/VirtualFluids_GPU/Output/EdgeNodeDebugWriter.hpp b/src/gpu/VirtualFluids_GPU/Output/EdgeNodeDebugWriter.hpp index 6498bbb0a2b787d70a3b11500549b2a8956ce67a..fb0423de958e16727eca8e5a40af2c3e32faf1ae 100644 --- a/src/gpu/VirtualFluids_GPU/Output/EdgeNodeDebugWriter.hpp +++ b/src/gpu/VirtualFluids_GPU/Output/EdgeNodeDebugWriter.hpp @@ -5,7 +5,7 @@ #include <sstream> #include <stdio.h> // #include <math.h> -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" #include "lbm/constants/D3Q27.h" #include "LBM/LB.h" #include "Parameter/Parameter.h" diff --git a/src/gpu/VirtualFluids_GPU/Output/FileWriter.cpp b/src/gpu/VirtualFluids_GPU/Output/FileWriter.cpp index edf705421530bdbc9c2c9fd8c44eca6d3c5ab923..cb8cefa389c141b7f38bbc54a68d8cf9841ba699 100644 --- a/src/gpu/VirtualFluids_GPU/Output/FileWriter.cpp +++ b/src/gpu/VirtualFluids_GPU/Output/FileWriter.cpp @@ -13,7 +13,7 @@ #include <sstream> #include <cmath> -#include <Core/StringUtilities/StringUtil.h> +#include <StringUtilities/StringUtil.h> #include "Parameter/Parameter.h" #include "GPU/CudaMemoryManager.h" @@ -379,7 +379,7 @@ void FileWriter::writeUnstrucuredGridLTConc(std::shared_ptr<Parameter> para, int nodedata[3][dn1] = (double)para->getParH(level)->velocityY[pos] * (double)para->getVelocityRatio(); nodedata[4][dn1] = (double)para->getParH(level)->velocityZ[pos] * (double)para->getVelocityRatio(); nodedata[5][dn1] = (double)para->getParH(level)->typeOfGridNode[pos]; - nodedata[6][dn1] = (double)para->getParH(level)->Conc[pos]; + nodedata[6][dn1] = (double)para->getParH(level)->concentration[pos]; ////////////////////////////////////////////////////////////////////////// number2 = para->getParH(level)->neighborX[number1]; number3 = para->getParH(level)->neighborY[number2]; diff --git a/src/gpu/VirtualFluids_GPU/Output/InterfaceDebugWriter.hpp b/src/gpu/VirtualFluids_GPU/Output/InterfaceDebugWriter.hpp index 4d5895b323efa1b94a5780a59c882fd5ce1be7eb..705d86992d9eac39b66cf5033f7c32b5cb4fb602 100644 --- a/src/gpu/VirtualFluids_GPU/Output/InterfaceDebugWriter.hpp +++ b/src/gpu/VirtualFluids_GPU/Output/InterfaceDebugWriter.hpp @@ -3,7 +3,7 @@ #include <fstream> #include <sstream> -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" #include "lbm/constants/D3Q27.h" #include "LBM/LB.h" #include "Parameter/Parameter.h" @@ -46,8 +46,7 @@ void writeInterfaceLinesDebugCF(Parameter *para) { for (int level = 0; level < para->getMaxLevel(); level++) { const std::string fileName = para->getFName() + "_" + StringUtil::toString<int>(level) + "_OffDebugCF.vtk"; - writeGridInterfaceLines(para, level, para->getParH(level)->intCF.ICellCFC, para->getParH(level)->intCF.ICellCFF, - para->getParH(level)->K_CF, fileName); + writeGridInterfaceLines(para, level, para->getParH(level)->coarseToFine.coarseCellIndices, para->getParH(level)->coarseToFine.fineCellIndices, para->getParH(level)->coarseToFine.numberOfCells, fileName); } } @@ -55,8 +54,7 @@ void writeInterfaceLinesDebugFC(Parameter *para) { for (int level = 0; level < para->getMaxLevel(); level++) { const std::string fileName = para->getFName() + "_" + StringUtil::toString<int>(level) + "_OffDebugFC.vtk"; - writeGridInterfaceLines(para, level, para->getParH(level)->intFC.ICellFCC, para->getParH(level)->intFC.ICellFCF, - para->getParH(level)->K_FC, fileName); + writeGridInterfaceLines(para, level, para->getParH(level)->fineToCoarse.coarseCellIndices, para->getParH(level)->fineToCoarse.fineCellIndices, para->getParH(level)->fineToCoarse.numberOfCells, fileName); } } @@ -90,7 +88,7 @@ void writeInterfaceLinesDebugCFCneighbor(Parameter *para) { for (int level = 0; level < para->getMaxLevel(); level++) { std::string filename = para->getFName() + "_" + StringUtil::toString<int>(level) + "_CFCneighbor.vtk"; - writeGridInterfaceLinesNeighbors(para, level, para->getParH(level)->intCF.ICellCFC, para->getParH(level)->K_CF, + writeGridInterfaceLinesNeighbors(para, level, para->getParH(level)->coarseToFine.coarseCellIndices, para->getParH(level)->coarseToFine.numberOfCells, filename); } } @@ -100,8 +98,7 @@ void writeInterfaceLinesDebugCFFneighbor(Parameter *para) { for (int level = 0; level < para->getMaxLevel(); level++) { std::string filename = para->getFName() + "_" + StringUtil::toString<int>(level) + "_CFFneighbor.vtk"; - writeGridInterfaceLinesNeighbors(para, level + 1, para->getParH(level)->intCF.ICellCFF, - para->getParH(level)->K_CF, filename); + writeGridInterfaceLinesNeighbors(para, level + 1, para->getParH(level)->coarseToFine.fineCellIndices, para->getParH(level)->coarseToFine.numberOfCells, filename); } } @@ -110,7 +107,7 @@ void writeInterfaceLinesDebugFCCneighbor(Parameter *para) { for (int level = 0; level < para->getMaxLevel(); level++) { std::string filename = para->getFName() + "_" + StringUtil::toString<int>(level) + "_FCCneighbor.vtk"; - writeGridInterfaceLinesNeighbors(para, level, para->getParH(level)->intFC.ICellFCC, para->getParH(level)->K_FC, + writeGridInterfaceLinesNeighbors(para, level, para->getParH(level)->fineToCoarse.coarseCellIndices, para->getParH(level)->fineToCoarse.numberOfCells, filename); } } @@ -120,8 +117,7 @@ void writeInterfaceLinesDebugFCFneighbor(Parameter *para) { for (int level = 0; level < para->getMaxLevel(); level++) { std::string filename = para->getFName() + "_" + StringUtil::toString<int>(level) + "_FCFneighbor.vtk"; - writeGridInterfaceLinesNeighbors(para, level + 1, para->getParH(level)->intFC.ICellFCF, - para->getParH(level)->K_FC, filename); + writeGridInterfaceLinesNeighbors(para, level + 1, para->getParH(level)->fineToCoarse.fineCellIndices, para->getParH(level)->fineToCoarse.numberOfCells, filename); } } @@ -134,17 +130,17 @@ void writeInterfaceLinesDebugOff(Parameter *para) for (int level = 0; level < para->getMaxLevel(); level++) // evtl. Maxlevel + 1 { - nodeNumberVec += (int)para->getParH(level)->K_CF; + nodeNumberVec += (int)para->getParH(level)->coarseToFine.numberOfCells; } nodesVec.resize(nodeNumberVec * 8); int nodeCount = 0; for (int level = 0; level < para->getMaxLevel(); level++) { - for (unsigned int u = 0; u < para->getParH(level)->K_CF; u++) { - double xoff = para->getParH(level)->offCF.xOffCF[u]; - double yoff = para->getParH(level)->offCF.yOffCF[u]; - double zoff = para->getParH(level)->offCF.zOffCF[u]; + for (unsigned int u = 0; u < para->getParH(level)->coarseToFine.numberOfCells; u++) { + double xoff = para->getParH(level)->neighborCoarseToFine.x[u]; + double yoff = para->getParH(level)->neighborCoarseToFine.y[u]; + double zoff = para->getParH(level)->neighborCoarseToFine.z[u]; - int posFine = para->getParH(level)->intCF.ICellCFF[u]; + int posFine = para->getParH(level)->coarseToFine.fineCellIndices[u]; double x1Fine = para->getParH(level + 1)->coordinateX[posFine]; double x2Fine = para->getParH(level + 1)->coordinateY[posFine]; @@ -175,13 +171,13 @@ void writeInterfacePointsDebugCFC(Parameter *para) for (int level = 0; level < para->getMaxLevel(); level++) // evtl. Maxlevel + 1 { - nodeNumberVec += (int)para->getParH(level)->K_CF; + nodeNumberVec += (int)para->getParH(level)->coarseToFine.numberOfCells; } nodesVec2.resize(nodeNumberVec * 8); int nodeCount2 = 0; for (int level = 0; level < para->getMaxLevel(); level++) { - for (unsigned int u = 0; u < para->getParH(level)->K_CF; u++) { - int pos = para->getParH(level)->intCF.ICellCFC[u]; + for (unsigned int u = 0; u < para->getParH(level)->coarseToFine.numberOfCells; u++) { + int pos = para->getParH(level)->coarseToFine.coarseCellIndices[u]; double x1 = para->getParH(level)->coordinateX[pos]; double x2 = para->getParH(level)->coordinateY[pos]; @@ -467,13 +463,13 @@ void writeInterfaceCellsDebugCFC(Parameter *para) int nodeNumberVec = 0; for (int level = 0; level < para->getMaxLevel(); level++) // evtl. Maxlevel + 1 { - nodeNumberVec += (int)para->getParH(level)->K_CF; + nodeNumberVec += (int)para->getParH(level)->coarseToFine.numberOfCells; } nodesVec.resize(nodeNumberVec * 8); int nodeCount = 0; for (int level = 0; level < para->getMaxLevel(); level++) { - for (unsigned int u = 0; u < para->getParH(level)->K_CF; u++) { - int pos = para->getParH(level)->intCF.ICellCFC[u]; + for (unsigned int u = 0; u < para->getParH(level)->coarseToFine.numberOfCells; u++) { + int pos = para->getParH(level)->coarseToFine.coarseCellIndices[u]; double x1 = para->getParH(level)->coordinateX[pos]; double x2 = para->getParH(level)->coordinateY[pos]; @@ -508,13 +504,13 @@ void writeInterfaceCellsDebugCFF(Parameter *para) int nodeNumberVec = 0; for (int level = 0; level < para->getMaxLevel(); level++) // evtl. Maxlevel + 1 { - nodeNumberVec += (int)para->getParH(level)->K_CF; + nodeNumberVec += (int)para->getParH(level)->coarseToFine.numberOfCells; } nodesVec.resize(nodeNumberVec * 8); int nodeCount = 0; for (int level = 0; level < para->getMaxLevel(); level++) { - for (unsigned int u = 0; u < para->getParH(level)->K_CF; u++) { - int pos = para->getParH(level)->intCF.ICellCFF[u]; + for (unsigned int u = 0; u < para->getParH(level)->coarseToFine.numberOfCells; u++) { + int pos = para->getParH(level)->coarseToFine.fineCellIndices[u]; double x1 = para->getParH(level + 1)->coordinateX[pos]; double x2 = para->getParH(level + 1)->coordinateY[pos]; @@ -620,7 +616,7 @@ void writeInterfaceFCC_Send(Parameter *para) std::vector<std::vector<double>> nodedata; for (int level = 0; level < para->getMaxLevel(); level++) { - nodeNumberVec += (int)para->getParH(level)->intFC.kFC; + nodeNumberVec += (int)para->getParH(level)->fineToCoarse.numberOfCells; } nodesVec.resize(nodeNumberVec); @@ -628,8 +624,8 @@ void writeInterfaceFCC_Send(Parameter *para) int nodeCount = 0; for (int level = 0; level < para->getMaxLevel(); level++) { - for (unsigned int u = 0; u < para->getParH(level)->intFC.kFC; u++) { - int pos = para->getParH(level)->intFC.ICellFCC[u]; + for (unsigned int u = 0; u < para->getParH(level)->fineToCoarse.numberOfCells; u++) { + int pos = para->getParH(level)->fineToCoarse.coarseCellIndices[u]; nodedata[0][nodeCount] = pos; // coordinate section @@ -639,7 +635,7 @@ void writeInterfaceFCC_Send(Parameter *para) nodesVec[nodeCount] = (makeUbTuple((float)(x1), (float)(x2), (float)(x3))); // nodedata section - nodedata[1][nodeCount] = u < para->getParH(level)->intFCBorder.kFC; + nodedata[1][nodeCount] = u < para->getParH(level)->fineToCoarseBorder.numberOfCells; int sendDir = 0.0; int sendDirectionInCommAfterFtoC = 0.0; int sendIndex = 0.0; @@ -674,7 +670,7 @@ void writeInterfaceCFC_Recv(Parameter *para) std::vector<std::vector<double>> nodedata; for (int level = 0; level < para->getMaxLevel(); level++) { - nodeNumberVec += (int)para->getParH(level)->intCF.kCF; + nodeNumberVec += (int)para->getParH(level)->coarseToFine.numberOfCells; } nodesVec.resize(nodeNumberVec); @@ -682,8 +678,8 @@ void writeInterfaceCFC_Recv(Parameter *para) int nodeCount = 0; for (int level = 0; level < para->getMaxLevel(); level++) { - for (unsigned int u = 0; u < para->getParH(level)->intCF.kCF; u++) { - int pos = para->getParH(level)->intCF.ICellCFC[u]; + for (unsigned int u = 0; u < para->getParH(level)->coarseToFine.numberOfCells; u++) { + int pos = para->getParH(level)->coarseToFine.coarseCellIndices[u]; nodedata[0][nodeCount] = pos; // coordinate section @@ -693,7 +689,7 @@ void writeInterfaceCFC_Recv(Parameter *para) nodesVec[nodeCount] = (makeUbTuple((float)(x1), (float)(x2), (float)(x3))); // nodedata section - nodedata[1][nodeCount] = u < para->getParH(level)->intCFBorder.kCF; + nodedata[1][nodeCount] = u < para->getParH(level)->coarseToFineBorder.numberOfCells; int recvDir = 0.0; int recvDirectionInCommAfterFtoC = 0.0; int recvIndex = 0.0; @@ -799,12 +795,12 @@ void writeSendNodesStream(Parameter *para) } } - // check if node is in iCellFCC + // check if node is in a coarse cell for the interpolation from fine to coarse nodedata[4].resize(nodedata[0].size()); for (int i = 0; i < (int)nodedata[0].size(); i++) { pos = nodedata[0][i]; - for (unsigned int u = 0; u < para->getParH(level)->intFC.kFC; u++) { - if (para->getParH(level)->intFC.ICellFCC[u] == (uint)pos) { + for (unsigned int u = 0; u < para->getParH(level)->fineToCoarse.numberOfCells; u++) { + if (para->getParH(level)->fineToCoarse.coarseCellIndices[u] == (uint)pos) { nodedata[4][i] = 1.0; break; } @@ -895,7 +891,7 @@ void writeRecvNodesStream(Parameter *para) } } - // Recv are nodes ghost nodes and therefore they can't be iCellCFCs + // Recv are nodes ghost nodes and therefore they can't be coarse cells for the interpolation from coarse to fine std::string filenameVec = para->getFName() + "_writeRecvNodesStreams_PID_" + std::to_string(vf::gpu::Communicator::getInstance().getPID()) + "_" + diff --git a/src/gpu/VirtualFluids_GPU/Output/NeighborDebugWriter.hpp b/src/gpu/VirtualFluids_GPU/Output/NeighborDebugWriter.hpp index 57139d25ae4d046e1dd1be1f3ef5e179daf0872e..e506a56bb76a263ac8982a7e53f39e67c268e49b 100644 --- a/src/gpu/VirtualFluids_GPU/Output/NeighborDebugWriter.hpp +++ b/src/gpu/VirtualFluids_GPU/Output/NeighborDebugWriter.hpp @@ -9,7 +9,7 @@ #include "lbm/constants/D3Q27.h" #include <basics/writer/WbWriterVtkXmlBinary.h> -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" #include "Utilities/FindNeighbors.h" #include "gpu/VirtualFluids_GPU/Communication/Communicator.h" diff --git a/src/gpu/VirtualFluids_GPU/Output/OffsetWriter.hpp b/src/gpu/VirtualFluids_GPU/Output/OffsetWriter.hpp index 7aa660fa33d8ad31a19053e3511241de3ee07c07..fb04951db68ae509dddc7d2fe52250489b54bde2 100644 --- a/src/gpu/VirtualFluids_GPU/Output/OffsetWriter.hpp +++ b/src/gpu/VirtualFluids_GPU/Output/OffsetWriter.hpp @@ -21,13 +21,13 @@ public: { for (int level = 0; level < para->getMaxLevel(); level++) { - out.writeInteger(para->getParH(level)->K_CF); + out.writeInteger(para->getParH(level)->coarseToFine.numberOfCells); out.writeLine(); - for(unsigned int u=0; u<para->getParH(level)->K_CF; u++) + for (unsigned int u = 0; u < para->getParH(level)->coarseToFine.numberOfCells; u++) { - out.writeDouble(para->getParH(level)->offCF.xOffCF[u]); - out.writeDouble(para->getParH(level)->offCF.yOffCF[u]); - out.writeDouble(para->getParH(level)->offCF.zOffCF[u]); + out.writeDouble(para->getParH(level)->neighborCoarseToFine.x[u]); + out.writeDouble(para->getParH(level)->neighborCoarseToFine.y[u]); + out.writeDouble(para->getParH(level)->neighborCoarseToFine.z[u]); } out.writeLine(); } //end levelloop @@ -36,13 +36,13 @@ public: { for (int level = 0; level < para->getMaxLevel(); level++) { - out.writeInteger(para->getParH(level)->K_FC); + out.writeInteger(para->getParH(level)->fineToCoarse.numberOfCells); out.writeLine(); - for(unsigned int u=0; u<para->getParH(level)->K_FC; u++) + for (unsigned int u = 0; u < para->getParH(level)->fineToCoarse.numberOfCells; u++) { - out.writeDouble(para->getParH(level)->offFC.xOffFC[u]); - out.writeDouble(para->getParH(level)->offFC.yOffFC[u]); - out.writeDouble(para->getParH(level)->offFC.zOffFC[u]); + out.writeDouble(para->getParH(level)->neighborFineToCoarse.x[u]); + out.writeDouble(para->getParH(level)->neighborFineToCoarse.y[u]); + out.writeDouble(para->getParH(level)->neighborFineToCoarse.z[u]); } out.writeLine(); } //end levelloop diff --git a/src/gpu/VirtualFluids_GPU/Output/PosVecIntWriter.hpp b/src/gpu/VirtualFluids_GPU/Output/PosVecIntWriter.hpp index a9207ed231e8d9667e57636a5a5fdd6b5aeab94f..d7eab31d639d23d2356263aa8b152d69b3c042b8 100644 --- a/src/gpu/VirtualFluids_GPU/Output/PosVecIntWriter.hpp +++ b/src/gpu/VirtualFluids_GPU/Output/PosVecIntWriter.hpp @@ -38,11 +38,11 @@ public: { for (int level = 0; level < para->getMaxLevel(); level++) { - out.writeInteger(para->getParH(level)->K_CF); + out.writeInteger(para->getParH(level)->coarseToFine.numberOfCells); out.writeLine(); - for(unsigned int u=0; u<para->getParH(level)->K_CF; u++) + for (unsigned int u = 0; u < para->getParH(level)->coarseToFine.numberOfCells; u++) { - out.writeInteger(para->getParH(level)->intCF.ICellCFC[u]); + out.writeInteger(para->getParH(level)->coarseToFine.coarseCellIndices[u]); } out.writeLine(); } //end levelloop @@ -51,11 +51,11 @@ public: { for (int level = 0; level < para->getMaxLevel(); level++) { - out.writeInteger(para->getParH(level)->K_CF); + out.writeInteger(para->getParH(level)->coarseToFine.numberOfCells); out.writeLine(); - for(unsigned int u=0; u<para->getParH(level)->K_CF; u++) + for (unsigned int u = 0; u < para->getParH(level)->coarseToFine.numberOfCells; u++) { - out.writeInteger(para->getParH(level)->intCF.ICellCFF[u]); + out.writeInteger(para->getParH(level)->coarseToFine.fineCellIndices[u]); } out.writeLine(); } //end levelloop @@ -64,11 +64,11 @@ public: { for (int level = 0; level < para->getMaxLevel(); level++) { - out.writeInteger(para->getParH(level)->K_FC); + out.writeInteger(para->getParH(level)->fineToCoarse.numberOfCells); out.writeLine(); - for(unsigned int u=0; u<para->getParH(level)->K_FC; u++) + for (unsigned int u = 0; u < para->getParH(level)->fineToCoarse.numberOfCells; u++) { - out.writeInteger(para->getParH(level)->intFC.ICellFCC[u]); + out.writeInteger(para->getParH(level)->fineToCoarse.coarseCellIndices[u]); } out.writeLine(); } //end levelloop @@ -77,11 +77,11 @@ public: { for (int level = 0; level < para->getMaxLevel(); level++) { - out.writeInteger(para->getParH(level)->K_FC); + out.writeInteger(para->getParH(level)->fineToCoarse.numberOfCells); out.writeLine(); - for(unsigned int u=0; u<para->getParH(level)->K_FC; u++) + for (unsigned int u = 0; u < para->getParH(level)->fineToCoarse.numberOfCells; u++) { - out.writeInteger(para->getParH(level)->intFC.ICellFCF[u]); + out.writeInteger(para->getParH(level)->fineToCoarse.fineCellIndices[u]); } out.writeLine(); } //end levelloop diff --git a/src/gpu/VirtualFluids_GPU/Output/QDebugVtkWriter.hpp b/src/gpu/VirtualFluids_GPU/Output/QDebugVtkWriter.hpp index d567c695a0e33b7a88c2c8cf3bcb88093ce5b802..d075c78e53a45e96adea43c8846159f4ba128c6d 100644 --- a/src/gpu/VirtualFluids_GPU/Output/QDebugVtkWriter.hpp +++ b/src/gpu/VirtualFluids_GPU/Output/QDebugVtkWriter.hpp @@ -4,11 +4,11 @@ #include <array> #include <vector> -#include "basics/Core/StringUtilities/StringUtil.h" +#include "basics/StringUtilities/StringUtil.h" #include "basics/utilities/UbSystem.h" #include "basics/writer/WbWriterVtkXmlBinary.h" #include "lbm/constants/D3Q27.h" -#include "logger/Logger.h" +#include <logger/Logger.h> #include "gpu/GridGenerator/grid/NodeValues.h" #include "gpu/VirtualFluids_GPU/Communication/Communicator.h" diff --git a/src/gpu/VirtualFluids_GPU/Output/QDebugWriter.hpp b/src/gpu/VirtualFluids_GPU/Output/QDebugWriter.hpp index c1a3658d318eb47e84530bf437afa0bb6ba91743..b24dab20be957fa27b9306d0bbabbec53694753c 100644 --- a/src/gpu/VirtualFluids_GPU/Output/QDebugWriter.hpp +++ b/src/gpu/VirtualFluids_GPU/Output/QDebugWriter.hpp @@ -11,7 +11,7 @@ #include "Parameter/Parameter.h" #include "basics/utilities/UbSystem.h" #include <basics/writer/WbWriterVtkXmlBinary.h> -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" namespace QDebugWriter { diff --git a/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.cpp b/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.cpp index 78da4947d0c8196cda49fef754a3f44fc39d0a44..979c4349a084342a897a0269ffb86a3714065e96 100644 --- a/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.cpp +++ b/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.cpp @@ -1,6 +1,6 @@ #include "helper_cuda.h" #include <cuda_runtime.h> -#include "Core/DataTypes.h" +#include "DataTypes.h" #include "UbScheduler.h" #include "Parameter/Parameter.h" diff --git a/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.h b/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.h index 982d1ce56bfadb7eddfd3d34d8d6b01ac6f92233..41bb9eba7ba09ddb092e644894eca0fde71fa27b 100644 --- a/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.h +++ b/src/gpu/VirtualFluids_GPU/Output/TimeStepTimer.h @@ -3,7 +3,7 @@ #include "helper_cuda.h" #include <cuda_runtime.h> -#include "Core/DataTypes.h" +#include "DataTypes.h" #include "UbScheduler.h" #include "Parameter/Parameter.h" diff --git a/src/gpu/VirtualFluids_GPU/Output/Timer.h b/src/gpu/VirtualFluids_GPU/Output/Timer.h index d035cbb6cef7ea9f8edabbd2894671a868c37eec..55ada64ad245ee41aa99a1185eba134a652067c9 100644 --- a/src/gpu/VirtualFluids_GPU/Output/Timer.h +++ b/src/gpu/VirtualFluids_GPU/Output/Timer.h @@ -2,9 +2,9 @@ #define TIMER_H #include <cuda_runtime.h> -#include "Core/DataTypes.h" +#include "DataTypes.h" #include "Parameter/Parameter.h" -#include "logger/Logger.h" +#include <logger/Logger.h> namespace vf::gpu{ class Communicator; diff --git a/src/gpu/VirtualFluids_GPU/Output/UnstructuredGridWriter.hpp b/src/gpu/VirtualFluids_GPU/Output/UnstructuredGridWriter.hpp index f26b4e5795466a72aa1894de37bdb066b9ab9d04..cafe70205455ae8592c1efe86e4ba9de8e1ba170 100644 --- a/src/gpu/VirtualFluids_GPU/Output/UnstructuredGridWriter.hpp +++ b/src/gpu/VirtualFluids_GPU/Output/UnstructuredGridWriter.hpp @@ -814,7 +814,7 @@ namespace UnstructuredGridWriter nodedata[3][dn1] = (double)para->getParH(level)->velocityY[pos] * (double)para->getVelocityRatio(); nodedata[4][dn1] = (double)para->getParH(level)->velocityZ[pos] * (double)para->getVelocityRatio(); nodedata[5][dn1] = (double)para->getParH(level)->typeOfGridNode[pos]; - nodedata[6][dn1] = (double)para->getParH(level)->Conc[pos]; + nodedata[6][dn1] = (double)para->getParH(level)->concentration[pos]; ////////////////////////////////////////////////////////////////////////// number2 = para->getParH(level)->neighborX[number1]; number3 = para->getParH(level)->neighborY[number2]; diff --git a/src/gpu/VirtualFluids_GPU/Output/interfaceWriter.hpp b/src/gpu/VirtualFluids_GPU/Output/interfaceWriter.hpp index f140b15a6b7595a959139da2a35ed58f01b2a307..bf35411b93fd1f126cfdde1f3739f1baa33a4d83 100644 --- a/src/gpu/VirtualFluids_GPU/Output/interfaceWriter.hpp +++ b/src/gpu/VirtualFluids_GPU/Output/interfaceWriter.hpp @@ -32,11 +32,11 @@ public: { if ((Type == "_InterfaceCFC") || (Type == "_InterfaceCFF")) { - nodeNumberVec += para->getParH(level)->K_CF; + nodeNumberVec += para->getParH(level)->coarseToFine.numberOfCells; } else if (Type == "_InterfaceFCF") { - nodeNumberVec += para->getParH(level)->K_FC; + nodeNumberVec += para->getParH(level)->fineToCoarse.numberOfCells; } } nodesVec.resize(nodeNumberVec*8); @@ -55,9 +55,9 @@ public: //std::vector<unsigned int>& posVec = posIndexVec[level]; if (Type == "_InterfaceCFC") { - for(unsigned int u=0;u<para->getParH(level)->K_CF;u++) + for (unsigned int u = 0; u < para->getParH(level)->coarseToFine.numberOfCells; u++) { - int pos = para->getParH(level)->intCF.ICellCFC[u]; + int pos = para->getParH(level)->coarseToFine.coarseCellIndices[u]; int ix1 = pos % nx1lev; int wertDurchNx1 = pos / nx1lev; int ix2 = wertDurchNx1 % nx2lev; @@ -82,9 +82,9 @@ public: } else if (Type == "_InterfaceCFF") { - for(unsigned int u=0;u<para->getParH(level)->K_CF;u++) + for (unsigned int u = 0; u < para->getParH(level)->coarseToFine.numberOfCells; u++) { - int pos = para->getParH(level)->intCF.ICellCFF[u]; + int pos = para->getParH(level)->coarseToFine.fineCellIndices[u]; int ix1 = pos % nx1lev; int wertDurchNx1 = pos / nx1lev; int ix2 = wertDurchNx1 % nx2lev; @@ -109,9 +109,9 @@ public: } else if (Type == "_InterfaceFCF") { - for(unsigned int u=0;u<para->getParH(level)->K_FC;u++) + for (unsigned int u = 0; u < para->getParH(level)->fineToCoarse.numberOfCells; u++) { - int pos = para->getParH(level)->intFC.ICellFCF[u]; + int pos = para->getParH(level)->fineToCoarse.fineCellIndices[u]; int ix1 = pos % nx1lev; int wertDurchNx1 = pos / nx1lev; int ix2 = wertDurchNx1 % nx2lev; @@ -146,7 +146,7 @@ public: int nodeNumberVec = 0; for (int level = 0; level < para->getMaxLevel(); level++) { - nodeNumberVec += para->getParH(level)->K_FC; + nodeNumberVec += para->getParH(level)->fineToCoarse.numberOfCells; } nodesVec.resize(nodeNumberVec*8); int nodeCount = 0; @@ -163,9 +163,9 @@ public: double achtelNodeDelta = 0.125*nodeDeltaLevel; //int count = 0; //std::vector<unsigned int>& posVec = posIndexVec[level]; - for(unsigned int u=0;u<para->getParH(level)->K_FC;u++) + for (unsigned int u = 0; u < para->getParH(level)->fineToCoarse.numberOfCells; u++) { - int pos = para->getParH(level)->intFC.ICellFCC[u];//posVec[u]; + int pos = para->getParH(level)->fineToCoarse.coarseCellIndices[u];//posVec[u]; int ix1 = pos % nx1lev; int wertDurchNx1 = pos / nx1lev; int ix2 = wertDurchNx1 % nx2lev; diff --git a/src/gpu/VirtualFluids_GPU/Parameter/CudaStreamManager.h b/src/gpu/VirtualFluids_GPU/Parameter/CudaStreamManager.h index 5c59bcd3a5e6178d6e70a63f803caf8e29f32604..631a945a653e6b4b60924a650e94b3873ebacc7d 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/CudaStreamManager.h +++ b/src/gpu/VirtualFluids_GPU/Parameter/CudaStreamManager.h @@ -33,7 +33,7 @@ #include <map> #include <cuda.h> #include <cuda_runtime.h> -#include "Core/DataTypes.h" +#include "DataTypes.h" enum class CudaStreamIndex { diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp index e593d16d6ed1f69ca65a22606a157e7ea9e6b111..bf0d72448fb5a69c849d93749e24f29290cf9621 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp @@ -39,7 +39,7 @@ #include <curand_kernel.h> -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" #include <basics/config/ConfigurationFile.h> @@ -54,8 +54,8 @@ Parameter::Parameter(int numberOfProcesses, int myId) : Parameter(numberOfProces Parameter::Parameter(int numberOfProcesses, int myId, std::optional<const vf::basics::ConfigurationFile*> configData) { - this->ic.numprocs = numberOfProcesses; - this->ic.myProcessId = myId; + this->numprocs = numberOfProcesses; + this->myProcessId = myId; this->setQuadricLimiters(0.01, 0.01, 0.01); this->setForcing(0.0, 0.0, 0.0); @@ -119,9 +119,6 @@ void Parameter::readConfigData(const vf::basics::ConfigurationFile &configData) if (configData.contains("UseConcFile")) this->setConcFile(configData.getValue<bool>("UseConcFile")); ////////////////////////////////////////////////////////////////////////// - if (configData.contains("UseStreetVelocityFile")) - this->setStreetVelocityFile(configData.getValue<bool>("UseStreetVelocityFile")); - ////////////////////////////////////////////////////////////////////////// if (configData.contains("UseMeasurePoints")) this->setUseMeasurePoints(configData.getValue<bool>("UseMeasurePoints")); ////////////////////////////////////////////////////////////////////////// @@ -359,13 +356,13 @@ void Parameter::initGridPaths(){ // add missing slash to gridPath if (gridPath.back() != '/') { gridPath += "/"; - ic.gridPath = gridPath; + this->gridPath = gridPath; } // for multi-gpu add process id (if not already there) if (this->getNumprocs() > 1) { gridPath += StringUtil::toString(this->getMyProcessID()) + "/"; - ic.gridPath = gridPath; + this->gridPath = gridPath; } ////////////////////////////////////////////////////////////////////////// @@ -406,7 +403,6 @@ void Parameter::initGridPaths(){ this->setcpBottom(gridPath + "cpBottom.dat"); this->setcpBottom2(gridPath + "cpBottom2.dat"); this->setConcentration(gridPath + "conc.dat"); - this->setStreetVelocity(gridPath + "streetVector.dat"); ////////////////////////////////////////////////////////////////////////// // Normals - Geometry @@ -493,9 +489,9 @@ void Parameter::initLBMSimulationParameter() parH[i]->gridNX = getGridX().at(i); parH[i]->gridNY = getGridY().at(i); parH[i]->gridNZ = getGridZ().at(i); - parH[i]->vis = ic.vis * pow(2.f, i); - parH[i]->diffusivity = ic.Diffusivity * pow(2.f, i); - parH[i]->omega = 1.0f / (3.0f * parH[i]->vis + 0.5f); // omega :-) not s9 = -1.0f/(3.0f*parH[i]->vis+0.5f);// + parH[i]->viscosity = this->vis * pow((real)2.0, i); + parH[i]->diffusivity = this->Diffusivity * pow((real)2.0, i); + parH[i]->omega = (real)1.0 / (real(3.0) * parH[i]->viscosity + real(0.5)); // omega :-) not s9 = -1.0f/(3.0f*parH[i]->vis+0.5f);// parH[i]->nx = parH[i]->gridNX + 2 * STARTOFFX; parH[i]->ny = parH[i]->gridNY + 2 * STARTOFFY; parH[i]->nz = parH[i]->gridNZ + 2 * STARTOFFZ; @@ -508,12 +504,12 @@ void Parameter::initLBMSimulationParameter() // parH[i]->mem_size_bool = sizeof(bool) * parH[i]->size_Mat; //DEPRECATED: related to full matrix // parH[i]->mem_size_real_yz = sizeof(real) * parH[i]->ny * parH[i]->nz; //DEPRECATED: related to full matrix parH[i]->isEvenTimestep = true; - parH[i]->startz = parH[i]->gridNZ * ic.myProcessId; - parH[i]->endz = parH[i]->gridNZ * ic.myProcessId + parH[i]->gridNZ; - parH[i]->Lx = (real)((1.f * parH[i]->gridNX - 1.f) / (pow(2.f, i))); - parH[i]->Ly = (real)((1.f * parH[i]->gridNY - 1.f) / (pow(2.f, i))); - parH[i]->Lz = (real)((1.f * parH[i]->gridNZ - 1.f) / (pow(2.f, i))); - parH[i]->dx = (real)(1.f / (pow(2.f, i))); + parH[i]->startz = parH[i]->gridNZ * this->myProcessId; + parH[i]->endz = parH[i]->gridNZ * this->myProcessId + parH[i]->gridNZ; + parH[i]->Lx = ((real)1.0 * parH[i]->gridNX - (real)1.0) / (pow((real)2.0, i)); + parH[i]->Ly = ((real)1.0 * parH[i]->gridNY - (real)1.0) / (pow((real)2.0, i)); + parH[i]->Lz = ((real)1.0 * parH[i]->gridNZ - (real)1.0) / (pow((real)2.0, i)); + parH[i]->dx = (real)1.0 / pow((real)2.0, i); parH[i]->XdistKn = getDistX().at(i); parH[i]->YdistKn = getDistY().at(i); parH[i]->ZdistKn = getDistZ().at(i); @@ -521,12 +517,12 @@ void Parameter::initLBMSimulationParameter() parH[i]->distX = (real)getDistX().at(i); parH[i]->distY = (real)getDistY().at(i); parH[i]->distZ = (real)getDistZ().at(i); - parH[i]->mTtoWx = (real)1.0f; - parH[i]->mTtoWy = (real)1.0f; - parH[i]->mTtoWz = (real)1.0f; - parH[i]->cTtoWx = (real)0.0f; - parH[i]->cTtoWy = (real)0.0f; - parH[i]->cTtoWz = (real)0.0f; + parH[i]->mTtoWx = (real)1.0; + parH[i]->mTtoWy = (real)1.0; + parH[i]->mTtoWz = (real)1.0; + parH[i]->cTtoWx = (real)0.0; + parH[i]->cTtoWy = (real)0.0; + parH[i]->cTtoWz = (real)0.0; ////MGs Trafo/////////////////////////////////////////////////////////////// // parH[i]->cStartx = (real)parH[i]->XdistKn; // parH[i]->cStarty = (real)parH[i]->XdistKn; @@ -534,9 +530,9 @@ void Parameter::initLBMSimulationParameter() //////////////////////////////////////////////////////////////////////////// } else { // Geller - parH[i]->distX = ((real)getDistX().at(i) + 0.25f) * parH[i - 1]->dx; - parH[i]->distY = ((real)getDistY().at(i) + 0.25f) * parH[i - 1]->dx; - parH[i]->distZ = ((real)getDistZ().at(i) + 0.25f) * parH[i - 1]->dx; + parH[i]->distX = ((real)getDistX().at(i) + (real)0.25) * parH[i - 1]->dx; + parH[i]->distY = ((real)getDistY().at(i) + (real)0.25) * parH[i - 1]->dx; + parH[i]->distZ = ((real)getDistZ().at(i) + (real)0.25) * parH[i - 1]->dx; // parH[i]->distX = ((real)getDistX().at(i) + 0.25f) * parH[i-1]->dx + parH[i-1]->distX; // parH[i]->distY = ((real)getDistY().at(i) + 0.25f) * parH[i-1]->dx + parH[i-1]->distY; // parH[i]->distZ = ((real)getDistZ().at(i) + 0.25f) * parH[i-1]->dx + parH[i-1]->distZ; @@ -561,7 +557,7 @@ void Parameter::initLBMSimulationParameter() parD[i]->gridNX = parH[i]->gridNX; parD[i]->gridNY = parH[i]->gridNY; parD[i]->gridNZ = parH[i]->gridNZ; - parD[i]->vis = parH[i]->vis; + parD[i]->viscosity = parH[i]->viscosity; parD[i]->diffusivity = parH[i]->diffusivity; parD[i]->omega = parH[i]->omega; parD[i]->nx = parH[i]->nx; @@ -598,7 +594,7 @@ void Parameter::checkParameterValidityCumulantK17() const if (this->mainKernel != "CumulantK17") return; - const real viscosity = this->parH[maxlevel]->vis; + const real viscosity = this->parH[maxlevel]->viscosity; const real viscosityLimit = 1.0 / 42.0; if (viscosity > viscosityLimit) { VF_LOG_WARNING("The viscosity (in LB units) at level {} is {:1.3g}. It is recommended to keep it smaller than {:1.3g} " @@ -606,7 +602,7 @@ void Parameter::checkParameterValidityCumulantK17() const maxlevel, viscosity, viscosityLimit); } - const real velocity = this->ic.u0; + const real velocity = this->u0; const real velocityLimit = 0.1; if (velocity > velocityLimit) { VF_LOG_WARNING("The velocity (in LB units) is {:1.4g}. It is recommended to keep it smaller than {:1.4g} for the " @@ -717,15 +713,15 @@ void Parameter::setEndXHotWall(real endXHotWall) } void Parameter::setTimestepEnd(unsigned int tend) { - ic.tend = tend; + this->tend = tend; } void Parameter::setTimestepOut(unsigned int tout) { - ic.tout = tout; + this->tout = tout; } void Parameter::setTimestepStartOut(unsigned int tStartOut) { - ic.tStartOut = tStartOut; + this->tStartOut = tStartOut; } void Parameter::setTimestepOfCoarseLevel(unsigned int timestep) { @@ -737,7 +733,7 @@ void Parameter::setCalcTurbulenceIntensity(bool calcVelocityAndFluctuations) } void Parameter::setCalcMedian(bool calcMedian) { - ic.calcMedian = calcMedian; + this->calcMedian = calcMedian; } void Parameter::setCalcDragLift(bool calcDragLift) { @@ -757,11 +753,11 @@ void Parameter::setCalcPlaneConc(bool calcPlaneConc) } void Parameter::setTimeCalcMedStart(int CalcMedStart) { - ic.tCalcMedStart = CalcMedStart; + this->tCalcMedStart = CalcMedStart; } void Parameter::setTimeCalcMedEnd(int CalcMedEnd) { - ic.tCalcMedEnd = CalcMedEnd; + this->tCalcMedEnd = CalcMedEnd; } void Parameter::setOutputPath(std::string oPath) { @@ -769,82 +765,82 @@ void Parameter::setOutputPath(std::string oPath) if (oPath.back() != '/') oPath += "/"; - ic.oPath = oPath; + this->oPath = oPath; this->setPathAndFilename(this->getOutputPath() + this->getOutputPrefix()); } void Parameter::setOutputPrefix(std::string oPrefix) { - ic.oPrefix = oPrefix; + this->oPrefix = oPrefix; this->setPathAndFilename(this->getOutputPath() + this->getOutputPrefix()); } void Parameter::setPathAndFilename(std::string fname) { - ic.fname = fname; + this->fname = fname; } void Parameter::setGridPath(std::string gridPath) { - ic.gridPath = gridPath; + this->gridPath = gridPath; this->initGridPaths(); } void Parameter::setPrintFiles(bool printfiles) { - ic.printFiles = printfiles; + this->printFiles = printfiles; } void Parameter::setReadGeo(bool readGeo) { - ic.readGeo = readGeo; + this->readGeo = readGeo; } void Parameter::setDiffusivity(real Diffusivity) { - ic.Diffusivity = Diffusivity; + this->Diffusivity = Diffusivity; } void Parameter::setTemperatureInit(real Temp) { - ic.Temp = Temp; + this->Temp = Temp; } void Parameter::setTemperatureBC(real TempBC) { - ic.TempBC = TempBC; + this->TempBC = TempBC; } void Parameter::setViscosityLB(real Viscosity) { - ic.vis = Viscosity; + this->vis = Viscosity; } void Parameter::setVelocityLB(real Velocity) { - ic.u0 = Velocity; + this->u0 = Velocity; } void Parameter::setViscosityRatio(real ViscosityRatio) { - ic.vis_ratio = ViscosityRatio; + this->vis_ratio = ViscosityRatio; } void Parameter::setVelocityRatio(real VelocityRatio) { - ic.u0_ratio = VelocityRatio; + this->u0_ratio = VelocityRatio; } void Parameter::setDensityRatio(real DensityRatio) { - ic.delta_rho = DensityRatio; + this->delta_rho = DensityRatio; } void Parameter::setPressRatio(real PressRatio) { - ic.delta_press = PressRatio; + this->delta_press = PressRatio; } real Parameter::getViscosityRatio() { - return ic.vis_ratio; + return this->vis_ratio; } real Parameter::getVelocityRatio() { - return ic.u0_ratio; + return this->u0_ratio; } real Parameter::getDensityRatio() { - return ic.delta_rho; + return this->delta_rho; } real Parameter::getPressureRatio() { - return ic.delta_press; + return this->delta_press; } real Parameter::getTimeRatio() { @@ -892,133 +888,129 @@ real Parameter::getScaledStressRatio(int level) } void Parameter::setRealX(real RealX) { - ic.RealX = RealX; + this->RealX = RealX; } void Parameter::setRealY(real RealY) { - ic.RealY = RealY; + this->RealY = RealY; } void Parameter::setPressInID(unsigned int PressInID) { - ic.PressInID = PressInID; + this->PressInID = PressInID; } void Parameter::setPressOutID(unsigned int PressOutID) { - ic.PressOutID = PressOutID; + this->PressOutID = PressOutID; } void Parameter::setPressInZ(unsigned int PressInZ) { - ic.PressInZ = PressInZ; + this->PressInZ = PressInZ; } void Parameter::setPressOutZ(unsigned int PressOutZ) { - ic.PressOutZ = PressOutZ; + this->PressOutZ = PressOutZ; } void Parameter::setOutflowPressureCorrectionFactor(real pressBCrhoCorrectionFactor) { - ic.outflowPressureCorrectionFactor = pressBCrhoCorrectionFactor; + this->outflowPressureCorrectionFactor = pressBCrhoCorrectionFactor; } void Parameter::setMaxDev(int maxdev) { - ic.maxdev = maxdev; + this->maxdev = maxdev; } void Parameter::setMyID(int myid) { - ic.myProcessId = myid; + this->myProcessId = myid; } void Parameter::setNumprocs(int numprocs) { - ic.numprocs = numprocs; + this->numprocs = numprocs; } void Parameter::setDevices(std::vector<uint> devices) { - ic.devices = devices; + this->devices = devices; } void Parameter::setGeometryFileC(std::string GeometryFileC) { - ic.geometryFileC = GeometryFileC; + this->geometryFileC = GeometryFileC; } void Parameter::setGeometryFileM(std::string GeometryFileM) { - ic.geometryFileM = GeometryFileM; + this->geometryFileM = GeometryFileM; } void Parameter::setGeometryFileF(std::string GeometryFileF) { - ic.geometryFileF = GeometryFileF; + this->geometryFileF = GeometryFileF; } void Parameter::setRe(real Re) { - ic.Re = Re; + this->Re = Re; } void Parameter::setFactorPressBC(real factorPressBC) { - ic.factorPressBC = factorPressBC; + this->factorPressBC = factorPressBC; } void Parameter::setIsGeo(bool isGeo) { - ic.isGeo = isGeo; + this->isGeo = isGeo; } void Parameter::setIsGeoNormal(bool isGeoNormal) { - ic.isGeoNormal = isGeoNormal; + this->isGeoNormal = isGeoNormal; } void Parameter::setIsInflowNormal(bool isInflowNormal) { - ic.isInflowNormal = isInflowNormal; + this->isInflowNormal = isInflowNormal; } void Parameter::setIsOutflowNormal(bool isOutflowNormal) { - ic.isOutflowNormal = isOutflowNormal; + this->isOutflowNormal = isOutflowNormal; } void Parameter::setIsProp(bool isProp) { - ic.isProp = isProp; + this->isProp = isProp; } void Parameter::setIsCp(bool isCp) { - ic.isCp = isCp; + this->isCp = isCp; } void Parameter::setConcFile(bool concFile) { - ic.isConc = concFile; -} -void Parameter::setStreetVelocityFile(bool streetVelocityFile) -{ - ic.streetVelocityFile = streetVelocityFile; + this->isConc = concFile; } void Parameter::setUseMeasurePoints(bool useMeasurePoints) { - ic.isMeasurePoints = useMeasurePoints; + this->isMeasurePoints = useMeasurePoints; } void Parameter::setUseInitNeq(bool useInitNeq) { - ic.isInitNeq = useInitNeq; + this->isInitNeq = useInitNeq; } void Parameter::setSimulatePorousMedia(bool simulatePorousMedia) { - ic.simulatePorousMedia = simulatePorousMedia; + this->simulatePorousMedia = simulatePorousMedia; } void Parameter::setUseTurbulentViscosity(bool useTurbulentViscosity) { - ic.isTurbulentViscosity = useTurbulentViscosity; + this->isTurbulentViscosity = useTurbulentViscosity; } void Parameter::setUseWale(bool useWale) { - ic.isWale = useWale; + this->isWale = useWale; if (useWale) setUseTurbulentViscosity(true); } void Parameter::setTurbulenceModel(TurbulenceModel turbulenceModel) { - ic.turbulenceModel = turbulenceModel; + this->turbulenceModel = turbulenceModel; } void Parameter::setSGSConstant(real SGSConstant) { - ic.SGSConstant = SGSConstant; + this->SGSConstant = SGSConstant; } void Parameter::setHasWallModelMonitor(bool hasWallModelMonitor) { - ic.hasWallModelMonitor = hasWallModelMonitor; + this->hasWallModelMonitor = hasWallModelMonitor; } void Parameter::setIsF3(bool isF3) @@ -1033,59 +1025,59 @@ void Parameter::setIsBodyForce(bool isBodyForce) void Parameter::setGridX(std::vector<int> GridX) { - ic.GridX = GridX; + this->GridX = GridX; } void Parameter::setGridY(std::vector<int> GridY) { - ic.GridY = GridY; + this->GridY = GridY; } void Parameter::setGridZ(std::vector<int> GridZ) { - ic.GridZ = GridZ; + this->GridZ = GridZ; } void Parameter::setDistX(std::vector<int> DistX) { - ic.DistX = DistX; + this->DistX = DistX; } void Parameter::setDistY(std::vector<int> DistY) { - ic.DistY = DistY; + this->DistY = DistY; } void Parameter::setDistZ(std::vector<int> DistZ) { - ic.DistZ = DistZ; + this->DistZ = DistZ; } void Parameter::setScaleLBMtoSI(std::vector<real> scaleLBMtoSI) { - ic.scaleLBMtoSI = scaleLBMtoSI; + this->scaleLBMtoSI = scaleLBMtoSI; } void Parameter::setTranslateLBMtoSI(std::vector<real> translateLBMtoSI) { - ic.translateLBMtoSI = translateLBMtoSI; + this->translateLBMtoSI = translateLBMtoSI; } void Parameter::setMinCoordX(std::vector<real> MinCoordX) { - ic.minCoordX = MinCoordX; + this->minCoordX = MinCoordX; } void Parameter::setMinCoordY(std::vector<real> MinCoordY) { - ic.minCoordY = MinCoordY; + this->minCoordY = MinCoordY; } void Parameter::setMinCoordZ(std::vector<real> MinCoordZ) { - ic.minCoordZ = MinCoordZ; + this->minCoordZ = MinCoordZ; } void Parameter::setMaxCoordX(std::vector<real> MaxCoordX) { - ic.maxCoordX = MaxCoordX; + this->maxCoordX = MaxCoordX; } void Parameter::setMaxCoordY(std::vector<real> MaxCoordY) { - ic.maxCoordY = MaxCoordY; + this->maxCoordY = MaxCoordY; } void Parameter::setMaxCoordZ(std::vector<real> MaxCoordZ) { - ic.maxCoordZ = MaxCoordZ; + this->maxCoordZ = MaxCoordZ; } void Parameter::setTempH(TempforBoundaryConditions *TempH) { @@ -1129,259 +1121,255 @@ void Parameter::setTempPressD(TempPressforBoundaryConditions *TempPressD) //} void Parameter::setkFull(std::string kFull) { - ic.kFull = kFull; + this->kFull = kFull; } void Parameter::setgeoFull(std::string geoFull) { - ic.geoFull = geoFull; + this->geoFull = geoFull; } void Parameter::setgeoVec(std::string geoVec) { - ic.geoVec = geoVec; + this->geoVec = geoVec; } void Parameter::setcoordX(std::string coordX) { - ic.coordX = coordX; + this->coordX = coordX; } void Parameter::setcoordY(std::string coordY) { - ic.coordY = coordY; + this->coordY = coordY; } void Parameter::setcoordZ(std::string coordZ) { - ic.coordZ = coordZ; + this->coordZ = coordZ; } void Parameter::setneighborX(std::string neighborX) { - ic.neighborX = neighborX; + this->neighborX = neighborX; } void Parameter::setneighborY(std::string neighborY) { - ic.neighborY = neighborY; + this->neighborY = neighborY; } void Parameter::setneighborZ(std::string neighborZ) { - ic.neighborZ = neighborZ; + this->neighborZ = neighborZ; } void Parameter::setneighborWSB(std::string neighborWSB) { - ic.neighborWSB = neighborWSB; + this->neighborWSB = neighborWSB; } void Parameter::setscaleCFC(std::string scaleCFC) { - ic.scaleCFC = scaleCFC; + this->scaleCFC = scaleCFC; } void Parameter::setscaleCFF(std::string scaleCFF) { - ic.scaleCFF = scaleCFF; + this->scaleCFF = scaleCFF; } void Parameter::setscaleFCC(std::string scaleFCC) { - ic.scaleFCC = scaleFCC; + this->scaleFCC = scaleFCC; } void Parameter::setscaleFCF(std::string scaleFCF) { - ic.scaleFCF = scaleFCF; + this->scaleFCF = scaleFCF; } void Parameter::setscaleOffsetCF(std::string scaleOffsetCF) { - ic.scaleOffsetCF = scaleOffsetCF; + this->scaleOffsetCF = scaleOffsetCF; } void Parameter::setscaleOffsetFC(std::string scaleOffsetFC) { - ic.scaleOffsetFC = scaleOffsetFC; + this->scaleOffsetFC = scaleOffsetFC; } void Parameter::setgeomBoundaryBcQs(std::string geomBoundaryBcQs) { - ic.geomBoundaryBcQs = geomBoundaryBcQs; + this->geomBoundaryBcQs = geomBoundaryBcQs; } void Parameter::setgeomBoundaryBcValues(std::string geomBoundaryBcValues) { - ic.geomBoundaryBcValues = geomBoundaryBcValues; + this->geomBoundaryBcValues = geomBoundaryBcValues; } void Parameter::setnoSlipBcPos(std::string noSlipBcPos) { - ic.noSlipBcPos = noSlipBcPos; + this->noSlipBcPos = noSlipBcPos; } void Parameter::setnoSlipBcQs(std::string noSlipBcQs) { - ic.noSlipBcQs = noSlipBcQs; + this->noSlipBcQs = noSlipBcQs; } void Parameter::setnoSlipBcValue(std::string noSlipBcValue) { - ic.noSlipBcValue = noSlipBcValue; + this->noSlipBcValue = noSlipBcValue; } void Parameter::setnoSlipBcValues(std::string noSlipBcValues) { - ic.noSlipBcValues = noSlipBcValues; + this->noSlipBcValues = noSlipBcValues; } void Parameter::setslipBcPos(std::string slipBcPos) { - ic.slipBcPos = slipBcPos; + this->slipBcPos = slipBcPos; } void Parameter::setslipBcQs(std::string slipBcQs) { - ic.slipBcQs = slipBcQs; + this->slipBcQs = slipBcQs; } void Parameter::setslipBcValue(std::string slipBcValue) { - ic.slipBcValue = slipBcValue; + this->slipBcValue = slipBcValue; } void Parameter::setpressBcPos(std::string pressBcPos) { - ic.pressBcPos = pressBcPos; + this->pressBcPos = pressBcPos; } void Parameter::setpressBcQs(std::string pressBcQs) { - ic.pressBcQs = pressBcQs; + this->pressBcQs = pressBcQs; } void Parameter::setpressBcValue(std::string pressBcValue) { - ic.pressBcValue = pressBcValue; + this->pressBcValue = pressBcValue; } void Parameter::setpressBcValues(std::string pressBcValues) { - ic.pressBcValues = pressBcValues; + this->pressBcValues = pressBcValues; } void Parameter::setvelBcQs(std::string velBcQs) { - ic.velBcQs = velBcQs; + this->velBcQs = velBcQs; } void Parameter::setvelBcValues(std::string velBcValues) { - ic.velBcValues = velBcValues; + this->velBcValues = velBcValues; } void Parameter::setinletBcQs(std::string inletBcQs) { - ic.inletBcQs = inletBcQs; + this->inletBcQs = inletBcQs; } void Parameter::setinletBcValues(std::string inletBcValues) { - ic.inletBcValues = inletBcValues; + this->inletBcValues = inletBcValues; } void Parameter::setoutletBcQs(std::string outletBcQs) { - ic.outletBcQs = outletBcQs; + this->outletBcQs = outletBcQs; } void Parameter::setoutletBcValues(std::string outletBcValues) { - ic.outletBcValues = outletBcValues; + this->outletBcValues = outletBcValues; } void Parameter::settopBcQs(std::string topBcQs) { - ic.topBcQs = topBcQs; + this->topBcQs = topBcQs; } void Parameter::settopBcValues(std::string topBcValues) { - ic.topBcValues = topBcValues; + this->topBcValues = topBcValues; } void Parameter::setbottomBcQs(std::string bottomBcQs) { - ic.bottomBcQs = bottomBcQs; + this->bottomBcQs = bottomBcQs; } void Parameter::setbottomBcValues(std::string bottomBcValues) { - ic.bottomBcValues = bottomBcValues; + this->bottomBcValues = bottomBcValues; } void Parameter::setfrontBcQs(std::string frontBcQs) { - ic.frontBcQs = frontBcQs; + this->frontBcQs = frontBcQs; } void Parameter::setfrontBcValues(std::string frontBcValues) { - ic.frontBcValues = frontBcValues; + this->frontBcValues = frontBcValues; } void Parameter::setbackBcQs(std::string backBcQs) { - ic.backBcQs = backBcQs; + this->backBcQs = backBcQs; } void Parameter::setbackBcValues(std::string backBcValues) { - ic.backBcValues = backBcValues; + this->backBcValues = backBcValues; } void Parameter::setwallBcQs(std::string wallBcQs) { - ic.wallBcQs = wallBcQs; + this->wallBcQs = wallBcQs; } void Parameter::setwallBcValues(std::string wallBcValues) { - ic.wallBcValues = wallBcValues; + this->wallBcValues = wallBcValues; } void Parameter::setperiodicBcQs(std::string periodicBcQs) { - ic.periodicBcQs = periodicBcQs; + this->periodicBcQs = periodicBcQs; } void Parameter::setperiodicBcValues(std::string periodicBcValues) { - ic.periodicBcValues = periodicBcValues; + this->periodicBcValues = periodicBcValues; } void Parameter::setpropellerQs(std::string propellerQs) { - ic.propellerQs = propellerQs; + this->propellerQs = propellerQs; } void Parameter::setpropellerValues(std::string propellerValues) { - ic.propellerValues = propellerValues; + this->propellerValues = propellerValues; } void Parameter::setpropellerCylinder(std::string propellerCylinder) { - ic.propellerCylinder = propellerCylinder; + this->propellerCylinder = propellerCylinder; } void Parameter::setmeasurePoints(std::string measurePoints) { - ic.measurePoints = measurePoints; + this->measurePoints = measurePoints; } void Parameter::setnumberNodes(std::string numberNodes) { - ic.numberNodes = numberNodes; + this->numberNodes = numberNodes; } void Parameter::setLBMvsSI(std::string LBMvsSI) { - ic.LBMvsSI = LBMvsSI; + this->LBMvsSI = LBMvsSI; } void Parameter::setcpTop(std::string cpTop) { - ic.cpTop = cpTop; + this->cpTop = cpTop; } void Parameter::setcpBottom(std::string cpBottom) { - ic.cpBottom = cpBottom; + this->cpBottom = cpBottom; } void Parameter::setcpBottom2(std::string cpBottom2) { - ic.cpBottom2 = cpBottom2; + this->cpBottom2 = cpBottom2; } void Parameter::setConcentration(std::string concFile) { - ic.concentration = concFile; -} -void Parameter::setStreetVelocity(std::string streetVelocity) -{ - ic.streetVelocity = streetVelocity; + this->concentration = concFile; } void Parameter::setclockCycleForMP(real clockCycleForMP) { - ic.clockCycleForMP = clockCycleForMP; + this->clockCycleForMP = clockCycleForMP; } void Parameter::setTimeDoCheckPoint(unsigned int tDoCheckPoint) { - ic.tDoCheckPoint = tDoCheckPoint; + this->tDoCheckPoint = tDoCheckPoint; } void Parameter::setTimeDoRestart(unsigned int tDoRestart) { - ic.tDoRestart = tDoRestart; + this->tDoRestart = tDoRestart; } void Parameter::setDoCheckPoint(bool doCheckPoint) { - ic.doCheckPoint = doCheckPoint; + this->doCheckPoint = doCheckPoint; } void Parameter::setDoRestart(bool doRestart) { - ic.doRestart = doRestart; + this->doRestart = doRestart; } void Parameter::settimestepForMP(unsigned int timestepForMP) { - ic.timeStepForMP = timestepForMP; + this->timeStepForMP = timestepForMP; } void Parameter::setObj(std::string str, bool isObj) { @@ -1401,19 +1389,19 @@ void Parameter::setObj(std::string str, bool isObj) } void Parameter::setUseGeometryValues(bool useGeometryValues) { - ic.GeometryValues = useGeometryValues; + this->GeometryValues = useGeometryValues; } void Parameter::setCalc2ndOrderMoments(bool is2ndOrderMoments) { - ic.is2ndOrderMoments = is2ndOrderMoments; + this->is2ndOrderMoments = is2ndOrderMoments; } void Parameter::setCalc3rdOrderMoments(bool is3rdOrderMoments) { - ic.is3rdOrderMoments = is3rdOrderMoments; + this->is3rdOrderMoments = is3rdOrderMoments; } void Parameter::setCalcHighOrderMoments(bool isHighOrderMoments) { - ic.isHighOrderMoments = isHighOrderMoments; + this->isHighOrderMoments = isHighOrderMoments; } void Parameter::setMemsizeGPU(double admem, bool reset) { @@ -1605,39 +1593,39 @@ void Parameter::setRecvProcessNeighborsAfterFtoCZ(int numberOfNodes, int level, } void Parameter::setgeomBoundaryNormalX(std::string geomNormalX) { - ic.geomNormalX = geomNormalX; + this->geomNormalX = geomNormalX; } void Parameter::setgeomBoundaryNormalY(std::string geomNormalY) { - ic.geomNormalY = geomNormalY; + this->geomNormalY = geomNormalY; } void Parameter::setgeomBoundaryNormalZ(std::string geomNormalZ) { - ic.geomNormalZ = geomNormalZ; + this->geomNormalZ = geomNormalZ; } void Parameter::setInflowBoundaryNormalX(std::string inflowNormalX) { - ic.inflowNormalX = inflowNormalX; + this->inflowNormalX = inflowNormalX; } void Parameter::setInflowBoundaryNormalY(std::string inflowNormalY) { - ic.inflowNormalY = inflowNormalY; + this->inflowNormalY = inflowNormalY; } void Parameter::setInflowBoundaryNormalZ(std::string inflowNormalZ) { - ic.inflowNormalZ = inflowNormalZ; + this->inflowNormalZ = inflowNormalZ; } void Parameter::setOutflowBoundaryNormalX(std::string outflowNormalX) { - ic.outflowNormalX = outflowNormalX; + this->outflowNormalX = outflowNormalX; } void Parameter::setOutflowBoundaryNormalY(std::string outflowNormalY) { - ic.outflowNormalY = outflowNormalY; + this->outflowNormalY = outflowNormalY; } void Parameter::setOutflowBoundaryNormalZ(std::string outflowNormalZ) { - ic.outflowNormalZ = outflowNormalZ; + this->outflowNormalZ = outflowNormalZ; } void Parameter::setMainKernel(std::string kernel) { @@ -1837,19 +1825,19 @@ unsigned int Parameter::getTimestepInit() } unsigned int Parameter::getTimestepEnd() { - return ic.tend; + return this->tend; } unsigned int Parameter::getTimestepOut() { - return ic.tout; + return this->tout; } unsigned int Parameter::getTimestepStartOut() { - return ic.tStartOut; + return this->tStartOut; } bool Parameter::getCalcMedian() { - return ic.calcMedian; + return this->calcMedian; } bool Parameter::getCalcDragLift() { @@ -1873,35 +1861,35 @@ bool Parameter::getCalcPlaneConc() } int Parameter::getTimeCalcMedStart() { - return ic.tCalcMedStart; + return this->tCalcMedStart; } int Parameter::getTimeCalcMedEnd() { - return ic.tCalcMedEnd; + return this->tCalcMedEnd; } std::string Parameter::getOutputPath() { - return ic.oPath; + return this->oPath; } std::string Parameter::getOutputPrefix() { - return ic.oPrefix; + return this->oPrefix; } std::string Parameter::getFName() { - return ic.fname; + return this->fname; } std::string Parameter::getGridPath() { - return ic.gridPath; + return this->gridPath; } bool Parameter::getPrintFiles() { - return ic.printFiles; + return this->printFiles; } bool Parameter::getReadGeo() { - return ic.readGeo; + return this->readGeo; } bool Parameter::getCalcTurbulenceIntensity() { @@ -1909,143 +1897,143 @@ bool Parameter::getCalcTurbulenceIntensity() } real Parameter::getDiffusivity() { - return ic.Diffusivity; + return this->Diffusivity; } real Parameter::getTemperatureInit() { - return ic.Temp; + return this->Temp; } real Parameter::getTemperatureBC() { - return ic.TempBC; + return this->TempBC; } real Parameter::getViscosity() { - return ic.vis; + return this->vis; } real Parameter::getVelocity() { - return ic.u0; + return this->u0; } real Parameter::getRealX() { - return ic.RealX; + return this->RealX; } real Parameter::getRealY() { - return ic.RealY; + return this->RealY; } unsigned int Parameter::getPressInID() { - return ic.PressInID; + return this->PressInID; } unsigned int Parameter::getPressOutID() { - return ic.PressOutID; + return this->PressOutID; } unsigned int Parameter::getPressInZ() { - return ic.PressInZ; + return this->PressInZ; } unsigned int Parameter::getPressOutZ() { - return ic.PressOutZ; + return this->PressOutZ; } real Parameter::getOutflowPressureCorrectionFactor() { - return ic.outflowPressureCorrectionFactor; + return this->outflowPressureCorrectionFactor; } int Parameter::getMaxDev() { - return ic.maxdev; + return this->maxdev; } int Parameter::getMyProcessID() { - return ic.myProcessId; + return this->myProcessId; } int Parameter::getNumprocs() { - return ic.numprocs; + return this->numprocs; } std::vector<uint> Parameter::getDevices() { - return ic.devices; + return this->devices; } std::string Parameter::getGeometryFileC() { - return ic.geometryFileC; + return this->geometryFileC; } std::string Parameter::getGeometryFileM() { - return ic.geometryFileM; + return this->geometryFileM; } std::string Parameter::getGeometryFileF() { - return ic.geometryFileF; + return this->geometryFileF; } real Parameter::getRe() { - return ic.Re; + return this->Re; } real Parameter::getFactorPressBC() { - return ic.factorPressBC; + return this->factorPressBC; } std::vector<int> Parameter::getGridX() { - return ic.GridX; + return this->GridX; } std::vector<int> Parameter::getGridY() { - return ic.GridY; + return this->GridY; } std::vector<int> Parameter::getGridZ() { - return ic.GridZ; + return this->GridZ; } std::vector<int> Parameter::getDistX() { - return ic.DistX; + return this->DistX; } std::vector<int> Parameter::getDistY() { - return ic.DistY; + return this->DistY; } std::vector<int> Parameter::getDistZ() { - return ic.DistZ; + return this->DistZ; } std::vector<real> Parameter::getScaleLBMtoSI() { - return ic.scaleLBMtoSI; + return this->scaleLBMtoSI; } std::vector<real> Parameter::getTranslateLBMtoSI() { - return ic.translateLBMtoSI; + return this->translateLBMtoSI; } std::vector<real> Parameter::getMinCoordX() { - return ic.minCoordX; + return this->minCoordX; } std::vector<real> Parameter::getMinCoordY() { - return ic.minCoordY; + return this->minCoordY; } std::vector<real> Parameter::getMinCoordZ() { - return ic.minCoordZ; + return this->minCoordZ; } std::vector<real> Parameter::getMaxCoordX() { - return ic.maxCoordX; + return this->maxCoordX; } std::vector<real> Parameter::getMaxCoordY() { - return ic.maxCoordY; + return this->maxCoordY; } std::vector<real> Parameter::getMaxCoordZ() { - return ic.maxCoordZ; + return this->maxCoordZ; } TempforBoundaryConditions *Parameter::getTempH() { @@ -2089,247 +2077,243 @@ TempPressforBoundaryConditions *Parameter::getTempPressD() //} std::string Parameter::getkFull() { - return ic.kFull; + return this->kFull; } std::string Parameter::getgeoFull() { - return ic.geoFull; + return this->geoFull; } std::string Parameter::getgeoVec() { - return ic.geoVec; + return this->geoVec; } std::string Parameter::getcoordX() { - return ic.coordX; + return this->coordX; } std::string Parameter::getcoordY() { - return ic.coordY; + return this->coordY; } std::string Parameter::getcoordZ() { - return ic.coordZ; + return this->coordZ; } std::string Parameter::getneighborX() { - return ic.neighborX; + return this->neighborX; } std::string Parameter::getneighborY() { - return ic.neighborY; + return this->neighborY; } std::string Parameter::getneighborZ() { - return ic.neighborZ; + return this->neighborZ; } std::string Parameter::getneighborWSB() { - return ic.neighborWSB; + return this->neighborWSB; } std::string Parameter::getscaleCFC() { - return ic.scaleCFC; + return this->scaleCFC; } std::string Parameter::getscaleCFF() { - return ic.scaleCFF; + return this->scaleCFF; } std::string Parameter::getscaleFCC() { - return ic.scaleFCC; + return this->scaleFCC; } std::string Parameter::getscaleFCF() { - return ic.scaleFCF; + return this->scaleFCF; } std::string Parameter::getscaleOffsetCF() { - return ic.scaleOffsetCF; + return this->scaleOffsetCF; } std::string Parameter::getscaleOffsetFC() { - return ic.scaleOffsetFC; + return this->scaleOffsetFC; } std::string Parameter::getgeomBoundaryBcQs() { - return ic.geomBoundaryBcQs; + return this->geomBoundaryBcQs; } std::string Parameter::getgeomBoundaryBcValues() { - return ic.geomBoundaryBcValues; + return this->geomBoundaryBcValues; } std::string Parameter::getnoSlipBcPos() { - return ic.noSlipBcPos; + return this->noSlipBcPos; } std::string Parameter::getnoSlipBcQs() { - return ic.noSlipBcQs; + return this->noSlipBcQs; } std::string Parameter::getnoSlipBcValue() { - return ic.noSlipBcValue; + return this->noSlipBcValue; } std::string Parameter::getnoSlipBcValues() { - return ic.noSlipBcValues; + return this->noSlipBcValues; } std::string Parameter::getslipBcPos() { - return ic.slipBcPos; + return this->slipBcPos; } std::string Parameter::getslipBcQs() { - return ic.slipBcQs; + return this->slipBcQs; } std::string Parameter::getslipBcValue() { - return ic.slipBcValue; + return this->slipBcValue; } std::string Parameter::getpressBcPos() { - return ic.pressBcPos; + return this->pressBcPos; } std::string Parameter::getpressBcQs() { - return ic.pressBcQs; + return this->pressBcQs; } std::string Parameter::getpressBcValue() { - return ic.pressBcValue; + return this->pressBcValue; } std::string Parameter::getpressBcValues() { - return ic.pressBcValues; + return this->pressBcValues; } std::string Parameter::getvelBcQs() { - return ic.velBcQs; + return this->velBcQs; } std::string Parameter::getvelBcValues() { - return ic.velBcValues; + return this->velBcValues; } std::string Parameter::getinletBcQs() { - return ic.inletBcQs; + return this->inletBcQs; } std::string Parameter::getinletBcValues() { - return ic.inletBcValues; + return this->inletBcValues; } std::string Parameter::getoutletBcQs() { - return ic.outletBcQs; + return this->outletBcQs; } std::string Parameter::getoutletBcValues() { - return ic.outletBcValues; + return this->outletBcValues; } std::string Parameter::gettopBcQs() { - return ic.topBcQs; + return this->topBcQs; } std::string Parameter::gettopBcValues() { - return ic.topBcValues; + return this->topBcValues; } std::string Parameter::getbottomBcQs() { - return ic.bottomBcQs; + return this->bottomBcQs; } std::string Parameter::getbottomBcValues() { - return ic.bottomBcValues; + return this->bottomBcValues; } std::string Parameter::getfrontBcQs() { - return ic.frontBcQs; + return this->frontBcQs; } std::string Parameter::getfrontBcValues() { - return ic.frontBcValues; + return this->frontBcValues; } std::string Parameter::getbackBcQs() { - return ic.backBcQs; + return this->backBcQs; } std::string Parameter::getbackBcValues() { - return ic.backBcValues; + return this->backBcValues; } std::string Parameter::getwallBcQs() { - return ic.wallBcQs; + return this->wallBcQs; } std::string Parameter::getwallBcValues() { - return ic.wallBcValues; + return this->wallBcValues; } std::string Parameter::getperiodicBcQs() { - return ic.periodicBcQs; + return this->periodicBcQs; } std::string Parameter::getperiodicBcValues() { - return ic.periodicBcValues; + return this->periodicBcValues; } std::string Parameter::getpropellerQs() { - return ic.propellerQs; + return this->propellerQs; } std::string Parameter::getpropellerValues() { - return ic.propellerValues; + return this->propellerValues; } std::string Parameter::getpropellerCylinder() { - return ic.propellerCylinder; + return this->propellerCylinder; } std::string Parameter::getmeasurePoints() { - return ic.measurePoints; + return this->measurePoints; } std::string Parameter::getLBMvsSI() { - return ic.LBMvsSI; + return this->LBMvsSI; } std::string Parameter::getnumberNodes() { - return ic.numberNodes; + return this->numberNodes; } std::string Parameter::getcpTop() { - return ic.cpTop; + return this->cpTop; } std::string Parameter::getcpBottom() { - return ic.cpBottom; + return this->cpBottom; } std::string Parameter::getcpBottom2() { - return ic.cpBottom2; + return this->cpBottom2; } std::string Parameter::getConcentration() { - return ic.concentration; -} -std::string Parameter::getStreetVelocityFilePath() -{ - return ic.streetVelocity; + return this->concentration; } real Parameter::getclockCycleForMP() { - return ic.clockCycleForMP; + return this->clockCycleForMP; } unsigned int Parameter::getTimeDoCheckPoint() { - return ic.tDoCheckPoint; + return this->tDoCheckPoint; } unsigned int Parameter::getTimeDoRestart() { - return ic.tDoRestart; + return this->tDoRestart; } //======================================================================================= @@ -2353,63 +2337,59 @@ unsigned int Parameter::getTimeStep(int level, unsigned int t, bool isPostCollis bool Parameter::getDoCheckPoint() { - return ic.doCheckPoint; + return this->doCheckPoint; } bool Parameter::getDoRestart() { - return ic.doRestart; + return this->doRestart; } bool Parameter::getIsGeo() { - return ic.isGeo; + return this->isGeo; } bool Parameter::getIsGeoNormal() { - return ic.isGeoNormal; + return this->isGeoNormal; } bool Parameter::getIsInflowNormal() { - return ic.isInflowNormal; + return this->isInflowNormal; } bool Parameter::getIsOutflowNormal() { - return ic.isOutflowNormal; + return this->isOutflowNormal; } bool Parameter::getIsCp() { - return ic.isCp; + return this->isCp; } bool Parameter::getConcFile() { - return ic.isConc; -} -bool Parameter::isStreetVelocityFile() -{ - return ic.streetVelocityFile; + return this->isConc; } bool Parameter::getUseMeasurePoints() { - return ic.isMeasurePoints; + return this->isMeasurePoints; } bool Parameter::getUseWale() { - return ic.isWale; + return this->isWale; } TurbulenceModel Parameter::getTurbulenceModel() { - return ic.turbulenceModel; + return this->turbulenceModel; } bool Parameter::getUseTurbulentViscosity() { - return ic.isTurbulentViscosity; + return this->isTurbulentViscosity; } real Parameter::getSGSConstant() { - return ic.SGSConstant; + return this->SGSConstant; } bool Parameter::getHasWallModelMonitor() { - return ic.hasWallModelMonitor; + return this->hasWallModelMonitor; } std::vector<SPtr<PreCollisionInteractor>> Parameter::getActuators() { @@ -2421,11 +2401,11 @@ std::vector<SPtr<PreCollisionInteractor>> Parameter::getProbes() } bool Parameter::getUseInitNeq() { - return ic.isInitNeq; + return this->isInitNeq; } bool Parameter::getSimulatePorousMedia() { - return ic.simulatePorousMedia; + return this->simulatePorousMedia; } bool Parameter::getIsF3() @@ -2440,23 +2420,23 @@ bool Parameter::getIsBodyForce() bool Parameter::getIsGeometryValues() { - return ic.GeometryValues; + return this->GeometryValues; } bool Parameter::getCalc2ndOrderMoments() { - return ic.is2ndOrderMoments; + return this->is2ndOrderMoments; } bool Parameter::getCalc3rdOrderMoments() { - return ic.is3rdOrderMoments; + return this->is3rdOrderMoments; } bool Parameter::getCalcHighOrderMoments() { - return ic.isHighOrderMoments; + return this->isHighOrderMoments; } bool Parameter::getIsProp() { - return ic.isProp; + return this->isProp; } bool Parameter::overWritingRestart(uint t) { @@ -2464,7 +2444,7 @@ bool Parameter::overWritingRestart(uint t) } unsigned int Parameter::getTimestepForMP() { - return ic.timeStepForMP; + return this->timeStepForMP; } unsigned int Parameter::getTimestepOfCoarseLevel() { @@ -2567,39 +2547,39 @@ bool Parameter::getIsNeighborZ() } std::string Parameter::getgeomBoundaryNormalX() { - return ic.geomNormalX; + return this->geomNormalX; } std::string Parameter::getgeomBoundaryNormalY() { - return ic.geomNormalY; + return this->geomNormalY; } std::string Parameter::getgeomBoundaryNormalZ() { - return ic.geomNormalZ; + return this->geomNormalZ; } std::string Parameter::getInflowBoundaryNormalX() { - return ic.inflowNormalX; + return this->inflowNormalX; } std::string Parameter::getInflowBoundaryNormalY() { - return ic.inflowNormalY; + return this->inflowNormalY; } std::string Parameter::getInflowBoundaryNormalZ() { - return ic.inflowNormalZ; + return this->inflowNormalZ; } std::string Parameter::getOutflowBoundaryNormalX() { - return ic.outflowNormalX; + return this->outflowNormalX; } std::string Parameter::getOutflowBoundaryNormalY() { - return ic.outflowNormalY; + return this->outflowNormalY; } std::string Parameter::getOutflowBoundaryNormalZ() { - return ic.outflowNormalZ; + return this->outflowNormalZ; } curandState *Parameter::getRandomState() { diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h index fa45b1742f20e32258195c78b630ce95175af938..5944cf66caed4f680ff0480c7b7c39ff7d237aab 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h @@ -85,196 +85,176 @@ struct LBMSimulationParameter { real *velocityX, *velocityY, *velocityZ, *rho, *pressure; //! \brief stores the value for omega real omega; + //! \brief stores the value for viscosity + real viscosity; ////////////////////////////////////////////////////////////////////////// //! \brief stores the number of nodes (based on indirect addressing scheme) unsigned long long numberOfNodes; //! \brief stores the size of the memory consumption for real/int values of the arrays (e.g. coordinates, velocity) unsigned long long memSizeRealLBnodes, memSizeLonglongLBnodes; - - - - - - ////////////////////////////////////////////////////////////////////////// - // DEPRECATED + //! \brief stores the slip boundary condition data + QforBoundaryConditions slipBC; ////////////////////////////////////////////////////////////////////////// - - // distributions/////////// - // Distributions19 d0; - Distributions27 d0; // DEPRECATED: distribution functions for full matrix (not sparse) - - // typeOfGridNode (formerly known as "geo") ///////////////////// - int *geo; // DEPRECATED: typeOfGridNode for full matrix (not sparse) - - // k/////////////////////// - unsigned int *k; // DEPRECATED: index for full matrix - - // memsize///////////////// - //unsigned int mem_size_real_yz; - //unsigned int mem_size_bool; - //unsigned int mem_size_int; - //unsigned int mem_size_real; - + //! \brief stores the no slip boundary condition data + QforBoundaryConditions noSlipBC; ////////////////////////////////////////////////////////////////////////// - - - - - + //! \brief stores the velocity boundary condition data + QforBoundaryConditions velocityBC; ////////////////////////////////////////////////////////////////////////// - // additional logic + //! \brief stores the geometry boundary condition data + QforBoundaryConditions geometryBC; ////////////////////////////////////////////////////////////////////////// + //! \brief stores the pressure boundary condition data + QforBoundaryConditions pressureBC; + ////////////////////////////////////////////////////////////////////////// + //! \brief stores the outflow boundary condition data + QforBoundaryConditions outflowBC; + ////////////////////////////////////////////////////////////////////////// + //! \brief stores the stress boundary condition data + QforBoundaryConditions stressBC; + ////////////////////////////////////////////////////////////////////////// + //! \brief stores the precursor boundary condition data + QforPrecursorBoundaryConditions precursorBC; - // distributions F3//////// - Distributions6 g6; - - unsigned int size_Array_SP; - - - // memsizeSP///////////////// - - - ////////////////////////////////////////////////////////////////////////// + //! \brief sets a uniform forcing on each fluid node in all three spatial dimensions + real *forcing; + ////////////////////////////////////////////////////////////////////////// + //! \brief stores parameters for a wall model + WallModelParameters wallModel; + ////////////////////////////////////////////////////////////////////////// + //! \brief allows reading values for a boundary condition from a file + std::vector<SPtr<TransientBCInputFileReader>> transientBCInputFileReader; + ////////////////////////////////////////////////////////////////////////// + //! \brief can be used for pressure correction at outflow boundary condition + real outflowPressureCorrectionFactor; + ////////////////////////////////////////////////////////////////////////// + //! \brief store the values of body forces for all 3 dimensions + real *forceX_SP, *forceY_SP, *forceZ_SP; - // advection diffusion ////////////////// - //! \brief store all distribution functions for the D3Q7 advection diffusion field - Distributions7 distributionsAD7; - //! \brief store all distribution functions for the D3Q27 advection diffusion field - Distributions27 distributionsAD27; - //! \brief stores a field of concentration values - real *Conc, *Conc_Full; + ////////////////////////////////////////////////////////////////////////// + // Advection Diffusion + ////////////////////////////////////////////////////////////////////////// //! \brief stores the diffusivity real diffusivity; //! \brief stores the value for omega (for the diffusivity) real omegaDiffusivity; - // BC NoSlip - TempforBoundaryConditions Temp; - // BC Velocity - TempVelforBoundaryConditions TempVel; - // BC Pressure - TempPressforBoundaryConditions TempPress; - // Plane Conc - real *ConcPlaneIn, *ConcPlaneOut1, *ConcPlaneOut2; - std::vector<double> PlaneConcVectorIn, PlaneConcVectorOut1, PlaneConcVectorOut2; - - // trafo/////////////////// - real mTtoWx, mTtoWy, mTtoWz; - real cTtoWx, cTtoWy, cTtoWz; - - // MGstrafo//////////////// - real cStartx, cStarty, cStartz; - real cFx, cFy, cFz; - - - // body forces//////////// - real *forceX_SP, *forceY_SP, *forceZ_SP; - - // vel parab/////////////// - real *vParab; - - // turbulent viscosity /// - real *turbViscosity; - real *gSij, *gSDij, *gDxvx, *gDyvx, *gDzvx, *gDxvy, *gDyvy, *gDzvy, *gDxvz, *gDyvz, *gDzvz; // DebugInformation + //! \brief stores a field of concentration values + real *concentration; + //! \brief store all distribution functions for the D3Q27 advection diffusion field + Distributions27 distributionsAD; + ////////////////////////////////////////////////////////////////////////// - // turbulence intensity // - real *vx_mean, *vy_mean, *vz_mean; // means - real *vxx, *vyy, *vzz, *vxy, *vxz, *vyz; // fluctuations - std::vector<real> turbulenceIntensity; - // macroscopic values////// - // real *vx, *vy, *vz, *rho; // DEPRECATED: macroscopic values for full matrix - //! \brief stores the value for viscosity (on level 0) - real vis; + ////////////////////////////////////////////////////////////////////////// + // Grid Refinement + ////////////////////////////////////////////////////////////////////////// + //! \brief stores the base-node-indices of coarse and fine refinement cells + InterpolationCells coarseToFine; + InterpolationCells fineToCoarse; + ////////////////////////////////////////////////////////////////////////// + //! \brief distinguish between bulk and border interpolation cells (necessary for communication hiding) + InterpolationCells fineToCoarseBorder; + InterpolationCells fineToCoarseBulk; + InterpolationCells coarseToFineBorder; + InterpolationCells coarseToFineBulk; + ////////////////////////////////////////////////////////////////////////// + //! \brief stores location of neighboring cell (necessary for refinement into the wall) + InterpolationCellNeighbor neighborCoarseToFine; + InterpolationCellNeighbor neighborCoarseToFineBulk; + InterpolationCellNeighbor neighborFineToCoarse; + InterpolationCellNeighbor neighborFineToCoarseBulk; + ////////////////////////////////////////////////////////////////////////// - // derivations for iso test - real *dxxUx, *dyyUy, *dzzUz; - // median-macro-values///// - real *vx_SP_Med, *vy_SP_Med, *vz_SP_Med, *rho_SP_Med, *press_SP_Med; - real *vx_SP_Med_Out, *vy_SP_Med_Out, *vz_SP_Med_Out, *rho_SP_Med_Out, *press_SP_Med_Out; - // Advection-Diffusion - real *Conc_Med, *Conc_Med_Out; + ////////////////////////////////////////////////////////////////////////// + // Inter-GPU-Communication + ////////////////////////////////////////////////////////////////////////// + //! \brief stores the base-node-indices of coarse and fine refinement cells + // 3D domain decomposition + std::vector<ProcessNeighbor27> sendProcessNeighborX; + std::vector<ProcessNeighbor27> sendProcessNeighborY; + std::vector<ProcessNeighbor27> sendProcessNeighborZ; + std::vector<ProcessNeighbor27> recvProcessNeighborX; + std::vector<ProcessNeighbor27> recvProcessNeighborY; + std::vector<ProcessNeighbor27> recvProcessNeighborZ; - // grid//////////////////// - unsigned int nx, ny, nz; - unsigned int gridNX, gridNY, gridNZ; + std::vector<ProcessNeighbor27> sendProcessNeighborsAfterFtoCX; + std::vector<ProcessNeighbor27> sendProcessNeighborsAfterFtoCY; + std::vector<ProcessNeighbor27> sendProcessNeighborsAfterFtoCZ; + std::vector<ProcessNeighbor27> recvProcessNeighborsAfterFtoCX; + std::vector<ProcessNeighbor27> recvProcessNeighborsAfterFtoCY; + std::vector<ProcessNeighbor27> recvProcessNeighborsAfterFtoCZ; + /////////////////////////////////////////////////////// + // 3D domain decomposition convection diffusion + std::vector<ProcessNeighbor27> sendProcessNeighborADX; + std::vector<ProcessNeighbor27> sendProcessNeighborADY; + std::vector<ProcessNeighbor27> sendProcessNeighborADZ; + std::vector<ProcessNeighbor27> recvProcessNeighborADX; + std::vector<ProcessNeighbor27> recvProcessNeighborADY; + std::vector<ProcessNeighbor27> recvProcessNeighborADZ; + /////////////////////////////////////////////////////// + // 3D domain decomposition F3 + std::vector<ProcessNeighborF3> sendProcessNeighborF3X; + std::vector<ProcessNeighborF3> sendProcessNeighborF3Y; + std::vector<ProcessNeighborF3> sendProcessNeighborF3Z; + std::vector<ProcessNeighborF3> recvProcessNeighborF3X; + std::vector<ProcessNeighborF3> recvProcessNeighborF3Y; + std::vector<ProcessNeighborF3> recvProcessNeighborF3Z; + //////////////////////////////////////////////////////////////////////////// + // 3D domain decomposition: position (index in array) of corner nodes in ProcessNeighbor27 + struct EdgeNodePositions { + int indexOfProcessNeighborRecv; + int indexInRecvBuffer; + int indexOfProcessNeighborSend; + int indexInSendBuffer; + EdgeNodePositions(int indexOfProcessNeighborRecv, int indexInRecvBuffer, int indexOfProcessNeighborSend, + int indexInSendBuffer) + : indexOfProcessNeighborRecv(indexOfProcessNeighborRecv), indexInRecvBuffer(indexInRecvBuffer), + indexOfProcessNeighborSend(indexOfProcessNeighborSend), indexInSendBuffer(indexInSendBuffer) + { + } + }; + std::vector<EdgeNodePositions> edgeNodesXtoY; + std::vector<EdgeNodePositions> edgeNodesXtoZ; + std::vector<EdgeNodePositions> edgeNodesYtoZ; - // size of matrix////////// - unsigned int size_Mat; - unsigned int sizePlaneXY, sizePlaneYZ, sizePlaneXZ; + /////////////////////////////////////////////////////// + std::map<CollisionTemplate, uint*> taggedFluidNodeIndices = {{CollisionTemplate::Default, nullptr}, + {CollisionTemplate::SubDomainBorder,nullptr}, + {CollisionTemplate::WriteMacroVars, nullptr}, + {CollisionTemplate::ApplyBodyForce, nullptr}, + {CollisionTemplate::AllFeatures, nullptr}}; + std::map<CollisionTemplate, uint > numberOfTaggedFluidNodes = {{CollisionTemplate::Default, 0}, + {CollisionTemplate::SubDomainBorder,0}, + {CollisionTemplate::WriteMacroVars, 0}, + {CollisionTemplate::ApplyBodyForce, 0}, + {CollisionTemplate::AllFeatures, 0}}; - // size of Plane btw. 2 GPUs////// - unsigned int sizePlaneSB, sizePlaneRB, startB, endB; - unsigned int sizePlaneST, sizePlaneRT, startT, endT; - bool isSetSendB, isSetRecvB, isSetSendT, isSetRecvT; - int *SendT, *SendB, *RecvT, *RecvB; + std::vector<CollisionTemplate> allocatedBulkFluidNodeTags = {}; - // size of Plane for PressMess - unsigned int sizePlanePress, startP; - unsigned int sizePlanePressIN, startPIN; - unsigned int sizePlanePressOUT, startPOUT; - bool isSetPress; - // print/////////////////// - unsigned int startz, endz; - real Lx, Ly, Lz, dx; - real distX, distY, distZ; - // interface//////////////// - bool need_interface[6]; - unsigned int XdistKn, YdistKn, ZdistKn; - InterpolationCellCF intCF; - InterpolationCellFC intFC; - unsigned int K_CF; - unsigned int K_FC; - unsigned int mem_size_kCF; - unsigned int mem_size_kFC; - - InterpolationCellFC intFCBorder; - InterpolationCellFC intFCBulk; - InterpolationCellCF intCFBorder; - InterpolationCellCF intCFBulk; - - // offset////////////////// - OffsetCF offCF; - OffsetCF offCFBulk; - OffsetFC offFC; - OffsetFC offFCBulk; - unsigned int mem_size_kCF_off; - unsigned int mem_size_kFC_off; - - //! \brief stores the boundary condition data - QforBoundaryConditions noSlipBC, velocityBC, outflowBC, slipBC, stressBC, pressureBC; - //! \brief number of lattice nodes for the boundary conditions - unsigned int numberOfNoSlipBCnodesRead, numberOfVeloBCnodesRead, numberOfOutflowBCnodesRead, numberOfSlipBCnodesRead, numberOfStressBCnodesRead, numberOfPressureBCnodesRead, numberOfPrecursorBCnodesRead; - QforBoundaryConditions QpressX0, QpressX1, QpressY0, QpressY1, QpressZ0, QpressZ1; // DEPRECATED - QforBoundaryConditions propellerBC; - QforBoundaryConditions geometryBC; - QforPrecursorBoundaryConditions precursorBC; - QforBoundaryConditions geometryBCnormalX, geometryBCnormalY, geometryBCnormalZ; - QforBoundaryConditions inflowBCnormalX, inflowBCnormalY, inflowBCnormalZ; - QforBoundaryConditions outflowBCnormalX, outflowBCnormalY, outflowBCnormalZ; - QforBoundaryConditions QInlet, QOutlet, QPeriodic; // DEPRECATED - unsigned int kInletQread, kOutletQread; // DEPRECATED - WallModelParameters wallModel; - std::vector<SPtr<TransientBCInputFileReader>> transientBCInputFileReader; - real outflowPressureCorrectionFactor; - // testRoundoffError - Distributions27 kDistTestRE; ////////////////////////////////////////////////////////////////////////// - // velocities to fit the force - real *VxForce, *VyForce, *VzForce; + // ADD IN FUTURE RELEASE ////////////////////////////////////////////////////////////////////////// - //! \brief sets the forcing uniform on every fluid node in all three space dimensions - real *forcing; + + // distributions F3//////// + Distributions6 g6; + + // BC NoSlip + TempforBoundaryConditions Temp; + // BC Velocity + TempVelforBoundaryConditions TempVel; + // BC Pressure + TempPressforBoundaryConditions TempPress; // Measure Points///////// std::vector<MeasurePoints> MP; @@ -324,94 +304,152 @@ struct LBMSimulationParameter { unsigned int numberOfPointsCpBottom2; std::vector<std::vector<double>> cpBottom2; - // Concentration//////// + ////////////////////////////////////////////////////////////////////////// + // \brief velocities to fit the force + real *VxForce, *VyForce, *VzForce; + + //! \brief stores indices for the concentration field int *concIndex; - real *concentration; + // real *concentration; unsigned int numberOfPointsConc; + //! \brief store all distribution functions for the D3Q7 advection diffusion field + Distributions7 distributionsAD7; + // Plane Conc + real *ConcPlaneIn, *ConcPlaneOut1, *ConcPlaneOut2; + std::vector<double> PlaneConcVectorIn, PlaneConcVectorOut1, PlaneConcVectorOut2; + + // turbulent viscosity /// + real *turbViscosity; + real *gSij, *gSDij, *gDxvx, *gDyvx, *gDzvx, *gDxvy, *gDyvy, *gDzvy, *gDxvz, *gDyvz, *gDzvz; // DebugInformation + + // turbulence intensity // + real *vx_mean, *vy_mean, *vz_mean; // means + real *vxx, *vyy, *vzz, *vxy, *vxz, *vyz; // fluctuations + std::vector<real> turbulenceIntensity; + + // median-macro-values///// + real *vx_SP_Med, *vy_SP_Med, *vz_SP_Med, *rho_SP_Med, *press_SP_Med; + real *vx_SP_Med_Out, *vy_SP_Med_Out, *vz_SP_Med_Out, *rho_SP_Med_Out, *press_SP_Med_Out; + // Advection-Diffusion + real *Conc_Med, *Conc_Med_Out; + + + + + + + + + + - // street X and Y velocity fractions/////// - real *streetFractionXvelocity; - real *streetFractionYvelocity; - int *naschVelocity; - uint numberOfStreetNodes; + + + ////////////////////////////////////////////////////////////////////////// + // DEPRECATED - planed to be taken out permanently + ////////////////////////////////////////////////////////////////////////// + + unsigned int size_Array_SP; //?? Deprecated + + // distributions/////////// + // Distributions19 d0; + Distributions27 d0; // DEPRECATED: distribution functions for full matrix (not sparse) + + // typeOfGridNode (formerly known as "geo") ///////////////////// + int *geo; // DEPRECATED: typeOfGridNode for full matrix (not sparse) + + // k/////////////////////// + unsigned int *k; // DEPRECATED: index for full matrix + + // memsize///////////////// + //unsigned int mem_size_real_yz; + //unsigned int mem_size_bool; + //unsigned int mem_size_int; + //unsigned int mem_size_real; + + QforBoundaryConditions QpressX0, QpressX1, QpressY0, QpressY1, QpressZ0, QpressZ1; // DEPRECATED BCs that are not used any more + QforBoundaryConditions QInlet, QOutlet, QPeriodic; // DEPRECATED BCs that are not used any more + unsigned int kInletQread, kOutletQread; // DEPRECATED + + QforBoundaryConditions propellerBC; // DEPRECATED + QforBoundaryConditions geometryBCnormalX, geometryBCnormalY, geometryBCnormalZ; // DEPRECATED + QforBoundaryConditions inflowBCnormalX, inflowBCnormalY, inflowBCnormalZ; // DEPRECATED + QforBoundaryConditions outflowBCnormalX, outflowBCnormalY, outflowBCnormalZ; // DEPRECATED + + unsigned int numberOfNoSlipBCnodesRead, numberOfVeloBCnodesRead, numberOfOutflowBCnodesRead, // DEPRECATED + numberOfSlipBCnodesRead, numberOfStressBCnodesRead, numberOfPressureBCnodesRead, numberOfPrecursorBCnodesRead; // DEPRECATED + + //! \brief stores a full matrix field of concentration values + real *Conc_Full; + + + + // trafo/////////////////// + real mTtoWx, mTtoWy, mTtoWz; + real cTtoWx, cTtoWy, cTtoWz; + + // MGstrafo//////////////// + real cStartx, cStarty, cStartz; + real cFx, cFy, cFz; + + // interface//////////////// + bool need_interface[6]; + unsigned int XdistKn, YdistKn, ZdistKn; + + // vel parab/////////////// + real *vParab; + + // macroscopic values////// + // real *vx, *vy, *vz, *rho; // DEPRECATED: macroscopic values for full matrix + + // derivations for iso test + real *dxxUx, *dyyUy, *dzzUz; + + // grid//////////////////// + unsigned int nx, ny, nz; + unsigned int gridNX, gridNY, gridNZ; + + // size of matrix////////// + unsigned int size_Mat; + unsigned int sizePlaneXY, sizePlaneYZ, sizePlaneXZ; + + // size of Plane btw. 2 GPUs////// + unsigned int sizePlaneSB, sizePlaneRB, startB, endB; + unsigned int sizePlaneST, sizePlaneRT, startT, endT; + bool isSetSendB, isSetRecvB, isSetSendT, isSetRecvT; + int *SendT, *SendB, *RecvT, *RecvB; + + // size of Plane for PressMess + unsigned int sizePlanePress, startP; + unsigned int sizePlanePressIN, startPIN; + unsigned int sizePlanePressOUT, startPOUT; + bool isSetPress; // deltaPhi real deltaPhi; - //////////////////////////////////////////////////////////////////////////// // particles PathLineParticles plp; - //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// // 1D domain decomposition std::vector<ProcessNeighbor27> sendProcessNeighbor; std::vector<ProcessNeighbor27> recvProcessNeighbor; - /////////////////////////////////////////////////////// - // 3D domain decomposition - std::vector<ProcessNeighbor27> sendProcessNeighborX; - std::vector<ProcessNeighbor27> sendProcessNeighborY; - std::vector<ProcessNeighbor27> sendProcessNeighborZ; - std::vector<ProcessNeighbor27> recvProcessNeighborX; - std::vector<ProcessNeighbor27> recvProcessNeighborY; - std::vector<ProcessNeighbor27> recvProcessNeighborZ; - std::vector<ProcessNeighbor27> sendProcessNeighborsAfterFtoCX; - std::vector<ProcessNeighbor27> sendProcessNeighborsAfterFtoCY; - std::vector<ProcessNeighbor27> sendProcessNeighborsAfterFtoCZ; - std::vector<ProcessNeighbor27> recvProcessNeighborsAfterFtoCX; - std::vector<ProcessNeighbor27> recvProcessNeighborsAfterFtoCY; - std::vector<ProcessNeighbor27> recvProcessNeighborsAfterFtoCZ; - /////////////////////////////////////////////////////// - // 3D domain decomposition convection diffusion - std::vector<ProcessNeighbor27> sendProcessNeighborADX; - std::vector<ProcessNeighbor27> sendProcessNeighborADY; - std::vector<ProcessNeighbor27> sendProcessNeighborADZ; - std::vector<ProcessNeighbor27> recvProcessNeighborADX; - std::vector<ProcessNeighbor27> recvProcessNeighborADY; - std::vector<ProcessNeighbor27> recvProcessNeighborADZ; - /////////////////////////////////////////////////////// - // 3D domain decomposition F3 - std::vector<ProcessNeighborF3> sendProcessNeighborF3X; - std::vector<ProcessNeighborF3> sendProcessNeighborF3Y; - std::vector<ProcessNeighborF3> sendProcessNeighborF3Z; - std::vector<ProcessNeighborF3> recvProcessNeighborF3X; - std::vector<ProcessNeighborF3> recvProcessNeighborF3Y; - std::vector<ProcessNeighborF3> recvProcessNeighborF3Z; - //////////////////////////////////////////////////////////////////////////// - // 3D domain decomposition: position (index in array) of corner nodes in ProcessNeighbor27 - struct EdgeNodePositions { - int indexOfProcessNeighborRecv; - int indexInRecvBuffer; - int indexOfProcessNeighborSend; - int indexInSendBuffer; - EdgeNodePositions(int indexOfProcessNeighborRecv, int indexInRecvBuffer, int indexOfProcessNeighborSend, - int indexInSendBuffer) - : indexOfProcessNeighborRecv(indexOfProcessNeighborRecv), indexInRecvBuffer(indexInRecvBuffer), - indexOfProcessNeighborSend(indexOfProcessNeighborSend), indexInSendBuffer(indexInSendBuffer) - { - } - }; - std::vector<EdgeNodePositions> edgeNodesXtoY; - std::vector<EdgeNodePositions> edgeNodesXtoZ; - std::vector<EdgeNodePositions> edgeNodesYtoZ; + // print/////////////////// + unsigned int startz, endz; + real Lx, Ly, Lz, dx; + real distX, distY, distZ; - /////////////////////////////////////////////////////// - std::map<CollisionTemplate, uint*> taggedFluidNodeIndices = {{CollisionTemplate::Default, nullptr}, - {CollisionTemplate::SubDomainBorder,nullptr}, - {CollisionTemplate::WriteMacroVars, nullptr}, - {CollisionTemplate::ApplyBodyForce, nullptr}, - {CollisionTemplate::AllFeatures, nullptr}}; - std::map<CollisionTemplate, uint > numberOfTaggedFluidNodes = {{CollisionTemplate::Default, 0}, - {CollisionTemplate::SubDomainBorder,0}, - {CollisionTemplate::WriteMacroVars, 0}, - {CollisionTemplate::ApplyBodyForce, 0}, - {CollisionTemplate::AllFeatures, 0}}; + // testRoundoffError + Distributions27 kDistTestRE; - std::vector<CollisionTemplate> allocatedBulkFluidNodeTags = {}; + + ////////////////////////////////////////////////////////////////////////// }; + //! \brief Class for LBM-parameter management class VIRTUALFLUIDS_GPU_EXPORT Parameter { @@ -540,7 +578,6 @@ public: void setcpBottom(std::string cpBottom); void setcpBottom2(std::string cpBottom2); void setConcentration(std::string concFile); - void setStreetVelocity(std::string streetVelocity); void setPrintFiles(bool printfiles); void setReadGeo(bool readGeo); void setTemperatureInit(real Temp); @@ -562,7 +599,6 @@ public: void setIsProp(bool isProp); void setIsCp(bool isCp); void setConcFile(bool concFile); - void setStreetVelocityFile(bool streetVelocityFile); void setUseMeasurePoints(bool useMeasurePoints); void setUseWale(bool useWale); void setTurbulenceModel(TurbulenceModel turbulenceModel); @@ -760,7 +796,6 @@ public: std::string getcpBottom(); std::string getcpBottom2(); std::string getConcentration(); - std::string getStreetVelocityFilePath(); unsigned int getPressInID(); unsigned int getPressOutID(); unsigned int getPressInZ(); @@ -858,7 +893,6 @@ public: bool getCalc3rdOrderMoments(); bool getCalcHighOrderMoments(); bool getConcFile(); - bool isStreetVelocityFile(); bool getUseMeasurePoints(); bool getUseWale(); TurbulenceModel getTurbulenceModel(); @@ -941,6 +975,23 @@ private: void checkParameterValidityCumulantK17() const; private: + real Re; + real factorPressBC{ 1.0 }; + real Diffusivity{ 0.001 }; + real Temp{ 0.0 }; + real TempBC{ 1.0 }; + real RealX{ 1.0 }; + real RealY{ 1.0 }; + real clockCycleForMP{ 1.0 }; + real vis{ 0.001 }; + real vis_ratio{ 1.0 }; + real u0{ 0.01 }; + real u0_ratio{ 1.0 }; + real delta_rho{ 0.0 }; + real delta_press{ 1.0 }; + real SGSConstant{ 0.0 }; + real outflowPressureCorrectionFactor{ 0.0 }; + bool compOn{ false }; bool diffOn{ false }; bool isF3{ false }; @@ -950,6 +1001,27 @@ private: bool calcPlaneConc{ false }; bool calcVelocityAndFluctuations{ false }; bool isBodyForce{ false }; + bool printFiles{ false }; + bool doRestart{ false }; + bool doCheckPoint{ false }; + bool readGeo{ false }; + bool isGeo; + bool isProp; + bool isCp; + bool GeometryValues{ false }; + bool is2ndOrderMoments{ false }; + bool is3rdOrderMoments{ false }; + bool isHighOrderMoments{ false }; + bool calcMedian{ false }; + bool isConc{ false }; + bool isWale{ false }; + bool isTurbulentViscosity{ false }; + bool isMeasurePoints{ false }; + bool isInitNeq{ false }; + bool isGeoNormal, isInflowNormal, isOutflowNormal; + bool hasWallModelMonitor{ false }; + bool simulatePorousMedia{ false }; + int diffMod{ 27 }; //! \property maximum level of grid refinement int maxlevel{ 0 }; @@ -957,11 +1029,60 @@ private: int fine{ 0 }; int factor_gridNZ{ 2 }; int D3Qxx{ 27 }; - InitCondition ic; + int numprocs{ 1 }; + int myProcessId{ 0 }; + int maxdev{ 1 }; + double memsizeGPU; - unsigned int limitOfNodesForVTK; - unsigned int outputCount; - unsigned int timestep; + + uint limitOfNodesForVTK; + uint outputCount; + uint timestep; + uint tDoCheckPoint{ 0 }; + uint tDoRestart{ 0 }; + uint tCalcMedStart{ 0 }; + uint tCalcMedEnd{ 10 }; + uint tend{ 10 }; + uint tout{ 1 }; + uint tStartOut{ 0 }; + uint PressInID{ 0 }; + uint PressOutID{ 0 }; + uint PressInZ{ 1 }; + uint PressOutZ{ 2 }; + uint timeStepForMP{ 10 }; + + std::vector<uint> devices{ 0, 1 }; // one device with ID = 0 + std::vector<int> GridX, GridY, GridZ, DistX, DistY, DistZ; + std::vector<real> scaleLBMtoSI, translateLBMtoSI; + std::vector<real> minCoordX, minCoordY, minCoordZ, maxCoordX, maxCoordY, maxCoordZ; + + std::string fname{ "output/simulation" }; + std::string oPath{ "output/" }; + std::string gridPath{ "grid/" }; + std::string oPrefix{ "simulation" }; + std::string geometryFileC, geometryFileM, geometryFileF; + std::string kFull, geoFull, geoVec, coordX, coordY, coordZ, neighborX, neighborY, neighborZ, neighborWSB, scaleCFC, scaleCFF, scaleFCC, scaleFCF, scaleOffsetCF, scaleOffsetFC; + std::string noSlipBcPos, noSlipBcQs, noSlipBcValue; + std::string slipBcPos, slipBcQs, slipBcValue; + std::string pressBcPos, pressBcQs, pressBcValue; + std::string geomBoundaryBcQs, velBcQs; + std::string geomBoundaryBcValues, velBcValues, pressBcValues, noSlipBcValues; + std::string propellerCylinder, propellerValues, propellerQs, measurePoints; + std::string inletBcQs, inletBcValues; + std::string outletBcQs, outletBcValues; + std::string topBcQs, topBcValues; + std::string bottomBcQs, bottomBcValues; + std::string frontBcQs, frontBcValues; + std::string backBcQs, backBcValues; + std::string wallBcQs, wallBcValues; + std::string periodicBcQs, periodicBcValues; + std::string numberNodes, LBMvsSI; + std::string cpTop, cpBottom, cpBottom2; + std::string concentration; + std::string geomNormalX, geomNormalY, geomNormalZ, inflowNormalX, inflowNormalY, inflowNormalZ, outflowNormalX, outflowNormalY, outflowNormalZ; + + TurbulenceModel turbulenceModel{ TurbulenceModel::None }; + // Kernel std::string mainKernel{ "CumulantK17CompChim" }; diff --git a/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp b/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp index 72a12ae880556e6e257eb69dee4e806617252629..b86d5657922deb9dca6e89574efc72766bcd16ce 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp +++ b/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp @@ -53,7 +53,6 @@ TEST(ParameterTest, check_all_Parameter_CanBePassedToConstructor) EXPECT_THAT(para.getWriteVeloASCIIfiles(), testing::Eq(true)); EXPECT_THAT(para.getCalcPlaneConc(), testing::Eq(true)); EXPECT_THAT(para.getConcFile(), testing::Eq(true)); - EXPECT_THAT(para.isStreetVelocityFile(), testing::Eq(true)); EXPECT_THAT(para.getUseMeasurePoints(), testing::Eq(true)); EXPECT_THAT(para.getUseWale(), testing::Eq(true)); EXPECT_THAT(para.getUseInitNeq(), testing::Eq(true)); diff --git a/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg b/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg index af9cb2851acbb56c2235c66ddf96bab3dac0d39f..097c6e6ccbec37c0f30de45ba444f33ff756cbdb 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg +++ b/src/gpu/VirtualFluids_GPU/Parameter/parameterTest.cfg @@ -17,7 +17,6 @@ calcDrafLift = true writeVeloASCIIfiles = true calcPlaneConc = true UseConcFile = true -UseStreetVelocityFile = true UseMeasurePoints = true UseWale = true UseInitNeq = true diff --git a/src/gpu/VirtualFluids_GPU/Particles/Particles.h b/src/gpu/VirtualFluids_GPU/Particles/Particles.h index 7a6d003a08ef7f6517b6259c2c1b895676c6d80b..805817e2f7c6c64b27d60109ad8b6ee2c60cf5cc 100644 --- a/src/gpu/VirtualFluids_GPU/Particles/Particles.h +++ b/src/gpu/VirtualFluids_GPU/Particles/Particles.h @@ -4,7 +4,7 @@ #include "LBM/LB.h" #include "GPU/GPU_Interface.h" #include "GPU/CudaMemoryManager.h" -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" #include "Parameter/Parameter.h" //void calcDragLift(Parameter* para, int lev); diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorFarm.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorFarm.cu index 9447a8636e801c132df9cef2feced4b5ab4e68de..bcdd63657d13cd8a9dcef3372fe02760a337b057 100644 --- a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorFarm.cu +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorFarm.cu @@ -44,10 +44,10 @@ #include "Parameter/CudaStreamManager.h" #include "DataStructureInitializer/GridProvider.h" #include "GPU/CudaMemoryManager.h" -#include "lbm/constants/NumericConstants.h" -#include "logger/Logger.h" +#include "basics/constants/NumericConstants.h" +#include <logger/Logger.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; __host__ __device__ __inline__ uint calcNode(uint bladeNode, uint numberOfBladeNodes, uint blade, uint numberOfBlades, uint turbine, uint numberOfTurbines) @@ -62,7 +62,7 @@ __host__ __device__ __inline__ void calcTurbineBladeAndBladeNode(uint node, uint uint x_off = turbine*numberOfBladeNodes*numberOfBlades; blade = (node - x_off)/numberOfBlades; uint y_off = numberOfBladeNodes*blade+x_off; - bladeNode = (node - y_off)/numberOfBladeNodes; + bladeNode = (node - y_off); } __host__ __device__ __forceinline__ real distSqrd(real distX, real distY, real distZ) @@ -78,9 +78,9 @@ void swapArrays(real* &arr1, real* &arr2) } __host__ __device__ __inline__ void rotateFromBladeToGlobal( - real& bladeCoordX_BF, real& bladeCoordY_BF, real& bladeCoordZ_BF, + real bladeCoordX_BF, real bladeCoordY_BF, real bladeCoordZ_BF, real& bladeCoordX_GF, real& bladeCoordY_GF, real& bladeCoordZ_GF, - real& azimuth, real& yaw) + real azimuth, real yaw) { real tmpX, tmpY, tmpZ; @@ -91,8 +91,8 @@ __host__ __device__ __inline__ void rotateFromBladeToGlobal( __host__ __device__ __inline__ void rotateFromGlobalToBlade( real& bladeCoordX_BF, real& bladeCoordY_BF, real& bladeCoordZ_BF, - real& bladeCoordX_GF, real& bladeCoordY_GF, real& bladeCoordZ_GF, - real& azimuth, real& yaw) + real bladeCoordX_GF, real bladeCoordY_GF, real bladeCoordZ_GF, + real azimuth, real yaw) { real tmpX, tmpY, tmpZ; @@ -305,11 +305,11 @@ void ActuatorFarm::init(Parameter* para, GridProvider* gridProvider, CudaMemoryM if(!para->getIsBodyForce()) throw std::runtime_error("try to allocate ActuatorFarm but BodyForce is not set in Parameter."); this->forceRatio = para->getForceRatio(); this->initTurbineGeometries(cudaMemoryManager); - this->initBladeCoords(cudaMemoryManager); + this->initBladeCoords(cudaMemoryManager); this->initBladeIndices(para, cudaMemoryManager); this->initBladeVelocities(cudaMemoryManager); - this->initBladeForces(cudaMemoryManager); - this->initBoundingSpheres(para, cudaMemoryManager); + this->initBladeForces(cudaMemoryManager); + this->initBoundingSpheres(para, cudaMemoryManager); this->streamIndex = 0; } @@ -321,7 +321,7 @@ void ActuatorFarm::interact(Parameter* para, CudaMemoryManager* cudaMemoryManage if(useHostArrays) cudaMemoryManager->cudaCopyBladeCoordsHtoD(this); - vf::cuda::CudaGrid bladeGrid = vf::cuda::CudaGrid(para->getParH(level)->numberofthreads, this->numberOfNodes); + vf::cuda::CudaGrid bladeGrid = vf::cuda::CudaGrid(para->getParH(level)->numberofthreads, this->numberOfGridNodes); interpolateVelocities<<< bladeGrid.grid, bladeGrid.threads, 0, stream >>>( para->getParD(this->level)->coordinateX, para->getParD(this->level)->coordinateY, para->getParD(this->level)->coordinateZ, @@ -378,6 +378,7 @@ void ActuatorFarm::calcForcesEllipticWing() real Cd = c0o1; real c0 = 20*c1o10; real c, Cn, Ct; + for(uint turbine=0; turbine<this->numberOfTurbines; turbine++) { real diameter = this->diametersH[turbine]; @@ -423,7 +424,7 @@ void ActuatorFarm::getTaggedFluidNodes(Parameter *para, GridProvider* gridProvid void ActuatorFarm::initTurbineGeometries(CudaMemoryManager* cudaMemoryManager) { this->numberOfTurbines = uint(this->preInitDiameters.size()); - this->numberOfNodes = numberOfTurbines*numberOfBladeNodes*numberOfBlades; + this->numberOfGridNodes = numberOfTurbines*numberOfBladeNodes*numberOfBlades; cudaMemoryManager->cudaAllocBladeGeometries(this); cudaMemoryManager->cudaAllocBladeOrientations(this); @@ -479,9 +480,9 @@ void ActuatorFarm::initBladeVelocities(CudaMemoryManager* cudaMemoryManager) { cudaMemoryManager->cudaAllocBladeVelocities(this); - std::fill_n(this->bladeVelocitiesXH, this->numberOfNodes, c0o1); - std::fill_n(this->bladeVelocitiesYH, this->numberOfNodes, c0o1); - std::fill_n(this->bladeVelocitiesZH, this->numberOfNodes, c0o1); + std::fill_n(this->bladeVelocitiesXH, this->numberOfGridNodes, c0o1); + std::fill_n(this->bladeVelocitiesYH, this->numberOfGridNodes, c0o1); + std::fill_n(this->bladeVelocitiesZH, this->numberOfGridNodes, c0o1); cudaMemoryManager->cudaCopyBladeVelocitiesHtoD(this); swapArrays(this->bladeVelocitiesXDCurrentTimestep, this->bladeVelocitiesXDPreviousTimestep); @@ -494,9 +495,9 @@ void ActuatorFarm::initBladeForces(CudaMemoryManager* cudaMemoryManager) { cudaMemoryManager->cudaAllocBladeForces(this); - std::fill_n(this->bladeForcesXH, this->numberOfNodes, c0o1); - std::fill_n(this->bladeForcesYH, this->numberOfNodes, c0o1); - std::fill_n(this->bladeForcesZH, this->numberOfNodes, c0o1); + std::fill_n(this->bladeForcesXH, this->numberOfGridNodes, c0o1); + std::fill_n(this->bladeForcesYH, this->numberOfGridNodes, c0o1); + std::fill_n(this->bladeForcesZH, this->numberOfGridNodes, c0o1); cudaMemoryManager->cudaCopyBladeForcesHtoD(this); swapArrays(this->bladeForcesXDCurrentTimestep, this->bladeForcesXDPreviousTimestep); @@ -509,7 +510,7 @@ void ActuatorFarm::initBladeIndices(Parameter* para, CudaMemoryManager* cudaMemo { cudaMemoryManager->cudaAllocBladeIndices(this); - std::fill_n(this->bladeIndicesH, this->numberOfNodes, 1); + std::fill_n(this->bladeIndicesH, this->numberOfGridNodes, 1); cudaMemoryManager->cudaCopyBladeIndicesHtoD(this); } @@ -574,23 +575,23 @@ void ActuatorFarm::setAllYaws(real* _yaws) void ActuatorFarm::setAllBladeCoords(real* _bladeCoordsX, real* _bladeCoordsY, real* _bladeCoordsZ) { - std::copy_n(_bladeCoordsX, this->numberOfNodes, this->bladeCoordsXH); - std::copy_n(_bladeCoordsY, this->numberOfNodes, this->bladeCoordsYH); - std::copy_n(_bladeCoordsZ, this->numberOfNodes, this->bladeCoordsZH); + std::copy_n(_bladeCoordsX, this->numberOfGridNodes, this->bladeCoordsXH); + std::copy_n(_bladeCoordsY, this->numberOfGridNodes, this->bladeCoordsYH); + std::copy_n(_bladeCoordsZ, this->numberOfGridNodes, this->bladeCoordsZH); } void ActuatorFarm::setAllBladeVelocities(real* _bladeVelocitiesX, real* _bladeVelocitiesY, real* _bladeVelocitiesZ) { - std::copy_n(_bladeVelocitiesX, this->numberOfNodes, this->bladeVelocitiesXH); - std::copy_n(_bladeVelocitiesY, this->numberOfNodes, this->bladeVelocitiesYH); - std::copy_n(_bladeVelocitiesZ, this->numberOfNodes, this->bladeVelocitiesZH); + std::copy_n(_bladeVelocitiesX, this->numberOfGridNodes, this->bladeVelocitiesXH); + std::copy_n(_bladeVelocitiesY, this->numberOfGridNodes, this->bladeVelocitiesYH); + std::copy_n(_bladeVelocitiesZ, this->numberOfGridNodes, this->bladeVelocitiesZH); } void ActuatorFarm::setAllBladeForces(real* _bladeForcesX, real* _bladeForcesY, real* _bladeForcesZ) { - std::copy_n(_bladeForcesX, this->numberOfNodes, this->bladeForcesXH); - std::copy_n(_bladeForcesY, this->numberOfNodes, this->bladeForcesYH); - std::copy_n(_bladeForcesZ, this->numberOfNodes, this->bladeForcesZH); + std::copy_n(_bladeForcesX, this->numberOfGridNodes, this->bladeForcesXH); + std::copy_n(_bladeForcesY, this->numberOfGridNodes, this->bladeForcesYH); + std::copy_n(_bladeForcesZ, this->numberOfGridNodes, this->bladeForcesZH); }void ActuatorFarm::setTurbineBladeCoords(uint turbine, real* _bladeCoordsX, real* _bladeCoordsY, real* _bladeCoordsZ) { diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorFarm.h b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorFarm.h index 8e21cdb6b21efd323f6723e21d6b28614109f1ec..67bf83691d19179984647cb808bb6c0592bb0bfb 100644 --- a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorFarm.h +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorFarm.h @@ -3,14 +3,14 @@ #include "PreCollisionInteractor.h" #include "PointerDefinitions.h" -#include "lbm/constants/NumericConstants.h" +#include "basics/constants/NumericConstants.h" #include <stdexcept> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; class Parameter; class GridProvider; -using namespace vf::lbm::constant; +using namespace vf::basics::constant; class ActuatorFarm : public PreCollisionInteractor { @@ -32,7 +32,7 @@ public: level(_level), useHostArrays(_useHostArrays), numberOfTurbines(0), - numberOfNodes(0), + numberOfGridNodes(0), PreCollisionInteractor() { this->deltaT = _deltaT*exp2(-this->level); @@ -62,7 +62,7 @@ public: uint getNumberOfBladesPerTurbine(){ return this->numberOfBlades; }; uint getNumberOfIndices(){ return this->numberOfIndices; }; - uint getNumberOfNodes(){ return this->numberOfNodes; }; + uint getNumberOfGridNodes(){ return this->numberOfGridNodes; }; real* getAllAzimuths(){ return azimuthsH; }; real* getAllOmegas(){ return omegasH; }; @@ -189,7 +189,7 @@ private: const real epsilon; // in m const int level; uint numberOfIndices; - uint numberOfNodes; + uint numberOfGridNodes; real forceRatio, factorGaussian, invEpsilonSqrd, invDeltaX; int streamIndex; }; diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h index f9a87f613e7607301e59a7c1e67eb556418892e4..811045a32b18fd0f5d7f71be39b0dfec8982b352 100644 --- a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h @@ -4,7 +4,7 @@ #include <string> #include <vector> -#include "Core/DataTypes.h" +#include "DataTypes.h" #include "PointerDefinitions.h" #include "VirtualFluids_GPU_export.h" diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/PrecursorWriter.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/PrecursorWriter.cu index 1a8260ef936e2707fb38fbbba71cdbfac692f350..99c60fd3d2aae2e796e0c95e624b9d5d33c30ef1 100644 --- a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/PrecursorWriter.cu +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/PrecursorWriter.cu @@ -39,7 +39,7 @@ #include "cuda/CudaGrid.h" #include "LBM/GPUHelperFunctions/KernelUtilities.h" -#include "Core/StringUtilities/StringUtil.h" +#include "StringUtilities/StringUtil.h" #include "Parameter/Parameter.h" #include "DataStructureInitializer/GridProvider.h" diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.cu index 03c18f5a9a2133bec244053113209abc70469a2a..a7a0e79c0bcbf0f7a9e13e879debfb378e23f69d 100644 --- a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.cu +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.cu @@ -37,15 +37,15 @@ #include <helper_cuda.h> #include "VirtualFluids_GPU/GPU/GeometryUtils.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> #include "basics/writer/WbWriterVtkXmlBinary.h" -#include <Core/StringUtilities/StringUtil.h> +#include <StringUtilities/StringUtil.h> #include "Parameter/Parameter.h" #include "DataStructureInitializer/GridProvider.h" #include "GPU/CudaMemoryManager.h" -using namespace vf::lbm::constant; +using namespace vf::basics::constant; __device__ void calculatePointwiseQuantities(uint n, real* quantityArray, bool* quantities, uint* quantityArrayOffsets, uint nPoints, uint node, real vx, real vy, real vz, real rho) { diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD27/InitCompAD27.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD27/InitCompAD27.cu index 60dbb2228e6d01fdabf7a6e1bfca786e2104d5b0..1e70fc642a3fd7f6fca4ed90b9ff4ebc1bb437db 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD27/InitCompAD27.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD27/InitCompAD27.cu @@ -18,12 +18,12 @@ void InitCompAD27::init(int level) para->getParD(level)->neighborY, para->getParD(level)->neighborZ, para->getParD(level)->typeOfGridNode, - para->getParD(level)->Conc, + para->getParD(level)->concentration, para->getParD(level)->velocityX, para->getParD(level)->velocityY, para->getParD(level)->velocityZ, para->getParD(level)->numberOfNodes, - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->isEvenTimestep); getLastCudaError("LB_Init_Comp_AD_27 execution failed"); } diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD27/InitCompAD27_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD27/InitCompAD27_Device.cu index d40e60c764054f8ac6c1793ea3e3573ed04a84fc..8fc9de61cfc20c5111a70ad544a9a26c5b3ea7b4 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD27/InitCompAD27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD27/InitCompAD27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD7/InitCompAD7.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD7/InitCompAD7.cu index 8097ee13d9064c4104ead8cd8eb5ba529d8972fc..f8fc6af00d93cc5a51da4a69d67b69b616f97140 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD7/InitCompAD7.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD7/InitCompAD7.cu @@ -18,7 +18,7 @@ void InitCompAD7::init(int level) para->getParD(level)->neighborY, para->getParD(level)->neighborZ, para->getParD(level)->typeOfGridNode, - para->getParD(level)->Conc, + para->getParD(level)->concentration, para->getParD(level)->velocityX, para->getParD(level)->velocityY, para->getParD(level)->velocityZ, diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD7/InitCompAD7_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD7/InitCompAD7_Device.cu index 38cd57fd48e02e410e1ae557088e023ffeadfc4e..bb3e6c97ddc387234252b59dc43143f115888a6a 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD7/InitCompAD7_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompAD7/InitCompAD7_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompSP27/InitCompSP27_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompSP27/InitCompSP27_Device.cu index dcc3b9a060a026accffdc6d24f338a6d23295d73..109ea18edf183b65106ce6ed86fea05d6b005d90 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompSP27/InitCompSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitCompSP27/InitCompSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" @@ -355,7 +355,7 @@ __global__ void LB_Init_Comp_Neq_SP_27( unsigned int* neighborX, ////////////////////////////////////////////////////////////////////////// - // the following code is copy and pasted from VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp + // the following code is copy and pasted from VirtualFluidsVisitors/InitDistributionsBlockVisitor.cpp // i.e. Konstantins code real ax = dvx1dx; diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitF3/InitF3_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitF3/InitF3_Device.cu index 25af54e43ec213214615c2edc79d7996e4651c38..349bfda9824483bf08d09f267d5fc4b0f6a13ac1 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitF3/InitF3_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitF3/InitF3_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD27/InitIncompAD27.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD27/InitIncompAD27.cu index ea700010960b11a1facdda18c35f220f43eb6a66..6a9b4cb31b1032f6921bddbe60d3cd570ef46b6d 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD27/InitIncompAD27.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD27/InitIncompAD27.cu @@ -18,12 +18,12 @@ void InitIncompAD27::init(int level) para->getParD(level)->neighborY, para->getParD(level)->neighborZ, para->getParD(level)->typeOfGridNode, - para->getParD(level)->Conc, + para->getParD(level)->concentration, para->getParD(level)->velocityX, para->getParD(level)->velocityY, para->getParD(level)->velocityZ, para->getParD(level)->numberOfNodes, - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->isEvenTimestep); getLastCudaError("LB_Init_Incomp_AD_27 execution failed"); } diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD27/InitIncompAD27_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD27/InitIncompAD27_Device.cu index 62d766aaa04b6f6349c6c4106e201f36898601ec..869169c525bf7f64a2c1ac9e1cf2d9678efdb28b 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD27/InitIncompAD27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD27/InitIncompAD27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD7/InitIncompAD7.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD7/InitIncompAD7.cu index d7c08e6932cacf2fb5a946010c1855212f1631fc..b7c7d46a9ea8e3133b8240e27959b6b4d2ed0cf5 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD7/InitIncompAD7.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD7/InitIncompAD7.cu @@ -18,12 +18,12 @@ void InitIncompAD7::init(int level) para->getParD(level)->neighborY, para->getParD(level)->neighborZ, para->getParD(level)->typeOfGridNode, - para->getParD(level)->Conc, + para->getParD(level)->concentration, para->getParD(level)->velocityX, para->getParD(level)->velocityY, para->getParD(level)->velocityZ, para->getParD(level)->numberOfNodes, - para->getParD(level)->distributionsAD27.f[0], + para->getParD(level)->distributionsAD.f[0], para->getParD(level)->isEvenTimestep); getLastCudaError("LB_Init_Incomp_AD_7 execution failed"); } diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD7/InitIncompAD7_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD7/InitIncompAD7_Device.cu index 94a4352d43dee67117f66eaf03536c5ea3e15edd..1fee2cbe232415d7435f5b60297799f2668cc01e 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD7/InitIncompAD7_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitIncompAD7/InitIncompAD7_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitSP27/InitSP27_Device.cu b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitSP27/InitSP27_Device.cu index b58935feb0bf276a2d8da3f36efbb1fb0ab9d13f..87abb17176942594280fae7b7592f31303ba746d 100644 --- a/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitSP27/InitSP27_Device.cu +++ b/src/gpu/VirtualFluids_GPU/PreProcessor/PreProcessorStrategy/InitSP27/InitSP27_Device.cu @@ -1,8 +1,8 @@ #include "LBM/LB.h" #include "lbm/constants/D3Q27.h" -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -using namespace vf::lbm::constant; +using namespace vf::basics::constant; using namespace vf::lbm::dir; #include "math.h" diff --git a/src/gpu/VirtualFluids_GPU/Restart/RestartObject.h b/src/gpu/VirtualFluids_GPU/Restart/RestartObject.h index 3d6db6e3a7aad82b2656d917a2b25b26c4ff4d92..963c6549fd41c80c77edc9a205679e8cbc627a1e 100644 --- a/src/gpu/VirtualFluids_GPU/Restart/RestartObject.h +++ b/src/gpu/VirtualFluids_GPU/Restart/RestartObject.h @@ -5,7 +5,7 @@ #include <string> #include <vector> -#include <basics/Core/DataTypes.h> +#include <basics/DataTypes.h> class Parameter; diff --git a/src/gpu/VirtualFluids_GPU/Temperature/FindTemperature.cpp b/src/gpu/VirtualFluids_GPU/Temperature/FindTemperature.cpp index 7b42b22cbf66b248bb1ae6681207eef1da22fa97..a4f6a01f83bd914e6ba7123a10387a463d90e84d 100644 --- a/src/gpu/VirtualFluids_GPU/Temperature/FindTemperature.cpp +++ b/src/gpu/VirtualFluids_GPU/Temperature/FindTemperature.cpp @@ -37,7 +37,7 @@ void initTemperatur(Parameter* para, CudaMemoryManager* cudaMemoryManager, int l //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - CalcMacThS7(para->getParD(lev)->Conc, + CalcMacThS7(para->getParD(lev)->concentration, para->getParD(lev)->typeOfGridNode, para->getParD(lev)->neighborX, para->getParD(lev)->neighborY, @@ -68,13 +68,13 @@ void initTemperatur(Parameter* para, CudaMemoryManager* cudaMemoryManager, int l //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// CalcConcentration27( para->getParD(lev)->numberofthreads, - para->getParD(lev)->Conc, + para->getParD(lev)->concentration, para->getParD(lev)->typeOfGridNode, para->getParD(lev)->neighborX, para->getParD(lev)->neighborY, para->getParD(lev)->neighborZ, para->getParD(lev)->numberOfNodes, - para->getParD(lev)->distributionsAD27.f[0], + para->getParD(lev)->distributionsAD.f[0], para->getParD(lev)->isEvenTimestep); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } diff --git a/src/lbm/BGK.cpp b/src/lbm/BGK.cpp index fa3af6777a0492687768dd4945cbf1e9b186f514..5d1993c872b1aefea801e6e2d2c602a82ecd9281 100644 --- a/src/lbm/BGK.cpp +++ b/src/lbm/BGK.cpp @@ -1,20 +1,17 @@ #include "BGK.h" -#include <basics/Core/DataTypes.h> -#include <basics/Core/RealConstants.h> +#include <basics/DataTypes.h> #include "constants/NumericConstants.h" #include "constants/D3Q27.h" #include "MacroscopicQuantities.h" -namespace vf -{ -namespace lbm +namespace vf::lbm { -using namespace constant; +using namespace vf::basics::constant; @@ -61,7 +58,7 @@ __host__ __device__ void bgk(KernelParameter parameter) //! - Acquire macroscopic quantities const real drho = getDensity(distribution.f); const real rho = c1o1 + drho; - const real OOrho = constant::c1o1 / (constant::c1o1 + drho); + const real OOrho = c1o1 / (c1o1 + drho); const real vvx = getIncompressibleVelocityX1(distribution.f) * OOrho; const real vvy = getIncompressibleVelocityX2(distribution.f) * OOrho; @@ -136,5 +133,4 @@ __host__ __device__ void bgk(KernelParameter parameter) } -} diff --git a/src/lbm/BGK.h b/src/lbm/BGK.h index 2c82f5bd445ee008954add02fd0d6d6093364e90..6cde85013dd92472022bbf7b93bc73e7940049a1 100644 --- a/src/lbm/BGK.h +++ b/src/lbm/BGK.h @@ -8,7 +8,7 @@ #define __device__ #endif -#include <basics/Core/DataTypes.h> +#include <basics/DataTypes.h> #include "KernelParameter.h" diff --git a/src/lbm/CMakeLists.txt b/src/lbm/CMakeLists.txt index 7a9a96ace1c7377b7ad0c67937464d1f2c00cce6..52ab3d78710c8551475307463334c9d1d0baf36f 100644 --- a/src/lbm/CMakeLists.txt +++ b/src/lbm/CMakeLists.txt @@ -1,7 +1,7 @@ vf_add_library(PUBLIC_LINK basics) -if(BUILD_VF_GPU OR BUILD_VF_GKS) +if(BUILD_VF_GPU) set_target_properties(lbm PROPERTIES CUDA_SEPARABLE_COMPILATION ON POSITION_INDEPENDENT_CODE ON) set_source_files_properties(KernelParameter.cpp PROPERTIES LANGUAGE CUDA) diff --git a/src/lbm/Chimera.h b/src/lbm/Chimera.h index 6ffa0918aac4e6303efe4db82aa98ee645dc63e8..8e54d47a42e164a89060f5009c112f5a69afd257 100644 --- a/src/lbm/Chimera.h +++ b/src/lbm/Chimera.h @@ -8,16 +8,14 @@ #define __device__ #endif -#include <basics/Core/DataTypes.h> +#include <basics/DataTypes.h> -#include <lbm/constants/NumericConstants.h> +#include <basics/constants/NumericConstants.h> -namespace vf -{ -namespace lbm -{ +using namespace vf::basics::constant; -using namespace constant; +namespace vf::lbm +{ //////////////////////////////////////////////////////////////////////////////// //! \brief forward chimera transformation \ref forwardInverseChimeraWithK @@ -116,6 +114,5 @@ inline __host__ __device__ void backwardChimeraWithK(real &mfa, real &mfb, real mfb = m1; } -} } #endif diff --git a/src/lbm/CumulantChimera.cpp b/src/lbm/CumulantChimera.cpp index e1c27f90b6611640d8e5db47c9432268f5f58f15..f8e11d468471efe96b3d9e17c356b8c1a3d59ff8 100644 --- a/src/lbm/CumulantChimera.cpp +++ b/src/lbm/CumulantChimera.cpp @@ -2,8 +2,7 @@ #include <cmath> -#include <basics/Core/DataTypes.h> -#include <basics/Core/RealConstants.h> +#include <basics/DataTypes.h> #include "constants/NumericConstants.h" #include "constants/D3Q27.h" @@ -11,12 +10,10 @@ #include "Chimera.h" #include "MacroscopicQuantities.h" -namespace vf -{ -namespace lbm +namespace vf::lbm { -using namespace constant; +using namespace vf::basics::constant; //////////////////////////////////////////////////////////////////////////////////// @@ -449,5 +446,4 @@ __host__ __device__ void cumulantChimera(KernelParameter parameter, RelaxationRa } -} diff --git a/src/lbm/CumulantChimera.h b/src/lbm/CumulantChimera.h index e8740c7d3f5b988a6fdc5c3b16ab6a90e0a28b83..c30a0c07912953cff45e3734c0b60fa7a03acd53 100644 --- a/src/lbm/CumulantChimera.h +++ b/src/lbm/CumulantChimera.h @@ -8,7 +8,7 @@ #define __device__ #endif -#include <basics/Core/DataTypes.h> +#include <basics/DataTypes.h> #include "KernelParameter.h" diff --git a/src/lbm/KernelParameter.h b/src/lbm/KernelParameter.h index 18c4f2a4b20b84d9d519993f3ddb54cf612d4306..9c07524226a40aaa9e2c65e7ab028b07aec62ddc 100644 --- a/src/lbm/KernelParameter.h +++ b/src/lbm/KernelParameter.h @@ -8,7 +8,7 @@ #define __device__ #endif -#include <basics/Core/DataTypes.h> +#include <basics/DataTypes.h> namespace vf::lbm diff --git a/src/lbm/MacroscopicQuantities.h b/src/lbm/MacroscopicQuantities.h index 8789f65195ee38b1399a42a0c24511dfcea3d6d0..751c874f1c240f5502ccaef5f6e540be1e5d28ff 100644 --- a/src/lbm/MacroscopicQuantities.h +++ b/src/lbm/MacroscopicQuantities.h @@ -8,16 +8,15 @@ #define __device__ #endif -#include <basics/Core/DataTypes.h> +#include <basics/DataTypes.h> #include "constants/NumericConstants.h" #include "constants/D3Q27.h" -namespace vf -{ -namespace lbm + +namespace vf::lbm { - + //////////////////////////////////////////////////////////////////////////////////// //! - Calculate density and velocity using pyramid summation for low round-off errors as in Eq. (J1)-(J3) \ref //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa 2015.05.001 ]</b></a> @@ -61,19 +60,19 @@ inline __host__ __device__ real getIncompressibleVelocityX3(const real *const &f */ inline __host__ __device__ real getCompressibleVelocityX1(const real *const &f27, const real& rho) { - return getIncompressibleVelocityX1(f27) / (rho + constant::c1o1); + return getIncompressibleVelocityX1(f27) / (rho + basics::constant::c1o1); } inline __host__ __device__ real getCompressibleVelocityX2(const real *const &f27, const real& rho) { - return getIncompressibleVelocityX2(f27) / (rho + constant::c1o1); + return getIncompressibleVelocityX2(f27) / (rho + basics::constant::c1o1); } inline __host__ __device__ real getCompressibleVelocityX3(const real *const &f27, const real& rho) { - return getIncompressibleVelocityX3(f27) / (rho + constant::c1o1); + return getIncompressibleVelocityX3(f27) / (rho + basics::constant::c1o1); } /* @@ -82,17 +81,17 @@ inline __host__ __device__ real getCompressibleVelocityX3(const real *const &f27 inline __host__ __device__ real getPressure(const real *const &f27, const real& rho, const real& vx, const real& vy, const real& vz) { return (f27[dir::DIR_P00] + f27[dir::DIR_M00] + f27[dir::DIR_0P0] + f27[dir::DIR_0M0] + f27[dir::DIR_00P] + f27[dir::DIR_00M] + - constant::c2o1 * (f27[dir::DIR_PP0] + f27[dir::DIR_MM0] + f27[dir::DIR_PM0] + f27[dir::DIR_MP0] + f27[dir::DIR_P0P] + + basics::constant::c2o1 * (f27[dir::DIR_PP0] + f27[dir::DIR_MM0] + f27[dir::DIR_PM0] + f27[dir::DIR_MP0] + f27[dir::DIR_P0P] + f27[dir::DIR_M0M] + f27[dir::DIR_P0M] + f27[dir::DIR_M0P] + f27[dir::DIR_0PP] + f27[dir::DIR_0MM] + f27[dir::DIR_0PM] + f27[dir::DIR_0MP]) + - constant::c3o1 * (f27[dir::DIR_PPP] + f27[dir::DIR_MMP] + f27[dir::DIR_PMP] + f27[dir::DIR_MPP] + + basics::constant::c3o1 * (f27[dir::DIR_PPP] + f27[dir::DIR_MMP] + f27[dir::DIR_PMP] + f27[dir::DIR_MPP] + f27[dir::DIR_PPM] + f27[dir::DIR_MMM] + f27[dir::DIR_PMM] + f27[dir::DIR_MPM]) - - rho - (vx * vx + vy * vy + vz * vz) * (constant::c1o1 + rho)) * - constant::c1o2 + rho; // times zero for incompressible case + rho - (vx * vx + vy * vy + vz * vz) * (basics::constant::c1o1 + rho)) * + basics::constant::c1o2 + rho; // times zero for incompressible case // Attention: op defined directly to op = 1 ; ^^^^(1.0/op-0.5)=0.5 } -} + } #endif diff --git a/src/lbm/constants/D3Q27.h b/src/lbm/constants/D3Q27.h index c799331815ff92b41b3daf8433bcc10d026a8738..b6c05eae921ae66b43999ff01977f7a674ce505f 100644 --- a/src/lbm/constants/D3Q27.h +++ b/src/lbm/constants/D3Q27.h @@ -2,7 +2,7 @@ #define LBM_D3Q27_H #include <map> -#include "basics/Core/DataTypes.h" +#include "basics/DataTypes.h" namespace vf::lbm::dir { diff --git a/src/lbm/constants/NumericConstants.h b/src/lbm/constants/NumericConstants.h deleted file mode 100644 index 6041988392cc289dfd1b074eb98693115c447435..0000000000000000000000000000000000000000 --- a/src/lbm/constants/NumericConstants.h +++ /dev/null @@ -1,255 +0,0 @@ -#ifndef REAL_CONSTANT_H -#define REAL_CONSTANT_H - -#include <cmath> - -namespace vf::lbm::constant -{ - -#ifdef VF_DOUBLE_ACCURACY -static constexpr double c1o2 = 0.5; -static constexpr double c3o2 = 1.5; -static constexpr double c1o3 = (1.0 / 3.0);// 0.333333333333333; -static constexpr double c2o3 = (2.0 / 3.0);// 0.666666666666667; -static constexpr double c1o4 = 0.25; -static constexpr double c3o4 = 0.75; -static constexpr double c1o6 = (1.0 / 6.0);// 0.166666666666667; -static constexpr double c1o7 = (1.0 / 7.0);// 0.142857142857143; -static constexpr double c1o8 = 0.125; -static constexpr double c1o9 = (1.0 / 9.0);// 0.111111111111111; -static constexpr double c2o9 = (2.0 / 9.0);// 0.222222222222222; -static constexpr double c4o9 = (4.0 / 9.0);// 0.444444444444444; -static constexpr double c4o10 = 0.4; -static constexpr double c1o10 = 0.1; -static constexpr double c1o12 = (1.0 / 12.0);// 0.083333333333333; -static constexpr double c1o16 = (1.0 / 16.0);// 0.0625; -static constexpr double c3o16 = (3.0 / 16.0);// 0.1875; -static constexpr double c9o16 = (9.0 / 16.0);// 0.5625; -static constexpr double c1o18 = (1.0 / 18.0);// 0.055555555555556; -static constexpr double c1o20 = 0.05; -static constexpr double c19o20 = (19.0 / 20.0);// 0.95; -static constexpr double c21o20 = 1.05; -static constexpr double c1o24 = (1.0 / 24.0);// 0.041666666666667; -static constexpr double c1o27 = (1.0 / 27.0);// 0.037037037037037; -static constexpr double c3o32 = (3.0 / 32.0);// 0.09375; -static constexpr double c4o32 = 0.125; -static constexpr double c1o36 = (1.0 / 36.0);// 0.027777777777778; -static constexpr double c1o48 = (1.0 / 48.0);// 0.020833333333333; -static constexpr double c1o64 = (1.0 / 64.0);// 0.015625; -static constexpr double c3o64 = (3.0 / 64.0);// 0.046875; -static constexpr double c9o64 = (9.0 / 64.0);// 0.140625; -static constexpr double c27o64 = (27.0 / 64.0);// 0.421875; -static constexpr double c1o66 = (1.0 / 66.0);// 0.015151515151515; -static constexpr double c1o72 = (1.0 / 72.0);// 0.013888888888889; -static constexpr double c1o264 = (1.0 / 264.0);// 0.003787878787879; -static constexpr double c8o27 = (8.0 / 27.0);// 0.296296296296296; -static constexpr double c2o27 = (2.0 / 27.0);// 0.074074074074074; -static constexpr double c1o54 = (1.0 / 54.0);// 0.018518518518519; -static constexpr double c1o100 = 0.01; -static constexpr double c99o100 = (99.0 / 100.0);// 0.99; -static constexpr double c1o126 = (1.0 / 126.0);// 0.007936507936508; -static constexpr double c1o216 = (1.0 / 216.0);// 0.004629629629630; -static constexpr double c5o4 = 1.25; -static constexpr double c4o3 = 1.333333333333333; -static constexpr double c9o4 = 2.25; -static constexpr double c5o2 = 2.5; -static constexpr double c9o2 = 4.5; - -static constexpr double c0o1 = 0.; -static constexpr double c1o1 = 1.; -static constexpr double c2o1 = 2.; -static constexpr double c3o1 = 3.; -static constexpr double c4o1 = 4.; -static constexpr double c5o1 = 5.; -static constexpr double c6o1 = 6.; -static constexpr double c7o1 = 7.; -static constexpr double c8o1 = 8.; -static constexpr double c9o1 = 9.; -static constexpr double c10o1 = 10.; -static constexpr double c11o1 = 11.; -static constexpr double c12o1 = 12.; -static constexpr double c13o1 = 13.; -static constexpr double c14o1 = 14.; -static constexpr double c15o1 = 15.; -static constexpr double c16o1 = 16.; -static constexpr double c17o1 = 17.; -static constexpr double c18o1 = 18.; -static constexpr double c21o1 = 21.; -static constexpr double c24o1 = 24.; -static constexpr double c25o1 = 25.; -static constexpr double c26o1 = 26.; -static constexpr double c27o1 = 27.; -static constexpr double c28o1 = 28.; -static constexpr double c29o1 = 29.; -static constexpr double c30o1 = 30.; -static constexpr double c32o1 = 32.; -static constexpr double c33o1 = 33.; -static constexpr double c34o1 = 34.; -static constexpr double c36o1 = 36.; -static constexpr double c40o1 = 40.; -static constexpr double c42o1 = 42.; -static constexpr double c46o1 = 46.; -static constexpr double c48o1 = 48.; -static constexpr double c50o1 = 50.; -static constexpr double c52o1 = 52.; -static constexpr double c54o1 = 54.; -static constexpr double c56o1 = 56.; -static constexpr double c64o1 = 64.; -static constexpr double c66o1 = 66.; -static constexpr double c68o1 = 68.; -static constexpr double c69o1 = 69.; -static constexpr double c72o1 = 72.; -static constexpr double c84o1 = 84.; -static constexpr double c88o1 = 88.; -static constexpr double c96o1 = 96.; -static constexpr double c100o1 = 100.; -static constexpr double c130o1 = 130.; -static constexpr double c152o1 = 152.; -static constexpr double c166o1 = 166.; -static constexpr double c195o1 = 195.; -static constexpr double c216o1 = 216.; -static constexpr double c264o1 = 264.; -static constexpr double c290o1 = 290.; -static constexpr double c367o1 = 367.; - -static constexpr double Op0000002 = 0.0000002; -static constexpr double c10eM30 = 1e-30; -static constexpr double c10eM10 = 1e-10; -static constexpr double smallSingle = 0.0000000002; - -static const double cPi = 4.0 * std::atan(1.0);// 3.1415926535; -static const double c2Pi = 2.0 * cPi;// 6.28318530717; -static const double cPio180 = cPi / 180.0;// 1.74532925199e-2; -static const double c180oPi = 180.0 / cPi;// 57.2957795131; - -static const double one_over_sqrt2 = 1.0 / sqrt(2.0); // 0.707106781 -static const double one_over_sqrt3 = 1.0 / sqrt(3.0); // 0.577350269 -static const double sqrt2 = sqrt(2.0); // 1.4142135 -static const double sqrt3 = sqrt(3.0); // 1.7320508 - -#else -static constexpr float c1o2 = 0.5f; -static constexpr float c3o2 = 1.5f; -static constexpr float c1o3 = (1.0f / 3.0f); -static constexpr float c2o3 = (2.0f / 3.0f); -static constexpr float c1o4 = 0.25f; -static constexpr float c3o4 = 0.75f; -static constexpr float c1o6 = (1.0f / 6.0f); -static constexpr float c1o7 = (1.0f / 7.0f); -static constexpr float c1o8 = 0.125f; -static constexpr float c1o9 = (1.0f / 9.0f); -static constexpr float c2o9 = (2.0f / 9.0f); -static constexpr float c4o9 = (4.0f / 9.0f); -static constexpr float c4o10 = 0.4f; -static constexpr float c1o10 = 0.1f; -static constexpr float c1o12 = (1.0f / 12.0f); -static constexpr float c1o16 = 0.0625f; -static constexpr float c3o16 = 0.1875f; -static constexpr float c9o16 = 0.5625f; -static constexpr float c1o18 = (1.0f / 18.0f); -static constexpr float c1o20 = 0.05f; -static constexpr float c19o20 = 0.95f; -static constexpr float c21o20 = 1.05f; -static constexpr float c1o24 = (1.0f / 24.0f); -static constexpr float c1o27 = (1.0f / 27.0f); -static constexpr float c3o32 = 0.09375f; -static constexpr float c4o32 = 0.125f; -static constexpr float c1o36 = (1.0f / 36.0f); -static constexpr float c1o48 = (1.0f / 48.0f); -static constexpr float c1o64 = 0.015625f; -static constexpr float c3o64 = 0.046875f; -static constexpr float c9o64 = 0.140625f; -static constexpr float c27o64 = 0.421875f; -static constexpr float c1o66 = (1.0f / 66.0f); -static constexpr float c1o72 = (1.0f / 72.0f); -static constexpr float c1o264 = (1.0f / 264.0f); -static constexpr float c8o27 = (8.0f / 27.0f); -static constexpr float c2o27 = (2.0f / 27.0f); -static constexpr float c1o54 = (1.0f / 54.0f); -static constexpr float c1o100 = 0.01f; -static constexpr float c99o100 = 0.99f; -static constexpr float c1o126 = (1.0f / 126.0f); -static constexpr float c1o216 = (1.0f / 216.0f); -static constexpr float c5o4 = 1.25f; -static constexpr float c4o3 = (4.0f / 3.0f); -static constexpr float c9o4 = 2.25f; -static constexpr float c5o2 = 2.5f; -static constexpr float c9o2 = 4.5f; - -static constexpr float c0o1 = 0.f; -static constexpr float c1o1 = 1.f; -static constexpr float c2o1 = 2.f; -static constexpr float c3o1 = 3.f; -static constexpr float c4o1 = 4.f; -static constexpr float c5o1 = 5.f; -static constexpr float c6o1 = 6.f; -static constexpr float c7o1 = 7.f; -static constexpr float c8o1 = 8.f; -static constexpr float c9o1 = 9.f; -static constexpr float c10o1 = 10.f; -static constexpr float c11o1 = 11.f; -static constexpr float c12o1 = 12.f; -static constexpr float c13o1 = 13.f; -static constexpr float c14o1 = 14.f; -static constexpr float c15o1 = 15.f; -static constexpr float c16o1 = 16.f; -static constexpr float c17o1 = 17.f; -static constexpr float c18o1 = 18.f; -static constexpr float c21o1 = 21.f; -static constexpr float c24o1 = 24.f; -static constexpr float c25o1 = 25.f; -static constexpr float c26o1 = 26.f; -static constexpr float c27o1 = 27.f; -static constexpr float c28o1 = 28.f; -static constexpr float c29o1 = 29.f; -static constexpr float c30o1 = 30.f; -static constexpr float c32o1 = 32.f; -static constexpr float c33o1 = 33.f; -static constexpr float c34o1 = 34.f; -static constexpr float c36o1 = 36.f; -static constexpr float c40o1 = 40.f; -static constexpr float c42o1 = 42.f; -static constexpr float c46o1 = 46.f; -static constexpr float c48o1 = 48.f; -static constexpr float c50o1 = 50.f; -static constexpr float c52o1 = 52.f; -static constexpr float c54o1 = 54.f; -static constexpr float c56o1 = 56.f; -static constexpr float c64o1 = 64.f; -static constexpr float c66o1 = 66.f; -static constexpr float c68o1 = 68.f; -static constexpr float c69o1 = 69.f; -static constexpr float c72o1 = 72.f; -static constexpr float c84o1 = 84.f; -static constexpr float c88o1 = 88.f; -static constexpr float c96o1 = 96.f; -static constexpr float c100o1 = 100.0f; -static constexpr float c130o1 = 130.0f; -static constexpr float c152o1 = 152.0f; -static constexpr float c166o1 = 166.0f; -static constexpr float c195o1 = 195.0f; -static constexpr float c216o1 = 216.0f; -static constexpr float c264o1 = 264.0f; -static constexpr float c290o1 = 290.0f; -static constexpr float c367o1 = 367.0f; - -static constexpr float Op0000002 = 0.0000002f; -static constexpr float c10eM30 = 1e-30f; -static constexpr float c10eM10 = 1e-10f; -static constexpr float smallSingle = 0.0000000002f; - -static const float cPi = 4.0f * std::atan(1.0f);// 3.1415926535f; -static const double c2Pi = 2.0f * cPi;// 6.2831853071f; -static const float cPio180 = cPi / 180.0f;// 1.74532925199e-2f; -static const float c180oPi = 180.0f / cPi;// 57.2957795131f; - -static const float one_over_sqrt2 = 1.0 / sqrtf(2.0); // 0.707106781 -static const float one_over_sqrt3 = 1.0 / sqrtf(3.0); // 0.577350269 -static const float sqrt2 = sqrtf(2.0); // 1.4142135 -static const float sqrt3 = sqrtf(3.0); // 1.7320508 - -#endif - -} - -#endif diff --git a/utilities/ci-regression-tests/generate-ci.py b/utilities/ci-regression-tests/generate-ci.py new file mode 100644 index 0000000000000000000000000000000000000000..834728b5b22d7cf566019483a3c405e75c6fc837 --- /dev/null +++ b/utilities/ci-regression-tests/generate-ci.py @@ -0,0 +1,23 @@ +from jinja2 import Template +from pathlib import Path + +TEMPLATES_DIR = Path(__file__).parent +REGRESSION_CI_TEMPLATE = TEMPLATES_DIR / "regression-tests-ci.yml.j2" +GENERATED_DIR = Path("generated") +REGRESSION_CI_FILE = GENERATED_DIR / "regression-tests-ci.yml" +TEST_FILE_DIR = Path("regression-tests") + + +def build_regression_job_string(regression_tests: list[str]) -> str: + template = Template(REGRESSION_CI_TEMPLATE.read_text()) + return template.render(regression_tests=regression_tests) + + +def main(): + regression_tests_files = [item.stem for item in TEST_FILE_DIR.glob("*_test.sh")] + regression_tests_ci_file = build_regression_job_string(regression_tests_files) + REGRESSION_CI_FILE.write_text(regression_tests_ci_file) + +if __name__ == "__main__": + GENERATED_DIR.mkdir(parents=True, exist_ok=True) + main() \ No newline at end of file diff --git a/utilities/ci-regression-tests/regression-tests-ci.yml.j2 b/utilities/ci-regression-tests/regression-tests-ci.yml.j2 new file mode 100644 index 0000000000000000000000000000000000000000..4367ad6c7d5f820ef8975c37dbf843e5342e4dbd --- /dev/null +++ b/utilities/ci-regression-tests/regression-tests-ci.yml.j2 @@ -0,0 +1,26 @@ +image: git.rz.tu-bs.de:4567/irmb/virtualfluids/ubuntu20_04:1.5 + +stages: + - test + +.regression-test: + stage: test + + needs: [] + + tags: + - gpu + - linux + + before_script: + - chmod +x ./regression-tests/* + - pip install fieldcompare + +{% for regression_test in regression_tests %} +run-regression-test-{{ regression_test }}: + extends: .regression-test + + script: + - ./regression-tests/{{ regression_test }}.sh + +{% endfor %} diff --git a/utilities/ci-regression-tests/requirements.txt b/utilities/ci-regression-tests/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..bb0794f9960967b2c8aac7fc4bf1162d0e68c85f --- /dev/null +++ b/utilities/ci-regression-tests/requirements.txt @@ -0,0 +1 @@ +Jinja2==3.1.2 \ No newline at end of file