FirstOrderTerm.h 23.9 KB
Newer Older
1 2 3 4 5 6 7
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
8
 * Authors:
9 10 11 12 13 14 15 16 17
 * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * This file is part of AMDiS
 *
 * See also license.opensource.txt in the distribution.
18
 *
19
 ******************************************************************************/
20 21


22 23 24 25 26 27

/** \file FirstOrderTerm.h */

#ifndef AMDIS_FIRST_ORDER_TERM_H
#define AMDIS_FIRST_ORDER_TERM_H

28
#include <vector>
29 30 31 32
#include "AMDiS_fwd.h"
#include "OperatorTerm.h"
#include "AbstractFunction.h"
#include "ElInfo.h"
33
#include "traits/size.hpp"
34
#include "MatrixVectorOperations.h"
35 36 37 38 39

namespace AMDiS {

  /**
   * \ingroup Assembler
40
   *
41 42 43 44 45 46 47
   * \brief
   * Describes the first order terms: \f$ b \cdot \nabla u(\vec{x}) \f$
   */
  class FirstOrderTerm : public OperatorTerm
  {
  public:
    /// Constructor.
48 49
    FirstOrderTerm(int deg)
      : OperatorTerm(deg)
50 51 52 53 54 55 56
    {}

    /// Destructor.
    virtual ~FirstOrderTerm() {}

    /// Evaluation of \f$ \Lambda b \f$.
    virtual void getLb(const ElInfo *elInfo,
57
		       std::vector<mtl::dense_vector<double> >& result) const = 0;
58 59 60

    /// Implenetation of FirstOrderTerm::eval().
    void eval(int nPoints,
61 62 63 64
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
65
	      double factor)
66 67 68
    {
      int dow = Global::getGeo(WORLD);

69
      if (num_rows(grdUhAtQP) > 0) {
70 71 72 73
	for (int iq = 0; iq < nPoints; iq++) {
	  double resultQP = 0.0;
	  for (int i = 0; i < dow; i++)
	    resultQP += grdUhAtQP[iq][i];
74

75 76 77 78 79
	  result[iq] += resultQP * factor;
	}
      }
    }

80
  protected:
81 82
    /// Evaluation of \f$ \Lambda \cdot b\f$ if b contains the value 1.0
    /// in each component.
83
    inline void l1(const DimVec<WorldVector<double> >& Lambda,
84
		   mtl::dense_vector<double>& Lb,
85 86
		   double factor) const
    {
87
      const int dim = size(Lambda);
88 89 90

      for (int i = 0; i < dim; i++) {
	double val = 0.0;
91

92 93 94 95
	for (int j = 0; j < dimOfWorld; j++)
	  val += Lambda[i][j];

	Lb[i] += val * factor;
96
      }
97 98 99 100 101
    }

    /// Evaluation of \f$ \Lambda \cdot b\f$.
    inline void lb(const DimVec<WorldVector<double> >& Lambda,
		   const WorldVector<double>& b,
102
		   mtl::dense_vector<double>& Lb,
103 104
		   double factor) const
    {
105
      const int dim = size(Lambda);
106 107

      for (int i = 0; i < dim; i++) {
108 109
//      double val = Lambda[i] * b;
//	double val = 0.0;
110
//
111 112
//	for (int j = 0; j < dimOfWorld; j++)
//	  val += Lambda[i][j] * b[j];
113
//
114 115
//	Lb[i] += val * factor;
        Lb[i] += (Lambda[i] * b) * factor;
116
      }
117 118 119 120
    }

    /// Evaluation of \f$ \Lambda \cdot b\f$.
    inline void lb_one(const DimVec<WorldVector<double> >& Lambda,
121
		       mtl::dense_vector<double>& Lb,
122 123
		       double factor) const
    {
124
      const int dim = size(Lambda);
125 126 127 128 129

      for (int i = 0; i < dim; i++)
	Lb[i] += Lambda[i][bOne] * factor;
    }

130 131 132 133 134 135
  };

