CArl
Code Arlequin / C++ implementation
weight_parameter_function.h
Go to the documentation of this file.
1 /*
2  * weight_parameter_function.h
3  *
4  * Created on: Feb 2, 2016
5  * Author: Thiago Milanetto Schlittler
6  */
7 
8 #ifndef COMMON_LIBMESH_CODE_WEIGHT_PARAMETER_FUNCTION_H_
9 #define COMMON_LIBMESH_CODE_WEIGHT_PARAMETER_FUNCTION_H_
10 
11 #include "carl_headers.h"
12 
13 namespace carl
14 {
15 
17 {
18 protected:
19  // Members
20 // const libMesh::PointLocatorBase& m_locator;
21  libMesh::Mesh& m_alpha_mesh;
22  std::unique_ptr<libMesh::PointLocatorBase> m_locator_unique_ptr;
23 
24  double m_alpha_eps;
27 
31 
32 public:
33 
34  // Constructor
35  weight_parameter_function( libMesh::Mesh& alpha_mesh, double alpha_eps,
36  double alpha_coupling_BIG,
37  int subdomain_idx_BIG, int subdomain_idx_micro, int subdomain_idx_coupling) :
38  m_alpha_mesh{ alpha_mesh },
39  m_locator_unique_ptr { alpha_mesh.sub_point_locator() },
40  m_alpha_eps { alpha_eps },
41  m_alpha_coupling_BIG { alpha_coupling_BIG },
42  m_alpha_coupling_micro { 1. - alpha_coupling_BIG },
43  m_subdomain_idx_BIG { subdomain_idx_BIG },
44  m_subdomain_idx_micro { subdomain_idx_micro },
45  m_subdomain_idx_coupling { subdomain_idx_coupling }
46  {
47  };
48 
49  weight_parameter_function( libMesh::Mesh& alpha_mesh ) :
50  m_alpha_mesh{ alpha_mesh },
51  m_locator_unique_ptr { alpha_mesh.sub_point_locator() },
52  m_alpha_eps { 10E-2 },
53  m_alpha_coupling_BIG { 0.5 },
54  m_alpha_coupling_micro { 0.5 },
55  m_subdomain_idx_BIG { -1 },
56  m_subdomain_idx_micro { -1 },
57  m_subdomain_idx_coupling { -1 }
58  {
59  };
60 
61  // Destructor
63  {
64  clear();
65  }
66 
67  void set_parameters(double alpha_eps, double alpha_coupling_BIG,
68  int subdomain_idx_BIG, int subdomain_idx_micro, int subdomain_idx_coupling)
69  {
70  m_alpha_eps = alpha_eps;
71  m_alpha_coupling_BIG = alpha_coupling_BIG;
72  m_alpha_coupling_micro = 1. - alpha_coupling_BIG;
73  m_subdomain_idx_BIG = subdomain_idx_BIG;
74  m_subdomain_idx_micro = subdomain_idx_micro;
75  m_subdomain_idx_coupling = subdomain_idx_coupling;
76  };
77 
78  double get_alpha_BIG(const libMesh::Point& qpoint)
79  {
80  libMesh::PointLocatorBase& locator = *m_locator_unique_ptr.get();
81  const libMesh::Elem* elem = locator(qpoint);
82  double output = 0;
83 
84  if(elem->subdomain_id() == m_subdomain_idx_BIG)
85  {
86  output = 1;
87  }
88  else if(elem->subdomain_id() == m_subdomain_idx_micro)
89  {
90  output = m_alpha_eps;
91  }
92  else if(elem->subdomain_id() == m_subdomain_idx_coupling)
93  {
94  output = m_alpha_coupling_BIG;
95  }
96 
97  return output;
98  }
99 
100  double get_alpha_micro(const libMesh::Point& qpoint)
101  {
102  libMesh::PointLocatorBase& locator = *m_locator_unique_ptr.get();
103  const libMesh::Elem* elem = locator(qpoint);
104  double output = 0;
105 
106  if(elem->subdomain_id() == m_subdomain_idx_BIG)
107  {
108  output = 0;
109  }
110  else if(elem->subdomain_id() == m_subdomain_idx_micro)
111  {
112  output = 1 - m_alpha_eps;
113  }
114  else if(elem->subdomain_id() == m_subdomain_idx_coupling)
115  {
116  output = m_alpha_coupling_micro;
117  }
118 
119  return output;
120  }
121 
122  // Methods
123  void clear()
124  {
125  m_locator_unique_ptr.reset(NULL);
126  // Nothing to do ... for now
127  };
128 };
129 
130 }
131 
132 #endif /* COMMON_LIBMESH_CODE_WEIGHT_PARAMETER_FUNCTION_H_ */
double get_alpha_BIG(const libMesh::Point &qpoint)
weight_parameter_function(libMesh::Mesh &alpha_mesh)
std::unique_ptr< libMesh::PointLocatorBase > m_locator_unique_ptr
double get_alpha_micro(const libMesh::Point &qpoint)
void set_parameters(double alpha_eps, double alpha_coupling_BIG, int subdomain_idx_BIG, int subdomain_idx_micro, int subdomain_idx_coupling)
weight_parameter_function(libMesh::Mesh &alpha_mesh, double alpha_eps, double alpha_coupling_BIG, int subdomain_idx_BIG, int subdomain_idx_micro, int subdomain_idx_coupling)