GRINS-0.8.0
List of all members | Public Member Functions | Private Attributes
GRINS::PressurePinning Class Reference

Class to hold typical boundary condition methods. More...

#include <pressure_pinning.h>

Public Member Functions

 PressurePinning (const GetPot &input, const std::string &physics_name)
 
 ~PressurePinning ()
 
void check_pin_location (const libMesh::MeshBase &mesh)
 Check the mesh to ensure pin location is found. More...
 
void pin_value (libMesh::DiffContext &context, const bool request_jacobian, const GRINS::VariableIndex var, const double penalty=1.0)
 The idea here is to pin a variable to a particular value if there is a null space - e.g. More...
 

Private Attributes

libMesh::Number _pin_value
 Value of pressure we wish to pin. More...
 
libMesh::Point _pin_location
 Location we want to pin the pressure. More...
 
libMesh::dof_id_type _pinned_elem_id
 Cache element id for element that contains _pin_location. More...
 

Detailed Description

Class to hold typical boundary condition methods.

This class holds functions to apply generic versions of Dirichlet and Neumann boundary conditions.

Definition at line 52 of file pressure_pinning.h.

Constructor & Destructor Documentation

GRINS::PressurePinning::PressurePinning ( const GetPot &  input,
const std::string &  physics_name 
)

Definition at line 42 of file pressure_pinning.C.

References _pin_location, and _pin_value.

44  : _pinned_elem_id(libMesh::DofObject::invalid_id)
45  {
46  _pin_value = input("Physics/"+physics_name+"/pin_value", 0.0 );
47 
48  unsigned int pin_loc_dim = input.vector_variable_size("Physics/"+physics_name+"/pin_location");
49 
50  // If the user is specifying a pin_location, it had better be at least 2-dimensional
51  if( pin_loc_dim > 0 && pin_loc_dim < 2 )
52  {
53  std::cerr << "Error: pressure pin location must be at least 2 dimensional"
54  << std::endl;
55  libmesh_error();
56  }
57 
58  _pin_location(0) = input("Physics/"+physics_name+"/pin_location", 0.0, 0 );
59 
60  if( pin_loc_dim > 1 )
61  _pin_location(1) = input("Physics/"+physics_name+"/pin_location", 0.0, 1 );
62 
63  if( pin_loc_dim == 3 )
64  _pin_location(2) = input("Physics/"+physics_name+"/pin_location", 0.0, 2 );
65 
66  return;
67  }
libMesh::Point _pin_location
Location we want to pin the pressure.
libMesh::dof_id_type _pinned_elem_id
Cache element id for element that contains _pin_location.
libMesh::Number _pin_value
Value of pressure we wish to pin.
GRINS::PressurePinning::~PressurePinning ( )

Definition at line 69 of file pressure_pinning.C.

70  {
71  return;
72  }

Member Function Documentation

void GRINS::PressurePinning::check_pin_location ( const libMesh::MeshBase &  mesh)

Check the mesh to ensure pin location is found.

If the pin location is found, we set _pin_location_found to true (for assertion later). If not found, we throw an error.

Definition at line 74 of file pressure_pinning.C.

References _pin_location, and _pinned_elem_id.

Referenced by GRINS::VariablePinning::auxiliary_init().

75  {
76  // We need to reset to invalid_id since this may not be the first time called
77  _pinned_elem_id = libMesh::DofObject::invalid_id;
78 
79  libMesh::MeshBase::const_element_iterator el = mesh.active_local_elements_begin();
80  const libMesh::MeshBase::const_element_iterator end_el = mesh.active_local_elements_end();
81 
82  for ( ; el != end_el; ++el)
83  {
84  const libMesh::Elem* elem = *el;
85 
86  if( elem->contains_point(_pin_location) )
87  {
88  _pinned_elem_id = elem->id();
89  break;
90  }
91  }
92 
93  // If we found the point on one of the processors, then we need
94  // to tell all the others. invalid_id is exceedingly large,
95  // so if we found an element, that id should be the smallest
96  mesh.comm().min( _pinned_elem_id );
97 
98  if( _pinned_elem_id == libMesh::DofObject::invalid_id )
99  {
100  libMesh::err << "ERROR: Could not locate point " << _pin_location
101  << " in mesh!" << std::endl;
102  libmesh_error();
103  }
104  }
libMesh::Point _pin_location
Location we want to pin the pressure.
libMesh::dof_id_type _pinned_elem_id
Cache element id for element that contains _pin_location.
void GRINS::PressurePinning::pin_value ( libMesh::DiffContext &  context,
const bool  request_jacobian,
const GRINS::VariableIndex  var,
const double  penalty = 1.0 
)

