b2api
B2000++ API Reference Manual, VERSION 4.6
 
Loading...
Searching...
No Matches
b2initial_condition_database.H
1//------------------------------------------------------------------------
2// b2initial_condition_database.H --
3//
4//
5// written by Mathias Doreille
6// Neda Ebrahimi Pour <neda.ebrahimipour@dlr.de>
7// Thomas Blome <thomas.blome@dlr.de>
8//
9// (c) 2004-2012 SMR Engineering & Development SA
10// 2502 Bienne, Switzerland
11//
12// (c) 2023 Deutsches Zentrum für Luft- und Raumfahrt (DLR) e.V.
13// Linder Höhe, 51147 Köln
14//
15// All Rights Reserved. Proprietary source code. The contents of
16// this file may not be disclosed to third parties, copied or
17// duplicated in any form, in whole or in part, without the prior
18// written permission of SMR.
19//------------------------------------------------------------------------
20
21#ifndef __B2INITIAL_CONDITION_DATABASE_H__
22#define __B2INITIAL_CONDITION_DATABASE_H__
23
24#include <complex>
25
26#include "b2domain_database.H"
27#include "b2ppconfig.h"
29#include "utils/b2database.H"
30#include "utils/b2linear_algebra.H"
31#include "utils/b2object.H"
32
33namespace b2000::b2dbv3 {
34
35template <typename T>
36class TypedInitialCondition : public b2000::TypedInitialCondition<T> {
37public:
38 void set_model(b2000::Model& model) override {
39 database = &dynamic_cast<DataBase&>(model);
40 domain = &dynamic_cast<Domain&>(model.get_domain());
41 }
42
43 void set_case(b2000::Case& case__) override { case_ = &case__; }
44
45 bool is_zero() override { return !case_->has_key("DOF_INIT"); }
46
47 bool get_static_initial_condition_value(
48 b2linalg::Vector<double, b2linalg::Vdense_ref> dof, double& time, int& stage,
49 std::string& domain_state_id) override {
50 bool zero = true;
51 SetName dof_init = case_->get_string("DOF_INIT", "");
52 if (dof_init.empty()) {
53 dof.set_zero();
54 } else {
55 domain->load_global_dof(dof_init, dof);
56 zero = false;
57 }
58 time = case_->get_double("TIME_INIT", 0);
59 if (time != 0) { zero = false; }
60 stage = case_->get_int("STAGE", 0);
61 domain_state_id = case_->get_string("STATE_INIT", "");
62 if (domain_state_id != "") { zero = false; }
63 return !zero;
64 }
65
66 bool get_dynamic_initial_condition_value(
67 b2linalg::Matrix<double, b2linalg::Mrectangle>& dof, double& time, int& stage,
68 std::string& domain_state_id) override {
69 SetName dof_init_id = case_->get_string("DOF_INIT", "");
70 SetName dofdot_init_id = case_->get_string("DOFD_INIT", "");
71 if (dofdot_init_id.empty()) {
72 dof.resize(domain->get_number_of_dof(), 1);
73 } else {
74 dof.resize(domain->get_number_of_dof(), 2);
75 }
76 dof.set_zero();
77 if (!dof_init_id.empty()) {
78 SetName dof_init;
79 if (std::isdigit(dof_init_id[0])) {
80 dof_init = SetName("DOF_INIT", "*", 0, 0, dof_init_id);
81 } else {
82 dof_init = dof_init_id;
83 }
84 domain->load_global_dof(dof_init, dof[0]);
85 }
86 if (!dofdot_init_id.empty()) {
87 SetName dofdot_init;
88 if (std::isdigit(dofdot_init_id[0])) {
89 dofdot_init = SetName("DOFD_INIT", "*", 0, 0, dofdot_init_id);
90 } else {
91 dofdot_init = dofdot_init_id;
92 }
93 domain->load_global_dof(dofdot_init, dof[1]);
94 }
95 time = case_->get_double("TIME", 0);
96 stage = case_->get_int("STAGE", 0);
97 domain_state_id = case_->get_string("STATE_INIT", "");
98 return true;
99 }
100
101 using type_t = ObjectTypeComplete<TypedInitialCondition>;
102 static type_t type;
103
104private:
105 DataBase* database{};
106 Domain* domain{};
107 b2000::Case* case_{};
108};
109
110template <typename T>
111typename TypedInitialCondition<T>::type_t TypedInitialCondition<T>::type(
112 "TypedInitialCondition", type_name<T>(), StringList(), b2000_module,
114
115} // Namespace b2000::b2dbv3
116
117#endif
Definition b2case.H:110
virtual bool has_key(const std::string &key) const =0
Definition b2model.H:69
virtual Domain & get_domain()=0
Definition b2initial_condition.H:59