20 #include "essential_boundary_conditions.h"
21 #include "exact_solution.h"
26 template<
typename Scalar>
33 template<
typename Scalar>
40 template<
typename Scalar>
43 markers.push_back(marker);
48 template<
typename Scalar>
53 template<
typename Scalar>
56 this->current_time =
time;
59 template<
typename Scalar>
65 template<
typename Scalar>
71 template<
typename Scalar>
75 this->
markers.push_back(marker);
78 template<
typename Scalar>
81 this->warn(
"EssentialBoundaryCondition::Function used either for a constant condition, or not redefined for nonconstant condition.");
85 template<
typename Scalar>
92 this->exact_solution = exact;
94 throw Exceptions::Exception(
"Wrong mesh function type passed to DefaultEssentialBCNonConst.");
96 for (
unsigned int i = 0; i < markers_.size(); i++)
97 this->
markers.push_back(markers_[i]);
100 template<
typename Scalar>
101 DefaultEssentialBCNonConst<Scalar>::DefaultEssentialBCNonConst(
std::string marker, MeshFunctionSharedPtr<Scalar> exact_solution_)
102 : EssentialBoundaryCondition<Scalar>(
std::vector<
std::
string>())
104 ExactSolutionScalar<Scalar>* exact =
dynamic_cast<ExactSolutionScalar<Scalar>*
>(exact_solution_.get());
106 this->exact_solution = exact;
108 throw Exceptions::Exception(
"Wrong mesh function type passed to DefaultEssentialBCNonConst.");
109 this->
markers.push_back(marker);
112 template<
typename Scalar>
115 return exact_solution->value(x, y);
118 template<
typename Scalar>
123 template<
typename Scalar>
129 template<
typename Scalar>
132 std::vector<EssentialBoundaryCondition<Scalar> *> boundary_conditions;
133 boundary_conditions.push_back(boundary_condition);
137 template<
typename Scalar>
143 this->markers.clear();
144 create_marker_cache();
147 template<
typename Scalar>
150 std::vector<EssentialBoundaryCondition<Scalar> *> boundary_conditions;
151 boundary_conditions.push_back(boundary_condition);
152 add_boundary_conditions(boundary_conditions);
155 template<
typename Scalar>
156 typename std::vector<EssentialBoundaryCondition<Scalar> *>::const_iterator EssentialBCs<Scalar>::begin()
const
161 template<
typename Scalar>
162 typename std::vector<EssentialBoundaryCondition<Scalar> *>::const_iterator EssentialBCs<Scalar>::end()
const
167 template<
typename Scalar>
172 template<
typename Scalar>
175 bool hermes_any_set =
false;
176 this->markers.clear();
179 for (this->iterator = begin(); iterator != end(); ++iterator)
180 for (std::vector<std::string>::const_iterator it = (*iterator)->markers.begin(); it != (*iterator)->markers.end(); ++it)
183 throw Hermes::Exceptions::Exception(
"Attempt to define a BC on HERMES_ANY together with a BC on a specific part: '%s'.", it->c_str());
184 if ((*it) == HERMES_ANY)
186 if (any_set !=
nullptr)
187 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());
188 hermes_any_set =
true;
189 this->HermesAnyBC = *iterator;
194 for (
unsigned short i = 0; i < this->markers.size(); i++)
195 if (this->markers[i] == *it)
196 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());
197 this->markers.push_back(*it);
198 this->BCs.push_back(*iterator);
203 template<
typename Scalar>
206 return this->markers;
209 template<
typename Scalar>
212 if (this->HermesAnyBC !=
nullptr)
213 return this->HermesAnyBC;
214 for (
unsigned short i = 0; i < this->markers.size(); i++)
215 if (this->markers[i] == marker)
220 template<
typename Scalar>
223 for (iterator = begin(); iterator != end(); iterator++)
224 (*iterator)->set_current_time(time);
Scalar value_const
Special case of a constant function.
EssentialBoundaryCondition< Scalar > * get_boundary_condition(std::string marker)
Return the essential BC on the specified marker.
DefaultEssentialBCConst(std::vector< std::string > markers, Scalar value_const)
Constructors.
virtual ~EssentialBoundaryCondition()
Virtual destructor.
::xsd::cxx::tree::time< char, simple_type > time
C++ type corresponding to the time XML Schema built-in type.
double get_current_time() const
Get the current time for time-dependent boundary conditions.
void set_current_time(double time)
Sets the current time for time-dependent boundary conditions.
void add_boundary_conditions(std::vector< EssentialBoundaryCondition< Scalar > * > essential_bcs)
Initializes the class, fills the structures.
void set_current_time(double time)
Set the current time for time-dependent boundary conditions.
std::vector< std::string > markers
Markers.
EssentialBoundaryCondition()
Default constructor.
EssentialBCs()
Default constructor.
double current_time
Current time.
Scalar value(double x, double y) const
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
virtual Scalar value(double x, double y) const
const std::vector< std::string > & get_markers() const
Return all the markers where this set of conditions is defined.
Class representing constant essential boundary condition.
~EssentialBCs()
Default destructor.