function [points_t, points_b, x_arc, y_arc, zl] = new_bmd(ang, l, r);
%a function that reurns the co-ordinate points and co-ordinate of arc.
%inputs
zo = 0;
zl = l;
%creating the arrays for x, y co-ordinates
x = linspace(0, r, 10);
y = linspace(0, r, 10);
%origin points
xo = x(1);
yo = y(1);
%The points at the edge of wedge.
xr = r*sind(ang);
yr = r*cosd(ang);
%Finding the points of the arc.
ang_1 = linspace(0, ang, ang);
for i = 1:length(ang_1)
if ang_1(i) == 0
x_arc = r*sind(ang_1(i));
y_arc = r*cosd(ang_1(i));
end
end
x_arc = x_arc;
y_arc = y_arc;
xl = -xr;
yl = yr;
%array that compiles the x, y, z co-ordinates
a = [xo, yo, zo, xr, yr, zo, xl, yl, zo];
b = [xo, yo, zl, xr, yr, zl, xl, yl, zl];
arc = zeros(3, 3);
arc_f = zeros(3,3);
%Converting the points into an array and the length of the wedge is
%along x-axis.
for p = 1:length(a)
arc(p) = a(p);
end
points_t = zeros(3, 3);
points_t(1, :) = arc(3, :);
points_t(2, :) = arc(2, :);
points_t(3, :) = arc(1, :);
for q = 1:length(b)
arc_f(q) = b(q);
end
points_b = zeros(3, 3);
points_b(1, :) = arc_f(3, :);
points_b(2, :) = arc_f(2, :);
points_b(3, :) = arc_f(1, :);
end
|
angle = [10, 25, 45];
for f = 1:length(angle)
piy = fopen(sprintf('blockMeshDict_sym%d.txt', f), 'wt');
[points_t, points_b, x_arc, y_arc, zl] = new_bmd(angle(f), 2.5, 0.01);
h = ["/*--------------------------------*- C++ -*----------------------------------*\";
" ========= |";
" \\ / F ield | OpenFOAM: The Open Source CFD Toolbox";
" \\ / O peration | Website: https://openfoam.org";
" \\ / A nd | Version: 8";
" \\/ M anipulation |";
"\*---------------------------------------------------------------------------*/";
"FoamFile";
"{";
" version 2.0;";
" format ascii;";
" class dictionary;";
" object blockMeshDict;";
"}";
"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //";
"convertToMeters 1;";
"vertices"];
for i = 1:length(h)
fprintf(piy, '%s\n', h(i));
end
fprintf(piy, '(\n');
for j = 1:3
fprintf(piy, '\t(%d %d %d)\n', points_t(1:3, j)');
end
fprintf(piy, '\n');
for k = 1:3
fprintf(piy, '\t(%d %d %d)\n', points_b(1:3, k)');
end
fprintf(piy, ');\n\n');
fprintf(piy, 'blocks\n(\n');
fprintf(piy, '\thex (%d %d %d %d %d %d %d %d) (500 20 1) simpleGrading (1 0.1 1)\n);\n', [0 3 5 2 0 3 4 1]);
fprintf(piy, 'edges\n(\n\tarc 1 2 (%d %d %d)\n\tarc 4 5 (%d %d %d)\n);\n\n', [x_arc y_arc 0 zl y_arc 0]);
fprintf(piy, 'boundary\n(\n\tinlet\n\t{\n\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(%d %d %d %d)\n\t\t);\n\t}\n', [0 1 2 0]);
fprintf(piy, '\toutlet\n\t{\n\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(%d %d %d %d)\n\t\t);\n\t}\n', [3 5 4 3]);
fprintf(piy, '\ttop\n\t{\n\t\ttype wall;\n\t\tfaces\n\t\t(\n\t\t\t(%d %d %d %d)\n\t\t);\n\t}\n', [1 4 5 2]);
fprintf(piy, '\tfront\n\t{\n\t\ttype symmetry;\n\t\tfaces\n\t\t(\n\t\t\t(%d %d %d %d)\n\t\t);\n\t}\n', [0 3 4 1]);
fprintf(piy, '\tback\n\t{\n\t\ttype symmetry;\n\t\tfaces\n\t\t(\n\t\t\t(%d %d %d %d)\n\t\t);\n\t}\n', [0 2 5 3]);
fprintf(piy, '\taxis\n\t{\n\t\ttype empty;\n\t\tfaces\n\t\t(\n\t\t\t(%d %d %d %d)\n\t\t);\n\t}\n);\n', [0 3 3 0]);
fprintf(piy, 'mergePatchPairs\n(\n);\n');
fprintf(piy, '%s', "// ************************************************************************* //");
fclose(piy);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%pressure_symmetry
press_sym = fopen(sprintf('p_sym.txt'), 'wt');
P_s = ["/*--------------------------------*- C++ -*----------------------------------*\";
" ========= |";
" \\ / F ield | OpenFOAM: The Open Source CFD Toolbox";
" \\ / O peration | Website: https://openfoam.org";
" \\ / A nd | Version: 8";
" \\/ M anipulation |";
"\*---------------------------------------------------------------------------*/";
"FoamFile";
"{";
" version 2.0;";
" format ascii;";
" class volScalarField;";
" object p;";
"}";
"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //";
"dimensions [0 2 -2 0 0 0 0];";
"internalField uniform 0;";
"boundaryField";
"{";
" inlet";
" {";
" type zeroGradient;";
" }";
" outlet";
" {";
" type fixedValue;";
" value uniform 0;";
" }";
" top";
" {";
" type zeroGradient;";
" }";
" front";
" {";
" type symmetry;";
" }";
" back";
" {";
" type symmetry;";
" }";
" axis";
" {";
" type empty;";
" }";
"}";
"// ************************************************************************* //"]
for p = 1:length(P_s)
fprintf(press_sym, '%s\n', P_s(p));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%velocity_symmetry
vel_sym = fopen('U_sym.txt', 'wt');
V_s = ["/*--------------------------------*- C++ -*----------------------------------*\";
" ========= |";
" \\ / F ield | OpenFOAM: The Open Source CFD Toolbox";
" \\ / O peration | Website: https://openfoam.org";
" \\ / A nd | Version: 8";
" \\/ M anipulation |";
"\*---------------------------------------------------------------------------*/";
"FoamFile";
"{";
" version 2.0;";
" format ascii;";
" class volVectorField;";
" object U;";
"}";
"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //";
"dimensions [0 1 -1 0 0 0 0];";
"internalField uniform (0.0935 0 0);";
"boundaryField";
"{";
" inlet";
" {";
" type fixedValue;";
" value uniform (0.0935 0 0);";
" }";
" outlet";
" {";
" type zeroGradient;";
" }";
" top";
" {";
" type fixedValue;";
" value uniform (0 0 0);";
" }";
" axis";
" {";
" type empty;";
" }";
" front";
" {";
" type symmetry;";
" }";
" back";
" {";
" type symmetry;";
" }";
"}";
"// ************************************************************************* //"]
for v = 1:length(V_s)
fprintf(vel_sym, '%s\n', V_s(v));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
piy = fopen(sprintf('blockMeshDict_wed%d.txt', f), 'wt');
h1 = ["/*--------------------------------*- C++ -*----------------------------------*\";
" ========= |";
" \\ / F ield | OpenFOAM: The Open Source CFD Toolbox";
" \\ / O peration | Website: https://openfoam.org";
" \\ / A nd | Version: 8";
" \\/ M anipulation |";
"\*---------------------------------------------------------------------------*/";
"FoamFile";
"{";
" version 2.0;";
" format ascii;";
" class dictionary;";
" object blockMeshDict;";
"}";
"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //";
"convertToMeters 1;";
"vertices"];
for i = 1:length(h1)
fprintf(piy, '%s\n', h1(i));
end
fprintf(piy, '(\n');
for j = 1:3
fprintf(piy, '\t(%d %d %d)\n', points_t(1:3, j)');
end
fprintf(piy, '\n');
for k = 1:3
fprintf(piy, '\t(%d %d %d)\n', points_b(1:3, k)');
end
fprintf(piy, ');\n\n');
fprintf(piy, 'blocks\n(\n');
fprintf(piy, '\thex (%d %d %d %d %d %d %d %d) (500 20 1) simpleGrading (1 0.1 1)\n);\n', [0 3 5 2 0 3 4 1]);
fprintf(piy, 'edges\n(\n\tarc 1 2 (%d %d %d)\n\tarc 4 5 (%d %d %d)\n);\n\n', [x_arc y_arc 0 zl y_arc 0]);
fprintf(piy, 'boundary\n(\n\tinlet\n\t{\n\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(%d %d %d %d)\n\t\t);\n\t}\n', [0 1 2 0]);
fprintf(piy, '\toutlet\n\t{\n\t\ttype patch;\n\t\tfaces\n\t\t(\n\t\t\t(%d %d %d %d)\n\t\t);\n\t}\n', [3 5 4 3]);
fprintf(piy, '\ttop\n\t{\n\t\ttype wall;\n\t\tfaces\n\t\t(\n\t\t\t(%d %d %d %d)\n\t\t);\n\t}\n', [1 4 5 2]);
fprintf(piy, '\tfront\n\t{\n\t\ttype wedge;\n\t\tfaces\n\t\t(\n\t\t\t(%d %d %d %d)\n\t\t);\n\t}\n', [0 3 4 1]);
fprintf(piy, '\tback\n\t{\n\t\ttype wedge;\n\t\tfaces\n\t\t(\n\t\t\t(%d %d %d %d)\n\t\t);\n\t}\n', [0 2 5 3]);
fprintf(piy, '\taxis\n\t{\n\t\ttype empty;\n\t\tfaces\n\t\t(\n\t\t\t(%d %d %d %d)\n\t\t);\n\t}\n);\n', [0 3 3 0]);
fprintf(piy, 'mergePatchPairs\n(\n);\n');
fprintf(piy, '%s', "// ************************************************************************* //");
fclose(piy);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%pressure wedge
press_wed = fopen(sprintf('p_wed.txt'), 'wt');
P_w = ["/*--------------------------------*- C++ -*----------------------------------*\";
" ========= |";
" \\ / F ield | OpenFOAM: The Open Source CFD Toolbox";
" \\ / O peration | Website: https://openfoam.org";
" \\ / A nd | Version: 8";
" \\/ M anipulation |";
"\*---------------------------------------------------------------------------*/";
"FoamFile";
"{";
" version 2.0;";
" format ascii;";
" class volScalarField;";
" object p;";
"}";
"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //";
"dimensions [0 2 -2 0 0 0 0];";
"internalField uniform 0;";
"boundaryField";
"{";
" inlet";
" {";
" type zeroGradient;";
" }";
" outlet";
" {";
" type fixedValue;";
" value uniform 0;";
" }";
" top";
" {";
" type zeroGradient;";
" }";
" front";
" {";
" type wedge;";
" }";
" back";
" {";
" type wedge;";
" }";
" axis";
" {";
" type empty;";
" }";
"}";
"// ************************************************************************* //"]
for p_w = 1:length(P_w)
fprintf(press_wed, '%s\n', P_w(p_w));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%velocity wedge
vel_wed = fopen('U_wed.txt', 'wt');
V_w = ["/*--------------------------------*- C++ -*----------------------------------*\";
" ========= |";
" \\ / F ield | OpenFOAM: The Open Source CFD Toolbox";
" \\ / O peration | Website: https://openfoam.org";
" \\ / A nd | Version: 8";
" \\/ M anipulation |";
"\*---------------------------------------------------------------------------*/";
"FoamFile";
"{";
" version 2.0;";
" format ascii;";
" class volVectorField;";
" object U;";
"}";
"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //";
"dimensions [0 1 -1 0 0 0 0];";
"internalField uniform (0.0935 0 0);";
"boundaryField";
"{";
" inlet";
" {";
" type fixedValue;";
" value uniform (0.0935 0 0);";
" }";
" outlet";
" {";
" type zeroGradient;";
" }";
" top";
" {";
" type fixedValue;";
" value uniform (0 0 0);";
" }";
" axis";
" {";
" type empty;";
" }";
" front";
" {";
" type wedge;";
" }";
" back";
" {";
" type wedge;";
" }";
"}";
"// ************************************************************************* //"]
for v_w = 1:length(V_w)
fprintf(vel_wed, '%s\n', V_w(v_w));
end
end
|