Commit 7452bd51 authored by Steffen Schotthöfer's avatar Steffen Schotthöfer
Browse files

Merge branch 'mergebranch_sprint1' of https://git.scc.kit.edu/rtsn/rtsn into sprint1

parents c3931573 6ed485c8
Pipeline #120260 passed with stage
in 18 minutes and 2 seconds
This diff is collapsed.
This diff is collapsed.
# importing PIL
from PIL import Image
import pydicom
import numpy as np
from pydicom.pixel_data_handlers.util import apply_modality_lut
from copy import deepcopy
def main():
image_name = "mini_phantom.png"
ending = image_name.split('.')[-1];
if(ending == 'dcm'): #dicom ct image
dataset = pydicom.dcmread(image_name)
hu = apply_modality_lut(dataset.pixel_array, dataset)
density = (dataset.RescaleIntercept + dataset.RescaleSlope*hu)/1000 +1
(spacingX, spacingY) = dataset.PixelSpacing
(sizeX,sizeY) = density.shape
dimensions = (spacingX*sizeX, spacingY*sizeY)
return density, dimensions
else: # jpg or png
img = Image.open(image_name).convert('L') #image data
I = np.asarray(img) # image as greyscale
I = I/255; # rescale values to [0,1]
J = deepcopy(np.flipud(I))
np.savetxt("foo.csv", J, delimiter=",")
dimensions = (1,1) # [cm]
return J , dimensions
if __name__ == '__main__':
main()
import pygmsh as pg
import numpy as np
import itertools
import os
def add_block(x0,y0,length,char_length,geom):
coords = np.array([
[x0, y0, 0.0],
[x0+length, y0, 0.0],
[x0+length, y0+length, 0.0],
[x0, y0+length, 0.0]
])
return geom.add_polygon(coords, char_length)
char_length = 0.2
geom = pg.opencascade.Geometry()
domain = add_block(-0.6, -0.6, 1.2, char_length, geom)
geom.add_raw_code('psource = newp;\nPoint(psource) = {0.0, 0.0, 0.0, '+str(char_length)+'};\nPoint{psource} In Surface{'+domain.id+'};')
geom.add_physical(domain.lines, label="void")
mesh_code = geom.get_code()
with open("linesource.geo","w") as mesh_file:
mesh_file.write(mesh_code)
os.system('gmsh linesource.geo -2 -format su2 -save_all')
os.system('rm linesource.geo')
This diff is collapsed.
import pygmsh as pg
import numpy as np
import itertools
import os
def add_block(x0,y0,length,char_length,geom):
coords = np.array([
[x0, y0, 0.0],
[x0+length, y0, 0.0],
[x0+length, y0+length, 0.0],
[x0, y0+length, 0.0]
])
return geom.add_polygon(coords, char_length)
char_length = 0.5
geom = pg.opencascade.Geometry()
domain = add_block(0.0, 0.0, 1.0, char_length, geom)
geom.add_physical(domain.lines, label="void")
mesh_code = geom.get_code()
with open("unit.geo","w") as mesh_file:
mesh_file.write(mesh_code)
os.system('gmsh unit.geo -2 -format su2 -save_all')
os.system('rm unit.geo')
% ---- File specifications ----
OUTPUT_DIR = ../../tests/result
OUTPUT_DIR = ../../../result
OUTPUT_FILE = ctscan_test
LOG_DIR = ../../tests/result/logs
MESH_FILE = ../../tests/result/ctscan_test.su2
LOG_DIR = ../../../result/logs
MESH_FILE = ../../../result/ctscan_test.su2
% ---- Solver specifications ----
CFL_NUMBER = 0.5
......
......@@ -18,7 +18,7 @@ OUTPUT_FILE = rtsn_test_unit_config
% Log directory
LOG_DIR = ../result/logs
% Mesh File
MESH_FILE = unit.su2
MESH_FILE = ../../mesh_files/unit.su2
%
% ---- Solver specifications ----
%
......
......@@ -10,10 +10,10 @@
% Only specify options that are important for this unit test!
%
% ---- File specifications ----
OUTPUT_DIR = ../../tests/result
OUTPUT_DIR = ../../../result
OUTPUT_FILE = rtsn_test_unit_mesh
LOG_DIR = ../../tests/result/logs
MESH_FILE = unit_mesh.su2
LOG_DIR = ../../../result/logs
MESH_FILE = ../../mesh_files/unit_mesh.su2
%
% ---- Boundary Conditions ----
BC_DIRICHLET = ( void )
......
......@@ -11,9 +11,9 @@
%
% ---- File specifications ----
%
OUTPUT_DIR = ../../tests/result
OUTPUT_DIR = ../../../result
OUTPUT_FILE = rtsn_test_unit_kernel
LOG_DIR = ../../tests/result/logs
LOG_DIR = ../../../result/logs
%
% ---- Quadrature Settings ----
QUAD_TYPE = LEBEDEV
......
......@@ -10,9 +10,9 @@
% Only specify options that are important for this unit test!
%
% ---- File specifications ----
OUTPUT_DIR = ../../tests/result
OUTPUT_DIR = ../../../result
OUTPUT_FILE = rtsn_test_unit_optimizerNewton
LOG_DIR = ../../tests/result/logs
LOG_DIR = ../../../result/logs
%
% ---- Solver specifications ----
%
......
......@@ -10,9 +10,9 @@
% Only specify options that are important for this unit test!
%
% ---- File specifications ----
OUTPUT_DIR = ../../tests/result
OUTPUT_DIR = ../../../result
OUTPUT_FILE = rtsn_test_unit_harmonics
LOG_DIR = ../../tests/result/logs
LOG_DIR = ../../../result/logs
% ---- Boundary Conditions ----
% This is just a dummy value!
......
......@@ -9,9 +9,9 @@
% Use this config file ONLY for test_harmonics.cpp!
%
% ---- File specifications ----
OUTPUT_DIR = ../../tests/result
OUTPUT_DIR = ../../../result
OUTPUT_FILE = rtsn_test_unit_harmonics
LOG_DIR = ../../tests/result/logs
LOG_DIR = ../../../result/logs
% ---- Boundary Conditions ----
QUAD_TYPE = GAUSS_LEGENDRE_TENSORIZED
......
......@@ -2,7 +2,7 @@
#include "common/config.h"
TEST_CASE( "Read in Config Template" ) {
std::string filename = std::string( TESTS_PATH ) + "input/unit_config.cfg";
std::string filename = std::string( TESTS_PATH ) + "input/unit_tests/common/unit_config.cfg";
// Load Settings from File
Config* config = new Config( filename );
......
......@@ -30,7 +30,7 @@ double P2_2( double my ) { return sqrt( 15 / ( 16 * M_PI ) ) * ( 1 - my * my );
TEST_CASE( "test the spherical harmonics basis computation", "[spherical_harmonics]" ) {
std::string filename = std::string( TESTS_PATH ) + "input/unit_harmonics.cfg";
std::string filename = std::string( TESTS_PATH ) + "input/unit_tests/solvers/unit_harmonics.cfg";
// Load Settings from File
Config* config = new Config( filename );
......@@ -86,7 +86,7 @@ TEST_CASE( "test the spherical harmonics basis computation", "[spherical_harmoni
Vector values( 9, 0.0 );
Vector result( 4, 0.0 );
case_file.open( "harmonicBasis_reference.csv", std::ios::in );
case_file.open( "unit_test/solvers/harmonicBasis_reference.csv", std::ios::in );
getline( case_file, text_line );
......
......@@ -9,11 +9,11 @@
#include "toolboxes/textprocessingtoolbox.h"
TEST_CASE( "convert image data to grayscale matrix", "[image I/O]" ) {
std::string config_file_name = std::string( TESTS_PATH ) + "input/image_conversion.cfg";
std::string config_file_name = std::string( TESTS_PATH ) + "input/unit_tests/common/image_conversion.cfg";
Config* config = new Config( config_file_name ); // just to init spdlog
std::string testImage = std::string( TESTS_PATH ) + "input/mini_phantom.png";
std::string testImage = std::string( TESTS_PATH ) + "input/unit_tests/common/mini_phantom.png";
std::string testMesh = config->GetMeshFile();
Matrix gsImage = createSU2MeshFromImage( testImage, testMesh );
......@@ -26,7 +26,7 @@ TEST_CASE( "convert image data to grayscale matrix", "[image I/O]" ) {
REQUIRE( blaze::max( gsImage ) <= 1.0 ); // upper bound
// load reference matrix from csv file
std::string refMatrixFile = std::string( TESTS_PATH ) + "input/phantom.csv";
std::string refMatrixFile = std::string( TESTS_PATH ) + "input/unit_tests/common/phantom.csv";
std::ifstream data( refMatrixFile );
REQUIRE( data.is_open() );
std::string line;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment