GRINS-0.8.0
List of all members | Public Member Functions | Protected Attributes | Private Member Functions
GRINS::PostProcessedQuantities< NumericType > Class Template Reference

#include <multiphysics_sys.h>

Inheritance diagram for GRINS::PostProcessedQuantities< NumericType >:
Inheritance graph
[legend]
Collaboration diagram for GRINS::PostProcessedQuantities< NumericType >:
Collaboration graph
[legend]

Public Member Functions

 PostProcessedQuantities (const GetPot &input)
 
virtual ~PostProcessedQuantities ()
 
virtual void init_context (const libMesh::FEMContext &context)
 
virtual libMesh::UniquePtr< libMesh::FEMFunctionBase< NumericType > > clone () const
 
virtual NumericType operator() (const libMesh::FEMContext &context, const libMesh::Point &p, const libMesh::Real time=0.)
 
virtual void operator() (const libMesh::FEMContext &context, const libMesh::Point &p, const libMesh::Real time, libMesh::DenseVector< NumericType > &output)
 
virtual NumericType component (const libMesh::FEMContext &context, unsigned int i, const libMesh::Point &p, libMesh::Real time=0.)
 
unsigned int register_quantity (std::string name)
 Register quantity to be postprocessed. More...
 
virtual void initialize (MultiphysicsSystem &system, libMesh::EquationSystems &equation_systems)
 
virtual void update_quantities (libMesh::EquationSystems &equation_systems)
 

Protected Attributes

std::map< std::string, unsigned int > _quantity_name_index_map
 
std::map< VariableIndex, unsigned int > _quantity_index_var_map
 
MultiphysicsSystem_multiphysics_sys
 
SharedPtr< AssemblyContext_multiphysics_context
 

Private Member Functions

 PostProcessedQuantities ()
 

Detailed Description

template<class NumericType>
class GRINS::PostProcessedQuantities< NumericType >

Definition at line 56 of file multiphysics_sys.h.

Constructor & Destructor Documentation

template<class NumericType >
GRINS::PostProcessedQuantities< NumericType >::PostProcessedQuantities ( const GetPot &  input)

Definition at line 34 of file postprocessed_quantities.C.

35  : libMesh::FEMFunctionBase<NumericType>()
36  {
37  if( input.have_variable("vis-options/output_vars") )
38  {
39 
40  std::cerr << "================================================================================" << std::endl
41  << "WARNING: Detected input variable 'vis-options/output_vars." << std::endl
42  << "WARNING: THIS IS OUTDATED. output_vars is now input within" << std::endl
43  << "WARNING: each Physics section." << std::endl
44  << " Erroring out to make you aware." << std::endl
45  << "================================================================================" << std::endl;
46  libmesh_error();
47  }
48  return;
49  }
template<class NumericType >
GRINS::PostProcessedQuantities< NumericType >::~PostProcessedQuantities ( )
virtual

Definition at line 52 of file postprocessed_quantities.C.

53  {
54  return;
55  }
template<class NumericType>
GRINS::PostProcessedQuantities< NumericType >::PostProcessedQuantities ( )
private

Member Function Documentation

template<class NumericType>
virtual libMesh::UniquePtr<libMesh::FEMFunctionBase<NumericType> > GRINS::PostProcessedQuantities< NumericType >::clone ( ) const
inlinevirtual

Definition at line 51 of file postprocessed_quantities.h.

References GRINS::PostProcessedQuantities< NumericType >::PostProcessedQuantities().

52  {
53  return libMesh::UniquePtr<libMesh::FEMFunctionBase<NumericType> >
54  ( new PostProcessedQuantities(*this) );
55  }
template<class NumericType >
NumericType GRINS::PostProcessedQuantities< NumericType >::component ( const libMesh::FEMContext &  context,
unsigned int  i,
const libMesh::Point &  p,
libMesh::Real  time = 0. 
)
virtual

Definition at line 116 of file postprocessed_quantities.C.

