14 #include "boost/lexical_cast.hpp"
27 using namespace boost;
32 unsigned int sides_0 [1] = {0};
33 old_to_new_side_numbering.push_back( sides_0 );
34 unsigned int sides_1 [2] = {0,1};
35 old_to_new_side_numbering.push_back( sides_1 );
36 unsigned int sides_2 [3] = {0,1,2};
37 old_to_new_side_numbering.push_back( sides_2 );
38 unsigned int sides_3 [4] = {0,1,2,3};
39 old_to_new_side_numbering.push_back( sides_3 );
50 flow_type = std::make_shared< FieldEnum >(1);
54 flow_flux = std::make_shared< FieldScalar >(1);
56 flow_sigma = std::make_shared< FieldScalar >(1);
59 Tokenizer tok(flow_bcd);
61 double scalar, flux, sigma;
64 xprintf(
MsgLog,
"Reading old BCD file for flow: %s ...", tok.f_name().c_str());
65 tok.skip_to(
"$BoundaryConditions");
67 unsigned int n_boundaries = lexical_cast<
unsigned int>(*tok); ++tok;
69 for(
unsigned int i_bcd=0; i_bcd < n_boundaries; i_bcd++) {
72 id = lexical_cast<
unsigned int>(*tok); ++tok;
74 unsigned int type = lexical_cast<
unsigned int>(*tok); ++tok;
78 scalar = lexical_cast<
double>(*tok); ++tok;
83 flux = lexical_cast<
double>(*tok); ++tok;
88 scalar = lexical_cast<
double>(*tok); ++tok;
89 sigma = lexical_cast<
double>(*tok); ++tok;
93 xprintf(
UsrErr,
"Unknown type of boundary condition - cond # %d, type %c\n",
id, type );
97 unsigned int where = lexical_cast<
unsigned int>(*tok); ++tok;
99 unsigned int eid, sid, bc_ele_idx, our_sid;
105 eid = lexical_cast<
unsigned int>(*tok); ++tok;
106 sid = lexical_cast<
unsigned int>(*tok); ++tok;
112 if( sid < 0 || sid >= ele->
n_sides() )
113 xprintf(
UsrErr,
"Boundary %d has incorrect reference to side %d\n",
id, sid );
114 our_sid=old_to_new_side_numbering[ele->
dim()][sid];
115 bcd = ele->
side(our_sid) -> cond();
121 flow_type->set_data_row( bc_ele_idx, type);
123 flow_flux->set_data_row( bc_ele_idx, flux);
126 xprintf(
Warn,
"IGNORING boundary condition %d for non-boundary side %d of element ID: %d\n",
id, sid, eid);
134 xprintf(
UsrErr,
"Unknown entity for boundary condition - cond # %d, ent. %c\n",
id, where );
137 unsigned int n_tags = lexical_cast<
unsigned int>(*tok); ++tok;
138 while (n_tags>0) ++tok, --n_tags;
142 }
catch (bad_lexical_cast &) {
143 xprintf(
UsrErr,
"Wrong format of number, %s.\n", tok.position_msg().c_str());
151 using namespace boost;
154 trans_conc = std::make_shared< FieldVector >( n_substances );
159 Tokenizer tok(transport_bcd);
161 unsigned int bcd_id, boundary_id, bc_ele_idx;
163 xprintf(
MsgLog,
"Reading old BCD file for transport: %s ...", tok.f_name().c_str());
164 if (tok.skip_to(
"$Transport_BCDFormat")) tok.next_line(
false);
165 tok.skip_to(
"$Transport_BCD");
166 tok.next_line(
false);
167 unsigned int n_bcd = lexical_cast<
unsigned int>(*tok); ++tok;
168 for (
unsigned int i_bcd = 0; i_bcd < n_bcd; i_bcd++) {
170 bcd_id = lexical_cast<
unsigned int>(*tok); ++tok;
171 boundary_id = lexical_cast<
unsigned int>(*tok); ++tok;
175 xprintf(
UsrErr,
"Wrong boundary index %d for bcd id %d in transport bcd file!", boundary_id, bcd_id);
176 bc_ele_idx = it->second;
178 for (
unsigned int sbi = 0; sbi < n_substances; sbi++) {
179 ele_value[sbi] = lexical_cast<
double>(*tok); ++tok;
182 trans_conc->set_data_row(bc_ele_idx, ele_value);
188 }
catch (bad_lexical_cast &) {
189 xprintf(
UsrErr,
"Wrong format of number, %s.\n", tok.position_msg().c_str());
internal::ReturnType< NRows, NCols, ET >::return_type return_type
FullIter find_id(const int id)
unsigned int n_sides() const
unsigned int index(const T *pointer) const
ElementVector bc_elements
SideIter side(const unsigned int loc_index)
Dedicated class for storing path to input and output files.
ElementFullIter element() const
bool is_valid() const
Returns false if the region has undefined/invalid value.
ElementVector element
Vector of elements of the mesh.