RFFGen
 All Classes Namespaces Files Functions Typedefs Enumerations Groups
volumetricPenaltyFunctions.hh
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the C++-library RFFGen. */
4 /* Copyright 2015 Lars Lubkoll */
5 /* */
6 /* RFFGen is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* RFFGen is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with RFFGen. If not, see <http://www.gnu.org/licenses/>. */
18 /* */
19 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
20 
21 #ifndef RFFGEN_EXAMPLES_VOLUMETRIC_PENALTY_FUNCTIONS_HH
22 #define RFFGEN_EXAMPLES_VOLUMETRIC_PENALTY_FUNCTIONS_HH
23 
24 #include "../LinearAlgebra/determinant.hh"
25 #include "../CMath/log.hh"
26 #include "../CMath/pow.hh"
27 #include "../generate.hh"
28 
29 namespace RFFGen
30 {
32  template <class Inflation, class Compression, class Matrix>
33  auto volumetricPenalty(double d0, double d1, const Matrix& A)
34  {
36  auto f = ( d0*Inflation(det()) + d1*Compression(det()) ) << det;
37  auto g = f - f.d0();
38  return g;
39  }
40 
42  template <class Matrix>
43  auto volumetricQuadAndLog(double d0, double d1, const Matrix& A)
44  {
45  return volumetricPenalty< CMath::Pow<2> , CMath::LN >(d0,d1,A);
46  }
47 
49  template <class Matrix>
50  auto volumetricHartmannNeff(double d0, double d1, const Matrix& A)
51  {
52  return volumetricPenalty< CMath::Pow<5> , CMath::Pow<-5> >(d0,d1,A);
53  }
54 }
55 
56 #endif // RFFGEN_EXAMPLES_VOLUMETRIC_PENALTY_FUNCTIONS_HH
auto det(Matrix const &A)
Convenient generation of Determinant<Matrix>(A).
Definition: determinant.hh:237
auto volumetricQuadAndLog(double d0, double d1, const Matrix &A)
Create the volumetric penalty function .
Definition: volumetricPenaltyFunctions.hh:43
Power function with rational exponent including first three derivatives.
Definition: pow.hh:43
Natural logarithm including first three derivatives.
Definition: log.hh:41
auto volumetricHartmannNeff(double d0, double d1, const Matrix &A)
Create the volumetric penalty function .
Definition: volumetricPenaltyFunctions.hh:50
auto volumetricPenalty(double d0, double d1, const Matrix &A)
Create volumetric penalty function composed of a penalty for inflation and one for compression...
Definition: volumetricPenaltyFunctions.hh:33
std::conditional_t< Checks::isConstantSizeMatrix< Matrix >(), ConstantSizeDeterminant< Matrix >, DynamicSizeDeterminant< Matrix > > Determinant
Determinant with first three derivatives.
Definition: determinant.hh:230