  /**
   * \ingroup Assembler
   *
   * \brief
136
   * First order term: \f$ b \cdot \nabla u(\vec{x}) \f$ with a vector b which
137 138
   * only consits of entries equal to one.
   */
139 140 141 142
//   class Simple_FOT : public FirstOrderTerm
//   {
//   public:
//     /// Constructor.
143 144
//     Simple_FOT()
//       : FirstOrderTerm(0)
145
//     {}
146
//
147
//     /// Implements FirstOrderTerm::getLb().
148 149
//     inline void getLb(const ElInfo *elInfo,
// 		      vector<mtl::dense_vector<double> >& Lb) const
150 151 152
//     {
//       const DimVec<WorldVector<double> > &grdLambda = elInfo->getGrdLambda();
//       const int nPoints = static_cast<int>(Lb.size());
153
//
154 155 156 157
//       for (int iq = 0; iq < nPoints; iq++)
// 	l1(grdLambda, Lb[iq], 1.0);
//     }
//   };
158 159 160 161 162

  /**
   * \ingroup Assembler
   *
   * \brief
163
   * First order term: \f$ b \cdot \nabla u(\vec{x}) \f$ with a vector b which
164 165
   * only consits of entries equal to one.
   */
166
  class Simple_FOT : public FirstOrderTerm
167 168 169
  {
  public:
    /// Constructor.
170
    Simple_FOT(double f = 1.0)
171 172 173 174 175 176 177
      : FirstOrderTerm(0)
    {
      factor = new double;
      *factor = f;
    }

    /// Constructor.
178 179
    Simple_FOT(double *fptr)
      : FirstOrderTerm(0), factor(fptr)
180 181 182
    {}

    /// Implements FirstOrderTerm::getLb().
183
    inline void getLb(const ElInfo *elInfo,
184
		      std::vector<mtl::dense_vector<double> >& Lb) const
185
    {
186
      const DimVec<WorldVector<double> > &grdLambda = elInfo->getGrdLambda();
187
      const int nPoints = static_cast<int>(Lb.size());
188 189

      for (int iq = 0; iq < nPoints; iq++)
190
	l1(grdLambda, Lb[iq], (*factor));
191 192 193 194 195 196 197
    }

  private:
    /// Pointer to the factor.
    double *factor;
  };

198 199
  // for compatibility
  typedef Simple_FOT FactorSimple_FOT;
200

201 202 203
  /**
   * \ingroup Assembler
   *
204
   * \brief
205 206 207 208 209 210
   * First order term: \f$ b \cdot \nabla u(\vec{x}) \f$ with a given vector b.
   */
  class Vector_FOT : public FirstOrderTerm
  {
  public:
    /// Constructor.
211
    Vector_FOT(WorldVector<double> *wv, double fac_ = 1.0)
Praetorius, Simon's avatar
Praetorius, Simon committed
212
      : FirstOrderTerm(0), b(wv), fac(fac_)
213 214 215
    {}

    /// Constructor.
216
    Vector_FOT(int bIdx, double fac_ = 1.0)
Praetorius, Simon's avatar
Praetorius, Simon committed
217
      : FirstOrderTerm(0), fac(fac_)
218 219 220 221 222
    {
      bOne = bIdx;
    }

    /// Implements FirstOrderTerm::getLb().
223 224
    void getLb(const ElInfo *elInfo,
	       std::vector<mtl::dense_vector<double> >& Lb) const
225
    {
226
      const DimVec<WorldVector<double> > &grdLambda = elInfo->getGrdLambda();
227
      const int nPoints = static_cast<int>(Lb.size());
228 229 230

      if (bOne > -1) {
	for (int iq = 0; iq < nPoints; iq++)
Praetorius, Simon's avatar
Praetorius, Simon committed
231
	  lb_one(grdLambda, Lb[iq], fac);
232 233
      } else {
	for (int iq = 0; iq < nPoints; iq++)
Praetorius, Simon's avatar
Praetorius, Simon committed
234
	  lb(grdLambda, *b, Lb[iq], fac);
235 236 237 238 239
      }
    }

