fem_context.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_FEM_CONTEXT_H
21 #define LIBMESH_FEM_CONTEXT_H
22 
23 // Local Includes
24 #include "libmesh/diff_context.h"
25 #include "libmesh/id_types.h"
26 #include "libmesh/fe_type.h"
27 #include "libmesh/fe_base.h"
28 #include "libmesh/vector_value.h"
29 
30 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
31 #include "libmesh/tensor_value.h"
32 #endif
33 
34 // C++ includes
35 #include <map>
36 
37 namespace libMesh
38 {
39 
40  // Forward Declarations
41  class BoundaryInfo;
42  class Elem;
43  template <typename T> class FEGenericBase;
44  typedef FEGenericBase<Real> FEBase;
45  class QBase;
46  class Point;
47  template <typename T> class NumericVector;
48 
61 // ------------------------------------------------------------
62 // FEMContext class definition
63 
64 class FEMContext : public DiffContext
65 {
66 public:
67 
71  explicit
72  FEMContext (const System &sys);
73 
77  virtual ~FEMContext ();
78 
83 
87  std::vector<boundary_id_type> side_boundary_ids() const;
88 
94  Number interior_value(unsigned int var, unsigned int qp) const;
95 
101  Number side_value(unsigned int var, unsigned int qp) const;
102 
108  Number point_value(unsigned int var, const Point &p) const;
109 
115  Gradient interior_gradient(unsigned int var, unsigned int qp) const;
116 
122  Gradient side_gradient(unsigned int var, unsigned int qp) const;
123 
129  Gradient point_gradient(unsigned int var, const Point &p) const;
130 
131 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
132 
137  Tensor interior_hessian(unsigned int var, unsigned int qp) const;
138 
144  Tensor side_hessian(unsigned int var, unsigned int qp) const;
145 
151  Tensor point_hessian(unsigned int var, const Point &p) const;
152 
153 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
154 
160  Number fixed_interior_value(unsigned int var, unsigned int qp) const;
161 
167  Number fixed_side_value(unsigned int var, unsigned int qp) const;
168 
174  Number fixed_point_value(unsigned int var, const Point &p) const;
175 
181  Gradient fixed_interior_gradient(unsigned int var, unsigned int qp) const;
182 
188  Gradient fixed_side_gradient(unsigned int var, unsigned int qp) const;
189 
195  Gradient fixed_point_gradient(unsigned int var, const Point &p) const;
196 
197 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
198 
203  Tensor fixed_interior_hessian(unsigned int var, unsigned int qp) const;
204 
210  Tensor fixed_side_hessian(unsigned int var, unsigned int qp) const;
211 
217  Tensor fixed_point_hessian (unsigned int var, const Point &p) const;
218 
219 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
220 
224  template<typename OutputShape>
225  void get_element_fe( unsigned int var, FEGenericBase<OutputShape> *& fe ) const;
226 
230  FEBase* get_element_fe( unsigned int var ) const;
231 
235  template<typename OutputShape>
236  void get_side_fe( unsigned int var, FEGenericBase<OutputShape> *& fe ) const;
237 
241  FEBase* get_side_fe( unsigned int var ) const;
242 
246  template<typename OutputShape>
247  void get_edge_fe( unsigned int var, FEGenericBase<OutputShape> *& fe ) const;
248 
252  FEBase* get_edge_fe( unsigned int var ) const;
253 
258  template<typename OutputType>
259  void interior_value(unsigned int var, unsigned int qp,
260  OutputType& u) const;
261 
266  template<typename OutputType>
267  void interior_values(unsigned int var, const NumericVector<Number> & _system_vector,
268  std::vector<OutputType>& interior_values_vector) const;
269 
274  template<typename OutputType>
275  void side_value(unsigned int var, unsigned int qp,
276  OutputType& u) const;
277 
282  template<typename OutputType>
283  void side_values(unsigned int var, const NumericVector<Number> & _system_vector,
284  std::vector<OutputType>& side_values_vector) const;
285 
290  template<typename OutputType>
291  void point_value(unsigned int var, const Point &p,
292  OutputType& u) const;
293 
298  template<typename OutputType>
299  void interior_gradient(unsigned int var, unsigned int qp,
300  OutputType& du) const;
301 
306  template<typename OutputType>
307  void interior_gradients(unsigned int var, const NumericVector<Number> & _system_vector,
308  std::vector<OutputType>& interior_gradients_vector) const;
309 
314  template<typename OutputType>
315  void side_gradient(unsigned int var, unsigned int qp,
316  OutputType & du) const;
317 
322  template<typename OutputType>
323  void side_gradients(unsigned int var, const NumericVector<Number> & _system_vector,
324  std::vector<OutputType>& side_gradients_vector) const;
325 
330  template<typename OutputType>
331  void point_gradient(unsigned int var, const Point &p,
332  OutputType& grad_u) const;
333 
334 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
335 
339  template<typename OutputType>
340  void interior_hessian(unsigned int var, unsigned int qp,
341  OutputType& d2u) const;
342 
348  template<typename OutputType>
349  void interior_hessians(unsigned int var, const NumericVector<Number> & _system_vector,
350  std::vector<OutputType>& d2u_vals) const;
351 
356  template<typename OutputType>
357  void side_hessian(unsigned int var, unsigned int qp,
358  OutputType& d2u) const;
359 
365  template<typename OutputType>
366  void side_hessians(unsigned int var, const NumericVector<Number> & _system_vector,
367  std::vector<OutputType>& d2u_vals) const;
368 
373  template<typename OutputType>
374  void point_hessian(unsigned int var, const Point &p,
375  OutputType& hess_u) const;
376 
377 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
378 
383  template<typename OutputType>
384  void fixed_interior_value(unsigned int var, unsigned int qp,
385  OutputType& u) const;
386 
391  template<typename OutputType>
392  void fixed_side_value(unsigned int var, unsigned int qp,
393  OutputType& u) const;
394 
399  template<typename OutputType>
400  void fixed_point_value(unsigned int var, const Point &p,
401  OutputType& u) const;
402 
407  template<typename OutputType>
408  void fixed_interior_gradient(unsigned int var, unsigned int qp,
409  OutputType& grad_u) const;
410 
415  template<typename OutputType>
416  void fixed_side_gradient(unsigned int var, unsigned int qp,
417  OutputType& grad_u) const;
418 
423  template<typename OutputType>
424  void fixed_point_gradient(unsigned int var, const Point &p,
425  OutputType& grad_u) const;
426 
427 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
428 
432  template<typename OutputType>
433  void fixed_interior_hessian(unsigned int var, unsigned int qp,
434  OutputType& hess_u) const;
435 
440  template<typename OutputType>
441  void fixed_side_hessian(unsigned int var, unsigned int qp,
442  OutputType& hess_u) const;
443 
448  template<typename OutputType>
449  void fixed_point_hessian(unsigned int var, const Point &p,
450  OutputType& hess_u) const;
451 
452 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
453 
458  template<typename OutputType>
459  void interior_curl(unsigned int var, unsigned int qp,
460  OutputType& curl_u) const;
461 
466  template<typename OutputType>
467  void point_curl(unsigned int var, const Point &p,
468  OutputType& curl_u) const;
469 
474  template<typename OutputType>
475  void interior_div(unsigned int var, unsigned int qp,
476  OutputType& div_u) const;
477 
482 // virtual void reinit(const FEMSystem&, Elem*);
483 
484 // should be protected:
490  virtual void elem_reinit(Real theta);
491 
497  virtual void elem_side_reinit(Real theta);
498 
504  virtual void elem_edge_reinit(Real theta);
505 
509  virtual void pre_fe_reinit(const System&, const Elem *e);
510 
514  void elem_fe_reinit();
515 
519  virtual void side_fe_reinit();
520 
524  void edge_fe_reinit();
525 
529  const QBase& get_element_qrule() const
530  { return *(this->element_qrule); }
531 
535  const QBase& get_side_qrule() const
536  { return *(this->side_qrule); }
537 
541  const QBase& get_edge_qrule() const
542  { return *(this->edge_qrule); }
543 
552  virtual void set_mesh_system(System* sys)
553  { this->_mesh_sys = sys; }
554 
558  const System* get_mesh_system() const
559  { return this->_mesh_sys; }
560 
565  { return this->_mesh_sys; }
566 
570  unsigned int get_mesh_x_var() const
571  { return _mesh_x_var; }
572 
578  void set_mesh_x_var(unsigned int x_var)
579  { _mesh_x_var = x_var; }
580 
584  unsigned int get_mesh_y_var() const
585  { return _mesh_y_var; }
586 
592  void set_mesh_y_var(unsigned int y_var)
593  { _mesh_y_var = y_var; }
594 
598  unsigned int get_mesh_z_var() const
599  { return _mesh_z_var; }
600 
606  void set_mesh_z_var(unsigned int z_var)
607  { _mesh_z_var = z_var; }
608 
612  const Elem& get_elem() const
613  { return *elem; }
614 
619  { return *(const_cast<Elem*>(elem)); }
620 
624  unsigned char get_side() const
625  { return side; }
626 
630  unsigned char get_edge() const
631  { return edge; }
632 
636  unsigned char get_dim() const
637  { return dim; }
638 
644  void elem_position_set(Real theta);
645 
650  void elem_position_get();
651 
656 
661 
665  unsigned char side;
666 
670  unsigned char edge;
671 
672 protected:
673 
677  template<typename OutputShape>
679 
683  std::map<FEType, FEAbstract*> _element_fe;
684  std::map<FEType, FEAbstract*> _side_fe;
685  std::map<FEType, FEAbstract*> _edge_fe;
686 
687 
692  std::vector<FEAbstract*> _element_fe_var;
693  std::vector<FEAbstract*> _side_fe_var;
694  std::vector<FEAbstract*> _edge_fe_var;
695 
701 
705  const Elem *elem;
706 
710  unsigned char dim;
711 
718 
725 
732 
733 private:
742  void _do_elem_position_set(Real theta);
743 
749  void _update_time_from_system(Real theta);
750 };
751 
752 
753 
754 // ------------------------------------------------------------
755 // FEMContext inline methods
756 
757 inline
759 {
760  if (_mesh_sys)
761  this->_do_elem_position_set(theta);
762 }
763 
764 template<typename OutputShape>
765 inline
766 void FEMContext::get_element_fe( unsigned int var, FEGenericBase<OutputShape> *& fe ) const
767 {
768  libmesh_assert_less ( var, _element_fe_var.size() );
769  fe = libmesh_cast_ptr<FEGenericBase<OutputShape>*>( _element_fe_var[var] );
770 }
771 
772 inline
773 FEBase* FEMContext::get_element_fe( unsigned int var ) const
774 {
775  libmesh_assert_less ( var, _element_fe_var.size() );
776  return libmesh_cast_ptr<FEBase*>( _element_fe_var[var] );
777 }
778 
779 template<typename OutputShape>
780 inline
781 void FEMContext::get_side_fe( unsigned int var, FEGenericBase<OutputShape> *& fe ) const
782 {
783  libmesh_assert_less ( var, _side_fe_var.size() );
784  fe = libmesh_cast_ptr<FEGenericBase<OutputShape>*>( _side_fe_var[var] );
785 }
786 
787 inline
788 FEBase* FEMContext::get_side_fe( unsigned int var ) const
789 {
790  libmesh_assert_less ( var, _side_fe_var.size() );
791  return libmesh_cast_ptr<FEBase*>( _side_fe_var[var] );
792 }
793 
794 template<typename OutputShape>
795 inline
796 void FEMContext::get_edge_fe( unsigned int var, FEGenericBase<OutputShape> *& fe ) const
797 {
798  libmesh_assert_less ( var, _edge_fe_var.size() );
799  fe = libmesh_cast_ptr<FEGenericBase<OutputShape>*>( _edge_fe_var[var] );
800 }
801 
802 inline
803 FEBase* FEMContext::get_edge_fe( unsigned int var ) const
804 {
805  libmesh_assert_less ( var, _edge_fe_var.size() );
806  return libmesh_cast_ptr<FEBase*>( _edge_fe_var[var] );
807 }
808 
809 
810 } // namespace libMesh
811 
812 #endif // LIBMESH_FEM_CONTEXT_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:05 UTC

Hosted By:
SourceForge.net Logo