libMesh
dg_fem_context.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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_DG_FEM_CONTEXT_H
21 #define LIBMESH_DG_FEM_CONTEXT_H
22 
23 // Local Includes
24 #include "libmesh/fem_context.h"
25 
26 
27 namespace libMesh
28 {
29 
39 class DGFEMContext : public FEMContext
40 {
41 public:
42 
46  explicit
47  DGFEMContext (const System & sys);
48 
52  virtual ~DGFEMContext ();
53 
59  virtual void side_fe_reinit () libmesh_override;
60 
67 
71  const std::vector<dof_id_type> & get_neighbor_dof_indices() const
72  { return _neighbor_dof_indices; }
73 
78  const std::vector<dof_id_type> & get_neighbor_dof_indices( unsigned int var ) const
79  { return _neighbor_dof_indices_var[var]; }
80 
85  { return _neighbor_residual; }
86 
91  { return _neighbor_residual; }
92 
97  const DenseSubVector<Number> & get_neighbor_residual( unsigned int var ) const
98  { return *(_neighbor_subresiduals[var]); }
99 
105  { return *(_neighbor_subresiduals[var]); }
106 
111  { return _elem_elem_jacobian; }
112 
117  { return _elem_elem_jacobian; }
118 
123  const DenseSubMatrix<Number> & get_elem_elem_jacobian( unsigned int var1, unsigned int var2 ) const
124  { return *(_elem_elem_subjacobians[var1][var2]); }
125 
130  DenseSubMatrix<Number> & get_elem_elem_jacobian( unsigned int var1, unsigned int var2 )
131  { return *(_elem_elem_subjacobians[var1][var2]); }
132 
137  { return _elem_neighbor_jacobian; }
138 
143  { return _elem_neighbor_jacobian; }
144 
149  const DenseSubMatrix<Number> & get_elem_neighbor_jacobian( unsigned int var1, unsigned int var2 ) const
150  { return *(_elem_neighbor_subjacobians[var1][var2]); }
151 
156  DenseSubMatrix<Number> & get_elem_neighbor_jacobian( unsigned int var1, unsigned int var2 )
157  { return *(_elem_neighbor_subjacobians[var1][var2]); }
158 
163  { return _neighbor_elem_jacobian; }
164 
169  { return _neighbor_elem_jacobian; }
170 
175  const DenseSubMatrix<Number> & get_neighbor_elem_jacobian( unsigned int var1, unsigned int var2 ) const
176  { return *(_neighbor_elem_subjacobians[var1][var2]); }
177 
182  DenseSubMatrix<Number> & get_neighbor_elem_jacobian( unsigned int var1, unsigned int var2 )
183  { return *(_neighbor_elem_subjacobians[var1][var2]); }
184 
189  { return _neighbor_neighbor_jacobian; }
190 
195  { return _neighbor_neighbor_jacobian; }
196 
201  const DenseSubMatrix<Number> & get_neighbor_neighbor_jacobian( unsigned int var1, unsigned int var2 ) const
202  { return *(_neighbor_neighbor_subjacobians[var1][var2]); }
203 
208  DenseSubMatrix<Number> & get_neighbor_neighbor_jacobian( unsigned int var1, unsigned int var2 )
209  { return *(_neighbor_neighbor_subjacobians[var1][var2]); }
210 
220  void set_neighbor(const Elem & neighbor)
221  { _neighbor = &neighbor; }
222 
226  const Elem & get_neighbor() const
227  { return *_neighbor; }
228 
232  bool dg_terms_are_active() const
233  { return _dg_terms_active; }
234 
238  template<typename OutputShape>
239  void get_neighbor_side_fe( unsigned int var, FEGenericBase<OutputShape> *& fe ) const;
240 
241 private:
242 
246  const Elem * _neighbor;
247 
252 
261 
265  std::vector<DenseSubVector<Number> *> _neighbor_subresiduals;
266  std::vector<std::vector<DenseSubMatrix<Number> *>> _elem_elem_subjacobians;
267  std::vector<std::vector<DenseSubMatrix<Number> *>> _elem_neighbor_subjacobians;
268  std::vector<std::vector<DenseSubMatrix<Number> *>> _neighbor_elem_subjacobians;
269  std::vector<std::vector<DenseSubMatrix<Number> *>> _neighbor_neighbor_subjacobians;
270 
274  std::vector<dof_id_type> _neighbor_dof_indices;
275  std::vector<std::vector<dof_id_type>> _neighbor_dof_indices_var;
276 
284  std::map<FEType, FEAbstract *> _neighbor_side_fe;
285 
290  std::vector<FEAbstract *> _neighbor_side_fe_var;
291 
297 };
298 
299 template<typename OutputShape>
300 inline
302 {
303  libmesh_assert_less ( var, _neighbor_side_fe_var.size() );
304  fe = cast_ptr<FEGenericBase<OutputShape> *>( _neighbor_side_fe_var[var] );
305 }
306 
307 } // namespace libMesh
308 
309 #endif // LIBMESH_FEM_CONTEXT_H
std::vector< dof_id_type > _neighbor_dof_indices
Global Degree of freedom index lists for the neighbor element.
DenseMatrix< Number > & get_neighbor_neighbor_jacobian()
Non-const accessor for element Jacobian.
DenseVector< Number > _neighbor_residual
Residual vector of the neighbor component.
DenseMatrix< Number > _elem_elem_jacobian
The DG Jacobian terms.
void neighbor_side_fe_reinit()
Initialize neighbor side data needed to assemble DG terms.
DenseMatrix< Number > & get_neighbor_elem_jacobian()
Non-const accessor for element Jacobian.
ImplicitSystem & sys
DenseSubMatrix< Number > & get_elem_elem_jacobian(unsigned int var1, unsigned int var2)
Non-const accessor for element-element Jacobian of particular variables corresponding to the variable...
std::vector< std::vector< dof_id_type > > _neighbor_dof_indices_var
std::map< FEType, FEAbstract * > _neighbor_side_fe
Finite element objects for each variable&#39;s sides on the neighbor element.
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
const DenseSubMatrix< Number > & get_elem_neighbor_jacobian(unsigned int var1, unsigned int var2) const
Const accessor for element-neighbor Jacobian of particular variables corresponding to the variable in...
std::vector< FEAbstract * > _neighbor_side_fe_var
Pointers to the same finite element objects on the neighbor element, but indexed by variable number...
The libMesh namespace provides an interface to certain functionality in the library.
DenseMatrix< Number > & get_elem_elem_jacobian()
Non-const accessor for element-element Jacobian.
const Elem & get_neighbor() const
Accessor for current neighbor Elem object for assembling DG terms.
Defines a dense subvector for use in finite element computations.
bool dg_terms_are_active() const
Are the DG terms active, i.e.
DenseVector< Number > & get_neighbor_residual()
Non-const accessor for neighbor residual.
std::vector< std::vector< DenseSubMatrix< Number > * > > _elem_elem_subjacobians
void set_neighbor(const Elem &neighbor)
Set the neighbor element which we will use to assemble DG terms.
std::vector< std::vector< DenseSubMatrix< Number > * > > _neighbor_neighbor_subjacobians
std::vector< std::vector< DenseSubMatrix< Number > * > > _elem_neighbor_subjacobians
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
DenseMatrix< Number > & get_elem_neighbor_jacobian()
Non-const accessor for element -neighborJacobian.
Defines a dense submatrix for use in Finite Element-type computations.
DenseMatrix< Number > _neighbor_elem_jacobian
This class extends FEMContext in order to provide extra data required to perform local element residu...
const DenseSubMatrix< Number > & get_neighbor_neighbor_jacobian(unsigned int var1, unsigned int var2) const
Const accessor for neighbor-neighbor Jacobian of particular variables corresponding to the variable i...
const DenseSubMatrix< Number > & get_neighbor_elem_jacobian(unsigned int var1, unsigned int var2) const
Const accessor for neighbor-element Jacobian of particular variables corresponding to the variable in...
This class provides all data required for a physics package (e.g.
Definition: fem_context.h:61
void get_neighbor_side_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for neighbor edge/face (2D/3D) finite element object for variable var.
DenseMatrix< Number > _elem_neighbor_jacobian
const DenseMatrix< Number > & get_elem_neighbor_jacobian() const
Const accessor for element-neighbor Jacobian.
const DenseMatrix< Number > & get_neighbor_elem_jacobian() const
Const accessor for element-neighbor Jacobian.
const DenseSubMatrix< Number > & get_elem_elem_jacobian(unsigned int var1, unsigned int var2) const
Const accessor for element-element Jacobian of particular variables corresponding to the variable ind...
const DenseMatrix< Number > & get_elem_elem_jacobian() const
Const accessor for element-element Jacobian.
const std::vector< dof_id_type > & get_neighbor_dof_indices() const
Accessor for neighbor dof indices.
bool _dg_terms_active
Boolean flag to indicate whether or not the DG terms have been assembled and should be used in the gl...
const Elem * _neighbor
Current neighbor element for assembling DG terms.
DenseSubMatrix< Number > & get_elem_neighbor_jacobian(unsigned int var1, unsigned int var2)
Non-const accessor for element-neighbor Jacobian of particular variables corresponding to the variabl...
DenseSubMatrix< Number > & get_neighbor_elem_jacobian(unsigned int var1, unsigned int var2)
Non-const accessor for neighbor-element Jacobian of particular variables corresponding to the variabl...
std::vector< std::vector< DenseSubMatrix< Number > * > > _neighbor_elem_subjacobians
DGFEMContext(const System &sys)
Constructor.
DenseMatrix< Number > _neighbor_neighbor_jacobian
std::vector< DenseSubVector< Number > * > _neighbor_subresiduals
Element residual subvectors and Jacobian submatrices.
DenseSubMatrix< Number > & get_neighbor_neighbor_jacobian(unsigned int var1, unsigned int var2)
Non-const accessor for neighbor-neighbor Jacobian of particular variables corresponding to the variab...
const DenseSubVector< Number > & get_neighbor_residual(unsigned int var) const
Const accessor for neighbor residual of a particular variable corresponding to the variable index arg...
virtual ~DGFEMContext()
Destructor.
const std::vector< dof_id_type > & get_neighbor_dof_indices(unsigned int var) const
Accessor for element dof indices of a particular variable corresponding to the index argument...
virtual void side_fe_reinit() libmesh_override
Override side_fe_reinit to set a boolean flag so that by default DG terms are assumed to be inactive...
const DenseVector< Number > & get_neighbor_residual() const
Const accessor for neighbor residual.
DenseSubVector< Number > & get_neighbor_residual(unsigned int var)
Non-const accessor for neighbor residual of a particular variable corresponding to the variable index...
const DenseMatrix< Number > & get_neighbor_neighbor_jacobian() const
Const accessor for element-neighbor Jacobian.
This class forms the foundation from which generic finite elements may be derived.