20 #include "essential_boundary_conditions.h"
21 #include "exact_solution.h"
26 template<
typename Scalar>
33 template<
typename Scalar>
36 markers.push_back(marker);
41 template<
typename Scalar>
46 template<
typename Scalar>
49 this->current_time =
time;
52 template<
typename Scalar>
58 template<
typename Scalar>
64 template<
typename Scalar>
68 this->
markers.push_back(marker);
71 template<
typename Scalar>
74 this->warn(
"EssentialBoundaryCondition::Function used either for a constant condition, or not redefined for nonconstant condition.");
78 template<
typename Scalar>
83 for (
unsigned int i = 0; i < this->
markers.size(); i++) this->
markers.push_back(markers_[i]);
86 template<
typename Scalar>
87 DefaultEssentialBCNonConst<Scalar>::DefaultEssentialBCNonConst(
std::string marker, ExactSolutionScalar<Scalar>* exact_solution)
88 : EssentialBoundaryCondition<Scalar>(Hermes::vector<std::
string>()), exact_solution(exact_solution)
90 this->
markers.push_back(marker);
93 template<
typename Scalar>
96 return exact_solution->value(x, y);
99 template<
typename Scalar>
104 for (
unsigned int i = 0; i < this->
markers.size(); i++)
105 this->
markers.push_back(markers_[i]);
108 template<
typename Scalar>
109 DefaultEssentialBCNonConstHcurl<Scalar>::DefaultEssentialBCNonConstHcurl(
std::string marker, ExactSolutionVector<Scalar>* exact_solution2)
110 : EssentialBoundaryCondition<Scalar>(Hermes::vector<std::
string>()), exact_solution2(exact_solution2)
112 this->
markers.push_back(marker);
115 template<
typename Scalar>
118 Scalar2<Scalar> val = exact_solution2->value(x, y);
119 return val.val[0] * t_x + val.val[1] * t_y;
122 template<
typename Scalar>
127 template<
typename Scalar>
133 template<
typename Scalar>
136 Hermes::vector<EssentialBoundaryCondition<Scalar> *> boundary_conditions;
137 boundary_conditions.push_back(boundary_condition);
141 template<
typename Scalar>
147 this->markers.clear();
148 create_marker_cache();
151 template<
typename Scalar>
154 Hermes::vector<EssentialBoundaryCondition<Scalar> *> boundary_conditions;
155 boundary_conditions.push_back(boundary_condition);
156 add_boundary_conditions(boundary_conditions);
159 template<
typename Scalar>
160 typename Hermes::vector<EssentialBoundaryCondition<Scalar> *>::const_iterator EssentialBCs<Scalar>::begin()
const
165 template<
typename Scalar>
166 typename Hermes::vector<EssentialBoundaryCondition<Scalar> *>::const_iterator EssentialBCs<Scalar>::end()
const
171 template<
typename Scalar>
176 template<
typename Scalar>
179 bool hermes_any_set =
false;
180 this->markers.clear();
183 for(this->iterator = begin(); iterator != end(); iterator++)
184 for(Hermes::vector<std::string>::const_iterator it = (*iterator)->markers.begin(); it != (*iterator)->markers.end(); it++)
187 throw Hermes::Exceptions::Exception(
"Attempt to define a BC on HERMES_ANY together with a BC on a specific part: '%s'.", it->c_str());
188 if((*it) == HERMES_ANY)
191 throw Hermes::Exceptions::Exception(
"Attempt to define a BC on HERMES_ANY together with a BC on a specific part: '%s'.", any_set->
markers.begin()->c_str());
192 hermes_any_set =
true;
193 this->HermesAnyBC = *iterator;
198 for(
int i = 0; i < this->markers.size(); i++)
199 if(this->markers[i] == *it)
200 throw Hermes::Exceptions::Exception(
"Attempt to define more than one description of the BC on the same part of the boundary with marker '%s'.", it->c_str());
201 this->markers.push_back(*it);
202 this->BCs.push_back(*iterator);
207 template<
typename Scalar>
208 EssentialBoundaryCondition<Scalar>* EssentialBCs<Scalar>::get_boundary_condition(
std::string marker)
210 if(this->HermesAnyBC != NULL)
211 return this->HermesAnyBC;
212 for(
int i = 0; i < this->markers.size(); i++)
213 if(this->markers[i] == marker)
218 template<
typename Scalar>
221 for(iterator = begin(); iterator != end(); iterator++)
222 (*iterator)->set_current_time(time);