Debian Codegraph @

packages/rol/example/PDE-OPT/topo-opt/navier-stokes/impermiability.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef IMPERMIABILITY_HPP
11 #define IMPERMIABILITY_HPP
12
13 #include <vector>
14 #include "ROL_ParameterList.hpp"
15 #include "ROL_Ptr.hpp"
16 #include "Intrepid_FieldContainer.hpp"
17
18 template<class Real>
19 class Impermiability {
20 private:
21 Real alphaLo_, alphaHi_, q_;
22
23 Real value(const Real z) const {
24 const Real one(1);
25 return alphaHi_ + (alphaLo_-alphaHi_)*z*(one+q_)/(q_+z);
26 }
27
28 Real deriv1(const Real z) const {
29 const Real one(1), two(2);
30 return (alphaLo_-alphaHi_)*q_*(q_+one)/std::pow(q_+z,two);
31 }
32
33 Real deriv2(const Real z) const {
34 const Real one(1), two(2), three(3);
35 return -(alphaLo_-alphaHi_)*two*q_*(q_+one)/std::pow(q_+z,three);
36 }
37
38 public:
39 Impermiability(ROL::ParameterList &list) {
40 alphaLo_ = list.sublist("Problem").get("Minimum Impermiability", 0.0);
41 alphaHi_ = list.sublist("Problem").get("Maximum Impermiability", 1e3);
42 q_ = list.sublist("Problem").get("RAMP Parameter", 1e5);
43 }
44
45 void compute(ROL::Ptr<Intrepid::FieldContainer<Real>> &alpha,
46 const ROL::Ptr<Intrepid::FieldContainer<Real>> &z,
47 const ROL::Ptr<const Intrepid::FieldContainer<Real>> &pts,
48 const int deriv=0) const {
49 const int c = pts->dimension(0);
50 const int p = pts->dimension(1);
51 for (int i = 0; i < c; ++i) {
52 for (int j = 0; j < p; ++j) {
53 // Compute spatially dependent viscosity
54 if (deriv==1) (*alpha)(i,j) = deriv1((*z)(i,j));
55 else if (deriv==2) (*alpha)(i,j) = deriv2((*z)(i,j));
56 else (*alpha)(i,j) = value((*z)(i,j));
57 }
58 }
59 }
60 };
61
62 #endif