    /// Implements FirstOrderTerm::eval().
    void eval(int nPoints,
240 241 242 243
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
244 245
	      double factor)
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
246 247
      if (num_rows(grdUhAtQP) > 0) {
	double factor_ = factor * fac;
248
	for (int iq = 0; iq < nPoints; iq++)
Praetorius, Simon's avatar
Praetorius, Simon committed
249 250
	  result[iq] += *b * grdUhAtQP[iq] * factor_;
      }
251 252 253 254
    }

  protected:
    /// Vector which is multiplied with \f$ \nabla u(\vec{x}) \f$
255
    WorldVector<double> *b;
Praetorius, Simon's avatar
Praetorius, Simon committed
256
    double fac;
257 258 259 260 261 262 263 264 265 266 267 268
  };

  /**
   * \ingroup Assembler
   *
   * \brief
   * Simple_FOT multiplied with \f$ f(v(\vec{x})) \f$.
   */
  class VecAtQP_FOT : public FirstOrderTerm
  {
  public:
    /// Constructor.
269
    VecAtQP_FOT(DOFVectorBase<double> *dv,
270 271 272 273 274 275 276 277 278 279
		AbstractFunction<double, double> *af,
		WorldVector<double> *wv);

    /// Constructor.
    VecAtQP_FOT(DOFVectorBase<double> *dv,
		AbstractFunction<double, double> *af,
		int bIdx);

    /// Implementation of \ref OperatorTerm::initElement().
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
280
		     Quadrature *quad = NULL);
281

282 283 284 285
    /// Implementation of \ref OperatorTerm::initElement() for multilpe meshes.
    void initElement(const ElInfo* smallElInfo,
		     const ElInfo* largeElInfo,
		     SubAssembler* subAssembler,
286
		     Quadrature *quad = NULL);
287

288
    /// Implements FirstOrderTerm::getLb().
289
    void getLb(const ElInfo *elInfo,
290
	       std::vector<mtl::dense_vector<double> >& Lb) const;
291 292 293

    /// Implements FirstOrderTerm::eval().
    void eval(int nPoints,
294 295 296 297
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
298 299 300 301 302 303 304
	      double factor);

  protected:
    /// DOFVector to be evaluated at quadrature points.
    DOFVectorBase<double>* vec;

    /// v at quadrature points.
305
    mtl::dense_vector<double> vecAtQPs;
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324

    /// Function f.
    AbstractFunction<double, double> *f;

    ///
    WorldVector<double> *b;
  };

  /**
   * \ingroup Assembler
   *
   * \brief
   * Simple_FOT multiplied with \f$ f(\vec{x}) \f$.
   */
  class CoordsAtQP_FOT : public FirstOrderTerm
  {
  public:
    /// Constructor.
    CoordsAtQP_FOT(AbstractFunction<double, WorldVector<double> > *af)
325
      : FirstOrderTerm(af->getDegree()), g(af)
326 327 328 329
    {}

    /// Implementation of \ref OperatorTerm::initElement().
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
330
		     Quadrature *quad = NULL);
331 332

    /// Implements FistOrderTerm::getLb().
333
    void getLb(const ElInfo *elInfo,
334
	       std::vector<mtl::dense_vector<double> >& Lb) const;
335 336 337

    /// Implements FirstOrderTerm::eval().
    void eval(int nPoints,
338 339 340 341
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
342 343 344 345
	      double factor);

  protected:
    /// Stores coordinates at quadrature points. Set in \ref initElement().
Thomas Witkowski's avatar
Thomas Witkowski committed
346
    mtl::dense_vector<WorldVector<double> > coordsAtQPs;
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362

    /// Function avaluated at world coordinates.
    AbstractFunction<double, WorldVector<double> > *g;
  };

  /**
   * \ingroup Assembler
   *
   * \brief
   * Vector_FOT multiplied with \f$ f(\vec{x}) \f$.
   */
  class VecCoordsAtQP_FOT : public FirstOrderTerm
  {
  public:
    /// Constructor.
    VecCoordsAtQP_FOT(AbstractFunction<double, WorldVector<double> > *af,
363
		      WorldVector<double> *wv)
364 365 366 367 368
      : FirstOrderTerm(af->getDegree()), g(af), b(wv)
    {}

    /// Implementation of \ref OperatorTerm::initElement().
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
369
		     Quadrature *quad = NULL);
