b2api
B2000++ API Reference Manual, VERSION 4.6
 
Loading...
Searching...
No Matches
b2solver.H
Go to the documentation of this file.
1//------------------------------------------------------------------------
2// b2solver.H --
3//
4//
5// written by Mathias Doreille
6// Thomas Blome <thomas.blome@dlr.de>
7//
8// Copyright (c) 2004-2012,2016 SMR Engineering & Development SA
9// 2502 Bienne, Switzerland
10//
11// Copyright (c) 2023 Deutsches Zentrum für Luft- und Raumfahrt (DLR) e.V.
12// Linder Höhe, 51147 Köln
13//
14// All Rights Reserved. Proprietary source code. The contents of
15// this file may not be disclosed to third parties, copied or
16// duplicated in any form, in whole or in part, without the prior
17// written permission of SMR.
18//------------------------------------------------------------------------
19
20#ifndef __B2SOLVER_H__
21#define __B2SOLVER_H__
22
23#include <functional>
24
25#include "b2ppconfig.h"
26#include "model/b2case.H"
27#include "model/b2domain.H"
28#include "model/b2element.H"
30#include "model/b2model.H"
31#include "utils/b2object.H"
32#include "utils/b2threading.H"
33
36
37namespace b2000 {
38
39class Model;
40class Case;
41
42namespace solver {
43extern Module module;
44}
45
50class Solver : public Object {
51public:
53
55 void set_model(Model& model) { model_ = &model; };
56
57 b2000::Model& GetModel() const { return *model_; };
58
60 void set_case(Case& b2case) { case_ = &b2case; };
61
63 const bool IsLinear() const { return is_linear_; }
64
66 bool IsDynamic() const { return is_dynamic_; }
67
69 bool IsDamped() const { return is_damped_; }
70
72 bool IsImplicit() const { return is_implicit_; }
73
74 double GetTime() const { return time_; }
75
76 double GetStepSize() const { return step_size_; }
77
79 virtual void solve() = 0;
80
81 static type_t type;
82
83protected:
85 virtual bool solve_iteration() = 0;
86
89 virtual void InitializeSolverOnCase();
90
94
95 double time_{};
96 double time_max_{1.0};
97 double step_size_{1.0};
98
99 bool is_linear_{};
100 bool is_implicit_{true};
101 bool is_damped_{};
102 bool is_dynamic_{};
103
104 size_t total_num_dof_{};
106 size_t number_of_fixed_dof_{};
107
108 size_t iteration_count_{};
109 const size_t kMaxIterations_{50};
110
112
113 CaseList::case_iterator case_iterator_{};
114};
115
117 if (model_ == nullptr) { Exception() << THROW; }
118
120
121 const std::string analysis_type = case_->get_string("ANALYSIS");
122 is_linear_ =
123 !analysis_type.ends_with("NONLINEAR") && !analysis_type.ends_with("NONLINEAR_SOLUTION");
124 is_dynamic_ = analysis_type.starts_with("MDYNAMIC");
125 is_damped_ = analysis_type.starts_with("MTRANSIENT");
126
127 time_ = 0;
128 time_max_ = is_dynamic_ || is_damped_
130 : 1;
131 step_size_ = is_dynamic_ || is_damped_ ? case_->get_double("STEP_SIZE") : 1;
132 iteration_count_ = 0;
133
134 // std::string domain_state_id;
135 Domain& domain{model_->get_domain()};
136
137 // Hier das evtl. auch für transient
138 // if (is_dynamic_) {
139 // dynamic_cast<TypedInitialCondition<T>&>(model_->get_initial_condition())
140 // .get_dynamic_initial_condition_value(dof, time_, current_stage_, domain_state_id);
141 // }
142
143 // case_->set_stage(current_stage_);
144 // if (!domain_state_id.empty()) { domain.load_state(domain_state_id); }
145
147}
148
168class SolverHints : public Object {
169public:
171 enum Hints {
173 none = 0,
174
180
184
189
195 };
196
197 SolverHints() : hints(none) {}
198
199 SolverHints(int hints_) : hints(hints_) {}
200
204 b2spin_rw_mutex::scoped_lock lock(tbb_mutex);
205
206 hints = 0;
207 return *this;
208 }
209
211 SolverHints& add(const Hints& other_hints) {
212 b2spin_rw_mutex::scoped_lock lock(tbb_mutex);
213
214 hints |= other_hints;
215 return *this;
216 }
217
219 SolverHints& add(const SolverHints& other) {
220 b2spin_rw_mutex::scoped_lock lock(tbb_mutex);
221
222 hints |= other.hints;
223 return *this;
224 }
225
227 SolverHints& operator|=(const Hints& other_hints) { return add(other_hints); }
228
230 SolverHints& operator|=(const SolverHints& other) { return add(other); }
231
233 int operator*() const {
234 b2spin_rw_mutex::scoped_lock lock(const_cast<b2spin_rw_mutex&>(tbb_mutex));
235
236 return hints;
237 }
238
239private:
240 int hints;
241
242 b2spin_rw_mutex tbb_mutex;
243};
244
245} // namespace b2000
246
247#endif
#define THROW
Definition b2exception.H:198
Definition b2case.H:110
virtual double get_stage_size(int stage=-1) const =0
virtual std::string get_string(const std::string &key) const =0
virtual double get_double(const std::string &key) const =0
Definition b2domain.H:70
virtual size_t get_number_of_dof() const =0
Definition b2exception.H:131
Definition b2model.H:69
virtual void set_case(Case &case_)=0
virtual Domain & get_domain()=0
Definition b2object.H:340
Definition b2object.H:456
Definition b2solver.H:168
Hints
Definition b2solver.H:171
@ diverge
Definition b2solver.H:183
@ none
Definition b2solver.H:173
@ unfinished
Definition b2solver.H:179
@ terminate_analysis
Definition b2solver.H:194
@ degradation
Definition b2solver.H:188
SolverHints & add(const SolverHints &other)
Definition b2solver.H:219
SolverHints & add(const Hints &other_hints)
Definition b2solver.H:211
SolverHints & clear()
Definition b2solver.H:203
int operator*() const
Definition b2solver.H:233
SolverHints & operator|=(const SolverHints &other)
Definition b2solver.H:230
SolverHints & operator|=(const Hints &other_hints)
Definition b2solver.H:227
A Solver instance executes an FE analysis. It is created and initialized by the Model instance and,...
Definition b2solver.H:50
virtual void solve()=0
This function is usually called by the Model instance.
void set_case(Case &b2case)
Make this constant (TB).
Definition b2solver.H:60
double step_size_
step size of the simulation.
Definition b2solver.H:97
virtual bool solve_iteration()=0
This function is called by the Solver instance itself.
size_t effective_num_dof_
Number of "true" unknowns of the global system.
Definition b2solver.H:105
bool IsImplicit() const
Definition b2solver.H:72
int current_stage_
Current stage number of current case.
Definition b2solver.H:111
bool IsDynamic() const
Definition b2solver.H:66
bool IsDamped() const
Definition b2solver.H:69
size_t total_num_dof_
Total number of all degrees of freedom of the system.
Definition b2solver.H:104
Case * case_
This also.
Definition b2solver.H:93
virtual void InitializeSolverOnCase()
Initializes the member variables of class Solver for the case at hand.
Definition b2solver.H:116
double time_max_
End time of simulation.
Definition b2solver.H:96
Model * model_
Definition b2solver.H:91
const bool IsLinear() const
Definition b2solver.H:63
void set_model(Model &model)
This function is called by the Model instance.
Definition b2solver.H:55
double time_
Pseudo time in case of stationary analyses.
Definition b2solver.H:95
Contains the base classes for implementing Finite Elements.
Definition b2boundary_condition.H:32
A dummy rw mutex for serial exeuction.
Definition b2threading.H:98