1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 This file is part of CEPS.
4 CEPS is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 CEPS is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with CEPS (see file LICENSE at root of project).
16 If not, see <https://www.gnu.org/licenses/>.
19 Copyright 2019-2024 Inria, Universite de Bordeaux
21 Authors, in alphabetical order:
23 Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24 Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25 Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26 * : currently active authors
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
29 /** @file BoundaryCondition.cpp Wrapper around Field, specialized with parameters for BCs*/
30 // #included from "pde/common/functions/BoundaryCondition.hpp"
32 template <class _Result>
33 BoundaryCondition<_Result>::BoundaryCondition(
34 ScalarSAFunc* functor,
35 const CepsVector<DegreeOfFreedom*>* domain,
36 CepsUnknownIndex unknown
38 Field<_Result,DegreeOfFreedom>(functor,domain),
39 m_type (CepsBoundaryConditionFlag::Dirichlet),
46 template <class _Result>
47 BoundaryCondition<_Result>::~BoundaryCondition()
51 template <class _Result>
53 BoundaryCondition<_Result>::setBoundaryConditionType(CepsBoundaryConditionFlag type)
59 template <class _Result>
60 CepsBoundaryConditionFlag
61 BoundaryCondition<_Result>::getBoundaryConditionType() const
66 template <class _Result>
68 BoundaryCondition<_Result>::getUnknownId() const
74 template <class _Result>
76 BoundaryCondition<_Result>::setAlpha(CoeffFunc alpha)
82 template <class _Result>
83 typename BoundaryCondition<_Result>::CoeffFunc
84 BoundaryCondition<_Result>::getAlpha() const
89 template <class _Result>
90 typename std::remove_pointer_t<
91 typename BoundaryCondition<_Result>::CoeffFunc
93 BoundaryCondition<_Result>::getAlpha(CepsStandardArgs args) const
95 if (this->hasOneOfAttributes(args.attr) or this->hasUniversalAttribute() or this->getNumberOfAttributes() == 0)
96 return m_alpha->eval(std::forward<CepsStandardArgs>(args));
100 template <class _Result>
102 BoundaryCondition<_Result>::setBeta(CoeffFunc beta)
108 template <class _Result>
109 typename BoundaryCondition<_Result>::CoeffFunc
110 BoundaryCondition<_Result>::getBeta() const
115 template <class _Result>
116 typename std::remove_pointer_t<
117 typename BoundaryCondition<_Result>::CoeffFunc
119 BoundaryCondition<_Result>::getBeta(CepsStandardArgs args) const
121 if (this->hasOneOfAttributes(args.attr) or this->hasUniversalAttribute() or this->getNumberOfAttributes() == 0)
122 return m_beta->eval(std::forward<CepsStandardArgs>(args));
126 template <class _Result>
128 BoundaryCondition<_Result>::applyAsDirichlet(DMatPtr mat, DVecPtr sec, CepsReal t, CepsReal scalingFactor)
131 if (ceps::isValidPtr(mat))
133 CepsVector<CepsIndex> indices = this->getSupportIndices();
134 mat->zeroRows(indices.size(),indices.data(),scalingFactor);
136 if (ceps::isValidPtr(sec))
138 setFieldValuesTo(*this,sec.get(),t);
144 template <class _Result>
146 BoundaryCondition<_Result>::eval(CepsStandardArgs args)
148 if (this->hasOneOfAttributes(args.attr) or this->hasUniversalAttribute() or this->getNumberOfAttributes() == 0)
149 return this->m_scaleFactor * this->m_functor->eval(std::forward<CepsStandardArgs>(args));
153 template <class _Result>
155 BoundaryCondition<_Result>::getFlags() const
157 return this->m_functor->getFlags();
160 // template <class _Result>
162 // operator<< (std::ostream &os, const BoundaryCondition<_Result> &that)
164 // os << static_cast<Field<_Result>> (that);
165 // os << " -- type : ";
168 // case CepsBoundaryConditionFlag::Dirichlet: os << "Dirichlet\n"; break;
169 // case CepsBoundaryConditionFlag::Neumann: os << "Neumann\n"; break;
170 // case CepsBoundaryConditionFlag::Robin: os << "Robin\n"; break;
172 // os << " -- alpha : " << m_alpha.get () << "\n";
173 // os << " -- beta : " << m_beta.get () << "\n";