MAST
complex_normal_rotation_mesh_function.cpp
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2019 Manav Bhatia
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 // MAST includes
23 
24 
26 ComplexNormalRotationMeshFunction(const std::string& nm,
29 _func(func)
30 { }
31 
32 
33 
34 void
36  const libMesh::Point& n,
37  const Real t,
38  ComplexVectorX& dn_rot) const {
39 
40 
41  dn_rot.setZero();
42 
43  libMesh::MeshFunction
44  &function_re = *_func.get_function().first,
45  &function_im = *_func.get_function().second;
46 
47  // translation is obtained by direct interpolation of the u,v,w vars
48 
50  v_re,
51  v_im;
52 
53  function_re(p, 0., v_re);
54  function_im(p, 0., v_im);
55 
56 
57  // perturbation of the normal requires calculation of the curl of
58  // displacement at the given point
59  std::vector<libMesh::Gradient>
60  gradients_re,
61  gradients_im;
62  function_re.gradient(p, 0., gradients_re);
63  function_im.gradient(p, 0., gradients_im);
64 
65  // TODO: these need to be mapped from local 2D to 3D space
66 
67  // now prepare the rotation vector
69  rot = ComplexVectorX::Zero(3);
70 
71  rot(0) = std::complex<Real>(gradients_re[2](1) - gradients_re[1](2),
72  gradients_im[2](1) - gradients_im[1](2)); // dwz/dy - dwy/dz
73  rot(1) = std::complex<Real>(gradients_re[0](2) - gradients_re[2](0),
74  gradients_im[0](2) - gradients_im[2](0)); // dwx/dz - dwz/dx
75  rot(2) = std::complex<Real>(gradients_re[1](0) - gradients_re[0](1),
76  gradients_im[1](0) - gradients_im[0](1)); // dwy/dx - dwx/dy
77 
78  // now do the cross-products
79  dn_rot(0) = rot(1) * n(2) - rot(2) * n(1);
80  dn_rot(1) = -(rot(0) * n(2) - rot(2) * n(0));
81  dn_rot(2) = rot(0) * n(1) - rot(1) * n(0);
82 }
83 
84 
85 
86 void
88  const libMesh::Point& n,
89  const Real t,
90  ComplexVectorX& dn_rot) const {
91 
92 
93  dn_rot.setZero();
94 
95  libMesh::MeshFunction
96  &perturbed_function_re = *_func.get_perturbed_function().first,
97  &perturbed_function_im = *_func.get_perturbed_function().second;
98 
99  // translation is obtained by direct interpolation of the u,v,w vars
100 
102  v_re,
103  v_im;
104  perturbed_function_re(p, 0., v_re);
105  perturbed_function_im(p, 0., v_im);
106 
107  // perturbation of the normal requires calculation of the curl of
108  // displacement at the given point
109  std::vector<libMesh::Gradient>
110  gradients_re,
111  gradients_im;
112  perturbed_function_re.gradient(p, 0., gradients_re);
113  perturbed_function_im.gradient(p, 0., gradients_im);
114 
115  // TODO: these need to be mapped from local 2D to 3D space
116 
117  // now prepare the rotation vector
119  rot = ComplexVectorX::Zero(3);
120 
121  rot(0) = std::complex<Real>(gradients_re[2](1) - gradients_re[1](2),
122  gradients_im[2](1) - gradients_im[1](2)); // dwz/dy - dwy/dz
123  rot(1) = std::complex<Real>(gradients_re[0](2) - gradients_re[2](0),
124  gradients_im[0](2) - gradients_im[2](0)); // dwx/dz - dwz/dx
125  rot(2) = std::complex<Real>(gradients_re[1](0) - gradients_re[0](1),
126  gradients_im[1](0) - gradients_im[0](1)); // dwy/dx - dwx/dy
127 
128  // now do the cross-products
129  dn_rot(0) = rot(1) * n(2) - rot(2) * n(1);
130  dn_rot(1) = -(rot(0) * n(2) - rot(2) * n(0));
131  dn_rot(2) = rot(0) * n(1) - rot(1) * n(0);
132 }
133 
134 
This uses the displacement gradient to calculate the rotation in a given surface normal.
virtual void perturbation(const libMesh::Point &p, const libMesh::Point &n, const Real t, ComplexVectorX &dn_rot) const
std::pair< libMesh::MeshFunction *, libMesh::MeshFunction * > get_perturbed_function()
MAST::ComplexMeshFieldFunction & _func
mesh field function
Matrix< Complex, Dynamic, 1 > ComplexVectorX
libMesh::Real Real
libMesh::DenseVector< Real > DenseRealVector
virtual void operator()(const libMesh::Point &p, const libMesh::Point &n, const Real t, ComplexVectorX &dn_rot) const
This provides a wrapper FieldFunction compatible class that interpolates the solution using libMesh&#39;s...
std::pair< libMesh::MeshFunction *, libMesh::MeshFunction * > get_function()
ComplexNormalRotationMeshFunction(const std::string &nm, MAST::ComplexMeshFieldFunction &func)