370 371

    /// Implements FistOrderTerm::getLb().
372
    void getLb(const ElInfo *elInfo,
373
	       std::vector<mtl::dense_vector<double> >& Lb) const;
374 375 376

    /// Implements FirstOrderTerm::eval().
    void eval(int nPoints,
377 378 379 380
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
381 382 383 384
	      double factor);

  protected:
    /// Stores coordinates at quadrature points. Set in \ref initElement().
Thomas Witkowski's avatar
Thomas Witkowski committed
385
    mtl::dense_vector<WorldVector<double> > coordsAtQPs;
386 387 388 389 390

    /// Function evaluated at world coordinates.
    AbstractFunction<double, WorldVector<double> > *g;

    /// Coefficient vector.
391
    WorldVector<double> *b;
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
  };

  /**
   * \ingroup Assembler
   *
   * \brief
   * First order term: \f$ b(\nabla v(\vec{x})) \cdot \nabla u(\vec{x})\f$.
   */
  class VectorGradient_FOT : public FirstOrderTerm
  {
  public:
    /// Constructor.
    VectorGradient_FOT(DOFVectorBase<double> *dv,
		       AbstractFunction<WorldVector<double>, WorldVector<double> > *af);

    /// Implementation of \ref OperatorTerm::initElement().
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
409
		     Quadrature *quad = NULL);
410 411

    /// Implements FirstOrderTerm::getLb().
412
    void getLb(const ElInfo *elInfo,
413
	       std::vector<mtl::dense_vector<double> >& Lb) const;
414 415 416

    /// Implements FirstOrderTerm::eval().
    void eval(int nPoints,
417 418 419 420
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
421 422 423 424 425 426 427 428 429
	      double factor);

  protected:
    DOFVectorBase<double>* vec;

    /// Function for b.
    AbstractFunction<WorldVector<double>, WorldVector<double> > *f;

    /// Gradient of v at quadrature points.
430
    mtl::dense_vector<WorldVector<double> > gradAtQPs;
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447
  };

  /**
   * \ingroup Assembler
   *
   * \brief
   * First order term: \f$ b(v(\vec{x})) \cdot \nabla u(\vec{x})\f$.
   */
  class VectorFct_FOT : public FirstOrderTerm
  {
  public:
    /// Constructor.
    VectorFct_FOT(DOFVectorBase<double> *dv,
		  AbstractFunction<WorldVector<double>, double> *fct);

    /// Implementation of \ref OperatorTerm::initElement().
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
448
		     Quadrature *quad = NULL);
449 450

    /// Implements FirstOrderTerm::getLb().
451
    void getLb(const ElInfo *elInfo,
452
	       std::vector<mtl::dense_vector<double> >& Lb) const;
453 454 455

    /// Implements FirstOrderTerm::eval().
    void eval(int nPoints,
456 457 458 459
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
460 461 462 463 464 465 466
	      double factor);

  protected:
    /// DOFVector to be evaluated at quadrature points.
    DOFVectorBase<double>* vec;

    /// Vector v at quadrature points.
467
    mtl::dense_vector<double> vecAtQPs;
468 469 470 471 472 473 474 475 476

    /// Function for b.
    AbstractFunction<WorldVector<double>, double> *vecFct;
  };

  /**
   * \ingroup Assembler
   *
   * \brief
477
   *
478 479 480 481 482 483
   */
  class VecFctAtQP_FOT : public FirstOrderTerm
  {
  public:
    /// Constructor.
    VecFctAtQP_FOT(AbstractFunction<WorldVector<double>, WorldVector<double> > *af)
484
      : FirstOrderTerm(af->getDegree()), g(af)
485 486 487 488
    {}

    /// Implementation of \ref OperatorTerm::initElement().
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
489
		     Quadrature *quad = NULL);
490 491

    /// Implements FistOrderTerm::getLb().
492
    void getLb(const ElInfo *elInfo,
493
	       std::vector<mtl::dense_vector<double> >& Lb) const;
