-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain_steadyStateIncompressibleNavierStokesFlow.m
More file actions
118 lines (98 loc) · 4.18 KB
/
Copy pathmain_steadyStateIncompressibleNavierStokesFlow.m
File metadata and controls
118 lines (98 loc) · 4.18 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
%% Licensing
%
% License: BSD License
% cane Multiphysics default license: cane/license.txt
%
% Main authors: Andreas Apostolatos
%
%% Script documentation
%
% Task : Solves the steady-state incompressible Navier-Stokes equations in
% 2D.
%
% Date : 18.04.2020
%
%% Preamble
clear;
clc;
close all;
%% Includes
% Add functions related to equation system solvers
addpath('../../equationSystemSolvers/');
% Add general math functions
addpath('../../generalMath/');
% Add the classical finite element basis functions
addpath('../../basisFunctions/');
% Add all functions related to plate in membrane action analysis
addpath('../../FEMPlateInMembraneActionAnalysis/solvers/',...
'../../FEMPlateInMembraneActionAnalysis/solutionMatricesAndVectors/',...
'../../FEMPlateInMembraneActionAnalysis/loads/',...
'../../FEMPlateInMembraneActionAnalysis/graphics/',...
'../../FEMPlateInMembraneActionAnalysis/output/',...
'../../FEMPlateInMembraneActionAnalysis/postprocessing/');
% Add all functions related to the Finite Element Methods for Computational
% Fluid Dynamics problems
addpath('../../FEMComputationalFluidDynamicsAnalysis/solutionMatricesAndVectors/',...
'../../FEMComputationalFluidDynamicsAnalysis/initialConditions',...
'../../FEMComputationalFluidDynamicsAnalysis/solvers/',...
'../../FEMComputationalFluidDynamicsAnalysis/loads/',...
'../../FEMComputationalFluidDynamicsAnalysis/postProcessing/',...
'../../FEMComputationalFluidDynamicsAnalysis/ALEMotion/');
% Add all functions related to parsing
addpath('../../parsers/');
% Add all functions related to the efficient computation functions
addpath('../../efficientComputation/');
%% Parse the data from the GiD input file
% Define the path to the case
pathToCase = '../../inputGiD/FEMComputationalFluidDynamicsAnalysis/';
% caseName = 'flowAroundCylinderAdaptiveSteadyStateALE';
% caseName = 'NACA2412_AoA5_CFD';
caseName = 'unitTest_flowAroundCylinderAdaptiveSteadyState';
% Parse the data from the GiD input file
[fldMsh, homDOFs, inhomDOFs, valuesInhomDOFs, propALE, propNBC, propAnalysis, ...
parameters, propNLinearAnalysis, propFldDynamics, propGaussInt, ~] = ...
parse_FluidModelFromGid...
(pathToCase, caseName, 'outputEnabled');
%% UI
% On the body forces
computeBodyForces = @computeConstantVerticalFluidBodyForceVct;
% On the initial conditions
% computeInitialConditions = @computeInitialConditionsFromVTKFileFEM4NSE2D;
computeInitialConditions = @computeNullInitialConditionsFEM4NSE;
% Output properties
propVTK.isOutput = true;
propVTK.writeOutputToFile = @writeOutputFEMIncompressibleFlowToVTK;
propVTK.VTKResultFile = 'undefined';
%% Choose the equation system solver
if strcmp(propAnalysis.type, 'NAVIER_STOKES_2D')
solve_LinearSystem = @solve_LinearSystemMatlabBackslashSolver;
elseif strcmp(propAnalysis.type, 'NAVIER_STOKES_3D')
solve_LinearSystem = @solve_LinearSystemGMResWithIncompleteLUPreconditioning;
else
error('Neither NAVIER_STOKES_2D or NAVIER_STOKES_3D has been chosen');
end
%% Initialize solution
[up, ~, ~, numIterStep] = computeInitialConditions...
(propAnalysis, fldMsh, 'undefined', 'undefined', 'undefined', ...
'undefined', 'undefined', 'undefined');
%% Compute ALE motion
if ~ischar(propALE) && ~isempty(propALE)
prescribedDoFs = mergesorted(homDOFs, inhomDOFs);
prescribedDoFs = unique(prescribedDoFs);
freeDOFs = 1:3*length(fldMsh.nodes(:, 1));
freeDOFs(ismember(freeDOFs, prescribedDoFs)) = [];
[fldMsh, uMeshALE, homDOFs, inhomDOFs, valuesInhomDOFs, freeDOFs] = ...
computeUpdatedMeshAndVelocitiesPseudoStrALE2D ...
(fldMsh, homDOFs, inhomDOFs, valuesInhomDOFs, freeDOFs, ...
fldMsh.nodes, propALE, solve_LinearSystem, ...
propFldDynamics, 0);
else
uMeshALE = 'undefined';
end
%% Solve the CFD problem
[up, FComplete, isConverged, minElSize] = solve_FEMVMSStabSteadyStateNSE ...
(fldMsh, up, homDOFs, inhomDOFs, valuesInhomDOFs, uMeshALE, parameters, ...
computeBodyForces, propAnalysis, solve_LinearSystem, propFldDynamics, ...
propNLinearAnalysis, numIterStep, propGaussInt, propVTK, caseName, ...
'outputEnabled');
%% END OF THE SCRIPT