120  {
121  // Check if the Elem is the same between the incoming context and the cached one.
122  // If not, reinit the cached MultiphysicsSystem context
123  if(context.has_elem() && _multiphysics_context->has_elem())
124  {
125  if( &(context.get_elem()) != &(_multiphysics_context->get_elem()) )
126  {
127  _multiphysics_context->pre_fe_reinit(*_multiphysics_sys,&context.get_elem());
128  _multiphysics_context->elem_fe_reinit();
129  }
130  }
131  else if( !context.has_elem() && _multiphysics_context->has_elem() )
132  {
133  // Incoming context has NULL elem ==> SCALAR variables
134  _multiphysics_context->pre_fe_reinit(*_multiphysics_sys,NULL);
135  _multiphysics_context->elem_fe_reinit();
136  }
137  else if( context.has_elem() && !_multiphysics_context->has_elem() )
138  {
139  _multiphysics_context->pre_fe_reinit(*_multiphysics_sys,&context.get_elem());
140  _multiphysics_context->elem_fe_reinit();
141  }
142  //else
143  /* If has_elem() is false for both contexts, we're still dealing with SCALAR variables
144  and therefore don't need to reinit. */
145 
146  libMesh::Real value = 0.0;
147 
148  // Quantity we want had better be there.
149  libmesh_assert(_quantity_index_var_map.find(component) != _quantity_index_var_map.end());
150  unsigned int quantity_index = _quantity_index_var_map.find(component)->second;
151 
153  *(this->_multiphysics_context),
154  p, value );
155 
156  return value;
157  }
virtual void compute_postprocessed_quantity(unsigned int quantity_index, const AssemblyContext &context, const libMesh::Point &point, libMesh::Real &value)
std::map< VariableIndex, unsigned int > _quantity_index_var_map
SharedPtr< AssemblyContext > _multiphysics_context
virtual NumericType component(const libMesh::FEMContext &context, unsigned int i, const libMesh::Point &p, libMesh::Real time=0.)
template<class NumericType >
void GRINS::PostProcessedQuantities< NumericType >::init_context ( const libMesh::FEMContext &  context)
virtual
Todo:
I believe this is redundant because it's done in the project_vector call. Double check.

Definition at line 160 of file postprocessed_quantities.C.

161  {
162  // Make sure we prepare shape functions for our output variables.
164  for( typename std::map<VariableIndex,unsigned int>::const_iterator it = _quantity_index_var_map.begin();
165  it != _quantity_index_var_map.end(); it++ )
166  {
167  libMesh::FEBase* elem_fe = NULL;
168  context.get_element_fe( it->first, elem_fe );
169  elem_fe->get_phi();
170  elem_fe->get_dphi();
171  elem_fe->get_JxW();
172  elem_fe->get_xyz();
173 
174  libMesh::FEBase* side_fe = NULL;
175  context.get_side_fe( it->first, side_fe );
176  side_fe->get_phi();
177  side_fe->get_dphi();
178  side_fe->get_JxW();
179  side_fe->get_xyz();
180  }
181 
182  // Create the context we'll be using to compute MultiphysicsSystem quantities
183  _multiphysics_context.reset( new AssemblyContext( *_multiphysics_sys ) );
185  return;
186  }
std::map< VariableIndex, unsigned int > _quantity_index_var_map
SharedPtr< AssemblyContext > _multiphysics_context
virtual void init_context(libMesh::DiffContext &context)
Context initialization. Calls each physics implementation of init_context()
template<class NumericType >
void GRINS::PostProcessedQuantities< NumericType >::initialize ( MultiphysicsSystem system,
libMesh::EquationSystems &  equation_systems 
)
virtual

Definition at line 78 of file postprocessed_quantities.C.

80  {
81  // Only need to initialize if the user requested any output quantities.
82  if( !_quantity_name_index_map.empty() )
83  {
84  // Need to cache the MultiphysicsSystem
85  _multiphysics_sys = &system;
86 
87  libMesh::System& output_system = equation_systems.add_system<libMesh::System>("interior_output");
88 
89  for( std::map<std::string, unsigned int>::const_iterator it = _quantity_name_index_map.begin();
90  it != _quantity_name_index_map.end();
91  ++it )
92  {
93  unsigned int var = output_system.add_variable( it->first, libMesh::FIRST );
94  _quantity_index_var_map.insert( std::make_pair(var,it->second) );
95  }
96  }
97 
98  return;
99  }
std::map< VariableIndex, unsigned int > _quantity_index_var_map
std::map< std::string, unsigned int > _quantity_name_index_map
template<class NumericType >
NumericType GRINS::PostProcessedQuantities< NumericType >::operator() ( const libMesh::FEMContext &  context,
const libMesh::Point &  p,
const libMesh::Real  time = 0. 
)
virtual

Definition at line 201 of file postprocessed_quantities.C.

204  {
205  libmesh_error();
206  return 0.0; //dummy
207  }
template<class NumericType >
void GRINS::PostProcessedQuantities< NumericType >::operator() ( const libMesh::FEMContext &  context,
const libMesh::Point &  p,
const libMesh::Real  time,
libMesh::DenseVector< NumericType > &  output 
)
virtual

Definition at line 189 of file postprocessed_quantities.C.

192  {
193  for( unsigned int i = 0; i != output.size(); i++ )
194  {
195  output(i) = this->component(context,i,p,time);
196  }
197  return;
198  }
virtual NumericType component(const libMesh::FEMContext &context, unsigned int i, const libMesh::Point &p, libMesh::Real time=0.)
template<class NumericType >
unsigned int GRINS::PostProcessedQuantities< NumericType >::register_quantity ( std::string  name)

Register quantity to be postprocessed.

This method returns an index that will correspond to the name provided. Note that this assumes all quantities are scalar. Thus, if there's a gradient quantity, each component will need to be separately registered.

Definition at line 58 of file postprocessed_quantities.C.

Referenced by GRINS::ElasticMembrane< StressStrainLaw >::register_postprocessing_vars(), GRINS::ElasticCable< StressStrainLaw >::register_postprocessing_vars(), GRINS::ReactingLowMachNavierStokes< Mixture, Evaluator >::register_postprocessing_vars(), GRINS::HeatTransfer< Conductivity >::register_postprocessing_vars(), GRINS::LowMachNavierStokes< Viscosity, SpecificHeat, ThermalConductivity >::register_postprocessing_vars(), GRINS::IncompressibleNavierStokes< Viscosity >::register_postprocessing_vars(), GRINS::AveragedFan< Viscosity >::register_postprocessing_vars(), GRINS::VelocityPenalty< Viscosity >::register_postprocessing_vars(), and GRINS::ParsedVelocitySource< Viscosity >::register_postprocessing_vars().

59  {
60  // Check if this quantity has already been registered
61  if( _quantity_name_index_map.find(name) != _quantity_name_index_map.end() )
62  {
63  std::cerr << "Error: trying to add existing quantity: " << name << std::endl;
64  libmesh_error();
65  }
66 
67  /* We add 1 so that the locally cached indices in each of the Physics
68  can safely initialize the index to zero. In particular this ensures
69  we count starting from 1. */
70  unsigned int new_index = _quantity_name_index_map.size()+1;
71 
72  _quantity_name_index_map.insert( std::make_pair( name, new_index ) );
73 
74  return new_index;
75  }
std::map< std::string, unsigned int > _quantity_name_index_map
template<class NumericType >
void GRINS::PostProcessedQuantities< NumericType >::update_quantities ( libMesh::EquationSystems &  equation_systems)
virtual

Definition at line 102 of file postprocessed_quantities.C.

103  {
104  // Only do the projection if the user actually added any quantities to compute.
105  if( !_quantity_name_index_map.empty() )
106  {
107  libMesh::System& output_system = equation_systems.get_system<libMesh::System>("interior_output");
108  output_system.project_solution(this);
109  }
110 
111  return;
112  }
std::map< std::string, unsigned int > _quantity_name_index_map

Member Data Documentation

template<class NumericType>
SharedPtr<AssemblyContext> GRINS::PostProcessedQuantities< NumericType >::_multiphysics_context
protected

Definition at line 92 of file postprocessed_quantities.h.

template<class NumericType>
MultiphysicsSystem* GRINS::PostProcessedQuantities< NumericType >::_multiphysics_sys
protected

Definition at line 91 of file postprocessed_quantities.h.

template<class NumericType>
std::map<VariableIndex, unsigned int> GRINS::PostProcessedQuantities< NumericType >::_quantity_index_var_map
protected

Definition at line 89 of file postprocessed_quantities.h.

template<class NumericType>
std::map<std::string, unsigned int> GRINS::PostProcessedQuantities< NumericType >::_quantity_name_index_map
protected

Definition at line 88 of file postprocessed_quantities.h.


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

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