494 495 496

    /// Implements FirstOrderTerm::eval().
    void eval(int nPoints,
497 498 499 500
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
501 502 503 504
	      double factor);

  protected:
    /// Stores coordinates at quadrature points. Set in \ref initElement().
Thomas Witkowski's avatar
Thomas Witkowski committed
505
    mtl::dense_vector<WorldVector<double> > coordsAtQPs;
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526

    /// Function avaluated at world coordinates.
    AbstractFunction<WorldVector<double>, WorldVector<double> > *g;
  };


  /**
   * \ingroup Assembler
   *
   * \brief
   * First order term: \f$ b(v(\vec{x}), \nabla w(\vec{x})) \cdot \nabla u(\vec{x})\f$.
   */
  class VecGrad_FOT : public FirstOrderTerm
  {
  public:
    /// Constructor.
    VecGrad_FOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2,
		BinaryAbstractFunction<WorldVector<double>, double, WorldVector<double> > *fct);

    /// Implementation of \ref OperatorTerm::initElement().
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
527
		     Quadrature *quad = NULL);
528 529 530 531 532

    /// Implementation of \ref OperatorTerm::initElement() for multilpe meshes.
    void initElement(const ElInfo* smallElInfo,
		     const ElInfo* largeElInfo,
		     SubAssembler* subAssembler,
533
		     Quadrature *quad = NULL);
534

535
    /// Implements FirstOrderTerm::getLb().
536
    void getLb(const ElInfo *elInfo,
537 538
	       std::vector<mtl::dense_vector<double> >& Lb) const;

539 540
    /// Implements FirstOrderTerm::eval().
    void eval(int nPoints,
541 542 543 544
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
545
	      double factor);
546

547 548 549 550
  protected:
    /// DOFVector to be evaluated at quadrature points.
    DOFVectorBase<double>* vec1;
    DOFVectorBase<double>* vec2;
551

552
    /// Vector v at quadrature points.
553
    mtl::dense_vector<double> vecAtQPs;
554

555
    mtl::dense_vector<WorldVector<double> > gradAtQPs;
556

557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
    /// Function for b.
    BinaryAbstractFunction<WorldVector<double>, double, WorldVector<double> > *vecFct;
  };


  /**
   * \ingroup Assembler
   *
   * \brief
   * First order term: \f$ b(\nabla v(\vec{x}), \nabla w(\vec{x})) \cdot \nabla u(\vec{x})\f$.
   */
  class FctGrad2_FOT : public FirstOrderTerm
  {
  public:
    /// Constructor
    FctGrad2_FOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2,
		BinaryAbstractFunction<WorldVector<double>, WorldVector<double>, WorldVector<double> > *vecFct_)
574
      : FirstOrderTerm(vecFct_->getDegree()), vec1(dv1), vec2(dv2), vecFct(vecFct_)
575 576 577 578
    {}

    /// Implementation of \ref OperatorTerm::initElement().
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
579
		     Quadrature *quad = NULL);
580

581
    /// Implements FirstOrderTerm::getLb().
582
    void getLb(const ElInfo *elInfo,
583 584
	       std::vector<mtl::dense_vector<double> >& Lb) const;

585 586
    /// Implements FirstOrderTerm::eval().
    void eval(int nPoints,
587 588 589 590
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
591
	      double factor);
592

593 594 595 596 597 598
  protected:
    /// DOFVector to be evaluated at quadrature points.
    DOFVectorBase<double>* vec1;

    /// DOFVector to be evaluated at quadrature points.
    DOFVectorBase<double>* vec2;
599

600
    /// Gradient v at quadrature points.
601
    mtl::dense_vector<WorldVector<double> > grad1AtQPs;
602 603

    /// Gradient v at quadrature points.
604
    mtl::dense_vector<WorldVector<double> > grad2AtQPs;
