Skip to content
Snippets Groups Projects
Commit 54c38a47 authored by Timo Koch's avatar Timo Koch
Browse files

[test][ff][cylinderbenchmark] Use iterative solver for Stokes problem

parent 8ebbfcc8
No related branches found
No related tags found
1 merge request!3404Feature/seq stokes solver
Pipeline #27355 passed
+2
...@@ -24,7 +24,8 @@ dumux_add_test(NAME test_ff_stokes_dfg_benchmark_stationary_diamond ...@@ -24,7 +24,8 @@ dumux_add_test(NAME test_ff_stokes_dfg_benchmark_stationary_diamond
--files ${CMAKE_SOURCE_DIR}/test/references/test_ff_stokes_dfg_benchmark_stationary_diamond.vtu --files ${CMAKE_SOURCE_DIR}/test/references/test_ff_stokes_dfg_benchmark_stationary_diamond.vtu
${CMAKE_CURRENT_BINARY_DIR}/test_ff_stokes_dfg_benchmark_stationary_diamond-00001.vtu ${CMAKE_CURRENT_BINARY_DIR}/test_ff_stokes_dfg_benchmark_stationary_diamond-00001.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_ff_navierstokes_dfg_benchmark_stationary_diamond params.input --command "${CMAKE_CURRENT_BINARY_DIR}/test_ff_navierstokes_dfg_benchmark_stationary_diamond params.input
-Problem.Name test_ff_stokes_dfg_benchmark_stationary_diamond -Problem.EnableInertiaTerms false") -Problem.Name test_ff_stokes_dfg_benchmark_stationary_diamond -Problem.EnableInertiaTerms false
-LinearSolver.UseIterativeSolver true")
# Navier-Stokes version of the test (Re=20) # Navier-Stokes version of the test (Re=20)
dumux_add_test(NAME test_ff_navierstokes_dfg_benchmark_stationary_pq1bubble_box dumux_add_test(NAME test_ff_navierstokes_dfg_benchmark_stationary_pq1bubble_box
...@@ -50,7 +51,8 @@ dumux_add_test(NAME test_ff_stokes_dfg_benchmark_stationary_pq1bubble_box ...@@ -50,7 +51,8 @@ dumux_add_test(NAME test_ff_stokes_dfg_benchmark_stationary_pq1bubble_box
--files ${CMAKE_SOURCE_DIR}/test/references/test_ff_stokes_dfg_benchmark_stationary_pq1bubble_box.vtu --files ${CMAKE_SOURCE_DIR}/test/references/test_ff_stokes_dfg_benchmark_stationary_pq1bubble_box.vtu
${CMAKE_CURRENT_BINARY_DIR}/test_ff_stokes_dfg_benchmark_stationary_pq1bubble_box-00001.vtu ${CMAKE_CURRENT_BINARY_DIR}/test_ff_stokes_dfg_benchmark_stationary_pq1bubble_box-00001.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_ff_navierstokes_dfg_benchmark_stationary_pq1bubble_box params.input --command "${CMAKE_CURRENT_BINARY_DIR}/test_ff_navierstokes_dfg_benchmark_stationary_pq1bubble_box params.input
-Problem.Name test_ff_stokes_dfg_benchmark_stationary_pq1bubble_box -Problem.EnableInertiaTerms false") -Problem.Name test_ff_stokes_dfg_benchmark_stationary_pq1bubble_box -Problem.EnableInertiaTerms false
-LinearSolver.UseIterativeSolver true")
# Navier-Stokes version of the test (Re=20) # Navier-Stokes version of the test (Re=20)
dumux_add_test(NAME test_ff_navierstokes_dfg_benchmark_stationary_pq1bubble_diamond dumux_add_test(NAME test_ff_navierstokes_dfg_benchmark_stationary_pq1bubble_diamond
......
...@@ -33,7 +33,8 @@ ...@@ -33,7 +33,8 @@
#include <dumux/io/vtkoutputmodule.hh> #include <dumux/io/vtkoutputmodule.hh>
#include <dumux/io/grid/gridmanager_ug.hh> #include <dumux/io/grid/gridmanager_ug.hh>
#include <dumux/linear/seqsolverbackend.hh> #include <dumux/linear/istlsolvers.hh>
#include <dumux/linear/stokes_solver.hh>
#include <dumux/multidomain/fvassembler.hh> #include <dumux/multidomain/fvassembler.hh>
#include <dumux/multidomain/traits.hh> #include <dumux/multidomain/traits.hh>
...@@ -43,6 +44,55 @@ ...@@ -43,6 +44,55 @@
#include "properties.hh" #include "properties.hh"
template<class Vector, class MomGG, class MassGG, class MomP, class MomIdx, class MassIdx>
auto dirichletDofs(std::shared_ptr<MomGG> momentumGridGeometry,
std::shared_ptr<MassGG> massGridGeometry,
std::shared_ptr<MomP> momentumProblem,
MomIdx momentumIdx, MassIdx massIdx)
{
Vector dirichletDofs;
dirichletDofs[momentumIdx].resize(momentumGridGeometry->numDofs());
dirichletDofs[massIdx].resize(massGridGeometry->numDofs());
dirichletDofs = 0.0;
auto fvGeometry = localView(*momentumGridGeometry);
for (const auto& element : elements(momentumGridGeometry->gridView()))
{
if constexpr (MomGG::discMethod == Dumux::DiscretizationMethods::pq1bubble)
{
fvGeometry.bind(element);
for (const auto& scv : scvs(fvGeometry))
{
if (momentumGridGeometry->dofOnBoundary(scv.dofIndex()))
{
const auto bcTypes = momentumProblem->boundaryTypes(element, scv);
for (int i = 0; i < bcTypes.size(); ++i)
if (bcTypes.isDirichlet(i))
dirichletDofs[momentumIdx][scv.dofIndex()][i] = 1.0;
}
}
}
else if constexpr (MomGG::discMethod == Dumux::DiscretizationMethods::fcdiamond)
{
fvGeometry.bind(element);
for (const auto& scvf : scvfs(fvGeometry))
{
if (scvf.boundary())
{
const auto bcTypes = momentumProblem->boundaryTypes(element, scvf);
for (int i = 0; i < bcTypes.size(); ++i)
if (bcTypes.isDirichlet(i))
dirichletDofs[momentumIdx][fvGeometry.scv(scvf.insideScvIdx()).dofIndex()][i] = 1.0;
}
}
}
else
DUNE_THROW(Dune::NotImplemented, "dirichletDof help for discretization " << MomGG::discMethod);
}
return dirichletDofs;
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
using namespace Dumux; using namespace Dumux;
...@@ -132,12 +182,26 @@ int main(int argc, char** argv) ...@@ -132,12 +182,26 @@ int main(int argc, char** argv)
vtkWriter.addVelocityOutput(std::make_shared<NavierStokesVelocityOutput<MassGridVariables>>()); vtkWriter.addVelocityOutput(std::make_shared<NavierStokesVelocityOutput<MassGridVariables>>());
vtkWriter.write(0.0); vtkWriter.write(0.0);
// the linear solver // the linearize and solve
using LinearSolver = UMFPackBackend; if (getParam<bool>("LinearSolver.UseIterativeSolver", false))
auto linearSolver = std::make_shared<LinearSolver>(); {
using NewtonSolver = MultiDomainNewtonSolver<Assembler, LinearSolver, CouplingManager>; using Matrix = typename Assembler::JacobianMatrix;
NewtonSolver nonLinearSolver(assembler, linearSolver, couplingManager); using Vector = typename Assembler::ResidualType;
nonLinearSolver.solve(x); using LinearSolver = StokesSolver<Matrix, Vector, MomentumGridGeometry, MassGridGeometry>;
auto dDofs = dirichletDofs<Vector>(momentumGridGeometry, massGridGeometry, momentumProblem, momentumIdx, massIdx);
auto linearSolver = std::make_shared<LinearSolver>(momentumGridGeometry, massGridGeometry, dDofs);
using NewtonSolver = MultiDomainNewtonSolver<Assembler, LinearSolver, CouplingManager>;
NewtonSolver nonLinearSolver(assembler, linearSolver, couplingManager);
nonLinearSolver.solve(x);
}
else
{
using LinearSolver = UMFPackIstlSolver<SeqLinearSolverTraits, LinearAlgebraTraitsFromAssembler<Assembler>>;
auto linearSolver = std::make_shared<LinearSolver>();
using NewtonSolver = MultiDomainNewtonSolver<Assembler, LinearSolver, CouplingManager>;
NewtonSolver nonLinearSolver(assembler, linearSolver, couplingManager);
nonLinearSolver.solve(x);
}
// write vtk output // write vtk output
vtkWriter.write(1.0); vtkWriter.write(1.0);
......
...@@ -24,6 +24,26 @@ BaseEpsilon = 0.01 ...@@ -24,6 +24,26 @@ BaseEpsilon = 0.01
PriVarMagnitude = 0.2 0.2 PriVarMagnitude = 0.2 0.2
BaseEpsilon = 0.01 BaseEpsilon = 0.01
[LinearSolver]
MaxIterations = 500
ResidualReduction = 1e-10
SymmetrizeDirichlet = true
DirectSolverForVelocity = false
GMResRestart = 500
Type = gmres
Verbosity = 1
[LinearSolver.Preconditioner]
Mode = Triangular
Iterations = 5
AmgSmootherIterations = 2
AmgDefaultAggregationDimension = 2
AmgMinAggregateSize = 2
AmgMaxAggregateSize = 2
AmgAdditive = false
AmgGamma = 1 # 1: V-cycle 2: W-cycle
AmgCriterionSymmetric = true
[Newton] [Newton]
MinSteps = 1 MinSteps = 1
EnableAbsoluteResidualCriterion = true EnableAbsoluteResidualCriterion = true
......
...@@ -39,8 +39,7 @@ ...@@ -39,8 +39,7 @@
#include <dumux/discretization/cctpfa.hh> #include <dumux/discretization/cctpfa.hh>
#include <dumux/discretization/box.hh> #include <dumux/discretization/box.hh>
#include <dumux/freeflow/navierstokes/momentum/diamond/model.hh> #include <dumux/freeflow/navierstokes/momentum/cvfe/model.hh>
#include <dumux/freeflow/navierstokes/momentum/pq1bubble/model.hh>
#include <dumux/freeflow/navierstokes/mass/1p/model.hh> #include <dumux/freeflow/navierstokes/mass/1p/model.hh>
#include <dumux/freeflow/navierstokes/momentum/problem.hh> #include <dumux/freeflow/navierstokes/momentum/problem.hh>
#include <dumux/freeflow/navierstokes/mass/problem.hh> #include <dumux/freeflow/navierstokes/mass/problem.hh>
...@@ -57,8 +56,8 @@ namespace Dumux::Properties { ...@@ -57,8 +56,8 @@ namespace Dumux::Properties {
// Create new type tags // Create new type tags
namespace TTag { namespace TTag {
struct DFGChannelTest {}; struct DFGChannelTest {};
struct DFGChannelTestMomentumDiamond { using InheritsFrom = std::tuple<DFGChannelTest, NavierStokesMomentumDiamond, FaceCenteredDiamondModel>; }; struct DFGChannelTestMomentumDiamond { using InheritsFrom = std::tuple<DFGChannelTest, NavierStokesMomentumCVFE, FaceCenteredDiamondModel>; };
struct DFGChannelTestMomentumPQ1Bubble { using InheritsFrom = std::tuple<DFGChannelTest, NavierStokesMomentumPQ1Bubble, PQ1BubbleModel>; }; struct DFGChannelTestMomentumPQ1Bubble { using InheritsFrom = std::tuple<DFGChannelTest, NavierStokesMomentumCVFE, PQ1BubbleModel>; };
struct DFGChannelTestMassTpfa { using InheritsFrom = std::tuple<DFGChannelTest, NavierStokesMassOneP, CCTpfaModel>; }; struct DFGChannelTestMassTpfa { using InheritsFrom = std::tuple<DFGChannelTest, NavierStokesMassOneP, CCTpfaModel>; };
struct DFGChannelTestMassBox { using InheritsFrom = std::tuple<DFGChannelTest, NavierStokesMassOneP, BoxModel>; }; struct DFGChannelTestMassBox { using InheritsFrom = std::tuple<DFGChannelTest, NavierStokesMassOneP, BoxModel>; };
struct DFGChannelTestMassDiamond { using InheritsFrom = std::tuple<DFGChannelTest, NavierStokesMassOneP, FaceCenteredDiamondModel>; }; struct DFGChannelTestMassDiamond { using InheritsFrom = std::tuple<DFGChannelTest, NavierStokesMassOneP, FaceCenteredDiamondModel>; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment