58 os<<
"Weak Dirichlet";
76 case condition_type::weak_clamped:
81 case condition_type::collapsed:
92 os<<
"condition type not known.\n";
118 m_parametric(parametric)
125 else if (
m_label ==
"Weak Clamped") m_type = condition_type::weak_clamped;
126 else if (
m_label ==
"Collapsed") m_type = condition_type::collapsed;
128 else m_type = condition_type::unknownType;
138 m_parametric(parametric)
169 case condition_type::weak_clamped:
174 case condition_type::collapsed:
197 m_parametric(parametric)
228 case condition_type::weak_clamped:
233 case condition_type::collapsed:
244 gsWarn<<
"gsBoundaryConditions: Unknown boundary condition.\n";
346 typedef typename std::deque<boundary_condition<T> > bcContainer;
347 typedef typename bcContainer::iterator iterator;
348 typedef typename bcContainer::const_iterator const_iterator;
350 typedef typename std::deque<corner_value<T> > cornerContainer;
351 typedef typename cornerContainer::iterator citerator;
352 typedef typename cornerContainer::const_iterator const_citerator;
354 typedef typename std::deque<coupled_boundary<T>> cplContainer;
355 typedef typename cplContainer::iterator cpliterator;
356 typedef typename cplContainer::const_iterator const_cpliterator;
358 typedef typename std::deque<boundaryInterface> ppContainer;
359 typedef typename ppContainer::iterator ppiterator;
360 typedef typename ppContainer::const_iterator const_ppiterator;
363 typedef std::map<std::string,bcContainer> bcData;
364 typedef typename bcData::iterator bciterator;
365 typedef typename bcData::const_iterator const_bciterator;
367 typedef memory::shared_ptr<gsBoundaryConditions> Ptr;
368 typedef memory::unique_ptr<gsBoundaryConditions> uPtr;
370 typedef typename boundary_condition<T>::function_ptr function_ptr;
372 typedef std::list<util::reference_wrapper<const boundary_condition<T> > > bcRefList;
391 m_bc.swap(other.
m_bc);
393 m_periodicPairs.swap(other.m_periodicPairs);
402 corner_values.clear();
403 m_periodicPairs.clear();
404 coupled_boundaries.clear();
410 for (
typename bcData::const_iterator it = m_bc.begin(); it != m_bc.end(); ++it)
411 sz += it->second.size();
412 return sz + corner_values.size() + coupled_boundaries.size();
416 const bcContainer &
container(
const std::string & label)
const {
return m_bc[label]; }
420 bcRefList
get(
const std::string & label,
const short_t unk = 0,
int comp = -1)
const
423 const const_bciterator it = m_bc.find(label);
424 if ( it != m_bc.end() )
425 for (const_iterator c = it->second.begin(); c!= it->second.end(); ++c)
426 if ( c->m_unknown == unk )
427 if ( c->m_unkcomp == comp || comp == -1 )
428 result.push_back(*c);
442 const bcContainer &
robinSides()
const {
return m_bc[
"Robin"]; }
444 const cornerContainer & cornerValues()
const {
return corner_values; }
446 const cplContainer & coupledBoundaries()
const {
return coupled_boundaries; }
453 for(
typename bcContainer::const_iterator iter=container.begin(); iter!=container.end();++iter)
455 if(iter->unknown()==unknown)
456 red.push_back(*iter);
461 bcContainer allConditions()
const
465 for (
typename bcData::const_iterator it = m_bc.begin(); it != m_bc.end(); ++it)
466 all.insert( all.end(), it->second.begin(), it->second.end() );
471 const_iterator
begin(
const std::string & label)
const {
return m_bc[label].begin(); }
474 iterator
begin(
const std::string & label) {
return m_bc[label].begin(); }
477 const_iterator
end(
const std::string & label)
const {
return m_bc[label].end(); }
480 iterator
end(
const std::string & label) {
return m_bc[label].end(); }
482 const_bciterator beginAll()
const {
return m_bc.begin(); }
483 bciterator beginAll() {
return m_bc.begin(); }
485 const_bciterator endAll()
const {
return m_bc.end(); }
486 bciterator endAll() {
return m_bc.end(); }
491 {
return m_bc[
"Dirichlet"].begin(); }
496 {
return m_bc[
"Dirichlet"].end(); }
501 {
return m_bc[
"Dirichlet"].begin(); }
506 {
return m_bc[
"Dirichlet"].end(); }
511 {
return m_bc[
"Weak Dirichlet"].begin(); }
516 {
return m_bc[
"Weak Dirichlet"].end(); }
521 {
return m_bc[
"Weak Dirichlet"].begin(); }
526 {
return m_bc[
"Weak Dirichlet"].end(); }
532 {
return m_bc[
"Neumann"].begin(); }
537 {
return m_bc[
"Neumann"].end(); }
542 {
return m_bc[
"Neumann"].begin(); }
547 {
return m_bc[
"Neumann"].end(); }
552 {
return m_bc[
"Robin"].begin(); }
557 {
return m_bc[
"Robin"].end(); }
562 {
return corner_values.begin(); }
567 {
return corner_values.end(); }
572 {
return coupled_boundaries.begin(); }
577 {
return coupled_boundaries.end(); }
582 {
return m_bc[
"Robin"].begin(); }
587 {
return m_bc[
"Robin"].end(); }
592 {
return corner_values.begin(); }
597 {
return corner_values.end(); }
602 {
return coupled_boundaries.begin(); }
607 {
return coupled_boundaries.end(); }
610 void add(
int p,
boxSide s,
const std::string & label,
611 const function_ptr & f_ptr,
short_t unknown = 0,
612 int comp = -1,
bool parametric =
false)
614 m_bc[label].push_back(
618 void add(
int p, boxSide s,
const std::string & label,
619 gsFunctionSet<T> * f,
short_t unknown = 0,
620 int comp = -1,
bool parametric =
false)
623 m_bc[label].push_back(
624 boundary_condition<T>(p, s, f_ptr, label, unknown, comp, parametric) );
627 void add(
int p, boxSide s,
const std::string & label,
628 const gsFunctionSet<T> & f,
short_t unknown = 0,
629 int comp = -1,
bool parametric =
false)
632 add(p,s,label,fun,unknown,comp,parametric);
654 addCondition(p,s,t,fun,unknown,parametric,comp);
657 void addConditions(
const bcRefList & bcrf)
660 m_bc[bc.get().ctype()].push_back(bc);
664 const function_ptr & f_shptr,
short_t unknown = 0,
665 bool parametric =
false,
int comp = -1)
667 auto bc = boundary_condition<T>(p,s,f_shptr,t,unknown,comp,parametric);
669 const auto & c = m_bc[bc.ctype()];
670 auto it = std::find_if(c.begin(), c.end(), [&bc](
const boundary_condition<T> & b){
return bc.isSame(b); });
672 m_bc[bc.ctype()].push_back(bc);
674 gsWarn<<
"Condition of type "<<bc.ctype()<<
" on patch "<<bc.patch()<<
" side "<<bc.side()<<
" of unknown "<<bc.unknown()<<
" with component "<<bc.unkComponent()<<
" ignored, because it has already been defined\n";
678 const gsFunctionSet<T> & func,
short_t unknown = 0,
679 bool parametric =
false,
int comp = -1)
681 function_ptr fun(func.clone().release());
682 addCondition(p,s,t,fun,unknown,parametric,comp);
686 gsFunctionSet<T> * f,
short_t unknown = 0,
bool parametric =
false,
int comp = -1)
689 addCondition(0,s,t,f,unknown,parametric,comp);
693 gsFunctionSet<T> * f,
short_t unknown = 0,
bool parametric =
false,
int comp = -1)
695 addCondition(ps.patch, ps.side(), t, f, unknown,parametric,comp);
699 const function_ptr & f_shptr,
short_t unknown = 0,
bool parametric =
false,
int comp = -1)
701 addCondition(ps.patch, ps.side(), t, f_shptr, unknown,parametric,comp);
705 const gsFunctionSet<T> & func,
short_t unknown = 0,
bool parametric =
false,
int comp = -1)
707 addCondition(ps.patch, ps.side(), t, func, unknown,parametric,comp);
711 const gsFunctionSet<T> & func,
short_t unknown = 0,
712 bool parametric =
false,
int comp = -1)
714 function_ptr fun(func.clone().release());
715 addCondition(p,boxSide(s),t,fun,unknown,parametric,comp);
719 gsFunctionSet<T> * func,
short_t unknown = 0,
720 bool parametric =
false,
int comp = -1)
722 addCondition(p,boxSide(s),t,func,unknown,parametric,comp);
728 corner_values.push_back(
corner_value<T>(p,c,value,unknown,component) );
739 short_t unknown = 0,
int comp = -1)
746 short_t unknown = 0,
int comp = -1)
752 std::ostream &
print(std::ostream &os,
const bool verbose =
false)
const {
754 for (
typename bcData::const_iterator it = m_bc.begin(); it != m_bc.end();
756 os <<
"* " << std::setw(13) << std::left << it->first <<
" : "
757 << it->second.size() <<
"\n";
759 if (!corner_values.empty())
760 os <<
"* Corner values : " << corner_values.size() <<
"\n";
764 os <<
"*\n* Summary\n*\n* " << std::right << std::setw(15) <<
"Type"
765 << std::setw(8) <<
"Patch" << std::setw(7) <<
"Side" << std::setw(9)
766 <<
"Unknown" << std::setw(13) <<
"Components" << std::setw(11)
767 <<
"Function" << std::endl;
768 for (
auto a = beginAll(); a != endAll(); a++) {
769 for (
const auto &element : a->second) {
770 os <<
"* " << std::right << std::setw(15) << element.ctype()
771 << std::setw(8) << element.patch() << std::setw(7)
772 << element.side().index() << std::setw(9) << element.unknown();
774 const auto &component = element.unkComponent();
775 if (component == -1) {
776 os << std::setw(13) <<
"all";
778 os << std::setw(13) << (element.unkComponent());
780 if (element.function()) {
781 os <<
" " << *element.function();
783 os <<
" Homogeneous";
788 os <<
"*" << std::endl;
810 const_iterator beg, end, cur;
811 patchSideComparison psRef(ps);
812 for (
auto & bcc : m_bc)
814 beg = bcc.second.begin();
815 end = bcc.second.end();
816 cur = std::find_if(beg,end,psRef);
832 const_iterator beg, end, cur;
833 for (
auto & bcc : m_bc)
835 beg = bcc.second.begin();
836 end = bcc.second.end();
837 for(cur=beg; cur!=end; ++cur)
839 result.push_back(*cur);
851 bcContainer bc_all = allConditions();
852 for(const_iterator it = bc_all.begin(); it!= bc_all.end();it++)
854 if((*it).patch()==np)
855 result.add(0,(*it).side(),it->ctype(),(*it).function(),(*it).unknown());
858 for(const_citerator it = cornerBegin(); it!= cornerEnd();it++)
861 result.
addCornerValue( (*it).corner, (*it).value, 0, (*it).unknown);
876 {
return m_periodicPairs.begin(); }
881 {
return m_periodicPairs.end(); }
886 {
return m_periodicPairs.begin(); }
891 {
return m_periodicPairs.end(); }
902 { m_trMatrix = trMatrix; }
911 GISMO_ASSERT(m_trMatrix.rows() > 0,
"Transformation matrix for periodic conditions not set!");
924 return nullptr!=m_patches;
930 GISMO_ASSERT(
nullptr!=m_patches,
"Geometry map was not provided in BC.");
935 struct patchSideComparison
942 bool operator() (
const boundary_condition<T> &bc)
const
954 ppContainer m_periodicPairs;
964 std::ostream &operator<<(std::ostream &os, const gsBoundaryConditions<T>& bvp)
965 {
return bvp.
print(os); }
967 #ifdef GISMO_WITH_PYBIND11
972 void pybind11_init_gsBoundaryConditions(pybind11::module &m);
973 void pybind11_enum_gsBoundaryConditions(pybind11::module &m);
979 #ifndef GISMO_BUILD_LIB
980 #include GISMO_HPP_HEADER(gsBoundaryConditions.hpp)
Robin type.
Definition: gsBoundaryConditions.h:34
const ppContainer & periodicPairs() const
Return a reference to the periodic sides.
Definition: gsBoundaryConditions.h:871
Neumann type.
Definition: gsBoundaryConditions.h:33
void clearPeriodicPairs()
Removes all periodic pairs.
Definition: gsBoundaryConditions.h:898
virtual std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsFunctionSet.h:587
short_t unknown() const
Returns the unknown to which this boundary condition refers to.
Definition: gsBoundaryConditions.h:272
shared_ptr< T > make_shared_not_owned(const T *x)
Creates a shared pointer which does not eventually delete the underlying raw pointer. Usefull to refer to objects which should not be destroyed.
Definition: gsMemory.h:189
const_citerator cornerBegin() const
Definition: gsBoundaryConditions.h:561
const_iterator dirichletBegin() const
Definition: gsBoundaryConditions.h:490
bool parametric() const
Definition: gsBoundaryConditions.h:279
const bcContainer & dirichletSides() const
Return a reference to the Dirichlet sides.
Definition: gsBoundaryConditions.h:433
Laplace type, e.g. u = g.
Definition: gsBoundaryConditions.h:38
Struct which represents a certain side of a patch.
Definition: gsBoundary.h:231
Dirichlet type.
Definition: gsBoundaryConditions.h:31
const bcContainer & weakDirichletSides() const
Return a reference to the Weak Dirichlet sides.
Definition: gsBoundaryConditions.h:436
std::ostream & print(std::ostream &os, const bool verbose=false) const
Prints the object as a string.
Definition: gsBoundaryConditions.h:752
void addCornerValue(boxCorner c, T value, int p=0, short_t unknown=0, int component=-1)
Adds a boundary condition with value on a corner c of patch p for unknown component.
Definition: gsBoundaryConditions.h:726
short_t m_unknown
Unknown to which this boundary condition refers to.
Definition: gsBoundaryConditions.h:294
#define short_t
Definition: gsConfig.h:35
Provides structs and classes related to interfaces and boundaries.
Dirichlet type.
Definition: gsBoundaryConditions.h:32
const_iterator begin(const std::string &label) const
Returns a const-iterator to the beginning of the Bc container of type label.
Definition: gsBoundaryConditions.h:471
iterator weakDirichletEnd()
Definition: gsBoundaryConditions.h:525
boxSide side() const
Returns the side to which this boundary condition refers to.
Definition: gsBoundaryConditions.h:269
const_cpliterator coupledBegin() const
Definition: gsBoundaryConditions.h:571
iterator robinEnd()
Definition: gsBoundaryConditions.h:586
iterator neumannBegin()
Definition: gsBoundaryConditions.h:541
const boundary_condition< T > * getConditionFromSide(patchSide ps) const
getSideCondition
Definition: gsBoundaryConditions.h:808
const_ppiterator periodicBegin() const
Definition: gsBoundaryConditions.h:875
T value
The value.
Definition: gsBoundaryConditions.h:312
const_iterator weakDirichletEnd() const
Definition: gsBoundaryConditions.h:515
int component
The component of the unknown.
Definition: gsBoundaryConditions.h:314
side
Identifiers for topological sides.
Definition: gsBoundary.h:58
bcContainer reducedContainer(const bcContainer &container, short_t unknown) const
Extracts the BC, comming from a certain component.
Definition: gsBoundaryConditions.h:449
ppiterator periodicEnd()
Definition: gsBoundaryConditions.h:890
const_iterator neumannBegin() const
Definition: gsBoundaryConditions.h:531
const_iterator robinBegin() const
Definition: gsBoundaryConditions.h:551
#define index_t
Definition: gsConfig.h:32
bool isSame(const boundary_condition &other)
Checks if this is the same as apart from the function data.
Definition: gsBoundaryConditions.h:282
void addCornerValue(boundary::corner c, T value, int p=0, short_t unknown=0, int component=-1)
Adds a boundary condition with value on a corner c of patch p for unknown component.
Definition: gsBoundaryConditions.h:732
const gsFunctionSet< T > & geoMap() const
Returns the geometry map.
Definition: gsBoundaryConditions.h:928
Class prescribing a value related to a corner of a patch.
Definition: gsBoundaryConditions.h:305
iterator weakDirichletBegin()
Definition: gsBoundaryConditions.h:520
citerator cornerBegin()
Definition: gsBoundaryConditions.h:591
ppiterator periodicBegin()
Definition: gsBoundaryConditions.h:885
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
Robin type.
Definition: gsBoundaryConditions.h:35
const_cpliterator coupledEnd() const
Definition: gsBoundaryConditions.h:576
index_t patch() const
Returns the patch to which this boundary condition refers to.
Definition: gsBoundaryConditions.h:266
gsMatrix< T > getTransformMatrix() const
Get transformation matrix for the periodic pairs of sides.
Definition: gsBoundaryConditions.h:909
const std::string & ctype() const
Returns the type of the boundary condition.
Definition: gsBoundaryConditions.h:263
memory::shared_ptr< gsFunctionSet > Ptr
Shared pointer for gsFunctionSet.
Definition: gsFunctionSet.h:223
corner
Identifiers for topological corners.
Definition: gsBoundary.h:65
const_iterator weakDirichletBegin() const
Definition: gsBoundaryConditions.h:510
const_iterator neumannEnd() const
Definition: gsBoundaryConditions.h:536
iterator dirichletBegin()
Definition: gsBoundaryConditions.h:500
cpliterator coupledBegin()
Definition: gsBoundaryConditions.h:601
cplContainer coupled_boundaries
List of boundaries that are coupled.
Definition: gsBoundaryConditions.h:950
Specifies the type of boundary condition.
Definition: gsBoundaryConditions.h:25
#define gsWarn
Definition: gsDebug.h:50
void setTransformMatrix(gsMatrix< T > trMatrix)
Set transformation matrix for the periodic pairs of sides.
Definition: gsBoundaryConditions.h:901
int component
The component of the unknown.
Definition: gsBoundaryConditions.h:329
const_iterator end(const std::string &label) const
Returns a const-iterator to the end of the Bc container of type label.
Definition: gsBoundaryConditions.h:477
void addPeriodic(int p1, boxSide s1, int p2, boxSide s2, short_t dim)
Add a periodic condition between side s1 of box p1 and side s2 of box p2.
Definition: gsBoundaryConditions.h:894
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
boxCorner corner
The corner.
Definition: gsBoundaryConditions.h:311
void getConditionsForPatch(const index_t np, gsBoundaryConditions &result) const
returns the set of all boundary conditions which refer to patch np
Definition: gsBoundaryConditions.h:848
short_t unkComponent() const
Returns the component of the unknown which this boundary condition refers to.
Definition: gsBoundaryConditions.h:275
cornerContainer corner_values
List of corners with fixed value.
Definition: gsBoundaryConditions.h:948
void setIdentityMatrix(short_t dim)
Set identity transformation matrix for the periodic pairs of sides.
Definition: gsBoundaryConditions.h:905
const bcContainer & container(const std::string &label) const
Return a reference to boundary conditions of certain type.
Definition: gsBoundaryConditions.h:416
iterator dirichletEnd()
Definition: gsBoundaryConditions.h:505
citerator cornerEnd()
Definition: gsBoundaryConditions.h:596
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
size_t numPeriodic() const
Get number of periodic pairs.
Definition: gsBoundaryConditions.h:868
const_iterator robinEnd() const
Definition: gsBoundaryConditions.h:556
const_citerator cornerEnd() const
Definition: gsBoundaryConditions.h:566
short_t unknown
Unknown to which this boundary condition refers to.
Definition: gsBoundaryConditions.h:313
void addCoupled(int p1, boxSide s1, int p2, boxSide s2, index_t dim, short_t unknown=0, int comp=-1)
Couples the degrees of freedom on patch p1 side s1 and patch p2 side s2 for unknown and component com...
Definition: gsBoundaryConditions.h:745
const bcContainer & robinSides() const
Return a reference to the Robin sides.
Definition: gsBoundaryConditions.h:442
Class that defines a boundary condition for a side of a patch for some unknown variable of a PDE...
Definition: gsBoundaryConditions.h:106
void addCoupled(int p1, boundary::side s1, int p2, boundary::side s2, index_t dim, short_t unknown=0, int comp=-1)
Couples the degrees of freedom on patch p1 side s1 and patch p2 side s2 for unknown and component com...
Definition: gsBoundaryConditions.h:738
const_ppiterator periodicEnd() const
Definition: gsBoundaryConditions.h:880
void getConditionFromSide(patchSide ps, bcContainer &result) const
getConditionFromSide returns the boundary conditions associated to the given patch side ...
Definition: gsBoundaryConditions.h:829
condition_type::type type() const
Returns the type of the boundary condition.
Definition: gsBoundaryConditions.h:260
Class containing a set of boundary conditions.
Definition: gsBoundaryConditions.h:341
void addCondition(int p, boxSide s, condition_type::type t, gsFunctionSet< T > *f, short_t unknown=0, bool parametric=false, int comp=-1)
Adds another boundary condition.
Definition: gsBoundaryConditions.h:650
type
Specifies the type of boundary condition.
Definition: gsBoundaryConditions.h:28
index_t patch
The index of the patch.
Definition: gsBoundaryConditions.h:310
std::string m_label
Description of type of the boundary condition.
Definition: gsBoundaryConditions.h:292
cpliterator coupledEnd()
Definition: gsBoundaryConditions.h:606
bool hasGeoMap() const
Checks if a geometry map is stored in the boundary conditions.
Definition: gsBoundaryConditions.h:922
bcData m_bc
Containers for BCs of various types.
Definition: gsBoundaryConditions.h:952
patchSide ps
Side of a patch for this boundary condition.
Definition: gsBoundaryConditions.h:284
void setGeoMap(const gsFunctionSet< T > &gm)
Set the geometry map to evaluate boundary conditions.
Definition: gsBoundaryConditions.h:916
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
const bcContainer & neumannSides() const
Return a reference to the Neumann sides.
Definition: gsBoundaryConditions.h:439
short_t m_unkcomp
Component of unknown to which this boundary condition refers to.
Definition: gsBoundaryConditions.h:296
iterator robinBegin()
Definition: gsBoundaryConditions.h:581
iterator neumannEnd()
Definition: gsBoundaryConditions.h:546
short_t unknown
Unknown to which this boundary condition refers to.
Definition: gsBoundaryConditions.h:328
iterator begin(const std::string &label)
Returns an iterator to the beginning of the Bc container of type label.
Definition: gsBoundaryConditions.h:474
const_iterator dirichletEnd() const
Definition: gsBoundaryConditions.h:495
index_t patch
The index of the patch.
Definition: gsBoundary.h:234
bool isHomogeneous() const
Returns true if there is no function data (homogeneous condition)
Definition: gsBoundaryConditions.h:251
Struct which represents a certain corner of a hyper-cube.
Definition: gsBoundary.h:291
Class prescribing a value related to a corner of a patch.
Definition: gsBoundaryConditions.h:321
function_ptr m_function
Function data for this boundary condition.
Definition: gsBoundaryConditions.h:286
shared_ptr< T > make_shared(T *x)
Definition: gsMemory.h:181
iterator end(const std::string &label)
Returns an iterator to the end of the Bc container of type label.
Definition: gsBoundaryConditions.h:480