Skip to content
Snippets Groups Projects
Commit eca2940e authored by Kyrylo Sovailo's avatar Kyrylo Sovailo :crossed_swords:
Browse files

Initial commit

parents
Branches
No related tags found
No related merge requests found
Showing
with 265 additions and 0 deletions
*.png binary
*.jpg binary
*.jpeg binary
*.pdf binary
# C++ compiler #
################
*.lib
*.obj
*.dll
*.exe
*.o
*.a
*.so
*.out
# OS generated #
################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Visual Studio #
#################
*.SLN
*VCXPROJ*
**/.vs/
**/Debug/
**/Release/
**/x64/
# Visual Studio Code #
######################
.vscode/
# CMake #
#########
build/
# Extra #
#########
demo/**/*.png
*.out
extra/
# This file is a part of Numsimulation project
# Developed as part of Numerical Flow Simulation course
# Author: Kyrylo Sovailo
# Header
cmake_minimum_required(VERSION 3.0)
project(NumericSimulation)
set(CMAKE_CXX_STANDARD 11)
# Dependencies
find_package(Eigen3 REQUIRED)
# Library
add_subdirectory(source/numsimulation)
#add_subdirectory(source/potential)
add_subdirectory(source/potential_rectangular)
#add_subdirectory(source/potential_warped)
#add_subdirectory(source/scalar)
#add_subdirectory(source/scalar_v2)
#add_subdirectory(source/simple)
#add_subdirectory(source/simple_partial)
# Demo
#add_subdirectory(demo/potential)
add_subdirectory(demo/potential_rectangular)
#add_subdirectory(demo/potential_warped)
#add_subdirectory(demo/scalar)
#add_subdirectory(demo/scalar_v2)
#add_subdirectory(demo/simple)
#add_subdirectory(demo/simple_partial)
add_custom_target(demo DEPENDS potential_rectangular_demo_all)
\ No newline at end of file
MIT License
Copyright (c) 2023 Kyrylo Sovailo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (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
AUTHORS OR COPYRIGHT HOLDERS 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.
Template repository suitable for C++, CMake and VS Code stack
Do not forget to:
1. Edit name and date in LICENSE.md
2. Edit executable name in launch.json
SCENARIO PARALLEL
VINFX 1 VINFY 0
NX 101 NY 101
XMIN 0 XMAX 1 YMIN 0 YMAX 1
MAX_ITERATION 100000
MAX_RESIDUAL 1.0
BETA 0.000025
\ No newline at end of file
SCENARIO STAGNATION_POINT
A 1
NX 101 NY 101
XMIN -1 XMAX 1 YMIN -1 YMAX 1
MAX_ITERATION 100000
MAX_RESIDUAL 1.0
BETA 0.000025
\ No newline at end of file
project(potential_rectangular_demo)
# Executable
add_executable(potential_rectangular_demo main.cpp)
target_link_libraries(potential_rectangular_demo PUBLIC potential_rectangular)
# Demo 1
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/1.out COMMAND $<TARGET_FILE:potential_rectangular_demo> ${PROJECT_SOURCE_DIR}/1.in ${PROJECT_SOURCE_DIR}/1.out DEPENDS $<TARGET_FILE:potential_rectangular_demo> ${PROJECT_SOURCE_DIR}/1.in VERBATIM)
add_custom_target(potential_rectangular_demo1r DEPENDS ${PROJECT_SOURCE_DIR}/1.out)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/1.png COMMAND ${CMAKE_SOURCE_DIR}/visualizer.py ${PROJECT_SOURCE_DIR}/1.out ${PROJECT_SOURCE_DIR}/1.png DEPENDS ${CMAKE_SOURCE_DIR}/visualizer.py ${PROJECT_SOURCE_DIR}/1.out VERBATIM)
add_custom_target(potential_rectangular_demo1v DEPENDS ${PROJECT_SOURCE_DIR}/1.png)
# Demo 2
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/2.out COMMAND $<TARGET_FILE:potential_rectangular_demo> ${PROJECT_SOURCE_DIR}/2.in ${PROJECT_SOURCE_DIR}/2.out DEPENDS $<TARGET_FILE:potential_rectangular_demo> ${PROJECT_SOURCE_DIR}/2.in VERBATIM)
add_custom_target(potential_rectangular_demo2 DEPENDS ${PROJECT_SOURCE_DIR}/2.out)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/2.png COMMAND ${CMAKE_SOURCE_DIR}/visualizer.py ${PROJECT_SOURCE_DIR}/2.out ${PROJECT_SOURCE_DIR}/2.png DEPENDS ${CMAKE_SOURCE_DIR}/visualizer.py ${PROJECT_SOURCE_DIR}/2.out VERBATIM)
add_custom_target(potential_rectangular_demo2v DEPENDS ${PROJECT_SOURCE_DIR}/2.png)
# Invokation
add_custom_target(potential_rectangular_demo_all DEPENDS potential_rectangular_demo1v potential_rectangular_demo2v)
\ No newline at end of file
/* This file is a part of Numsimulation project
Developed as part of Numerical Flow Simulation course
Author: Kyrylo Sovailo */
#include <potential_rectangular/potential_rectangular.h>
#include <numsimulation/common.h>
using namespace numsimulation;
using namespace potential_rectangular;
#include <stdexcept>
#include <iostream>
#include <math.h>
int _main(int argc, char **argv)
{
//Parsing arguments
if (argc != 3) throw std::runtime_error("Invalid argument number");
//Creating parameters object
ParameterReader reader(argv[1]);
AbstractParameters *parameters;
struct ParallelParameters : AbstractParameters
{
double vinf[2];
virtual double potential(double x, double y) const { return vinf[0] * x + vinf[1] * y; }
ParallelParameters(double vinfx, double vinfy) : vinf{vinfx, vinfy} {};
};
struct StagnationPointParameters : AbstractParameters
{
double a;
virtual double potential(double x, double y) const { return a * (pow(x, 2) - pow(y, 2)); }
StagnationPointParameters(double a) : a(a) {};
};
if (reader.get_string("SCENARIO") == "PARALLEL") parameters = new ParallelParameters(reader.get_real("VINFX"), reader.get_real("VINFY"));
else if (reader.get_string("SCENARIO") == "STAGNATION_POINT") parameters = new StagnationPointParameters(reader.get_real("A"));
//Reading parameters
parameters->n[0] = reader.get_integer("NX");
parameters->n[1] = reader.get_integer("NY");
parameters->min[0] = reader.get_real("XMIN");
parameters->max[0] = reader.get_real("XMAX");
parameters->min[1] = reader.get_real("YMIN");
parameters->max[1] = reader.get_real("YMAX");
parameters->max_iteration = reader.get_integer("MAX_ITERATION");
parameters->max_residual = reader.get_real("MAX_RESIDUAL");
parameters->beta = reader.get_real("BETA");
parameters->exact = true;
reader.warn_unused();
//Setting simulation up
Solver solver(parameters, argv[2]);
solver.solve();
solver.output();
return 0;
}
int main(int argc, char **argv)
{
try
{
return _main(argc, argv);
}
catch (const std::exception &e)
{
std::cerr << e.what() << "\n";
return 1;
}
}
\ No newline at end of file
SCENARIO PARALLEL
VINFX 1
NXI 101 NETA 101
XIMIN 0 XIMAX 1 ETAMIN 0 ETAMAX 1
MAX_ITERATION 100000
MAX_RESIDUAL 1.0
BETA 0.000025
\ No newline at end of file
SCENARIO STAGNATION_POINT
A 1
NXI 101 NETA 101
XIMIN 0.5 XIMAX 1 ETAMIN -0.5 ETAMAX 0.5
MAX_ITERATION 100000
MAX_RESIDUAL 1.0
BETA 0.00001
\ No newline at end of file
SCENARIO PIPE
YBOTTOM 1
YTOP 2
VINFX 1
NXI 101 NETA 101
XIMIN 0 XIMAX 1 ETAMIN 0 ETAMAX 1
MAX_ITERATION 100000
MAX_RESIDUAL 1.0
BETA 0.000025
\ No newline at end of file
project(1_2)
add_executable(1_2 src/main.cpp)
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/1.2.1.out COMMAND $<TARGET_FILE:1_2> ${PROJECT_SOURCE_DIR}/1.2.1.in ${PROJECT_BINARY_DIR}/1.2.1.out DEPENDS $<TARGET_FILE:1_2> ${PROJECT_SOURCE_DIR}/1.2.1.in VERBATIM)
add_custom_target(1_2_1_test DEPENDS ${PROJECT_BINARY_DIR}/1.2.1.out)
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/1.2.1.png COMMAND python ${CMAKE_SOURCE_DIR}/vis/vis.py ${PROJECT_BINARY_DIR}/1.2.1.out ${PROJECT_BINARY_DIR}/1.2.1.png DEPENDS ${PROJECT_BINARY_DIR}/1.2.1.out VERBATIM)
add_custom_target(1_2_1_vis DEPENDS ${PROJECT_BINARY_DIR}/1.2.1.png)
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/1.2.2.out COMMAND $<TARGET_FILE:1_2> ${PROJECT_SOURCE_DIR}/1.2.2.in ${PROJECT_BINARY_DIR}/1.2.2.out DEPENDS $<TARGET_FILE:1_2> ${PROJECT_SOURCE_DIR}/1.2.2.in VERBATIM)
add_custom_target(1_2_2_test DEPENDS ${PROJECT_BINARY_DIR}/1.2.2.out)
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/1.2.2.png COMMAND python ${CMAKE_SOURCE_DIR}/vis/vis.py ${PROJECT_BINARY_DIR}/1.2.2.out ${PROJECT_BINARY_DIR}/1.2.2.png DEPENDS ${PROJECT_BINARY_DIR}/1.2.2.out VERBATIM)
add_custom_target(1_2_2_vis DEPENDS ${PROJECT_BINARY_DIR}/1.2.2.png)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment