MAST
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 NormalRotationMeshFunction(const std::string& nm,
29 _func(func)
30 { }
31 
32 
33 
34 void
36  const libMesh::Point& n,
37  const Real t,
38  RealVectorX& dn_rot) const {
39 
40 
41  dn_rot.setZero();
42  dn_rot.setZero();
43 
44  libMesh::MeshFunction&
45  function = _func.get_function();
46 
47  // translation is obtained by direct interpolation of the u,v,w vars
48 
50  function(p, 0., v);
51 
52 
53  // perturbation of the normal requires calculation of the curl of
54  // displacement at the given point
55  std::vector<libMesh::Gradient> gradients;
56  function.gradient(p, 0., gradients);
57 
58  // TODO: these need to be mapped from local 2D to 3D space
59 
60  // now prepare the rotation vector
62  rot = RealVectorX::Zero(3);
63 
64  rot(0) = gradients[2](1) - gradients[1](2); // dwz/dy - dwy/dz
65  rot(1) = gradients[0](2) - gradients[2](0); // dwx/dz - dwz/dx
66  rot(2) = gradients[1](0) - gradients[0](1); // dwy/dx - dwx/dy
67 
68  // now do the cross-products
69  dn_rot(0) = rot(1) * n(2) - rot(2) * n(1);
70  dn_rot(1) = -(rot(0) * n(2) - rot(2) * n(0));
71  dn_rot(2) = rot(0) * n(1) - rot(1) * n(0);
72 }
73 
74 
75 
76 void
78  const libMesh::Point& n,
79  const Real t,
80  RealVectorX& dn_rot) const {
81 
82 
83  dn_rot.setZero();
84  dn_rot.setZero();
85 
86  libMesh::MeshFunction&
87  perturbed_function = _func.get_perturbed_function();
88 
89  // translation is obtained by direct interpolation of the u,v,w vars
90 
92  perturbed_function(p, 0., v);
93 
94 
95  // perturbation of the normal requires calculation of the curl of
96  // displacement at the given point
97  std::vector<libMesh::Gradient> gradients;
98  perturbed_function.gradient(p, 0., gradients);
99 
100  // TODO: these need to be mapped from local 2D to 3D space
101 
102  // now prepare the rotation vector
104  rot = RealVectorX::Zero(3);
105 
106  rot(0) = gradients[2](1) - gradients[1](2); // dwz/dy - dwy/dz
107  rot(1) = gradients[0](2) - gradients[2](0); // dwx/dz - dwz/dx
108  rot(2) = gradients[1](0) - gradients[0](1); // dwy/dx - dwx/dy
109 
110  // now do the cross-products
111  dn_rot(0) = rot(1) * n(2) - rot(2) * n(1);
112  dn_rot(1) = -(rot(0) * n(2) - rot(2) * n(0));
113  dn_rot(2) = rot(0) * n(1) - rot(1) * n(0);
114 }
115 
116 
This uses the displacement gradient to calculate the rotation in a given surface normal.
MAST::MeshFieldFunction & _func
mesh field function
This provides a wrapper FieldFunction compatible class that interpolates the solution using libMesh&#39;s...
virtual void operator()(const libMesh::Point &p, const libMesh::Point &n, const Real t, RealVectorX &dn_rot) const
virtual void perturbation(const libMesh::Point &p, const libMesh::Point &n, const Real t, RealVectorX &dn_rot) const
libMesh::Real Real
libMesh::DenseVector< Real > DenseRealVector
libMesh::MeshFunction & get_perturbed_function()
Matrix< Real, Dynamic, 1 > RealVectorX
libMesh::MeshFunction & get_function()
NormalRotationMeshFunction(const std::string &nm, MAST::MeshFieldFunction &func)