605 606 607 608 609 610 611 612 613

    /// Function for b.
    BinaryAbstractFunction<WorldVector<double>, WorldVector<double>, WorldVector<double> > *vecFct;
  };


  class Vec2AndGradAtQP_FOT : public FirstOrderTerm
  {
  public:
614
    Vec2AndGradAtQP_FOT(DOFVectorBase<double> *dv1,
615 616 617
			DOFVectorBase<double> *dv2,
			TertiaryAbstractFunction<double, double, double, WorldVector<double> > *f_, WorldVector<double> *b_);

618
    void initElement(const ElInfo* elInfo,
619
		     SubAssembler* subAssembler,
620
		     Quadrature *quad = NULL);
621 622

    void getLb(const ElInfo *elInfo,
623
	       std::vector<mtl::dense_vector<double> >& Lb) const;
624

625
    void eval(int nPoints,
626 627 628 629
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
630 631 632
	      double factor);

  protected:
633 634 635
    DOFVectorBase<double> *vec1, *vec2;

    mtl::dense_vector<double> vec1AtQPs, vec2AtQPs;
636

637
    mtl::dense_vector<WorldVector<double> > gradAtQPs1;
638 639

    TertiaryAbstractFunction<double, double, double, WorldVector<double> > *f;
640

641 642 643 644 645 646 647 648 649 650
    WorldVector<double> *b;
  };


  class FctVecAtQP_FOT : public FirstOrderTerm
  {
  public:
    FctVecAtQP_FOT(DOFVectorBase<double> *dv,
		   BinaryAbstractFunction<double, WorldVector<double>, double> *f_,
		   WorldVector<double> *b_);
651

652
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
653
		     Quadrature *quad = NULL);
654

655
    void getLb(const ElInfo *elInfo,
656
	       std::vector<mtl::dense_vector<double> >& Lb) const;
657

658
    void eval(int nPoints,
659 660 661 662
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
663
	      double factor);
664

665 666
  protected:
    DOFVectorBase<double>* vec;
Thomas Witkowski's avatar
Thomas Witkowski committed
667

668
    mtl::dense_vector<double> vecAtQPs;
Thomas Witkowski's avatar
Thomas Witkowski committed
669 670 671

    mtl::dense_vector<WorldVector<double> > coordsAtQPs;

672
    BinaryAbstractFunction<double, WorldVector<double>, double> *f;
Thomas Witkowski's avatar
Thomas Witkowski committed
673

674 675 676 677 678 679 680 681 682 683 684 685 686 687
    WorldVector<double> *b;
  };


  class Vec2AtQP_FOT : public FirstOrderTerm
  {
  public:
    Vec2AtQP_FOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2,
		 BinaryAbstractFunction<double, double, double> *af,
		 WorldVector<double> *b_);

    Vec2AtQP_FOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2,
		 BinaryAbstractFunction<double, double, double> *af,
		 int bIdx);
688

689
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
690
		     Quadrature *quad = NULL);
691

692
    void getLb(const ElInfo *elInfo,
693
	       std::vector<mtl::dense_vector<double> >& Lb) const;
694

695
    void eval(int nPoints,
696 697 698 699
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
700
	      double factor);
701

702
  protected:
703 704 705 706
    DOFVectorBase<double> *vec1, *vec2;

    mtl::dense_vector<double> vec1AtQPs, vec2AtQPs;

707
    BinaryAbstractFunction<double, double, double> *f;
708

709 710 711 712
    WorldVector<double> *b;
  };


713
  class Vec3AtQP_FOT : public FirstOrderTerm
714 715
  {
  public:
716
    Vec3AtQP_FOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2, DOFVectorBase<double> *dv3,
717 718
		    TertiaryAbstractFunction<double, double, double, double> *f,
		    WorldVector<double> *b);
719

720
    Vec3AtQP_FOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2, DOFVectorBase<double> *dv3,
721 722
		    TertiaryAbstractFunction<double, double, double, double> *f,
		    int b);
723

724
    void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
725
		     Quadrature *quad = NULL);
726

727
    void getLb(const ElInfo *elInfo,
728
	       std::vector<mtl::dense_vector<double> >& Lb) const;
729

730
    void eval(int nPoints,
731 732 733 734
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
735
	      double factor);
736

737
  protected:
738 739
    DOFVectorBase<double> *vec1, *vec2, *vec3;

740
    TertiaryAbstractFunction<double, double, double, double>* f;
