FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
meshopt_precond_factory.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
9
10#include <kernel/solver/nlopt_precond.hpp>
11
12#include <control/meshopt/dudv_functional_control.hpp>
13
14#include <deque>
15
16namespace FEAT
17{
18 namespace Control
19 {
20 namespace Meshopt
21 {
26 {
53 template
54 <
55 typename MeshoptCtrl_,
56 typename DomCtrl_ = typename MeshoptCtrl_::DomainControlType,
57 typename SolverVectorType_ = typename MeshoptCtrl_::SystemLevelType::GlobalSystemVectorL,
58 typename FilterType_ = typename MeshoptCtrl_::SystemLevelType::GlobalSystemFilter
59 >
60 static std::shared_ptr<Solver::NLOptPrecond<SolverVectorType_, FilterType_>>
61 create_nlopt_precond(MeshoptCtrl_& my_ctrl, DomCtrl_& dom_ctrl, PropertyMap* current_section)
62 {
63 std::shared_ptr<Solver::NLOptPrecond<SolverVectorType_, FilterType_> > result;
64
65 auto& solver_config = my_ctrl.solver_config;
66
67 auto precon_p = current_section->query("precon");
68
69 if(precon_p.second && precon_p.first != "none")
70 {
71 auto precon_section = solver_config.query_section(precon_p.first);
72 if(precon_section == nullptr)
73 XABORTM("precon_section "+precon_p.first+" not found!");
74
75 /*auto precon_type_p = precon_section->query("type");
76 if(!precon_type_p.second)
77 XABORTM("Section "+precon_p.first+" does not have a type key!");
78
79 if(precon_type_p.first == "DuDvPrecon")*/
80 {
81 auto precon_solver_p = precon_section->query("linear_solver");
82 if(!precon_solver_p.second)
83 XABORTM("precon_section has no linear_solver key!");
84
85 auto dirichlet_list_p = precon_section->query("dirichlet_boundaries");
86 std::deque<String> precon_dirichlet_list = dirichlet_list_p.first.split_by_whitespaces();
87
88 auto slip_list_p = precon_section->query("slip_boundaries");
89 std::deque<String> precon_slip_list = slip_list_p.first.split_by_whitespaces();
90
91 bool fixed_reference_domain(false);
92 auto fixed_reference_domain_p = precon_section->query("fixed_reference_domain");
93 if(fixed_reference_domain_p.second)
94 {
95 fixed_reference_domain = (std::stoi(fixed_reference_domain_p.first) == 1);
96 }
97
98 int level(my_ctrl.meshopt_lvl);
99
101 <
102 typename MeshoptCtrl_::DataType,
103 typename MeshoptCtrl_::IndexType,
104 DomCtrl_
105 > PreconControlType;
106
107 result = Solver::new_nonlinear_operator_precond_wrapper<PreconControlType>
108 (dom_ctrl, level, precon_dirichlet_list, precon_slip_list,
109 precon_solver_p.first, solver_config, fixed_reference_domain);
110 }
111 /*else if(precon_p.first != "none")
112 {
113 XABORTM("Unsupport nonlinear optimizer precon: "+precon_p.first);
114 }*/
115 }
116 else
117 {
118 auto inner_solver_p = current_section->query("inner_solver");
119 if(inner_solver_p.second)
120 {
121 auto inner_solver_section = solver_config.query_section(inner_solver_p.first);
122 result = create_nlopt_precond(my_ctrl, dom_ctrl, inner_solver_section);
123 }
124 }
125
126 return result;
127 } // create_nlopt_precond
128 };
129 } // namespace Meshopt
130 } // namespace Control
131} //namespace FEAT
#define XABORTM(msg)
Abortion macro definition with custom message.
Definition: assertion.hpp:192
FEAT Kernel base header.
A class organizing a tree of key-value pairs.
std::pair< String, bool > query(String key_path) const
Queries a value by its key path.
FEAT namespace.
Definition: adjactor.hpp:12
Factory class for specialized preconditioners.
static std::shared_ptr< Solver::NLOptPrecond< SolverVectorType_, FilterType_ > > create_nlopt_precond(MeshoptCtrl_ &my_ctrl, DomCtrl_ &dom_ctrl, PropertyMap *current_section)
Creates a preconditioner for nonlinear mesh optimization problems.