21#ifndef __B2INITIAL_CONDITION_DATABASE_H__
22#define __B2INITIAL_CONDITION_DATABASE_H__
27#include "b2ppconfig.h"
29#include "utils/b2database.H"
30#include "utils/b2linear_algebra.H"
33namespace b2000::b2dbv3 {
39 database = &
dynamic_cast<DataBase&
>(model);
40 domain = &
dynamic_cast<Domain&
>(model.
get_domain());
43 void set_case(
b2000::Case& case__)
override { case_ = &case__; }
45 bool is_zero()
override {
return !case_->
has_key(
"DOF_INIT"); }
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 {
51 SetName dof_init = case_->get_string(
"DOF_INIT",
"");
52 if (dof_init.empty()) {
55 domain->load_global_dof(dof_init, dof);
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; }
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);
74 dof.resize(domain->get_number_of_dof(), 2);
77 if (!dof_init_id.empty()) {
79 if (std::isdigit(dof_init_id[0])) {
80 dof_init = SetName(
"DOF_INIT",
"*", 0, 0, dof_init_id);
82 dof_init = dof_init_id;
84 domain->load_global_dof(dof_init, dof[0]);
86 if (!dofdot_init_id.empty()) {
88 if (std::isdigit(dofdot_init_id[0])) {
89 dofdot_init = SetName(
"DOFD_INIT",
"*", 0, 0, dofdot_init_id);
91 dofdot_init = dofdot_init_id;
93 domain->load_global_dof(dofdot_init, dof[1]);
95 time = case_->get_double(
"TIME", 0);
96 stage = case_->get_int(
"STAGE", 0);
97 domain_state_id = case_->get_string(
"STATE_INIT",
"");
101 using type_t = ObjectTypeComplete<TypedInitialCondition>;
105 DataBase* database{};
111typename TypedInitialCondition<T>::type_t TypedInitialCondition<T>::type(
112 "TypedInitialCondition", type_name<T>(), StringList(), b2000_module,
virtual bool has_key(const std::string &key) const =0
virtual Domain & get_domain()=0
Definition b2initial_condition.H:59