The idea here is to pin a variable to a particular value if there is a null space - e.g.

pressure for IncompressibleNavierStokes.

Todo:
pin_location needs to be const. Currently a libMesh restriction.
Todo:
What the hell is the c.get_elem_solution_derivative() all about?

Definition at line 106 of file pressure_pinning.C.

References _pin_location, _pin_value, and _pinned_elem_id.

110  {
111  // Make sure we've called check_pin_location() and that pin location
112  // is in the mesh somewhere
113  libmesh_assert_not_equal_to( _pinned_elem_id, libMesh::DofObject::invalid_id );
114 
116  AssemblyContext &c = libMesh::cast_ref<AssemblyContext&>(context);
117 
118  if( c.get_elem().id() == _pinned_elem_id )
119  {
120  // This is redundant for vast majority of cases, but we trying to
121  // be prepared for cases involving, e.g. mesh motion that we're not
122  // currently handling.
123  if( !c.get_elem().contains_point(_pin_location) )
124  {
125  libmesh_error_msg("ERROR: _pin_location not in the current element!");
126  }
127 
128  libMesh::DenseSubVector<libMesh::Number> &F_var = c.get_elem_residual(var); // residual
129  libMesh::DenseSubMatrix<libMesh::Number> &K_var = c.get_elem_jacobian(var, var); // jacobian
130 
131  // The number of local degrees of freedom in p variable.
132  const unsigned int n_var_dofs = c.get_dof_indices(var).size();
133 
134  libMesh::Number var_value = c.point_value(var, _pin_location);
135 
136  libMesh::FEType fe_type = c.get_element_fe(var)->get_fe_type();
137 
138  libMesh::Point point_loc_in_masterelem =
139  libMesh::FEInterface::inverse_map(c.get_dim(), fe_type, &c.get_elem(), _pin_location);
140 
141  std::vector<libMesh::Real> phi(n_var_dofs);
142 
143  for (unsigned int i=0; i != n_var_dofs; i++)
144  phi[i] = libMesh::FEInterface::shape( c.get_dim(), fe_type, &c.get_elem(), i,
145  point_loc_in_masterelem );
146 
147  for (unsigned int i=0; i != n_var_dofs; i++)
148  {
149  F_var(i) += penalty*(var_value - _pin_value)*phi[i];
150 
152  if (request_jacobian && c.get_elem_solution_derivative())
153  {
154  libmesh_assert (c.get_elem_solution_derivative() == 1.0);
155 
156  for (unsigned int j=0; j != n_var_dofs; j++)
157  K_var(i,j) += penalty*phi[i]*phi[j];
158 
159  } // End if request_jacobian
160  } // End i loop
161  } // End if pin_location
162 
163  return;
164  }
libMesh::Point _pin_location
Location we want to pin the pressure.
libMesh::dof_id_type _pinned_elem_id
Cache element id for element that contains _pin_location.
libMesh::Number _pin_value
Value of pressure we wish to pin.

Member Data Documentation

libMesh::Point GRINS::PressurePinning::_pin_location
private

Location we want to pin the pressure.

Definition at line 78 of file pressure_pinning.h.

Referenced by check_pin_location(), pin_value(), and PressurePinning().

libMesh::Number GRINS::PressurePinning::_pin_value
private

Value of pressure we wish to pin.

Definition at line 75 of file pressure_pinning.h.

Referenced by pin_value(), and PressurePinning().

libMesh::dof_id_type GRINS::PressurePinning::_pinned_elem_id
private

Cache element id for element that contains _pin_location.

We will initalize this to libMesh::DofObject::invalid_id and use that to check whether or not we located an element that contains the _pin_location.

Definition at line 84 of file pressure_pinning.h.

Referenced by check_pin_location(), and pin_value().


The documentation for this class was generated from the following files:

Generated on Tue Dec 19 2017 12:47:32 for GRINS-0.8.0 by  doxygen 1.8.9.1