741 742 743

    mtl::dense_vector<double> vec1AtQPs, vec2AtQPs, vec3AtQPs;

744 745
    WorldVector<double> *b;
  };
746

747 748
  // for compatibility
  typedef Vec3AtQP_FOT Vec3FctAtQP_FOT;
749 750 751 752 753 754


  class General_FOT : public FirstOrderTerm
  {
  public:
    /// Constructor
755 756
    General_FOT(std::vector<DOFVectorBase<double>*> vecs,
		std::vector<DOFVectorBase<double>*> grads,
757
		TertiaryAbstractFunction<WorldVector<double>,
758
		WorldVector<double>,
759
		std::vector<double>,
760
		std::vector<WorldVector<double> > > *f);
761 762

    /// Implementation of \ref OperatorTerm::initElement().
763
    void initElement(const ElInfo*,
764
		     SubAssembler* ,
765
		     Quadrature *quad= NULL);
766 767

    /// Implements FirstOrderTerm::getLb().
768
    void getLb(const ElInfo *elInfo,
769
	       std::vector<mtl::dense_vector<double> >& result) const;
770 771 772

    /// Implenetation of FirstOrderTerm::eval().
    void eval(int nPoints,
773 774 775 776
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
777 778 779
	      double factor);

  protected:
780
    std::vector<DOFVectorBase<double>*> vecs_;
781

782
    std::vector<DOFVectorBase<double>*> grads_;
783

784
    TertiaryAbstractFunction<WorldVector<double>,
785
			     WorldVector<double>,
786
			     std::vector<double>,
787
			     std::vector<WorldVector<double> > > *f_;
788

Thomas Witkowski's avatar
Thomas Witkowski committed
789
    mtl::dense_vector<WorldVector<double> > coordsAtQPs;
790

791
    std::vector<mtl::dense_vector<double> > vecsAtQPs;
792

793
    std::vector<mtl::dense_vector<WorldVector<double> > > gradsAtQPs_;
794 795 796 797 798 799 800
  };


  class GeneralParametric_FOT : public FirstOrderTerm
  {
  public:
    /// Constructor
801 802
    GeneralParametric_FOT(std::vector<DOFVectorBase<double>*> vecs,
			  std::vector<DOFVectorBase<double>*> grads,
803
			  QuartAbstractFunction<WorldVector<double>,
804 805
			  WorldVector<double>,
			  WorldVector<double>,
806
			  std::vector<double>,
807
			  std::vector<WorldVector<double> > > *f);
808 809

    /// Implementation of \ref OperatorTerm::initElement().
810
    void initElement(const ElInfo*, SubAssembler*, Quadrature *quad = NULL);
811 812

    /// Implements FirstOrderTerm::getLb().
813
    void getLb(const ElInfo *elInfo,
814
	       std::vector<mtl::dense_vector<double> >& result) const;
815 816 817

    /// Implenetation of FirstOrderTerm::eval().
    void eval(int nPoints,
818 819 820 821
	      const mtl::dense_vector<double>& uhAtQP,
	      const mtl::dense_vector<WorldVector<double> >& grdUhAtQP,
	      const mtl::dense_vector<WorldMatrix<double> >& D2UhAtQP,
	      mtl::dense_vector<double>& result,
822 823 824
	      double factor);

  protected:
825
    std::vector<DOFVectorBase<double>*> vecs_;
826

827
    std::vector<DOFVectorBase<double>*> grads_;
828

829
    QuartAbstractFunction<WorldVector<double>,
830 831
			  WorldVector<double>,
			  WorldVector<double>,
832
			  std::vector<double>,
833
			  std::vector<WorldVector<double> > > *f_;
834

Thomas Witkowski's avatar
Thomas Witkowski committed
835 836
    mtl::dense_vector<WorldVector<double> > coordsAtQPs;

837 838
    WorldVector<double> elementNormal_;

839
    std::vector<mtl::dense_vector<double> > vecsAtQPs;
840

841
    std::vector<mtl::dense_vector<WorldVector<double> > > gradsAtQPs_;
842 843 844 845 846
  };

}

#endif