DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_ProjectionPrimitiveNonlinearProblems.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 /*
3  Copyright (c) 2012, Stuart R. Slattery
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are
8  met:
9 
10  *: Redistributions of source code must retain the above copyright
11  notice, this list of conditions and the following disclaimer.
12 
13  *: Redistributions in binary form must reproduce the above copyright
14  notice, this list of conditions and the following disclaimer in the
15  documentation and/or other materials provided with the distribution.
16 
17  *: Neither the name of the University of Wisconsin - Madison nor the
18  names of its contributors may be used to endorse or promote products
19  derived from this software without specific prior written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 //---------------------------------------------------------------------------//
39 //---------------------------------------------------------------------------//
40 
41 #ifndef DTK_PROJECTIONPRIMITIVENONLINEARPROBLEMS_HPP
42 #define DTK_PROJECTIONPRIMITIVENONLINEARPROBLEMS_HPP
43 
44 #include <cmath>
45 
47 
48 #include <Teuchos_RCP.hpp>
49 
50 #include <Shards_CellTopology.hpp>
51 
52 #include <Intrepid_Basis.hpp>
53 #include <Intrepid_FieldContainer.hpp>
54 
55 namespace DataTransferKit
56 {
57 //---------------------------------------------------------------------------//
63 //---------------------------------------------------------------------------//
65 {
66  public:
68  typedef Intrepid::FieldContainer<double> md_array_type;
69  typedef typename Intrepid::FieldContainer<double>::scalar_type Scalar;
70 
71  // Constructor.
73  const Teuchos::RCP<
74  Intrepid::Basis<Scalar, Intrepid::FieldContainer<double>>>
75  &face_basis,
76  const Intrepid::FieldContainer<double> &point,
77  const Intrepid::FieldContainer<double> &face_nodes,
78  const Intrepid::FieldContainer<double> &face_node_normals );
79 
81  void updateState( const Intrepid::FieldContainer<double> &u );
82 
83  // Evaluate the nonlinear residual.
84  void evaluateResidual( const Intrepid::FieldContainer<double> &u,
85  Intrepid::FieldContainer<double> &F ) const;
86 
87  // Evaluate the jacobian.
88  void evaluateJacobian( const Intrepid::FieldContainer<double> &u,
89  Intrepid::FieldContainer<double> &J ) const;
90 
91  public:
92  // Basis of the face we are projecting to.
93  Teuchos::RCP<Intrepid::Basis<Scalar, Intrepid::FieldContainer<double>>>
94  d_face_basis;
95 
96  // Point coordinates to be projected.
97  Intrepid::FieldContainer<double> d_point;
98 
99  // Physical coordinates of the face nodes.
100  Intrepid::FieldContainer<double> d_face_nodes;
101 
102  // Normal vectors of the face nodes.
103  Intrepid::FieldContainer<double> d_face_node_normals;
104 
105  // Spatial dimension.
106  int d_space_dim;
107 
108  // Face topological dimension.
109  int d_topo_dim;
110 
111  // Face basis cardinality.
112  int d_cardinality;
113 
114  // Face basis evaluations.
115  Intrepid::FieldContainer<double> d_basis_evals;
116 
117  // Face basis gradient evalations.
118  Intrepid::FieldContainer<double> d_grad_evals;
119 
120  // Evaluation points in natural coordinates.
121  Intrepid::FieldContainer<double> d_eval_points;
122 
123 }; // end ProjectToFaceNonlinearProblem
124 
125 //---------------------------------------------------------------------------//
126 // ProjectPointToFaceNonlinearProblem traits implementation.
127 //---------------------------------------------------------------------------//
128 template <>
130 {
131  public:
132  typedef ProjectPointToFaceNonlinearProblem nonlinear_problem_type;
133 
134  typedef typename nonlinear_problem_type::md_array_type MDArray;
135 
136  typedef typename nonlinear_problem_type::Scalar Scalar;
137 
138  static inline void updateState( nonlinear_problem_type &problem,
139  const Intrepid::FieldContainer<double> &u )
140  {
141  problem.updateState( u );
142  }
143 
144  static inline void
145  evaluateResidual( const nonlinear_problem_type &problem,
146  const Intrepid::FieldContainer<double> &u,
147  Intrepid::FieldContainer<double> &F )
148  {
149  problem.evaluateResidual( u, F );
150  }
151 
152  static inline void
153  evaluateJacobian( const nonlinear_problem_type &problem,
154  const Intrepid::FieldContainer<double> &u,
155  Intrepid::FieldContainer<double> &J )
156  {
157  problem.evaluateJacobian( u, J );
158  }
159 };
160 
161 //---------------------------------------------------------------------------//
168 //---------------------------------------------------------------------------//
170 {
171  public:
173  typedef Intrepid::FieldContainer<double> md_array_type;
174  typedef typename Intrepid::FieldContainer<double>::scalar_type Scalar;
175 
176  // Constructor.
178  const Intrepid::FieldContainer<double> &point,
179  const Intrepid::FieldContainer<double> &face_edge_nodes,
180  const Intrepid::FieldContainer<double> &face_edge_node_normals,
181  const double c );
182 
183  // Update the state of the problem given the new solution vector.
184  void updateState( const Intrepid::FieldContainer<double> &u );
185 
186  // Evaluate the nonlinear residual.
187  void evaluateResidual( const Intrepid::FieldContainer<double> &u,
188  Intrepid::FieldContainer<double> &F ) const;
189 
190  // Evaluate the jacobian.
191  void evaluateJacobian( const Intrepid::FieldContainer<double> &u,
192  Intrepid::FieldContainer<double> &J ) const;
193 
194  public:
195  // Point to check for inclusion in the volume of influence.
196  Intrepid::FieldContainer<double> d_point;
197 
198  // Physical coordinates of the nodes constructing the edge of the face
199  // we are currently checking.
200  Intrepid::FieldContainer<double> d_face_edge_nodes;
201 
202  // Normal vectors of the nodes constructing the edge of the face that
203  // we are currently checking.
204  Intrepid::FieldContainer<double> d_face_edge_node_normals;
205 
206  // Scale factor.
207  double d_c;
208 
209  // Spatial dimension.
210  int d_space_dim;
211 
212  // Face topological dimension.
213  int d_topo_dim;
214 
215  // Pseudo-face cardinality.
216  int d_cardinality;
217 
218  // Psuedo-face basis evaluations.
219  Intrepid::FieldContainer<double> d_basis_evals;
220 
221  // Psuedo-face basis gradient evaluations.
222  Intrepid::FieldContainer<double> d_grad_evals;
223 
224  // Psuedo-face basis projection natural coordinates.
225  Intrepid::FieldContainer<double> d_eval_points;
226 
227  // Current projection normal direction.
228  Intrepid::FieldContainer<double> d_proj_normal;
229 
230  // Extra nodes constructing the pseudo-face.
231  Intrepid::FieldContainer<double> d_face_normal_nodes;
232 
233 }; // end PointInFaceVolumeOfInfluenceNonlinearProblem
234 
235 //---------------------------------------------------------------------------//
236 // PointInFaceVolumeOfInfluenceNonlinearProblem traits implementation.
237 //---------------------------------------------------------------------------//
238 template <>
240 {
241  public:
242  typedef PointInFaceVolumeOfInfluenceNonlinearProblem nonlinear_problem_type;
243 
244  typedef typename nonlinear_problem_type::md_array_type MDArray;
245 
246  typedef typename nonlinear_problem_type::Scalar Scalar;
247 
248  static inline void updateState( nonlinear_problem_type &problem,
249  const Intrepid::FieldContainer<double> &u )
250  {
251  problem.updateState( u );
252  }
253 
254  static inline void
255  evaluateResidual( const nonlinear_problem_type &problem,
256  const Intrepid::FieldContainer<double> &u,
257  Intrepid::FieldContainer<double> &F )
258  {
259  problem.evaluateResidual( u, F );
260  }
261 
262  static inline void
263  evaluateJacobian( const nonlinear_problem_type &problem,
264  const Intrepid::FieldContainer<double> &u,
265  Intrepid::FieldContainer<double> &J )
266  {
267  problem.evaluateJacobian( u, J );
268  }
269 };
270 
271 //---------------------------------------------------------------------------//
277 //---------------------------------------------------------------------------//
279 {
280  public:
282  typedef Intrepid::FieldContainer<double> md_array_type;
283  typedef typename Intrepid::FieldContainer<double>::scalar_type Scalar;
284 
285  // Constructor.
287  const Intrepid::FieldContainer<double> &point,
288  const Intrepid::FieldContainer<double> &edge_nodes,
289  const Intrepid::FieldContainer<double> &edge_node_normals,
290  const Intrepid::FieldContainer<double> &edge_node_binormals );
291 
292  // Update the state of the problem given the new solution vector.
293  void updateState( const Intrepid::FieldContainer<double> &u );
294 
295  // Evaluate the nonlinear residual.
296  void evaluateResidual( const Intrepid::FieldContainer<double> &u,
297  Intrepid::FieldContainer<double> &F ) const;
298 
299  // Evaluate the jacobian.
300  void evaluateJacobian( const Intrepid::FieldContainer<double> &u,
301  Intrepid::FieldContainer<double> &J ) const;
302 
303  public:
304  // point to project.
305  Intrepid::FieldContainer<double> d_point;
306 
307  // Coordinates of the edge nodes.
308  Intrepid::FieldContainer<double> d_edge_nodes;
309 
310  // Normal vectors of the edge nodes.
311  Intrepid::FieldContainer<double> d_edge_node_normals;
312 
313  // Binormal vectors of the edge nodes.
314  Intrepid::FieldContainer<double> d_edge_node_binormals;
315 
316  // Spatial dimension.
317  int d_space_dim;
318 
319 }; // end ProjectPointFeatureToEdgeFeatureNonlinearProblem
320 
321 //---------------------------------------------------------------------------//
322 // ProjectPointFeatureToEdgeFeatureNonlinearProblem traits implementation.
323 //---------------------------------------------------------------------------//
324 template <>
326 {
327  public:
329  nonlinear_problem_type;
330 
331  typedef typename nonlinear_problem_type::md_array_type MDArray;
332 
333  typedef typename nonlinear_problem_type::Scalar Scalar;
334 
335  static inline void updateState( nonlinear_problem_type &problem,
336  const Intrepid::FieldContainer<double> &u )
337  {
338  problem.updateState( u );
339  }
340 
341  static inline void
342  evaluateResidual( const nonlinear_problem_type &problem,
343  const Intrepid::FieldContainer<double> &u,
344  Intrepid::FieldContainer<double> &F )
345  {
346  problem.evaluateResidual( u, F );
347  }
348 
349  static inline void
350  evaluateJacobian( const nonlinear_problem_type &problem,
351  const Intrepid::FieldContainer<double> &u,
352  Intrepid::FieldContainer<double> &J )
353  {
354  problem.evaluateJacobian( u, J );
355  }
356 };
357 
358 //---------------------------------------------------------------------------//
359 
360 } // end namespace DataTransferKit
361 
362 //---------------------------------------------------------------------------//
363 
364 #endif // end DTK_PROJECTIONPRIMITIVENONLINEARPROBLEMS_HPP
365 
366 //---------------------------------------------------------------------------//
367 // end DTK_ProjectionPrimitiveNonlinearProblems.hpp
368 //---------------------------------------------------------------------------//
Nonlinear problem struct for ProjectBlueFeatureToGreenFeature. This problem projects a feature point ...
ProjectPointToFaceNonlinearProblem(const Teuchos::RCP< Intrepid::Basis< Scalar, Intrepid::FieldContainer< double >>> &face_basis, const Intrepid::FieldContainer< double > &point, const Intrepid::FieldContainer< double > &face_nodes, const Intrepid::FieldContainer< double > &face_node_normals)
Constructor.
Nonlinear problem for projecting a point into the reference frame of a face.
Intrepid::FieldContainer< double > md_array_type
Multidimensional array typedefs.
void evaluateResidual(const Intrepid::FieldContainer< double > &u, Intrepid::FieldContainer< double > &F) const
Evaluate the nonlinear residual.
Intrepid::FieldContainer< double > md_array_type
Multidimensional array typedefs.
Nonlinear problem struct for pointInFaceVolumeOfInfluence. This problem projects a point onto the sur...
void evaluateJacobian(const Intrepid::FieldContainer< double > &u, Intrepid::FieldContainer< double > &J) const
Evaluate the jacobian.
Traits/policy class for nonlinear problems.
void updateState(const Intrepid::FieldContainer< double > &u)
Update the state of the problem given the new solution vector.
Intrepid::FieldContainer< double > md_array_type
Multidimensional array typedefs.
Traits class for nonlinear problems.
DTK_BasicEntitySet.cpp.