1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
|
// This file is part of ff3d - http://www.freefem.org/ff3d
// Copyright (C) 2001, 2002, 2003 Stphane Del Pino
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// $Id: VariationalProblem.hpp,v 1.7 2007/06/10 15:03:31 delpinux Exp $
#ifndef VARIATIONAL_PROBLEM_HPP
#define VARIATIONAL_PROBLEM_HPP
#include <list>
#include <Problem.hpp>
#include <VariationalBilinearBorderOperator.hpp>
#include <VariationalLinearBorderOperator.hpp>
#include <VariationalBilinearOperator.hpp>
#include <VariationalLinearOperator.hpp>
#include <BoundaryConditionSet.hpp>
/**
* @file VariationalProblem.hpp
* @author Stephane Del Pino
* @date Fri May 31 00:48:36 2002
*
* @brief Describes variational problems
*
* this class describes problems of the form: find @f$ u @f$ such that
* @f$ a(u,v)=l(v)\forall v@f$
*/
class VariationalProblem
: public Problem
{
private:
typedef std::list <ConstReferenceCounting<VariationalBilinearOperator> >
BilinearOperatorListType;
BilinearOperatorListType
__bilinearOperatorList; /**< list of bilinear operators */
typedef std::list <ConstReferenceCounting<VariationalLinearOperator> >
LinearOperatorListType;
LinearOperatorListType
__linearOperatorList; /**< list of linear operators */
typedef std::list <ConstReferenceCounting<VariationalBilinearBorderOperator> >
BilinearBorderOperatorListType;
BilinearBorderOperatorListType
__bilinearBorderOperatorList; /**< list of bilinear border
operators, ie operators living on
the border for natural BC as an
example */
typedef std::list <ConstReferenceCounting<VariationalLinearBorderOperator> >
LinearBorderOperatorListType;
LinearBorderOperatorListType
__linearBorderOperatorList; /**< list of bilinear border operators,
ie operators living on the border for
natural BC for example */
std::vector<ConstReferenceCounting<BoundaryConditionSet> >
__bc; /**< list of dirichlet conditions */
public:
typedef BilinearOperatorListType::iterator bilinearOperatorIterator;
typedef BilinearOperatorListType::const_iterator bilinearOperatorConst_iterator;
typedef LinearOperatorListType::iterator linearOperatorIterator;
typedef LinearOperatorListType::const_iterator linearOperatorConst_iterator;
typedef BilinearBorderOperatorListType::iterator bilinearBorderOperatorIterator;
typedef BilinearBorderOperatorListType::const_iterator bilinearBorderOperatorConst_iterator;
typedef LinearBorderOperatorListType::iterator linearBorderOperatorIterator;
typedef LinearBorderOperatorListType::const_iterator linearBorderOperatorConst_iterator;
/**
* Bilinear Operator iterator begin
*
* @return iterator on the first bilinear operator
*/
bilinearOperatorIterator beginBilinearOperator()
{
return __bilinearOperatorList.begin();
}
/**
* Bilinear Operator const iterator begin
*
* @return iterator on the first bilinear operator
*/
bilinearOperatorConst_iterator beginBilinearOperator() const
{
return __bilinearOperatorList.begin();
}
/**
* Bilinear Operator const iterator end
*
* @return iterator at the end of the bilinear operator list
*/
bilinearOperatorConst_iterator endBilinearOperator() const
{
return __bilinearOperatorList.end();
}
/**
* Linear Operator iterator begin
*
* @return iterator on the first bilinear operator
*/
linearOperatorIterator beginLinearOperator()
{
return __linearOperatorList.begin();
}
/**
* Linear Operator iterator begin
*
* @return iterator on the first bilinear operator
*/
linearOperatorConst_iterator beginLinearOperator() const
{
return __linearOperatorList.begin();
}
/**
* Linear Operator iterator end
*
* @return iterator at the end of the linear opearator list
*/
linearOperatorConst_iterator endLinearOperator() const
{
return __linearOperatorList.end();
}
/**
* Bilinear Border Operator iterator begin
*
* @return iterator on the first bilinear border operator
*/
bilinearBorderOperatorIterator beginBilinearBorderOperator()
{
return __bilinearBorderOperatorList.begin();
}
/**
* Bilinear Border Operator const iterator begin
*
* @return iterator on the first bilinear border operator
*/
bilinearBorderOperatorConst_iterator beginBilinearBorderOperator() const
{
return __bilinearBorderOperatorList.begin();
}
/**
* Bilinear Border Operator const iterator end
*
* @return iterator at the end of the bilinear border operator list
*/
bilinearBorderOperatorConst_iterator endBilinearBorderOperator() const
{
return __bilinearBorderOperatorList.end();
}
/**
* Linear Border Operator iterator begin
*
* @return iterator on the first bilinear border operator
*/
linearBorderOperatorIterator beginLinearBorderOperator()
{
return __linearBorderOperatorList.begin();
}
/**
* Linear Border Operator iterator begin
*
* @return iterator on the first bilinear border operator
*/
linearBorderOperatorConst_iterator beginLinearBorderOperator() const
{
return __linearBorderOperatorList.begin();
}
/**
* Linear Border Operator iterator end
*
* @return iterator at the end of the linear border opearator list
*/
linearBorderOperatorConst_iterator endLinearBorderOperator() const
{
return __linearBorderOperatorList.end();
}
/**
* Returns the problem given by the "product" of a function u in the
* variational forms
*
* @param u the given function
*
* @return the modified problem
*/
ReferenceCounting<Problem>
operator*(const ConstReferenceCounting<ScalarFunctionBase>& u) const
{
VariationalProblem* newVariationalProblem = new VariationalProblem(*this);
newVariationalProblem->__bilinearOperatorList.clear();
for (BilinearOperatorListType::const_iterator i = __bilinearOperatorList.begin();
i != __bilinearOperatorList.end(); ++i) {
newVariationalProblem->__bilinearOperatorList.push_back((**i) * u);
}
newVariationalProblem->__linearOperatorList.clear();
for (LinearOperatorListType::const_iterator i = __linearOperatorList.begin();
i != __linearOperatorList.end(); ++i) {
newVariationalProblem->__linearOperatorList.push_back((**i) * u);
}
return newVariationalProblem;
}
/**
* Adds a variational bilinear operator to its list
*
* @param v a variational bilinear operator
*/
void add(ReferenceCounting<VariationalBilinearOperator> v)
{
__bilinearOperatorList.push_back(v);
}
/**
* Adds a variational "border" bilinear operator to its list
*
* @param v a variational "border" bilinear operator
*/
void add(ReferenceCounting<VariationalBilinearBorderOperator> v)
{
__bilinearBorderOperatorList.push_back(v);
}
/**
* Adds a variational linear operator to its list
*
* @param v a variational linear operator
*/
void add(ReferenceCounting<VariationalLinearOperator> v)
{
__linearOperatorList.push_back(v);
}
/**
* Adds a variational "border" linear operator to its list
*
* @param v a variational "border" linear operator
*/
void add(ReferenceCounting<VariationalLinearBorderOperator> v)
{
__linearBorderOperatorList.push_back(v);
}
/**
* Returns the number of unknowns
*
*
* @return __numberOfUnknow
*/
size_t numberOfUnknown() const
{
return __bc.size();
}
/**
* Returns the boundary condition set associated to the ith unknown
*
* @param i
*
* @return
*/
const BoundaryConditionSet& boundaryConditionSet(const size_t& i) const
{
return *(__bc[i]);
}
bool hasJumpOrMean() const
{
for (BilinearOperatorListType::const_iterator i=__bilinearOperatorList.begin();
i != __bilinearOperatorList.end(); ++i) {
if (((*i)->testFunctionProperty() != VariationalOperator::normal) or
((*i)->unknownProperty() != VariationalOperator::normal)) {
return true;
}
}
for (LinearOperatorListType::const_iterator i=__linearOperatorList.begin();
i != __linearOperatorList.end(); ++i) {
if ((*i)->testFunctionProperty() != VariationalOperator::normal) {
return true;
}
}
return false;
}
/**
* Constructor
*
* @param bc Boundary condition sets
*/
VariationalProblem(std::vector<ConstReferenceCounting<BoundaryConditionSet> > bc)
: Problem(Problem::variationalProblem, 0),
__bc(bc)
{
;
}
/**
* Copy constructor
*
* @param V original variational problem
*/
VariationalProblem(const VariationalProblem& V)
: Problem(V),
__bilinearOperatorList(V.__bilinearOperatorList),
__linearOperatorList(V.__linearOperatorList),
__bilinearBorderOperatorList(V.__bilinearBorderOperatorList),
__linearBorderOperatorList(V.__linearBorderOperatorList),
__bc(V.__bc)
{
;
}
/**
* Destructor
*
*/
~VariationalProblem()
{
;
}
};
#endif // VARIATIONAL_PROBLEM_HPP
|